Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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());

                //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()	//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();
        }
Ejemplo n.º 3
0
        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, 11500);

                //create a DisplacementNode with the connection
                mscl.DisplacementNode node = new mscl.DisplacementNode(connection);

                //TODO: Uncomment the lines below to run the examples

                //Example: Get Configuration
                //Example1.getCurrentConfig(node);

                //Example: Set Configuration
                //Example2.setCurrentConfig(node); //Warning: this example changes settings on your Node!

                //Example: Start Sampling
                //Example3.startSampling(node);

                //Example: Set to Idle
                //Example4.setToIdle(node);

                //Example: Parse Data
                //Example5.parseData(node);
            }
            catch (mscl.Error e)
            {
                Console.WriteLine("Error: " + e.Message);
            }

            Console.WriteLine("Press Enter to quit...");
            Console.Read();
        }
Ejemplo n.º 4
0
        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 stop function and get the resulting StopNodeStatus object
                mscl.StopNodeStatus stopStatus = node.stop();

                Console.Write("Stopping Node");

                //using the StopNodeStatus object, check if the Stop Node 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 Stop Node
                //		  operation has not finished. Leaving this blank defaults to a timeout of 10ms.
                while (!stopStatus.complete(300))
                {
                    //Note: the Stop Node operation can be canceled by calling stopStatus.cancel()
                    Console.Write(".");
                }

                //at this point, the Stop Node operation has completed

                //check the result of the Stop Node operation
                switch (stopStatus.result())
                {
                //Stop Node completed successfully
                case mscl.StopNodeStatus.StopNodeResult.stopNodeResult_success:
                    Console.WriteLine("Successfully stopped the Node!");
                    break;

                //Stop Node has been canceled by the user
                case mscl.StopNodeStatus.StopNodeResult.stopNodeResult_canceled:
                    Console.WriteLine("Stop Node was canceled!");
                    break;

                //Failed to perform the Stop Node operation
                case mscl.StopNodeStatus.StopNodeResult.stopNodeResult_failed:
                default:
                    Console.WriteLine("Stop Node has failed!");
                    break;
                }
            }
            catch (mscl.Error e)
            {
                Console.WriteLine("Error: " + e.Message);
            }

            Console.WriteLine("Press Enter to quit...");
            Console.Read();
        }
Ejemplo n.º 5
0
        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();
        }
Ejemplo n.º 6
0
        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 an InertialNode with the connection
                mscl.InertialNode node = new mscl.InertialNode(connection);

                //endless loop of reading in data
                while (true)
                {
                    try
                    {
                        //This example uses the "getNextDataPacket()" command. This command gets the next InertialDataPacket in the buffer and throws an exception if no data exists.
                        //Alternatively, you may use the "getDataPackets()" command to get ALL the InertialDataPackets available in the buffer. If the returned container is empty, no data exists.

                        //get the next data packet from the node, with a timeout of 500 milliseconds
                        mscl.InertialDataPacket packet = node.getNextDataPacket(500);

                        //print out the data
                        Console.Write("Packet Received: ");

                        //iterate over all the data points in the packet
                        foreach (mscl.InertialDataPoint dataPoint in packet.data())
                        {
                            //print out the channel data
                            Console.Write(dataPoint.ToString() + ": ");
                            Console.Write(dataPoint.as_string() + " "); //Just printing this out as a string. Other methods (ie. as_float, as_uint16, as_Vector) are also available.

                            //if the dataPoint is invalid
                            if (!dataPoint.valid())
                            {
                                //print out that it is invalid
                                Console.Write("[Invalid] ");
                            }
                        }
                        Console.WriteLine();
                    }
                    catch (mscl.Error_NoData noData)
                    {
                        Console.WriteLine(noData.Message);
                    }
                }
            }
            catch (mscl.Error e)
            {
                Console.WriteLine("Error: " + e.Message);
            }

            Console.WriteLine("Press Enter to quit...");
            Console.Read();
        }
