4 running your program – Rice Lake iRite IDE User Manual

Page 6

Advertising
background image

2

920i

Programming Reference

Writing custom event handlers is what

iRite

is for.

Each of the

920i

tasks share processor time, but some

tasks have higher priorities than other tasks. If a low
priority task is taking more than its share of processor
time, it will be suspended so a higher priority task can
be given processor time when it needs it. Then, when
all the other higher priority tasks have completed, the
low priority task will be resumed.

Gathering analog weight signals and converting it to
weight data is the

920i

’s highest priority. Running a

user-defined program has a very low priority.
Streaming data out a serial port is the lowest priority
t a s k , b e c a u s e o f i t s m i n i m a l c o m p u t a t i o n a l
requirements. This means that if your

iRite

program

"hangs", the task of streaming out the serial ports will
never get any CPU time and streaming will never
happen. An example of interrupting a task would be if
a user program included an event handler for SP1Trip
(Setpoint 1 Trip Event) and this event "fired".

Let’s assume the logic for the SP1Trip event is
executing at a given moment in time. In this example,
the programmer wanted to display the message
"Setpoint 1 Tripped" on the display. If the SP1Trip
event logic doesn’t complete by the time the

920i

needs to calculate a new weight, for example, the
SP1Trip handler will be interrupted immediately, a
new weight will be calculated, and the SP1Trip event
w i l l r e s u m e e x e c u t i n g e x a c t l y w h e r e i t w a s
interrupted. In most circumstances, this happens so
quickly the user will never know that the SP1Trip
handler was ever interrupted.

How Do I write and Compile iRite Programs?

Templates and sample programs are available from
RLWS to provide the skeleton of a working program.
Once you have the

iRev

Editor open, you are ready to

start writing a program.

iRite

source files are named

with the .src extension.

In addition to writing .src files you may write include
files with an extension .iri. The

iRite

language doesn’t

have the ability to include files, but when using

iRev

you can. An include file can be helpful in keeping
your .src program from getting cluttered with small
unrelated functions and procedures that get used in
many different programs. For example, you could
create a file named math.iri and put only functions
that perform some kind of math operation not
supported in the

iRite

library already. When the

program is compiled through

iRev

, the .iri file is

placed where you told it to be placed in

iRev

. Because

iRite

enforces "declaration before use", the iri file

needs to be placed before any of the subprograms in
your .src file.

When you are ready to compile your program, use the
"Compile" feature from the "Tools" menu in the

iRev

Editor. If the program compiles without errors a new
text file is created. This new text file has the same
name but an extension of .cod. The new file named

your_program.cod

is a text file containing commands

that can be sent to the

920i

via an RS232 serial

communication connection between your computer
and the

920i

. Although the .cod file is a text file, most

of it will not be understandable. There is really no
reason to edit the .cod file and we strongly discourage
doing so.

How Do I Get My Program into the 920i?

The

920i

indicator must be in configuration mode

before the .cod file can be sent. The easiest way to
send the .cod file to the

920i

is to use

iRev

. You can

use the

Send .COD file to Indicator

option under the

Tools

menu in the

iRev

Editor, or you can send the .cod file

d i r e c t l y f r o m

i R e v

b y u s i n g t h e

D o w n l o a d

Configuration…

selection on the

Communications

menu

and specifying that you want to send the .cod file.

If the

920i

indicator is not in configuration mode,

iRev

w i l l p o p - u p a m e s s a g e i n f o r m i n g y o u o f t h i s
condition. It is strongly recommended that you use

iRev

or the

iRev

Editor to send the compiled program

to the

920i

. This method implements error checking

on each string sent to the indicator and helps protect
from data transmission errors corrupting the program.

1.4

Running Your Program

A program written for the

920i

is simply a collection

of one or more custom event handlers and their
supporting subprograms. A custom event handler is
run whenever the associated event occurs. The

ProgramStartup

event is called whenever the indicator

is powered up, is taken out of configuration mode, or
i s s e n t t h e R S s e r i a l c o m m a n d . I t s h o u l d b e
straightforward when the other event handlers are
called. For example, the

DotKeyPressed

event handler

is called whenever the "." key is pressed.

All events have built-in intrinsic functionality
a s s o c i a t e d w i t h t h e m , a l t h o u g h , t h e i n t r i n s i c
functionality may be to do nothing. If you write a
custom event handler for an event, your custom event
handler will be called instead of the intrinsic function,
and the default action will be suppressed.

Advertising
This manual is related to the following products: