Crestron
SIMPL+
Software
To solve this problem, SIMPL+ has introduced the concept of function libraries.
Simply put, a function library is a collection of user-defined functions placed in a
separate file. A library can consist of only a single function, or can consist of every
function you have ever written. More likely, you will organize your libraries so that
each one contains related functions. For example, you may create a "string handling"
library, which consists of a number of functions that perform useful operations on
stings.
Once a function has been included inside of a function library, it now becomes
accessible to all SIMPL+ modules that are made aware of it. To make a SIMPL+
program aware of a particular library, you must use the #USER_LIBRARY. To
include a user library within a SIMPL+ module, the syntax is as follows:
#USER_LIBRARY "MyStringFunctionLib"
Note that the file extension (.usl in this case) is left out. The above example refers to
the function library called "MyStringFunctionLib.usl." Any number of user libraries
can be included within a SIMPL+ module.
Special function libraries that are created by Crestron and made available to all
customers can be used in a similar manner. The only difference is the use of the
#CRESTRON_LIBRARY compiler directive in place of #USER_LIBRARY.
Crestron function library files end with the extension .csl.
Compact Flash Functions
The 2-series control system supports reading and writing to compact flash cards.
Certain control systems have a built-in compact flash slot with the ability to easily
insert and remove compact flash cards (i.e., AV2, PRO2, and PAC2).
Data storage is a valuable, powerful and important part of programming. The ability
to store and retrieve data from a removable data source can provide many useful and
powerful solutions. Some of these solutions include the ability to backup data,
transferring data from one control system to another, reading and writing data to and
from formats that other database programs can recognize, and implementing
database-driven programs (the ability for a program to act dynamically based on
actions defined in the database).
The SIMPL+ file functions perform file access with the control system’s compact
flash card. Because of the overhead involved with maintaining current directory and
file positions, there are restrictions on file I/O. Each SIMPL+ thread (main loop or
event handler) that requires file operations must first identify itself with the operating
system. This is done with the function,
StartFileOperations
. Before terminating the
thread, the function,
EndFileOperations
must be called. Files cannot be opened
across threads. In other words, you cannot open a file in one thread, such as
Function
Main
, and then access the file with the returned file handle in another thread, such as
an event handler. Files should be opened, accessed and closed within the same
thread.
CheckForDisk and WaitForNewDisk
Before accessing compact flash, the program must either first check to see if a
compact flash card exists within the control system, or wait for a card to be inserted.
Certain programs might rely on the compact flash card being inserted within the
control system. The function,
CheckForDisk
, will test for the existence of a compact
Programming Guide – DOC. 5789A
SIMPL+
•
39