POWER-KI a programming language. Preludio

Page 1

POWER-KI

®

©

a programming language

XPLAB research in automation

Preludio


POWER-KI Ⓡ - a programming language. Preludio Author: C.A.Perani Copyright Ⓒ 2012 by XPLAB s.a.s - Brescia - Italy All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Information in this document is subject to change without notice and does not represent a commitment on the part of XPLAB s.a.s.. The software described in this document is an original creation of the Author; it is furnished under a license agreement or nondisclosure agreement. The software may be used or copied only in accordance with the terms of the agreement. No licenses, express or implied, are granted with respect to any of the technology described in this document. XPLAB retains all intellectual property rights associated with the technologies described in this document. POWER-KI Ⓡ is a registered trademark of XPLAB s.a.s. ISBN 978-88-907392-0-0

Even though XPLAB has reviewed this document, XPLAB MAKES NO WARRANTY OR REPRESENTATION, EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THIS DOCUMENT, ITS QUALITY, ACCURACY, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. AS A RESULT, THIS DOCUMENT IS PROVIDED “AS IS,” AND YOU, THE READER, ARE ASSUMING THE ENTIRE RISK AS TO ITS QUALITY AND ACCURACY. IN NO EVENT WILL XPLAB BE LIABLE FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES RESULTING FROM ANY DEFECT OR INACCURACY IN THIS DOCUMENT, even if advised of the possibility of such damages. THE WARRANTY AND REMEDIES SET FORTH ABOVE ARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORAL OR WRITTEN, EXPRESS OR IMPLIED. No XPLAB dealer, agent, or employee is authorized to make any modification, extension, or addition to this warranty. Some states do not allow the exclusion or limitation of implied warranties or liability for incidental or consequential damages, so the above limitation or exclusion may not apply to you. This warranty gives you specific legal rights, and you may also have other rights which vary from state to state.



preludio

a

X


Symbols are substitutes of entities, real or abstract. Thought is the processing of symbols. A language consists of symbols, structures, and rules. Programming languages differ from natural languages in that they involve explicitly the concept of flow. They must not only describe a model, but also set the flow of the elaboration. They must tell the computer how to think. Programming is considered by many to be a work of technicians that, in strict compliance with rules, generate applications that often make us feel a little stupid. Instead it requires high creativity, especially to develop Intelligent Applications. The developer is however conditioned by the language used, which often implement simple paradigms: lists, objects, structures, and thus force him to comply with this view. Reality is multifaceted and can only be properly described with a language that is equally versatile. POWER-KI arises from a very long work, with the purpose to provide such a language, to allow the programmer not to deform his/her thought patterns to fit a tool, but freed from many constraints, can explore new ways of thinking, to develop, in less time, powerful applications. We are just at the prelude, many things have yet to emerge. From our experience of these last two years of development of important POWER-KI projects, we are confident that those who will approach this language, will find a new world: powerful, comfortable, relaxing, more fun. Enjoy. Cesare A. Perani


The intended audience of this book, is that of software architects, engineers, programmers. It is not intended as a tutorial for beginners. It should preferably be read from beginning to end. Without the anxiety of having to understand everything at once. The concepts included in gray blocks can be read in no particular order. The color becomes darker when a sequential read is instead preferable. We hope that this book will become your mentor, in the early stage of your use of POWER-KI.


Introduction Components and Software WorkBench Executor GUI Graphic User Interface The many ways to say “Hello World” The Language


introduction

POWER-KI is an innovative language, thanks to the sum of the many original ideas and features that characterize it.

These concepts, the basis for the use of POWER-KI as a platform for Intelligent Applications development, are inspired by the functionality of the human brain.

The Language A POWER-KI Assembly is a data structure, in the form of a forest of items, each one of them capable to contain other items, growing in this way like a tree. The execution engine, depending on the Item type, will run it as an instruction or will treat it as a data container. To each item can be associated attributes containing untyped data.

WorkBench Unlike traditional programming languages it is not possible to write applications without using the PWK's development environment: the WorkBench. A great effort has been done to make it comfortable, productive and complete with everything required by the programmer to manage any aspect of the production cycle.


