示例#1
0
 private void DtcMenuItem_Click(object sender, System.EventArgs e)
 {
     OBDCodes.CreateSingleton();
     OBDRead.GetSingleton().ReadReadCodes();
     OBDCodes.GetSingleton().ShowDialog();
     OBDCodes.DestroySingleton();
     OBDRead.GetSingleton().ReadRestart();
 }
示例#2
0
 private void OBDGauge_Load(object sender, System.EventArgs e)
 {
     OBDSerial.CreateSingleton();
     OBDRead.CreateSingleton();
     OBDSensor.CreateSingleton();
     OBDPrefs.LoadPrefs(mPrefs);
     OBDRead.GetSingleton().Prefs   = mPrefs;
     OBDSensor.GetSingleton().Prefs = mPrefs;
     OBDSensor.GetSingleton().Init();
 }
示例#3
0
        private void preferencesMenuItem_Click(object sender, System.EventArgs e)
        {
            OBDRead.GetSingleton().ReadClose();
            OBDPrefs OBDPrefs = new OBDPrefs(mPrefs);

            OBDPrefs.ShowDialog();
            OBDPrefs.SavePrefs(mPrefs);
            OBDRead.GetSingleton().Prefs   = mPrefs;
            OBDSensor.GetSingleton().Prefs = mPrefs;

            ReadOpen();
        }
示例#4
0
 private void clearButton_Click(object sender, System.EventArgs e)
 {
     if (MessageBox.Show(
             "Turn off the engine lamp and erase all diagnostic data?\nPlease shut off engine but leave ignition on before proceeding.",
             "Clear Trouble Codes", MessageBoxButtons.OKCancel, MessageBoxIcon.Question,
             MessageBoxDefaultButton.Button1) == DialogResult.OK)
     {
         ClearLists();
         DisplayWait();
         OBDRead.GetSingleton().ReadClearCodes();
     }
 }
示例#5
0
 private void ReadOpen()
 {
     OBDSensor.GetSingleton().SensorUpdateStatus("Initializing...");
     try
     {
         OBDRead.GetSingleton().ReadOpen();
     }
     catch
     {
         System.Windows.Forms.MessageBox.Show("Failed to open serial port.", "Error",
                                              System.Windows.Forms.MessageBoxButtons.OK,
                                              System.Windows.Forms.MessageBoxIcon.Exclamation,
                                              System.Windows.Forms.MessageBoxDefaultButton.Button1);
     }
 }
示例#6
0
        private void CalcActivePids()
        {
            int    page, row;
            UInt32 activePids = 0;

            for (page = 0; page < PAGEMAX; page++)
            {
                if (mPrefs.Query == 0 || page == mSensorPrefs.Page)
                {
                    for (row = 0; row < mSensorPrefs.SensorCount[page]; row++)
                    {
                        activePids |= (UInt32)(1L << (32 - pidMap[(int)activeSensor[mSensorPrefs.Sensor[page, row]]]));
                    }
                }
            }
            OBDRead.GetSingleton().ReadSetActivePids(activePids);
        }
示例#7
0
        private void tickTimer_Tick(object sender, System.EventArgs e)
        {
            if (OBDSensor.GetSingleton() == null)
            {
                return;
            }
            this.tickTimer.Enabled = false;

            if (mFirstTick)
            {
                mFirstTick = false;
                OBDSensor.GetSingleton().SensorPage(0);
                ReadOpen();
            }
            OBDRead.GetSingleton().ReadHandleTick();

            this.tickTimer.Enabled = true;
        }
示例#8
0
        public void SensorWriteLogRecord()
        {
            if (mLogWriter == null)
            {
                return;
            }
            // Palm uses Jan 1, 1904 as date times are measured from
            UInt32  seconds    = Convert.ToUInt32(DateTime.Now.Subtract(new DateTime(1904, 1, 1)).TotalSeconds);
            UInt32  activePids = OBDRead.GetSingleton().ReadGetActivePids();
            byte    length     = 8;
            int     pid;
            eSensor sensorNum;

            for (pid = 1; pid < 32; pid++)
            {
                if ((activePids & (1L << (32 - pid))) != 0)
                {
                    sensorNum = sensorMap[pid];
                    if (sensorNum >= 0)
                    {
                        length += 2;
                    }
                }
            }
            mLogWriter.Write(length);
            mLogWriter.Write(seconds);
            mLogWriter.Write(activePids);
            for (pid = 1; pid < 32; pid++)
            {
                if ((activePids & (1L << (32 - pid))) != 0)
                {
                    sensorNum = sensorMap[pid];
                    if (sensorNum >= 0)
                    {
                        mLogWriter.Write(reading[(int)sensorNum].value);
                        mUpdateCount = 0;
                    }
                }
            }
        }
示例#9
0
 static public void DestroySingleton()
 {
     mOBDRead.ReadClose();
     mOBDRead = null;
 }
示例#10
0
 static public void CreateSingleton()
 {
     mOBDRead = new OBDRead();
 }
示例#11
0
        private void UpdateRate(Int16 rate)
        {
            int           i;
            StringBuilder s = new StringBuilder();
            UInt32        activePids;
            Int16         sensorCount;
            int           pid;

            activePids  = OBDRead.GetSingleton().ReadGetActivePids();
            sensorCount = 0;
            if (mLogWriter != null)
            {
                s.Append("Record ");
                long fileLength = mLogWriter.BaseStream.Length;
                s.Append(fileLength / 1024);
                s.Append('.');
                s.Append((fileLength % 1024) * 100 / 1024);
                s.Append('K');
            }
            else
            {
                s.Append("Scan ");
                for (pid = 1; pid < 32; pid++)
                {
                    if ((activePids & (1L << (32 - pid))) != 0)
                    {
                        if (sensorMap[pid] >= 0)
                        {
                            sensorCount++;
                        }
                    }
                }
                for (i = 0; i < sensorCount; i++)
                {
                    s.Append((i == mUpdateCount) ? 'o' : '.');
                }
                mUpdateRate[mUpdateCount++] = rate;
                if (mUpdateCount >= sensorCount)
                {
                    mUpdateCount = 0;
                }
                rate = 0;
                for (i = 0; i < sensorCount; i++)
                {
                    rate += mUpdateRate[i];
                }
                if (sensorCount != 0)
                {
                    rate /= sensorCount;
                }
                s.Append(' ');
                if (rate < 0)
                {
                    rate = 0;
                }
                if (rate > 99)
                {
                    rate = 99;
                }
                s.Append(rate / 10);
                s.Append('.');
                s.Append(rate - (rate / 10) * 10);
                s.Append("/s");
            }
            SensorUpdateStatus(s.ToString());
        }
示例#12
0
		static public void DestroySingleton()
		{
			mOBDRead.ReadClose();
			mOBDRead = null;
		}
示例#13
0
		static public void CreateSingleton()
		{
			mOBDRead = new OBDRead();
		}
示例#14
0
 private void OBDGauge_Closed(object sender, System.EventArgs e)
 {
     OBDSensor.DestroySingleton();
     OBDRead.DestroySingleton();
     OBDSerial.DestroySingleton();
 }