static void Main(string[] args) { try { //create a Serial Connection with the specified COM Port, default baud rate of 921600 mscl.Connection connection = mscl.Connection.Serial(COM_PORT); //create a BaseStation with the connection mscl.BaseStation baseStation = new mscl.BaseStation(connection); //endless loop of reading in data while (true) { //This example uses the "getData()" command. This command gets ALL of the available DataSweeps in the buffer. If the returned contains is empty, no data exists. //Alternatively, you may use the "getNextData()" command to get a single DataSweep from the buffer. If no data exists in this case, an exception will be thrown. //get all of the data sweeps that have been collected by the BaseStation, with a timeout of 500 milliseconds mscl.DataSweeps sweeps = baseStation.getData(500); foreach (mscl.DataSweep sweep in sweeps) { //print out information about the sweep Console.Write("Packet Received: "); Console.Write("Node " + sweep.nodeAddress() + " "); Console.Write("Timestamp: " + sweep.timestamp().ToString() + " "); Console.Write("Tick: " + sweep.tick() + " "); Console.Write("Sample Rate: " + sweep.sampleRate().prettyStr() + " "); Console.Write("Base RSSI: " + sweep.baseRssi() + " "); Console.Write("Node RSSI: " + sweep.nodeRssi() + " "); //get the container of data in the sweep mscl.ChannelData data = sweep.data(); Console.Write("DATA: "); //iterate over each point in the sweep foreach (mscl.WirelessDataPoint dataPoint in data) { //print out the channel name Console.Write(dataPoint.channelName() + ": "); //Print out the channel data as a string. Other methods (ie. as_float, as_uint16) are also available. //Note: The storedAs() function describes how the data is actually stored Console.Write(dataPoint.as_string() + " "); } Console.WriteLine(); } } } catch (mscl.Error e) { Console.WriteLine("Error: " + e); } Console.WriteLine("Press Enter to quit..."); Console.Read(); }
private void data_from_sweeps() { mscl.DataSweeps sweeps = baseStation.getData(10); foreach (mscl.DataSweep sweep in sweeps) { mscl.ChannelData data = sweep.data(); chanel1Array = FIFO(chanel1Array); foreach (mscl.WirelessDataPoint dataPoint in data) { string chanelname = dataPoint.channelName(); char chanel_char = chanelname[2]; Int16 chanel = Int16.Parse("0" + chanel_char); chanel1Array[chanel - 1, chanel1Array.GetLength(1) - 1] = dataPoint.as_double(); } Peak_check(); } }
public static void parseData(mscl.BaseStation baseStation) { //endless loop of reading in data while (true) { //get all of the data sweeps that have been collected by the BaseStation, with a timeout of 500 milliseconds mscl.DataSweeps sweeps = baseStation.getData(500); foreach (mscl.DataSweep sweep in sweeps) { //print out information about the sweep Console.Write("Packet Received: "); Console.Write("Node " + sweep.nodeAddress() + " "); Console.Write("Timestamp: " + sweep.timestamp().ToString() + " "); Console.Write("Tick: " + sweep.tick() + " "); Console.Write("Sample Rate: " + sweep.sampleRate().prettyStr() + " "); Console.Write("Base RSSI: " + sweep.baseRssi() + " "); Console.Write("Node RSSI: " + sweep.nodeRssi() + " "); //get the container of data in the sweep mscl.ChannelData data = sweep.data(); Console.Write("DATA: "); //iterate over each point in the sweep foreach (mscl.WirelessDataPoint dataPoint in data) { //print out the channel name Console.Write(dataPoint.channelName() + ": "); //print out the channel data //Note: The as_string() function is being used here for simplicity. // Other methods (ie. as_float, as_uint16, as_Vector) are also available. // To determine the format that a dataPoint is stored in, use dataPoint.storedAs(). Console.Write(dataPoint.as_string() + " "); } Console.WriteLine(); } } }
// #### SWEEPS ### // private void data_from_sweeps() { int actual_node = 0; mscl.DataSweeps sweeps = baseStation.getData(10); foreach (mscl.DataSweep sweep in sweeps) { double[,] NodeArray = new double[3, buffor_length]; switch (sweep.nodeAddress()) { case 873: NodeArray = Node1Array; actual_node = 1; break; case 874: NodeArray = Node2Array; actual_node = 2; break; case 875: NodeArray = Node3Array; actual_node = 3; break; case 876: NodeArray = Node4Array; actual_node = 4; break; case 877: NodeArray = Node5Array; actual_node = 5; break; } mscl.ChannelData data = sweep.data(); NodeArray = FIFO(NodeArray); foreach (mscl.WirelessDataPoint dataPoint in data) { string chanelname = dataPoint.channelName(); char chanel_char = chanelname[2]; Int16 chanel = Int16.Parse("0" + chanel_char); NodeArray[chanel - 1, NodeArray.GetLength(1) - 1] = dataPoint.as_double(); } switch (sweep.nodeAddress()) { case 873: Node1Array = NodeArray; break; case 874: Node2Array = NodeArray; break; case 875: Node3Array = NodeArray; break; case 876: Node4Array = NodeArray; break; case 877: Node5Array = NodeArray; break; } // mamy tablice node arrey z 1 noda z wlasciwymi danymi Peak_check(NodeArray, actual_node); } }