Difference between revisions of "Extensible Object Script"
(→Integrated Types) |
|||
(30 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
<td colspan="2" style="padding-bottom:.5em; padding-top:.5em; text-align:center; border-bottom:1px solid #a2a9b1;"> | <td colspan="2" style="padding-bottom:.5em; padding-top:.5em; text-align:center; border-bottom:1px solid #a2a9b1;"> | ||
− | [[File:Eos.png| | + | [[File:Eos.png|250px|frameless|border|EOS Logo]] |
</td></tr> | </td></tr> | ||
<tr> | <tr> | ||
− | <td style="width: 130px;vertical-align: top;">''' | + | <td style="width: 130px;vertical-align: top;">'''Designer''' |
</td> | </td> | ||
− | <td> | + | <td>R. Clark, A. Zeneli et. al. |
</td> | </td> | ||
</tr> | </tr> | ||
Line 23: | Line 23: | ||
<td style="width: 130px;vertical-align: top;">'''Type''' | <td style="width: 130px;vertical-align: top;">'''Type''' | ||
</td> | </td> | ||
− | <td> | + | <td>Programming Language |
</td> | </td> | ||
</tr> | </tr> | ||
Line 41: | Line 41: | ||
<td style="width: 130px;vertical-align: top;">'''Current Version''' | <td style="width: 130px;vertical-align: top;">'''Current Version''' | ||
</td> | </td> | ||
− | <td>2.10.2 | + | <td>2.10.2 (06/2021) |
</td></tr> | </td></tr> | ||
<tr> | <tr> | ||
<td style="width: 130px;vertical-align: top;">'''Platform'''</td> | <td style="width: 130px;vertical-align: top;">'''Platform'''</td> | ||
− | <td>EOSRuntime (Java / Platform Independent) | + | <td>[[EOSRuntime]] (Java / Platform Independent) |
</td></tr> | </td></tr> | ||
Line 77: | Line 77: | ||
</td> | </td> | ||
<td>Java, ActionScript, JavaScript | <td>Java, ActionScript, JavaScript | ||
+ | </td></tr> | ||
+ | |||
+ | <tr> | ||
+ | <td style="width: 130px;vertical-align: top;">'''Filename Extension''' | ||
+ | </td> | ||
+ | <td>.eos | ||
</td></tr> | </td></tr> | ||
Line 83: | Line 89: | ||
'''Extensible Object Script''' (short "EOS") is the Scripting language used for Systems Based on the [[Extensible Services / Server]] for Automation family. Extensible Object Script features Object mixing, caching, lambda expressions and dynamic typing. | '''Extensible Object Script''' (short "EOS") is the Scripting language used for Systems Based on the [[Extensible Services / Server]] for Automation family. Extensible Object Script features Object mixing, caching, lambda expressions and dynamic typing. | ||
− | Extensible Object Script runs inside the ES/S-A Enviroment (Java-Based) | + | Extensible Object Script runs inside the ES/S-A Enviroment (Java-Based) using the he portable script engine [[EOSRuntime]]. It is compatble with Java Objects (Objects extending java.lang.Object). As Java-based Language (Heavily dependent on Java-API's and processed by JCC and [https://commons.apache.org/proper/commons-bcel/ Apache BCEL]) it is theoretically plattform independent, as the runtime can be executed on any Java-capable platform. |
== Background == | == Background == | ||
− | ExtensibleObjectScript is a general purpose object-oriented programming and scripting language. It is designed to be simple to learn, easy to use, yet still powerful | + | ExtensibleObjectScript is a general purpose object-oriented programming and scripting language. It is designed to be simple to learn, easy to use, yet still powerful enough to master complex automation processes. The main goals was combining the convenience of a just-in-time interpreter with the features and reliability of the surrounding Java virtual machine. Its origins trace to ObjectScript developed originally by R. Clark at Texas Instrument until the mid 2000s. Efforts were taken by Netroda Technolgies and A. Zeneli to modernize the language, optimize and modernize the runtime and to introduce new features like headless lambda functions, anonymous JSON deserialization and bundled application loading. |
== Introduction == | == Introduction == | ||
− | Extensible Object Script is a full featured object oriented scripting language, which combines the powerful features of a full | + | Extensible Object Script is a full featured object oriented scripting language, which combines the powerful features of a full featured programming language such as Java with the ease of use of a scripting language. It supports functions (which can be closures), classes, inheritance, synchronization (for multi-threaded programs) and garbage collection. Also, an ObjectScript program can take advantage of exising Java APIs by creating instances of Java classes, calling methods of Java objects, and even implementing Java interfaces or extending Java classes. As the Core of Extensible Services / Server for Automation is java based, Extensible Object Script integrates seamlessly. |
== Uses == | == Uses == | ||
Line 104: | Line 110: | ||
! Information | ! Information | ||
|- | |- | ||
− | | | + | | '''DiscreteNumber''' |
| 25 | | 25 | ||
| A signed integer number up to 64 bits precision | | A signed integer number up to 64 bits precision | ||
− | | Stores discrete numbers with exact precision and no decimal point | + | | Stores discrete numbers with exact precision and no decimal point, ranges from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (inclusive) |
|- | |- | ||
− | | | + | | '''FloatNumber''' |
| 4512.25 | | 4512.25 | ||
| A signed floating point number up to 64 bits precision | | A signed floating point number up to 64 bits precision | ||
− | | Stores floating decimal numbers with variable inexact precision | + | | Stores floating decimal numbers with variable inexact precision, on most platforms also known as "Double" (double precision floating point). Ranges from -1.797693134862315E+308 to -2.225073858507201E-308 |
|- | |- | ||
− | | Boolean | + | | '''Boolean''' |
| true | | true | ||
| A boolean type, ie. true or false | | A boolean type, ie. true or false | ||
| Stores the two boolean states true and false | | Stores the two boolean states true and false | ||
|- | |- | ||
− | | String | + | | '''String''' |
| "Hello World" | | "Hello World" | ||
− | | A set of chars combined creating | + | | A string of arbitrary length as set of chars combined creating text |
− | | Stores a String of | + | | Stores a String of arbitrary length. A string is immutable, but supports read-only array like access using the [] and [..] operators. The length() method returns the length of the string. |
|- | |- | ||
− | | Array | + | | '''Array''' |
| ["Test",4,65.3,false] | | ["Test",4,65.3,false] | ||
− | | | + | | An array of arbitrary length, whose members can be of arbitrary type |
| Stores Arrays of arbitrary type (and don't have to be of the same type). The length() method returns the current length of the array. An array will automatically grow to accomodate the n'th element. indices start at 0. | | Stores Arrays of arbitrary type (and don't have to be of the same type). The length() method returns the current length of the array. An array will automatically grow to accomodate the n'th element. indices start at 0. | ||
|- | |- | ||
− | | Object | + | | '''Object''' |
− | | new | + | | new PersonDetail() |
− | | | + | | A Object of any type |
| In Object Script, everything (event the primitive types) are Objects. | | In Object Script, everything (event the primitive types) are Objects. | ||
|} | |} | ||
− | It is worth noting that, everything is just an object. The literal number 1 is an object, the statement (3 + "c") evaluates to an object. All objects define a getType() method, which returns the type of the object (which itself is an object.) | + | It is worth noting that, everything is just an object. The literal number 1 is an object, the statement (3 + "c") evaluates to an object. All objects define a getType() method, which returns the type of the object (which itself is an enumerative object.) |
+ | |||
+ | Arrays can be declared with the Array constructor, or with the more compact square bracket syntax: [1,2,3]. | ||
+ | Arrays can be accessed using the [] or [..] operators, such as arr[0] which will evaluate to the first element in the array, | ||
+ | or arr[0..5] which will return the sub-array containing the 0'th throughout 5'th (inclusive) elements of the array. | ||
+ | |||
+ | [[File:InexactNumber.png|350px|thumb|Sign, exponent and mantissa of InexactNumber]] | ||
== Examples == | == Examples == | ||
Line 150: | Line 162: | ||
continue; | continue; | ||
a = 10; // this line is never evaluated | a = 10; // this line is never evaluated | ||
− | } | + | }</shl> |
− | </shl> | ||
<shl> | <shl> | ||
// Two For-Loops | // Two For-Loops |
Latest revision as of 02:58, 20 August 2023
Extensible Object Script | |
---|---|
Designer | R. Clark, A. Zeneli et. al. |
Type | Programming Language |
Licenses | LGPL |
Initial release |
2002 |
Current Version | 2.10.2 (06/2021) |
Platform | EOSRuntime (Java / Platform Independent) |
Origin |
|
Paradigm | Imperative Procedural |
Typing | Dynamic, Weak |
Influences | Java, ActionScript, JavaScript |
Filename Extension | .eos |
Extensible Object Script (short "EOS") is the Scripting language used for Systems Based on the Extensible Services / Server for Automation family. Extensible Object Script features Object mixing, caching, lambda expressions and dynamic typing.
Extensible Object Script runs inside the ES/S-A Enviroment (Java-Based) using the he portable script engine EOSRuntime. It is compatble with Java Objects (Objects extending java.lang.Object). As Java-based Language (Heavily dependent on Java-API's and processed by JCC and Apache BCEL) it is theoretically plattform independent, as the runtime can be executed on any Java-capable platform.
Background
ExtensibleObjectScript is a general purpose object-oriented programming and scripting language. It is designed to be simple to learn, easy to use, yet still powerful enough to master complex automation processes. The main goals was combining the convenience of a just-in-time interpreter with the features and reliability of the surrounding Java virtual machine. Its origins trace to ObjectScript developed originally by R. Clark at Texas Instrument until the mid 2000s. Efforts were taken by Netroda Technolgies and A. Zeneli to modernize the language, optimize and modernize the runtime and to introduce new features like headless lambda functions, anonymous JSON deserialization and bundled application loading.
Introduction
Extensible Object Script is a full featured object oriented scripting language, which combines the powerful features of a full featured programming language such as Java with the ease of use of a scripting language. It supports functions (which can be closures), classes, inheritance, synchronization (for multi-threaded programs) and garbage collection. Also, an ObjectScript program can take advantage of exising Java APIs by creating instances of Java classes, calling methods of Java objects, and even implementing Java interfaces or extending Java classes. As the Core of Extensible Services / Server for Automation is java based, Extensible Object Script integrates seamlessly.
Uses
Scripts utilizing EOS are used to create Complex Typed System Assets (CTSA), Create and modify Area Service Controllers (ASXC) and to create user programs, like recurring tasks, automation routines and similar.
Integrated Types
Name | Example | Description | Information |
---|---|---|---|
DiscreteNumber | 25 | A signed integer number up to 64 bits precision | Stores discrete numbers with exact precision and no decimal point, ranges from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (inclusive) |
FloatNumber | 4512.25 | A signed floating point number up to 64 bits precision | Stores floating decimal numbers with variable inexact precision, on most platforms also known as "Double" (double precision floating point). Ranges from -1.797693134862315E+308 to -2.225073858507201E-308 |
Boolean | true | A boolean type, ie. true or false | Stores the two boolean states true and false |
String | "Hello World" | A string of arbitrary length as set of chars combined creating text | Stores a String of arbitrary length. A string is immutable, but supports read-only array like access using the [] and [..] operators. The length() method returns the length of the string. |
Array | ["Test",4,65.3,false] | An array of arbitrary length, whose members can be of arbitrary type | Stores Arrays of arbitrary type (and don't have to be of the same type). The length() method returns the current length of the array. An array will automatically grow to accomodate the n'th element. indices start at 0. |
Object | new PersonDetail() | A Object of any type | In Object Script, everything (event the primitive types) are Objects. |
It is worth noting that, everything is just an object. The literal number 1 is an object, the statement (3 + "c") evaluates to an object. All objects define a getType() method, which returns the type of the object (which itself is an enumerative object.)
Arrays can be declared with the Array constructor, or with the more compact square bracket syntax: [1,2,3]. Arrays can be accessed using the [] or [..] operators, such as arr[0] which will evaluate to the first element in the array, or arr[0..5] which will return the sub-array containing the 0'th throughout 5'th (inclusive) elements of the array.
Examples
// A Simple While-Loop var a = 0; while(true) { a++; if( a > 5 ) break; else continue; a = 10; // this line is never evaluated }
// Two For-Loops var arr = []; for( var i=0; i<10; i++ ) arr[i] = i; var sum = 0; for( var item : arr ) sum += item;
// Simple Recursion function fib(n) { if( n == 0 ) throw new Exception("Invalid Input"); else if( n == 1 ) return 1; else if( n == 2 ) return 1; else return fib(n-1) + fib(n-2); }
Object-Oriented Examples
// Objects and Object-Mixing function Color() { public function setRGB( r, g, b ) { // ... } } function Shape() { // ... } function Square() extends Shape() { public function setSize( w, h ) { // ... } } /* derived class created using mixins: */ function ColoredSquare() { mixin new Square(); mixin new Color(); } var coloredSquare = new ColoredSquare(); coloredSquare.setRGB( 0xff, 0xff, 0xff ); coloredSquare.setSize( 25, 50 );
A Example complex program shown below, this snippets creates a Lighting theme for a residential or public building utilizing a Extensible Services / Server for Automation based system.
/* Created on 09.01.2021 ALSC Setup - Extensible Object Script ---------------------------------------------------------------------------------------- The designated Area's Light Service Controller functions and allocations. ---------------------------------------------------------------------------------------- Copyright (C), N.P.A.L. 2015, 2021 Netroda Technologies, all rights reserved. this software can be reproduced, altered shared or distributed according to the terms of the Netroda Parity Access License (N.P.A.L.) See http://www.netroda.com/global/en/license/npal for further information Hint: to work with features and structures provided use the following variables provided */ var inp1 = ESS.Services.PTSA.getAssetById("ASES_0F26A000001"); // input1 => mode(on/off/auto) var highCeiling = ESS.Services.CTSA.getAssetById("CSES_0000P09F0E9A0"); // HIGH_CEILING_LAMP var dev2 = ESS.Services.CTSA.getAssetById("CSES_0000P09F0EA81"); var dev3 = ESS.Services.CTSA.getAssetById("CSES_0000P09F0EA82"); const var HIGH_CEILING_LAMP = 0; ALSC.primaryLights.createDevice(highCeiling,HIGH_CEILING_LAMP); // Reference Device 1 (high ceiling lamp) ALSC.primaryLights.createDevice(dev2,2); // Reference Device 2 ALSC.primaryLights.createDevice(dev3,3); // Reference Device 3 ALSC.primaryLights.addModeEventHandler( new (function() extends Lambda.ALSCModeEventHandler(){ var timer; public function onModeChange(e){ debug("Mode Changed"); timer = ESS.Runtime.invokeLater( new (function() extends EOSFoundation.ESSRunnable(){ public function run(){ debug("Mode Indication..."); debug(ESS.Services.DateTime.now()); var complexObject = ESS.Services.Complex.resolveArea("c0.b0.lv1.a001"); var currentMode = complexObject.lightsService.primaryLights.primaryMode.valueOf(); var modeIndicatorDevice = ESS.Services.PTSA.getAssetById("ASES_0FE00050001"); debug("Curr Mode (ext): " + currentMode); debug("Curr Mode (int): " + currentMode); if(currentMode == "ConstantOn"){ modeIndicatorDevice.inp(ContextAuthority,128); } else if(currentMode == "ConstantOff"){ modeIndicatorDevice.inp(ContextAuthority,0); } else if(currentMode == "Automatic"){ modeIndicatorDevice.inp(ContextAuthority,255); } } })(),0 ); } })() ); ALSC.primaryLights.createInput( inp1, new (function() extends EOSFoundation.InputEventHandler(){ public function onChange(e){ debug("Changed: Input 1"); } public function onHigh(e){ debug("High: Input 1, Cycling ALSC Mode..."); // this function is executed asynchronously in a new StackFrame, // so it might be necessary to reallocate the base ALSC object var complexObject = ESS.Services.Complex.resolveArea("c0.b0.lv1.a001"); complexObject.lightsService.primaryLights.cycleMode(); } public function onLow(e){ debug("Low: Input 1"); } })() ); ALSC.primaryLights.addTheme( new (function() extends Lambda.ALSCTheme(){ name = "Visitors"; allowModes = ["ConstantOn","ConstantOff","Automatic"]; public function onLoad(){ } public function onUnload(newTheme){ debug("Theme \""+name+"\" has been unloaded, new: " + newTheme); } public function onManualActivation(){ } public function onPresency(){ } public function onModeChange(modeArgument){ } public function onPanic() { } })() ); ALSC.primaryLights.addTheme( new (function() extends Lambda.ALSCTheme(){ name = "Cleaning Service"; allowModes = ["ConstantOn","ConstantOff"]; public function onLoad(){ //set the mode without invoking handlers [ changeMode(a,b) a=name b=silent ] because we just changed our theme //to prevent detrimental effects on the lost theme. var complexObject = ESS.Services.Complex.resolveArea("c0.b0.lv1.a001"); complexObject.lightsService.primaryLights.changeMode("ConstantOn",true); debug("Theme \""+name+"\" has been loaded"); evaluate(); } public function onUnload(newTheme){ debug("Theme \""+name+"\" has been unloaded, new: " + newTheme); //unload components if(highCeiling.isPoweredOn()){ highCeiling.requestPowerOffInstant(); } } public function onManualActivation(){ } public function onPresency(){ } public function onModeChange(modeArgument){ evaluate(); } public function onPanic(){ } private function evaluate(){ var complexObject = ESS.Services.Complex.resolveArea("c0.b0.lv1.a001"); var currentMode = complexObject.lightsService.primaryLights.primaryMode.valueOf(); if(currentMode == "ConstantOn"){ if(highCeiling.isPoweredOff()){ highCeiling.requestPowerOnInstant(); } } else if(currentMode == "ConstantOff"){ if(highCeiling.isPoweredOn()){ highCeiling.requestPowerOffInstant(); } } } })() );