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 fmParamSet : Form { SmartX.SmartLabel[] lbParamName; SmartX.SmartLabel[] lbProtection; SmartX.SmartLabel[] lbWarning; SmartX.SmartLabel[] lbRecovery; SmartX.SmartButton[] btnSet; DeviceParam disTrayParam; int CloseTimeCount = 0; int CloseClickCount = 0; public fmParamSet() { InitializeComponent(); CreateComponent(); ResetControl(); lbHdSetting.Visible = false; btnParamInit.Visible = false; btnSetA.Visible = false; } #region CREATE COMPONENT private void CreateComponent() { lbParamName = new SmartX.SmartLabel[9]; for (int i = 0; i < 9; i++) { lbParamName[i] = new SmartX.SmartLabel(); //lbParamName[i].BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(192)))), ((int)(((byte)(255))))); lbParamName[i].BackPictureBox = null; lbParamName[i].BackPictureBox1 = null; lbParamName[i].BackPictureBox2 = null; lbParamName[i].BorderColor = System.Drawing.Color.Black; lbParamName[i].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; lbParamName[i].Font = new System.Drawing.Font("Arial Black", 11F, System.Drawing.FontStyle.Bold); lbParamName[i].InitVisible = true; lbParamName[i].LineSpacing = 0F; lbParamName[i].Location = new System.Drawing.Point(3, 92 + (i * 37)); lbParamName[i].Name = String.Format("ParamName{0}", i); lbParamName[i].Size = new System.Drawing.Size(281, 35); lbParamName[i].TabIndex = 70; lbParamName[i].Text = SetParamter.Name[i]; lbParamName[i].TextHAlign = SmartX.SmartLabel.TextHorAlign.Left; lbParamName[i].TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle; lbParamName[i].Wordwrap = false; } lbProtection = new SmartX.SmartLabel[9]; for (int i = 0; i < 9; i++) { lbProtection[i] = new SmartX.SmartLabel(); //lbProtection[i].BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(192)))), ((int)(((byte)(255))))); lbProtection[i].BackPictureBox = null; lbProtection[i].BackPictureBox1 = null; lbProtection[i].BackPictureBox2 = null; lbProtection[i].BorderColor = System.Drawing.Color.Black; lbProtection[i].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; lbProtection[i].Font = new System.Drawing.Font("Arial Black", 11F, System.Drawing.FontStyle.Bold); lbProtection[i].InitVisible = true; lbProtection[i].LineSpacing = 0F; lbProtection[i].Location = new System.Drawing.Point(286, 92 + (i * 37)); lbProtection[i].Name = String.Format("ParamProtection{0}", i); lbProtection[i].Size = new System.Drawing.Size(123, 35); lbProtection[i].TabIndex = 70; lbProtection[i].Text = "0.0 "; lbProtection[i].TextHAlign = SmartX.SmartLabel.TextHorAlign.Right; lbProtection[i].TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle; lbProtection[i].Wordwrap = false; } lbWarning = new SmartX.SmartLabel[9]; for (int i = 0; i < 9; i++) { lbWarning[i] = new SmartX.SmartLabel(); //lbWarning[i].BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(192)))), ((int)(((byte)(255))))); lbWarning[i].BackPictureBox = null; lbWarning[i].BackPictureBox1 = null; lbWarning[i].BackPictureBox2 = null; lbWarning[i].BorderColor = System.Drawing.Color.Black; lbWarning[i].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; lbWarning[i].Font = new System.Drawing.Font("Arial Black", 11F, System.Drawing.FontStyle.Bold); lbWarning[i].InitVisible = true; lbWarning[i].LineSpacing = 0F; lbWarning[i].Location = new System.Drawing.Point(411, 92 + (i * 37)); lbWarning[i].Name = String.Format("ParamWarning{0}", i); lbWarning[i].Size = new System.Drawing.Size(123, 35); lbWarning[i].TabIndex = 70; lbWarning[i].Text = "0.0 "; lbWarning[i].TextHAlign = SmartX.SmartLabel.TextHorAlign.Right; lbWarning[i].TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle; lbWarning[i].Wordwrap = false; } lbRecovery = new SmartX.SmartLabel[9]; for (int i = 0; i < 9; i++) { lbRecovery[i] = new SmartX.SmartLabel(); //lbRecovery[i].BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(192)))), ((int)(((byte)(255))))); lbRecovery[i].BackPictureBox = null; lbRecovery[i].BackPictureBox1 = null; lbRecovery[i].BackPictureBox2 = null; lbRecovery[i].BorderColor = System.Drawing.Color.Black; lbRecovery[i].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; lbRecovery[i].Font = new System.Drawing.Font("Arial Black", 11F, System.Drawing.FontStyle.Bold); lbRecovery[i].InitVisible = true; lbRecovery[i].LineSpacing = 0F; lbRecovery[i].Location = new System.Drawing.Point(536, 92 + (i * 37)); lbRecovery[i].Name = String.Format("ParamRecovery{0}", i); lbRecovery[i].Size = new System.Drawing.Size(123, 35); lbRecovery[i].TabIndex = 70; lbRecovery[i].Text = "0.0 "; lbRecovery[i].TextHAlign = SmartX.SmartLabel.TextHorAlign.Right; lbRecovery[i].TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle; lbRecovery[i].Wordwrap = false; } btnSet = new SmartX.SmartButton[9]; for (int i = 0; i < 9; i++) { btnSet[i] = new SmartX.SmartButton(); btnSet[i].BackPictureBox = null; btnSet[i].BackPictureBox1 = null; btnSet[i].BackPictureBox2 = null; btnSet[i].ButtonColor = System.Drawing.Color.Gray; btnSet[i].ButtonImageAutoSize = true; btnSet[i].ColorKeySamplePosition = new System.Drawing.Point(0, 0); btnSet[i].DisableImage = null; btnSet[i].DownImage = btnSetA.DownImage; btnSet[i].Font = new System.Drawing.Font("Arial Black", 12F, System.Drawing.FontStyle.Bold); btnSet[i].GroupID = 0; btnSet[i].InitVisible = true; btnSet[i].Location = new System.Drawing.Point(662, 92 + (i * 37)); btnSet[i].Mode = SmartX.SmartButton.BUTTONMODE.NORMAL; btnSet[i].Name = "btnSetA"; btnSet[i].NestedClickEventPrevent = false; btnSet[i].RepeatInterval = 1000; btnSet[i].SafeInterval = 200; btnSet[i].Size = new System.Drawing.Size(135, 33); btnSet[i].SpecialFunction = SmartX.SmartButton.SPECIALFUNC.NONE; btnSet[i].TabIndex = 1 + i; btnSet[i].Text = "SET"; btnSet[i].TextColor = System.Drawing.Color.Black; btnSet[i].TextDownColor = System.Drawing.Color.White; btnSet[i].TextHAlign = SmartX.SmartButton.TextHorAlign.Middle; btnSet[i].TextLocation = new System.Drawing.Point(0, 0); btnSet[i].TextVAlign = SmartX.SmartButton.TextVerAlign.Middle; btnSet[i].UpImage = btnSetA.UpImage; btnSet[i].Click += new System.EventHandler(ParamSetCmd_Click); btnSet[i].Visible = false; } } #endregion private void ResetControl() { this.SuspendLayout(); this.Controls.Clear(); for (int i = 0; i < 9; i++) { this.Controls.Add(lbParamName[i]); if ((i != 8) && (i != 7) && (i != 5) && (i != 3) && (i != 2)) this.Controls.Add(lbProtection[i]); this.Controls.Add(lbWarning[i]); this.Controls.Add(lbRecovery[i]); //this.Controls.Add(btnSet[i]); } this.Controls.Add(this.lbExit); this.Controls.Add(this.cbLogTime); this.Controls.Add(this.cbLog); //this.Controls.Add(this.btnParamInit); //this.Controls.Add(this.lbHdSetting); this.Controls.Add(this.lbHdRecovery); this.Controls.Add(this.lbHdWarning); this.Controls.Add(this.lnHdPrtection); this.Controls.Add(this.lbHdParamName); this.Controls.Add(this.lbParamInfo); this.Controls.Add(this.btnMenu); this.Controls.Add(this.smartForm1); this.ResumeLayout(false); } private void btnMain_Click(object sender, EventArgs e) { ((fmBMSMain)(Owner)).ChangeScreen(0, 0, ScreenID.SET_MENU_SCREEN_ID); } private void tmrDisplay_Tick(object sender, EventArgs e) { DisplayParam(false); } private void DisplayParam(bool p) { int aParam, i; DeviceDataSystem aBMSData; aBMSData = ((fmBMSMain)(Owner)).GetBmsSystemData(); // SOV Parameter display i = 0; if (p || (disTrayParam.voltage.SOV_Threshold != aBMSData.param.voltage.SOV_Threshold)) { aParam = aBMSData.param.voltage.SOV_Threshold; lbProtection[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 1); disTrayParam.voltage.SOV_Threshold = aBMSData.param.voltage.SOV_Threshold; } if (p || (disTrayParam.voltage.SOV_Warning != aBMSData.param.voltage.SOV_Warning)) { aParam = aBMSData.param.voltage.SOV_Warning; lbWarning[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 1); disTrayParam.voltage.SOV_Warning = aBMSData.param.voltage.SOV_Warning; } if (p || (disTrayParam.voltage.SOV_Recovery != aBMSData.param.voltage.SOV_Recovery)) { aParam = aBMSData.param.voltage.SOV_Recovery; lbRecovery[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 1); disTrayParam.voltage.SOV_Recovery = aBMSData.param.voltage.SOV_Recovery; } // COV Parameter display i = 1; if (p || (disTrayParam.voltage.COV_Threshold != aBMSData.param.voltage.COV_Threshold)) { aParam = aBMSData.param.voltage.COV_Threshold; lbProtection[i].Text = String.Format("{0:#0.000} ", Convert.ToDouble(aParam) / 1000); disTrayParam.voltage.COV_Threshold = aBMSData.param.voltage.COV_Threshold; } if (p || (disTrayParam.voltage.COV_Warning != aBMSData.param.voltage.COV_Warning)) { aParam = aBMSData.param.voltage.COV_Warning; lbWarning[i].Text = String.Format("{0:#0.000} ", Convert.ToDouble(aParam) / 1000); disTrayParam.voltage.COV_Warning = aBMSData.param.voltage.COV_Warning; } if (p || (disTrayParam.voltage.COV_Recovery != aBMSData.param.voltage.COV_Recovery)) { aParam = aBMSData.param.voltage.COV_Recovery; lbRecovery[i].Text = String.Format("{0:#0.000} ", Convert.ToDouble(aParam) / 1000); disTrayParam.voltage.COV_Recovery = aBMSData.param.voltage.COV_Recovery; } // SUV Parameter display i = 2; if (p || (disTrayParam.voltage.SUV_Threshold != aBMSData.param.voltage.SUV_Threshold)) { aParam = aBMSData.param.voltage.SUV_Threshold; lbProtection[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 1); disTrayParam.voltage.SUV_Threshold = aBMSData.param.voltage.SUV_Threshold; } if (p || (disTrayParam.voltage.SUV_Warning != aBMSData.param.voltage.SUV_Warning)) { aParam = aBMSData.param.voltage.SUV_Warning; lbWarning[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 1); disTrayParam.voltage.SUV_Warning = aBMSData.param.voltage.SUV_Warning; } if (p || (disTrayParam.voltage.SUV_Recovery != aBMSData.param.voltage.SUV_Recovery)) { aParam = aBMSData.param.voltage.SUV_Recovery; lbRecovery[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 1); disTrayParam.voltage.SUV_Recovery = aBMSData.param.voltage.SUV_Recovery; } // CUV Parameter display i = 3; if (p || (disTrayParam.voltage.CUV_Threshold != aBMSData.param.voltage.CUV_Threshold)) { aParam = aBMSData.param.voltage.CUV_Threshold; lbProtection[i].Text = String.Format("{0:#0.000} ", Convert.ToDouble(aParam) / 1000); disTrayParam.voltage.CUV_Threshold = aBMSData.param.voltage.CUV_Threshold; } if (p || (disTrayParam.voltage.CUV_Warning != aBMSData.param.voltage.CUV_Warning)) { aParam = aBMSData.param.voltage.CUV_Warning; lbWarning[i].Text = String.Format("{0:#0.000} ", Convert.ToDouble(aParam) / 1000); disTrayParam.voltage.CUV_Warning = aBMSData.param.voltage.CUV_Warning; } if (p || (disTrayParam.voltage.CUV_Recovery != aBMSData.param.voltage.CUV_Recovery)) { aParam = aBMSData.param.voltage.CUV_Recovery; lbRecovery[i].Text = String.Format("{0:#0.000} ", Convert.ToDouble(aParam) / 1000); disTrayParam.voltage.CUV_Recovery = aBMSData.param.voltage.CUV_Recovery; } // OC Charge Parameter display i = 4; if (p || (disTrayParam.current.OC_Chg_Threshold != aBMSData.param.current.OC_Chg_Threshold)) { aParam = aBMSData.param.current.OC_Chg_Threshold; lbProtection[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 1); disTrayParam.current.OC_Chg_Threshold = aBMSData.param.current.OC_Chg_Threshold; } if (p || (disTrayParam.current.OC_Chg_Warning != aBMSData.param.current.OC_Chg_Warning)) { aParam = aBMSData.param.current.OC_Chg_Warning; lbWarning[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 1); disTrayParam.current.OC_Chg_Warning = aBMSData.param.current.OC_Chg_Warning; } if (p || (disTrayParam.current.OC_Chg_Recovery != aBMSData.param.current.OC_Chg_Recovery)) { aParam = aBMSData.param.current.OC_Chg_Recovery; lbRecovery[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 1); disTrayParam.current.OC_Chg_Recovery = aBMSData.param.current.OC_Chg_Recovery; } // OC Discharge Parameter display i = 5; if (p || (disTrayParam.current.OC_Dsg_Threshold != aBMSData.param.current.OC_Dsg_Threshold)) { aParam = aBMSData.param.current.OC_Dsg_Threshold; lbProtection[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 1); disTrayParam.current.OC_Dsg_Threshold = aBMSData.param.current.OC_Dsg_Threshold; } if (p || (disTrayParam.current.OC_Dsg_Warning != aBMSData.param.current.OC_Dsg_Warning)) { aParam = aBMSData.param.current.OC_Dsg_Warning; lbWarning[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 1); disTrayParam.current.OC_Dsg_Warning = aBMSData.param.current.OC_Dsg_Warning; } if (p || (disTrayParam.current.OC_Dsg_Recovery != aBMSData.param.current.OC_Dsg_Recovery)) { aParam = aBMSData.param.current.OC_Dsg_Recovery; lbRecovery[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 1); disTrayParam.current.OC_Dsg_Recovery = aBMSData.param.current.OC_Dsg_Recovery; } // OT Charge Parameter display i = 6; if (p || (disTrayParam.temperature.OT_Chg_Threshold != aBMSData.param.temperature.OT_Chg_Threshold)) { aParam = aBMSData.param.temperature.OT_Chg_Threshold; lbProtection[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 10); disTrayParam.temperature.OT_Chg_Threshold = aBMSData.param.temperature.OT_Chg_Threshold; } if (p || (disTrayParam.temperature.OT_Chg_Warning != aBMSData.param.temperature.OT_Chg_Warning)) { aParam = aBMSData.param.temperature.OT_Chg_Warning; lbWarning[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 10); disTrayParam.temperature.OT_Chg_Warning = aBMSData.param.temperature.OT_Chg_Warning; } if (p || (disTrayParam.temperature.OT_Chg_Recovery != aBMSData.param.temperature.OT_Chg_Recovery)) { aParam = aBMSData.param.temperature.OT_Chg_Recovery; lbRecovery[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 10); disTrayParam.temperature.OT_Chg_Recovery = aBMSData.param.temperature.OT_Chg_Recovery; } // OT Discharge Parameter display i = 7; if (p || (disTrayParam.temperature.OT_Dsg_Threshold != aBMSData.param.temperature.OT_Dsg_Threshold)) { aParam = aBMSData.param.temperature.OT_Dsg_Threshold; lbProtection[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 10); disTrayParam.temperature.OT_Dsg_Threshold = aBMSData.param.temperature.OT_Dsg_Threshold; } if (p || (disTrayParam.temperature.OT_Dsg_Warning != aBMSData.param.temperature.OT_Dsg_Warning)) { aParam = aBMSData.param.temperature.OT_Dsg_Warning; lbWarning[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 10); disTrayParam.temperature.OT_Dsg_Warning = aBMSData.param.temperature.OT_Dsg_Warning; } if (p || (disTrayParam.temperature.OT_Dsg_Recovery != aBMSData.param.temperature.OT_Dsg_Recovery)) { aParam = aBMSData.param.temperature.OT_Dsg_Recovery; lbRecovery[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 10); disTrayParam.temperature.OT_Dsg_Recovery = aBMSData.param.temperature.OT_Dsg_Recovery; } // SOC Parameter display i = 8; if (p || (disTrayParam.soc.Low_SOC_Warning != aBMSData.param.soc.Low_SOC_Warning)) { aParam = aBMSData.param.soc.Low_SOC_Warning; lbWarning[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 1); disTrayParam.soc.Low_SOC_Warning = aBMSData.param.soc.Low_SOC_Warning; } if (p || (disTrayParam.soc.Low_SOC_Recovery != aBMSData.param.soc.Low_SOC_Recovery)) { aParam = aBMSData.param.soc.Low_SOC_Recovery; lbRecovery[i].Text = String.Format("{0:#0} ", Convert.ToDouble(aParam) / 1); disTrayParam.soc.Low_SOC_Recovery = aBMSData.param.soc.Low_SOC_Recovery; } } private void fmParamSet_Load(object sender, EventArgs e) { cbLogTime.Text = "60"; tmrDisplay.Start(); tmrClose.Start(); } private void fmParamSet_Activated(object sender, EventArgs e) { DisplayParam(true); } private void ParamSetCmd_Click(object sender, EventArgs e) { int i = ((SmartX.SmartButton)(sender)).TabIndex; ((fmBMSMain)(Owner)).ScreenSaverTimeReset(); ((fmBMSMain)(Owner)).chfParamSetCmd.SetID = i; ((fmBMSMain)(Owner)).sfmMain.Show(5); } private void btnParamInit_Click(object sender, EventArgs e) { short Reg_Addr = 0x4001; short Reg_Count = 2; short[] Reg_Data = new short[Reg_Count]; ((fmBMSMain)(Owner)).ScreenSaverTimeReset(); Reg_Data[0] = 1; Reg_Data[1] = 0; ((fmBMSMain)(Owner)).SetModBusWriteCmd(1, Reg_Addr, Reg_Count, Reg_Data, 0x4001); } private void cbLog_Click(object sender, EventArgs e) { if (cbLog.Checked == true) { cbLogTime.Enabled = false; } else { cbLogTime.Enabled = true; } } public bool GetLogFlag() { return cbLog.Checked; } public int GetLogTime() { return Convert.ToInt32(cbLogTime.Text); } private void lbExit_Click(object sender, EventArgs e) { CloseClickCount++; CloseTimeCount = 0; if (CloseClickCount >= 5) { CloseClickCount++; CloseTimeCount = 0; if (CloseClickCount >= 5) { ((fmBMSMain)(Owner)).ApplicationExit(); } } } private void tmrClose_Tick(object sender, EventArgs e) { if (CloseClickCount > 0) { CloseTimeCount++; if (CloseTimeCount > 20) { CloseClickCount = 0; } } } } }