131
Pattern Processing
Now that the data has been captured it has to be processed ready for display. The purpose of the Serial Text Display is
to supply a user with information in a manner which makes it easy for them to do their job. This discussion will
concentrate on how to get the data from the matched string and display it in the simplest manner. More complex and
visually pleasing displays can be created as the user wishes.
Processing the captured data falls in to three basic areas; Firstly there is the
direct acti
on of taking an ASCII byte from
the matched string and writing it to the current cursor position. Secondly there is
indirect action
, where the bytes from
the match string are fed through to the routine cyclic data section of the text display, allowing the use of bar graphs.
Finally there is the
decision making
part of the process in which the data in one or more bytes directs the flow of the
script.
Direct Action Commands
The direct action command is
*PW
n
,
m
,
p
Pattern Write. It takes bytes from the matched data and writes them at the
current cursor position on the display using any attributes that have been previously set. The parameter
n
defines the
pattern number to use (1-4),
m
indicates the position of the first byte to be extracted and
p
tells the system how many
characters to write. In our voltmeter example a
*PW1,3,6
would write the value transmitted from the host straight on
the screen.
So we can now develop our simple script to this:
*BB
*PS1,9
*PE1,gotit
*PD1,1,2
*PD1,9,3
*PC1,1
*BI
*LAgotit
*BB
F2
CM2,0
*PW1,3,6
*BI
This script sets up the pattern to match the data as before. When a match arrives it will write the value received on to the
screen of the display in font size 2. The cursor move
CM2,0
ensures that the latest value is written over the old value.
Indirect Action Commands
The indirect action commands are a little more complex. These commands work on a stored variable rather than writing
directly to the screen. The concepts behind cyclic data and mapped variables should be understood before attempting to
use this type of action. There are commands to add data to the store and then to convert the store into cyclic data. When
a script is first executed the store is empty, and once it has been converted to cyclic data, it is cleared. However there
may be times when the store needs to be cleared under script control. The Initialise Variable
*IV
command performs
this function.
To add data to the store the
*PV
n
,
m
,
p
Pattern Variable command is used in the same way as the
*PW
command,
except that the data is added to the store rather than being written directly to the screen. The store is relatively small and
can only handle 10 bytes but this is adequate for the purpose. The
*PV
command will only handle numerical data:
i.e. 0 to 9 and the characters “E + - .” Trying to use any other characters will cause an error. In the default state the error
is hidden from the user as the
*PV
command will just ignore the whole sequence. Thus the on screen data will not be
updated until the
*PV
command gets supplied with valid data again. During programme development the
*VD
Variable
Debug command can be used to force the display to report an error to the user, stopping the script in the process. Once
the
*VD
command has been issued, the debug mode is enabled until the script is stopped and restarted without the
command.
The next stage is to convert the stored value into cyclic data so that the cyclic data mechanism of the display can update
the mapped variables and bar graphs automatically. The
*MVn
Make Variable command is used to perform this task.
The parameter
n
is the target variable and must be in the range of 1 to 8, corresponding to the cyclic data values IN_1 to