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; } }
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"; } }
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; } }
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; } }
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(); } }
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; } }
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(); } }
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; } }