public JsonFileConfig() { ComConfig = new ComConfig(); AlgorithmPara = new AlgorithmPara(); UiConfig = new UiConfig(); PlotConfig = new PlotConfig(); }
public override global::System.Data.DataSet Clone() { ComConfig cln = ((ComConfig)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
static void BuildTcpUdpNet() { lockobj = new object(); packetBuilder = new ATCDataPacketBuilder(); comConfig = JsonFileConfig.Instance.ComConfig; Console.WriteLine($"Me is {WswHelper.GetFlightKindFromIp(comConfig.SelfIp)}"); udpClient = new UdpClient(comConfig.SelfPort); tcpClient = new TcpClient(); sendInterval = comConfig.SendDataIntervalMs; isTest = comConfig.IsTCPTest; }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { ComConfig ds = new ComConfig(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
/// <summary> /// 获取配置文件中串口线路的信息 /// </summary> public static List <ComConfig> GetComConfig() { try { List <ComConfig> ls = new List <ComConfig>(); List <string> strName = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComName"), ';', true); List <string> strBaudRate = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComBaudRate"), ';', false); List <string> strParity = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComParity"), ';', false); List <string> strStopBits = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComStopBits"), ';', false); List <string> strComTimeout = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComTimeout"), ';', false); List <string> strRefreshPeriod = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComRefreshPeriod"), ';', false); List <string> strConnectCheckPeriod = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComConnectCheckPeriod"), ';', false); List <string> strComInterFrameGap = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComInterFrameGap"), ';', false); List <string> strDeviceID = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComDeviceID"), ';', false); List <string> strDeviceType = StringPlus.GetStrArray(ConfigHelper.GetConfigString("ComDeviceType"), ';', true); List <int> baudrate = new List <int>(); foreach (string str in strBaudRate) { baudrate.Add(int.Parse(str)); } List <Parity> parity = new List <Parity>(); foreach (string str in strParity) { parity.Add(((Parity)(int.Parse(str)))); } List <StopBits> stop = new List <StopBits>(); foreach (string str in strStopBits) { stop.Add(((StopBits)(int.Parse(str)))); } for (int i = 0; i < strName.Count; i++) { ComConfig cc = new ComConfig(); cc.ComPort = new SerialPort(strName[i], baudrate[i], parity[i], 8, stop[i]); cc.Timeout = int.Parse(strComTimeout[i]); cc.RefreshPeriod = int.Parse(strRefreshPeriod[i]); cc.ConnectCheckPeriod = int.Parse(strConnectCheckPeriod[i]); cc.InterFrameGap = int.Parse(strComInterFrameGap[i]); Log.InfoFormat("解析串口线路配置信息:{0},{1},{2},{3},刷新周期{4}(ms),连接检测周期{5}(ms),超时{6}(ms),帧间隙{7}(ms)", cc.ComPort.PortName, cc.ComPort.BaudRate, cc.ComPort.Parity.ToString(), cc.ComPort.StopBits.ToString(), cc.RefreshPeriod, cc.ConnectCheckPeriod, cc.Timeout, cc.InterFrameGap); cc.Device = new Dictionary <byte, string>(); List <string> deviceID = StringPlus.GetStrArray(strDeviceID[i], ',', false); List <string> deviceType = StringPlus.GetStrArray(strDeviceType[i], ',', false); for (int j = 0; j < deviceID.Count; j++) { cc.Device.Add(byte.Parse(deviceID[j]), deviceType[j]); Log.InfoFormat("解析串口线路配置信息:设备通讯地址[{0}],类型[{1}]", deviceID[j], deviceType[j]); } ls.Add(cc); } return(ls); } catch (System.Exception ex) { string str = "解析串口线路配置信息出错,程序无法继续执行: " + ex.Message; Log.Fatal(str); throw new Exception(str); } }
/// <summary> /// 无参构造函数 /// </summary> public JsonFileConfig() { this.ComConfig = new ComConfig(); }
private void SaveConfig() { ComConfig ds =new ComConfig(); ds.ReadXml("ComConfig.xsd"); if (ds.config.Rows.Count==0) { // rConfig } serialPort1.PortName = cb_SPNumber.SelectedItem.ToString(); //设置串口号 serialPort1.BaudRate = Convert.ToInt16(cb_SPBaudRate.SelectedItem.ToString());//设置波特率 serialPort1.DataBits = Convert.ToInt16(cb_SPDataBits.SelectedItem.ToString());//设置数据位 switch (cb_SPStopBits.SelectedItem.ToString())//设置停止位 { case "1": serialPort1.StopBits = StopBits.One; break; case "1.5": serialPort1.StopBits = StopBits.OnePointFive; break; case "2": serialPort1.StopBits = StopBits.Two; break; } switch (cb_SPHandshake.SelectedItem.ToString())//设置流控制 { case "HARDWARE": serialPort1.Handshake = Handshake.RequestToSend; break; case "SOFTWARE": serialPort1.Handshake = Handshake.XOnXOff; break; case "NONE": serialPort1.Handshake = Handshake.None; break; case "Custom": serialPort1.Handshake = Handshake.RequestToSendXOnXOff; break; } }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); ComConfig ds = new ComConfig(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "configDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }