a programming language
XPLAB research in automation
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.
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
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
Ⓒ 2012 XPLAB - Research in Automation - Page 11
Files extensions identify POWER-KI components. Executable code
Graphic User Interface Code
.BSK Basket ÂŠ
Executable Package: executable code + graphic user interface + resources
WorkBench Reusable code
Tool & Wiz definition file
Tool & Wiz
.PDC Debug conf
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
Tools & Wiz
Test & Debug
Ⓒ 2012 XPLAB - Research in Automation - Page 15
License type and purpose
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.
WorkBench Main menu usually appears on the top left of the screen.
â’¸ 2012 XPLAB - Research in Automation - Page 17
package name Add new Section
Main Assembly System Sections
User added Section
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
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.
Inside Assembly, an Item Attribute can be referred with the syntax:
Data Item Container
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.
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
Mouse item LIVE panel Active item
Press the LIVE button to show the GUI and the live panel.
In LIVE you can’t add or delete Item.
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
Select and Move the item
Select and change Item size
Select the parent Item
Select the parent Item
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
Update for changes of GUI or LIB
Click To GoTo Package Mng
Basket for item re-use
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.
Wizard are programs that automate the making of parts or elements of the Assembly. Wiz product is poured in the basket.
Click to Expand CLICK LEFT
when not selected
Open Item Editor
when selected (wait till a new label appears)
HOLD and MOVE
Select the Item
Open Option Put a copy in the Basket Open Item Editor Test (EXO only)
Delete Item Item Type
CLICK RIGHT Item Options â’¸ 2012 XPLAB - Research in Automation - Page 25
Item Identification and comment
Click To GoTo Assembly
Attribute / Value
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
Only Item with PUBLIC clause are visible from external Assembly.
PUBLIC PRIVATE clause
Comment can be inserted directly or, doubleClicking, from an edit page.
Item Name can be in the form: PREFIX:LABEL
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
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
when not selected
Open Item Editor
when selected (wait till a new label appears)
CLICK LEFT CLICK RIGHT
HOLD and MOVE
Select the Item
Automatic Syntax Highlight
CODE in editing
Constant ÂŁitteral Constant
â’¸ 2012 XPLAB - Research in Automation - Page 31
ALT+ UP/DOWN Arrow matching symbols list
Effects Navigate inside matching symbol List
Add to the editing symbol one char from the current matching symbol
Remove from the editing symbol the last added char
Add to the editing symbol all letters up to the first PATH delimiter
Select current symbol in list
Break the code in two
Copy the selection in EA board
Paste from EA Board
Open the Function Editor Assistant
Show GLOBAL symbol
Show LOCAL symbol
DoubleClick Function Parameters to edit window
â’¸ 2012 XPLAB - Research in Automation - Page 33
TEST Debug Enabled
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
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
SKIP button : inner ITEM code lines are executed continuosly.
â’¸ 2012 XPLAB - Research in Automation - Page 37
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
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
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
â’¸ 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.
MAIN If .PWK EXECUTOR search the main .PKA GUIs declared in .PKA with _AUTOLOAD_= ON are loaded.
LIBraries declared in .PKA are loaded.
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
StartUp Logo is displayed if enabled STARTLOGO@\pwk\Executor or if an error is detected.
StarUp Errors Code
Empty parameter list
EXECUTOR has been invoked without parameters
Error loading: wrong program
The program (first command line parameter) is not a valid POWER-KI Assembly
EXECUTOR ITEM not found
\pwk\Executor was not found in the Assembly
EXECUTOR EXO not defined
EXO@\pwk\Executor is not defined
EXO main not found
The EXO specified in EXO@\pwk\Executor does not exists in the Assembly
Another instance is executing and LIMIT_ONCE@\pwk\Executor is set
LIC file not found or invalid
The application needs a license
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
With : KEEPOPEN@\pwk\Executor = YES after the end of the execution the Console remains visible.
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
Parent continues execution
Parent execution is suspended
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
GUI Command Line Parameters #
Open on Port
The port number on which the gui will be opened. 0 = use default port
Peer connection parameter. Address can be a dotted IP or URL. If % an intranet broadcast search or PWK-EnterpriseServer is dispatched
Choose ACT, for intranet connection, PSV for internet (PWK-ES)
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
On OS console
On PWK chat
1 2 3
On PWK console
â’¸ 2012 XPLAB - Research in Automation - Page 59
On a window
On a web page
â’¸ 2012 XPLAB - Research in Automation - Page 61
â’¸ 2012 XPLAB - Research in Automation - Page 63
A POWER-KI Assembly can be thought of as s forest of trees.
Each tree is an Item which in turn contains other Items.
ITEM ITEM ITEM ITEM
POWER-KI eXecutable ITEMs (XI):
Item Category data
execution container unconditional flow conditional flow
EXO EXO sync
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 :
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.
V1=1; !! IMPLICIT; V2@C=2; !! RELATIVE; V3@\E=3;!! ABSOLUTE;
C 3 V2
V1=1; !! IMPLICIT; V4=4; V3@\E=3;!! ABSOLUTE;
In Assemblies attributes can be referenced as:
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 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@B=1; V2@\D=2; 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.
Indirection can be set for only the path or, if indicating an attribute, for all. C
RunTime Reference can be created and then used whith REF function.
Ⓒ 2012 XPLAB - Research in Automation - Page 69
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.
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.
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
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.
_ADDR_ _PORT_ _TRIG_ _PTR_
_EVT_ _SIGNAL_ Events Status
_PTH_ITEM_ _ITEM_ _PTH_ITEM_ACT_
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
EXecutable Object Synchronous
EXOs , the workhorse of POWER-KI, are the entry point of Assembly execution.
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).
Execution invocation Synchronous
â’¸ 2012 XPLAB - Research in Automation - Page 75
Thread invocation. A new execution flow is started.
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
Execute a computation
Item name must be an attribute containing the code. _SET_. Current XI item is assumed for reference.
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.
When the execution reaches this Item, END.
END â’¸ 2012 XPLAB - Research in Automation - Page 79
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.
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.
Unconditional Flow change
Any visible item inside the current XI can be the target of a GOTO jump.
Unconditional Flow change with Return
The Item BLOCK is the usual target of the CALL. After the CALL, execution resumes with the next item.
â’¸ 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
The name of the TRUE should be the reference of a visible attribute, if its value is TRUE contained are executed.
The name of the FALSE should be the reference of a visible attribute, if its value is FALSE Items contained are executed.
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 the value of the attribute _COND_ is TRUE the items belonging to DO are executed.
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 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
With this you can document your Assembly.
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 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.
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
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
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.
The £SHOW message tells GUI to show.
The text of the label is set to “Hello World!”.
The thread will loop until stop is not FALSE.
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
Create a Web Server
In the example web pages are contained in the package, in the user section dati with name WEB.
Build the real path, linking package path with the path of inside web folder.
Web server is created on port 80, then the pointer(PTR) web is used to start the service.
â’¸ 2012 XPLAB - Research in Automation - Page 93
DB Search inside a Data Base table.
Sql Data Base
In the example we assume that the Client table has at least three columns: NAME, SURNAME, AGE
Open the Data Base type SQLite
Get number of rows
For each row, print results.
â’¸ 2012 XPLAB - Research in Automation - Page 95
DOC Fill a table in a Open Document.
Open Document Format (ODF)
From a template create a new document.
Search the table: ”Table1”
Fill Table cells.
Ⓒ 2012 XPLAB - Research in Automation - Page 97
Insert and extract information from a KB1
Open the KB
Insert and extract data
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
research in automation
brescia - italy www.xplab.net www.power-ki.com â’¸ 2012 - XPLAB