/// <summary> /// Generates the Raw Data transform that produces our program's output. /// </summary> /// <returns>A transform configuration to be given to the API pipeline.</returns> public OutputConfig GenerateTransforms() { SimulatedPipeline.TransformManager.TransformList.Clear(); //Create the transforms for the first time. int sensorNum = 0; int channelNum = 0; for (int i = 0; i < SimulatedPipeline.TrignoSimulatedManager.Components.Count; i++) { if (SimulatedPipeline.TrignoSimulatedManager.Components[i].State == SelectionState.Allocated) { var tmp = SimulatedPipeline.TrignoSimulatedManager.Components[i]; sensorNum++; channelNum += tmp.Configuration.Channels.Count; } } if (TransformManager.TransformList.Count == 0) { var t = new TransformRawData(channelNum, channelNum); TransformManager.AddTransform(t); } //channel configuration happens each time transforms are armed. var t0 = TransformManager.TransformList[0]; var outconfig = new OutputConfig(); outconfig.NumChannels = channelNum; int channelIndex = 0; for (int i = 0; i < SimulatedPipeline.TrignoSimulatedManager.Components.Count; i++) { var component = SimulatedPipeline.TrignoSimulatedManager.Components[i]; if (component.State == SelectionState.Allocated) { for (int k = 0; k < component.Configuration.Channels.Count; k++) { var chin = component.SimChannels[k]; var chout = new ChannelTransform(chin.FrameInterval, chin.SamplesPerFrame, Units.VOLTS); TransformManager.AddInputChannel(t0, chin); TransformManager.AddOutputChannel(t0, chout); outconfig.MapOutputChannel(channelIndex, chout); channelIndex++; } } } return(outconfig); }
/// <summary> /// Generates the Raw Data transform that produces our program's output. /// </summary> /// <returns>A transform configuration to be given to the API pipeline.</returns> public OutputConfig GenerateTransforms() { // Clear the previous transforms should they exist. TransformManager.TransformList.Clear(); int channelNumber = 0; // Obtain the number of channels based on our sensors and their mode. for (int i = 0; i < BTPipeline.TrignoBtManager.Components.Count; i++) { if (BTPipeline.TrignoBtManager.Components[i].State == SelectionState.Allocated) { var tmp = BTPipeline.TrignoBtManager.Components[i]; BTCompConfig someconfig = tmp.Configuration as BTCompConfig; if (someconfig.IsComponentAvailable()) { channelNumber += BTPipeline.TrignoBtManager.Components[i].BtChannels.Count; } } } // Create the raw data transform, with an input and output channel for every // channel that exists in our setup. This transform applies the scaling to the raw // data from the sensor. var rawDataTransform = new TransformRawData(channelNumber, channelNumber); TransformManager.AddTransform(rawDataTransform); var fib = new FibonacciTransform(channelNumber, channelNumber); TransformManager.AddTransform(fib); var t0 = TransformManager.TransformList[0]; var fibonacciTransform = TransformManager.TransformList[1]; // The output configuration for the API to use. var outconfig = new OutputConfig(); outconfig.NumChannels = channelNumber; int channelIndex = 0; for (int i = 0; i < BTPipeline.TrignoBtManager.Components.Count; i++) { if (BTPipeline.TrignoBtManager.Components[i].State == SelectionState.Allocated) { BTCompConfig someconfig = BTPipeline.TrignoBtManager.Components[i].Configuration as BTCompConfig; if (someconfig.IsComponentAvailable()) { // For every channel in every sensor, we gather its sampling information (rate, interval, units) and create a // channel transform (an abstract channel used by transforms) from it. We then add the actual component's channel // as an input channel, and the channel transform as an output. // Finally, we map the channel counter and the output channel. This mapping is what determines the channel order in // the CollectionDataReady callback function. for (int k = 0; k < BTPipeline.TrignoBtManager.Components[i].BtChannels.Count; k++) { var chin = BTPipeline.TrignoBtManager.Components[i].BtChannels[k]; var chout = new ChannelTransform(chin.FrameInterval, chin.SamplesPerFrame, BTPipeline.TrignoBtManager.Components[i].BtChannels[k].Unit); TransformManager.AddInputChannel(rawDataTransform, chin); TransformManager.AddOutputChannel(rawDataTransform, chout); // now reroute the raw transform's data into the fibonacci transform var fibChin = chout; var fibChout = new ChannelTransform(fibChin.FrameInterval, fibChin.SamplesPerFrame, Units.VOLTS); TransformManager.AddInputChannel(fibonacciTransform, fibChin); TransformManager.AddOutputChannel(fibonacciTransform, fibChout); outconfig.MapOutputChannel(channelIndex, fibChout); channelIndex++; } } } } return(outconfig); }