From editing, code and user interfaces, testing, debugging, documentation to distribution steps. The professional version is also provided for the management of user licenses. WorkBench supports and assists the programmer with a number of active instruments such active parser, assistant editor and assistant function, which can dramatically reduce the amount of typed code and the greater part of common grammatical or syntactical errors. The code entry can be made almost entirely from the keyboard with a minimal use of the mouse. Test mode can be activated for individual components of the code, allowing for immediate work verification. Debug Tool, multithreading oriented, provides, easily, immediate feedback useful for troubleshooting.

POWER-KI Applications , in the form of packages, are easily manageable in distribution and installation. All these elements together ensure high productivity with minimum levels of stress, both mentally and physically.

GUI The decoupling between the execution engine and the User Interface allows to easily create native CLOUD applications, providing a viable alternative to web applications, often limited, difficult to maintain and manage, as constituted by a set of technologies not entirely homogeneous. (howerer HTTP LIB provides powerful functions for web app).

AGILE Developers using the AGILE methodology, w i l l fi n d i n P O W E R - K I a p e r f e c t development tool.


Components and Software


© PTW

PDC

Ⓒ 2012 XPLAB - Research in Automation - Page 11


.PKA

Files extensions identify POWER-KI components. Executable code

Assembly

.PKI

Graphic User Interface Code

Interface

.PWK Package

.BSK Basket Š

Executable Package: executable code + graphic user interface + resources

WorkBench Reusable code

.PTW

Tool & Wiz definition file

Tool & Wiz

.PDC Debug conf

Debug configuration


Wo r k B e n c h i s t h e I n t e g r a t e d PWK-WBK-01 Developing Environment for POWER-KI applications. It contains all the functions for WorkBench editing both Assembly and GUI, Package manager, Wiz&Tool, test and debug, generation of documentation. WorkBench is highly ergonomical.

The Executor is the run time engine of POWER-KI applications. PWK-EXC-00 It is started automatically by clicking on a PKA or PWK component or Executor with a direct command line invocation. In the last case the User must provide the name of the executable as parameter and the additional required parameters.

The GUI Graphics User Interface PWK-GUI-X01 provides its services both to Executor and to the WorkBench. Due to loose coupling, the GUI can Graphic User Interface be located on a different hardware with respect with the invoker. Started directly, with the right parameters, it can act as a client interface for applications like PWK Enterprise Server. â’¸ 2012 XPLAB - Research in Automation - Page 13


WorkBench


WorkBench

Package

manager

GUI Editor

Assembly Editor

Tools & Wiz

Test & Debug

Doc Creator

PTW

©

Ⓒ 2012 XPLAB - Research in Automation - Page 15


License type and purpose

ACCEPT Button

License ID

Developer ID

Starting WorkBench, the window of the license , clearly indicating its type and purpose, appears. Below is shown the license and User ID, needed for upgrades. Clicking the ACCEPT button, you accept our EULA (End User License Agreement) so you can start using WorkBench. Clicking the DECLINE button you exit from WorkBench.


MAIN Menu

Alive

Minimize

Show License

Rearranges windows

Close

Close windows

WorkBench Main menu usually appears on the top left of the screen.

â’¸ 2012 XPLAB - Research in Automation - Page 17


Package Manager

package name Add new Section

Main Assembly System Sections

User added Section

Package Directory

Attrubutes/ Values

Commercial Options

Double Click to open directory window


Package is an executable product of WorkBench, containing all that is needed by the application.

Package manager has three parts: directory, attribute/values and, for commercial licenses, commercial options.

The default Directory contains three system sections: - ASSEMBLY (.pka), - UserInterface (.pki) - Resources used within .pki. The User can add new sections for application use.

Double clicking on a directory item, open it with the default manager: Editor for Assemblies, GUI Editor for user interface, specific application, if available, for resources and others.

To each file is associated a symbolic name and that name is used inside Assemblies.

The MAIN item of the directory, defines the Assembly to start at application launch.

SAVE button and AutoSave option store the package in the default work directory at “C:\PWK-PRG” and , if defined, in the StorageDirectory.

SAVE VERSION button stores in the StorageDirectory a copy of the package with the file name extended with date and time.

DEPLOY button, if DeployDirectory is defined, publishes the package.

EXPORT PSC saves in the default directory the POWER-KI SECURE CERTIFICATE (PSC). Ⓒ 2012 XPLAB - Research in Automation - Page 19


GUI Editor

Selected Item

Usable Items

Item path

Item Name

