05.05.2014 Views

csmstr - Omega Engineering

csmstr - Omega Engineering

csmstr - Omega Engineering

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

WRITING ACTIONS<br />

CHANGING PAGE<br />

WRITING ACTIONS<br />

While expressions are used to define values, actions are used to define what you want to<br />

happen when a trigger or other event occurs. Since the vast majority of the actions in a<br />

database will relate to key-presses, and since Crimson provides a simple method of defining<br />

commonly-used actions via the dialog box discussed in the User Interface section, you will<br />

often be able to avoid writing actions “by hand”. Actions are needed, though, if you want to<br />

use triggers, write programs, or use a key in User Defined mode.<br />

CHANGING PAGE<br />

To create an action that changes the page shown on the Master’s virtual HMI, use the syntax<br />

GotoPage(Name), where Name is the name of the display page in question. The current page<br />

will be removed, and the new page will be displayed in its place.<br />

CHANGING NUMERIC VALUES<br />

Crimson provides several ways of changing data values.<br />

SIMPLE ASSIGNMENT<br />

To create an action that assigns a new value to a tag or to a register in a communications<br />

device, use the syntax Data:=Value, where Data is the data item to be changed, and Value<br />

is the value to be assigned. Note that Value need not just be a constant value, but can be any<br />

valid expression of the correct type. Refer to the previous section for details of how to write<br />

expressions. For example, code such as [N7:0]:=Tank1+Tank2 can be used to add two tank<br />

levels and store the total quantity directly in a PLC register.<br />

COMPOUND ASSIGNMENT<br />

To create an action that sets a data value equal to its current value combined with another<br />

value by means of any of the operators defined in the previous section, use the syntax<br />

Dataop=Value, where Data is the tag to be changed, Value is the value to be used by the<br />

operator, and op is any of the available operators. For example, the code Tag+=10 will<br />

increase Tag by a value of 10, while Tag*=10 will multiply the current value by 10.<br />

INCREMENT AND DECREMENT<br />

To create an action that increases a data value by one, use the syntax Data++. To create an<br />

action that decreases a tag by one, use the syntax Data--. Note that the ++ or -- operators<br />

may be placed before or after the data value in question. In the former case, the value of the<br />

expression represented by ++Data is equal to the value of Data after it has been incremented.<br />

In the latter case, the expression is equal to the value before it has changed.<br />

CHANGING BIT VALUES<br />

To change a bit within a tag, use the syntax Data.Bit:=1 or Data.Bit:=0 to set or clear the<br />

bit as required, where Data is the tag in question and Bit is the zero-based bit number. Note<br />

again that the value on the right-hand side of the := operator can be an expression if desired,<br />

REVISION 6 PAGE 269

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!