Ejemplo n.º 7
0
        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);

                //TODO: add as many other WirelessNode objects here as you want (used in the startSyncSampling example)
                List <mscl.WirelessNode> networkNodes = new List <mscl.WirelessNode>();
                networkNodes.Add(node);

                //due to the nature of wireless devices, it is possible to lose packets over the air.
                //MSCL has a built in way of performing retries whenever an eeprom address is attempted to be read.
                //By default, this value is set to 0. You may wish to keep it at 0 and handle retries yourself depending on your application.
                baseStation.readWriteRetries(3);
                node.readWriteRetries(3);

                //TODO: Uncomment the lines below to run the examples

                //Example: Ping Node
                //Example1.pingNode(node);

                //Example: Get Configuration
                //Example2.getCurrentConfig(node);

                //Example: Set Configuration
                //Example3.setCurrentConfig(node); //Warning: this example changes settings on your Node!

                //Example: Start Sampling
                //Example4.startSyncSampling(baseStation, networkNodes);

                //Example: Set to Idle
                //Example5.setToIdle(node);

                //Example: Parse Data
                //Example6.parseData(baseStation);

                //Example: Enable and Disable Beacon
                //Example7.enableDisableBeacon(baseStation);
            }
            catch (mscl.Error e)
            {
                Console.WriteLine("Error: " + e.Message);
            }

            Console.WriteLine("Press Enter to quit...");
            Console.Read();
        }
Ejemplo n.º 8
0
        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.");
        }
Ejemplo n.º 9
0
        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 an InertialNode with the connection
                mscl.InertialNode node = new mscl.InertialNode(connection);

                //endless loop of reading in data
                while (true)
                {
                    //get all of the next data packet from the node, with a timeout of 500 milliseconds
                    mscl.InertialDataPackets packets = node.getDataPackets(500);

                    foreach (mscl.InertialDataPacket in packets)
                    {
                        //print out the data
                        Console.Write("Packet Received: ");

                        //iterate over all the data points in the packet
                        foreach (mscl.InertialDataPoint dataPoint in packet.data())
                        {
                            //print out the channel data
                            Console.Write(dataPoint.ToString() + ": ");
                            Console.Write(dataPoint.as_string() + " "); //Just printing this out as a string. Other methods (ie. as_float, as_uint16, as_Vector) are also available.

                            //if the dataPoint is invalid
                            if (!dataPoint.valid())
                            {
                                //print out that it is invalid
                                Console.Write("[Invalid] ");
                            }
                        }
                        Console.WriteLine();
                    }
                }
            }
            catch (mscl.Error e)
            {
                Console.WriteLine("Error: " + e.Message);
            }

            Console.WriteLine("Press Enter to quit...");
            Console.Read();
        }
Ejemplo n.º 10
0
        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();
        }
Ejemplo n.º 11
0
        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 an InertialNode with the connection
                mscl.InertialNode node = new mscl.InertialNode(connection);

                Console.WriteLine("Node Information: ");
                Console.WriteLine("Model Name: " + node.modelName());
                Console.WriteLine("Model Number: " + node.modelNumber());
                Console.WriteLine("Serial: " + node.serialNumber());
                Console.WriteLine("Firmware: " + node.firmwareVersion().ToString());
                Console.WriteLine();

                //TODO: Uncomment the lines below to run the examples

                //Example: Get Configuration
                //Example1.getCurrentConfig(node);

                //Example: Set Configuration
                //Example2.setCurrentConfig(node); //Warning: this example changes settings on your Node!

                //Example: Start Sampling
                //Example3.startSampling(node);

                //Example: Set to Idle
                //Example4.setToIdle(node);

                //Example: Parse Data
                //Example5.parseData(node);
            }
            catch (mscl.Error e)
            {
                Console.WriteLine("Error: " + e.Message);
            }

            Console.WriteLine("Press Enter to quit...");
            Console.Read();
        }
Ejemplo n.º 12
0
        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();
        }
Ejemplo n.º 13
0
        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();
        }