Professor Training Day 1 (II)

scacchicgardenΛογισμικό & κατασκευή λογ/κού

13 Δεκ 2013 (πριν από 3 χρόνια και 3 μήνες)

73 εμφανίσεις

Professor Training Day 1 (II)


QNX Reference Platform

How to Customize

March 15, 2012

A subsidiary of Research In Motion Limited

2

QNX Confidential. All content copyright QNX Software Systems.

Agenda

Introduction of the Reference Platform:

installing the software to run on the BeagleBoard

installing the VMware image

Identifying the Demo Components

Navigating the file system

Persistent Publish/Subscribe

Customizing

splash screen location

modifying the room configurations

resource managers

How to build Flash based applications

FlashDevelop

Adobe Flash Professional

loading it onto the Reference Platform

how to change UI behavior

A subsidiary of Research In Motion Limited

Tools Required for customization

QNX Momentics Integrated Development Environment

Software Development Platform v6.5.0

http://www.qnx.com/

Add HMI player

Adobe Creative Suite 5 (CS5)

Adobe Flash Professional

http://www.adobe.com/


FlashDevelop

http://www.flashdevelop.org/


VMware Workstation/VMware Player

optional, if target hardware is not available

http://www.vmware.com/

3

QNX Confidential. All content copyright QNX Software Systems.

QNX Reference Platform


A subsidiary of Research In Motion Limited

5

QNX Confidential. All content copyright QNX Software Systems.

Network

Powerline

Communications

Insteon

Server

Dimmer

Controllers


IP Camera

Zigbee
Gateway

Utility
Simulator

Zigbee Sensors

Temperature & Humidity

Smart Meter

Load
Switches

Weather, Flickr,
Pandora, etc.

QNX Smart Energy Reference Design Configuration

A subsidiary of Research In Motion Limited

6

QNX Confidential. All content copyright QNX Software Systems.

Demo platform used in this course …

BeagleBoard

http://beagleboard.org

VMware Workstation

http://www.vmware.com/

A subsidiary of Research In Motion Limited

7

QNX Confidential. All content copyright QNX Software Systems.

Using the BeagleBoard

The Foundry27 home page is located at:

http://www.qnx.com/products/reference
-
design/

Scroll down to the “
Smart energy in
-
home display section


Select the “
TI BeagleBoard (OMAP 3530) with Lilliput 8” touch screen



A subsidiary of Research In Motion Limited

8

QNX Confidential. All content copyright QNX Software Systems.

Downloading the BeagleBoard Software Image

Simply register to download this software package, and follow the on
screen instructions to download


A subsidiary of Research In Motion Limited

9

QNX Confidential. All content copyright QNX Software Systems.

Creating the Software FileSystem for the BeagleBoard

Once the reference platform software package has been
downloaded, the
beagle_lilliput_SmartEnergy_v1.3.5_external.zip

file
will contain the following files:

README.txt

UNZIP_TO_FAT32_USB_DEVICE.zip

smartER_alpha.pdf

smartEnergyCtrl.swf


Simply unzip the contents of the
UNZIP_TO_FAT32_USB_DEVICE.zip

archive onto a FAT formatted SD card. The recommended minimum
size of the SD card is 2 GB

A subsidiary of Research In Motion Limited

10

QNX Confidential. All content copyright QNX Software Systems.

Setting up the BeagleBoard hardware

Lilliput Display

BeagleBoard

USB Hub

Power Cable

USB

mini AB

Cable

Lilliput

HDMI/USB Cable

SD Card

Linksys

USB300M

Network



Serial RS232
Interface


to DB9
connector

A subsidiary of Research In Motion Limited

11

QNX Confidential. All content copyright QNX Software Systems.

Configuring the BeagleBoard

If this is the first time you use the BeagleBoard, you will need to
program the on board u
-
boot to automatically load the QNX
Reference Platform image on start up. The instructions are as
follows:

Connect to the serial console (115200bps, 8N1)

Boot the OMAP3530 board

When uboot has started, enter the following commands:

# setenv bootdelay 1


This command sets a one second boot delay.

# setenv bootcmd 'mmc init 1;fatload mmc 1 0x80200000
beagle.ifs
;go
0x80200000'


where
beagle.ifs

is the OMAP 3530 (Beagle) IFS file that was installed on
the SD card on the previous slide

# saveenv

The boot sequence is now saved and will execute when you restart
the board


A subsidiary of Research In Motion Limited

12

QNX Confidential. All content copyright QNX Software Systems.

Running the Reference Platform on the BeagleBoard

