Script Syntax

 

OVERVIEW

The iNetGrow script specifies the tasks that are automatically performed by the controller unit.  These tasks typical set the outputs depending on the values of the inputs.  The input and output names given during the I/O module configuration is used.  These given names must be unique to prevent conflicts or logical inconsistencies.  In addition, the script may use general-purpose variables or system variables.  The latter are the “built-in” variables, such as the current minutes, which automatically updated by the controller.

 

The script is case sensitive.

 

ORGANIZATION

The script is organized in two blocks: the declarations block and the program block.  Comments may be placed after double slashes.

 

Keywords

The script uses only six keywords:

 

title

input

output

var

if

else

 

The first four are used in the declarations section, and the latter two, in conditional statements.

 

Declarations

The declarations block uses keywords to indicate the various declarations.  There are four keywords: title, input, output, and var. 

 

The keyword “title” defines a user-given phrase, such as:

 

title “Thermostat control.”

 

As shown, the phrase must be encapsulated within quotation marks.

 

The remaining keywords define the symbols used in the logic.

 

// symbols

input  temperature;

output fan_1, fan_2;

var    x, y;

 

First, we find the comment “symbols.”  One input variable (“temperature”) and two output variables (“fan_1” and “fan_2”) are defined.  These must correspond to the names given to the inputs and outputs while configuring the I/O modules.  Finally, the two general-purpose variables “x” and ‘y” are defined.  Note that the general-purpose variables do not correspond to actual inputs or outputs.

 

In addition to the declared variables, the script may use predefined variables, called the system variables.  The system variables start with an underscore character.  Currently the following variables are used:

 

Variable

Remark

_second

Current seconds (0 to 59)

_minute

Current minutes (0 to 59)

_hour

Current hour (0 to 23)

_day

Current day of the month (1 to 31)

_month

Current month (1 to 12)

_year

Current year (2000 to 2099)

 

 

Program

The iNetGrow program consists of assignments statements and conditional statements.  An assignment statement sets the value of an output to an expression.  For example,

 

fan_1 = 1;

 

and

 

x = y / 2;

 

are valid assignments.  Note that assignment statements are terminated by semicolons.  The expressions may involve unary and binary operations listed below:

 

Symbol

remark

+

Add

-

Subtract

*

Multiply

/

Divide

%

Modulus (remainder)

 

 

||

Logical or

&&

Logical and

 

 

|

Bitwise or

&

Bitwise and

^

Bitwise exclusive or

 

 

==

Equal

!=

Not equal

<

Less than

<=

Less than or equal

>

Greater than

>=

Greater than or equal

 

 

$

Unary negation (minus)

~

Bitwise negation (bitwise not)

!

Logical negation (not)

 

The precedence in multi-operation expressions must be exclusively defined using parentheses.  For example,

 

x = (2*y) + y;

 

Conditional statements use the keywords “if” and “else.”  The format of conditional statements are similar to many programming languages: if(condition) { statement } else {statement }.

 

An example follows.

 

if(temperature>80)

 {

  fan_1=1;

  x=1;

  }

 else

  {

   fan_1=0;

   }

 

Note that curly braces (‘{‘ and ‘}’) are used after the conditions and else to define a block of one or more statements.  The curly braces are necessary even if the action statement is a single assignment statement.  Nested conditional statements are allowed.  For instance,

 

if(temperature>80)

 {

  fan_1=1;

  if(humidity<60)

   {

    x=1;

    }

   else

    {

     x=2;

     }

   }

  else

   {

    fan_1=0;

    }

 

 

Examples

Several examples may be found in the directory.  The iNetGrow program script files use the extension “ipf.”

 

Also see: iNetGrow Hardware

 

 

 


© Rigel Corporation iNetGrow 2003-2006.  All rights reserved.