Click To GoTo Package Mng

Item type double click to change

Default Tree Level expansion

Attribute/value doubleClick to edit window

Page Tree Drag & Drop sub items Wizard

Basket for Item re-use

Lock autoselection of item after insertion


A root item of type FORM, is inserted by default in page tree.

To p o p u l a t e t h e F O R M , DragAndDrop usable or basket item on the insert area or, if the FORM is not empty, on the tree.

FORM Tree

Inside Assembly, an Item Attribute can be referred with the syntax:

FORM ELM1

ELM11 ELM12

Usable items

Resource

ELM21 ELM22

path: \FORM\ELM2\ELM22

attribute@ItemPath

Data Item Container

ELM2

The Item that you add to another will appear in the s e l e c t i o n . To a v o i d t h i s behavior, use LOCK botton.

Double Click on an attribute value to open the window to edit it.

Property Component

Wizard are programs that automate the making of parts or elements of the GUI. Wiz product is poured in the basket.

â’¸ 2012 XPLAB - Research in Automation - Page 21


LIVE

Mouse position

Event

key Code

Signal

Mouse item LIVE panel Active item

Selected item

GUI OnLive


Press the LIVE button to show the GUI and the live panel.

In LIVE you can’t add or delete Item.

Attribute

Value

GUI

Live Action

+ Action

CLICK LEFT

Changes of attribute values are reflected in realTime on the GUI. Changes made on the GUI are reflected in the attribute value.

Effects Select the Item

CLICK LEFT

MOUSE MOVE

Select and Move the item

CLICK RIGHT

MOUSE MOVE

Select and change Item size

CLICK LEFT

UP ARROW

Select the parent Item

CLICK RIGHT

UP ARROW

Select the parent Item

CLICK RIGHT

Edit Text (if Item with Text)

If SNAP is enabled, changes in size or position of the items, made on the GUI are rounded with snap XY values.

Ⓒ 2012 XPLAB - Research in Automation - Page 23


ASSEMBLY Editor

Update for changes of GUI or LIB

Click To GoTo Package Mng

Usable Items

ASSEMBLY Tree

Basket for item re-use

Wizard


To populate the Assembly Tree, DragAndDrop usable or basket item on the tree or on the insert area, in this case the Item will be added to the end of the tree.

REFRESH EXTERNAL button update GUI or LIB reference inside the Assembly for changes occurred after its opening.

Mouse Action

+ Action

Wizard are programs that automate the making of parts or elements of the Assembly. Wiz product is poured in the basket.

Condition

Effects

Click to Expand CLICK LEFT

when not selected

CLICK LEFT

when selected

Open Item Editor

when selected (wait till a new label appears)

item Move

CLICK LEFT

HOLD and MOVE

CLICK RIGHT

Select the Item

Open Option Put a copy in the Basket Open Item Editor Test (EXO only)

Index

Delete Item Item Type

CLICK RIGHT Item Options â’¸ 2012 XPLAB - Research in Automation - Page 25


Item Editor

Item Identification and comment

Click To GoTo Assembly

Attribute / Value

Usable Item

Code editor

Item Tree


To populate the Item tree, DragAndDrop usable or basket item on the tree or on the insert area to add to the tree end.

KEYBOARD ITEM INSERTION Select a row in the tree, keep ALT pressed and digit a few letters of the Item that you want to insert, in the same order as they appear in the item name. When only ONE usable element name is visible, press ENTER and it will be added to the tree.

â’¸ 2012 XPLAB - Research in Automation - Page 27


ITEM NAME

Only Item with PUBLIC clause are visible from external Assembly.

ITEM TYPE

PUBLIC PRIVATE clause

Comment can be inserted directly or, doubleClicking, from an edit page.

Name: PREFIX

Name: LABEL

Item Name can be in the form: PREFIX:LABEL

Comment

DoubleClick to Insert a new Row or to delete an empty one

Value and Comment: DoubleClick to edit in a separate window

for MATRIX type, Label contains the dimensions

TYPE column appears only for Item of type: EXO, EXO_SYNC, MTHD The choice is between: SET, GET, SET+GET, DAT , “ ”(as SET+GET)


Include Lib and Gui in the search

ITEM NAME

LOCAL / GLOBAL

Symbol Search Window is displayed when:

