770 lines
32 KiB
C#
770 lines
32 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
using BMS_D1000H.BMSConstData;
|
|
using BMS_D1000H.DataStructs;
|
|
using BMS_D1000H.Utils.Functions;
|
|
|
|
namespace BMS_D1000H
|
|
{
|
|
public partial class fmTrayInfo : Form
|
|
{
|
|
string[] TrayName = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" };
|
|
public int CurrentTrayNo = 0;
|
|
int disTrayNo = 0;
|
|
byte[] cLed = new byte[15];
|
|
bool ledflag = false;
|
|
|
|
|
|
SmartX.SmartLabel[] CellVoltage;
|
|
SmartX.SmartLabel[] TrayTemp;
|
|
|
|
PictureBox[] TrayWarning;
|
|
PictureBox[] TrayProtection;
|
|
|
|
SmartX.SmartLabel[] CellLed;
|
|
SmartX.SmartLabel[] TempLed;
|
|
|
|
DeviceDataTray disTrayData;
|
|
|
|
public fmTrayInfo()
|
|
{
|
|
InitializeComponent();
|
|
|
|
#region CellLed of Tray
|
|
CellLed = new SmartX.SmartLabel[15];
|
|
for (int i = 0; i < 15; i++)
|
|
{
|
|
CellLed[i] = new SmartX.SmartLabel();
|
|
//CellLed[i].BackPictureBox = this.sfmMainDetail;
|
|
CellLed[i].BackPictureBox = null;
|
|
CellLed[i].BackPictureBox1 = null;
|
|
CellLed[i].BackPictureBox2 = null;
|
|
CellLed[i].BorderColor = System.Drawing.Color.Black;
|
|
CellLed[i].BorderStyle = System.Windows.Forms.BorderStyle.None;
|
|
CellLed[i].Font = new System.Drawing.Font("Arial", 10F, System.Drawing.FontStyle.Bold);
|
|
CellLed[i].InitVisible = true;
|
|
CellLed[i].LineSpacing = 0F;
|
|
CellLed[i].Location = new System.Drawing.Point(8, 148);
|
|
CellLed[i].Name = String.Format("CellLed{0}", i);
|
|
CellLed[i].Size = new System.Drawing.Size(25, 25);
|
|
CellLed[i].TabIndex = 53;
|
|
CellLed[i].TextHAlign = SmartX.SmartLabel.TextHorAlign.Middle;
|
|
CellLed[i].TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle;
|
|
CellLed[i].Wordwrap = false;
|
|
}
|
|
CellLed[0].Location = new System.Drawing.Point( 8, 148);
|
|
CellLed[1].Location = new System.Drawing.Point( 8, 89);
|
|
CellLed[2].Location = new System.Drawing.Point( 36, 89);
|
|
CellLed[3].Location = new System.Drawing.Point( 36, 148);
|
|
CellLed[4].Location = new System.Drawing.Point( 81, 148);
|
|
CellLed[5].Location = new System.Drawing.Point( 81, 89);
|
|
CellLed[6].Location = new System.Drawing.Point(108, 89);
|
|
CellLed[7].Location = new System.Drawing.Point(108, 148);
|
|
CellLed[8].Location = new System.Drawing.Point(153, 148);
|
|
CellLed[9].Location = new System.Drawing.Point(153, 89);
|
|
CellLed[10].Location = new System.Drawing.Point(181, 89);
|
|
CellLed[11].Location = new System.Drawing.Point(181, 148);
|
|
CellLed[12].Location = new System.Drawing.Point(225, 148);
|
|
CellLed[13].Location = new System.Drawing.Point(225, 89);
|
|
CellLed[14].Location = new System.Drawing.Point(253, 89);
|
|
#endregion
|
|
|
|
#region TempLed of Tray
|
|
TempLed = new SmartX.SmartLabel[SystemID.MAX_TRAY_TEMP_SIZE];
|
|
for (int i = 0; i < SystemID.MAX_TRAY_TEMP_SIZE; i++)
|
|
{
|
|
TempLed[i] = new SmartX.SmartLabel();
|
|
TempLed[i].BackPictureBox = this.sfmMainDetail;
|
|
TempLed[i].BackPictureBox1 = null;
|
|
TempLed[i].BackPictureBox2 = null;
|
|
TempLed[i].BorderColor = System.Drawing.Color.Black;
|
|
TempLed[i].BorderStyle = System.Windows.Forms.BorderStyle.None;
|
|
TempLed[i].Font = new System.Drawing.Font("Arial", 10F, System.Drawing.FontStyle.Bold);
|
|
TempLed[i].InitVisible = true;
|
|
TempLed[i].LineSpacing = 0F;
|
|
TempLed[i].Location = new System.Drawing.Point(8, 89);
|
|
TempLed[i].Name = String.Format("TempLed{0}", i);
|
|
TempLed[i].Size = new System.Drawing.Size(25, 25);
|
|
TempLed[i].TabIndex = 53;
|
|
TempLed[i].TextHAlign = SmartX.SmartLabel.TextHorAlign.Middle;
|
|
TempLed[i].TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle;
|
|
TempLed[i].Wordwrap = false;
|
|
}
|
|
#endregion
|
|
|
|
#region CellVoltageLabel of Tray
|
|
CellVoltage = new SmartX.SmartLabel[SystemID.MAX_TRAY_CELL_SIZE];
|
|
for (int i = 0; i < SystemID.MAX_TRAY_CELL_SIZE; i++)
|
|
{
|
|
CellVoltage[i] = new SmartX.SmartLabel();
|
|
CellVoltage[i].BackColor = System.Drawing.Color.White;
|
|
CellVoltage[i].BackPictureBox = this.sfmMainDetail;
|
|
CellVoltage[i].BackPictureBox1 = null;
|
|
CellVoltage[i].BackPictureBox2 = null;
|
|
CellVoltage[i].BorderColor = System.Drawing.Color.Black;
|
|
CellVoltage[i].BorderStyle = System.Windows.Forms.BorderStyle.None;
|
|
CellVoltage[i].Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold);
|
|
CellVoltage[i].InitVisible = true;
|
|
CellVoltage[i].LineSpacing = 0F;
|
|
CellVoltage[i].Location = new System.Drawing.Point(378 + ((i / 8) * 170), 271 + ((i % 8) * 20));
|
|
CellVoltage[i].Name = String.Format("CellVoltage{0}", i);
|
|
CellVoltage[i].Size = new System.Drawing.Size(78, 15);
|
|
CellVoltage[i].TabIndex = 49;
|
|
CellVoltage[i].Text = "0.000";
|
|
CellVoltage[i].TextHAlign = SmartX.SmartLabel.TextHorAlign.Middle;
|
|
CellVoltage[i].TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle;
|
|
CellVoltage[i].Wordwrap = false;
|
|
}
|
|
#endregion
|
|
|
|
#region TemperatureLabel of Tray
|
|
TrayTemp = new SmartX.SmartLabel[SystemID.MAX_TRAY_TEMP_SIZE];
|
|
for (int i = 0; i < SystemID.MAX_TRAY_TEMP_SIZE; i++)
|
|
{
|
|
TrayTemp[i] = new SmartX.SmartLabel();
|
|
TrayTemp[i].BackColor = System.Drawing.Color.White;
|
|
TrayTemp[i].BackPictureBox = this.sfmMainDetail;
|
|
TrayTemp[i].BackPictureBox1 = null;
|
|
TrayTemp[i].BackPictureBox2 = null;
|
|
TrayTemp[i].BorderColor = System.Drawing.Color.Black;
|
|
TrayTemp[i].BorderStyle = System.Windows.Forms.BorderStyle.None;
|
|
TrayTemp[i].Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold);
|
|
TrayTemp[i].InitVisible = true;
|
|
TrayTemp[i].LineSpacing = 0F;
|
|
TrayTemp[i].Location = new System.Drawing.Point(717, 271 + (i * 20));
|
|
TrayTemp[i].Name = String.Format("TrayTemp{0}", i);
|
|
TrayTemp[i].Size = new System.Drawing.Size(78, 15);
|
|
TrayTemp[i].TabIndex = 50;
|
|
TrayTemp[i].Text = "0.0";
|
|
TrayTemp[i].TextHAlign = SmartX.SmartLabel.TextHorAlign.Middle;
|
|
TrayTemp[i].TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle;
|
|
TrayTemp[i].Wordwrap = false;
|
|
}
|
|
#endregion
|
|
|
|
#region Warning Alarm ICON of Tray
|
|
TrayWarning = new PictureBox[10];
|
|
for (int i = 0; i < 10; i++)
|
|
{
|
|
TrayWarning[i] = new PictureBox();
|
|
//if ((i % 2) == 0)
|
|
// TrayWarning[i].Image = pbAlarmNormalA.Image;
|
|
//else
|
|
// TrayWarning[i].Image = pbAlarmNormalB.Image;
|
|
TrayWarning[i].Location = new System.Drawing.Point(205, (234 + (i * 24)));
|
|
TrayWarning[i].Name = String.Format("TrayWarning{0}", i);
|
|
TrayWarning[i].Size = new System.Drawing.Size(23, 23);
|
|
TrayWarning[i].SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
|
}
|
|
TrayWarning[0].Location = new System.Drawing.Point(205, 234);
|
|
TrayWarning[1].Location = new System.Drawing.Point(205, 259);
|
|
TrayWarning[2].Location = new System.Drawing.Point(205, 283);
|
|
TrayWarning[3].Location = new System.Drawing.Point(205, 308);
|
|
TrayWarning[4].Location = new System.Drawing.Point(205, 332);
|
|
TrayWarning[5].Location = new System.Drawing.Point(205, 357);
|
|
TrayWarning[6].Location = new System.Drawing.Point(205, 381);
|
|
TrayWarning[7].Location = new System.Drawing.Point(205, 406);
|
|
TrayWarning[8].Location = new System.Drawing.Point(205, 430);
|
|
TrayWarning[9].Location = new System.Drawing.Point(205, 455);
|
|
#endregion
|
|
|
|
#region Protection Alarm ICON of Tray
|
|
TrayProtection = new PictureBox[10];
|
|
for (int i = 0; i < 10; i++)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
case 1:
|
|
case 4:
|
|
case 6:
|
|
case 7:
|
|
//case 8:
|
|
TrayProtection[i] = new PictureBox();
|
|
break;
|
|
}
|
|
if (TrayProtection[i] != null)
|
|
{
|
|
//if ((i % 2) == 0)
|
|
// TrayProtection[i].Image = pbAlarmNormalA.Image;
|
|
//else
|
|
// TrayProtection[i].Image = pbAlarmNormalB.Image;
|
|
TrayProtection[i].Location = new System.Drawing.Point(252, (234 + (i * 24)));
|
|
TrayProtection[i].Name = String.Format("TrayProtection{0}", i);
|
|
TrayProtection[i].Size = new System.Drawing.Size(23, 23);
|
|
TrayProtection[i].SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
|
}
|
|
}
|
|
TrayProtection[0].Location = new System.Drawing.Point(252, 234);
|
|
TrayProtection[1].Location = new System.Drawing.Point(252, 259);
|
|
//TrayProtection[2].Location = new System.Drawing.Point(252, 283);
|
|
//TrayProtection[3].Location = new System.Drawing.Point(252, 308);
|
|
TrayProtection[4].Location = new System.Drawing.Point(252, 332);
|
|
//TrayProtection[5].Location = new System.Drawing.Point(252, 357);
|
|
TrayProtection[6].Location = new System.Drawing.Point(252, 381);
|
|
TrayProtection[7].Location = new System.Drawing.Point(252, 406);
|
|
//TrayProtection[8].Location = new System.Drawing.Point(252, 430);
|
|
//TrayProtection[9].Location = new System.Drawing.Point(252, 455);
|
|
#endregion
|
|
|
|
ReloadControl();
|
|
|
|
disTrayData = new DeviceDataTray();
|
|
disTrayData.CellVoltage = new short[SystemID.MAX_TRAY_CELL_SIZE];
|
|
disTrayData.CellTemperature = new short[SystemID.MAX_TRAY_TEMP_SIZE];
|
|
}
|
|
|
|
#region Control Re-loading
|
|
private void ReloadControl()
|
|
{
|
|
this.SuspendLayout();
|
|
this.Controls.Clear();
|
|
|
|
this.Controls.Add(this.lbTrayNo);
|
|
|
|
// CellLed
|
|
for (int i = 0; i < SystemID.MAX_TRAY_CELL_SIZE; i++)
|
|
{
|
|
this.Controls.Add(CellLed[i]);
|
|
}
|
|
// TempLed
|
|
for (int i = 0; i < SystemID.MAX_TRAY_TEMP_SIZE; i++)
|
|
{
|
|
this.Controls.Add(TempLed[i]);
|
|
}
|
|
|
|
for (int i = 0; i < SystemID.MAX_TRAY_CELL_SIZE; i++)
|
|
{
|
|
this.Controls.Add(CellVoltage[i]);
|
|
}
|
|
for (int i = 0; i < SystemID.MAX_TRAY_TEMP_SIZE; i++)
|
|
{
|
|
this.Controls.Add(TrayTemp[i]);
|
|
}
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
{
|
|
this.Controls.Add(TrayWarning[i]);
|
|
}
|
|
for (int i = 0; i < 10; i++)
|
|
{
|
|
if (TrayProtection[i] != null)
|
|
this.Controls.Add(TrayProtection[i]);
|
|
}
|
|
|
|
this.Controls.Add(lbModelName);
|
|
this.Controls.Add(lbModelSpec);
|
|
|
|
this.Controls.Add(lbW);
|
|
this.Controls.Add(lbP);
|
|
|
|
this.Controls.Add(MaxCVolt);
|
|
this.Controls.Add(MinCVolt);
|
|
this.Controls.Add(AvgCVolt);
|
|
this.Controls.Add(MaxTemp);
|
|
this.Controls.Add(MinTemp);
|
|
this.Controls.Add(AvgTemp);
|
|
|
|
this.Controls.Add(this.TrayVoltage);
|
|
this.Controls.Add(this.TrayCurrent);
|
|
this.Controls.Add(this.TraySoc);
|
|
this.Controls.Add(this.btnMain);
|
|
|
|
this.Controls.Add(this.lbTrayAlarm);
|
|
this.Controls.Add(this.lbTrayStatus);
|
|
this.Controls.Add(this.TrayMaxTemp);
|
|
this.Controls.Add(this.btnRight);
|
|
this.Controls.Add(this.btnLeft);
|
|
this.Controls.Add(this.btnHistory);
|
|
this.Controls.Add(this.btnMain);
|
|
this.Controls.Add(this.TraySoc);
|
|
this.Controls.Add(this.TrayCurrent);
|
|
this.Controls.Add(this.TrayVoltage);
|
|
this.Controls.Add(this.sfmMainDetail);
|
|
|
|
this.ResumeLayout(false);
|
|
}
|
|
#endregion
|
|
|
|
private void btnMain_Click(object sender, EventArgs e)
|
|
{
|
|
// Main 폼 표시 Index가 0이면 Main폼을 의미 합니다.
|
|
((fmBMSMain)(Owner)).sfmMain.Show(0);
|
|
}
|
|
|
|
private void InitTrayValue()
|
|
{
|
|
//lbTrayStatusA.Text = "대기중";
|
|
//lbTrayStatusB.Text = "대기중";
|
|
//lbTrayStatusC.Text = "대기중";
|
|
//lbTrayAlarmA.Text = "정상";
|
|
//lbTrayAlarmB.Text = "정상";
|
|
//lbTrayAlarmC.Text = "정상";
|
|
}
|
|
|
|
#region Tray Detail Form Load
|
|
private void fmMainDetail_Load(object sender, EventArgs e)
|
|
{
|
|
InitTrayValue();
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
{
|
|
if ((i % 2) == 0)
|
|
{
|
|
TrayWarning[i].Image = pbAlarmNormalA.Image;
|
|
if (TrayProtection[i] != null)
|
|
TrayProtection[i].Image = pbAlarmNormalA.Image;
|
|
}
|
|
else
|
|
{
|
|
TrayWarning[i].Image = pbAlarmNormalB.Image;
|
|
if (TrayProtection[i] != null)
|
|
TrayProtection[i].Image = pbAlarmNormalB.Image;
|
|
}
|
|
}
|
|
|
|
DisplayTrayMain(CurrentTrayNo, true);
|
|
DisplayTrayAlarmList(CurrentTrayNo, true);
|
|
DisplayTrayStatus(CurrentTrayNo, true);
|
|
CheckCellLed(CurrentTrayNo, true);
|
|
|
|
tmDisplay.Start();
|
|
}
|
|
#endregion
|
|
|
|
#region Display Tray Data
|
|
public void DisplayTrayMain(int tno, bool p)
|
|
{
|
|
DeviceDataTray aTrayData;
|
|
|
|
aTrayData = ((fmBMSMain)(Owner)).GetTrayData(tno);
|
|
|
|
if (p || (disTrayNo != CurrentTrayNo))
|
|
{
|
|
lbTrayNo.Text = String.Format("{0}", TrayName[CurrentTrayNo]);
|
|
disTrayNo = CurrentTrayNo;
|
|
}
|
|
|
|
if (p || (disTrayData.BatVoltage != aTrayData.BatVoltage))
|
|
{
|
|
TrayVoltage.Text = String.Format("{0:#0.0}", Convert.ToDouble(aTrayData.BatVoltage) / 100);
|
|
disTrayData.BatVoltage = aTrayData.BatVoltage;
|
|
}
|
|
if (p || (disTrayData.Current != aTrayData.Current))
|
|
{
|
|
TrayCurrent.Text = String.Format("{0:#0.0}", Convert.ToDouble(aTrayData.Current) / 10);
|
|
disTrayData.Current = aTrayData.Current;
|
|
}
|
|
if (p || (disTrayData.RelativeStateOfCharge != aTrayData.RelativeStateOfCharge))
|
|
{
|
|
TraySoc.Text = String.Format("{0:#0}", (aTrayData.RelativeStateOfCharge) / 10);
|
|
disTrayData.RelativeStateOfCharge = aTrayData.RelativeStateOfCharge;
|
|
}
|
|
|
|
/* Average Cell Voltage Display */
|
|
if (p || (disTrayData.MaxCellVoltage != aTrayData.MaxCellVoltage))
|
|
{
|
|
MaxCVolt.Text = String.Format("{0:#0.000}", Convert.ToDouble(aTrayData.MaxCellVoltage) / 1000);
|
|
disTrayData.MaxCellVoltage = aTrayData.MaxCellVoltage;
|
|
}
|
|
if (p || (disTrayData.AvgCellVoltage != aTrayData.AvgCellVoltage))
|
|
{
|
|
AvgCVolt.Text = String.Format("{0:#0.000}", Convert.ToDouble(aTrayData.AvgCellVoltage) / 1000);
|
|
disTrayData.AvgCellVoltage = aTrayData.AvgCellVoltage;
|
|
}
|
|
if (p || (disTrayData.MinCellVoltage != aTrayData.MinCellVoltage))
|
|
{
|
|
MinCVolt.Text = String.Format("{0:#0.000}", Convert.ToDouble(aTrayData.MinCellVoltage) / 1000);
|
|
disTrayData.MinCellVoltage = aTrayData.MinCellVoltage;
|
|
}
|
|
|
|
/* Average Temperature Display */
|
|
if (p || (disTrayData.MaxTemp != aTrayData.MaxTemp))
|
|
{
|
|
TrayMaxTemp.Text = String.Format("{0:#0.0}", Convert.ToDouble(aTrayData.MaxTemp) / 10);
|
|
MaxTemp.Text = String.Format("{0:#0.0}", Convert.ToDouble(aTrayData.MaxTemp) / 10);
|
|
disTrayData.MaxTemp = aTrayData.MaxTemp;
|
|
}
|
|
if (p || (disTrayData.AvgTemp != aTrayData.AvgTemp))
|
|
{
|
|
AvgTemp.Text = String.Format("{0:#0.0}", Convert.ToDouble(aTrayData.AvgTemp) / 10);
|
|
disTrayData.AvgTemp = aTrayData.AvgTemp;
|
|
}
|
|
if (p || (disTrayData.MinTemp != aTrayData.MinTemp))
|
|
{
|
|
MinTemp.Text = String.Format("{0:#0.0}", Convert.ToDouble(aTrayData.MinTemp) / 10);
|
|
disTrayData.MinTemp = aTrayData.MinTemp;
|
|
}
|
|
|
|
for (int i = 0; i < SystemID.MAX_TRAY_CELL_SIZE; i++)
|
|
{
|
|
if (p || (disTrayData.CellVoltage[i] != aTrayData.CellVoltage[i]))
|
|
{
|
|
CellVoltage[i].Text = String.Format("{0:#0.000}", Convert.ToDouble(aTrayData.CellVoltage[i]) / 1000);
|
|
disTrayData.CellVoltage[i] = aTrayData.CellVoltage[i];
|
|
}
|
|
}
|
|
for (int i = 0; i < SystemID.MAX_TRAY_TEMP_SIZE; i++)
|
|
{
|
|
if (p || (disTrayData.CellTemperature[i] != aTrayData.CellTemperature[i]))
|
|
{
|
|
TrayTemp[i].Text = String.Format("{0:#0.0}", Convert.ToDouble(aTrayData.CellTemperature[i]) / 10);
|
|
disTrayData.CellTemperature[i] = aTrayData.CellTemperature[i];
|
|
}
|
|
}
|
|
}
|
|
|
|
public void DisplayTrayAlarmList(int tno, bool p)
|
|
{
|
|
int i = 0;
|
|
DeviceDataTray aTrayData;
|
|
|
|
aTrayData = ((fmBMSMain)(Owner)).GetTrayData(tno);
|
|
|
|
if (p || (disTrayData.Warning != aTrayData.Warning) || (disTrayData.AlarmStatus != aTrayData.AlarmStatus))
|
|
{
|
|
// System Over Voltage Warning
|
|
i = 0;
|
|
if (ConvertTo.GetBit(aTrayData.Warning, i) == true)
|
|
TrayWarning[i].Image = pbAlarmWarningA.Image;
|
|
else
|
|
TrayWarning[i].Image = pbAlarmNormalA.Image;
|
|
|
|
// Cell Over Voltage Warning
|
|
i = 1;
|
|
if (ConvertTo.GetBit(aTrayData.Warning, i) == true)
|
|
TrayWarning[i].Image = pbAlarmWarningB.Image;
|
|
else
|
|
TrayWarning[i].Image = pbAlarmNormalB.Image;
|
|
|
|
// System Under Voltage Warning
|
|
i = 2;
|
|
if (ConvertTo.GetBit(aTrayData.Warning, i) == true)
|
|
TrayWarning[i].Image = pbAlarmWarningA.Image;
|
|
else
|
|
TrayWarning[i].Image = pbAlarmNormalA.Image;
|
|
|
|
// Cell Under Voltage Warning
|
|
i = 3;
|
|
if (ConvertTo.GetBit(aTrayData.Warning, i) == true)
|
|
TrayWarning[i].Image = pbAlarmWarningB.Image;
|
|
else
|
|
TrayWarning[i].Image = pbAlarmNormalB.Image;
|
|
|
|
// Charge Over Current Warning
|
|
i = 4;
|
|
if (ConvertTo.GetBit(aTrayData.Warning, i) == true)
|
|
TrayWarning[i].Image = pbAlarmWarningA.Image;
|
|
else
|
|
TrayWarning[i].Image = pbAlarmNormalA.Image;
|
|
|
|
// Discharge Over Current Warning
|
|
i = 5;
|
|
if (ConvertTo.GetBit(aTrayData.Warning, i) == true)
|
|
TrayWarning[i].Image = pbAlarmWarningB.Image;
|
|
else
|
|
TrayWarning[i].Image = pbAlarmNormalB.Image;
|
|
|
|
// Charge or Discharge High Temperature Warning
|
|
i = 6;
|
|
if ((ConvertTo.GetBit(aTrayData.Warning, 8) == true)||
|
|
(ConvertTo.GetBit(aTrayData.Warning, 9) == true))
|
|
TrayWarning[i].Image = pbAlarmWarningA.Image;
|
|
else
|
|
TrayWarning[i].Image = pbAlarmNormalA.Image;
|
|
|
|
// Charge or Discharge Low Temperature Warning
|
|
i = 7;
|
|
if ((ConvertTo.GetBit(aTrayData.Warning, 10) == true) ||
|
|
(ConvertTo.GetBit(aTrayData.Warning, 11) == true))
|
|
TrayWarning[i].Image = pbAlarmWarningB.Image;
|
|
else
|
|
TrayWarning[i].Image = pbAlarmNormalB.Image;
|
|
|
|
// Charge or Discharge High Temperature Warning
|
|
i = 8;
|
|
if (ConvertTo.GetBit(aTrayData.Warning, 12) == true)
|
|
TrayWarning[i].Image = pbAlarmWarningA.Image;
|
|
else
|
|
TrayWarning[i].Image = pbAlarmNormalA.Image;
|
|
|
|
DisplayTrayAlarm(tno);
|
|
|
|
disTrayData.Warning = aTrayData.Warning;
|
|
disTrayData.AlarmStatus = aTrayData.AlarmStatus;
|
|
}
|
|
|
|
if (p || (disTrayData.Protection != aTrayData.Protection))
|
|
{
|
|
// System Over Voltage Protection
|
|
i = 0;
|
|
if (ConvertTo.GetBit(aTrayData.Protection, i) == true)
|
|
TrayProtection[i].Image = pbAlarmProtectA.Image;
|
|
else
|
|
TrayProtection[i].Image = pbAlarmNormalA.Image;
|
|
|
|
// Cell Over Voltage Protection
|
|
i = 1;
|
|
if (ConvertTo.GetBit(aTrayData.Protection, i) == true)
|
|
TrayProtection[i].Image = pbAlarmProtectB.Image;
|
|
else
|
|
TrayProtection[i].Image = pbAlarmNormalB.Image;
|
|
|
|
// Charge Over Current Protection
|
|
i = 4;
|
|
if (ConvertTo.GetBit(aTrayData.Protection, i) == true)
|
|
TrayProtection[i].Image = pbAlarmProtectA.Image;
|
|
else
|
|
TrayProtection[i].Image = pbAlarmNormalA.Image;
|
|
|
|
// Charge or Discharge High Temperature Protection
|
|
i = 6;
|
|
if ((ConvertTo.GetBit(aTrayData.Protection, 8) == true) ||
|
|
(ConvertTo.GetBit(aTrayData.Protection, 9) == true))
|
|
TrayProtection[i].Image = pbAlarmProtectA.Image;
|
|
else
|
|
TrayProtection[i].Image = pbAlarmNormalA.Image;
|
|
|
|
// Charge or Discharge Low Temperature Protection
|
|
i = 7;
|
|
if ((ConvertTo.GetBit(aTrayData.Protection, 10) == true) ||
|
|
(ConvertTo.GetBit(aTrayData.Protection, 11) == true))
|
|
TrayProtection[i].Image = pbAlarmProtectB.Image;
|
|
else
|
|
TrayProtection[i].Image = pbAlarmNormalB.Image;
|
|
|
|
DisplayTrayAlarm(tno);
|
|
|
|
disTrayData.Protection = aTrayData.Protection;
|
|
}
|
|
|
|
if (p || (disTrayData.Commfail != aTrayData.Commfail))
|
|
{
|
|
if (aTrayData.Commfail == 1)
|
|
TrayWarning[9].Image = pbAlarmWarningA.Image;
|
|
else
|
|
TrayWarning[9].Image = pbAlarmNormalA.Image;
|
|
|
|
disTrayData.Commfail = aTrayData.Commfail;
|
|
}
|
|
}
|
|
|
|
public void DisplayTrayStatus(int tno, bool p)
|
|
{
|
|
DeviceDataTray aTrayData;
|
|
|
|
aTrayData = ((fmBMSMain)(Owner)).GetTrayData(tno);
|
|
|
|
if (p || (disTrayData.OpStatus != aTrayData.OpStatus))
|
|
{
|
|
switch (aTrayData.OpStatus)
|
|
{
|
|
case 0:
|
|
lbTrayStatus.Font = new System.Drawing.Font("Tahoma", 16F, System.Drawing.FontStyle.Bold);
|
|
lbTrayStatus.ForeColor = System.Drawing.Color.Black;
|
|
lbTrayStatus.Text = "STAND BY";
|
|
break;
|
|
case 1:
|
|
lbTrayStatus.Font = new System.Drawing.Font("Tahoma", 16F, System.Drawing.FontStyle.Bold);
|
|
lbTrayStatus.ForeColor = System.Drawing.Color.Blue;
|
|
lbTrayStatus.Text = "CHARGING";
|
|
break;
|
|
case 2:
|
|
lbTrayStatus.Font = new System.Drawing.Font("Tahoma", 16F, System.Drawing.FontStyle.Bold);
|
|
lbTrayStatus.ForeColor = System.Drawing.Color.Magenta;
|
|
lbTrayStatus.Text = "DISCHARGING";
|
|
break;
|
|
case 3:
|
|
lbTrayStatus.Font = new System.Drawing.Font("Tahoma", 16F, System.Drawing.FontStyle.Bold);
|
|
lbTrayStatus.ForeColor = System.Drawing.Color.Black;
|
|
lbTrayStatus.Text = "FLOATING";
|
|
break;
|
|
}
|
|
disTrayData.OpStatus = aTrayData.OpStatus;
|
|
}
|
|
}
|
|
|
|
public void DisplayTrayAlarm(int tno)
|
|
{
|
|
DeviceDataTray aTrayData;
|
|
|
|
aTrayData = ((fmBMSMain)(Owner)).GetTrayData(tno);
|
|
|
|
switch (aTrayData.AlarmStatus)
|
|
{
|
|
case 0:
|
|
lbTrayAlarm.Font = new System.Drawing.Font("Tahoma", 16F, System.Drawing.FontStyle.Bold);
|
|
lbTrayAlarm.ForeColor = System.Drawing.Color.Green;
|
|
lbTrayAlarm.Text = "NORMAL";
|
|
break;
|
|
case 1:
|
|
lbTrayAlarm.Font = new System.Drawing.Font("Tahoma", 16F, System.Drawing.FontStyle.Bold);
|
|
lbTrayAlarm.ForeColor = System.Drawing.Color.Orange;
|
|
lbTrayAlarm.Text = "WARNING";
|
|
break;
|
|
case 2:
|
|
lbTrayAlarm.Font = new System.Drawing.Font("Tahoma", 16F, System.Drawing.FontStyle.Bold);
|
|
lbTrayAlarm.ForeColor = System.Drawing.Color.Red;
|
|
lbTrayAlarm.Text = "TRIP";
|
|
break;
|
|
case 3:
|
|
lbTrayAlarm.Font = new System.Drawing.Font("Tahoma", 16F, System.Drawing.FontStyle.Bold);
|
|
lbTrayAlarm.ForeColor = System.Drawing.Color.Black;
|
|
lbTrayAlarm.Text = "WARMING UP";
|
|
break;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Display Cell LED
|
|
private void CheckCellLed(int tno, bool p)
|
|
{
|
|
DeviceDataTray aTrayData;
|
|
|
|
aTrayData = ((fmBMSMain)(Owner)).GetTrayData(tno);
|
|
|
|
if (p || (disTrayData.cov_protection_cell != aTrayData.cov_protection_cell) ||
|
|
(disTrayData.cov_warning_cell != aTrayData.cov_warning_cell) ||
|
|
(disTrayData.cuv_protection_cell != aTrayData.cuv_protection_cell) ||
|
|
(disTrayData.cuv_warning_cell != aTrayData.cuv_warning_cell))
|
|
{
|
|
for (int i = 0; i < 15; i++)
|
|
{
|
|
if (ConvertTo.GetBit(aTrayData.cov_protection_cell, i) ||
|
|
ConvertTo.GetBit(aTrayData.cuv_protection_cell, i))
|
|
cLed[i] = 2;
|
|
else if (ConvertTo.GetBit(aTrayData.cov_warning_cell, i) ||
|
|
ConvertTo.GetBit(aTrayData.cuv_warning_cell, i))
|
|
cLed[i] = 1;
|
|
else
|
|
cLed[i] = 0;
|
|
}
|
|
disTrayData.cov_protection_cell = aTrayData.cov_protection_cell;
|
|
disTrayData.cov_warning_cell = aTrayData.cov_warning_cell;
|
|
disTrayData.cuv_protection_cell = aTrayData.cuv_protection_cell;
|
|
disTrayData.cuv_warning_cell = aTrayData.cuv_warning_cell;
|
|
}
|
|
if ((0 != aTrayData.cov_protection_cell) ||
|
|
(0 != aTrayData.cov_warning_cell) ||
|
|
(0 != aTrayData.cuv_protection_cell) ||
|
|
(0 != aTrayData.cuv_warning_cell))
|
|
{
|
|
tmLedDisplay.Start();
|
|
}
|
|
else
|
|
{
|
|
tmLedDisplay.Stop();
|
|
for (int i = 0; i < 15; i++)
|
|
{
|
|
CellLed[i].BackPictureBox = this.sfmMainDetail;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region TIMER TICK SERVICE
|
|
private void tmDisplay_Tick(object sender, EventArgs e)
|
|
{
|
|
DisplayTrayMain(CurrentTrayNo, false);
|
|
DisplayTrayAlarmList(CurrentTrayNo, false);
|
|
DisplayTrayStatus(CurrentTrayNo, false);
|
|
CheckCellLed(CurrentTrayNo, false);
|
|
}
|
|
|
|
private void tmLedDisplay_Tick(object sender, EventArgs e)
|
|
{
|
|
for (int i = 0; i < 15; i++)
|
|
{
|
|
if (cLed[i] == 2)
|
|
{
|
|
if (ledflag)
|
|
{
|
|
CellLed[i].BackColor = System.Drawing.Color.Red;
|
|
CellLed[i].BackPictureBox = null;
|
|
}
|
|
else
|
|
{
|
|
CellLed[i].BackPictureBox = this.sfmMainDetail;
|
|
}
|
|
}
|
|
else if (cLed[i] == 1)
|
|
{
|
|
if (ledflag)
|
|
{
|
|
CellLed[i].BackColor = System.Drawing.Color.Yellow;
|
|
CellLed[i].BackPictureBox = null;
|
|
}
|
|
else
|
|
{
|
|
CellLed[i].BackPictureBox = this.sfmMainDetail;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
CellLed[i].BackPictureBox = this.sfmMainDetail;
|
|
}
|
|
}
|
|
ledflag = !ledflag;
|
|
}
|
|
#endregion
|
|
|
|
#region BUTTON CLICK SERVICE
|
|
private void btnGotoMain_Click(object sender, EventArgs e)
|
|
{
|
|
((fmBMSMain)(Owner)).ScreenSaverTimeReset();
|
|
// Main 폼 표시 Index가 0이면 Main폼을 의미 합니다.
|
|
((fmBMSMain)(Owner)).sfmMain.Show(0);
|
|
}
|
|
|
|
private void btnRight_Click(object sender, EventArgs e)
|
|
{
|
|
int mQty = ((fmBMSMain)(Owner)).GetModuleQuantity();
|
|
int cNo = CurrentTrayNo;
|
|
|
|
((fmBMSMain)(Owner)).ScreenSaverTimeReset();
|
|
cNo += 1;
|
|
cNo %= mQty;
|
|
if ((cNo < 0) || (cNo >= 10)) cNo = 0;
|
|
CurrentTrayNo = cNo;
|
|
|
|
DisplayTrayMain(CurrentTrayNo, true);
|
|
DisplayTrayAlarmList(CurrentTrayNo, true);
|
|
DisplayTrayStatus(CurrentTrayNo, true);
|
|
}
|
|
|
|
private void btnLeft_Click(object sender, EventArgs e)
|
|
{
|
|
int mQty = ((fmBMSMain)(Owner)).GetModuleQuantity();
|
|
int cNo = CurrentTrayNo;
|
|
|
|
((fmBMSMain)(Owner)).ScreenSaverTimeReset();
|
|
if (cNo > 0)
|
|
cNo--;
|
|
else
|
|
cNo = mQty - 1;
|
|
|
|
if ((cNo < 0) || (cNo >= 10)) cNo = 0;
|
|
CurrentTrayNo = cNo;
|
|
|
|
DisplayTrayMain(CurrentTrayNo, true);
|
|
DisplayTrayAlarmList(CurrentTrayNo, true);
|
|
DisplayTrayStatus(CurrentTrayNo, true);
|
|
}
|
|
|
|
private void btnHistory_Click(object sender, EventArgs e)
|
|
{
|
|
((fmBMSMain)(Owner)).ScreenSaverTimeReset();
|
|
// Main 폼 표시 Index가 0이면 Main폼을 의미 합니다.
|
|
((fmBMSMain)(Owner)).sfmMain.Show(2);
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
} |