Exemple #1
0
        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, "");
        }
Exemple #2
0
        public ConfigVehicleData GetVehicle(string name)
        {
            ConfigVehicleData vehicle = null;

            vehicles_map.TryGetValue(name, out vehicle);
            return(vehicle);
        }
Exemple #3
0
        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();
        }
Exemple #4
0
        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, "");
        }
Exemple #5
0
        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();
        }