private void ParseControllerConfig(XmlNode configRoot) { int temp_mapping = 0; for (int i = 0; i < (int)ChannelNumber.NUM_CHANNELS; i++) { channel_config[i] = new ChannelConfigValues(); inputMapping[i] = new ControllerProperty(); temp_mapping = int.Parse(configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue((ChannelNumber)i))).Item(0).Attributes["map"].Value); inputMapping[i] = (ControllerProperty)Math.Abs(temp_mapping); if (temp_mapping < 0) { inputInverted[i] = true; } channel_config[i].MIN = double.Parse(configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue((ChannelNumber)i))).Item(0).Attributes["min"].Value); channel_config[i].MAX = double.Parse(configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue((ChannelNumber)i))).Item(0).Attributes["max"].Value); channel_config[i].CENTER = double.Parse(configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue((ChannelNumber)i))).Item(0).Attributes["default"].Value); precisionFormat[i] = configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue((ChannelNumber)i))).Item(0).Attributes["precision"].Value; channelGain[i] = double.Parse(configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue((ChannelNumber)i))).Item(0).Attributes["gain"].Value); channelPrefix[i] = configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue((ChannelNumber)i))).Item(0).InnerXml; } z_persist = Boolean.Parse(configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue(ChannelNumber.CH1))).Item(0).Attributes["persist"].Value); z_accumulating = Boolean.Parse(configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue(ChannelNumber.CH1))).Item(0).Attributes["accum"].Value); chanSeparator = configRoot.SelectNodes(".//ChannelSeparator").Item(0).InnerXml; stopCommand = configRoot.SelectNodes(".//StopCommand").Item(0).InnerXml; cmdPrefixAbsolute = configRoot.SelectNodes(".//StartOfFrame[@type='absolute']").Item(0).InnerXml; cmdPrefixRelative = configRoot.SelectNodes(".//StartOfFrame[@type='relative']").Item(0).InnerXml; }
private void InitArrays() { channel_config = new ChannelConfigValues[(int)ChannelNumber.NUM_CHANNELS]; inputMapping = new ControllerProperty[(int)ChannelNumber.NUM_CHANNELS]; precisionFormat = Enumerable.Repeat <String>("", (int)ChannelNumber.NUM_CHANNELS).ToArray(); channelPrefix = Enumerable.Repeat <String>("", (int)ChannelNumber.NUM_CHANNELS).ToArray(); channelGain = Enumerable.Repeat <double>(0.0, (int)ChannelNumber.NUM_CHANNELS).ToArray(); inputInverted = Enumerable.Repeat <bool>(false, (int)ChannelNumber.NUM_CHANNELS).ToArray(); }
private void UpdateConfig() { Control[,] configTxtBoxes = { { txt1_min, txt1_max, txt1_center }, { txt2_min, txt2_max, txt2_center }, { txt3_min, txt3_max, txt3_center }, { txt4_min, txt4_max, txt4_center }, { txt5_min, txt5_max, txt5_center } }; ChannelConfigValues[] configValues = new ChannelConfigValues[(int)ChannelNumber.NUM_CHANNELS]; for (int i = 0; i < (int)ChannelNumber.NUM_CHANNELS; i++) { configValues[i] = new ChannelConfigValues(); configValues[i].MIN = double.Parse(configTxtBoxes[i, 0].Text); configValues[i].MAX = double.Parse(configTxtBoxes[i, 1].Text); configValues[i].CENTER = double.Parse(configTxtBoxes[i, 2].Text); } activeConfig.SetConfigParams(configValues, chkPersist.Checked, chkAccum.Checked); }