You add items of the type: TRUE, FALSE, ONERR, GOTO, SWITCH, CALL, EXEC, EXEC_SYNC, THREAD You double click on Item Name and the type is: TRUE, FALSE, ONERR, GOTO, SWITCH, CALL, EXEC, EXEC_SYNC, THREAD

You press INDIR button (types: EXEC, EXEC_SYNC, THREAD)

Ⓒ 2012 XPLAB - Research in Automation - Page 29


CODE Editing

Mouse Action

+ Action

Condition

Effects

CLICK LEFT

when not selected

CLICK LEFT

when selected

Open Item Editor

when selected (wait till a new label appears)

Item Move

CLICK LEFT CLICK RIGHT

HOLD and MOVE

Select the Item

Open Option


Automatic Syntax Highlight

CODE in editing

comment Function

Constant ÂŁitteral Constant

comment Unrecognized

â’¸ 2012 XPLAB - Research in Automation - Page 31


ALT+ UP/DOWN Arrow matching symbols list

Function Help

Library

Library functions

Board

Effects Navigate inside matching symbol List

RIGHT arrow

Add to the editing symbol one char from the current matching symbol

LEFT arrow

Remove from the editing symbol the last added char

SPACE

Add to the editing symbol all letters up to the first PATH delimiter

ENTER

Select current symbol in list

B

Break the code in two

C

Copy the selection in EA board

V

Paste from EA Board

F

Open the Function Editor Assistant

G

Show GLOBAL symbol

L

Show LOCAL symbol


DoubleClick Function Parameters to edit window

â’¸ 2012 XPLAB - Research in Automation - Page 33


TEST Debug Enabled

Exec/Stop

DoubleClick Function Attributes to edit window Program Consolle output


Select TEST from EXO option or press TEST button and DragAndDrop the EXO in test textbox.

ERROR : doubleClick on the $index$

Chat provides an iteractive way of data exchange with the executing program.

LOAD button reloads EXO attributes/values from code.

In TEST mode: the program tree will be expanded to show the code. In EDIT mode: the Item editor will be opened

STOP button END program execution

â’¸ 2012 XPLAB - Research in Automation - Page 35


DEBUG Control Panel

Program trace

Break Point

Threads

Console Messages

Errors


POWER-KI DEBUG is a powerful tool designed to provide the Programmer with an instrument to help in the debugging of a complex multi-thread environment.

Enable/Disable Step mode

Thread in STEP

In STEP mode program is executed line by line. In DELAY mode each line is executed with the ms delay specified GO button: execution of the next line

Delay Execution

ms

Line Index

SKIP button : inner ITEM code lines are executed continuosly.

â’¸ 2012 XPLAB - Research in Automation - Page 37


Thread ID

Line in execution

TRACE: enable trace mode, (only one thread at a time). The line in execution is traced on the program tree. STEP: enable step mode, (only one thread at a time). BREAK: enable break.

BREAK POINTS can be set manually or with CTRL CLICK on the program tree.

ALWAYS : any thread that reaches the index is stopped, even if it does not have break checked.

GS (GO STEP): automatically enable STEP mode for the breaked thread.

GO: program execution resume.


DoubleClick on a tree line to open the CODE or the Item INSPECTOR, from which one can see the values of the attributes of all item instances.

â’¸ 2012 XPLAB - Research in Automation - Page 39


DOCUMENTATION


POWER-KI DOCUMENTATION generate a complete printable document of the developed application. DOC windows provides also an alternative way to navigate inside the application. In fact its interactive nature allows not only the standard operation, like search, but also , with a doubleclick or pressing ENTER on a line, to open the relative ITEM editor. Use the REFRESH button to update after code changes.

â’¸ 2012 XPLAB - Research in Automation - Page 41


Tools & Wiz

Tools & Wiz are POWER-KI applications that extend or automate the functions of WorkBench.

USER TW are searched in : C:\PWK-PRG\TW

Show PTW builder

Scan for new


WIZ products are purged in the basket.

If you choose one “Tool Ask For” option, when the tool will be started you will be asked to select a file of that type.

Path of ASSEMBY or Package

Ⓒ 2012 XPLAB - Research in Automation - Page 43


strange things

Adding a SWITCH type item causes the opening of its editor, with the _DEFAULT_ case already inserted. Any addition of CASEs.

new attributes determines the automatic insertion of new


