Fork me on GitHub

ICasa Script Language

ICasa Simulation module provides a script language that can be used to create scenarios in order to test pervasive applications. In the next section we show the instructions set supported by the language and their (XML) syntax.

Outline

Script File Syntax

Scenarios in iCasa simulation module are specified in a XML file using the tag behavior.

Example:

<behavior startdate="03/10/2011-00:00:00" factor="1440">
   <!-- Scenario instructions -->
</behavior>
Attribute Description
startdate Starting date of script execution in format "dd/MM/yyyy-HH:mm:ss"
factor speed factor for script execution

General Instructions

Delay

Introduces a delay in (virtual) minutes between the previous instruction and the next one.

Example:

<delay value="60" />

or

<delay value="60" unit="h"/>
Attribute Description
value Time in (virtual) units
unit Time unit, value it can be h (hours), m (minuts), s (seconds). Default value is m


Zone Instructions

Create Zone

Creates a zone in application context

Example:

<create-zone id="kitchen"  leftX="410" topY="370" X-Length="245" Y-Length="210" />

or

<create-zone id="kitchen"  leftX="410" topY="370" bottomZ="0" X-Length="245" Y-Length="210" Z-Length="300" />
Attribute Description
id Zone's Identifier
leftX Left X coordinate value
topY Top Y coordinate value
bottomZ Bottom Z coordinate value
X-Length Zone X-Length
Y-Length Zone Y-Length
Z-Length Zone Z-Length

Move Zone

Move a zone in application context

Example:

<move-zone id="kitchen"  leftX="410" topY="370" />
Attribute Description
id Zone's Identifier
leftX New left X coordinate value
topY New top Y coordinate value

Resize Zone

Resize a zone in application context

Example:

<resize-zone id="kitchen"  X-Length="245" Y-Length="210" />

or

<resize-zone id="kitchen"  X-Length="245" Y-Length="210" Z-Length="210" />
Attribute Description
id Zone's Identifier
X-Length New zone X-Length
Y-Length New zone Y-Length
Z-Length New zone Z-Length

Add Variable to Zone

It adds a simulation variable to a zone

Example:

<add-zone-variable zoneId="livingroom" variable="Temperature" />
Attribute Description
zoneId Zone's Identifier
variable Variable name

Modify Variable in Zone

It modifies a simulation variable in a zone

Example:

<modify-zone-variable zoneId="kitchen" variable="Temperature" value="296.15"/>
Attribute Description
zoneId Zone's Identifier
variable Variable name
value Variable value

Device Instructions

Create Device

It creates a device instance in the application context

Example:

<create-device id="Pres-A1255D-D" type="iCasa.PresenceSensor" />
Attribute Description
id Device's Identifier
type Device's type

Remove Device

Example:

<remove-device deviceId="Pres-A1255D-D" />
Attribute Description
deviceId Device's Identifier


Move device into zone

Places a device in a zone of application context.

Example:

<move-device-zone deviceId="BiLi-A7496W-S" zoneId="kitchen" />
Attribute Description
deviceId Device's Identifier
zoneId Zone's Identifier


Activate Device

Changes the device's state to activated.

Example:

<activate-device deviceId="Pres-A1255D-D" />
Attribute Description
deviceId Device's Identifier


Deactivate Device

Changes the device's state to deactivated.

Example:

<deactivate-device deviceId="Pres-A1255D-D" />
Attribute Description
deviceId Device's Identifier


Fault Device

Changes the device's fault state to yes.

Example:

<fault-device deviceId="Pres-A1255D-D" />
Attribute Description
deviceId Device's Identifier


Repair Device

Changes the device's fault state to no.

Example:

<repair-device deviceId="Pres-A1255D-D" />
Attribute Description
deviceId Device's Identifier


Set device property value

Set the value of the device property

Example:

<set-device-property deviceId="BiLi-A7496W-S" property="power_status" value="true"/>
Attribute Description
deviceId Device's Identifier
property property name
value property value


Person Instructions


Create Person

Adds a person to the simulation context

Example:

<create-person id="Paul" type="Grandfather" />
Attribute Description
id Person's Identifier
type Person's type


Move Person into zone

Places a person in a zone in the application context

Example:

<move-person-zone personId="Paul" zoneId="bedroom"  />
Attribute Description
personId Person's Identifier
zoneId Zone's identifier


Scenario Example

<behavior startdate="27/10/2011-00:00:00" factor="1440">

   <!-- Creation of kitchen zone -->   
   <create-zone id="kitchen"  leftX="410" topY="370" X-Length="245" Z-Length="210" />    

   <!-- Adding and setting variables in kitchen zone -->
   <add-zone-variable zoneId="kitchen" variable="Temperature" />
   <add-zone-variable zoneId="kitchen" variable="Illuminance" />
   <modify-zone-variable zoneId="kitchen" variable="Temperature" value="296.15"/>
   <modify-zone-variable zoneId="kitchen" variable="Illuminance" value="0"/>

   <!-- Creating and placing devices in kitchen zone -->
   <create-device id="Pres-A1255D-D" type="iCasa.PresenceSensor" />
   <create-device id="Ther-A3654Q-S" type="iCasa.Thermometer" />
   <create-device id="Phot-A4894S-S" type="iCasa.Photometer" />
   <create-device id="BiLi-A7496W-S" type="iCasa.BinaryLight" />    
   <move-device-zone deviceId="Pres-A1255D-D" zoneId="kitchen" />
   <move-device-zone deviceId="Ther-A3654Q-S" zoneId="kitchen" />
   <move-device-zone deviceId="Phot-A4894S-S" zoneId="kitchen" />
   <move-device-zone deviceId="BiLi-A7496W-S" zoneId="kitchen" />

   <!-- Creation of livingroom zone --> 
   <create-zone id="livingroom" leftX="410" topY="28" X-Length="245" Y-Length="350" />
   <!-- Adding and setting variables in kitchen zone -->

   <add-zone-variable zoneId="livingroom" variable="Temperature" />
   <add-zone-variable zoneId="livingroom" variable="Illuminance" />
   <add-zone-variable zoneId="livingroom" variable="Volume" />
   <modify-zone-variable zoneId="livingroom" variable="Temperature" value="295.15"/>
   <modify-zone-variable zoneId="livingroom" variable="Illuminance" value="5"/>
   <modify-zone-variable zoneId="livingroom" variable="Volume" value="10"/>

   <!-- Others instructions --> 
   <delay value="100" />    
   <deactivate-device deviceId="Pres-A1255D-D" />
   <delay value="100" />
   <activate-device deviceId="Pres-A1255D-D" />
   <delay value="100" />
   <fault-device deviceId="Pres-A1255D-D" />
   <delay value="100" />
   <repair-device deviceId="Pres-A1255D-D" />
   <delay value="100" />
   <remove-device deviceId="Pres-A1255D-D" />   
   <delay value="100" />
   <set-device-property deviceId="BiLi-A7496W-S" property="power_status" value="true"/>

</behavior>

Script Deployment

New scripts have to be deployed to the directory ICASA_HOME/scripts in the gateway. All scripts files must have the .bhv extensions to be recognized by the iCasa platform.