Base class for the Sense World Data Network.
- Example -
x = SWDataNetwork.new;
q = XBeeSMS.new( "/dev/ttyUSB0", 115200 );
q.action_({ |msg| x.setData( msg[0], msg.copyToEnd(1) ); });
x.addExpected( 2, \floor );
x.addExpected( 102, \floorVar );
q.start;
x[\floor].scale = 1/255;
x[\floor].createBus( s );
~floorVar = StdDevNode.new( 102, x, x.at( \floor ).bus, s );
~floorVar.start;
- Methods -
- *new
- Create an instance of SWDataNetwork
- Node Control -
- setData ( id, data )
- Set the data for a node. This registers a node if it does not yet exist. The size of the data array determines the amount of slots the node will have. Subsequent calls to this method for this same node ID will have to have the same size of the data array.
- registerNode ( id, sz )
- register a node in the network with a specific size. If a node is not expected (see below), then it cannot be registered.
- nodes ( )
- returns an Array of the nodes of the network
- removeNode ( id )
- remove a node from the network.
- Expected nodes -
- addExpected ( id, label, size )
- add an expected node to the network. Label (the key the node will have in the spec) and size are optional. If size is specified, a node will be created with size number of slots; the value of each slot will be initialized with 0.
- isExpected ( id )
- Answers whether the given node ID is expected or not.
- expectedNodes ( )
- returns an Array of the expected nodes (actually just their IDs) of the network
- expectedNodes_ ( )
- set the expected nodes of the network (should be an Array of ids)
- Spec -
- spec ( )
- returns the SWDataNetworkSpec
- setSpec ( name )
- Load an SWDataNetworkSpec from file.
- add ( key, slot )
- Add a key (node or slot label) to the spec. slot can be the node ID (one integer), or the slot ID (an Array of two integers).
- Named access to nodes, values and actions -
- at ( key )
- Returns the node or slot at key
- value ( key )
- Get the value of the node or slot at key
- action_ ( key, action )
- Set the action of the node or slot at key
- Node bus control -
- bus ( key )
- Get the bus of the node or slot at key
- createBus ( key, server )
- Create a control bus on the server for the node or slot at key. The data that comes into the slot is automatically mapped to this bus.
- freeBus ( key )
- Free the bus of the node or slot at key
- createAllBuses ( server )
- Creates buses for all nodes and slots that are named in the spec on the specified server
- freeAllBuses ( )
- Free all the buses that have been created.
- createAllNodeBuses ( server )
- create buses on the server for all nodes (Note difference with createAllBuses, which creates buses for all nodes that are named in the spec).
- Data input control -
- worrytime ( )
- worrytime_ ( wt )
- time after which the network will perform an action to restart the network data inputs
- watch ( onoff )
- turn on or off whether to worry about data (not) coming in
- watcher ( )
- private - the task that performs the watching to regularly check when data was last set in the network
- Data logging and recording -
- initRecord ( fn, dt )
- initialize recording the data. fn is the filename. dt is the time interval at which to write lines of data.
- record ( onoff )
- turn recording on or off
- closeRecord ( )
- close the recorded file
- recnodes ( )
- private - The nodes which are being recorded.
- writeHeader ( )
- private - write the header into the logfile
- writeLine ( dt, recordnodes )
- private - write one line of data into the logfile
- recTask ( )
- private
- recTask_ ( )
- private - the task performing the file writing
- logfile ( )
- private - the file into which data is written
- Logging update times -
- initTimeRecord ( fn )
- initialize recording of the update times of the data. fn is the filename.
- closeTimeRecord ( )
- close the update time recorded file
- writeTimeUpdate ( id, time )
- private - write one line of time update data to the log (format node id - update time)
- recTime
- private whether currently recording update times or not
- timelogfile ( )
- private - the file into which update time data is written
- Graphical user interface -
- makeGui ( )
- Create a graphical user interface.
- gui ( )
- private returns the SWDataNetworkGui
- gui_ ( )
- private set the SWDataNetwork graphical interface (called internally when creating a new SWDataNetworkGui).
- OpenSoundControl interface (OSC) -
- addOSCInterface ( )
- Add the OSC interface to the network.
- osc ( )
- private returns the SWDataNetworkOSC
- osc_ ( )
- private set the SWDataNetworkOSC interface (called internally when creating a new SWDataNetworkOSC).
- Debugging and verbosity -
- debug_ ( onoff )
- turn debugging on for all slots. This will post all incoming data.
- verbose ( )
- posting of messages. There are various verbosity levels. 0 is no posts, 1 posts informational/warning messages, 2 posts all data coming in.
- verbose_ ( )
- Set the verbosity level.
Marije Baalman
2009-03-16