Crestron
SIMPL+
Software
Start creating a new SIMPL
+
program while running SIMPL Windows. Select
File
|
New | New SIMPL+ Module
.
The SIMPL
+
programming environment appears.
Instead of a blank window, a skeleton program filled with commented code shows
up. This commented out code makes it easy to remember the language syntax and
structure. Simply locate the necessary lines, uncomment them, and add the
appropriate code. To uncomment a line of code, either remove the “//” that appears at
the start of the line or remove the multi-line comment indicators /*…*/.
SIMPL
+
programs communicate with the SIMPL Windows wrapper program via
inputs and outputs. These inputs and outputs correspond to signals in the world of
SIMPL and can be digital, analog, or serial signals (if these terms are unfamiliar,
they are covered in more detail in “Input/Output Types”). For this first program, only
a single digital input is defined. Find the line of code that says “//
DIGITAL_INPUT”. Uncomment it and edit it so it looks like the following:
DIGITAL_INPUT speak;
This line defines the variable speak as the first digital input to the SIMPL
+
program.
Notice that most lines in SIMPL+ end in a semi-colon (;). To be precise, all
statements end with a semi-colon. The definition of a statement in SIMPL+ can be
found in the latest revision of the SIMPL+ Language Reference Guide (Doc. 5797).
When a digital input goes from low to high, a push event is generated. To define a
push event function for that signal, program this function to yield the desired actions.
From the skeleton program, find the commented line of code that says “push {”.
Uncomment the function block by removing the surrounding comment characters
and edit it to read the following:
PUSH speak
{
Print( “Hello world!”\n );
}
This function causes the string
“hello world”
plus a carriage return and line feed to
be sent out the control system computer port (or Ethernet port) whenever the signal
speak goes high. Notice the curly-braces ({}) surrounding the print statement above.
In SIMPL+ these braces are used to group multiple statements into a compound
statement. In the case of a function definition, always surround the contents of the
function with these braces.
The next step is to add another event function, one that responds when a signal goes
from high to low. This event is called a release event. From the skeleton program,
find the line of code that says “RELEASE input”. Uncomment and edit it to read the
following:
RELEASE speak
{
Print( “Crestron people make the difference”\n );
}
Finally, define what happens when the control system first boots up. This is
accomplished using
Function Main
. Upon system startup, the program code defined
in this function executes. Unless there are looping constructs (discussed in
“Controlling Program Flow: Loops”) defined in this function, this code executes
only one time for the life of the control system (or until it is rebooted). From the
skeleton program, find the section of the program that says “Function Main”. Edit it
to read the following.
Programming Guide – DOC. 5789A
SIMPL+
•
3