To launch the SmartEnergy
QNX Reference Platform
software on the
BeagleBoard:

Press and hold the User
button (S1) in order to
enable USB

Power on the
BeagleBoard, or press the
Reset button (S2)

After approximately 10
seconds, release the User
button (S1)

When the QNX Reference
Platform image appears on
your screen, the board has
completed start up
successfully


RESET (S2)

USER (S1)

User (S1)

Reset (S2)

A subsidiary of Research In Motion Limited

13

QNX Confidential. All content copyright QNX Software Systems.

QNX Smart Energy Reference Platform Home Screen

A subsidiary of Research In Motion Limited

14

QNX Confidential. All content copyright QNX Software Systems.

Using VMware

The Foundry27 home page is located at:

http://www.qnx.com/products/reference
-
design/

Select and download the file:

vmware_SmartEnergy_1.3.5_2010
-
06
-
07.iso


A subsidiary of Research In Motion Limited

15

QNX Confidential. All content copyright QNX Software Systems.

Downloading the VMware Installation Image

Simply register to download this software package, and follow the on
screen instructions to download


A subsidiary of Research In Motion Limited

QNX Confidential. All content copyright QNX Software Systems.

Creating the VMware Image










A subsidiary of Research In Motion Limited

17

QNX Confidential. All content copyright QNX Software Systems.

Installing the Reference Platform

Once the New VM Wizard has finished, it will automatically start the
new Virtual Machine that was just created. It will boot the ISO image
that was specified, and the Reference Platform install process will
begin

Demo Components


A subsidiary of Research In Motion Limited

19

QNX Confidential. All content copyright QNX Software Systems.

Home Screen

Weather Info

Lighting Control

Video Surveillance

Looking at the individual UI components

A subsidiary of Research In Motion Limited

20

QNX Confidential. All content copyright QNX Software Systems.

Energy Usage

Detailed Monthly Energy Usage

Energy Management

Editing Energy Rules

Looking at the individual UI components

A subsidiary of Research In Motion Limited

Reference Design Software Architecture


Flash Lite 3 Player

PPS

SQL

Power

Scheduler

SQL

SQLite

Energy Usage

Database

PPS

Flash Player Extensions

Insteon

Lighting

PPS


HVAC

Controll
er

PPS


MPG4

Mediaplayer

PPS


Load

Switches

PPS


Smart

Meter

PPS


Flash

Action Script

C/C++

Drivers &
Applications

Zigbee

Sensors

PPS


Navigating the Reference Platform File System


A subsidiary of Research In Motion Limited

23

QNX Confidential. All content copyright QNX Software Systems.

Accessing the Reference Platform File System

BeagleBoard

via the serial console

connect using Hyperterminal or putty

configured for 115200 8N1

the IP address can be determined using “ifconfig”


VMware

via Q
-
NET

use the remote shell command: “on

f HOMEUNIT_vmware sh”

the IP address can be determined using “/proc/boot/ifconfig”


The best method of connecting to the Reference Platform, whether it is
BeagleBoard or VMware, is via the “telnet” utility, or using the QNX
Momentics IDE

via telnet

require prior knowledge of the IP address as determined above

username and password are both “root”

A subsidiary of Research In Motion Limited

24

QNX Confidential. All content copyright QNX Software Systems.

Once in …

The launch environment of the Reference Platform is not stored into the
IFS image, and must be loaded each time you log in

to setup the running environment:

cd /qnx
-
ia/scripts

. ./env.sh


If for any reason, the Reference Platform is not operating correctly, the
factory default condition can be restored by running the clean
-
up script

once logged into the Reference Platform:

cd /qnx
-
ia/scripts

./clean_target.sh


You can now examine the environment inside the Reference Platform

A subsidiary of Research In Motion Limited

25

QNX Confidential. All content copyright QNX Software Systems.

Location of important files

File Type

BeagleBoard

VMware

IFS image

/beagle.ifs

/.boot/vmware.ifs

Script files

/qnx
-
ia/scripts

/qnx
-
ia/scripts

Flash files

/qnx
-
ia/runtime

/qnx
-
ia/runtime

PPS files

/fs/etfs/var/pps

/fs/pps

/var/pps

/fs/pps

Persistent Publish / Subscribe


A subsidiary of Research In Motion Limited

27

QNX Confidential. All content copyright QNX Software Systems.

Persistent Publish Subscribe Interface

The communication channel which the
Resource Managers
uses to
provide feedback information to the User Interface

Arranged in files

One file for each category of information

Usually located in “/fs/pps/…”


PPS





Insteon

Lighting

HVAC

