Actions

Difference between revisions of "External Data Input"

From Zenitel Wiki

(Moved description of string and temp macroes to separate pages. Cleaned up the example)
Line 21: Line 21:
 
|-
 
|-
 
|}
 
|}
 +
  
 
*Input message
 
*Input message
Line 28: Line 29:
  
 
*Context parameters
 
*Context parameters
:- %edi is the input text where termination character is excluded
+
:- [[Edi (macro)|%edi]] is the input text where termination character is excluded
:- %sev is the EDI port (sub-event)
+
:- [[%sev]] is the EDI port (sub-event)
 
 
*Operator macros
 
:- %scutc(string,start-pos,lenght)
 
::* Extract substring by byte (character) position
 
::* Example: %scutc(0123456789,2,3) returns 234
 
::* Example: %scutc(%edi,4,3) returns 3 characters from the input string, starting from char 5
 
 
 
:- %scutf(string, delimiter, field-no)
 
::* Extract field, fields defined by delimiter character
 
::* delimiter is a single char, possibly escaped.  Example: Tab= \t  ‘,’ = \,
 
::* Optionally followed by + sign to indicate that more than one delimiter character is allowed between fields
 
::* field-no is a integer number, counting starts from zero!
 
::* Example: %scutf(%edi, +,3) extract field number 3; fields separated by any number of spaces
 
::* Example: %scutf(%edi,\,,3)extract field number 3; fields separated by commas
 
  
:- %sscan(string, search-string)[[Image:EDI - External Data Input (3).jpg|thumb|right|500px]]
+
*Useful macros and statements
::* Scan for string, extract rest of string after first match
+
:* [[%scutc]] - Extract substring by byte (character) position
::* Example: If %sscan(%edi,connect) Check if text has the string “connect”
+
:* [[%scutf]] - Extract field, fields defined by delimiter character
 +
:* [[%sscan]] - Scan for string, extract rest of string after first match
 +
:* [[%scmp]]  - Compare strings
 +
:* [[Tmp_statement|TMP]]  - Set temporary variable
 +
:* [[%tmp]]  - Read temporary variable
  
:- %scmp(string1,string2)
 
Compare strings. Return “1” if equal, empty string if not
 
  
*Temporary variables
+
== Example ==
  
:-Temporary variables (strings), numbered 0 to 9
+
[[Image:EDI - External Data Input (3).jpg|thumb|right|500px]]
:-Lives only within the action string
 
:-Set temporary variable:      TMP 0 "<string>"
 
:-Read temporary variable:  %tmp(0)
 
  
*The rules below will allow you to issue commands to EDI port like this:  
+
The rule below will allow you to issue commands to EDI port like this:
 
*connect,101,103
 
*connect,101,103
:-Generates internal <br\>command $CALL <br\>L101 L103
+
:-Generates internal command '''$CALL L101 L103'''
  
 
*disconnect,101,103
 
*disconnect,101,103
:-Generates internal <br\>command $C L101 <br\>and $C L103
+
:-Generates internal commands '''$C L101'''and '''$C L103'''
 +
 
 +
evh add edi 0
 +
tmp 0 "%scutf(%edi,\,,0)"
 +
tmp 1 "%scutf(%edi,\,,1)"
 +
tmp 2 "%scutf(%edi,\,,2)"
 +
if %scmp(%tmp(0),connect)
 +
  $call l%tmp(1) l%tmp(2)
 +
  stop
 +
endif
 +
if %scmp(%tmp(0),disconnect)
 +
  $c l%tmp(1)
 +
  $c l%tmp(2)
 +
  stop
 +
endif

Revision as of 15:34, 17 July 2007

Event description

Event Owner: EDI Text Config
Event type: External Data Input
Sub-Event: 1 – 4: specifies which EDI port. 0: matches all ports
When Change to ON: When valid data is received on EDI port
When Change to OFF: N/A
When Related to: N/A


  • Input message
- The EDI port is defined in the ‘Serial Ports’ Setup
- The input message must have a termination character. Max 128 char.
- Parsing the content is done in the action string
  • Context parameters
- %edi is the input text where termination character is excluded
- %sev is the EDI port (sub-event)
  • Useful macros and statements
  • %scutc - Extract substring by byte (character) position
  • %scutf - Extract field, fields defined by delimiter character
  • %sscan - Scan for string, extract rest of string after first match
  • %scmp - Compare strings
  • TMP - Set temporary variable
  • %tmp - Read temporary variable


Example

EDI - External Data Input (3).jpg

The rule below will allow you to issue commands to EDI port like this:

  • connect,101,103
-Generates internal command $CALL L101 L103
  • disconnect,101,103
-Generates internal commands $C L101and $C L103
evh add edi 0
tmp 0 "%scutf(%edi,\,,0)"
tmp 1 "%scutf(%edi,\,,1)"
tmp 2 "%scutf(%edi,\,,2)"
if %scmp(%tmp(0),connect)
 $call l%tmp(1) l%tmp(2)
 stop
endif
if %scmp(%tmp(0),disconnect)
 $c l%tmp(1)
 $c l%tmp(2)
 stop
endif