Direct LonWorks Network Variable Access (for Advanced Users)
LonWorks Local Bound Network Variables
The local LonWorks processor holds 36 network variable outputs or NVO's (defined as sensor function blocks) and 20 network variable inputs or NVI's (defined as actuator function blocks). These may be bound to other nodes by any external network management tool that supports standard LonWorks objects. The network types may be dynamically changed to any standard variable type (SNVT). The variables may be read or written from the PL/i program using the following statements:
nv_read ( <index> , <var> );
nv_write ( <index> , <var> );
<var> = nv_isnew ( <index> );
nv_info ( <index> , <var> );
The <index> in each of the above statements is the network variable index, which must be in the range of 5 to 61 (for AddMe III, or 3 to 59 for Babel Buster X2). Any valid expression may be used as the index (constant, variable, etc.). The network variable will be read into the variable named by <var> in nv_read, and written from <var> in nv_write. The nv_isnew function will return TRUE if the indexed network variable input (NVI) has received an update since the last call, or false otherwise. The NVO's will always return false (they do not "receive" data).
The variable types read or written should match the expected data type on the network. A large number of SNVT's are 2-byte integer values, and a large number are 4-byte floating point. Several SNVT's are also structures. Use a PL/i record defined in the same format as the SNVT to read or write structured network variables. The following simple example shows the definition of SNVT_switch and a program that turns the switch "on" at 100% (value is scaled x2 in SNVT_switch). In this case, we have made the assumption that the external network management tool has changed the type of the NV at index 5 to SNVT_switch.
type SNVT_switch = record
netvar.state = 1;
netvar.value = 200;
nv_write (5, netvar);
It may be desirable to find out from within your PL/i program what type (SNVT) the network variable has been configured to. You cannot reconfigure network variable types from a PL/i program. Due to the fact that the Neuron Chip is not allowed to self-modify its code, network variable type changes can only be made from outside the device via the network using a network management tool. However, once reconfigured, you can retrieve the configuration information to see what type you have been given.
You must define a record which is an abbreviated form of SNVT_nv_type. It is defined in PL/i as shown in the following example. The call to nv_info then retrieves this information record for NV index 5.
type nvInfo = record
nv_info (5, infovar);
The nv_info function is only applicable to the local bound network variables.