SWCombineNode

- Example -

// define the data network:
x = SWDataNetwork.new;

// add some labels:
x.add( \floor1, 2 );
x.add( \floor2, 11 );
x.add( \floor3, 12 );
x.add( \floorAll, 100 );

// In this example the data comes into the network, set from an XBee network,
// with sensor devices which have the ID's 2, 11 and 12.
// These ID's are used directly as node IDs in the Data Network.
// The sensors involved are pressure sensors with multiple areas of sensing.
// Since the spatial layout of the sensors vary from setup to setup,
// setting up the sensing environment involves checking what the current layout is.
// So, in the setup time the spatial mapping needs to be defined,
// so that further processing of the data is fixed.

// indices per 8 pressure areas:
~floorsorders = [ 
    [0,1,4,6, 2,3,4,6],
    [1,0,6,7, 2,3,4,5],
    [5,4,3,0, 6,7,1,2]
];

// indices per sensor node:
~floorsensors = [0,2,1];

// ~floorall will combine all data into one node, with a fixed order.
~floorall = SWCombineNode.new( 100, x, 24 );
[\floor1,\floor2,\floor3].do{ |it,i|
    x[it].scale_( 1/256 );
    x[it].action_( { |data|
        // reorder data and set in combine node
        ~floorall.set( (~floorsensors[i]*8), data.at( ~floorsorders[i].copyRange(0,data.size-1) ) ); 
    }; );
};

- Methods -

*new ( id, network, size )
Creates a node that gets data from various sources, but combines it into one node. size is the total size of the data array that will be supplied as one node.
data ( )
The current data values.
set ( index, newdata )
Puts newdata into the data array at offset index, and updates the node in the network accordingly.
network ( )
The SWDataNetwork.
id ( )
id_ ( )
The node ID.
node ( )
The SWDataNode.



Marije Baalman 2009-03-16