A Commercial License gives you the opportunity to protect your work and to distribute it safely.

If the Package or ASSEMBLY is protected by a PASSWORD (function obtainable only with a Commercial License), you will be prompted to its insertion when you will try to open it.

Check PassWord and insert it to enable password protection. Checking License File and giving the file name, enables your application to be executed only if the User has a license file. If Unique is checked for each installation a specific license must be used. If Demo is checked the program can be enabled to work in demo mode. Licenses are built with PWK-LIC-MNG-xx.pwk provided as tool to Commercial Licensees.

â’¸ 2012 XPLAB - Research in Automation - Page 45


Executor


User/Program

PWK-EXC-00

OS

â’¸ 2012 XPLAB - Research in Automation - Page 47


POWER-KI EXECUTOR can be directly invoked from the command line, or indirectly by clicking the .PWK or .PKA applications through the service provided by operative System. In direct invocation the name of the application to start should be inserted in the command line.

Package

MAIN If .PWK EXECUTOR search the main .PKA GUIs declared in .PKA with _AUTOLOAD_= ON are loaded.

LIB

\pwk\Executor

LIBraries declared in .PKA are loaded.

EXO GUI

The EXO declared in EXO@\pwk\Executor is started.


EXECUTOR behavior is mainly controlled by the values of the attributes of the \pwk\Executor VAR

Message Box

StartUp Logo is displayed if enabled STARTLOGO@\pwk\Executor or if an error is detected.

StarUp Errors Code

Description

Meaning

0

General Error

1

Empty parameter list

EXECUTOR has been invoked without parameters

2

Error loading: wrong program

The program (first command line parameter) is not a valid POWER-KI Assembly

3

EXECUTOR ITEM not found

\pwk\Executor was not found in the Assembly

4

EXECUTOR EXO not defined

EXO@\pwk\Executor is not defined

5

EXO main not found

The EXO specified in EXO@\pwk\Executor does not exists in the Assembly

6

Already executing

Another instance is executing and LIMIT_ONCE@\pwk\Executor is set

7

LIC file not found or invalid

The application needs a license

XXX

LIC for XXX code required

The application needs a Unique license for XXX code

â’¸ 2012 XPLAB - Research in Automation - Page 49


POWER-KI RunTime Console is displayed if : CONS@\pwk\Executor = YES CONS@\pwk\Executor = PROG programmatically when the function CONS(ÂŁSHOW) is executed Chat Output

Chat Input

Message Console

With : KEEPOPEN@\pwk\Executor = YES after the end of the execution the Console remains visible.

Error Console

End The program


With: CONS_OS@\pwk\Executor = YES Operative System console is shown.

For POWER-KI command line application, you can control parent console behavior setting CONS_OS_PARENT@\pwk\Executor

CONS_OS_PARENT@\pwk\Executor CONTINUE

Parent continues execution

SUSPEND

Parent execution is suspended

TERMINATE

Parent execution is terminated

â’¸ 2012 XPLAB - Research in Automation - Page 51


GUI Graphic User Interface


â’¸ 2012 XPLAB - Research in Automation - Page 53


GUI Graphic User Interface provides its services both to WorkBench and to Executor, but can also be used as a client to connect to POWER-KI cloud applications.

GUI Command Line PWK-GUI-X01.EXE

Open on Port

Remote Address

Remote Port

Type

GUI Command Line Parameters #

Description

Meaning

0

GUI Executable

PWK-GUI-X01.EXE

1

Open on Port

The port number on which the gui will be opened. 0 = use default port

2

Remote Address

3

Remote Port

Peer connection parameter. Address can be a dotted IP or URL. If % an intranet broadcast search or PWK-EnterpriseServer is dispatched

4

Connection Type

Choose ACT, for intranet connection, PSV for internet (PWK-ES)

5

...

...


Using % as remote address, activates broadcast search of PWK-ES. If more than one are discovered, a Server List is proposed to make the choice.

2012 XPLAB PWK-ES-01 1332007611 : READ, WRITE, EXECUTE

In remote mode, peer request to READ, WRITE, EXECUTE are signaled to the User. This way he/she has the option to block any unwanted or malicious action. To allow remote peer operations in a trusted way, a POWER-KI Secure Certificate (PSC) of the requesting application could be installed on the GUI computer in PWK-PRG directory.

