Пример #1
0
        public void TestGetDtcText()
        {
            var actual = ObdSupport.GetDtcText(0x0133);

            Assert.AreEqual("P0133", actual);

            actual = ObdSupport.GetDtcText(0x3133);
            Assert.AreEqual("P3133", actual);

            actual = ObdSupport.GetDtcText(0x4133);
            Assert.AreEqual("C0133", actual);

            actual = ObdSupport.GetDtcText(0x8133);
            Assert.AreEqual("B0133", actual);

            actual = ObdSupport.GetDtcText(0xC133);
            Assert.AreEqual("U0133", actual);

            actual = ObdSupport.GetDtcText(0xF369);
            Assert.AreEqual("U3369", actual);
        }
Пример #2
0
        } // BtnCreateRawReportClick()

        /// <summary>
        /// Handles the Click event of the <c>btnReadDtc</c> control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing
        /// the event data.</param>
        private async void BtnReadDtcClick(object sender, EventArgs e)
        {
            if (this.obdManager == null)
            {
                return;
            } // if

            try
            {
                var monitorStatus = await this.obdManager.GetMonitorStatus();

                var milOn = ((monitorStatus & ObdBase.B7) > 0);
                this.picMil.Image = milOn ? Resources.Check_Engine_70 : Resources.Check_Engine_gray_70;
                this.lblMil.Text  = string.Format("MIL (malfunction indicator lamp) is {0}", milOn ? "ON" : "OFF");
                var numDtcs = (monitorStatus & 0x7F000000) >> 24;
                if (numDtcs == 0)
                {
                    lblNumDtc.Text = "No DTCs";
                    return;
                } // if
                lblNumDtc.Text = string.Format("#DTC = {0}", numDtcs);

                var dtcList = await this.obdManager.GetDiagnosticTroubleCodes();

                this.listViewDtc.Items.Clear();
                foreach (var dtc in dtcList)
                {
                    var dtcText        = ObdSupport.GetDtcText(dtc);
                    var dtcDescription = DtcDatabase.GetDtcDescription(dtcText);
                    var item           = new ListViewItem(dtcText);
                    item.SubItems.Add(dtcDescription);
                    this.listViewDtc.Items.Add(item);
                } // foreach
            }
            catch (Exception ex)
            {
                log.Error("Error reading DTC data", ex);
            } // catch
        }     // BtnReadDtcClick()