running psql on iot devices - · pdf file“things” with microcontroller board...

21
Confidential © 2016 Actian Corporation Confidential © 2016 Actian Corporation Running PSQL on IoT Devices Sunil Jacob – Product Architect Actian Technical User Group Conference October 11 2016

Upload: dinhdung

Post on 05-Mar-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

Confidential © 2016 Actian Corporation1 Confidential © 2016 Actian Corporation

Running PSQL on IoT Devices

Sunil Jacob – Product ArchitectActian Technical User Group ConferenceOctober 11 2016

Confidential © 2016 Actian Corporation2

Confidential © 2016 Actian Corporation3

1. Embedded devices – SoC (System on Chip)

■ Example : microchip size of a shirt button for wearable devices for movement tracking and gesture recognition

2. Mobile devices

■ Example : mobile phone, iPad

3. “Things” with microcontroller board

■ Example : smart refrigerator uses microcontroller to read real-time temperature, control buzzer for alerts, LCD display.

4. Mini 32/64 bit single-board computing platforms

■ Example : Raspberry Pi (ARM), MinnowBoard MAX (Intel)

What are IoT devices?

Confidential © 2016 Actian Corporation4

Where do PSQL fit?

Confidential © 2016 Actian Corporation5

Confidential © 2016 Actian Corporation6

A single-board computer that is most likely.

A. Raspberry Pi X (ARM)

B. MinnowBoard MAX (Intel)

Operating system on single-board computer that is most likely.

A. Raspbian (ARM)

B. Windows IoT Core (Intel and ARM)

What would make a IoT Gateway machine?

Confidential © 2016 Actian Corporation7

Why ARM CPU support is important?

■ The primary difference between ARM and X86 processors is that ARM processors follow a RISC (Reduced Instruction Set Computer) architecture, while x86 processors are CISC (Complex Instruction set Architecture).

■ ARM is a simpler architecture, resulting in small silicon portion and a lot of energy saving and with modern design changes that have resulted in a significantly faster chip speed.

■ Qualcomm becomes the latest vendor to build a server chip using the ARM architecture, which is widely used in smartphones and tablets. Some believe ARM can challenge x86 in the data center because of its low-power characteristics.

■ If you want an ARM chip for PCs or servers, AMD can make it. If you want x86, AMD has that, too. AMD officials have stressed the importance of versatility many times over the last two years. AMD's business relies on x86, but the company has stocked up on ARM technology, which could explode into servers and embedded devices in the coming years. Intel makes only x86chips and doesn't have its sights on ARM.

■ Intel’s Krzanich describes that strategy as one that will “transform our company from a PC company to a company that powers the cloud and billions of smart, connected computing devices.” In short, a transition echoing the one Microsoft is also navigating. Call it the Wintel playbook for surviving in the 21st Century.

Confidential © 2016 Actian Corporation8

PSQL is a DBMS that is:

Small install footprint, less than 30 MB

Run with low memory requirements – could be less than 256 MB

Uses lossless compression

Simple application development support both NoSQL and SQL

Require absolutely no administration

Able to network multiple gateways together

Supports ARM and Intel CPUs

Supports Raspbian and Windows IoT Core (Intel and ARM)

What makes PSQL v13 an IoT Gateway Database?

PSQL is powerful enough to ingest, process and aggregate

data in real-time!

Confidential © 2016 Actian Corporation9

Demos

PSQL on Raspberry Pi3 – Raspbian

PSQL on MinnowBoard – Windows IoTCore

PSQL on Raspberry Pi3 – Raspbian

Confidential © 2016 Actian Corporation10

Raspberry PI 3 running Raspbian (based on Debian Linux)

Sense HAT add-on board – used in an education outreach program in the UK.

Sensors for temperature, pressure, humidity.

Accelerometer, Gyroscope

Demo program uses Python ‘sense_hat’ library

Demo 1 – Raspberry Pi 3