Controll
er

MPG4

Mediaplayer

Load

Switches

Smart

Meter

Zigbee

Sensors

Manager

A subsidiary of Research In Motion Limited

2010/06/22 R11

28

PPS

Persistent Publish and Subscribe:

is a low volume, one
-
to
-
many IPC mechanism

a publisher supplies data

subscriber(s) are given the data, or notified that the data is available

the
pps

manager handles the data, notification, and persistence

the API is (primarily) POSIX file access:
open()
,
read()
,
write()
,
select()
, etc

is used by much of the QNX HMI framework

A subsidiary of Research In Motion Limited

2010/06/22 R11

29

PPS

The
pps

server:

manages the names in the pathname space

current implementation registers at
/pps

by default

requires an underlying file system for the persistent storage

e.g. a disk or flash based file system

stores data/attributes when a publisher writes them to an object

notifies subscribers when data on an object has changed

A subsidiary of Research In Motion Limited

2010/06/22 R11

30

PPS

Objects and Attributes

each file is an object

each object will have attributes associated with it

attributes may be created, deleted, or modified

more than one publisher can change the same attribute, or different
attributes of the same object

an attribute is a string:


<attribute_name>:<encoding>:<value>
\
n


name and encoding may contain alpha
-
numerics or underscore and period


value can be any characters except null or linefeed

can easily be read with
cat

for debugging


A subsidiary of Research In Motion Limited

2010/06/22 R11

31

PPS
-

subscriber

A subscriber:

opens the object for READ

may request notification of attribute changes:

ionotify()

can request a signal or pulse on change

select()

can be used to block until change on one or more objects or other
fds

a read() will return the current object state

reads default to non
-
blocking, treating the object like a file

can be set to blocking with
fcntl()

or by opening the object
“?wait”

appended to the name

A subsidiary of Research In Motion Limited

2010/06/22 R11

32

A read() will return:

object name, and attributes, general format:




e.g.






the encoding, meaning, and parsing of the attributes is user
-
defined

PPS
-

subscriber

@<object_name>

<attr1_name>:<encoding>:<attribute_one_value>

<attr2_name>:<encoding>:<attribute_two_value>

@Current_Position

lat::45.417266

long::
-
75.696895

address::221 Bank Street

city::Ottawa,Ontario,Canada

A subsidiary of Research In Motion Limited

2010/06/22 R11

33

PPS
-

publisher

Data is published with
write()
:

one or multiple attributes can be changed with a single
write()

an attribute can be deleted by preceding its name with a minus sign,
e.g.:

echo “
-
address” >> /pps/Current_Position

all attributes of an object are deleted if the object is open
O_TRUNC

echo anything > /pps/object


will do this!

all subscribers will be notified of changes as appropriate

A subsidiary of Research In Motion Limited

34

QNX Confidential. All content copyright QNX Software Systems.

How is PPS used in the Reference Platform?

Recall that the current working copies of PPS files are located in
“/fs/pps”

We can contribute to the input data by using command line
operations to simulate actual behaviour of the Resource Managers

cat /fs/pps/hvac/zone0_state

echo “currentTemp::21.5” >> /fs/pps/hvac/zone0_state


A subsidiary of Research In Motion Limited

35

QNX Confidential. All content copyright QNX Software Systems.

How does PPS really work here?

Recall that the current working copies of PPS files are located in
“/fs/pps”

We can contribute to the input data by using command line
operations to simulate actual behaviour of the Resource Managers

cat /fs/pps/hvac/zone1_state

echo “currentTemp::21.5” >> /fs/pps/hvac/zone1_state


The control and data for the various “zones” are controlled by the
following set of Resource Managers:

hvac


overall control for each zone

Motor
-
1


environment control

EnvSensor


sensor input

insteon
-
mgr


lighting control and sensor

These Resource Managers are launched via the “ia.sh” script

A subsidiary of Research In Motion Limited

36

QNX Confidential. All content copyright QNX Software Systems.

Interaction between PPS and Resource Manager

Examine the contents of the PPS files

“cat /fs/pps/hvac/zone1_state”


As you modify these configurations for the “Main” room

Change the set temperature

Change the light dimmer level

Change the light switch position


Customizations


A subsidiary of Research In Motion Limited

38

QNX Confidential. All content copyright QNX Software Systems.

Splash Screen

The splash image is configured by default as

${HMIROOT}/usr/share/wallpaper/std_splash.png”

A subsidiary of Research In Motion Limited

39

QNX Confidential. All content copyright QNX Software Systems.

Exercise


changing the Splash Image

