TINE console client applications play an important role in middle-layer servers, automatic servers, scripts, diagnostic checks, etc. Client applications requiring a user interface are best written as GUI applications.
The example below is a simple client code module which obtains the sine curve from the simple console server example, and illustrates both synchronous and asynchronous calls.
First some necessary #includes, #defines, and global variables:
For convenience we've #defined the device server name to refer to the one exported in the simple server example. Likewise we have #defined the total number used in the call, and we have assigned the global arrays sdat[] and refdat[].
The function below (showsine()) will be used as an asynchronous callback. Note that this is just an example. In general, displaying 1024 float values on the console at 1 Hz is a bad idea!
Below is an initialization routine PostSystemInit() which is used to obtain a reference sine curve via a synchronous call ExecLink(). This routine also sets up an asynchronous link through AttachLink(), which is to receive a sine curve every 1000 milliseconds. Note that CM_POLL mode is used (and not CM_REFRESH). This is because we know a priori that the data at the server will change with every call (due to the dataMode being either TRAVELLING or NOISE). In both the synchronous and the asynchronous call, there is only an output data set (dout) and no need to send data to the server, hence argument 4 is NULL.
Also note that for a client call, the full device name is formed via the concatenation of DEVSRVNAME and “/#1”. The way the server is written in Example 1, the specific device name is ignored, so appending “/#1” is actually irrelevant here.
Below is a simple main() routine. Please see the corresponding comments in Example 1 for more details.
Note that even though the initialization routine is call 'PostSystemInit' there is no call to SystemInit() in a pure console client. The duties of SystemInit() are primarily to initialize a server.
You can try compiling and linking the above code. You will need to have a repository containing the TINE kernel library and the TINE include files. Please see the section on 'Recipes' for your platform as to how to generate the library and suggestions as to where to keep the include files and library.
In order to contact the simple server from Example 1, the TINE ENS must be available. So either a cshosts.csv should be available in the TINE_HOME directory (pointing to a functioning equipment name server) or a DNS request to tineens (or tineens1) should resolve to a functioning equipment name server.