Esempio n. 1
0
        //Function: setCurrentConfig
        //    This function demonstrates how to change the configuration
        //    settings of a Wireless Node with MSCL.
        //
        //    Note:	More settings are available than are demoed here.
        //            Reference the documentation for the full list of functions.
        static void setCurrentConfig(ref mscl.WirelessNode node)
        {
            Console.WriteLine("Changing configuration settings.");

            //create a WirelessNodeConfig which is used to set all node configuration options
            mscl.WirelessNodeConfig config = new mscl.WirelessNodeConfig();

            //set some of the node's configuration options
            config.bootMode(mscl.WirelessTypes.BootMode.bootMode_normal);
            config.inactivityTimeout(7200);
            config.samplingMode(mscl.WirelessTypes.SamplingMode.samplingMode_sync);
            config.sampleRate(mscl.WirelessTypes.WirelessSampleRate.sampleRate_256Hz);
            config.unlimitedDuration(true);

            //attempt to verify the configuration with the Node we want to apply it to
            //	Note that this step is not required before applying, however the apply will throw an
            //	Error_InvalidNodeConfig exception if the config fails to verify.
            mscl.ConfigIssues issues = new mscl.ConfigIssues();
            if(!node.verifyConfig(config, issues))
            {
                Console.WriteLine("Failed to verify the configuration. The following issues were found:");

                //print out all of the issues that were found
                foreach(var issue in issues)
                {
                    Console.WriteLine(issue.description());
                }

                Console.WriteLine("Configuration will not be applied.");
            }
            else
            {
                //apply the configuration to the Node
                //	Note that if this writes multiple options to the Node.
                //	If an Error_NodeCommunication exception is thrown, it is possible that
                //	some options were successfully applied, while others failed.
                //	It is recommended to keep calling applyConfig until no exception is thrown.
                node.applyConfig(config);
            }

            Console.WriteLine("Done.");
        }