private SafetyParameters CreateRemoteSafetyParameters(string section) { var remoteSafetyParam = new SafetyParameters(); // Address remoteSafetyParam.Addr = (ushort)SettingsParser.ParseDecimal(_iniFile.ReadValue(section, "Address")); // SID var sid = SettingsParser.ParseDecimals(_iniFile.ReadValue(section, "SID"), new string[] { ",", "," }); if (sid.Count < 2) { throw new Exception(string.Format("{0}.SID个数不能小于2。", section)); } remoteSafetyParam.SID = sid.Select(p => (uint)p).ToArray(); // SINIT var sinit = SettingsParser.ParseDecimals(_iniFile.ReadValue(section, "SINIT"), new string[] { ",", "," }); if (sinit.Count < 2) { throw new Exception(string.Format("{0}.SINIT个数不能小于2。", section)); } remoteSafetyParam.SINIT = sinit.Select(p => (uint)p).ToArray(); // DataVersion var dataVer = SettingsParser.ParseDecimals(_iniFile.ReadValue(section, "DATAVER"), new string[] { ",", "," }); if (dataVer.Count < 2) { throw new Exception(string.Format("{0}.DATAVER个数不能小于2。", section)); } remoteSafetyParam.DATAVER = dataVer.Select(p => (uint)p).ToArray(); return(remoteSafetyParam); }
private void BuildLocalSafetyParameter() { this.LocalSafetyParam = new SafetyParameters(); // address //var localAddrs = SettingsParser.ParseDictionary(_iniFile.ReadValue("Local", "Address"), new String[] { ",", "," }, new string[] { "=>" }); //if (localAddrs.Count < 2) throw new Exception(string.Format("Local.Address个数不能小于2。")); //this.LocalSafetyParam.Addr = (ushort)localAddrs[this.LocalCodeInAts]; this.LocalSafetyParam.Addr = (ushort)SettingsParser.ParseDecimal(_iniFile.ReadValue("Local", "Address")); var sid = SettingsParser.ParseDecimals(_iniFile.ReadValue("Local", "SID"), new string[] { ",", "," }); if (sid.Count < 2) { throw new Exception(string.Format("Local.SID个数不能小于2。")); } this.LocalSafetyParam.SID = sid.Select(p => (uint)p).ToArray(); // SINIT var sinit = SettingsParser.ParseDecimals(_iniFile.ReadValue("Local", "SINIT"), new string[] { ",", "," }); if (sinit.Count < 2) { throw new Exception(string.Format("Local.SINIT个数不能小于2。")); } this.LocalSafetyParam.SINIT = sinit.Select(p => (uint)p).ToArray(); // DataVersion var dataVer = SettingsParser.ParseDecimals(_iniFile.ReadValue("Local", "DATAVER"), new string[] { ",", "," }); if (dataVer.Count < 2) { throw new Exception(string.Format("Local.DATAVER个数不能小于2。")); } this.LocalSafetyParam.DATAVER = dataVer.Select(p => (uint)p).ToArray(); }