// 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) ) ); }; ); };