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); //create a WirelessNode with the BaseStation we created mscl.WirelessNode node = new mscl.WirelessNode(NODE_ADDRESS, baseStation); //run the example showing how to retrieve the Node's current configuration getCurrentConfig(ref node); //run the example showing how to update/change the Node's current configuration setCurrentConfig(ref node); } catch (mscl.Error e) { Console.WriteLine("Error: " + e.Message); } Console.WriteLine("Press Enter to quit..."); Console.Read(); }
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); //create a WirelessNode with the BaseStation we created mscl.WirelessNode node = new mscl.WirelessNode(NODE_ADDRESS, baseStation); //call the set to idle function and get the resulting SetToIdleStatus object mscl.SetToIdleStatus status = node.setToIdle(); Console.Write("Setting Node to Idle"); //using the SetToIdleStatus object, check if the Set to Idle operation is complete. // Note: we are specifying a timeout of 300 milliseconds here which is the maximum // amount of time that the complete function will block if the Set to Idle // operation has not finished. Leaving this blank defaults to a timeout of 10ms. while (!status.complete(300)) { //Note: the Set to Idle operation can be canceled by calling status.cancel() Console.Write("."); } //at this point, the Set to Idle operation has completed //check the result of the Set to Idle operation switch (status.result()) { //completed successfully case mscl.SetToIdleStatus.SetToIdleResult.setToIdleResult_success: Console.WriteLine("Successfully set to idle!"); break; //canceled by the user case mscl.SetToIdleStatus.SetToIdleResult.setToIdleResult_canceled: Console.WriteLine("Set to Idle was canceled!"); break; //Failed to perform the operation case mscl.SetToIdleStatus.SetToIdleResult.setToIdleResult_failed: default: Console.WriteLine("Set to Idle has failed!"); break; } } catch (mscl.Error e) { Console.WriteLine("Error: " + e.Message); } Console.WriteLine("Press Enter to quit..."); Console.Read(); }
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 create_conection() { //create a Serial Connection with the specified COM Port, default baud rate of 921600 connection = mscl.Connection.Serial(ports[0]); //create a BaseStation with the connection baseStation = new mscl.BaseStation(connection); //create a WirelessNode with the BaseStation we created node1 = new mscl.WirelessNode(NODE_ADDRESS1, baseStation); node2 = new mscl.WirelessNode(NODE_ADDRESS2, baseStation); node3 = new mscl.WirelessNode(NODE_ADDRESS3, baseStation); node4 = new mscl.WirelessNode(NODE_ADDRESS4, baseStation); node5 = new mscl.WirelessNode(NODE_ADDRESS5, baseStation); node_set = 1; Set_Idle(); //create a SyncSamplingNetwork object, giving it the BaseStation that will be the master BaseStation for the network mscl.SyncSamplingNetwork network = new mscl.SyncSamplingNetwork(baseStation); //add a WirelessNode to the network // Note: The Node must already be configured for Sync Sampling before adding to the network, or else Error_InvalidConfig will be thrown. //TODO: Repeat this for all WirelessNodes that you want in the network zmien_richTextBox1("Adding node to the network.."); network.addNode(node1); network.addNode(node2); network.addNode(node3); network.addNode(node4); network.addNode(node5); //can get information about the network zmien_richTextBox1("\n Network info: "); zmien_richTextBox1("\n Network OK: " + network.ok().ToString()); zmien_richTextBox1("\n Percent of Bandwidth: " + network.percentBandwidth().ToString() + "%"); zmien_richTextBox1("\n Lossless Enabled: " + network.lossless().ToString()); zmien_richTextBox1("\n High Capacity Mode: " + network.highCapacity().ToString()); //apply the network configuration to every node in the network zmien_richTextBox1("\n Applying network configuration..."); network.applyConfiguration(); zmien_richTextBox1(" \n Done."); //start all the nodes in the network sampling. The master BaseStation's beacon will be enabled with the system time. // Note: if you wish to provide your own start time (not use the system time), pass a mscl::Timestamp object as a second parameter to this function. // Note: if you do not want to enable a beacon at this time, use the startSampling_noBeacon() function. (A beacon is required for the nodes to actually start sending data). zmien_richTextBox1(" \n Starting the network..."); network.startSampling(); zmien_richTextBox1(" \n Done."); }
public static void startSyncSampling(mscl.BaseStation baseStation, List <mscl.WirelessNode> nodes) { //create a SyncSamplingNetwork object, giving it the BaseStation that will be the master BaseStation for the network mscl.SyncSamplingNetwork network = new mscl.SyncSamplingNetwork(baseStation); //add a WirelessNode to the network //Note: The Node must already be configured for Sync Sampling before adding to the network, or else Error_InvalidConfig will be thrown. foreach (mscl.WirelessNode node in nodes) { Console.Write("Adding node to the network..."); network.addNode(node); Console.WriteLine("Done."); } //can get information about the network Console.WriteLine("Network info: "); Console.WriteLine("Network OK: " + network.ok().ToString()); Console.WriteLine("Percent of Bandwidth: " + network.percentBandwidth().ToString() + "%"); Console.WriteLine("Lossless Enabled: " + network.lossless().ToString()); //apply the network configuration to every node in the network Console.Write("Applying network configuration..."); network.applyConfiguration(); Console.WriteLine("Done."); //start all the nodes in the network sampling. The master BaseStation's beacon will be enabled with the system time. // Note: if you wish to provide your own start time (not use the system time), pass a mscl::Timestamp object as a second parameter to this function. // Note: if you do not want to enable a beacon at this time, use the startSampling_noBeacon() function. (A beacon is required for the nodes to actually start sending data). Console.Write("Starting the network..."); network.startSampling(); Console.WriteLine("Done."); //======================================================================================= //Many other functions are available for the SyncSamplingNetwork: // //network.lossless() //enable or disable "lossless" mode for the network (default of enabled). //network.ok() //check whether or not the network is "OK" meaning all nodes fit in the network and have communicated successfully. //network.percentBandwidth() //get the percent of bandwidth for the entire network. //network.refresh() //refreshes the entire network. Should be called any time a change is made to the node after it has been added to the network. //network.removeNode() //remove a node from the network. //network.getNodeNetworkInfo(nodeAddress) //get network information for an individual node in the network (TDMA address, percent bandwidth, etc.) //======================================================================================= }
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); //make sure we can ping the base station if (!baseStation.ping()) { Console.WriteLine("Failed to ping the Base Station"); } Console.WriteLine("Attempting to enable the beacon..."); //enable the beacon on the Base Station using the PC time mscl.Timestamp beaconTime = baseStation.enableBeacon(); //if we got here, no exception was thrown, so enableBeacon was successful Console.WriteLine("Successfully enabled the beacon on the Base Station"); Console.WriteLine("Beacon's initial Timestamp: " + beaconTime.ToString()); Console.WriteLine("Beacon is active"); Console.WriteLine("Sleeping for 3 seconds..."); Thread.Sleep(3000); //disable the beacon on the Base Station baseStation.disableBeacon(); //if we got here, no exception was thrown, so disableBeacon was successful Console.WriteLine("Successfully disabled the beacon on the Base Station"); } catch (mscl.Error e) { Console.WriteLine("Error: " + e.Message); } Console.WriteLine("Press Enter to quit..."); Console.Read(); }
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(); } } }
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); //create a WirelessNode with the BaseStation we created mscl.WirelessNode node = new mscl.WirelessNode(NODE_ADDRESS, baseStation); Console.WriteLine("Attempting to ping the Node..."); //ping the Node mscl.PingResponse response = node.ping(); //if the ping response was a success if (response.success()) { Console.WriteLine("Successfully pinged Node " + NODE_ADDRESS); Console.WriteLine("Base Station RSSI: " + response.baseRssi()); Console.WriteLine("Node RSSI: " + response.nodeRssi()); } else { Console.WriteLine("Failed to ping Node " + NODE_ADDRESS); } } catch (mscl.Error e) { Console.WriteLine("Error: " + e.Message); } Console.WriteLine("Press Enter to quit..."); Console.Read(); }
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); //create a WirelessNode with the BaseStation we created mscl.WirelessNode node = new mscl.WirelessNode(NODE_ADDRESS, baseStation); //create an ArmedDataloggingNetwork object, giving it the BaseStation that will be the master BaseStation for the network mscl.ArmedDataloggingNetwork network = new mscl.ArmedDataloggingNetwork(baseStation); //add a WirelessNode to the network // Note: The Node must already be configured for Armed Datalogging before adding to the network, or else Error_InvalidConfig will be thrown. //TODO: Repeat this for all WirelessNodes that you want in the network Console.Write("Adding node to the network..."); network.addNode(node, "This is an optional <50-char message."); Console.WriteLine("Done."); //start all the nodes in the network sampling. Console.Write("Starting the network..."); network.startSampling(); Console.WriteLine("Done."); } catch (mscl.Error e) { Console.WriteLine("Error: " + e.Message); } Console.WriteLine("Press Enter to quit..."); Console.Read(); }
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); //create a WirelessNode with the BaseStation we created mscl.WirelessNode node = new mscl.WirelessNode(NODE_ADDRESS, baseStation); //create a SyncSamplingNetwork object, giving it the BaseStation that will be the master BaseStation for the network mscl.SyncSamplingNetwork network = new mscl.SyncSamplingNetwork(baseStation); //add a WirelessNode to the network // Note: The Node must already be configured for Sync Sampling before adding to the network, or else Error_InvalidConfig will be thrown. //TODO: Repeat this for all WirelessNodes that you want in the network Console.Write("Adding node to the network..."); network.addNode(node); Console.WriteLine("Done."); //can get information about the network Console.WriteLine("Network info: "); Console.WriteLine("Network OK: " + network.ok().ToString()); Console.WriteLine("Percent of Bandwidth: " + network.percentBandwidth().ToString() + "%"); Console.WriteLine("Lossless Enabled: " + network.lossless().ToString()); Console.WriteLine("High Capacity Mode: " + network.highCapacity().ToString()); //apply the network configuration to every node in the network Console.Write("Applying network configuration..."); network.applyConfiguration(); Console.WriteLine("Done."); //start all the nodes in the network sampling. The master BaseStation's beacon will be enabled with the system time. // Note: if you wish to provide your own start time (not use the system time), pass a mscl::Timestamp object as a second parameter to this function. // Note: if you do not want to enable a beacon at this time, use the startSampling_noBeacon() function. (A beacon is required for the nodes to actually start sending data). Console.Write("Starting the network..."); network.startSampling(); Console.WriteLine("Done."); //======================================================================================= //Many other functions are available for the SyncSamplingNetwork: // //network.lossless() //enable or disable "lossless" mode for the network (default of enabled). //network.highCapacity() //enable or disable "high capacity" mode for the network (default of disabled). //network.ok() //check whether or not the network is "OK" meaning all nodes fit in the network and have communicated successfully. //network.percentBandwidth() //get the percent of bandwidth for the entire network. //network.refresh() //refreshes the entire network. Should be called any time a change is made to the node after it has been added to the network. //network.removeNode() //remove a node from the network. //network.getNodeNetworkInfo() //get network information for an individual node in the network (TDMA address, percent bandwidth, etc.) //======================================================================================= } catch (mscl.Error e) { Console.WriteLine("Error: " + e.Message); } Console.WriteLine("Press Enter to quit..."); Console.Read(); }