To restore the standard GUI behavior the User has only to delete the PSC. To limit peer allowed actions, simply remove from PSC the unwanted one.

â’¸ 2012 XPLAB - Research in Automation - Page 55


O L L E H D L R O W the many ways to say “Hello World”


â’¸ 2012 XPLAB - Research in Automation - Page 57


1

On OS console

2

On PWK chat

1 2 3

1

3

On PWK console


2

3

â’¸ 2012 XPLAB - Research in Automation - Page 59


4

On a window

5

On a web page


4

4

5

4

4 5

â’¸ 2012 XPLAB - Research in Automation - Page 61


POWER-KI® ©

The Language


â’¸ 2012 XPLAB - Research in Automation - Page 63


ITEM

A POWER-KI Assembly can be thought of as s forest of trees.

ITEM ITEM

Each tree is an Item which in turn contains other Items.

ITEM ITEM

ITEM ITEM ITEM ITEM

ITEM ITEM

ITEM

POWER-KI eXecutable ITEMs (XI):

EXO

EXO sync

MTHD


Item Category data

MTHD

executable MTHD

execution container unconditional flow conditional flow

EXO EXO sync

comment support

MTHD

allowed entries

code â’¸ 2012 XPLAB - Research in Automation - Page 65


Names of ITEMs beginning and ending with “_” (underscore) are reserved

Each ITEM can have attributes to contain :

SYMBOL

A SYMBOL can be: Numerical value Not Numerical Value

ITEMs inside assemblies are indicated by PATH which can be ABSOLUTE or RELATIVE to the item in which they are considered.

NV NNV

ABSOLUTE

\item\item\item

RELATIVE

item\item\item


A V1

1

E V3

V1=1; !! IMPLICIT; V2@C=2; !! RELATIVE; V3@\E=3;!! ABSOLUTE;

B

@

C 3 V2

2

V1=1; !! IMPLICIT; V4=4; V3@\E=3;!! ABSOLUTE;

D V4

In Assemblies attributes can be referenced as:

ABSOLUTE

att@\item\item\item

RELATIVE

att@item\item\item

IMPLICIT

att

4

RELATIVE and IMPLICIT references are resolved with respect to the XI under which the containing Item falls.

If the XI is a MTHD, the resolution process is extended to the parent ITEM (types: EXO, VAR, GUI, MTX).

â’¸ 2012 XPLAB - Research in Automation - Page 67


A V1

B

X

V1

1

D V2

2 B

D V2

X

A B S O L U T E a n d R E L AT I V E references are solved TOP/DOWN with the first found item.

V1

V1@B=1; V2@\D=2; V1=3;

C X

V1

3

IMPLICIT references are solved BOTTOM/UP with the first found item.


Curly braces indicate an indirect reference, the level of indirection is equal to the number of couples of braces.

A V1

1

B

{V2@C}=2;

Indirection can be set for only the path or, if indicating an attribute, for all. C

att@{xxx}

V2 V1

{xxx}

RunTime Reference can be created and then used whith REF function.

A A

V3

P

\E

B

REF(A++’@’++P)=3

E V3

3

V3@\E

Ⓒ 2012 XPLAB - Research in Automation - Page 69


ITEM TYPES


VAR

DATA can be stored in VAR Item.

When an Assembly is created an ITEM of type VAR named pwk is inserted by default. It contains two VAR: Editor - controlling editor behavior, Executor - with execution setting.

MATRIX

MTX are expanded by Executor and addressable by index.

In the example info Item has three dimensions, the size of the first is two, of the second is four, of the third is five.

v1@\info:[1,a,2]= 10;

Square Brackets operator transforms the expression item:[1,2,3] in item_1_2_3 . Any inside expression is solved before transformation.

At runTime Executor expands the MTX in copies of the declared Item.

â’¸ 2012 XPLAB - Research in Automation - Page 71


GUI

Maps the Graphics User Interface in the assembly

When a GUI Item is added to the assembly tree, the Editor prompts you to choose the .PKI from the package or from the default PWK-PRG directory.

GUI Item is pre-filled with attributes to control GUI loading, event management, and in which status informations are posted. A trig MTHD item is inserted as skeleton for event management,

If _AUTOLOAD_= ON Executor tries to load the GUI before starting the execution of the program.

If _AUTOLOAD_ Is empty the GUI should be loaded programmatically using GUI_ library functions.


