public static void EngineConnect() { var veh = config.GetVehicle(config.Vehicle); if (veh == null) { veh = new ConfigVehicleData(); } if (HOBD.engine == null) { HOBD.engine = Engine.CreateInstance(veh.ECUEngine); } IStream stream = null; if (config.Port.StartsWith("btspp")) { stream = new BluetoothStream(); } else if (config.Port.StartsWith("tcp")) { stream = new TCPStream(); } else { stream = new SerialStream(); } engine.Deactivate(); engine.Registry = Registry; engine.Init(stream, config.Port, ""); }
public ConfigVehicleData GetVehicle(string name) { ConfigVehicleData vehicle = null; vehicles_map.TryGetValue(name, out vehicle); return(vehicle); }
void ReadVehicles(string vfile) { XmlReaderSettings xrs = new XmlReaderSettings(); xrs.IgnoreWhitespace = true; xrs.IgnoreComments = true; XmlReader reader = XmlReader.Create(Path.Combine(Path.GetDirectoryName(file), vfile), xrs); reader.ReadStartElement("vehicles"); while (reader.IsStartElement("vehicle")) { ConfigVehicleData v = new ConfigVehicleData(); v.Name = reader.GetAttribute("name"); reader.ReadStartElement(); if (reader.IsStartElement("obd")) { reader.ReadStartElement(); while (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "engine": v.ECUEngine = reader.ReadElementString("engine"); break; case "engine-init": v.EngineInit = reader.ReadElementString("engine-init"); break; case "sensors": v.Sensors.Add(reader.ReadElementString("sensors")); break; default: reader.ReadElementString(); break; } } reader.ReadEndElement(); } while (reader.NodeType != XmlNodeType.EndElement) { if (reader.NodeType == XmlNodeType.Element) { var name = reader.Name; var val = reader.ReadElementString(); v.Parameters.Add(name, val); } } reader.ReadEndElement(); this.vehicles.Add(v); this.vehicles_map.Add(v.Name, v); } reader.Close(); }
public static void EngineConnect() { var veh = config.GetVehicle(config.Vehicle); if (veh == null) veh = new ConfigVehicleData(); if (HOBD.engine == null) HOBD.engine = Engine.CreateInstance(veh.ECUEngine); IStream stream = null; if (config.Port.StartsWith("btspp")) stream = new BluetoothStream(); else if (config.Port.StartsWith("tcp")) stream = new TCPStream(); else stream = new SerialStream(); engine.Deactivate(); engine.Registry = Registry; engine.Init(stream, config.Port, ""); }
void ReadVehicles(string vfile) { XmlReaderSettings xrs = new XmlReaderSettings(); xrs.IgnoreWhitespace = true; xrs.IgnoreComments = true; XmlReader reader = XmlReader.Create(Path.Combine(Path.GetDirectoryName(file), vfile), xrs); reader.ReadStartElement("vehicles"); while( reader.IsStartElement("vehicle") ){ ConfigVehicleData v = new ConfigVehicleData(); v.Name = reader.GetAttribute("name"); reader.ReadStartElement(); if ( reader.IsStartElement("obd") ){ reader.ReadStartElement(); while(reader.NodeType == XmlNodeType.Element) { switch(reader.Name) { case "engine": v.ECUEngine = reader.ReadElementString("engine"); break; case "engine-init": v.EngineInit = reader.ReadElementString("engine-init"); break; case "sensors": v.Sensors.Add(reader.ReadElementString("sensors")); break; default: reader.ReadElementString(); break; } } reader.ReadEndElement(); } while (reader.NodeType != XmlNodeType.EndElement){ if (reader.NodeType == XmlNodeType.Element){ var name = reader.Name; var val = reader.ReadElementString(); v.Parameters.Add(name, val); } } reader.ReadEndElement(); this.vehicles.Add(v); this.vehicles_map.Add(v.Name, v); } reader.Close(); }