//Function: getCurrentConfig // This function demonstrates how to obtain the current 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 getCurrentConfig(ref mscl.WirelessNode node) { Console.WriteLine("Current Configuration Settings"); //read some of the current node configuration settings Console.WriteLine("# of Triggers: " + node.getNumDatalogSessions()); Console.WriteLine("User Inactivity Timeout: " + node.getInactivityTimeout() + " seconds"); Console.WriteLine("Total active channels: " + node.getActiveChannels().count()); Console.WriteLine("# of sweeps: " + node.getNumSweeps()); //If a configuration function requires a ChannelMask parameter, this indicates that the //option may affect 1 or more channels on the Node. For instance, a hardware gain may //affect ch1 and ch2 with just 1 setting. If you know the mask for your Node, you can just provide //that mask when asking for the configuration. If you want to programatically determine //the mask for each setting, you can ask for the Node's ChannelGroups. See below. mscl.ChannelGroups chGroups = node.features().channelGroups(); //iterate over each channel group foreach(var group in chGroups) { //get all of the settings for this group (ie. may contain linear equation and hardware gain). mscl.ChannelGroupSettings groupSettings = group.settings(); //iterate over each setting for this group foreach(var setting in groupSettings) { //if the group contains the linear equation setting if(setting == mscl.WirelessTypes.ChannelGroupSetting.chSetting_linearEquation) { //we can now pass the channel mask (group.channels()) for this group to the node.getLinearEquation function. //Note: once this channel mask is known for a specific node (+ fw version), it should never change mscl.LinearEquation le = node.getLinearEquation(group.channels()); Console.WriteLine("Linear Equation for: " + group.name()); Console.WriteLine("Slope: " + le.slope()); Console.WriteLine("Offset: " + le.offset()); } } } }
//Function: getCurrentConfig // This function demonstrates how to obtain the current 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 getCurrentConfig(ref mscl.WirelessNode node) { Console.WriteLine("Current Configuration Settings"); //read some of the current node configuration settings Console.WriteLine("# of Triggers: " + node.getNumDatalogSessions()); Console.WriteLine("User Inactivity Timeout: " + node.getInactivityTimeout() + " seconds"); Console.WriteLine("Total active channels: " + node.getActiveChannels().count()); Console.WriteLine("# of sweeps: " + node.getNumSweeps()); //get a list of the supported channels mscl.WirelessChannels supportedChannels = node.channels(); //loop through all of the channels foreach(var channel in supportedChannels) { //print out some information about the channels Console.WriteLine("Channel #: " + channel.Key); Console.WriteLine("Slope: " + channel.Value.getLinearEquation().slope()); Console.WriteLine("Offset: " + channel.Value.getLinearEquation().offset()); } }
//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."); }