コード例 #1
0
        private void Watch_Dog_Load(object sender, EventArgs e)
        {
            UInt16 LastErrCode;

            byte[] byLibVersion = new byte[Watch_Dog_API.IMC_LIB_VERSION_SIZE];

            LastErrCode = Watch_Dog_API.WD_GetLibVersion(byLibVersion);

            if (LastErrCode != IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to get library version");
                return;
            }
            int nRealSize;

            LibVersionTxtBx.Text = ConvertByte2String(byLibVersion, byLibVersion.Length, out nRealSize);


            LastErrCode = Watch_Dog_API.WD_Initialize(TREK_WD_PORT_NUMBER);
            if (LastErrCode != IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to start up the Watch_Dog library");
                return;
            }
        }
コード例 #2
0
        private void WDTimerEnabledBtn_Click(object sender, EventArgs e)
        {
            UInt16 LastErrCode;

            if (bActive == false)
            {
                LastErrCode = Watch_Dog_API.WD_Enabled(true);
                if (LastErrCode != IMC_ERR_NO_ERROR)
                {
                    MessageBox.Show("Fails to enable Watch Dog timer");
                    return;
                }
                bActive = true;
                WDTimerEnabledBtn.Text = "Stop WD Timer";
            }
            else
            {
                LastErrCode = Watch_Dog_API.WD_Enabled(false);
                if (LastErrCode != IMC_ERR_NO_ERROR)
                {
                    MessageBox.Show("Fails to disable Watch Dog timer");
                    return;
                }
                bActive = false;
                WDTimerEnabledBtn.Text = "Start WD Timer";
            }
        }
コード例 #3
0
        private void WDTimerTriggerBtn_Click(object sender, EventArgs e)
        {
            UInt16 LastErrCode;

            LastErrCode = Watch_Dog_API.WD_Trigger();
            if (LastErrCode != IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to trigger Watch Dog timer");
                return;
            }
        }
コード例 #4
0
        private void Watch_Dog_Closed(object sender, EventArgs e)
        {
            UInt16 LastErrCode;

            LastErrCode = Watch_Dog_API.WD_Deinitialize();
            if (LastErrCode != IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to deinit the Watch dog library");
                return;
            }
        }
コード例 #5
0
        private void GetWDTimerBtn_Click(object sender, EventArgs e)
        {
            unsafe
            {
                UInt16 LastErrCode;
                ushort Time; ushort *pTime = &Time;
                LastErrCode = Watch_Dog_API.WD_GetTime(pTime);
                if (LastErrCode != IMC_ERR_NO_ERROR)
                {
                    MessageBox.Show("Fails to get timer time from Watch Dog");
                    return;
                }

                GetWDTimerTxt.Text = Time.ToString();
            }
        }
コード例 #6
0
        private void SetWDTimerBtn_Click(object sender, EventArgs e)
        {
            UInt16 LastErrCode;

            if (Convert.ToInt32(SetWDTimerTxt.Text) > 0xFFFF)
            {
                MessageBox.Show("Invalid value of timer.");
                return;
            }

            LastErrCode = Watch_Dog_API.WD_SetTime(Convert.ToUInt16(SetWDTimerTxt.Text));
            if (LastErrCode != IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to set timer time to Watch Dog");
                return;
            }
        }
コード例 #7
0
        private void GetRangeBtn_Click(object sender, EventArgs e)
        {
            unsafe
            {
                UInt16 LastErrCode;

                UInt32 MaxTime; UInt32 *pMaxTime = &MaxTime;
                UInt32 MinTime; UInt32 *pMinTime = &MinTime;

                LastErrCode = Watch_Dog_API.WD_GetRange(pMinTime, pMaxTime);
                if (LastErrCode != IMC_ERR_NO_ERROR)
                {
                    MessageBox.Show("Fails to get Watch Dog timer ragne");
                    return;
                }

                TimeMinTxt.Text = MinTime.ToString();
                TimeMaxTxt.Text = MaxTime.ToString();
            }
        }
コード例 #8
0
        private void SetWDTimerBtn_Click(object sender, EventArgs e)
        {
            UInt16 LastErrCode;
            ushort countdown_time;

            try
            {
                countdown_time = Convert.ToUInt16(SetWDTimerTxt.Text);
            }
            catch
            {
                MessageBox.Show("Format incorrect.");
                return;
            }
            LastErrCode = Watch_Dog_API.WD_SetTime(countdown_time);
            if (LastErrCode != IMC_ERR_NO_ERROR)
            {
                MessageBox.Show("Fails to set timer time to Watch Dog");
                return;
            }
        }