The Splash Image can be changed by:

overwriting the current image file

changing the launch script to point to a different file


This image is located in “${HMIROOT}/usr/share/splash”

Change image to one with customer logo

A subsidiary of Research In Motion Limited

40

QNX Confidential. All content copyright QNX Software Systems.

Room Controls


Temperature & Lighting

The majority of the behaviour configuration are stored in:

${HMIROOT}/scripts/ia.sh

${HMIROOT}/etc/ia.cfg


The room names are configured by:

IA_ZONE_x_HVAC_OPTS


The startup temperature setting are set by:

IA_ZONE_x_SENSOR_OPTS

IA_ZONE_x_MOTOR_OPTS


The lights are controlled by:

IA_ZONE_x_NUM_LIGHTS=y

IA_ZONE_x_LIGHT_y_OPTS

A subsidiary of Research In Motion Limited

41

QNX Confidential. All content copyright QNX Software Systems.

Exercise


Room Controls

Modify these files

${HMIROOT}/scripts/ia.sh

${HMIROOT}/etc/ia.cfg








Change the room names

Change the number of rooms

Change the default set temperature

Change the number of lights per room

Change the type of lights in a room

Collaborative real home deployment implementation

A subsidiary of Research In Motion Limited

42

QNX Confidential. All content copyright QNX Software Systems.

Resource Managers


In the source package that is being provided, the resource managers
are found in:

./drivers/src


Examine the source file to learn how the communications interface
between a Flash UI and the Resource Manager is performed

How to post results to the PPS Interface

How to provide APIs for the ASE Interface

Handling the input from the ASE APIs

A subsidiary of Research In Motion Limited

43

QNX Confidential. All content copyright QNX Software Systems.

Exercise


Resource Managers


Modify some of the behaviour of a resource manager, and test it out
on the target


example:

the way the temperature is being updated

the controller for the light timers

add a new entry to the PPS



Building the Flash Applications


A subsidiary of Research In Motion Limited

45

QNX Confidential. All content copyright QNX Software Systems.

Project File



The Action Script Extension 2 project file has a file extension of
“as2proj”

The top level project file for the Smart Energy Reference Platform is

SmartEnergyPanel.as2proj

It is located in:

./hmi/as2/src/industrial/demos/smartenergy/teknision


Open this file using FlashDevelop

or double click on it

A subsidiary of Research In Motion Limited

46

QNX Confidential. All content copyright QNX Software Systems.

FlashDevelop

A subsidiary of Research In Motion Limited

47

QNX Confidential. All content copyright QNX Software Systems.

Flash UI Content

A subsidiary of Research In Motion Limited

48

QNX Confidential. All content copyright QNX Software Systems.

Adobe Flash Professional

A subsidiary of Research In Motion Limited

49

QNX Confidential. All content copyright QNX Software Systems.

Adding the Flash UI, Building the Project

right mouse click …

A subsidiary of Research In Motion Limited

50

QNX Confidential. All content copyright QNX Software Systems.

exporting the Flash SWF file


SWF file

The file built by FlashDevelop is located at:

./hmi/as2/src/industrial/demos/smartenergy/teknision/bin

This file is to be copied onto the target at:

/qnx
-
ia/runtime/applications/SmartEnergyPanel_Teknision


Copying the file

For the BeagleBoard target, this file can be copied directly onto the
SD Flash memory card

For the VMware demo, this file will need to be transferred via FTP, or
via Q
-
NET

Connect the BeagleBoard or VMware demo target to the Momentics
IDE, and use the “Target File System Navigator” window (found in the
“System Information” perspective) to transfer the file

A subsidiary of Research In Motion Limited

51

QNX Confidential. All content copyright QNX Software Systems.

Exercise


changing the Flash UI


This is not a training course on how to use Flash, so only simple
modifications will be made


Demonstrate using Flash Professional:

how to modify the UI

what modifications can be made

building the UI


Exercise

Add a component on the display that will be updated based on PPS
data

Take an existing UI that is fairly simple, and add a simple push button
action to it


A subsidiary of Research In Motion Limited

52

QNX Confidential. All content copyright QNX Software Systems.

Exercise


modifying Action Script Extension


Again, this is not a training course on how to write ASE2 code


Demonstrate using FlashDevelop:

How to read from PPS entries

How to update the UI according to PPS entries

APIs for the resource manager to interface to ASE

How to take the UI inputs, and link them to the APIs


Exercise

Create PPS entry, and post updates to Flash UI

Take the added button push added in the previous exercise in
customizing UIs, and interface them to the resource manager


Questions