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

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

            return(false);
        }
예제 #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);
            }
        }
예제 #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);
        }
예제 #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);
        }
예제 #6
0
        public static string ToPidReturn(PIDCode code)
        {
            var pidCode = ((int)code).ToString("X4");

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