示例#1
0
        /// <summary>
        /// Get data for pid
        /// </summary>
        /// <param name="pid"></param>
        /// <returns></returns>
        public OdbQueryResponse RequestFor(OdbPid pid)
        {
            //add new query to databaze
            if (!queryResponses.ContainsKey(pid))
            {
                OdbQuery newQuery = new OdbQuery();
                newQuery.Pid = pid;
                newQuery.Status = this.checkSupported(newQuery);
                queryResponses.Add(pid, newQuery);

                reporter.ReportNewQuery(newQuery);
            }

            //read data from query
            OdbQuery query = queryResponses[pid];
            OdbQueryResponse response = new OdbQueryResponse();
            if (query.Status == QueryStatus.Complete)
            {
                response.Data = query.Data;
                response.Unit = query.Pid.Units;
                response.MinValue = query.Pid.MinValue;
                response.MaxValue = query.Pid.MaxValue;

                return response;
            }
            return null;
        }
示例#2
0
        /// <summary>
        /// Report new query
        /// </summary>
        /// <param name="newQuery"></param>
        public void ReportNewQuery(OdbQuery newQuery)
        {
            if (!OdbClient.OBD_REPORTER_ENABLED)
            {
                return;
            }

            if (newQuery.Status == QueryStatus.NotSupported)
            {
                Debug.WriteLine(InfoPrefix + "Query for '{0} ({1})' can not be registered because this PID is not supported.", newQuery.Pid.Description, newQuery.Pid.Pid);
            }
            else
            {
                Debug.WriteLine(InfoPrefix + "Registering new query for '{0} ({1})'.", newQuery.Pid.Description, newQuery.Pid.Pid);
            }
        }
示例#3
0
 /// <summary>
 /// Check if query is supported
 /// </summary>
 /// <param name="query"></param>
 /// <returns></returns>
 private QueryStatus checkSupported(OdbQuery query)
 {
     if (this.commands.IsPidSupportedForEcu(this.ecu.Current, query.Pid))
     {
         return QueryStatus.NoData;
     }
     return QueryStatus.NotSupported;
 }