123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- namespace FPER
- {
- public partial class frmDriveTest : Form
- {
- public frmDriveTest()
- {
- InitializeComponent();
-
- timer_Protect.Enabled = true;
- }
- LogFileCreate LFC = new LogFileCreate();
- MDIParent mdi = null;
- delegate void deleFormInit();
- bool sBatteryTestCommandStart = false;
- int sBatteryTestAction = 0;
- int sBatteryTestSecond = 20;
- int iStatusCount = 0;
-
-
- delegate void SetVoltageCallback(float cnt);
- private void btnWinClose_Click(object sender, EventArgs e)
- {
- try
- {
-
- mdi.winDriveTestForm = null;
- this.Close();
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- public void Form_Init()
- {
- try
- {
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
-
- }
- }
- private void frmDriveTest_Load(object sender, EventArgs e)
- {
-
- SetStyle(ControlStyles.UserPaint, true);
-
- SetStyle(ControlStyles.AllPaintingInWmPaint, true);
-
- SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
- this.UpdateStyles();
- try
- {
- this.mdi = (MDIParent)this.MdiParent;
- txtThisReceiverID.Text = string.Format("{0:00}", mdi.myReceiverID);
-
-
-
-
-
-
-
-
- foreach (Control currentControl in panel_Bottom.Controls)
- {
- if (currentControl is TextBox)
- {
- TextBox txt = (TextBox)currentControl;
- txt.Text = "";
- }
- }
- txtTestSecond.Text = string.Format("{0}초", sBatteryTestSecond);
-
- this.mdi.ui.Voltage_Read(null);
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void frmDriveTest_Activated(object sender, EventArgs e)
- {
- try
- {
- this.mdi.SelectMenuIndex = 5;
-
-
-
- this.mdi.Form_Active_frmDriveTest = true;
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void frmDriveTest_Disposed(object sender, EventArgs e)
- {
- try
- {
- this.mdi.SelectMenuIndex = 0;
-
- this.mdi.Form_Active_frmDriveTest = false;
-
- DoBatteryTest(false);
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
-
- public void Display_24Voltage(float vol)
- {
- try
- {
- if (this.txt24Voltage.InvokeRequired)
- {
- Console.WriteLine("Display_24Voltage = {0}", vol);
- SetVoltageCallback d = new SetVoltageCallback(Display_24Voltage);
- this.txt24Voltage.Invoke(d, new object[] { vol });
- }
- else
- {
- this.txt24Voltage.Text = String.Format("{0:0.00}V", vol);
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
-
- public void Display_5Voltage(float vol)
- {
- try
- {
- if (this.txt5Voltage.InvokeRequired)
- {
- SetVoltageCallback d = new SetVoltageCallback(Display_5Voltage);
- this.txt5Voltage.Invoke(d, new object[] { vol });
- }
- else
- {
- this.txt5Voltage.Text = String.Format("{0:0.00}V", vol);
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
-
- public void Display_3Voltage(float vol)
- {
- try
- {
- if (this.txt3Voltage.InvokeRequired)
- {
- SetVoltageCallback d = new SetVoltageCallback(Display_3Voltage);
- this.txt3Voltage.Invoke(d, new object[] { vol });
- }
- else
- {
- this.txt3Voltage.Text = String.Format("{0:0.00}V", vol);
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
-
- public void Display_BatteryVoltage(float vol)
- {
- try
- {
- if (this.txtBatteryVoltage.InvokeRequired)
- {
- SetVoltageCallback d = new SetVoltageCallback(Display_BatteryVoltage);
- this.txtBatteryVoltage.Invoke(d, new object[] { vol });
- }
- else
- {
- this.txtBatteryVoltage.Text = String.Format("{0:0.00}V", vol);
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
-
- public void btnBatteryTest_Click(object sender, EventArgs e)
- {
-
-
-
- if (mdi.AC_TestError == true && mdi.Battery_TestError == false)
- lblBatteryTestResult.Text = "BATTERY 테스트 대기 (교류전원 확인)";
- else if (mdi.Battery_TestError == true && mdi.AC_TestError == false)
- lblBatteryTestResult.Text = "BATTERY 테스트 대기 (예비전원 확인)";
- else
- lblBatteryTestResult.Text = "BATTERY 테스트 대기 (전원 확인)";
- LFC.Log("타입: 수신기 조작 로그, 메세지: BATTERY 테스트");
-
- mdi.ui.ReadIO15Input();
-
- iStatusCount = 0;
- StatusTimer.Enabled = true;
- }
-
- public void DoBatteryTest2(bool status)
- {
-
- if (status == false)
- {
- DoBatteryTest(false);
- }
-
-
-
-
-
-
-
-
- btnBatteryTest_Click(null, null);
- }
-
- public void DoBatteryTest(bool status)
- {
- try
- {
- if (status == true)
- {
- if ((mdi.ui.bPowerStatus == true) && (mdi.ui.bEmergencyPowerStatus == true))
- {
- sBatteryTestAction = 1;
- sBatteryTestCommandStart = true;
- btnBatteryTest.Text = " 시험종료";
- sBatteryTestCommandStart = true;
- timer1.Interval = 1000;
- timer1.Enabled = true;
- timer1.Start();
- lblBatteryTestResult.Text = "BATTERY 테스트 시작";
- lblBatteryTestResult.ForeColor = System.Drawing.Color.Blue;
- lblBatteryTestResult.Show();
- lblBatteryTestMessage.Show();
- lblBatteryTestMessage2.Show();
- }
- }
- else
- {
- sBatteryTestAction = 0;
- sBatteryTestCommandStart = false;
-
- btnBatteryTest.Text = " 시험시작";
- sBatteryTestSecond = 20;
- txtTestSecond.Text = string.Format("{0}초", sBatteryTestSecond);
- timer1.Enabled = false;
- lblBatteryTestResult.Text = "BATTERY 테스트 완료";
- lblBatteryTestResult.ForeColor = System.Drawing.Color.Blue;
- lblBatteryTestResult.Show();
- lblBatteryTestMessage.Hide();
- lblBatteryTestMessage2.Hide();
- }
-
- dCommandResponse d = new dCommandResponse(BatteryTestComplete);
-
- CmdInfo cmd = new CmdInfo(prt_cmd_define.read_command_status, mdi.myReceiverID, 0, 0, 0, d);
- cmd.CommandType = "TB";
- cmd.ApplyRange = "A";
- cmd.CommandData = null;
- cmd.Status = sBatteryTestAction;
- mdi.ui.runCommand(cmd);
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- btnBatteryTest.Enabled = true;
- this.Cursor = Cursors.Default;
- }
- }
-
- private void button_end(Button btn, Boolean val)
- {
- if (val)
- {
- btn.Enabled = true;
- this.Cursor = Cursors.Default;
- }
- else
- {
- btn.Enabled = false;
- this.Cursor = Cursors.WaitCursor;
- }
- }
-
-
-
- public void BatteryTestComplete(CmdInfo cmd)
- {
- try
- {
-
- btnBatteryTest.Enabled = true;
- this.Cursor = Cursors.Default;
-
- if (!Util.ComInfoErrProcess(cmd, mdi.ui.Connected, "RCVData_ReadCommandStatus"))
- {
-
- sBatteryTestCommandStart = false;
- timer1.Stop();
- timer1.Enabled = false;
-
- DoBatteryTest(false);
- return;
- }
- sBatteryTestCommandStart = true;
- if (sBatteryTestAction == 1)
- {
- btnBatteryTest.Text = " 시험종료";
- sBatteryTestCommandStart = true;
- timer1.Interval = 1000;
- timer1.Enabled = true;
- timer1.Start();
- lblBatteryTestMessage.Show();
- lblBatteryTestMessage2.Show();
- }
- else
- {
- sBatteryTestCommandStart = false;
- sBatteryTestAction = 0;
- btnBatteryTest.Text = " 시험시작";
- sBatteryTestSecond = 20;
- txtTestSecond.Text = string.Format("{0}초", sBatteryTestSecond);
- timer1.Enabled = false;
- lblBatteryTestMessage.Hide();
- lblBatteryTestMessage2.Hide();
- }
- this.mdi.ui.Voltage_Read(null);
-
-
-
-
-
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
-
- private int timer_Protect_Tick_Cnt = 0;
- private void timer_Protect_Tick(object sender, EventArgs e)
- {
- try
- {
-
- if (this.mdi == null
- || this.mdi.ui == null
- || this.txt24Voltage == null
- || this.timer1 == null
- || this.StatusTimer == null)
- return;
-
-
- if (this.timer1.Enabled == true || this.StatusTimer.Enabled == true)
- return;
- timer_Protect_Tick_Cnt++;
- if (timer_Protect_Tick_Cnt == 1)
- {
- this.mdi.ui.Voltage_Read(null);
- this.txt24Voltage.Text = mdi.Power_Main_vol24;
- timer_Protect_Tick_Cnt = 0;
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- try
- {
-
-
-
- if (sBatteryTestSecond > 1 && sBatteryTestSecond < 20)
- this.mdi.ui.Voltage_Read(null);
- if (sBatteryTestCommandStart)
- {
- sBatteryTestSecond--;
- txtTestSecond.Text = string.Format("{0}초", sBatteryTestSecond);
- if (sBatteryTestSecond < 1)
- {
- sBatteryTestSecond = 0;
- sBatteryTestCommandStart = false;
- lblBatteryTestResult.Text = "BATTERY 테스트 완료";
- lblBatteryTestResult.ForeColor = System.Drawing.Color.Blue;
- lblBatteryTestResult.Show();
- btnBatteryTest_Click(btnBatteryTest, System.EventArgs.Empty);
- }
- }
-
- if ((mdi.ui.bPowerStatus == false) || (mdi.ui.bEmergencyPowerStatus == false))
- {
- DoBatteryTest(false);
- }
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
- private void frmDriverTestClose(object sender, FormClosedEventArgs e)
- {
- try
- {
- DoBatteryTest(false);
- mdi.winDriveTestForm = null;
- }
- catch (Exception ex)
- {
- Util.UErrorMessage(ex, 0, 0);
- }
- }
-
-
-
- private void StatusTimer_Tick(object sender, EventArgs e)
- {
- iStatusCount++;
- if (iStatusCount > 20)
- {
- StatusTimer.Enabled = false;
- iStatusCount = 0;
- }
-
- if (iStatusCount == 1) return;
-
- if (mdi.AC_TestError == true && mdi.Battery_TestError == false)
- lblBatteryTestResult.Text = "BATTERY 테스트 대기 (교류전원 확인)";
- else if (mdi.Battery_TestError == true && mdi.AC_TestError == false)
- lblBatteryTestResult.Text = "BATTERY 테스트 대기 (예비전원 확인)";
- else
- lblBatteryTestResult.Text = "BATTERY 테스트 대기 (전원 확인)";
- if (mdi.ui.bReceivePowerStatus == true)
- {
-
- StatusTimer.Enabled = false;
- iStatusCount = 0;
-
- if (sBatteryTestAction == 1)
- {
-
- DoBatteryTest(false);
-
- Console.WriteLine("DoBatteryTest(false);");
- }
- else
- {
- DoBatteryTest(true);
- Console.WriteLine("DoBatteryTest(true);");
- }
- }
- else
- {
-
- if (mdi.AC_TestError == true && mdi.Battery_TestError == true)
- {
- lblBatteryTestResult.Text = "통신 응답 없음 ";
- lblBatteryTestResult.ForeColor = System.Drawing.Color.Blue;
- lblBatteryTestResult.Show();
-
- StatusTimer.Enabled = false;
- iStatusCount = 0;
- }
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }
|