public static void getCurrentConfig(mscl.DisplacementNode node) { mscl.LinearEquation cals = node.getAnalogToDisplacementCal(); Console.WriteLine("Analog to Displacement Cal: Slope: " + cals.slope() + " Offset: " + cals.offset()); Console.WriteLine("Output Data Rate: " + node.getDisplacementOutputDataRate().prettyStr()); }
public static void setCurrentConfig(mscl.DisplacementNode node) { //seed the device time with the current PC time //Note: you can pass your own time to this function as a // parameter in nanoseconds since unix epoch node.setDeviceTime(); }
public static void parseData(mscl.DisplacementNode node) { //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.MipDataPackets packets = node.getDataPackets(500); foreach (mscl.MipDataPacket packet in packets) { //print out the data Console.Write("Packet Received: "); //iterate over all the data points in the packet foreach (mscl.MipDataPoint dataPoint in packet.data()) { 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, 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(); }
public static void setToIdle(mscl.DisplacementNode node) { node.setToIdle(); //Note: you can also disable the datastream for each class/category // seperately if desired, by using the enableDataStream command shown in // the startSampling example, but passing a second parameter of 'false' }
public static void startSampling(mscl.DisplacementNode node) { node.resume(); }