Initial commit
This commit is contained in:
383
BMS_D1000/Form/fmNetConfig.cs
Normal file
383
BMS_D1000/Form/fmNetConfig.cs
Normal file
@@ -0,0 +1,383 @@
|
||||
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 fmNetConfig : Form
|
||||
{
|
||||
SmartX.SmartLabel[] lbNetItem;
|
||||
SmartX.SmartLabel[] lbClassA;
|
||||
SmartX.SmartLabel[] lbClassB;
|
||||
SmartX.SmartLabel[] lbClassC;
|
||||
SmartX.SmartLabel[] lbClassD;
|
||||
SmartX.SmartButton[] btnSet;
|
||||
|
||||
DeviceNetConfig disNetConfig;
|
||||
|
||||
public fmNetConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
CreateComponent();
|
||||
|
||||
ResetControl();
|
||||
|
||||
tmrDisplay.Start();
|
||||
}
|
||||
|
||||
#region CREATE COMPONENT
|
||||
private void CreateComponent()
|
||||
{
|
||||
lbNetItem = new SmartX.SmartLabel[7];
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
lbNetItem[i] = new SmartX.SmartLabel();
|
||||
//lbNetItem[i].BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
|
||||
lbNetItem[i].BackPictureBox = null;
|
||||
lbNetItem[i].BackPictureBox1 = null;
|
||||
lbNetItem[i].BackPictureBox2 = null;
|
||||
lbNetItem[i].BorderColor = System.Drawing.Color.Black;
|
||||
lbNetItem[i].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
lbNetItem[i].Font = new System.Drawing.Font("Arial Black", 11F, System.Drawing.FontStyle.Bold);
|
||||
lbNetItem[i].InitVisible = true;
|
||||
lbNetItem[i].LineSpacing = 0F;
|
||||
lbNetItem[i].Location = new System.Drawing.Point(2, 91 + (i * 37));
|
||||
lbNetItem[i].Name = String.Format("NetConfig{0}", i);
|
||||
lbNetItem[i].Size = new System.Drawing.Size(249, 33);
|
||||
lbNetItem[i].TabIndex = 70;
|
||||
lbNetItem[i].Text = SetNetConfig.Name[i];
|
||||
lbNetItem[i].TextHAlign = SmartX.SmartLabel.TextHorAlign.Left;
|
||||
lbNetItem[i].TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle;
|
||||
lbNetItem[i].Wordwrap = false;
|
||||
}
|
||||
|
||||
lbClassA = new SmartX.SmartLabel[7];
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
lbClassA[i] = new SmartX.SmartLabel();
|
||||
//lbClassA[i].BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
|
||||
lbClassA[i].BackPictureBox = null;
|
||||
lbClassA[i].BackPictureBox1 = null;
|
||||
lbClassA[i].BackPictureBox2 = null;
|
||||
lbClassA[i].BorderColor = System.Drawing.Color.Black;
|
||||
lbClassA[i].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
lbClassA[i].Font = new System.Drawing.Font("Arial Black", 11F, System.Drawing.FontStyle.Bold);
|
||||
lbClassA[i].InitVisible = true;
|
||||
lbClassA[i].LineSpacing = 0F;
|
||||
lbClassA[i].Location = new System.Drawing.Point(254, 91 + (i * 37));
|
||||
lbClassA[i].Name = String.Format("NetConfigClassA{0}", i);
|
||||
lbClassA[i].Size = new System.Drawing.Size(100, 33);
|
||||
lbClassA[i].TabIndex = 70;
|
||||
lbClassA[i].Text = "0 ";
|
||||
lbClassA[i].TextHAlign = SmartX.SmartLabel.TextHorAlign.Right;
|
||||
lbClassA[i].TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle;
|
||||
lbClassA[i].Wordwrap = false;
|
||||
}
|
||||
|
||||
lbClassB = new SmartX.SmartLabel[7];
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
lbClassB[i] = new SmartX.SmartLabel();
|
||||
//lbClassB[i].BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
|
||||
lbClassB[i].BackPictureBox = null;
|
||||
lbClassB[i].BackPictureBox1 = null;
|
||||
lbClassB[i].BackPictureBox2 = null;
|
||||
lbClassB[i].BorderColor = System.Drawing.Color.Black;
|
||||
lbClassB[i].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
lbClassB[i].Font = new System.Drawing.Font("Arial Black", 11F, System.Drawing.FontStyle.Bold);
|
||||
lbClassB[i].InitVisible = true;
|
||||
lbClassB[i].LineSpacing = 0F;
|
||||
lbClassB[i].Location = new System.Drawing.Point(356, 91 + (i * 37));
|
||||
lbClassB[i].Name = String.Format("NetConfigClassB{0}", i);
|
||||
lbClassB[i].Size = new System.Drawing.Size(100, 33);
|
||||
lbClassB[i].TabIndex = 70;
|
||||
lbClassB[i].Text = "0 ";
|
||||
lbClassB[i].TextHAlign = SmartX.SmartLabel.TextHorAlign.Right;
|
||||
lbClassB[i].TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle;
|
||||
lbClassB[i].Wordwrap = false;
|
||||
}
|
||||
|
||||
lbClassC = new SmartX.SmartLabel[7];
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
lbClassC[i] = new SmartX.SmartLabel();
|
||||
//lbClassC[i].BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
|
||||
lbClassC[i].BackPictureBox = null;
|
||||
lbClassC[i].BackPictureBox1 = null;
|
||||
lbClassC[i].BackPictureBox2 = null;
|
||||
lbClassC[i].BorderColor = System.Drawing.Color.Black;
|
||||
lbClassC[i].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
lbClassC[i].Font = new System.Drawing.Font("Arial Black", 11F, System.Drawing.FontStyle.Bold);
|
||||
lbClassC[i].InitVisible = true;
|
||||
lbClassC[i].LineSpacing = 0F;
|
||||
lbClassC[i].Location = new System.Drawing.Point(458, 91 + (i * 37));
|
||||
lbClassC[i].Name = String.Format("NetConfigClassC{0}", i);
|
||||
lbClassC[i].Size = new System.Drawing.Size(100, 33);
|
||||
lbClassC[i].TabIndex = 70;
|
||||
lbClassC[i].Text = "0 ";
|
||||
lbClassC[i].TextHAlign = SmartX.SmartLabel.TextHorAlign.Right;
|
||||
lbClassC[i].TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle;
|
||||
lbClassC[i].Wordwrap = false;
|
||||
}
|
||||
|
||||
lbClassD = new SmartX.SmartLabel[7];
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
lbClassD[i] = new SmartX.SmartLabel();
|
||||
//lbClassD[i].BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
|
||||
lbClassD[i].BackPictureBox = null;
|
||||
lbClassD[i].BackPictureBox1 = null;
|
||||
lbClassD[i].BackPictureBox2 = null;
|
||||
lbClassD[i].BorderColor = System.Drawing.Color.Black;
|
||||
lbClassD[i].BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
lbClassD[i].Font = new System.Drawing.Font("Arial Black", 11F, System.Drawing.FontStyle.Bold);
|
||||
lbClassD[i].InitVisible = true;
|
||||
lbClassD[i].LineSpacing = 0F;
|
||||
lbClassD[i].Location = new System.Drawing.Point(560, 91 + (i * 37));
|
||||
lbClassD[i].Name = String.Format("NetConfigClassD{0}", i);
|
||||
lbClassD[i].Size = new System.Drawing.Size(100, 33);
|
||||
lbClassD[i].TabIndex = 70;
|
||||
lbClassD[i].Text = "0 ";
|
||||
lbClassD[i].TextHAlign = SmartX.SmartLabel.TextHorAlign.Right;
|
||||
lbClassD[i].TextVAlign = SmartX.SmartLabel.TextVerAlign.Middle;
|
||||
lbClassD[i].Wordwrap = false;
|
||||
}
|
||||
|
||||
btnSet = new SmartX.SmartButton[7];
|
||||
for (int i = 0; i < 7; 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, 91 + (i * 37));
|
||||
btnSet[i].Mode = SmartX.SmartButton.BUTTONMODE.NORMAL;
|
||||
btnSet[i].Name = "btnSet";
|
||||
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 = 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(NetConfigSetCmd_Click);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RESET CONTROL
|
||||
private void ResetControl()
|
||||
{
|
||||
this.SuspendLayout();
|
||||
this.Controls.Clear();
|
||||
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
this.Controls.Add(lbNetItem[i]);
|
||||
this.Controls.Add(lbClassA[i]);
|
||||
this.Controls.Add(lbClassB[i]);
|
||||
this.Controls.Add(lbClassC[i]);
|
||||
this.Controls.Add(lbClassD[i]);
|
||||
this.Controls.Add(btnSet[i]);
|
||||
}
|
||||
|
||||
this.Controls.Add(this.lbHdClassD);
|
||||
this.Controls.Add(this.lbHdSetting);
|
||||
this.Controls.Add(this.lbHdNetConfigName);
|
||||
this.Controls.Add(this.lbHdClassC);
|
||||
this.Controls.Add(this.lbHdClassB);
|
||||
this.Controls.Add(this.lnHdClassA);
|
||||
this.Controls.Add(this.btnReset);
|
||||
this.Controls.Add(this.btnMenu);
|
||||
this.Controls.Add(this.lbNetConfig);
|
||||
this.Controls.Add(this.sfmNetConfig);
|
||||
|
||||
this.ResumeLayout(false);
|
||||
|
||||
disNetConfig.ip_addr = new ClassAddr();
|
||||
disNetConfig.ip_addr.addr = new short[4];
|
||||
disNetConfig.subnet_mask = new ClassAddr();
|
||||
disNetConfig.subnet_mask.addr = new short[4];
|
||||
disNetConfig.gateway_addr = new ClassAddr();
|
||||
disNetConfig.gateway_addr.addr = new short[4];
|
||||
|
||||
disNetConfig.trap = new ClassAddr[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
disNetConfig.trap[i] = new ClassAddr();
|
||||
disNetConfig.trap[i].addr = new short[4];
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void fmNetConfig_Activated(object sender, EventArgs e)
|
||||
{
|
||||
DisplayNetConfig(true);
|
||||
}
|
||||
|
||||
private void NetConfigSetCmd_Click(object sender, EventArgs e)
|
||||
{
|
||||
int i = ((SmartX.SmartButton)(sender)).TabIndex;
|
||||
|
||||
((fmBMSMain)(Owner)).ScreenSaverTimeReset();
|
||||
((fmBMSMain)(Owner)).chfNetConfigCmd.SetID = i;
|
||||
|
||||
((fmBMSMain)(Owner)).ChangeScreen(0, 0, ScreenID.NET_CONFIG_CMD_SCREEN_ID);
|
||||
}
|
||||
|
||||
private void btnMenu_Click(object sender, EventArgs e)
|
||||
{
|
||||
((fmBMSMain)(Owner)).ChangeScreen(0, 0, ScreenID.SET_MENU_SCREEN_ID);
|
||||
}
|
||||
|
||||
#region DISPLAY NET CONFIG
|
||||
private void DisplayNetConfig(bool p)
|
||||
{
|
||||
int i;
|
||||
DeviceNetConfig aNetConfig;
|
||||
|
||||
aNetConfig = ((fmBMSMain)(Owner)).GetNetConfigData();
|
||||
|
||||
if (aNetConfig.ip_addr.addr == null) return;
|
||||
|
||||
// IP Address Display
|
||||
i = 0;
|
||||
if (p || (disNetConfig.ip_addr.addr[0] != aNetConfig.ip_addr.addr[0]) ||
|
||||
(disNetConfig.ip_addr.addr[1] != aNetConfig.ip_addr.addr[1]) ||
|
||||
(disNetConfig.ip_addr.addr[2] != aNetConfig.ip_addr.addr[2]) ||
|
||||
(disNetConfig.ip_addr.addr[3] != aNetConfig.ip_addr.addr[3]))
|
||||
{
|
||||
lbClassA[i].Text = String.Format("{0} ", aNetConfig.ip_addr.addr[0]);
|
||||
lbClassB[i].Text = String.Format("{0} ", aNetConfig.ip_addr.addr[1]);
|
||||
lbClassC[i].Text = String.Format("{0} ", aNetConfig.ip_addr.addr[2]);
|
||||
lbClassD[i].Text = String.Format("{0} ", aNetConfig.ip_addr.addr[3]);
|
||||
|
||||
disNetConfig.ip_addr.addr = aNetConfig.ip_addr.addr;
|
||||
}
|
||||
// Subnet Display
|
||||
i = 1;
|
||||
if (p || (disNetConfig.subnet_mask.addr[0] != aNetConfig.subnet_mask.addr[0]) ||
|
||||
(disNetConfig.subnet_mask.addr[1] != aNetConfig.subnet_mask.addr[1]) ||
|
||||
(disNetConfig.subnet_mask.addr[2] != aNetConfig.subnet_mask.addr[2]) ||
|
||||
(disNetConfig.subnet_mask.addr[3] != aNetConfig.subnet_mask.addr[3]))
|
||||
{
|
||||
lbClassA[i].Text = String.Format("{0} ", aNetConfig.subnet_mask.addr[0]);
|
||||
lbClassB[i].Text = String.Format("{0} ", aNetConfig.subnet_mask.addr[1]);
|
||||
lbClassC[i].Text = String.Format("{0} ", aNetConfig.subnet_mask.addr[2]);
|
||||
lbClassD[i].Text = String.Format("{0} ", aNetConfig.subnet_mask.addr[3]);
|
||||
|
||||
disNetConfig.subnet_mask.addr = aNetConfig.subnet_mask.addr;
|
||||
}
|
||||
// Gateway Display
|
||||
i = 2;
|
||||
if (p || (disNetConfig.gateway_addr.addr[0] != aNetConfig.gateway_addr.addr[0]) ||
|
||||
(disNetConfig.gateway_addr.addr[1] != aNetConfig.gateway_addr.addr[1]) ||
|
||||
(disNetConfig.gateway_addr.addr[2] != aNetConfig.gateway_addr.addr[2]) ||
|
||||
(disNetConfig.gateway_addr.addr[3] != aNetConfig.gateway_addr.addr[3]))
|
||||
{
|
||||
lbClassA[i].Text = String.Format("{0} ", aNetConfig.gateway_addr.addr[0]);
|
||||
lbClassB[i].Text = String.Format("{0} ", aNetConfig.gateway_addr.addr[1]);
|
||||
lbClassC[i].Text = String.Format("{0} ", aNetConfig.gateway_addr.addr[2]);
|
||||
lbClassD[i].Text = String.Format("{0} ", aNetConfig.gateway_addr.addr[3]);
|
||||
|
||||
disNetConfig.gateway_addr.addr = aNetConfig.gateway_addr.addr;
|
||||
}
|
||||
// Trap #1 Display
|
||||
i = 3;
|
||||
if (p || (disNetConfig.trap[0].addr[0] != aNetConfig.trap[0].addr[0]) ||
|
||||
(disNetConfig.trap[0].addr[1] != aNetConfig.trap[0].addr[1]) ||
|
||||
(disNetConfig.trap[0].addr[2] != aNetConfig.trap[0].addr[2]) ||
|
||||
(disNetConfig.trap[0].addr[3] != aNetConfig.trap[0].addr[3]))
|
||||
{
|
||||
lbClassA[i].Text = String.Format("{0} ", aNetConfig.trap[0].addr[0]);
|
||||
lbClassB[i].Text = String.Format("{0} ", aNetConfig.trap[0].addr[1]);
|
||||
lbClassC[i].Text = String.Format("{0} ", aNetConfig.trap[0].addr[2]);
|
||||
lbClassD[i].Text = String.Format("{0} ", aNetConfig.trap[0].addr[3]);
|
||||
|
||||
disNetConfig.trap[0].addr = aNetConfig.trap[0].addr;
|
||||
}
|
||||
// Trap #2 Display
|
||||
i = 4;
|
||||
if (p || (disNetConfig.trap[1].addr[0] != aNetConfig.trap[1].addr[0]) ||
|
||||
(disNetConfig.trap[1].addr[1] != aNetConfig.trap[1].addr[1]) ||
|
||||
(disNetConfig.trap[1].addr[2] != aNetConfig.trap[1].addr[2]) ||
|
||||
(disNetConfig.trap[1].addr[3] != aNetConfig.trap[1].addr[3]))
|
||||
{
|
||||
lbClassA[i].Text = String.Format("{0} ", aNetConfig.trap[1].addr[0]);
|
||||
lbClassB[i].Text = String.Format("{0} ", aNetConfig.trap[1].addr[1]);
|
||||
lbClassC[i].Text = String.Format("{0} ", aNetConfig.trap[1].addr[2]);
|
||||
lbClassD[i].Text = String.Format("{0} ", aNetConfig.trap[1].addr[3]);
|
||||
|
||||
disNetConfig.trap[1].addr = aNetConfig.trap[1].addr;
|
||||
}
|
||||
// Trap #3 Display
|
||||
i = 5;
|
||||
if (p || (disNetConfig.trap[2].addr[0] != aNetConfig.trap[2].addr[0]) ||
|
||||
(disNetConfig.trap[2].addr[1] != aNetConfig.trap[2].addr[1]) ||
|
||||
(disNetConfig.trap[2].addr[2] != aNetConfig.trap[2].addr[2]) ||
|
||||
(disNetConfig.trap[2].addr[3] != aNetConfig.trap[2].addr[3]))
|
||||
{
|
||||
lbClassA[i].Text = String.Format("{0} ", aNetConfig.trap[2].addr[0]);
|
||||
lbClassB[i].Text = String.Format("{0} ", aNetConfig.trap[2].addr[1]);
|
||||
lbClassC[i].Text = String.Format("{0} ", aNetConfig.trap[2].addr[2]);
|
||||
lbClassD[i].Text = String.Format("{0} ", aNetConfig.trap[2].addr[3]);
|
||||
|
||||
disNetConfig.trap[2].addr = aNetConfig.trap[2].addr;
|
||||
}
|
||||
// Trap #4 Display
|
||||
i = 6;
|
||||
if (p || (disNetConfig.trap[3].addr[0] != aNetConfig.trap[3].addr[0]) ||
|
||||
(disNetConfig.trap[3].addr[1] != aNetConfig.trap[3].addr[1]) ||
|
||||
(disNetConfig.trap[3].addr[2] != aNetConfig.trap[3].addr[2]) ||
|
||||
(disNetConfig.trap[3].addr[3] != aNetConfig.trap[3].addr[3]))
|
||||
{
|
||||
lbClassA[i].Text = String.Format("{0} ", aNetConfig.trap[3].addr[0]);
|
||||
lbClassB[i].Text = String.Format("{0} ", aNetConfig.trap[3].addr[1]);
|
||||
lbClassC[i].Text = String.Format("{0} ", aNetConfig.trap[3].addr[2]);
|
||||
lbClassD[i].Text = String.Format("{0} ", aNetConfig.trap[3].addr[3]);
|
||||
|
||||
disNetConfig.trap[3].addr = aNetConfig.trap[3].addr;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void tmrDisplay_Tick(object sender, EventArgs e)
|
||||
{
|
||||
DisplayNetConfig(false);
|
||||
}
|
||||
|
||||
private void btnReset_Click(object sender, EventArgs e)
|
||||
{
|
||||
((fmBMSMain)(Owner)).ScreenSaverTimeReset();
|
||||
|
||||
ushort Reg_Addr = 0x9000;
|
||||
short Reg_Count = 1;
|
||||
short[] Reg_Data = new short[1];
|
||||
|
||||
((fmBMSMain)(Owner)).SetModBusWriteCmd(1, (short)Reg_Addr, Reg_Count, Reg_Data, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user