Esempio n. 1
0
 static public PID GetPID(PIDCode pidCode)
 {
     foreach (var pid in _listPIDs)
     {
         if (pid.PIDCode == pidCode)
         {
             return(pid);
         }
     }
     return(null);
 }
Esempio n. 2
0
        public bool IsPidSupported(PIDCode pidCode)
        {
            int[] list = PidsSupported;

            if (list != null)
            {
                return(list.FirstOrDefault(n => n == (int)pidCode) != 0);
            }

            return(false);
        }
Esempio n. 3
0
        public PID this[PIDCode pidCode]
        {
            get
            {
                var pid = PID.GetPID(pidCode);

                if (pid == null)     // not registered in PID.cs
                {
                    Logger?.WriteLine($"{pidCode} not found in static PID list (PID.cs)");
                }

                return(pid);
            }
        }
Esempio n. 4
0
        public object GetValue(PIDCode pidCode)
        {
            LastResponse = Connection.WriteAndRead(PID.ToPidString(pidCode) + '\r');

            if (LastResponse == null)
            {
                throw new Exception("Connection to OBD adapter lost");
            }

            LastResponse = LastResponse.ToUpper();

            var pid = PID.Parse(pidCode, this, LastResponse, CurrentEcu);

            Logger?.WriteLine($"{pidCode}: {pid.Value}");

            return(pid.Value);
        }
Esempio n. 5
0
        public static PID Parse(PIDCode pidCode, ObdCommand command, string response, string ecu)
        {
            var pid = _listPIDs.FirstOrDefault(p => p.PIDCode == pidCode);

            if (pid == null)
            {
                throw new ArgumentException($"PIDCode {pidCode} not defined in PID.CS (_listPids)");
            }

            var rawValue = GetRawValue(pid, response, ecu);

            if (rawValue != null)
            {
                pid.Value = pid.Decoder(rawValue);
            }

            return(pid);
        }
Esempio n. 6
0
        public static string ToPidReturn(PIDCode code)
        {
            var pidCode = ((int)code).ToString("X4");

            return('4' + pidCode.Substring(1));
        }
Esempio n. 7
0
 public static string ToPidString(PIDCode code)
 {
     return(((int)code).ToString("X4"));
 }
Esempio n. 8
0
 public OBDValue(string description, PIDCode pidCode, string value = "")
 {
     Description = description;
     PIDCode     = pidCode;
     Value       = value;
 }