Confidential © 2016 Actian Corporation11

Record Structure for Sensor Data

class RECORD(ctypes.Structure):_pack_ = 1_fields_ = [ ("timestamp", ctypes.c_uint64),

("direction", ctypes.c_float),("temperature", ctypes.c_float),("humidity", ctypes.c_float),("pressure", ctypes.c_float)]

Inserting new sensor data into data file

def put(self, timestamp, direction, temperature, humidity, pressure):"""Insert a new record with the specified attribute values."""record = self.RECORD()record.timestamp = ts_to_uint64(timestamp)record.direction = directionrecord.temperature = temperaturerecord.humidity = humidityrecord.pressure = pressureself.hdl.Insert(record)

Confidential © 2016 Actian Corporation12

Reading records using Python generators- Special kind of function that contains yield statements (returns a generator iterator)- ‘yield’ suspends processing, saves execution state and returns

def iterator(self):try:

self.hdl.GetFirst(record, keynum=keynumts = ts_from_uint64(record.timestamp)yield ts,record.direction,record.temperature,\

record.humidity, record.pressurewhile True:

self.hdl.GetNext(record)ts = ts_from_uint64(record.timestamp)yield ts,record.direction,record.temperature,\

record.humidity, record.pressureexcept btrieve.EndOfFileError:

pass

Using the generator

for timestamp,direction,temp,humidity,pressure indatafil.iterator():

# Use the retrieved values

Confidential © 2016 Actian Corporation13

Demos

PSQL on Raspberry Pi3 – Raspbian

PSQL on MinnowBoard – Windows IoTCore (Intel)

PSQL on Raspberry Pi3 – Raspbian

Confidential © 2016 Actian Corporation14

Windows IOT Core – version of Windows 10

Minnowboard MAX – Intel Atom E3800

PSQL prototype (x86) – Workgroup engine running on Minnowboard MAX.

Demo retrieves data from Minnowboard MAX.

Demo 2 - PSQL on Windows IOT Core

Confidential © 2016 Actian Corporation15

Demos

PSQL on Raspberry Pi3 – Raspbian

PSQL on MinnowBoard – Windows IoTCore (Intel)

PSQL on Raspberry Pi3 – Raspbian

Confidential © 2016 Actian Corporation16

Raspberry PI 3 running Raspbian (based on Debian Linux)

PSQL port to Raspbian.

Demo 3 - PSQL on Raspbian

Confidential © 2016 Actian Corporation17

Image Data Record Header

class RECORD(ctypes.Structure):_pack_ = 1_fields_ = [ ("timestamp", ctypes.c_uint64),

("seqnum", ctypes.c_uint32),("size", ctypes.c_uint32)]

Image date follows header (variable length)

Inserted/Retrieved using chunk operations

Demo 3 - PSQL on Raspbian

Confidential © 2016 Actian Corporation18

Demo program

- Uses separate threads for image processing, Btrieve data file operations.

- Uses OpenCV for image processing

- Images captured from Pi Camera

- Each frame is compared with the average frame (rolling)

- Contours of changed regions.

- Motion detected if contour area greater than threshold.

- Frame is queued for ‘Save Thread’ to operate on

- Frame saved to Btrieve data file.

Demo 3 - PSQL on Raspbian

Confidential © 2016 Actian Corporation19

Thank You!

Confidential © 2016 Actian Corporation20

Confidential © 2016 Actian Corporation21

This document is for informational purposes only and is subject to change at any time without notice. The information in this document is proprietary to Actian and no part of this document may be reproduced, copied, or transmitted in any form or for any purpose without the express prior written permission of Actian.

This document is not intended to be binding upon Actian to any particular course of business, pricing, product strategy, and/or development. Actian assumes no responsibility for errors or omissions in this document. Actian shall have no liability for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials. Actian does not warrant the accuracy or completeness of the information, text, graphics, links, or other items contained within this material. This document is provided without a warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, or non-infringement.