GUI _AUTOLOAD_

trig

_ADDR_ _PORT_ _TRIG_ _PTR_

FORM B

_EVT_ _SIGNAL_ Events Status

C

_PTH_ITEM_ _ITEM_ _PTH_ITEM_ACT_

DATA link

FORM data are mapped and exist on Assembly when (and while) the GUI is loaded. After this, they are connected so any change to FORM data is sent to GUI and viceversa.

â’¸ 2012 XPLAB - Research in Automation - Page 73


EXO

EXO_Sync

EXecutable Object

EXecutable Object Synchronous

EXOs , the workhorse of POWER-KI, are the entry point of Assembly execution.

MTHD

Method

Method is executable code usable within EXOs and DATA item that have the local visibility of the container Item.

XI (eXecutable Item) attributes are tagged with a TYPE that define they use in invocation (see EXEC).


EXEC

Execution invocation

EXEC_Sync

Execution invocation Synchronous

A D1

DAT

D2

DAT

B

B set

V1=D1;

get

D2=V2;

B

V1

SET

V2

GET

V3

DAT

â’¸ 2012 XPLAB - Research in Automation - Page 75


THREAD

Thread invocation. A new execution flow is started.

A D1

DAT

D2

DAT

B set

B V1

B SET

V1=D1;


Synchronization

POWER-KI provides “SYNC” for sinchronization. Within CODE Items User can use SYS_ library functions to manage SEMAPHOREs, DOORs and wait for conditions.

If EXO is invoked for execution, a new copy of the EXO is created. NO ASSUMPTIONS should be made with respect to values of attributes other than those set from the calling. Attributes are NOT ADDRESSABLE outside the EXO.

EXO_sync is statically available so it retains attribute values between calls.

Access to EXO_sync is allowed on one thread at a time basis.

Invoking EXO with EXEC_sync allows only one thread at a time to execute it.

Threads waiting for sync are served on first arrived order.

Ⓒ 2012 XPLAB - Research in Automation - Page 77


CALC

Execute a computation

Item name must be an attribute containing the code. _SET_. Current XI item is assumed for reference.

BREAK

Result is put in the attribute referenced by

Break the execution flow

When the execution reaches this Item and _LEVEL_ attribute is not defined: Inside a WHILE or a SWITCH item, break the item and flow resume to the next item. Inside an XI break it.

if _LEVEL_ is defined, the flow resumes to the next item, which follows the first item, of type _LEVEL_, found going up the path.

END

End execution

When the execution reaches this Item, END.


A

D1

D1

D2+1

D2

1

D3

2

(Calc)

_SET_

while

D3

do break

break LBL

while

do

break _LEVEL_

LBL

END â’¸ 2012 XPLAB - Research in Automation - Page 79


LBL

Label

LBLs provide explicit target point for unconditional flow command. They also give a way to group related parts of the assembly. The content of the LBL is in the program execution flow.

BLOCK

Block

The contents of BLOCKs is NOT in the program execution flow. They can be reached by means of the execution of an unconditional flow command.

GOTO

Unconditional Flow change

Any visible item inside the current XI can be the target of a GOTO jump.

CALL

Unconditional Flow change with Return

The Item BLOCK is the usual target of the CALL. After the CALL, execution resumes with the next item.


block

call

goto

LBL

â’¸ 2012 XPLAB - Research in Automation - Page 81


FALSE = 0 or NULL

ERROR = < 0 or NULL

NNV are FALSE if NULL or EMPTY

NNV used as NV gives always 0


TRUE

Conditional Execution

The name of the TRUE should be the reference of a visible attribute, if its value is TRUE contained are executed.

FALSE

Items

Conditional Execution

The name of the FALSE should be the reference of a visible attribute, if its value is FALSE Items contained are executed.

ONERR

Conditional Execution

The name of the ONERR should be the reference of a visible attribute, if its value is ERROR Items contained are executed.

â’¸ 2012 XPLAB - Research in Automation - Page 83


WHILE

Conditional loop

WHILE the value of the attribute _COND_ is TRUE the items belonging to DO are executed.

SWITCH

Conditional branch

The name of the SWITCH should be the reference of a visible attribute. Its value is compared with the values of the SWITCH attributes. For each equality, the contained item that has the same name of the attribute is executed. If no match is found the _DEFAULT_ item is executed instead.


