RG 002 0 EN (Programming - Reference - Guide) PDF
RG 002 0 EN (Programming - Reference - Guide) PDF
Programming Guide
ver 1.9
1.1.1 Introduction
The program of the eWON is based on syntax close to the BASIC, with many specific extensions.
As you can see, the code you have entered is present, but the eWON has added some remarks and labels in order to allow edition and to
provide program flow control.
For each section in the editor, the eWON has added an END statement at the end to prevent the program from continuing to the next
section.
The example also shows that any label is global to the whole program and should not be duplicated.
We can also see here that there is not correlation between the section name and the label used in that section. The section name is only
a way to organize program listing during edition in the eWON. The section names can contain spaces while the program labels can't.
When the program starts (click RUN from the web site for example), the eWON posts 2 commands in the Queue:
The eWON BASIC task will read the request in the queue that has the lowest index and will execute it until an END is found or until an
error occurs.
The first command is "goto ewon_init_section". The following lines will be executed:
ewon_init_section:
rem --- eWON user (start)
CLS
MyVar=0
rem --- eWON user (end)
end
The END command on the last line will end the program and the BASIC task will check in the queue for a new request:
The first available command is "goto ewon_cyclic_section", it will also be executed until the END is found.
When this END is executed the BASIC task will detect that the section it has just executed was a CYCLIC_SECTION and it will post a
new "goto ewon_cyclic_section" request in the queue.
This is how the program is continuously executed forever while the BASIC is in RUN mode.
There are a number of actions that can be programmed to occur upon event, like ONTIMER:
TSET 1,10
ONTIMER 1,"goto MyLabel"
Suppose you add the above lines in the INIT SECTION, it will start timer 1 with an interval of 10 seconds and program a "goto MyLabel"
request when timer 1 ellapses.
What actually happens when the ONTIMER occurs is that the eWON posts the "goto MyLabel" request in the BASIC queue.
2 goto MyLabel
When the CYCLIC SECTION will be finished, the timer request will be extracted from the queue and then executed.
If the CYCLIC SECTION takes a long time to execute, then the time can elapse more than once during its execution, this could lead to
more timer action to be posted in the queue:
4 goto MyLabel
3 goto MyLabel
2 goto MyLabel
The basic queue can hold more than 100 requests, but if TIMER goes too fast or if other events like ONCHANGE are used the queue can
overflow, in that case an error is logged in the events file and requests are dropped.
You can also see that the ONTIMER request is not executed with the exact precision of a timer, depending on the current load of the
BASIC when the timer elapses. When an ASP block has to be executed for the delivery of a WEB page to a client, the ASP block is also
put in the queue
Example: if ASP block contains the following lines:
FromWebVar = Var1!
PRINT #0;TIME$
FromWebVar = Var1!
3
PRINT #0;TIME$
2 goto MyLabel
If a request in the queue contains more than 1 BASIC line, what actually happens is the following:
• The block is appended to the end of the program as a temporary section:
ewon_one_shot_section::
FromWebVar = Var1!
PRINT #0;TIME$
END
When creating an alphanumeric string with a quoted string the ‘ or " delimiter can be used:
Examples:
"abcd"
’abdc’
"abc‘def’ ghi "
Are 3 valid quoted strings.
A character string can be stored either in an alphanumeric type variable, or in an alphanumeric variable array.
1.1.4 Command
A command is an instruction that has 0 or several comma (,) separated parameters.
There are 2 exceptions to the comma separator: PRINT and PUT.
Examples:
GOTO Label
PRINT
CLS
SETSYS TAG, "name","Power"
SETSYS TAG,"SAVE"
1.1.5 Integer
An integer is a number between -2147483648 and +2147483647. This number can be stored in an integer variable. When a parameter of
integer type is specified for a function or a command and the variable past is of real type, the eWON automatically converts the real value
to an integer value. When the expected value is of integer type and the past value is a character string, the eWON generates an error.
1.1.6 Real
A real number is a number in floating point representation of which value is between -3.4028236 10E38 and +3.4028234 10E38. Value of
this type can be stored in a variable of real type or in an array of reals.
Precision: a Real number has approximately 7 significant digits. This means that conversion of a number with more than 7
significant digits to real will lead to a lost of precision.
When a function expects a real number and an integer is passed, the eWON automatically converts the integer into a real
value. If the function waits for a real and a character string is passed, the eWON generates an error.
eWON uses IEEE 754 single precision representation (32 bits).
So the fraction is coded on 23 bits, which represents about 7 significants digits.
But in the ViewIO page the values are only displayed with 6 digits. If you use the Tag in Basic Scripting you will find the 7 significant digits.
1.1.8 Function
A function is a BASIC command having 0 or several parameters and returning a result that can be of integer, real or string type.
Examples:
ASCII "HOP"
GETSYS TAG,"NAME"
PI
1.1.9 Label
To use the GOTO and GOSUB commands, you need to define LABELS.
A label is a name beginning a line and ended by a colon ‘:’
The label couldn’t have any space character.
The GOTO/GOSUB instruction use the Label name without the colon as parameter.
MyLabel:
GOTO MyLabel
“NOT” on page 33, “BNOT” on page 13, “AND” on page 12, “OR” on page 43, “XOR” on page 58, “MOD” on page 33
The variable name can only contain the letters "a" to "z"; all other characters are not allowed. The variable name can contain alphabetical
characters, numbers and "_" underscore, but name must begin with an alphabetical character. Others characters are not allowed.
Examples:
When the DIM command is called, the array is created and replaces any other DIM or variable existing with the same name. To erase an
array you can either use the CLEAR command that erases all variables, or change the dimension of the array to 1 element with another
call to DIM if you don’t want to clear everything but need to release memory.
An array of which name is a$(E1,E2,E3) and an alphanumeric variable of which name is a$ can exist simultaneously. A characters array
contains E1*E2*E3 *... characters.
Syntax [Command]
DIM a$(E1 [, E2 [, E3 [,....]]])
a$ is the name of the variable array created, its name only contains one active character of "a" until "z". E1 is the number of characters for
the first dimension. E2, E3, E4 are optional and are present if the array must have 2, 3, 4,...dimensions.
Examples:
DIM A$(10,20)
DIM Z(6)
An array of which name is a(E1,E2,E3) and a real variable of which name is a CAN exist simultaneously. A real array contains E1*E2*E3
*... reals.
Syntax [Command]
DIM a(E1 [, E2 [, E3 [,....]]])
a is the name of the array variable created, its name contains one character from "a" to "z". E1 is the number of real for the first
dimension. E2, E3, E4 are optional and are present if the array must have 2, 3, 4,… dimensions. The number of dimensions is only limited
by the BASIC memory size.
Example:
DIM d(5,5)
d(1,6)=6
Examples:
Tag1@ = 25.3
Tag2@ = Tag1@
IF (Tag3@>20.0) THEN …
Only in some cases it is useful to use the GETIO or SETIO commands in order to build the Tag name in the program (to perform some
repetitive operations or if a Tag name begins with a number, it cannot be accessed in Basic using the @ syntax, instead the GETIO,
SETIO function must be used).
Example:
FOR i%=1 to 10
A$ = "Tag"+STR$(i%)
SETIO A$,i%
NEXT i%
Tag name access Tagname String SETIO "TAG1",23.5 Set the value 23.5 in the Tag named TAG1
TagId access Positive Integer (>0) SETIO 2,23.5 Set the value 23.5 in the Tag with the ID=2
If there are 6 Tags defined in the config, each Tag can be accessed by its index (-0 to -5) or by its ID (the first item of a Tag definition
when reloading the config.txt file, the ID of a Tag is never reused during the live of a configuration until the eWON is formatted) or finally
by its name.
Parameter Type
E1,E2,.. Integer
S1,S2,.. String
CA Character (if string passed, first char is evaluated)
1.2.3 ABS
Syntax [function]
ABS E1
Purpose:
The function returns the absolute value of E1. E1 can be a value or a Tag name. See also “Operators priority” on page 8. If the value is
negative, you have to add use ().
Example:
ABS (-10.4)
Returns 10.4
1.2.4 ALMACK
Syntax [function]
ALMACK TagRef, S2
• TagRef is the Tag reference (TagName, ID or -Index) See Tag Access on page 10
• S2 is the UserName of the user that will acknowledge the alarm. If this field is the empty field "", then the "adm" login is
assumed for acknowledgement.
Purpose:
The function acknowledges the alarm status of a given Tag.
ALMACK returns error “Operation failed (28)” if the tag is not in alarm.
Example:
ALMACK "MyTag", "TheMighty"
1.2.5 ALSTAT
Syntax [function]
ALSTAT TagRef
• TagRef is the Tag reference (TagName, ID or -Index) See Tag Access on page 10
Purpose:
Returns the S1 Tag alarm status. The returned values are:
Values Description
0 No alarm
2 In alarm
Example:
a% = ALSTAT "MyLittleTag"
1.2.6 AND
Syntax [Operator]
E1 AND E2
Purpose:
Do a bit-wise AND between E1 and E2. Also have a look at the priority of the operators.
Examples:
1 AND 2
Returns 0
2 AND 2
Returns 2
3 AND 1
Returns 1
MyFirstTag@ AND 3
See also:
“Operators priority” on page 8, “OR” on page 43, “XOR” on page 58
1.2.7 ASCII
Syntax [function]
ASCII CA
Purpose:
The function returns the ASCII code of the first character of the chain CA. If the chain is empty, the function returns 0.
Example:
a% = ASCII "HOP"
See also:
“CHR$” on page 13
1.2.8 BIN$
Syntax [function]
BIN$ E1
Purpose:
The function returns a string of 32 characters that represents the binary value of E1. It does not work on negative values.
Example:
A$= BIN$ 5
REM A$ is worth " 00000000000000000000000000000101 " after this affectation
See also:
“HEX$” on page 28
1.2.9 BNOT
Syntax [function]
BNOT E1
Purpose:
This function returns the "bitwise negation" or one's complement of the integer E1.
Example:
a%=5
b%=BNOT a%
print BIN$(b%)
Will display 11111111111111111111111111111010
See also:
“Operators priority” on page 8
1.2.10 CFGSAVE
Syntax [Command]
CFGSAVE
Purpose:
Writes the eWON configuration to flash. This command is necessary after SETSYS command on SYS, TAG or USER records because
using SETSYS will modify the configuration in memory. The modification will be effective as soon as the SETSYS XXX,"save" (where
XXX stands for SYS, USER or TAG), but the config is not saved to the eWON flash file system.
See also:
“GETSYS, SETSYS” on page 24
1.2.11 CHR$
Syntax [Function]
CHR$ E1
Purpose:
The function returns a character string with only one character corresponding to the ASCII code of E1. E1 must be contained in the 0..255
range.
Example:
A$= CHR$ 48
A$ is worth "0" after this affectation
B$=CHR$(getio(MyTag))
See also:
“ASCII” on page 12
1.2.12 CLEAR
Syntax [Command]
CLEAR
Purpose:
Erases all variables from the eWON. All DIM are erased. This command cannot be canceled.
1.2.13 CLOSE
Syntax [Command]
CLOSE I1
I1 is the file number (1-8)
Purpose:
This command closes the file with file number I1. If the file is opened for write, it is actually written to the flash file system.
The function can be called even if the file is not opened.
See also:
“EOF” on page 17, “GET” on page 21, “OPEN” on page 40, “PUT” on page 44
1.2.14 CLS
Syntax [Command]
CLS
Purpose:
This command erases the virtual screen of the eWON, visible in the Script control page.
See also:
“PRINT - AT” on page 43
1.2.15 DAY
Syntax [Function]
DAY E1 / S1
• E1 is a date in integer format (number of seconds since 1/1/1970)
• S1 is a date in String format ("18/09/2003 15:45:30")
Purpose:
This function returns an integer corresponding to the value of the day of the month (1--31) that matches a defined time variable.
REM: Do not call the function with a float variable of value (or this would result to error "invalid parameter").
Example 1:
a$ = TIME$
a% = DAY a$
Example 2:
b% = getsys prg,"TIMESEC"
a% = DAY b%
See also:
“DOW” on page 15, “DOY” on page 16, “MONTH” on page 33, “WOY” on page 58
1.2.16 DEC
Syntax [Function]
DEC S1
• S1 is the string to convert from HEX to DEC
Purpose:
This function returns an integer corresponding to the hexadecimal value of parameter.
The string is not case sensitive (a023fc = A023FC). The string can be of any length.
Example:
A$= HEX$(1234)
I%=DEC(A$)
1.2.17 DIM
Purpose:
The DIM function permits to create variables of array type. Two types of array are available: the characters arrays and the real arrays.
See also:
“Type of Variables” on page 8
1.2.18 DOW
Syntax [Function]
DOW E1 / S1
• E1 is a date in integer format (number of seconds since 1/1/1970)
• S1 is a date in String format ("18/09/2003 15:45:30")
Purpose:
This function returns an integer corresponding to the value of the day of the week (0--6; Sunday = 0) that matches a defined time variable.
REM: Do not call the function with a float variable of value (or this would result to error "invalid parameter").
Example 1:
a$ = TIME$
a% = DOW a$
Example 2:
b% = getsys prg,"TIMESEC"
a% = DOW b%
See also:
“DAY” on page 14, “DOY” on page 16, “MONTH” on page 33, “WOY” on page 58
1.2.19 DOY
Syntax [Function]
DOY E1 / S1
• E1 is a date in integer format (number of seconds since 1/1/1970)
• S1 is a date in String format ("18/09/2003 15:45:30")
Purpose:
This function returns an integer corresponding to the value of the current day in the year (0-365) that matches a defined time variable.
REM: Do not call the function with a float variable of value (or this would result to error "invalid parameter").
Example 1:
a$ = TIME$
a% = DOY a$
Example 2:
b% = getsys prg,"TIMESEC"
a% = DOY b%
See also:
“DAY” on page 14, “DOW” on page 15, “MONTH” on page 33, “WOY” on page 58
1.2.20 DYNDNS
Syntax
DYNDNS
Purpose:
The command has no parameter and asks a NO-IP dynamic PPP IP address update to the Dynamic DNS server you have set in Publish
IP address Configuration page.
It will be used to synchronize a Dynamic DNS server such as No-IP with the eWON PPP IP address.
1.2.21 END
Syntax [Command]
END
Purpose:
Indicates the end of the program. This command can also be used to stop the execution of a section. If the program is in RUN mode, this
command will suspend the execution until another section is ready to run (ONCHANGE, CYCLIC etc.).
Example:
PRINT " START "
END
PRINT " SUB "
See also:
“HALT” on page 28
1.2.22 EOF
Syntax [function]
EOF E1
• E1 is a number (1-8) corresponding to a /usr file or an ExportBlocDescriptor.
Purpose:
Returns 1 when end of file is reached.
EOF always returns 1 for files opened for write.
EOF works only with OPEN “file:...” or OPEN “exp:...” FileStream.
Example:
PRINT "open file"
OPEN "file:/usr/myfile.txt" FOR TEXT INPUT AS 1
ReadNext:
IF EOF 1 THEN GOTO ReadDone
A$ = GET 1
PRINT A$
GOTO ReadNext
ReadDone:
PRINT "close file"
CLOSE 1
See also:
“CLOSE” on page 14, “GET” on page 21, “OPEN” on page 40, “PUT” on page 44
1.2.23 ERASE
Syntax [Command]
ERASE Filename|Keyword
Purpose:
Erase the specified file in the /usr directory. That means this command will not work for a different directory than the "/usr" directory.
Omitting "/usr/" before the filename will result to a syntax error.
The file and directory names are case sensitive.
Example:
ERASE "/usr/myfile.shtm"
in order to erase some root files, some special keywords have been added.
See also:
“RENAME” on page 48
1.2.24 FCNV
Syntax [function]
FCNV S1,EType[,ESize,SFormat]
• S1 is the string to be converted.
• EType is the parameter determining the type of conversion.
• ESize is the size of the string to convert (can be shorter than the entire S1).
• SFormat is the format specifier for the conversion.
Purpose:
Converts a string to a number (float or integer).
The return value can be an IEEE float, an Integer, a CRC16, a LRC.
See also:
“SFMT” on page 52
FCNV A$, 1 : convert A$(1 to 4) to a float IEEE representation with MSB first
A$(1) = MSB (Exponent+ Sign)... A$(4) = LSB (Mantissa LSB)
FCNV A$, 2 : convert A$(1 to 4) to a float IEEE representation with:
A$(1) = LSB (Mantissa LSB) ... A$(4) = MSB (Exponent+ Sign)
Example:
ieee = 0.0
A$="1234"
A$(1) = Chr$(140) : A$(2) = Chr$(186)
A$(3) = Chr$(9) : A$(4) = Chr$(194)
ieee = FCNV A$,2
Print ieee : rem ieee = -34.432176
FCNV A$, 10,4 : convert A$(1 to 4) to an integer representation with MSB first
A$(1) = MSB ... A$(4) = LSB
FCNV A$, 10,2 : convert A$(1 to 2) to an integer representation with MSB first
A$(1) = MSB ... A$(2) = LSB
FCNV A$, 11,4 : convert A$(1 to 4) to an integer representation with LSB first
A$(1) = LSB ... A$(4) = MSB
FCNV A$, 11,2 : convert A$(1 to 2) to an integer representation with LSB first
A$(1) = LSB ... A$(2) = MSB
Example:
A$=CHR$(1)+CHR$(4)+CHR$(2)+CHR$(0)
a%=FCNV A$,10,2
b%=FCNV A$,11,2
PRINT a% : rem a% = 260
PRINT b% : rem b% = 1025
c%=FCNV A$,10,3
PRINT c% : rem c% = 66562
c%=FCNV A$,10,4
PRINT c% : rem c% = 17039872
1.2.26 GET
The GET command works completely differently if the file is opened in Binary mode or in Text mode.
The file syntax has been extended in version 3 of the eWON to allow access to the serial port and to TCP and UDP socket.
The command description describes operation for /usr (Text and Binary modes), COM (always binary) and TCP-UDP (always binary)
Purpose:
Returns a string of char with the data read. Moves the file read pointer to the character following the last character read (or to end of file).
DIM A$(2,20)
DIM A(2)
OPEN "/myfile.txt" FOR TEXT INPUT AS 1
I%=1
ReadNext:
IF EOF 1 THEN GOTO ReadDone
A(I%) = GET 1
A$(I%) = GET 1
I% = I%+1
GOTO ReadNext
ReadDone:
CLOSE 1
See also:
“CLOSE” on page 14, “EOF” on page 17, “OPEN” on page 40, “PUT” on page 44
1.2.27 GETFTP
Syntax [function]
GETFTP S1, S2 [,S3]
• S1 is the name of the source file (to retrieve on the FTP server)
• S2 is the name of the destination file (to write on the eWON)
• S3 (optional) is the FTP server connection parameters.
If S3 is unused, the FTPServer parameters from the General config page will be used.
Purpose:
Retrieves a file on an FTP server and copy it on the eWON.
The source filename can include a path (built with “/” or “\” depending of the FTP server).
As the destination filename is on the eWON, you must begin by a “/” and can include a path built with “/”.
The S3 parameters is as follow:
[user:password@]servername[:port][,option1]
The option1 parameters is to force PassiveMode, put a value 1 as option1 parameter.
If omitted, option1=0, then eWON will connect in ActiveMode.
When the function returns, the GETSYS PRG,"ACTIONID" returns the ID of the scheduled action and allows tracking this action. It is also
possible to program an ONSTATUS action that will be called when the action is finished (with or without success).
Examples:
GETFTP "server_file_name.txt","/usr/ewon_file_name.txt"
GETFTP "server_file.txt","/usr/ewon_file.txt","user:pwd@ServerTP.com:21,1"
GETFTP "inst_val.txt","/inst_val.txt"
See also:
“ONSTATUS” on page 38, “GETSYS, SETSYS” on page 24, “PUTFTP” on page 46
1.2.28 GETHTTP
Syntax [function]
GETHTTP S1,S2,S3[,S4]
• S1: Connexion Parameter with the format [user:password@]servername[:port]
• S2: file name to assign on the eWON file name path
• S3: URI of the file on the HTTP server absolute path of the file to be downloaded
• S4 (optional): "PROXY"
Purpose:
The GETHTTP command submit a HTTP GET request. It allows the download of a file (one per GETHTTP command) using its URI.
When the function returns, the GETSYS PRG, returns the ID of the scheduled action and allows tracking of this action. It is also possible
to program an ONSTATUS action that will be called when the action is finished (with or without success).
When "PROXY" is added at the end of the command, the eWON will perform the GETHTTP through a Proxy server. The eWON will use
the Proxy server parameters configured in System Setup / Communication / VPN Global.
Examples:
• download without HTTP basic authentification:
GETHTTP "10.0.100.206","/usr/filename1.txt","/filename1.txt"
When no port is specified HTTP port 80 is used.
See also:
“ONSTATUS” on page 38, “GETSYS, SETSYS” on page 24, “PUTHTTP” on page 47
1.2.29 GETIO
Syntax [function]
GETIO TagRef
• TagRef is the Tag reference (TagName, ID or -Index) See Tag Access on page 10
Returns the value of the S1 Tag. This value is a FLOAT.
Example 1:
A = GETIO "MyTag"
Example 2:
A = GETIO 12 : rem if TagID =12
See also:
“SETIO” on page 51
Group Description
Program parameters like the time in milliseconds or the type of action that
PRG
started the program
Current status of the action with ActionID given by ACTIONID. If ACTIONSTAT must be checked,
ACTIONID must first be initialized
Possible values of ACTIONSTAT are:
-1: in progress
-2: ID not found
ACTIONSTAT RO I 0: done with success
>0: finished with error = error code
The eWON maintains a list with the status of the last 20 scheduled actions executed. When more actions
are executed, the older status is erased and its ACTIONSTAT may return –2, meaning it is not available
anymore
The value of this field is updated before executing the ONXXXXX (ONSTATUS, ONERROR, etc.), see the
EVTINFO RO I different ONXXXXX function for the meaning of the EVTINFO parameter
Returns the time elapsed since 1/1/1970 in seconds. (Useful for computing time differences)
TIMESEC RO I Warning: when you assign this value to a float variable the number is too big and rounding will occur. You
should use an integer variable (ex: a%) to store this value
When program is started, the source of the execution is given by this parameter:
1: Started from the Web site ‘Script Control’ window
RUNSRC RO I 2: Started by the FTP server because program has been updated
3: A ‘GO’ command has been executed from the script
4: Automatic program start at eWON boot
This parameter returns the string corresponding to the current PPP IP address. When the eWON is
offline, the value returned is "0.0.0.0". When the eWON is online the value returned is the dotted IP
PPPIP R/W S/I address allocated for the PPP connection
The parameter can be written in order to disconnect the eWON. The only value accepted when writing in
this parameter is 0 (setsys prg, "PPPIP", 0)
This parameter returns the string corresponding to the current WAN IP address. When the eWON is
offline, the value returned is "0.0.0.0".
If no-ip has been called, then WANIP returns the IP returned by no-ip, otherwise the actual physical WAN
IP address (PPP or Ethernet) is returned.
WANIP RO S REM1: if getsys prg,"WANIP" is called in a ONWAN event it is likely that if a no-ip request is scheduled
through publish ip address, it is not yet finished when the ONWAN is called.
REM2: getsys prg,"WANIP" returns the same value as getsys prg,"PPPIP" if no-ip is not (yet) called and
WAN interface is on modem, BUT writing to WANIP does not close the WAN connection like writing to
PPPIP may close the PPP connection.
VPNIP RO S Currently allocated VPN ip address. If eWON is not connected to VPN this is 0.0.0.0
Transparent forwarding IP address. The parameter can be used to write or read the routing parameter.
TRFWD R/W S The parameter is only active when the PPP connection is established
SERNUM R/W S Returns a string with the eWON serial number string
PRIOH R/W I Used for changing the script priority (Currently not documented)
PRION R/W I Used for changing the script priority (Currently not documented)
PRIOT R/W I Used for changing the script priority (Currently not documented)
Contains the code from the last Basic error that occurred (-1: no error).
See “BASIC Errors Codes” on page 59
LSTERR R/W I The LSTERR is automatically cleared (value -1) when an end of section is reached (instruction END)
You can also write the value -1 on LSTERR to clear the error ( SETSYS PRG,”LSTERR”,-1 ).
Clear all pending scheduled actions (except the action currently ‘in progress’).
Write only with the value 1
SCHRST W I SETSYS PRG,”SCHRST”,1
When Scheduled Actions are cleared, they have the status ‘Action Canceled’ (value 21613)
Notes:
RO means read only
R/W means read/write
I,R,S means Integer, Real, String
• SYS fields group:
The fields edited with this group are the one found in the config.txt file under the section System. The fields are described in the
section "Configuration fields".
• COM fields group:
The fields edited with this group are the one found in the comcfg.txt. The fields are described in the section "Configuration fields".
It is possible to tune the modem detection too. See Com Section on page 62.
• INF fields group:
This group holds all information data about eWON. All these fields are Read Only.
The fields displayed from this group are the one found in the estat.htm file.
• TAG fields group:
The fields edited with this group are the one found in the config.txt file under the section TagList. The fields are described in the
section "Configuration fields".
The TAG load case is particular because is allows to load a Tag defined by its name, its ID or its Index.
If there are 6 Tags defined in the config, each Tag can be accessed by its index (0 to 5), its ID (the first item of a Tag definition when
reloading the config.txt file, the ID of a Tag is never reused during the live of a configuration until the eWON is formatted) or finally by its
name.
See also:
See Tag Access on page 10
Tag name access Tagname Setsys Tag,"load","MyTagName" Loads Tag with name MyTagName
1.2.31 GO
Syntax [Command]
GO
Purpose:
Start program execution (RUN). This is equivalent to clicking RUN in the script control window.
This command is mainly useful for remote eWON operation through the use of REMOTE.BAS FTP transfer.
See also:
“HALT” on page 28), (“REBOOT” on page 48)
1.2.33 GOTO
Syntax [Command]
GOTO Label
Purpose:
The execution of the program continues to the line indicated by Label. The GOTO command also allows starting the program without
erasing all variables. The Label statement cannot be empty.
Example:
GOTO Label
Print " Hop "
REM the program continues at line Label (Hop is not printed)
Label:
1.2.34 HALT
Syntax [Command]
HALT
Purpose:
Stops program execution. This is equivalent to clicking STOP’ in the script control window.
This command is mainly useful for remote eWON operation through the use of REMOTE.BAS FTP transfer.
See also:
“GO” on page 27, “REBOOT” on page 48
1.2.35 HEX$
Syntax [function]
HEX$ E1
Purpose:
The function returns a chain of 8 characters that represents the hexadecimal value of the E1 number.
Example:
a$= HEX$ 255
REM A$ is worth " 000000FF " after this affectation
See also:
“BIN$” on page 13
1.2.37 INSTR
Syntax [Function]
INSTR I1,S1,S2
• I1 is the index in the string to search (valid value goes from 1 to LEN S1)
• S1 is the string to be search for S2
• S2 is the string to search for in S1
Purpose:
The function returns an integer equal to the position of string S2 in string S1.
If string S2 is found, the function return a value from 1 to the length of S1 (The returned index is 1 based).
If string S2 is not contained in S1, the function returns 0.
The I1 parameter should be 1 to search the whole S1 string. If I1 is >0 then string S1 is searched starting at offset I1. The value returned
is still referenced to the beginning of S1, example:
INSTR 1, "AAABBC","BB" = 4 and INSTR 3, "AAABBC","BB" = 4 also.
note: As internally, the INSTR function uses the character zero (0x00) as delimiter, you cannot search for character zero with INSTR.
B$=CHR$(0) : A% = INSTR 1,A$,B$ will always return 1, whichever a zero character is present or not.
1.2.38 INT
Syntax [function]
INT F1
Purpose:
Example 1:
A = INT(10.95)
REM A equals 10.00
Example 2:
A% = 10.95
REM A equals 10 --- automatic type conversion
1.2.39 IOMOD
Syntax [function]
IOMOD TagRef
• TagRef is the Tag reference (TagName, ID or -Index) See Tag Access on page 10
Purpose:
Returns '1' if the TagRef Tag value has been modified in the eWON since the last call to the IOMOD command. The call to this function
resets Tag change internal flag to 0. i.e. if the variable doesn't change anymore, the next call to IOMOD will return 0. You can achieve an
equivalent behavior with the use of ONCHANGE event handler.
Example:
a% = IOMOD " MYTAG "
IF a% THEN PRINT " mytag has changed "
See also:
“ONCHANGE” on page 34
1.2.40 IORCV
Syntax [function]
IORCV S1
or
IORCV S1, I1
• S1 is the STRING IOServerName
• I1 is an additional parameter (= 0 OR = 1 OR = -1)
Purpose:
The IOSEND and IORCV functions must be used together. They are used to send/receive custom IOServer requests.
These functions can only be used if IOServer is configured.
Use IORCV function for reading IO server response to an IOSEND request.
Note:
There are three transmission slots available, using IORCV allows you to free them before the three slots are busy.
Requests are interlaced with gateway requests sent to the IO server and with normal IO server polling operations.
• First case:
a$ = IORCV a%
a$ = IORCV a%,0
Returns the result or the status of the Request.
a% holds the request number and is the result of the IOSEND command.
a$=”XXXXXXXXX” where XXXXXXXXX is the result of the request
a$="#FREE" slot a% is free
a$="#RUN" slot a% is in progress
a$="#ERR" slot a% is done with error
If the request is done (all cases except “#RUN”), the slot is always freed after the “IORCV a%” or “IORCV a%,0”.
• Second case:
a$ = IORCV a%,-1
Same as for “a$=IORCV a%,0”, but the slot is not freed if a request is done.
• Third case:
b% = IORCV a%,1
Returns the status of the IORCV command in INTEGER format.
The slot is not freed by this parameter.
The returned status can contain the following values:
b%= -2 slot a% is free
slot a% is done with error - code type: warning. Such warning codes mean “Read failed”
b% < -2 on the serial link. These warnings are flagged as internal and thus are not added in the
event log. The warning codes can be very long; ie. -536893114
Example:
TestIO:
A$ = chr$(4)+chr$(0)+chr$(0)+chr$(0)+chr$(1) : rem create modbus command
rem initiate the modbus request on slave 21
a% = IOSEND "MODBUS","21",A$
Wait_IO_End:
b% = IORCV a%,1 : rem read the status
IF b%=-1 THEN
GOTO Wait_IO_End : rem if idle then loop
ENDIF
1.2.41 IOSEND
Syntax [function]
IOSEND S1, S2, S3
Purpose:
Sends a request by using the IO server's protocol.
See “IORCV” on page 30 for an example of how this function must be used.
Parameters are:
• STRING IOServerName: IO Server name as it appears in the Tag configuration page
• STRING Address: Slave address as described in the eWON User manual for each IO server section
• STRING IoCommand: Array of bytes with a protocol command, the content depends on the IO server.
Returns a request number (slot) that must be used in IORCV for reading the response to the request.
Note:
The request result is read by using the IORCV function and uses a polling mechanism. That means that you need to use
IORCV in order to check with the request received with IOSEND that the slot is free. There are three transmission slots
available, using IORCV allows you to free them before the three slots are busy.
Requests are interlaced with gateway requests sent to the IO server and with normal IO server polling operations.
Example:
a% = IOSEND IOServerName,Address,IoCommand
See also:
“IORCV” on page 30
1.2.42 LEN
Syntax [function]
LEN S1
Purpose:
The function returns the number of characters in a string.
Example:
a$= "Hop "
A% = LEN A$
REM a% equal 3
1.2.43 LOGEVENT
Syntax [command]
LOGEVENT S1 [,S2]
• S1 is the phrase to log
• S2 is the type of logging. This parameter is optional and can take the following ranges of values:
-99 .. -1 Warning
1.2.44 LOGIO
Syntax [command]
LOGIO TagRef
• TagRef is the Tag reference (TagName, ID or -Index) See Tag Access on page 10
Purpose:
Force historical logging of TagRef Tag.
The Tag must have historical logging enabled (Warning: not available on all eWON’s versions).
The point is logged at the time the LOGIO command is issued with its current value.
Note: If the Tag is configured for historical logging with logging dead band equal to –1 and time interval equal to 0, no point will be logged
automatically and it is possible to program a purely scripted logging.
Example:
LOGIO "mytag"
1.2.45 LTRIM
Syntax[Command]
LTRIM S1
• S1 is a string.
Purpose:
LTRIM returns a copy of a string with the leftmost spaces removed.
Example:
b$ = LTRIM a$
See also:
“RTRIM” on page 48
1.2.46 MOD
Syntax [Operator]
E1 MOD E2
Purpose:
Compute the remainder of the division of E1 by E2
Example:
1 MOD 2
REM returns 1
2 MOD 2
REM returns 0
See also:
“Operators priority” on page 8
1.2.47 MONTH
Syntax [Function]
MONTH E1
• E1 is a date in integer format (number of seconds since 1/1/1970)
• S1 is a date in String format ("18/09/2003 15:45:30")
Purpose:
This function returns an integer corresponding to the value of the month (1--12) that matches a defined time variable.
Warning: Do not call the function with a float variable of value (or this would result to error "invalid parameter").
Example 1:
a$ = TIME$
a% = MONTH a$
Example 2:
b% = getsys prg,"TIMESEC"
a% = MONTH b%
See also:
“DAY” on page 14, “DOW” on page 15, “DOY” on page 16, “WOY” on page 58
1.2.48 NOT
Syntax [function]
NOT E1
Purpose:
The function returns '1' if E1 is equal to '0' otherwise the function returns 0.
Example:
IF NOT a% THEN PRINT " A% is worth 0 "
See also:
“Operators priority” on page 8
1.2.49 NTPSync
Syntax [function]
NtpSync
Purpose:
Posts a request for clock resynchronization (even if this feature is disabled in the configuration).
1.2.50 ONxxxxxx
There are some ONxxxxxx commands listed below. These commands are used to register a BASIC action to perform in case of special
conditions. For every ONxxxxx command, the action to execute is a string that is used as a BASIC command line. When the condition
occurs, the command is queued in an execution queue and is executed when its turn comes. These functions are:
ONSMS Executed when a SMS is received (only for eWON with GSM/GPRS Modem)
When the command line programmed is executed, a special parameter is set in SETSYS PRG,"EVTINFO". The value of the parameter
depends on the ONxxxxxx function and it can be checked with the GETSYS command.
Warning:
For all ONxxxx command, if the last parameter is omitted, the action is canceled.
Example:
ONTIMER 1
REM will cancel any action programmed on TIMER 1.
See also:
“GETSYS, SETSYS” on page 24, ONxxxxx (following chapters)
1.2.51 ONALARM
Syntax [command]
ONALARM TagRef,S2
• TagRef is the Tag reference (TagName, ID or -Index) See Tag Access on page 10
• S2 is the command line to execute in case of alarm state change.
Purpose:
Executes the S2 command line when alarm state on TagRef Tag changes. The EVTINFO parameter (see GETSYS page 24) is set to the
Tag ID when command is called.
Note: ONALARM will execute the command when the alarm status gets the value "2" (or above), that means that ONALARM DOES NOT
DETECT the "pre trigger" status (value=1).
Example:
ONALARM "MyTag","goto MyTagAlarm"
See also:
“ALSTAT” on page 12, “GETSYS, SETSYS” on page 24, “ONxxxxxx” on page 33, “ONCHANGE” on page 34
1.2.52 ONCHANGE
Syntax [command]
ONCHANGE TagRef,S2
• TagRef is the Tag reference (TagName, ID or -Index) See Tag Access on page 10
• S2 is the command line to execute in case of value change.
Purpose:
Executes S2 command line when the TagRef Tag changes (value or configuration).
The EVTINFO parameter (see “GETSYS, SETSYS” on page 24) is set to the Tag ID when command is called.
Example:
ONCHANGE "MyTag","goto MyTagChange"
See also:
“IOMOD” on page 30, “GETSYS, SETSYS” on page 24, “ONxxxxxx” on page 33
1.2.53 ONDATE
Syntax [command]
ONDATE I1,S1,S2
• I1 is the planner entry index to set (from 1 to 10).
• S1 is the Timer Interval string.
• S2 is the Basic command(s) to execute at the specified interval.
ONDATE I1
• I1 is the planner entry index to delete (from 1 to 10).
Purpose:
The ONDATE function allows you to defined 10 plannified tasks.
Available since Firmware 5.7.
All ONDATE entries are deleted automatically when the program is stopped by the RUN/STOP link.
Field Settings
Operator Description
The * (asterisk) operator specifies all possible values for a field from Table 14.
* For example, an * in the hh time field would be equivalent to 'every hour'.
The , (comma) operator specifies a list of values, for example: "1,3,4,7,8" (space inside the list must
, not be used)
The - (dash) operator specifies a range of values, for example: "1-6", which is equivalent to
- "1,2,3,4,5,6".
The / (slash) operator (called "step"), which can be used to skip a given number of values.
/ For example, "*/3" in the hour time field is equivalent to "0,3,6,9,12,15,18,21".
Examples:
Example Meaning
ONDATE 1,"0 0 * * *","GOTO MyFunc" will do "GOTO MyFunc" on every day at midnight (00:00).
ONDATE 1,"0 6,7,18,19 * * *","GOTO MyFunc" will do "GOTO MyFunc" at 6, 7, 18 and 19 o’clock on every day.
See also:
“TSET” on page 56, “ONTIMER” on page 38
1.2.54 ONERROR
Syntax [command]
ONERROR S1
• S1 is the command line to execute when an error occurs during program execution.
Purpose:
The EVTINFO parameter (See GETSYS, SETSYS on page 24) is set to the code of the error.
Example:
ONERROR "goto TrapError"
See also:
“GETSYS, SETSYS” on page 24, “ONxxxxxx” on page 33
1.2.55 ONPPP
Syntax [command]
ONPPP S1
• S1 is the command line to execute when the PPP connection goes online or offline.
Purpose:
The EVTINFO parameter (see GETSYS page 24) is set to one of the following values:
EVTINFO Value Situation
1 The PPP connection has gone ONLINE
2 The PPP has gone OFFLINE
Example:
ONPPP "goto PppAction"
END
PppAction:
I%=GETSYS PRG,"EVTINFO"
IF I%=1 then
PRINT "Online with address";GETSYS PRG,"PPPIP"
ELSE
PRINT "PPP Going offline"
ENDIF
END
See also:
“GETSYS, SETSYS” on page 24, “ONxxxxxx” on page 33
1.2.56 ONSMS
Syntax [command]
ONSMS S1
• S1 is the command line to execute when eWON receives a SMS.
Purpose:
A typical use of the ONSMS syntax is allowing eWON to send a read SMS receipt to the SMS sender.
You can read the received SMS with GETSYS PRG function with:
• smsRead:
hold 1 if there is a new SMS (reading smsRead load the other parameters)
hold 0 if the SMS queue is empty
• smsFrom:
String holding the phone number of the sender
• smsDate:
String holding the Date of SMS reception
• smsMsg:
String holding the SMS message
Example:
InitSection:
ONSMS "Goto HSms"
HSms:
a% = getsys prg,"SmsRead"
if (a%<>0) then
s% = s%+1
print "SMS Nr: ";s%
f$ = getsys prg,"smsfrom"
print "From: ";f$
print getsys prg,"smsdate"
a$ = getsys prg,"smsmsg"
print "Message: ";a$
b$ = f$+",gsm,0"
c$ = "Received message: "+a$
sendsms b$,c$
goto HSms
endif
end
1.2.57 ONSTATUS
Syntax [command]
ONSTATUS S1
• S1 is the command line to execute when a scheduled action is finished.
Purpose:
The EVTINFO parameter (see GETSYS page 24) is set to the ACTIONID of the finished action when command is called. This function
can be used to track success or failure of scheduled actions.
Example:
ONSTATUS "goto Status"
See also:
“GETSYS, SETSYS” on page 24, “ONxxxxxx” on page 33, “PUTFTP” on page 46, “SENDMAIL” on page 49, “SENDSMS” on
page 49, “SENDTRAP” on page 50
1.2.58 ONTIMER
Syntax [command]
ONTIMER E1,S1
• E1 is the timer number (see TSET page 56)
• S1 is the command line to execute when timer expires.
Purpose:
Executes S1 command line when E1 expires.
The EVTINFO parameter (see GETSYS page 24) is set to the timer number when command is called.
Example:
ONTIMER 1,"goto Timer1"
ONTIMER 1, "LOGIO ‘mytag’ "
See also:
“GETSYS, SETSYS” on page 24, “ONxxxxxx” on page 33, “TSET” on page 56
1.2.59 ONVPN
Syntax [command]
ONVPN S1
• S1 is the command line to execute when the VPN connection status change (at connection or at disconnection).
Purpose:
The EVTINFO parameter (see GETSYS page 24) is set to one of the following values:
EVTINFO Value Situation
1 The VPN connection has gone ONLINE
2 The VPN has gone OFFLINE
Example:
ONVPN "goto VPN_Action"
END
VPN_Action:
I%=GETSYS PRG,"EVTINFO"
IF I%=1 then
PRINT "VPN Online"
ELSE
PRINT "VPN Going offline"
ENDIF
END
See also:
“GETSYS, SETSYS” on page 24, “ONxxxxxx” on page 33
1.2.60 ONWAN
Syntax [command]
ONWAN S1
• S1 is the command line to execute when the WAN connection status change (at connection or at disconnection).
Purpose:
The EVTINFO parameter (see GETSYS page 24) is set to one of the following values:
EVTINFO Value Situation
1 The WAN connection has gone ONLINE
2 The WAN has gone OFFLINE
Example:
ONWAN "goto WAN_Action"
END
WAN_Action:
I%=GETSYS PRG,"EVTINFO"
IF I%=1 then
PRINT "WAN Online with address";GETSYS PRG,"WANIP"
ELSE
PRINT "WAN Going offline"
ENDIF
END
See also:
“GETSYS, SETSYS” on page 24, “ONxxxxxx” on page 33
1.2.61 OPEN
Parameter
Description
value
INPUT The file must exist. It is opened for a read only operation. The file pointer is set to the beginning of the file
OUTPUT The Path must exist. If the file exists it is erased first. The file is opened for write only operation
The Path must exist. The file must not exist. If the file does not exist, it is created (like with OUTPUT type), if
APPEND the file exists, it is opened and the write pointer is located at the end of the file. The file is opened for write only
operation
When binary mode is used, the data written to the file are strings of characters that are considered as stream of bytes. The GET
command returns the amount of bytes requested.
When Text mode is used, the operation is completely different: the PUT operation is more like a PRINT command directed to file, the data
are formatted as text, and each data is separated by a ‘;’ in the output file (strings are exported between quotes). The GET command
works like a READ command, the file is read sequentially and each GET returns one of the ‘;’ separated element, the type of the data
returned depends on the type of data read.
In both modes, files are read sequentially until end of file is reached. End of file can be tested with the EOF function.
The eWON user flash file system allows up to 8 files to be simultaneously opened for read (even twice the same file), and 1 file opened
for write. If a file is opened for read it cannot be opened for write at the same time (and vice versa).
Running the program will close any previously opened files (not GOTO).
This allows to read or write files in the /usr directories. You will not be able to access the files in the root (virtual files like config.txt) with
this command.
Example Comment
• If S1 does not begin by "file:", "tcp", "com", or "exp", then the file will be considered as being part of the /usr directory.
Example Comment
This syntax was the old (ver 3) syntax and is kept for compatibility purpose.
“tcp:Address:dest_Port[,TimeOut]”
“udp:Address:dest_Port[:src_Port][,TimeOut]”
Address can be a dotted IP address like 10.0.0.1 or a valid resolvable internet name like ftp.ewon.be
src_Port (optional) If defined, the return port will be forced to the src_Port value (works only with UDP protocol).
If not defined, the return port is allocated automatically by the eWON TCP/IP stack.
TimeOut (optional) is the number of seconds eWON will wait to decide if the OPEN command failed (default : 75 sec)
E1 is the file number. After the OPEN operation, the file is referenced by its file number and not by its file name. There are 8 file numbers
available. Once a file number is assigned to a file, it is allocated to that file, until the CLOSE command is issued.
WARNING - scheduled action: when the OPEN command is used to open a TCP connection, the command returns before
the connection is actually opened. A scheduled action is posted because opening the socket may require a dial out or take
up to more than a minute, and the BASIC cannot be stopped during that time.
Example Comment
S1 will be as follows:
"com:n,b,dpsh"
• where n is 1 to 4 (the port number, 1 is Front panel serial port, 2 is Modem Port)
• where b is the baud rate
• where d is the number of bits "7" or "8"
• where p is the parity: "e","o" or "n"
• where s is the number of stop bit "1" or "2"
• where h is the handshaking "h": half duplex, "r": yes Rts/Cts, "n": No
This command will open the serial port to port 1 to 4 with the given line parameters.
E1 is the file number. After the OPEN operation, the file is referenced by its file number and not by its file name. There are 8 file numbers
available. Once a file number is assigned to a file it is allocated to that file until the CLOSE command is issued.
REM: Attempting to USE a serial port used by an IO server is not allowed and returns an error.
Example:
Example Comment
Example 2:
OPEN "exp:$dtUF $ftT $fn/myfile.txt" FOR TEXT INPUT AS
1
A$ = Get 1
PRINT A$
CLOSE 1
See also:
“CLOSE” on page 14, “EOF” on page 17, “GET” on page 21, “PUT” on page 44
1.2.62 OR
Syntax [Operator]
E1 OR E2
Purpose:
Does a bit-by-bit OR between the 2 integers E1 and E2.
WARNINGS:
• When executed on float elements (float constant or float variable), the OR functions returns the logical OR operation.
• When executed on integer elements (integer constant or integer variable - like i%), the OR function returns the bitwise OR
operation
• This is NOT true for AND and XOR
• This is historical and is left for compatibility with existing programs
Examples:
1 OR 2 REM returns 3
2 OR 2 REM returns 2
3 OR 1 REM returns 3
• Logical OR:
var1=0.0
var2=0.0
ORResult = var1 OR var2
Print ORresult
rem ORResult = 0.0
var1=0.0
var2=12.0
OR Result = var1 OR var2
Print ORresult
rem ORResult = 1.0
See also:
“Operators priority” on page 8, “AND” on page 12, “XOR” on page 58
1.2.63 PI
Syntax [function]
PI
Purpose:
1.2.64 PRINT - AT
Syntax [Command]
PRINT CA
This command displays the text CA followed by a new line.
PRINT CA;
This command displays the text CA without a new line.
PRINT AT E1, E2 CA
This command displays the text CA at the E1 column and at the E2 line.
PRINT CA1;CA2[;CA3...]
Display the CA1, CA2 text etc. one following the other (don't pass to next line).
Purpose:
The eWON has a virtual "screen" that can be used in order to inspect the content of values while the program is running, or in order to
debug an expression…
Example:
See also:
“CLS” on page 14
1.2.65 PRINT #
Syntax [Command]
PRINT #x,CA
With x defined as follows:
Value Description
1 Virtual screen
1.2.66 PUT
The put command works completely differently if the file is opened in Binary mode or in Text mode. The file must be opened for OUTPUT
or for APPEND operation (APPEND for /usr files only).
123;"ABC";"DEF"
345.7;"YYY";"ZZZ"
REM: there is a CRLF at the end of the last line, PUT 1,345.7;"YYY";"ZZZ"; would avoid that.
Writes the S1 string to the serial port. The function returns only after all the data have been actually sent.
Warnings:
• The string can contain any byte by using the CHR$ function.
• Serial port cannot be used by an IO server in the same time, or it would result to a “IO Error”.
See also:
“CLOSE” on page 14, “EOF” on page 17, “GET” on page 21, “OPEN” on page 40.
1.2.67 PUTFTP
Syntax[command]
PUTFTP S1,S2 [,S3]
• S1 is the destination file name (to write on the FTPServer)
• S2 is the file content (String)
This content may be an EXPORT_BLOCK_DESCRIPTOR content.
See also chapter “Export block descriptor” in the General User Guide.
• S3 (optional) is the FTP server connection parameters.
If S3 is unused, the FTPServer parameters from the General config page will be used.
Purpose:
Put a file on a FTP server, content of the file is either a string or an Export_Bloc_Descriptor.
When the function returns, the GETSYS PRG,"ACTIONID" returns the ID of the scheduled action and allows tracking this action. It is also
possible to program an ONSTATUS action that will be called when the action is finished (with or without success).
Examples:
REM Post a file containing a custom text
PUTFTP "/ewon1/MyFile.txt","this is the text of the file"
REM Post a file containing the event log
PUTFTP "/ewon1/events.txt","[$dtEV]"
REM Post on a defined FTP server, a file with the Histo logging of Temperature tag
PUTFTP "/ewon1/Temperature.txt","[dtHL$ftT$tnTemperature]","user:pwd@FTPserver.com"
See also:
“GETSYS, SETSYS” on page 24, “ONxxxxxx” on page 33, “ONSTATUS” on page 38.
1.2.68 PUTHTTP
Syntax [Command]
PUTHTTP S1,S2,S3,S4,S5 [,S6]
• S1: Connexion Parameter with the format [User:Password@]ServerName[:Port]
• S2: URI of the action (absolute path of the request URI)
• S3: Text fields with the format [FieldName1=ValueName1][&FieldNameX=ValueNameX]*
• S4: File fields with the format
[FieldName1=ExportBlockDescriptor1][&FieldNameX=ExportBlockDescriptorX]*
• S5: Error String
• S6 (Optional): "PROXY"
Notes:
• In the preceding syntax description the square brackets are used to define an optional section for a given parameter.
The * is used to indicate that the preceding optional section may be repeated 0 to n times.
• All the parameters are mandatory. If you don't need to post Text fields, just write an empty string for the S3 parameter
• The HTTP Server response sent back will be checked against the Error String. If the Response contains the Error String the
command will finish without success.
• Spaces in Text fields and File fields strings are not allowed except inside export block descriptors (inside the EBD brackets).
• One fieldname=valuename section in the text field parameter may not exceed 7500 bytes (Otherwise action will finish without
success). This limitation does not apply for the file fields.
Purpose:
The PUTHTTP command submit an HTTP form to a Web server (like you do when you answer a Web form).
The submitted forms may contain text fields and file fields.
The HTTP method used is the POST method (multipart/form-data). Content Type of the file fields is always application/octet-stream.
Files to upload are defined using the Export Block descriptor syntax (See also Export Block descriptor section in the eWON reference
guide).
When the function returns, the GETSYS PRG, returns the ID of the scheduled action and allows tracking of this action.
It is also possible to program an ONSTATUS action that will be called when the action is finished (with or without success).
When "PROXY" is added at the end of the command, the eWON will perform the PUTHTTP through a Proxy server. The eWON will use
the Proxy server parameters configured in System Setup / Communication / VPN Global.
Important: The posting method used (chunked packets) is only correctly handled on IIS 6.0 and Apache Webservers.
Posting on IIS 5 doesn’t work (Windows XP). Chuncked packets are not applied when the "PROXY" parameter is used
because most Proxy servers do not accept them. If PUTHTTP is used with the "PROXY" parameter, then eWON creates
a temporary file named "puthttp.proxy" in the /usr directory to store the data locally before sending it towards the server
via the Proxy.
Examples:
• Textfields form without HTTP basic authentfication:
PUTHTTP "10.0.5.33","/textfields.php","firstname=jack&lastname=nicholson","","failed"
When file fields are not needed an empty string is used for parameter S4.
When no port is specified HTPP port 80 is used.
See also:
“ONSTATUS” on page 38, “GETSYS, SETSYS” on page 24, “GETHTTP” on page 23,
see Export Block Descriptor on General Reference Manual
1.2.69 REBOOT
Syntax [Command]
REBOOT
Purpose:
A typical use of this command is by simply entering it into a file you name "remote.bas" then saving locally and uploading this file on the
eWON FTP site to replace the existing remote.bas file. eWON then directly reboots.
1.2.70 REM
Syntax [command]
REM free text
Purpose:
This command enables the insertion of a line of comment in the program. The interpreter does not consider the line.
Example:
PRINT a%
REM we can put whatever comment we want here
a%=2: REM Set a% to 2
1.2.71 RENAME
Syntax [Command]
RENAME S1,S2
• S1, S2 are string.
Purpose:
Change the name of file S1 to S2. The command only works in the “/usr” directory.
Omitting "/usr/" before the filename will result to a I/O error.
The file and directory names are case sensitive.
The directory must exist before the call of the function. There is no automatic directory creation.
Example:
RENAME "/usr/OldName.txt","/usr/NewName.txt"
See also:
“ERASE” on page 17
1.2.72 RTRIM
Syntax[Command]
RTRIM S1
• S1 is a string.
Purpose:
RTRIM returns a copy of a string with the rightmost spaces removed.
Example:
b$ = RTRIM a$
See also:
“LTRIM” on page 32
1.2.73 SENDMAIL
Syntax[command]
SENDMAIL S1,S2,S3,S4
• S1 is the E-mail address of the recipients (TO). Multiple recipients can be entered separated by ‘;’.
• S2 is the E-mail address of the recipient Carbon Copies (CC). Multiple recipients can be entered separated by ‘;’.
• S3 is the subject of the message.
• S4 is the content of the message.
Purpose:
This command posts a scheduled action request for an Email generation. When the function returns, the GETSYS PRG,"ACTIONID"
returns the ID of the scheduled action and allows tracking this action. It is also possible to program an ONSTATUS action that will be
called when the action is finished (with or without success). The S4 message content follows a special syntax that allows sending
attachments and inserting Export data inside the content itself (See also chapter “Export block descriptor” in the General User Guide).
The content field (S4) syntax can content any number of [EXPORT_BLOCK_DESCRIPTOR], these blocks will be replaced by their actual
content.
Example:
S4 = "Event Log data [$dtEV] And a real time table: [$dtRL $ftT $tnMyTag]"
Rem will generate an Email with [$dtEV] and [$dtRL…] replaced by the actual data.
If instead of putting [EXPORT_BLOCK_DESCRIPTOR] you put &[EXPORT_BLOCK_DESCRIPTOR], then the same data is attached to
the Email. The position in the S4 field where the &[..] is placed does not matter, the attachment &[…] descriptor will NOT appear in the
content itself, but will produce the given attachment.
Example:
M$ = "Event Log data are attached to this mail &[$dtEV]"
Rem will generate an Email with "Event Log data are attached to this mail " as content
and an attachment with the events log.
See also:
“GETSYS, SETSYS” on page 24, “ONxxxxxx” on page 33, “ONSTATUS” on page 38.
1.2.74 SENDSMS
Syntax[command]
SENDSMS S1,S2
• S1 is the SMS recipients list.
Please refer to chapter “SMS on alarm configuration” in the General User Guide, for syntax of this field.
• S2 is the content of the message (maximum 140 characters).
Purpose:
This command posts a scheduled action request for an SMS generation.
When the function returns, the GETSYS PRG,"ACTIONID" returns the ID of the scheduled action and allows tracking this action. It is also
possible to program an ONSTATUS action that will be called when the action is finished (with or without success).
Example:
REM send an SMS to 2 recipients.
D$ = "0407886633,ucp,0475161622,proximus"
D$ = D$ + ";" + "0407886634,ucp,0475161622,proximus"
SENDSMS D$, "Message from eWON"
See also:
“GETSYS, SETSYS” on page 24, “ONxxxxxx” on page 33, “ONSTATUS” on page 38.
1.2.75 SENDTRAP
Syntax[command]
SENDTRAP I1,S1
• I1 is the first trap parameter (INTEGER)
• S1 is the second trap parameter (STRING)
Purpose:
This command posts a scheduled action request for an SNMP TRAP generation.
The first parameter is sent on OID .1.3.6.1.4.1.8284.2.1.4.2
The second parameter is sent in OID .1.3.6.1.4.1.8284.2.1.4.1
--
-- Script information
--
ewonScript OBJECT IDENTIFIER ::= { prodEwon 4 }
scpUserNotif OBJECT-TYPE
SYNTAX DisplayString (SIZE (0..255))
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"This is the text of the last trap sent by the Script"
::= { ewonScript 1 }
scpUserNotifI OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"This is a free parameters for script generated traps"
::= { ewonScript 2 }
When the function returns, the GETSYS PRG,"ACTIONID" returns the ID of the scheduled action and allows tracking this action. It is also
possible to program an ONSTATUS action that will be called when the action is finished (with or without success).
Example:
REM send a trap with NotifI = 10 and Notif = Trap message
SENDTRAP 10,"Trap message"
See also:
“GETSYS, SETSYS” on page 24, “ONxxxxxx” on page 33, “ONSTATUS” on page 38.
1.2.76 SETIO
Syntax [command]
SETIO TagRef, F1
• TagRef is the Tag reference (TagName, ID or -Index) See Tag Access on page 10
• F1 is the value to give to the Tag.
Purpose:
Modifies the value of a Tag. The Tag must be writable (not for the read-only Tags).
Note:
In many cases this function is efficiently replaced by the TagName@ syntax. For example SETIO "MyTag", 10.2 is equivalent
to MyTag@=10.2
Example:
SETIO "MYTAG", 10.123
1.2.77 SETTIME
Syntax [Command]
SETTIME S1
• S1 is the new date / time to set.
• S1 can contain only the time. In that case the date is not modified.
• S1 can contain only a date. In that case the time is set to 00:00:00
Purpose:
Note:
An event is generated in the events log.
Example
REM The following are valid time updates
SETTIME "1/1/2000": REM Time is set to 01/01/2000 00:00:00
SETTIME "01/12/2000 12:00": REM Time is set to 01/12/2000 12:00:00
PRINT TIME$: REM suppose it returns "15/01/2000 07:38:04"
SETTIME "12:00": REM Time is set to 15/01/2000 12:00:00
See also:
“TIME$” on page 55
1.2.78 SFMT
Syntax [Command]
SFMT Item,EType[,ESize,SFormat]
• Item is the number (Integer or Float) to format into string.
• EType is the parameter determining the type of conversion.
• ESize is the size of the output string as formated.
• SFormat is the format specifier for the conversion.
Purpose:
Converts a number (float or integer) to a formated string.
The type of conversion is determined by the EType parameter.
If ESize is equal to 0 (or negative) with a SFormat present, then ESize is the size of the output string as formated.
If ESize is positive, SFMT will produce a string of ESize bytes.
See also:
“FCNV” on page 18
EType = 1 or 2
The string could be LSB first or MSB first.
A$ = SFMT FloatNum, 1 : convert FloatNum to a string holding the IEEE representation with MSB first
A$(1) = MSB (Exponent+ Sign) ... A$(4) = LSB (Mantissa LSB)
A$ = SFMT FloatNum, 2 : convert FloatNum to a string holding the IEEE representation with LSB first
A$(1) = LSB (Mantissa LSB) ... A$(4) = MSB (Exponent+ Sign)
Example:
ieee = -63.456
A$ = SFMT ieee,1
rem a$(1)=194 a$(2)=125 a$(3)=210 as(4)=242
A$ = SFMT ieee,2
rem a$(1)=242 a$(2)=210 a$(3)=125 as(4)=194
A$ = SFMT a%,11,4
rem a$(1)=254 a$(2)=5 a$(3)=0 as(4)=0
width • number : set the length of the whole string for padding.
(optional) Only needed when flag 0 is used.
.precision • number : the decimal portion of the output will be expressed in at least
(optional) number digits.
Examples:
MyVal = 164.25
A$ = SFMT MyVal,20,0,"%f"
rem a$="164.250000"
A$ = SFMT MyVal,20,0,"%012.3f"
rem a$="00000164.250"
A$ = SFMT MyVal,20,0,"%e"
rem a$ = "1.642500e+02"
width • number : set the length of the whole string for padding.
(optional) Only needed when flag 0 is used.
Examples:
a% = 2568
A$ = SFMT a%,30,0,"%010d"
rem a$="0000002568"
A$ = SFMT a%,30,0,"%o"
rem a$="5010" OCTAL notation
A$ = SFMT a%,30,0,"%X"
rem a$ = "A08"
1.2.79 SGN
Syntax [function]
SGN F1
Purpose:
1.2.80 SQRT
Syntax [function]
SQRT F1
Purpose:
Example:
SQRT 16 :REM returns 4
1.2.81 STR$
Syntax [function]
STR$ F1/E1
Purpose:
Example:
a%=48
a$= STR$ a%
REM A$ is worth " 48 " after this affectation
See also:
“VAL” on page 56
1.2.82 TIME$
Syntax[function]
TIME$
Purpose:
Returns the string with the current date and time. The output format is “dd/mm/yyyy hh:mm:ss” (ex: “25/10/2004 15:45:55”)
The number of characters in the returned string is constant.
Note:
The GETSYS command provides a mean to return the current time as a number of seconds since 1/1/1970.
The SFMT and FCNV functions allow you to convert between TimeString and TimeInteger.
Example:
PRINT TIME$
See also:
“SETTIME” on page 51, See FCNV on page 18, See SFMT on page 52
1.2.83 TGET
Syntax[function]
TGET E1
• E1 is the number of the timer (1 to 4).
Purpose:
Returns N (>0) if the timer expires and then resets the value (N is the number of times the timer has expired).
Returns '0' if the timer did not expired since the last call to TGET.
Example:
REM timer 1 minute
TSET 1,60
Label1:
IF NOT TGET 1 GOTO LABEL1
See also:
“ONTIMER” on page 38, “TSET” on page 56.
1.2.84 TSET
Syntax[Command]
TSET E1, E2
• E1 is the number of the timer (1 to 4).
• E2 is the value in seconds of the timer.
Purpose:
Initializes the timer E1 at an E2 time base (in second). The timer is read by TGET.
Example:
REM timer 1 minute
TSET 1,60
Label1:
IF NOT TGET 1 GOTO LABEL1
To stop a timer, you must put the value 0:
TSET 1,0
See also:
“ONTIMER” on page 38, “TGET” on page 55.
1.2.85 VAL
Syntax [function]
VAL S1
Purpose:
The function evaluates the character string and returns the corresponding expression.
Note:
VAL is a function that usually takes an expression and returns a Real after expression evaluation. This VAL function can also
evaluate an expression that returns a string.
Example:
a$= "12"
a% = VAL (" 10"+ a$)
REM a% equal 1012
a$="abc"
b$="efg"
c$=val("a$+b$")
REM c$ equal "abcefg"
See also:
“STR$” on page 55.
1.2.86 WAIT
Syntax [function]
WAIT N1,S[,N2]
• N1 is the File number to wait on.
• S is the operation to execute (max 255 char)
• N2 is the timeout in sec (if omitted, the default is 60 sec)
Purpose:
The WAIT command is used to monitor events on files.
Currently the events monitored are:
• Data received on TCP and UDP socket
Wait for data available on N1 (or TimeOut) and then execute the S operation (ex: "goto DataReceived").
The WAIT function will register a request to wait for the event, it will not block until the event occurs.
When the WAIT function calls the operation, it will preset the EVTINFO (see Getsys PRG,”EvtInfo”), with the result of the operation:
EVTINFO meaning
-1 The wait operation was aborted because of an error on the file monitored (for example the file
was closed).
-2 The condition was not met during the wait operation (TimeOut).
You can have a maximum of 4 WAIT command pending at the same time.
If a WAIT command is pending on a file and another WAIT command is issued on the same file, an “IO Error” error will occur.
tw:
Cls
Close 1
OPEN "tcp:10.0.100.1:7" FOR BINARY OUTPUT AS 1
o%=0
wo:
a% = Getsys Prg,"actionstat"
If a%=-1 Then Goto wo
Put 1,"msg_start"
Wait 1,"goto rx_data"
End
rx_data:
a%=Getsys Prg,"evtinfo"
If (a%>0) Then
Print "info:";a%
a$=Get 1
Print a$
Put 1,"abc"+Str$(o%)
o%=o%+1
Wait 1,"goto rx_data"
Else
Print "error:";a%
Endif
1.2.87 WOY
Syntax [Function]
WOY E1 / S1
• E1 is a date in integer format (number of seconds since 1/1/1970)
• S1 is a date in String format ("18/09/2003 15:45:30")
Purpose:
This function returns an integer corresponding to the ISO8601 Week-Of-Year number that matches a specified time variable.
REM: Do not call the function with a float variable of value (or this would result to error "invalid parameter").
Example 1:
a$ = TIME$
a% = WOY a$
Example 2:
b% = getsys prg,"TIMESEC"
a% = WOY b%
See also:
“DAY” on page 14, “DOW” on page 15, “DOY” on page 16, “MONTH” on page 33
1.2.88 XOR
Syntax [Operator]
E1 XOR E2
Purpose:
This command returns the bitwise XOR comparison of E1 and E2.
a XOR b returns 1 if a if true or if b is true, but NOT IF both of them are true.
Example:
1 XOR 2 returns 3
2 XOR 2 returns 0
See also:
“Operators priority” on page 8, “AND” on page 12, “OR” on page 43.
syntax error 0
'( or )' expected 1
no expression present 2
'=' expected 3
not a variable 4
invalid parameter 5
duplicate label 6
undefined label 7
THEN expected 8
TO expected 9
too many nested FOR loops 10
NEXT without FOR 11
too many nested GOSUBs 12
RETURN without GOSUB 13
Out of memory 14
invalid var name 15
variable not found 16
unknown operator 17
mixed string&num operation 18
Dim index error 19
',' expected 20
Number expected 21
Invalid assignment 22
Quote too long 23
Var or keyword too long 24
No more data 25
reenter timer 26
label not found 27
Operation failed 28
ENDIF expected 29
ENDIF without IF 30
ELSE without IF 31
Math error 32
IO Error 33
End of file 34
val in val 35
Table 23:
PrgAutorun 1 if script starts at eWON boot time. See script control page Script Setup
MbsBaudRate Modbus baud rate. 0 if disabled, positive value otherwise IO Server Config Æ Modbus
Mbs2StopBit 1 if Modbus IO server uses two stop bits, 0 if it uses 1 stop bit IO Server Config Æ Modbus
MbsParity 0 for none, 1 for even, 2 for odd IO Server Config Æ Modbus
MbsPR(x) x = 1..3, Modbus topic 1..3 polling rate (expressed in Msec) IO Server Config Æ Modbus
Page(x) x = 1..11, User Page as defined in the Page Lists config page Pages List
IOSrv(x) x = 0..9
SmtpAllowB64
MbsEn(x) x=1..3, Modbus Topic x enabled (1 if enabled, 0 otherwise) IO Server Config Æ Modbus
FTPC_SDTO
FTPC_SCTO
FTPC_ACTO
FTPC_RDTO
DNS_SRTO
SnmpAlwAll Accepts SNMP packet from any host (1 = enabled) System Setup/General/SNMP
The MbsBits parameter specifies how to Modbus IO Server will read the bytes. The possible values are 7 and 8 bits/byte.
Example:
Setting the First ISP phone number (parameter = PPPClPhone1) to number 0123456789:
SETSYS COM, "LOAD"
SETSYS COM, "PPPClPhone1","0123456789"
SETSYS COM, "SAVE"
The following table describes the fields accessible from the communication configuration. The last column gives the ewon configuration
web page where the parameter appears. The web pages are found under System Setup.
InEqualOut Enable Usage of dial in connection to dial out (enabled = 1) Communication/Dial UP (PPP)
CBPubEMail Email address where to send the IP address when callback Communication/Callback
CBNbRingOH Number of rings more than the minimal for callback Communication/Callback
Type Value
Not used -1
No modem 0
14400 baud 1
33600 baud 2
56600 3
ISDN 4
Unknown 5
***Modem type can be found in the eWON Information page you open by clicking on the eWON Logo. In the above case: “Internal
BIBAND GSM (131)”
Description Value
The last server that worked will be used for next call -1
The following table describes the fields accessible from the Tag configuration. The web pages are found under Tag Setup/Tag Name.
Name Description
Id Tag id. Not editable through the web page (only for program usage)
EAT Email alarm attachment (as Export Block Descriptor) alarm notification config
FCO FTP file content (as Export Block Descriptor) alarm notification config
x 8
x 16
x 32
x 2
If you activate several of the send on alarm actions checkboxes, the result of the value will be an addition of selected fields’ values:
Example:
If you activate “ALM” and “END” to trigger an SMS sending, the value of the “SEN” field will be 10.
MM1@ = 1234
setio "MM1",1234
Let’s the MM1 Tag is in alarm state. It is then possible to acknowledge its alarm with the following command:
SETSYS TAG, "LOAD", "MM1"
SETSYS TAG, "DoAck", 1
SETSYS TAG, "SAVE"
Example:
Changing password of user "pierre"
SETSYS USER, "LOAD", "pierre"
SETSYS USER, "password", "new_password"
The following table describes the fields accessible from the User configuration. The web pages are found under Users Setup/[The name
from the User].
Name Description
Right Combination of bits for user rights on Tags (acknowledge, view, write, …)