IF

Conditional Execution

IF the value of the attribute _COND_ is TRUE the items contained in THEN are executed, if FALSE the ELSE items are executed instead.

WHILE and IF have equivalents in the SYS_ LIB functions. #WHILE(X); ............;#END; #IF(X); ....; #ELSE; ...#END; For IF there is also a conditional assignement function: a=If( X, true, false);

â’¸ 2012 XPLAB - Research in Automation - Page 85


COMMENT

Comment

With this you can document your Assembly.

TEMPLATE

To ease code writing

The TEMPLATE purpose is to give a way to add prebuilt structures of ITEMs. Its use is very simple: 1) add the TEMPLATE to the Assembly tree; 2) add to the TEMPLATE the needed items; 3) When you will add a TEMPLATE to an item, only its content, in the proper order, is inserted.


LIBRARY

External code

LIBRARY provides the way to use external developed Assemblies. Only ITEMs declared with the clause PUBLIC are visible. If protected by PASSWORD there is no way to open it with WorkBench. External LIBRARY ITEMs are mapped under the LIBRARY item.

CODE

The code

Within ITEM CODE, the developer can use LIB functions and operators documented in: PWK-MAN-LIB-CORE PWK-MAN-GUI

â’¸ 2012 XPLAB - Research in Automation - Page 87


CODE SAMPLE


Each Statement ends with semicolon. Comments begin with double or triple exclamation points, and end with semicolon.

Functions names, usually begin with the name of the LIB, with the exception of functions belonging to SYS_.

Symbols beginning with £ are literal: £TRUE = “TRUE”

Ⓒ 2012 XPLAB - Research in Automation - Page 89


GUI

Simple GUI

The package contains the .PKI which is mapped in the Assembly in a GUI item called HW with _AUTOLOAD_ = ON. To manage GUI message the TRIG attribute point to the trig MTHD of HW.

72

The £SHOW message tells GUI to show.

74

The text of the label is set to “Hello World!”.


81

The thread will loop until stop is not FALSE.

28

35

The trig is invoked by any GUI message.

When _EVT_ = WIND_CLS stop attribute at main is set to 1, in this way the assembly can exit from the while and thus terminate.

â’¸ 2012 XPLAB - Research in Automation - Page 91


HTTP

Create a Web Server

In the example web pages are contained in the package, in the user section dati with name WEB.

77

Build the real path, linking package path with the path of inside web folder.

79

Web server is created on port 80, then the pointer(PTR) web is used to start the service.


SYS

References

+1

â’¸ 2012 XPLAB - Research in Automation - Page 93


DB Search inside a Data Base table.

Sql Data Base


28

In the example we assume that the Client table has at least three columns: NAME, SURNAME, AGE

Open the Data Base type SQLite

34

39

Get number of rows

49

For each row, print results.

â’¸ 2012 XPLAB - Research in Automation - Page 95


DOC Fill a table in a Open Document.

Open Document Format (ODF)


141

From a template create a new document.

146

Search the table: ”Table1”

151

Fill Table cells.

Ⓒ 2012 XPLAB - Research in Automation - Page 97


KB1

knowledge base

Insert and extract information from a KB1

209

Open the KB


214

Insert and extract data

219

Print query result on the chat

â’¸ 2012 XPLAB - Research in Automation - Page 99


I: “Why don’t you read me the last story? “ X: “Because it’s not there” I: “But there must be the 101’s !” X: “No, it’s a zen book. They are one hundred”. ®

(X and I , an age ago)

XPLAB s.a.s. Acknowledgments The thoughtful criticisms and suggestions of coleagues, in particular eng. Luca Trevisson, have helped to improve POWER-KI. For the friendly help in the review of this book we thanks eng. C. Benzon and dr. Maurizio Annibaletto.

research in automation brescia - italy www.xplab.net www.power-ki.com © 2012 - XPLAB all rights reserved POWER-KI®, XPOLYPLUS®

Cover concept: Waves on piano, CAP 2012 pag.6-7 Incisioni rupestri, Val Camonica, BS, Italy pag.10 concept: Blocks, CAP 2012

XPLAB actively support :

BLIND EYES APPLICATIONS

BEA



XPLAB

research in automation

brescia - italy www.xplab.net www.power-ki.com â’¸ 2012 - XPLAB


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.