diff --git a/Cs_HMI/Project/AGV4.csproj b/Cs_HMI/Project/AGV4.csproj index beb4b6d..4f340c6 100644 --- a/Cs_HMI/Project/AGV4.csproj +++ b/Cs_HMI/Project/AGV4.csproj @@ -466,9 +466,7 @@ Settings.settings True - - PreserveNewest - + diff --git a/Cs_HMI/Project/Dialog/fJobSelect.cs b/Cs_HMI/Project/Dialog/fJobSelect.cs index fa491e0..f5d22d3 100644 --- a/Cs_HMI/Project/Dialog/fJobSelect.cs +++ b/Cs_HMI/Project/Dialog/fJobSelect.cs @@ -51,7 +51,7 @@ namespace Project.Dialog e.SuppressKeyPress = false; DialogResult = DialogResult.Cancel; this.Close(); - } + } else if (e.KeyCode == Keys.F5) btYes.PerformClick(); } @@ -104,7 +104,7 @@ namespace Project.Dialog private void label1_MouseDoubleClick(object sender, MouseEventArgs e) { - + } public enum EWinColor @@ -149,8 +149,9 @@ namespace Project.Dialog { var bg1 = lbTitle.BackColor; var bg2 = lbTitle.BackColor2; - lbTitle.BackColor = bg2; - lbTitle.BackColor2 = bg1; + if (bg1 != null) lbTitle.BackColor2 = (Color)bg1; + if (bg2 != null) lbTitle.BackColor = (Color)bg2; + } private void btYes_Click(object sender, EventArgs e) @@ -161,8 +162,8 @@ namespace Project.Dialog private void btNo_Click(object sender, EventArgs e) { - DialogResult = DialogResult.Cancel; - this.Close(); + DialogResult = DialogResult.Cancel; + this.Close(); } } diff --git a/Cs_HMI/Project/Dialog/fUpdateForm.cs b/Cs_HMI/Project/Dialog/fUpdateForm.cs index f13e136..f4a59f4 100644 --- a/Cs_HMI/Project/Dialog/fUpdateForm.cs +++ b/Cs_HMI/Project/Dialog/fUpdateForm.cs @@ -185,8 +185,8 @@ namespace Project.Dialog { var bg1 = lbTitle.BackColor; var bg2 = lbTitle.BackColor2; - lbTitle.BackColor = bg2; - lbTitle.BackColor2 = bg1; + lbTitle.BackColor = (Color)bg2; + lbTitle.BackColor2 = (Color)bg1; } private void btYes_Click(object sender, EventArgs e) diff --git a/Cs_HMI/Project/MessageWindow/fMessageWindow.cs b/Cs_HMI/Project/MessageWindow/fMessageWindow.cs index 7befd3b..d0d64dc 100644 --- a/Cs_HMI/Project/MessageWindow/fMessageWindow.cs +++ b/Cs_HMI/Project/MessageWindow/fMessageWindow.cs @@ -179,8 +179,8 @@ namespace Project { var bg1 = lbTitle.BackColor; var bg2 = lbTitle.BackColor2; - lbTitle.BackColor = bg2; - lbTitle.BackColor2 = bg1; + lbTitle.BackColor = (Color)bg2; + lbTitle.BackColor2 = (Color)bg1; } private void btYes_Click(object sender, EventArgs e) diff --git a/Cs_HMI/Project/StateMachine/_AGV.cs b/Cs_HMI/Project/StateMachine/_AGV.cs index 440bab7..c7dc72b 100644 --- a/Cs_HMI/Project/StateMachine/_AGV.cs +++ b/Cs_HMI/Project/StateMachine/_AGV.cs @@ -35,59 +35,6 @@ namespace Project } } - //ePosition ParsePosition(uint tag, out string dirBW) - //{ - // var tagstr = tag.ToString(); - // var tagno = tagstr.Substring(0, tagstr.Length - 1); - - // if (tag == PUB.setting.TAGNOT) { dirBW = "0"; return ePosition.NOT; } - - // else if (tag == PUB.setting.TAG_QA_QC) { dirBW = "0"; return ePosition.QA_QC; } - // else if (tag == PUB.setting.TAG_QC_F1) { dirBW = "0"; return ePosition.QC_F1; } - // else if (tag == PUB.setting.TAG_F1_F2) { dirBW = "0"; return ePosition.F1_F2; } - // else if (tag == PUB.setting.TAG_F2_F3) { dirBW = "0"; return ePosition.F2_F3; } - // else if (tag == PUB.setting.TAG_F3_F4) { dirBW = "0"; return ePosition.F3_F4; } - // else if (tag == PUB.setting.TAG_F4_F5) { dirBW = "0"; return ePosition.F4_F5; } - - // else if (tag == PUB.setting.TAGQAB) { dirBW = "0"; return ePosition.QA; } - // else if (tag == PUB.setting.TAGQCB) { dirBW = "0"; return ePosition.QC; } - // else if (tag == PUB.setting.TAGF1B) { dirBW = "0"; return ePosition.F1; } - // else if (tag == PUB.setting.TAGF2B) { dirBW = "0"; return ePosition.F2; } - // else if (tag == PUB.setting.TAGF3B) { dirBW = "0"; return ePosition.F3; } - // else if (tag == PUB.setting.TAGF4B) { dirBW = "0"; return ePosition.F4; } - // else if (tag == PUB.setting.TAGF5B) { dirBW = "0"; return ePosition.F5; } - // //else if (tag == PUB.setting.TAGQAA) { dirBW = "1"; return ePosition.QA; } - // //else if (tag == PUB.setting.TAGCHA) { dirBW = "1"; return ePosition.CHARGE; } - // else if (tag == PUB.setting.TAGQAA) { dirBW = "1"; return ePosition.QA; } - // else if (tag == PUB.setting.TAGQCA) { dirBW = "1"; return ePosition.QC; } - // else if (tag == PUB.setting.TAGF1A) { dirBW = "1"; return ePosition.F1; } - // else if (tag == PUB.setting.TAGF2A) { dirBW = "1"; return ePosition.F2; } - // else if (tag == PUB.setting.TAGF3A) { dirBW = "1"; return ePosition.F3; } - // else if (tag == PUB.setting.TAGF4A) { dirBW = "1"; return ePosition.F4; } - // else if (tag == PUB.setting.TAGF5A) { dirBW = "1"; return ePosition.F5; } - // else if (tag == PUB.setting.TAGPOT) { dirBW = "0"; return ePosition.POT; } - // else - // { - // if (tag > 9350 && tag < 9400) - // { - // dirBW = "0"; return ePosition.QC_F1; - // } - // else if (tag > 9250 && tag < 9300) - // { - // dirBW = "0"; return ePosition.QA_QC; - // } - // else if (tag > 9000 && tag < 9100) - // { - // dirBW = "0"; return ePosition.NOT; - // } - // else - // { - // dirBW = "0"; return ePosition.NONE; - // } - - // } - //} - bool _charging = false; private void AGV_DataReceive(object sender, arDev.Narumi.DataEventArgs e) @@ -107,6 +54,11 @@ namespace Project VAR.BOOL[eVarBool.AGV_ERROR] = PUB.AGV.error.Value > 0; VAR.BOOL[eVarBool.EMERGENCY] = PUB.AGV.error.Emergency; + if (PUB.AGV.data.Direction =='B') + PUB.mapctl.agv.CurrentDirection = AGVControl.Models.Direction.Backward; + else + PUB.mapctl.agv.CurrentDirection = AGVControl.Models.Direction.Forward; + if (PUB.AGV.signal.mark_sensor == false) { if (VAR.BOOL[eVarBool.MARK_SENSOROFF] == false) diff --git a/Cs_HMI/Project/StateMachine/_BMS.cs b/Cs_HMI/Project/StateMachine/_BMS.cs index ec85211..ed17150 100644 --- a/Cs_HMI/Project/StateMachine/_BMS.cs +++ b/Cs_HMI/Project/StateMachine/_BMS.cs @@ -25,7 +25,7 @@ namespace Project DateTime lastbmstime = DateTime.Now; private void Bms_Message(object sender, arDev.BMS.MessageEventArgs e) { - if (e.MsgType == arDev.arRS232.MessageType.Error) PUB.logbms.AddE( e.Message); + if (e.MsgType == arRS232.MessageType.Error) PUB.logbms.AddE( e.Message); else { var hexstr = e.Data.GetHexString().Trim(); diff --git a/Cs_HMI/Project/StateMachine/_SPS.cs b/Cs_HMI/Project/StateMachine/_SPS.cs index ef6bb8a..ab2f615 100644 --- a/Cs_HMI/Project/StateMachine/_SPS.cs +++ b/Cs_HMI/Project/StateMachine/_SPS.cs @@ -98,7 +98,7 @@ namespace Project { if (PUB.sm.Step < eSMStep.IDLE || PUB.sm.Step >= eSMStep.CLOSING) return; - + //agv connect ConnectSerialPort(PUB.AGV, PUB.setting.Port_AGV, PUB.setting.Baud_AGV, eVarTime.LastConn_AGV, eVarTime.LastConnTry_AGV, eVarTime.LastRecv_AGV); @@ -108,8 +108,18 @@ namespace Project eVarTime.LastConn_XBE, eVarTime.LastConnTry_XBE, eVarTime.LastRecv_XBE); //bms connect - ConnectSerialPort(PUB.BMS, PUB.setting.Port_BAT, PUB.setting.Baud_BAT, - eVarTime.LastConn_BAT, eVarTime.LastConnTry_BAT, eVarTime.LastRecv_BAT); + if (PUB.BMS.IsOpen == false) + { + var ts = VAR.TIME.RUN(eVarTime.LastConn_BAT); + if (ts.TotalSeconds > 3) + { + PUB.BMS.PortName = PUB.setting.Port_BAT; + PUB.BMS.Open(); + VAR.TIME.Update(eVarTime.LastConn_BAT); + } + } + //ConnectSerialPort(PUB.BMS, PUB.setting.Port_BAT, PUB.setting.Baud_BAT, + // eVarTime.LastConn_BAT, eVarTime.LastConnTry_BAT, eVarTime.LastRecv_BAT); //지그비상태전송 if (PUB.XBE != null && PUB.XBE.IsOpen) @@ -133,9 +143,9 @@ namespace Project PUB.BMS.SendQuery(); } - - Update_BatteryWarnSpeak(); - + + Update_BatteryWarnSpeak(); + } } } diff --git a/Cs_HMI/Project/StateMachine/_TMDisplay.cs b/Cs_HMI/Project/StateMachine/_TMDisplay.cs index 2049ebe..f9df0c9 100644 --- a/Cs_HMI/Project/StateMachine/_TMDisplay.cs +++ b/Cs_HMI/Project/StateMachine/_TMDisplay.cs @@ -65,6 +65,8 @@ namespace Project lbBat.CurA = PUB.BMS.Current_Amp; lbBat.IsOpen = PUB.BMS.IsOpen; + if (PUB.mapctl != null) + PUB.mapctl.Invalidate(); //쓰레드로인해서 메인에서 진행하게한다. SPS는 메인쓰레드에서 진행 됨 //팝을 제거 혹은 표시하는 기능 @@ -391,7 +393,7 @@ namespace Project var tswarnmsg = VAR.TIME.RUN(eVarTime.BatWarnTime); if (tswarnmsg.TotalSeconds >= timeoutsec) { - if (VAR.BOOL[eVarBool.FLAG_CHARGEONM]==false && VAR.BOOL[eVarBool.FLAG_CHARGEONA] == false) + if (VAR.BOOL[eVarBool.FLAG_CHARGEONM] == false && VAR.BOOL[eVarBool.FLAG_CHARGEONA] == false) { if (PUB.BMS.IsValid == false) { @@ -409,7 +411,7 @@ namespace Project { //충전중이므로 메세지처리를 하지 않는다 } - + VAR.TIME.Update(eVarTime.BatWarnTime); } diff --git a/Cs_HMI/Project/ViewForm/fBms.Designer.cs b/Cs_HMI/Project/ViewForm/fBms.Designer.cs index 65b3f8d..c6a6263 100644 --- a/Cs_HMI/Project/ViewForm/fBms.Designer.cs +++ b/Cs_HMI/Project/ViewForm/fBms.Designer.cs @@ -31,46 +31,56 @@ this.components = new System.ComponentModel.Container(); this.timer1 = new System.Windows.Forms.Timer(this.components); this.panel1 = new System.Windows.Forms.Panel(); - this.button2 = new System.Windows.Forms.Button(); - this.button1 = new System.Windows.Forms.Button(); - this.arLabel1 = new arCtl.arLabel(); this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.panel2 = new System.Windows.Forms.Panel(); - this.label1 = new System.Windows.Forms.Label(); - this.cv1 = new System.Windows.Forms.Label(); - this.panel3 = new System.Windows.Forms.Panel(); - this.cv2 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.panel4 = new System.Windows.Forms.Panel(); - this.cv3 = new System.Windows.Forms.Label(); - this.label6 = new System.Windows.Forms.Label(); - this.panel5 = new System.Windows.Forms.Panel(); - this.cv4 = new System.Windows.Forms.Label(); - this.label8 = new System.Windows.Forms.Label(); - this.panel6 = new System.Windows.Forms.Panel(); - this.cv5 = new System.Windows.Forms.Label(); - this.label10 = new System.Windows.Forms.Label(); - this.panel7 = new System.Windows.Forms.Panel(); - this.cv6 = new System.Windows.Forms.Label(); - this.label12 = new System.Windows.Forms.Label(); - this.panel8 = new System.Windows.Forms.Panel(); - this.cv7 = new System.Windows.Forms.Label(); - this.label14 = new System.Windows.Forms.Label(); + this.lbcvSt = new System.Windows.Forms.Label(); this.panel9 = new System.Windows.Forms.Panel(); this.cv8 = new System.Windows.Forms.Label(); this.label16 = new System.Windows.Forms.Label(); + this.panel8 = new System.Windows.Forms.Panel(); + this.cv7 = new System.Windows.Forms.Label(); + this.label14 = new System.Windows.Forms.Label(); + this.panel7 = new System.Windows.Forms.Panel(); + this.cv6 = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); + this.panel6 = new System.Windows.Forms.Panel(); + this.cv5 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.panel5 = new System.Windows.Forms.Panel(); + this.cv4 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.panel4 = new System.Windows.Forms.Panel(); + this.cv3 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.panel3 = new System.Windows.Forms.Panel(); + this.cv2 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.panel2 = new System.Windows.Forms.Panel(); + this.cv1 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.button2 = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.arLabel1 = new arCtl.arLabel(); this.lbinfost = new System.Windows.Forms.Label(); - this.lbcvSt = new System.Windows.Forms.Label(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.panel10 = new System.Windows.Forms.Panel(); + this.lbTemp1 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.panel11 = new System.Windows.Forms.Panel(); + this.lbtemp2 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.groupBox1.SuspendLayout(); - this.panel2.SuspendLayout(); - this.panel3.SuspendLayout(); - this.panel4.SuspendLayout(); - this.panel5.SuspendLayout(); - this.panel6.SuspendLayout(); - this.panel7.SuspendLayout(); - this.panel8.SuspendLayout(); this.panel9.SuspendLayout(); + this.panel8.SuspendLayout(); + this.panel7.SuspendLayout(); + this.panel6.SuspendLayout(); + this.panel5.SuspendLayout(); + this.panel4.SuspendLayout(); + this.panel3.SuspendLayout(); + this.panel2.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.panel10.SuspendLayout(); + this.panel11.SuspendLayout(); this.SuspendLayout(); // // timer1 @@ -80,6 +90,7 @@ // // panel1 // + this.panel1.Controls.Add(this.groupBox2); this.panel1.Controls.Add(this.groupBox1); this.panel1.Controls.Add(this.button2); this.panel1.Controls.Add(this.button1); @@ -89,12 +100,319 @@ this.panel1.Size = new System.Drawing.Size(187, 577); this.panel1.TabIndex = 0; // + // groupBox1 + // + this.groupBox1.Controls.Add(this.panel9); + this.groupBox1.Controls.Add(this.panel8); + this.groupBox1.Controls.Add(this.panel7); + this.groupBox1.Controls.Add(this.panel6); + this.groupBox1.Controls.Add(this.panel5); + this.groupBox1.Controls.Add(this.panel4); + this.groupBox1.Controls.Add(this.panel3); + this.groupBox1.Controls.Add(this.panel2); + this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top; + this.groupBox1.ForeColor = System.Drawing.Color.White; + this.groupBox1.Location = new System.Drawing.Point(0, 118); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(187, 347); + this.groupBox1.TabIndex = 2; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Cell voltage"; + // + // lbcvSt + // + this.lbcvSt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lbcvSt.AutoSize = true; + this.lbcvSt.Font = new System.Drawing.Font("굴림", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.lbcvSt.ForeColor = System.Drawing.Color.White; + this.lbcvSt.Location = new System.Drawing.Point(148, 82); + this.lbcvSt.Name = "lbcvSt"; + this.lbcvSt.Size = new System.Drawing.Size(39, 27); + this.lbcvSt.TabIndex = 8; + this.lbcvSt.Text = "●"; + // + // panel9 + // + this.panel9.Controls.Add(this.cv8); + this.panel9.Controls.Add(this.label16); + this.panel9.Dock = System.Windows.Forms.DockStyle.Top; + this.panel9.Location = new System.Drawing.Point(3, 297); + this.panel9.Name = "panel9"; + this.panel9.Size = new System.Drawing.Size(181, 40); + this.panel9.TabIndex = 7; + // + // cv8 + // + this.cv8.Dock = System.Windows.Forms.DockStyle.Fill; + this.cv8.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cv8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); + this.cv8.Location = new System.Drawing.Point(47, 0); + this.cv8.Name = "cv8"; + this.cv8.Size = new System.Drawing.Size(134, 40); + this.cv8.TabIndex = 0; + this.cv8.Text = "--"; + this.cv8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label16 + // + this.label16.Dock = System.Windows.Forms.DockStyle.Left; + this.label16.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.label16.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); + this.label16.Location = new System.Drawing.Point(0, 0); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(47, 40); + this.label16.TabIndex = 0; + this.label16.Text = "#8"; + this.label16.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // panel8 + // + this.panel8.Controls.Add(this.cv7); + this.panel8.Controls.Add(this.label14); + this.panel8.Dock = System.Windows.Forms.DockStyle.Top; + this.panel8.Location = new System.Drawing.Point(3, 257); + this.panel8.Name = "panel8"; + this.panel8.Size = new System.Drawing.Size(181, 40); + this.panel8.TabIndex = 6; + this.panel8.Paint += new System.Windows.Forms.PaintEventHandler(this.panel8_Paint); + // + // cv7 + // + this.cv7.Dock = System.Windows.Forms.DockStyle.Fill; + this.cv7.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cv7.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); + this.cv7.Location = new System.Drawing.Point(47, 0); + this.cv7.Name = "cv7"; + this.cv7.Size = new System.Drawing.Size(134, 40); + this.cv7.TabIndex = 0; + this.cv7.Text = "--"; + this.cv7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label14 + // + this.label14.Dock = System.Windows.Forms.DockStyle.Left; + this.label14.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.label14.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); + this.label14.Location = new System.Drawing.Point(0, 0); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(47, 40); + this.label14.TabIndex = 0; + this.label14.Text = "#7"; + this.label14.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // panel7 + // + this.panel7.Controls.Add(this.cv6); + this.panel7.Controls.Add(this.label12); + this.panel7.Dock = System.Windows.Forms.DockStyle.Top; + this.panel7.Location = new System.Drawing.Point(3, 217); + this.panel7.Name = "panel7"; + this.panel7.Size = new System.Drawing.Size(181, 40); + this.panel7.TabIndex = 5; + // + // cv6 + // + this.cv6.Dock = System.Windows.Forms.DockStyle.Fill; + this.cv6.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cv6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); + this.cv6.Location = new System.Drawing.Point(47, 0); + this.cv6.Name = "cv6"; + this.cv6.Size = new System.Drawing.Size(134, 40); + this.cv6.TabIndex = 0; + this.cv6.Text = "--"; + this.cv6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label12 + // + this.label12.Dock = System.Windows.Forms.DockStyle.Left; + this.label12.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.label12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); + this.label12.Location = new System.Drawing.Point(0, 0); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(47, 40); + this.label12.TabIndex = 0; + this.label12.Text = "#6"; + this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // panel6 + // + this.panel6.Controls.Add(this.cv5); + this.panel6.Controls.Add(this.label10); + this.panel6.Dock = System.Windows.Forms.DockStyle.Top; + this.panel6.Location = new System.Drawing.Point(3, 177); + this.panel6.Name = "panel6"; + this.panel6.Size = new System.Drawing.Size(181, 40); + this.panel6.TabIndex = 4; + this.panel6.Paint += new System.Windows.Forms.PaintEventHandler(this.panel6_Paint); + // + // cv5 + // + this.cv5.Dock = System.Windows.Forms.DockStyle.Fill; + this.cv5.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cv5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); + this.cv5.Location = new System.Drawing.Point(47, 0); + this.cv5.Name = "cv5"; + this.cv5.Size = new System.Drawing.Size(134, 40); + this.cv5.TabIndex = 0; + this.cv5.Text = "--"; + this.cv5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label10 + // + this.label10.Dock = System.Windows.Forms.DockStyle.Left; + this.label10.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.label10.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); + this.label10.Location = new System.Drawing.Point(0, 0); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(47, 40); + this.label10.TabIndex = 0; + this.label10.Text = "#5"; + this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // panel5 + // + this.panel5.Controls.Add(this.cv4); + this.panel5.Controls.Add(this.label8); + this.panel5.Dock = System.Windows.Forms.DockStyle.Top; + this.panel5.Location = new System.Drawing.Point(3, 137); + this.panel5.Name = "panel5"; + this.panel5.Size = new System.Drawing.Size(181, 40); + this.panel5.TabIndex = 3; + // + // cv4 + // + this.cv4.Dock = System.Windows.Forms.DockStyle.Fill; + this.cv4.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cv4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); + this.cv4.Location = new System.Drawing.Point(47, 0); + this.cv4.Name = "cv4"; + this.cv4.Size = new System.Drawing.Size(134, 40); + this.cv4.TabIndex = 0; + this.cv4.Text = "--"; + this.cv4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label8 + // + this.label8.Dock = System.Windows.Forms.DockStyle.Left; + this.label8.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.label8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); + this.label8.Location = new System.Drawing.Point(0, 0); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(47, 40); + this.label8.TabIndex = 0; + this.label8.Text = "#4"; + this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // panel4 + // + this.panel4.Controls.Add(this.cv3); + this.panel4.Controls.Add(this.label6); + this.panel4.Dock = System.Windows.Forms.DockStyle.Top; + this.panel4.Location = new System.Drawing.Point(3, 97); + this.panel4.Name = "panel4"; + this.panel4.Size = new System.Drawing.Size(181, 40); + this.panel4.TabIndex = 2; + this.panel4.Paint += new System.Windows.Forms.PaintEventHandler(this.panel4_Paint); + // + // cv3 + // + this.cv3.Dock = System.Windows.Forms.DockStyle.Fill; + this.cv3.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cv3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); + this.cv3.Location = new System.Drawing.Point(47, 0); + this.cv3.Name = "cv3"; + this.cv3.Size = new System.Drawing.Size(134, 40); + this.cv3.TabIndex = 0; + this.cv3.Text = "--"; + this.cv3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label6 + // + this.label6.Dock = System.Windows.Forms.DockStyle.Left; + this.label6.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.label6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); + this.label6.Location = new System.Drawing.Point(0, 0); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(47, 40); + this.label6.TabIndex = 0; + this.label6.Text = "#3"; + this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // panel3 + // + this.panel3.Controls.Add(this.cv2); + this.panel3.Controls.Add(this.label4); + this.panel3.Dock = System.Windows.Forms.DockStyle.Top; + this.panel3.Location = new System.Drawing.Point(3, 57); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(181, 40); + this.panel3.TabIndex = 1; + this.panel3.Paint += new System.Windows.Forms.PaintEventHandler(this.panel3_Paint); + // + // cv2 + // + this.cv2.Dock = System.Windows.Forms.DockStyle.Fill; + this.cv2.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cv2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); + this.cv2.Location = new System.Drawing.Point(47, 0); + this.cv2.Name = "cv2"; + this.cv2.Size = new System.Drawing.Size(134, 40); + this.cv2.TabIndex = 0; + this.cv2.Text = "--"; + this.cv2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label4 + // + this.label4.Dock = System.Windows.Forms.DockStyle.Left; + this.label4.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.label4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); + this.label4.Location = new System.Drawing.Point(0, 0); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(47, 40); + this.label4.TabIndex = 0; + this.label4.Text = "#2"; + this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // panel2 + // + this.panel2.Controls.Add(this.cv1); + this.panel2.Controls.Add(this.label1); + this.panel2.Dock = System.Windows.Forms.DockStyle.Top; + this.panel2.Location = new System.Drawing.Point(3, 17); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(181, 40); + this.panel2.TabIndex = 0; + // + // cv1 + // + this.cv1.Dock = System.Windows.Forms.DockStyle.Fill; + this.cv1.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cv1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); + this.cv1.Location = new System.Drawing.Point(47, 0); + this.cv1.Name = "cv1"; + this.cv1.Size = new System.Drawing.Size(134, 40); + this.cv1.TabIndex = 0; + this.cv1.Text = "--"; + this.cv1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label1 + // + this.label1.Dock = System.Windows.Forms.DockStyle.Left; + this.label1.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(47, 40); + this.label1.TabIndex = 0; + this.label1.Text = "#1"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // // button2 // this.button2.Dock = System.Windows.Forms.DockStyle.Top; - this.button2.Location = new System.Drawing.Point(0, 67); + this.button2.Location = new System.Drawing.Point(0, 59); this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(187, 67); + this.button2.Size = new System.Drawing.Size(187, 59); this.button2.TabIndex = 1; this.button2.Text = "Query Cell Voltage"; this.button2.UseVisualStyleBackColor = true; @@ -105,7 +423,7 @@ this.button1.Dock = System.Windows.Forms.DockStyle.Top; this.button1.Location = new System.Drawing.Point(0, 0); this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(187, 67); + this.button1.Size = new System.Drawing.Size(187, 59); this.button1.TabIndex = 0; this.button1.Text = "Query Remain"; this.button1.UseVisualStyleBackColor = true; @@ -155,302 +473,6 @@ this.arLabel1.TextShadow = false; this.arLabel1.TextVisible = true; // - // groupBox1 - // - this.groupBox1.Controls.Add(this.lbcvSt); - this.groupBox1.Controls.Add(this.panel9); - this.groupBox1.Controls.Add(this.panel8); - this.groupBox1.Controls.Add(this.panel7); - this.groupBox1.Controls.Add(this.panel6); - this.groupBox1.Controls.Add(this.panel5); - this.groupBox1.Controls.Add(this.panel4); - this.groupBox1.Controls.Add(this.panel3); - this.groupBox1.Controls.Add(this.panel2); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.ForeColor = System.Drawing.Color.White; - this.groupBox1.Location = new System.Drawing.Point(0, 134); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(187, 443); - this.groupBox1.TabIndex = 2; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Cell voltage"; - // - // panel2 - // - this.panel2.Controls.Add(this.cv1); - this.panel2.Controls.Add(this.label1); - this.panel2.Dock = System.Windows.Forms.DockStyle.Top; - this.panel2.Location = new System.Drawing.Point(3, 17); - this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(181, 40); - this.panel2.TabIndex = 0; - // - // label1 - // - this.label1.Dock = System.Windows.Forms.DockStyle.Left; - this.label1.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); - this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); - this.label1.Location = new System.Drawing.Point(0, 0); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(47, 40); - this.label1.TabIndex = 0; - this.label1.Text = "#1"; - this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // cv1 - // - this.cv1.Dock = System.Windows.Forms.DockStyle.Fill; - this.cv1.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.cv1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); - this.cv1.Location = new System.Drawing.Point(47, 0); - this.cv1.Name = "cv1"; - this.cv1.Size = new System.Drawing.Size(134, 40); - this.cv1.TabIndex = 0; - this.cv1.Text = "--"; - this.cv1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // panel3 - // - this.panel3.Controls.Add(this.cv2); - this.panel3.Controls.Add(this.label4); - this.panel3.Dock = System.Windows.Forms.DockStyle.Top; - this.panel3.Location = new System.Drawing.Point(3, 57); - this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(181, 40); - this.panel3.TabIndex = 1; - this.panel3.Paint += new System.Windows.Forms.PaintEventHandler(this.panel3_Paint); - // - // cv2 - // - this.cv2.Dock = System.Windows.Forms.DockStyle.Fill; - this.cv2.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.cv2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); - this.cv2.Location = new System.Drawing.Point(47, 0); - this.cv2.Name = "cv2"; - this.cv2.Size = new System.Drawing.Size(134, 40); - this.cv2.TabIndex = 0; - this.cv2.Text = "--"; - this.cv2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // label4 - // - this.label4.Dock = System.Windows.Forms.DockStyle.Left; - this.label4.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); - this.label4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); - this.label4.Location = new System.Drawing.Point(0, 0); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(47, 40); - this.label4.TabIndex = 0; - this.label4.Text = "#2"; - this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // panel4 - // - this.panel4.Controls.Add(this.cv3); - this.panel4.Controls.Add(this.label6); - this.panel4.Dock = System.Windows.Forms.DockStyle.Top; - this.panel4.Location = new System.Drawing.Point(3, 97); - this.panel4.Name = "panel4"; - this.panel4.Size = new System.Drawing.Size(181, 40); - this.panel4.TabIndex = 2; - this.panel4.Paint += new System.Windows.Forms.PaintEventHandler(this.panel4_Paint); - // - // cv3 - // - this.cv3.Dock = System.Windows.Forms.DockStyle.Fill; - this.cv3.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.cv3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); - this.cv3.Location = new System.Drawing.Point(47, 0); - this.cv3.Name = "cv3"; - this.cv3.Size = new System.Drawing.Size(134, 40); - this.cv3.TabIndex = 0; - this.cv3.Text = "--"; - this.cv3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // label6 - // - this.label6.Dock = System.Windows.Forms.DockStyle.Left; - this.label6.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); - this.label6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); - this.label6.Location = new System.Drawing.Point(0, 0); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(47, 40); - this.label6.TabIndex = 0; - this.label6.Text = "#3"; - this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // panel5 - // - this.panel5.Controls.Add(this.cv4); - this.panel5.Controls.Add(this.label8); - this.panel5.Dock = System.Windows.Forms.DockStyle.Top; - this.panel5.Location = new System.Drawing.Point(3, 137); - this.panel5.Name = "panel5"; - this.panel5.Size = new System.Drawing.Size(181, 40); - this.panel5.TabIndex = 3; - // - // cv4 - // - this.cv4.Dock = System.Windows.Forms.DockStyle.Fill; - this.cv4.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.cv4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); - this.cv4.Location = new System.Drawing.Point(47, 0); - this.cv4.Name = "cv4"; - this.cv4.Size = new System.Drawing.Size(134, 40); - this.cv4.TabIndex = 0; - this.cv4.Text = "--"; - this.cv4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // label8 - // - this.label8.Dock = System.Windows.Forms.DockStyle.Left; - this.label8.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); - this.label8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); - this.label8.Location = new System.Drawing.Point(0, 0); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(47, 40); - this.label8.TabIndex = 0; - this.label8.Text = "#4"; - this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // panel6 - // - this.panel6.Controls.Add(this.cv5); - this.panel6.Controls.Add(this.label10); - this.panel6.Dock = System.Windows.Forms.DockStyle.Top; - this.panel6.Location = new System.Drawing.Point(3, 177); - this.panel6.Name = "panel6"; - this.panel6.Size = new System.Drawing.Size(181, 40); - this.panel6.TabIndex = 4; - this.panel6.Paint += new System.Windows.Forms.PaintEventHandler(this.panel6_Paint); - // - // cv5 - // - this.cv5.Dock = System.Windows.Forms.DockStyle.Fill; - this.cv5.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.cv5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); - this.cv5.Location = new System.Drawing.Point(47, 0); - this.cv5.Name = "cv5"; - this.cv5.Size = new System.Drawing.Size(134, 40); - this.cv5.TabIndex = 0; - this.cv5.Text = "--"; - this.cv5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // label10 - // - this.label10.Dock = System.Windows.Forms.DockStyle.Left; - this.label10.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); - this.label10.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); - this.label10.Location = new System.Drawing.Point(0, 0); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(47, 40); - this.label10.TabIndex = 0; - this.label10.Text = "#5"; - this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // panel7 - // - this.panel7.Controls.Add(this.cv6); - this.panel7.Controls.Add(this.label12); - this.panel7.Dock = System.Windows.Forms.DockStyle.Top; - this.panel7.Location = new System.Drawing.Point(3, 217); - this.panel7.Name = "panel7"; - this.panel7.Size = new System.Drawing.Size(181, 40); - this.panel7.TabIndex = 5; - // - // cv6 - // - this.cv6.Dock = System.Windows.Forms.DockStyle.Fill; - this.cv6.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.cv6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); - this.cv6.Location = new System.Drawing.Point(47, 0); - this.cv6.Name = "cv6"; - this.cv6.Size = new System.Drawing.Size(134, 40); - this.cv6.TabIndex = 0; - this.cv6.Text = "--"; - this.cv6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // label12 - // - this.label12.Dock = System.Windows.Forms.DockStyle.Left; - this.label12.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); - this.label12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); - this.label12.Location = new System.Drawing.Point(0, 0); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(47, 40); - this.label12.TabIndex = 0; - this.label12.Text = "#6"; - this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // panel8 - // - this.panel8.Controls.Add(this.cv7); - this.panel8.Controls.Add(this.label14); - this.panel8.Dock = System.Windows.Forms.DockStyle.Top; - this.panel8.Location = new System.Drawing.Point(3, 257); - this.panel8.Name = "panel8"; - this.panel8.Size = new System.Drawing.Size(181, 40); - this.panel8.TabIndex = 6; - this.panel8.Paint += new System.Windows.Forms.PaintEventHandler(this.panel8_Paint); - // - // cv7 - // - this.cv7.Dock = System.Windows.Forms.DockStyle.Fill; - this.cv7.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.cv7.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); - this.cv7.Location = new System.Drawing.Point(47, 0); - this.cv7.Name = "cv7"; - this.cv7.Size = new System.Drawing.Size(134, 40); - this.cv7.TabIndex = 0; - this.cv7.Text = "--"; - this.cv7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // label14 - // - this.label14.Dock = System.Windows.Forms.DockStyle.Left; - this.label14.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); - this.label14.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); - this.label14.Location = new System.Drawing.Point(0, 0); - this.label14.Name = "label14"; - this.label14.Size = new System.Drawing.Size(47, 40); - this.label14.TabIndex = 0; - this.label14.Text = "#7"; - this.label14.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // panel9 - // - this.panel9.Controls.Add(this.cv8); - this.panel9.Controls.Add(this.label16); - this.panel9.Dock = System.Windows.Forms.DockStyle.Top; - this.panel9.Location = new System.Drawing.Point(3, 297); - this.panel9.Name = "panel9"; - this.panel9.Size = new System.Drawing.Size(181, 40); - this.panel9.TabIndex = 7; - // - // cv8 - // - this.cv8.Dock = System.Windows.Forms.DockStyle.Fill; - this.cv8.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.cv8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); - this.cv8.Location = new System.Drawing.Point(47, 0); - this.cv8.Name = "cv8"; - this.cv8.Size = new System.Drawing.Size(134, 40); - this.cv8.TabIndex = 0; - this.cv8.Text = "--"; - this.cv8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // label16 - // - this.label16.Dock = System.Windows.Forms.DockStyle.Left; - this.label16.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); - this.label16.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); - this.label16.Location = new System.Drawing.Point(0, 0); - this.label16.Name = "label16"; - this.label16.Size = new System.Drawing.Size(47, 40); - this.label16.TabIndex = 0; - this.label16.Text = "#8"; - this.label16.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // // lbinfost // this.lbinfost.AutoSize = true; @@ -462,17 +484,87 @@ this.lbinfost.TabIndex = 2; this.lbinfost.Text = "●"; // - // lbcvSt + // groupBox2 // - this.lbcvSt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.lbcvSt.AutoSize = true; - this.lbcvSt.Font = new System.Drawing.Font("굴림", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129))); - this.lbcvSt.ForeColor = System.Drawing.Color.White; - this.lbcvSt.Location = new System.Drawing.Point(2, 411); - this.lbcvSt.Name = "lbcvSt"; - this.lbcvSt.Size = new System.Drawing.Size(39, 27); - this.lbcvSt.TabIndex = 8; - this.lbcvSt.Text = "●"; + this.groupBox2.Controls.Add(this.lbcvSt); + this.groupBox2.Controls.Add(this.panel11); + this.groupBox2.Controls.Add(this.panel10); + this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox2.ForeColor = System.Drawing.Color.White; + this.groupBox2.Location = new System.Drawing.Point(0, 465); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(187, 112); + this.groupBox2.TabIndex = 3; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Temp"; + // + // panel10 + // + this.panel10.Controls.Add(this.lbTemp1); + this.panel10.Controls.Add(this.label3); + this.panel10.Dock = System.Windows.Forms.DockStyle.Top; + this.panel10.Location = new System.Drawing.Point(3, 17); + this.panel10.Name = "panel10"; + this.panel10.Size = new System.Drawing.Size(181, 40); + this.panel10.TabIndex = 9; + // + // label2 + // + this.lbTemp1.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbTemp1.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbTemp1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); + this.lbTemp1.Location = new System.Drawing.Point(47, 0); + this.lbTemp1.Name = "label2"; + this.lbTemp1.Size = new System.Drawing.Size(134, 40); + this.lbTemp1.TabIndex = 0; + this.lbTemp1.Text = "--"; + this.lbTemp1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label3 + // + this.label3.Dock = System.Windows.Forms.DockStyle.Left; + this.label3.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); + this.label3.Location = new System.Drawing.Point(0, 0); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(47, 40); + this.label3.TabIndex = 0; + this.label3.Text = "#1"; + this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // panel11 + // + this.panel11.Controls.Add(this.lbtemp2); + this.panel11.Controls.Add(this.label7); + this.panel11.Dock = System.Windows.Forms.DockStyle.Top; + this.panel11.Location = new System.Drawing.Point(3, 57); + this.panel11.Name = "panel11"; + this.panel11.Size = new System.Drawing.Size(181, 40); + this.panel11.TabIndex = 10; + // + // label5 + // + this.lbtemp2.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbtemp2.Font = new System.Drawing.Font("Tahoma", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbtemp2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); + this.lbtemp2.Location = new System.Drawing.Point(47, 0); + this.lbtemp2.Name = "label5"; + this.lbtemp2.Size = new System.Drawing.Size(134, 40); + this.lbtemp2.TabIndex = 0; + this.lbtemp2.Text = "--"; + this.lbtemp2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label7 + // + this.label7.Dock = System.Windows.Forms.DockStyle.Left; + this.label7.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.label7.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); + this.label7.Location = new System.Drawing.Point(0, 0); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(47, 40); + this.label7.TabIndex = 0; + this.label7.Text = "#2"; + this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // fBms // @@ -490,15 +582,18 @@ this.VisibleChanged += new System.EventHandler(this.fAgv_VisibleChanged); this.panel1.ResumeLayout(false); this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - this.panel2.ResumeLayout(false); - this.panel3.ResumeLayout(false); - this.panel4.ResumeLayout(false); - this.panel5.ResumeLayout(false); - this.panel6.ResumeLayout(false); - this.panel7.ResumeLayout(false); - this.panel8.ResumeLayout(false); this.panel9.ResumeLayout(false); + this.panel8.ResumeLayout(false); + this.panel7.ResumeLayout(false); + this.panel6.ResumeLayout(false); + this.panel5.ResumeLayout(false); + this.panel4.ResumeLayout(false); + this.panel3.ResumeLayout(false); + this.panel2.ResumeLayout(false); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.panel10.ResumeLayout(false); + this.panel11.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -537,5 +632,12 @@ private System.Windows.Forms.Label label4; private System.Windows.Forms.Label lbinfost; private System.Windows.Forms.Label lbcvSt; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Panel panel11; + private System.Windows.Forms.Label lbtemp2; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Panel panel10; + private System.Windows.Forms.Label lbTemp1; + private System.Windows.Forms.Label label3; } } \ No newline at end of file diff --git a/Cs_HMI/Project/ViewForm/fBms.cs b/Cs_HMI/Project/ViewForm/fBms.cs index 399b280..afea04f 100644 --- a/Cs_HMI/Project/ViewForm/fBms.cs +++ b/Cs_HMI/Project/ViewForm/fBms.cs @@ -73,6 +73,8 @@ namespace Project.ViewForm this.cv6.Text = PUB.BMS.CellVoltage[5].ToString("N3") + "v"; this.cv7.Text = PUB.BMS.CellVoltage[6].ToString("N3") + "v"; this.cv8.Text = PUB.BMS.CellVoltage[7].ToString("N3") + "v"; + this.lbTemp1.Text = PUB.BMS.Current_temp1.ToString() + "℃"; + this.lbtemp2.Text = PUB.BMS.Current_temp2.ToString() + "℃"; timer1.Start(); } diff --git a/Cs_HMI/Project/sample.route b/Cs_HMI/Project/sample.route index 46d1fba..cea5fcc 100644 --- a/Cs_HMI/Project/sample.route +++ b/Cs_HMI/Project/sample.route @@ -1,113 +1,102 @@ [RFID_POINTS] -100,486,0002 -164,494,0003 -229,493,0004 -309,489,0005 -370,490,0006 -437,486,0007 -483,459,0008 -511,421,0009 -543,371,0010 -569,329,0011 -608,289,0012 -661,279,0013 -700,297,0014 -698,349,0015 -698,391,0016 -699,449,0017 -691,491,0018 -569,275,0019 -518,264,0020 -454,264,0021 -388,261,0022 -314,258,0023 -639,234,0024 -621,182,0025 -629,143,0026 -657,101,0027 -627,82,0028 -560,73,0029 -499,65,0030 -432,65,0031 -264,232,0032 -363,60,0033 -654,508,0034 -96,542,0050 -159,542,0051 -226,542,0061 -309,541,0070 -369,542,0071 -483,165,0010 -735,163,0011 -523,170,0001 -565,175,0002 -597,182,0003 -665,181,0004 -700,176,0005 -721,170,0006 - +100,486,517 +173,488,516 +230,493,515 +309,489,514 +370,490,513 +437,487,512 +483,459,511 +511,421,510 +543,371,509 +569,329,508 +608,289,507 +661,279,506 +701,297,505 +698,349,504 +698,391,503 +699,449,502 +691,491,501 +570,275,400 +517,264,401 +454,264,402 +388,262,403 +315,258,404 +639,234,600 +621,182,601 +641,183,602 +657,101,603 +627,82,604 +560,73,605 +499,65,606 +432,65,607 +264,232,405 +363,60,608 +654,508,500 +96,542,100 +159,542,101 +226,542,102 +309,541,103 +369,542,104 +483,165,753 +735,163,700 +523,170,752 +565,175,751 +597,182,750 +665,181,703 +700,176,702 +722,170,701 [RFID_LINES] -96,542,100,486,0005,0002,False,56.14267 -100,486,164,494,0002,0003,False,64.49806 -164,494,229,493,0003,0004,False,65.00769 -229,493,309,489,0004,0005,False,80.09994 -309,489,370,490,0005,0006,False,61.0082 -370,490,437,486,0006,0007,False,67.11929 -437,486,483,459,0007,0008,False,53.33854 -483,459,511,421,0008,0009,False,47.20169 -511,421,543,371,0009,0010,False,59.36329 -543,371,569,329,0010,0011,False,49.39635 -569,329,608,289,0011,0012,False,55.86591 -608,289,661,279,0012,0013,False,53.93515 -661,279,700,297,0013,0014,False,42.95346 -700,297,698,349,0014,0015,False,52.03845 -698,349,698,391,0015,0016,False,42 -698,391,699,449,0016,0017,False,58.00862 -699,449,691,491,0017,0018,False,42.75512 -691,491,654,508,0018,0034,False,40.71855 -159,542,164,494,0006,0003,False,48.25971 -226,542,229,493,0007,0004,False,49.09175 -309,541,309,489,0008,0005,False,52 -369,542,370,490,0009,0006,False,52.00961 -370,490,370,490,0006,0006,False,0 -608,289,569,275,0012,0019,False,41.4367 -569,275,518,264,0019,0020,False,52.17279 -518,264,454,264,0020,0021,False,64 -454,264,388,261,0021,0022,False,66.06815 -388,261,314,258,0022,0023,False,74.06078 -661,279,639,234,0013,0024,False,50.08992 -639,234,621,182,0024,0025,False,55.02727 -621,182,629,143,0025,0026,False,39.81206 -629,143,657,101,0026,0027,False,50.47772 -657,101,627,82,0027,0028,False,35.51056 -627,82,560,73,0028,0029,False,67.60178 -560,73,499,65,0029,0030,False,61.52235 -483,165,523,170,0010,0001,False,40.31129 -523,170,565,175,0001,0002,False,42.29657 -565,175,597,182,0002,0003,False,32.75668 -597,182,621,182,0003,0025,False,24 -621,182,665,181,0025,0004,False,44.01136 -665,181,700,176,0004,0005,False,35.35534 -700,176,721,170,0005,0006,False,21.84033 -721,170,735,163,0006,0011,False,15.65248 -735,163,721,170,0011,0006,False,15.65248 -721,170,735,163,0006,0011,False,15.65248 -314,258,388,261,0023,0022,False,74.06078 -388,261,454,264,0022,0021,False,66.06815 -454,264,518,264,0021,0020,False,64 -518,264,569,275,0020,0019,False,52.17279 -569,275,608,289,0019,0012,False,41.4367 -264,232,314,258,0032,0023,False,56.35601 -363,60,432,65,0033,0031,False,69.18092 -432,65,499,65,0031,0030,False,67 - - +100,486,173,488,517,516,False,73.02739 +173,488,230,493,516,515,False,57.21888 +230,493,309,489,515,514,False,79.1012 +309,489,370,490,514,513,False,61.0082 +370,490,437,487,513,512,False,67.06713 +437,487,483,459,512,511,False,53.85165 +483,459,511,421,511,510,False,47.20169 +511,421,543,371,510,509,False,59.36329 +543,371,569,329,509,508,False,49.39635 +569,329,608,289,508,507,False,55.86591 +608,289,639,234,507,600,False,63.13478 +639,234,665,181,600,703,False,59.03389 +665,181,657,101,703,603,False,80.399 +657,101,627,82,603,604,False,35.51056 +627,82,560,73,604,605,False,67.60178 +560,73,499,65,605,606,False,61.52235 +499,65,432,65,606,607,False,67 +432,65,363,60,607,608,False,69.18092 +641,183,665,181,602,703,False,24.08319 +665,181,700,176,703,702,False,35.35534 +700,176,722,170,702,701,False,22.80351 +722,170,735,163,701,700,False,14.76482 +641,183,621,182,602,601,False,20.02498 +621,182,597,182,601,750,False,24 +597,182,565,175,750,751,False,32.75668 +565,175,523,170,751,752,False,42.29657 +523,170,483,165,752,753,False,40.31129 +264,232,315,258,405,404,False,57.24509 +315,258,388,262,404,403,False,73.1095 +388,262,454,264,403,402,False,66.0303 +454,264,517,264,402,401,False,63 +517,264,570,275,401,400,False,54.12947 +570,275,608,289,400,507,False,40.49691 +608,289,661,279,507,506,False,53.93515 +661,279,701,297,506,505,False,43.86343 +701,297,698,349,505,504,False,52.08647 +698,349,698,391,504,503,False,42 +698,391,699,449,503,502,False,58.00862 +699,449,691,491,502,501,False,42.75512 +691,491,654,508,501,500,False,40.71855 +96,542,100,486,100,517,False,56.14267 +159,542,173,488,101,516,False,55.7853 +226,542,230,493,102,515,False,49.16299 +309,541,309,489,103,514,False,52 +369,542,370,490,104,513,False,52.00961 [MAP_TEXTS] 179,251,-1,-16777216,Arial,12,OPS-2 239,52,-256,-65408,Arial,12,SSOTRON-3 617,527,-16711936,-16777216,Arial,12,SSOTRON-1 87,551,-16777216,16777215,Arial,12,B1 -150,551,-16777216,16777215,Arial,12,B2 +150,550,-16777216,16777215,Arial,12,B2 227,553,-16777216,16777215,Arial,12,B3 299,555,-16777216,16777215,Arial,12,B4 367,554,-16777216,16777215,Arial,12,B5 diff --git a/Cs_HMI/SubProject/AGVControl/.vscode/settings.json b/Cs_HMI/SubProject/AGVControl/.vscode/settings.json new file mode 100644 index 0000000..359cd76 --- /dev/null +++ b/Cs_HMI/SubProject/AGVControl/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dotnet.preferCSharpExtension": true +} \ No newline at end of file diff --git a/Cs_HMI/SubProject/AGVControl/MapControl.cs b/Cs_HMI/SubProject/AGVControl/MapControl.cs index 03db220..80b1150 100644 --- a/Cs_HMI/SubProject/AGVControl/MapControl.cs +++ b/Cs_HMI/SubProject/AGVControl/MapControl.cs @@ -49,6 +49,12 @@ namespace AGVControl public List Path { get; set; } } + public enum AGVMoveState + { + Stop = 0, + Run + } + public enum AGVActionReasonCode { Unknown = 0, @@ -57,7 +63,8 @@ namespace AGVControl NotOnPath, // 현재 위치가 경로에 없음 Arrived, // 경로의 마지막 지점(목적지 도달) Normal, // 정상(다음 RFID 있음) - NeedTurn + NeedTurn, + NoTurnPoint, } public class AGVActionPrediction @@ -66,6 +73,7 @@ namespace AGVControl public uint? NextRFID { get; set; } public string Reason { get; set; } public AGVActionReasonCode ReasonCode { get; set; } + public AGVMoveState MoveState { get; set; } // RUN 또는 STOP } public partial class MapControl : Control @@ -401,35 +409,17 @@ namespace AGVControl var selected_rfid = rfidPoints.Where(t => t.Bounds.Expand(SELECTION_DISTANCE, SELECTION_DISTANCE).Contains(mapPoint)).FirstOrDefault(); if (selected_rfid != null) { - var oldtagno = selected_rfid.RFIDValue; - AR.UTIL.ShowProperty(selected_rfid); - if (selected_rfid.RFIDValue != oldtagno) - { - var items1 = this.rfidConnections.Where(t=>t.StartRFID == oldtagno); - foreach (var item in items1) - item.StartRFID = selected_rfid.RFIDValue; - - var items2 = this.rfidConnections.Where(t => t.EndRFID == oldtagno); - foreach (var item in items2) - item.EndRFID = selected_rfid.RFIDValue; - } - + UTIL.ShowPropertyDialog(selected_rfid); this.Invalidate(); return; } - - // 텍스트 객체 찾기 var selected_txt = mapTexts.Where(t => t.Bounds.Expand(SELECTION_DISTANCE, SELECTION_DISTANCE).Contains(mapPoint)).FirstOrDefault(); if (selected_txt != null) { - var rlt = AR.UTIL.InputBox("input", selected_txt.Text); - if (rlt.Item1 == true) - { - selected_txt.Text = rlt.Item2; - this.Invalidate(); - } + UTIL.ShowPropertyDialog(selected_txt); + this.Invalidate(); return; } } @@ -451,7 +441,7 @@ namespace AGVControl } else { - zoom /= 1.1f; + zoom /= 1.2f; } zoom = Math.Max(0.1f, Math.Min(10.0f, zoom)); @@ -744,9 +734,17 @@ namespace AGVControl var rfidPoint = FindRFIDPoint(rfidValue); if (rfidPoint != null) { + // 이전 위치 저장 (방향 검증용) + Point previousPosition = agv.CurrentPosition; + uint previousRFID = agv.CurrentRFID; + + // AGV 위치 업데이트 agv.CurrentPosition = rfidPoint.Location; agv.CurrentRFID = rfidValue; + // 이동 경로에 추가 + agv.AddToMovementHistory(rfidValue, rfidPoint.Location); + // 목적지가 설정되어 있고 경로가 있는 경우 검증 if (agv.TargetPosition != Point.Empty && agv.CurrentPath.Count > 0) { @@ -784,6 +782,52 @@ namespace AGVControl } } + // 방향 검증 및 정정 (이전 위치가 있고 경로가 있는 경우) + if (previousRFID != 0 && agv.CurrentPath.Count > 0) + { + // RFID 연결 정보 기반 예상 방향 계산 + Direction? expectedDirection = null; + int currentIdx = agv.CurrentPath.FindIndex(p => p == agv.CurrentPosition); + if (currentIdx >= 0 && currentIdx < agv.CurrentPath.Count - 1) + { + // 현재 위치와 다음 위치의 RFID 찾기 + var currentRFIDPoint = FindRFIDPoint(agv.CurrentRFID); + var nextPoint = agv.CurrentPath[currentIdx + 1]; + var nextRFIDPoint = rfidPoints.FirstOrDefault(p => p.Location == nextPoint); + + if (currentRFIDPoint != null && nextRFIDPoint != null) + { + // rfidConnections에서 연결 정보 확인 + var connection = rfidConnections.FirstOrDefault(c => + (c.StartRFID == currentRFIDPoint.RFIDValue && c.EndRFID == nextRFIDPoint.RFIDValue) || + (c.IsBidirectional && c.StartRFID == nextRFIDPoint.RFIDValue && c.EndRFID == currentRFIDPoint.RFIDValue)); + + if (connection != null) + { + // 연결된 경로이므로 방향 결정 + if (connection.StartRFID == currentRFIDPoint.RFIDValue && connection.EndRFID == nextRFIDPoint.RFIDValue) + { + expectedDirection = Direction.Forward; // Start -> End 방향 + } + else + { + expectedDirection = Direction.Backward; // End -> Start 방향 + } + } + } + } + + if (expectedDirection.HasValue) + { + bool directionValid = agv.ValidateAndCorrectDirectionByConnection(expectedDirection.Value, rfidConnections.ToList()); + if (!directionValid) + { + // 방향이 정정되었음을 로그로 기록 + Console.WriteLine($"AGV 방향 정정 (연결 정보 기반): 예상 {expectedDirection.Value} -> 실제 {agv.CurrentDirection}"); + } + } + } + this.Invalidate(); return true; } @@ -1233,37 +1277,52 @@ namespace AGVControl var MarkerSize = 5; var half = MarkerSize / 2f; rfid.Bounds = new RectangleF(rfid.Location.X - half, rfid.Location.Y - half, MarkerSize, MarkerSize); - - // 회전 가능 여부에 따라 다른 색상 사용 - using (var brush = new SolidBrush(rfid.IsRotatable ? Color.Yellow : Color.Green)) + + // 종단 RFID는 특별한 색상으로 표시 + Color pointColor; + if (rfid.IsTerminal) + { + pointColor = Color.Orange; // 종단은 주황색 + } + else if (rfid.IsRotatable) + { + pointColor = Color.Yellow; // 회전 가능은 노란색 + } + else + { + pointColor = Color.Green; // 일반은 초록색 + } + + using (var brush = new SolidBrush(pointColor)) { g.FillEllipse(brush, rfid.Bounds); } + // 고정방향이 있으면 테두리 색상 표시 if (rfid.FixedDirection.HasValue) { - Color borderColor = rfid.FixedDirection.Value == Direction.Forward ? Color.DeepSkyBlue : Color.Gold; using (var pen = new Pen(borderColor, 2)) + Color borderColor = rfid.FixedDirection.Value == Direction.Forward ? Color.DeepSkyBlue : Color.Gold; + using (var pen = new Pen(borderColor, 2)) { - g.DrawEllipse(pen, rfid.Bounds.Expand(5, 5)); + g.DrawEllipse(pen, rfid.Bounds.Expand(5,5)); } } + + // 종단 RFID는 특별한 테두리 표시 + if (rfid.IsTerminal) + { + using (var pen = new Pen(Color.Red, 3)) + { + pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; + g.DrawEllipse(pen, rfid.Bounds.Expand(8,8)); + } + } + + var str = rfid.RFIDValue.ToString(); + g.DrawString(str, this.Font, Brushes.DarkGray, rfid.Bounds.X, rfid.Bounds.Y+5); } - // RFID 값 표시 - foreach (var rfid in rfidPoints) - { - var tagstr = $"{rfid.RFIDValue}"; - var fsize = g.MeasureString(tagstr, Font); - var rect = new RectangleF(rfid.Bounds.X - (fsize.Width / 2f) + 3, - rfid.Bounds.Y + 6, - fsize.Width, - fsize.Height); - g.DrawString(tagstr, Font, Brushes.WhiteSmoke, rect, new StringFormat - { - Alignment = StringAlignment.Center, - LineAlignment = StringAlignment.Center, - }); - } + } private void DrawAGV(Graphics g) @@ -1277,11 +1336,64 @@ namespace AGVControl agv.CurrentPosition.Y - halfsize, agvsize, agvsize); - // 삼각형 화살표를 위한 포인트 배열 - Point[] trianglePoints = new Point[3]; - var arrowSize = halfsize - 5; // 삼각형 크기 + // AGV 몸체 회전 각도 계산 + float bodyRotation = 0f; + if (agv.CurrentPath != null && agv.CurrentPath.Count > 1) + { + // 현재 위치에서 다음 목적지 방향 계산 + int currentIdx = agv.CurrentPath.FindIndex(p => p == agv.CurrentPosition); + if (currentIdx >= 0 && currentIdx < agv.CurrentPath.Count - 1) + { + Point nextPoint = agv.CurrentPath[currentIdx + 1]; + float deltaX = nextPoint.X - agv.CurrentPosition.X; + float deltaY = nextPoint.Y - agv.CurrentPosition.Y; + bodyRotation = (float)Math.Atan2(deltaY, deltaX) * 180f / (float)Math.PI; + } + } - // AGV의 방향에 따라 삼각형 포인트 계산 + // 그래픽스 상태 저장 + var originalTransform = g.Transform; + + // AGV 위치로 이동하고 회전 + g.TranslateTransform(agv.CurrentPosition.X, agv.CurrentPosition.Y); + g.RotateTransform(bodyRotation); + + // 원 그리기 (회전된 상태) + Color bgcolor = agv.BatteryLevel > 80 ? Color.Lime : (agv.BatteryLevel > 60 ? Color.Gold : Color.Tomato); + using (var circleBrush = new SolidBrush(Color.FromArgb(150, bgcolor))) + g.FillEllipse(circleBrush, -halfsize, -halfsize, agvsize, agvsize); + using (var circlePen = new Pen(Color.Black, 2)) + g.DrawEllipse(circlePen, -halfsize, -halfsize, agvsize, agvsize); + + // 리프트 그리기 (회전된 상태, 항상 전진 방향쪽) + var liftWidth = circleRect.Width; + var liftHeight = (int)(circleRect.Height * 0.4); + var liftOffset = halfsize + 1; + + var liftRect = new Rectangle( + -liftWidth / 2, + -halfsize - liftOffset, + liftWidth, liftHeight); + + using (var liftBrush = new SolidBrush(Color.FromArgb(200, Color.DarkGray))) + g.FillRectangle(liftBrush, liftRect); + using (var liftPen = new Pen(Color.Black, 1)) + g.DrawRectangle(liftPen, liftRect); + + // 리프트 연결선 그리기 + using (var connectionPen = new Pen(Color.Black, 2)) + { + g.DrawLine(connectionPen, 0, -halfsize, 0, -halfsize - liftOffset); + } + + // 그래픽스 상태 복원 + g.Transform = originalTransform; + + // 삼각형 화살표 그리기 (현재 이동 방향, 회전하지 않음) + Point[] trianglePoints = new Point[3]; + var arrowSize = halfsize - 5; + + // AGV의 현재 이동 방향에 따라 삼각형 포인트 계산 switch (agv.CurrentDirection) { case Direction.Forward: @@ -1296,16 +1408,6 @@ namespace AGVControl break; } - - - // 원 그리기 - Color bgcolor = agv.BatteryLevel > 80 ? Color.Lime : (agv.BatteryLevel > 60 ? Color.Gold : Color.Tomato); - using (var circleBrush = new SolidBrush(Color.FromArgb(150, bgcolor))) - g.FillEllipse(circleBrush, circleRect); - using (var circlePen = new Pen(Color.Black, 2)) - g.DrawEllipse(circlePen, circleRect); - - // 삼각형 화살표 그리기 using (var arrowBrush = new SolidBrush(Color.FromArgb(200, Color.White))) g.FillPolygon(arrowBrush, trianglePoints); using (var arrowPen = new Pen(Color.Black, 2)) @@ -1563,17 +1665,15 @@ namespace AGVControl lines.Add("[RFID_POINTS]"); foreach (var point in rfidPoints) { - lines.Add($"{point.Location.X},{point.Location.Y},{point.RFIDValue}"); + lines.Add($"{point.Location.X},{point.Location.Y},{point.RFIDValue},{point.IsRotatable},{point.FixedDirection},{point.IsTerminal}"); } // RFID 라인 저장 lines.Add("[RFID_LINES]"); foreach (var connection in rfidConnections) { - var startPoint = rfidPoints.FirstOrDefault(p => p.RFIDValue == connection.StartRFID)?.Location ?? Point.Empty; - var endPoint = rfidPoints.FirstOrDefault(p => p.RFIDValue == connection.EndRFID)?.Location ?? Point.Empty; - if (startPoint.IsEmpty || endPoint.IsEmpty) continue; - + var startPoint = rfidPoints.First(p => p.RFIDValue == connection.StartRFID).Location; + var endPoint = rfidPoints.First(p => p.RFIDValue == connection.EndRFID).Location; lines.Add($"{startPoint.X},{startPoint.Y},{endPoint.X},{endPoint.Y}," + $"{connection.StartRFID},{connection.EndRFID},{connection.IsBidirectional},{connection.Distance}"); } @@ -1625,19 +1725,38 @@ namespace AGVControl var validY = int.TryParse(rfidParts[1], out int valY); var validN = uint.TryParse(rfidParts[2], out uint valRfid); - if (validX && validY && validN) { - - if (rfidPoints.Where(t => t.RFIDValue == valRfid).Any()) { //이미존재한다 var newvalue = sb.AppendLine($"rfid중복{valRfid}"); } - AddRFIDPoint(new Point(valX, valY), valRfid); - + + var rfidPoint = new RFIDPoint + { + Location = new Point(valX, valY), + RFIDValue = valRfid + }; + + // 추가 속성 로드 (기본값 처리) + if (rfidParts.Length >= 4) + { + bool isRotatable; + bool.TryParse(rfidParts[3], out isRotatable); + rfidPoint.IsRotatable = isRotatable; + } + if (rfidParts.Length >= 5 && !string.IsNullOrEmpty(rfidParts[4])) + rfidPoint.FixedDirection = (Direction)Enum.Parse(typeof(Direction), rfidParts[4]); + if (rfidParts.Length >= 6) + { + bool isTerminal; + bool.TryParse(rfidParts[5], out isTerminal); + rfidPoint.IsTerminal = isTerminal; + } + + rfidPoints.Add(rfidPoint); } else sb.AppendLine($"[{section}] {line}"); } @@ -1908,7 +2027,8 @@ namespace AGVControl Direction = Direction.Backward, NextRFID = null, Reason = "AGV 위치 미확정(처음 기동)", - ReasonCode = AGVActionReasonCode.NoPosition + ReasonCode = AGVActionReasonCode.NoPosition, + MoveState = AGVMoveState.Run }; } @@ -1920,7 +2040,8 @@ namespace AGVControl Direction = agv.CurrentDirection, NextRFID = null, Reason = "경로 없음 또는 현재 위치 미확정", - ReasonCode = AGVActionReasonCode.NoPath + ReasonCode = AGVActionReasonCode.NoPath, + MoveState = AGVMoveState.Stop }; } @@ -1933,7 +2054,8 @@ namespace AGVControl Direction = agv.CurrentDirection, NextRFID = null, Reason = "현재 위치가 경로에 없음", - ReasonCode = AGVActionReasonCode.NotOnPath + ReasonCode = AGVActionReasonCode.NotOnPath, + MoveState = AGVMoveState.Stop }; } @@ -1948,7 +2070,11 @@ namespace AGVControl { // 목적지 바로 전 위치에서 목적지로 이동할 때의 방향 var beforeDest = agv.CurrentPath[agv.CurrentPath.Count - 2]; - Direction arriveDir = (destPoint.X > beforeDest.X) ? Direction.Forward : Direction.Backward; + float arriveDeltaX = destPoint.X - beforeDest.X; + float arriveDeltaY = destPoint.Y - beforeDest.Y; + Direction arriveDir = (Math.Abs(arriveDeltaX) > Math.Abs(arriveDeltaY)) ? + (arriveDeltaX > 0 ? Direction.Forward : Direction.Backward) : + (arriveDeltaY > 0 ? Direction.Forward : Direction.Backward); if (arriveDir != destRFID.FixedDirection.Value) { // 목적지 도달 전, 마지막 회전 가능한 RFID를 찾음 @@ -1961,7 +2087,7 @@ namespace AGVControl } if (lastRotatableIdx >= 0) { - // 회전 가능한 위치에 도달하면 NeedTurn 반환 + // 회전 가능한 위치에 도달하면 NeedTurn 반환 (STOP) if (idx == lastRotatableIdx) { var rfid = rfidPoints.FirstOrDefault(r => r.Location == agv.CurrentPath[lastRotatableIdx]); @@ -1970,35 +2096,43 @@ namespace AGVControl Direction = agv.CurrentDirection, NextRFID = rfid?.RFIDValue, Reason = "목적지 진입방향 맞추기 위해 회전 필요", - ReasonCode = AGVActionReasonCode.NeedTurn + ReasonCode = AGVActionReasonCode.NeedTurn, + MoveState = AGVMoveState.Stop }; } else if (idx < lastRotatableIdx) { - // 회전 가능한 위치까지 이동 안내 + // 회전 가능한 위치까지 이동 안내 (RUN) var rfid = rfidPoints.FirstOrDefault(r => r.Location == agv.CurrentPath[lastRotatableIdx]); + float moveDeltaX = agv.CurrentPath[lastRotatableIdx].X - agv.CurrentPosition.X; + float moveDeltaY = agv.CurrentPath[lastRotatableIdx].Y - agv.CurrentPosition.Y; + Direction moveDir = (Math.Abs(moveDeltaX) > Math.Abs(moveDeltaY)) ? + (moveDeltaX > 0 ? Direction.Forward : Direction.Backward) : + (moveDeltaY > 0 ? Direction.Forward : Direction.Backward); return new AGVActionPrediction { - Direction = (agv.CurrentPath[lastRotatableIdx].X > agv.CurrentPosition.X) ? Direction.Forward : Direction.Backward, + Direction = moveDir, NextRFID = rfid?.RFIDValue, Reason = "회전 가능한 위치로 이동 중", - ReasonCode = AGVActionReasonCode.Normal + ReasonCode = AGVActionReasonCode.Normal, + MoveState = AGVMoveState.Run }; } } - // 회전 가능한 위치가 없음 + // 회전 가능한 위치가 없음 (STOP) return new AGVActionPrediction { Direction = agv.CurrentDirection, NextRFID = null, Reason = "경로상에 회전 가능한 위치가 없음", - ReasonCode = AGVActionReasonCode.Unknown + ReasonCode = AGVActionReasonCode.NoTurnPoint, + MoveState = AGVMoveState.Stop }; } } } - // 5. 목적지 도달 시(방향이 맞는 경우) + // 5. 목적지 도달 시(방향이 맞는 경우) (STOP) if (idx == agv.CurrentPath.Count - 1) { return new AGVActionPrediction @@ -2006,21 +2140,29 @@ namespace AGVControl Direction = agv.CurrentDirection, NextRFID = null, Reason = "경로의 마지막 지점(목적지 도달)", - ReasonCode = AGVActionReasonCode.Arrived + ReasonCode = AGVActionReasonCode.Arrived, + MoveState = AGVMoveState.Stop }; } - // 6. 일반 경로 주행 + // 6. 일반 경로 주행 (RUN) Point nextPoint = agv.CurrentPath[idx + 1]; var nextRFID = rfidPoints.FirstOrDefault(r => r.Location == nextPoint)?.RFIDValue; - Direction nextDir = (nextPoint.X > agv.CurrentPosition.X) ? Direction.Forward : Direction.Backward; + + // X, Y 좌표 모두 고려한 방향 판단 + float deltaX = nextPoint.X - agv.CurrentPosition.X; + float deltaY = nextPoint.Y - agv.CurrentPosition.Y; + Direction nextDir = (Math.Abs(deltaX) > Math.Abs(deltaY)) ? + (deltaX > 0 ? Direction.Forward : Direction.Backward) : + (deltaY > 0 ? Direction.Forward : Direction.Backward); return new AGVActionPrediction { Direction = nextDir, NextRFID = nextRFID, Reason = null, - ReasonCode = AGVActionReasonCode.Normal + ReasonCode = AGVActionReasonCode.Normal, + MoveState = AGVMoveState.Run }; } #endregion diff --git a/Cs_HMI/SubProject/AGVControl/Models/AGV.cs b/Cs_HMI/SubProject/AGVControl/Models/AGV.cs index 1d1ada4..02fae10 100644 --- a/Cs_HMI/SubProject/AGVControl/Models/AGV.cs +++ b/Cs_HMI/SubProject/AGVControl/Models/AGV.cs @@ -1,9 +1,16 @@ +using System; using System.Drawing; using System.Collections.Generic; using System.Linq; namespace AGVControl.Models { + public enum Direction + { + Forward = 0, + Backward = 1 + } + public class AGV { public Point CurrentPosition { get; set; } @@ -19,12 +26,17 @@ namespace AGVControl.Models /// public Direction TargetDirection { get; set; } public bool IsMoving { get; set; } - public List CurrentPath { get; set; } + public List CurrentPath { get; set; } = new List(); public List PlannedPath { get; set; } public List PathRFIDs { get; set; } public Point TargetPosition { get; set; } public uint TargetRFID { get; set; } + // 이동 경로 기록을 위한 새로운 속성들 + public List MovementHistory { get; set; } = new List(); + public List PositionHistory { get; set; } = new List(); + public const int HISTORY_SIZE = 4; // 최근 4개 위치 기록 + public AGV() { CurrentPath = new List(); @@ -45,12 +57,179 @@ namespace AGVControl.Models } } - } + // 이동 경로에 새로운 RFID 추가 + public void AddToMovementHistory(uint rfidValue, Point position) + { + // 중복 RFID가 연속으로 들어오는 경우 무시 + if (MovementHistory.Count > 0 && MovementHistory[MovementHistory.Count - 1] == rfidValue) + return; - public enum Direction - { - Forward, - Backward + MovementHistory.Add(rfidValue); + PositionHistory.Add(position); + + // 기록 크기 제한 + if (MovementHistory.Count > HISTORY_SIZE) + { + MovementHistory.RemoveAt(0); + PositionHistory.RemoveAt(0); + } + } + + // 연결 정보 기반 실제 이동 방향 계산 + public Direction? CalculateActualDirectionByConnection(uint currentRFID, uint previousRFID, List connections) + { + if (connections == null || connections.Count == 0) + return null; + + // 이전 RFID에서 현재 RFID로의 연결 확인 + var connection = connections.FirstOrDefault(c => + (c.StartRFID == previousRFID && c.EndRFID == currentRFID) || + (c.IsBidirectional && c.StartRFID == currentRFID && c.EndRFID == previousRFID)); + + if (connection == null) + return null; // 연결되지 않은 경로 + + // 연결 방향에 따라 실제 이동 방향 결정 + if (connection.StartRFID == previousRFID && connection.EndRFID == currentRFID) + { + return Direction.Forward; // Start -> End 방향으로 이동 + } + else + { + return Direction.Backward; // End -> Start 방향으로 이동 + } + } + + // 연결 정보 기반 방향 불일치 검증 및 정정 + public bool ValidateAndCorrectDirectionByConnection(Direction expectedDirection, List connections) + { + if (MovementHistory.Count < 2 || connections == null) + return true; // 검증 불가능한 경우 + + // 최근 두 RFID 값 가져오기 + var recentRFIDs = MovementHistory.Skip(Math.Max(0, MovementHistory.Count - 2)).Take(2).ToList(); + if (recentRFIDs.Count < 2) + return true; + + var previousRFID = recentRFIDs[0]; + var currentRFID = recentRFIDs[1]; + + var actualDirection = CalculateActualDirectionByConnection(currentRFID, previousRFID, connections); + if (!actualDirection.HasValue) + return true; // 연결 정보로 방향 판단 불가 + + // 방향이 일치하지 않는 경우 + if (actualDirection.Value != expectedDirection) + { + // AGV 방향을 실제 이동 방향으로 정정 + CurrentDirection = actualDirection.Value; + TargetDirection = actualDirection.Value; + return false; // 정정됨을 알림 + } + + return true; // 방향 일치 + } + + // RFID 순서 기반 실제 이동 방향 계산 (기존 메서드 - 호환성 유지) + public Direction? CalculateActualDirectionByRFID() + { + if (MovementHistory.Count < 2) + return null; + + // 최근 두 RFID 값으로부터 실제 이동 방향 계산 + var recentRFIDs = MovementHistory.Skip(Math.Max(0, MovementHistory.Count - 2)).Take(2).ToList(); + if (recentRFIDs.Count < 2) + return null; + + var prevRFID = recentRFIDs[0]; + var currentRFID = recentRFIDs[1]; + + // RFID 값의 증가/감소로 방향 판단 + if (currentRFID > prevRFID) + { + return Direction.Forward; // RFID 값이 증가하면 전진 + } + else if (currentRFID < prevRFID) + { + return Direction.Backward; // RFID 값이 감소하면 후진 + } + else + { + return null; // 같은 RFID 값이면 방향 판단 불가 + } + } + + // 경로상 RFID 순서 기반 예상 방향 계산 + public Direction? CalculateExpectedDirectionByRFID() + { + if (CurrentPath == null || CurrentPath.Count < 2) + return null; + + // 현재 위치의 RFID 찾기 + var currentRFID = CurrentRFID; + if (currentRFID == 0) + return null; + + // 경로상 다음 RFID 찾기 + int currentIdx = CurrentPath.FindIndex(p => p == CurrentPosition); + if (currentIdx < 0 || currentIdx >= CurrentPath.Count - 1) + return null; + + // 다음 위치의 RFID 찾기 (MapControl에서 RFID 정보 필요) + // 이 부분은 MapControl에서 처리하도록 수정 필요 + return null; + } + + // 실제 이동 방향 계산 (기존 메서드 - 호환성 유지) + public Direction? CalculateActualDirection() + { + if (MovementHistory.Count < 2) + return null; + + // 최근 두 위치로부터 실제 이동 방향 계산 + var recentPositions = PositionHistory.Skip(Math.Max(0, PositionHistory.Count - 2)).Take(2).ToList(); + if (recentPositions.Count < 2) + return null; + + var prevPos = recentPositions[0]; + var currentPos = recentPositions[1]; + + // X축 이동이 더 큰 경우 + if (Math.Abs(currentPos.X - prevPos.X) > Math.Abs(currentPos.Y - prevPos.Y)) + { + return currentPos.X > prevPos.X ? Direction.Forward : Direction.Backward; + } + // Y축 이동이 더 큰 경우 + else + { + return currentPos.Y > prevPos.Y ? Direction.Forward : Direction.Backward; + } + } + + // 경로상 예상 방향 계산 + public Direction? CalculateExpectedDirection() + { + if (CurrentPath == null || CurrentPath.Count < 2) + return null; + + int currentIdx = CurrentPath.FindIndex(p => p == CurrentPosition); + if (currentIdx < 0 || currentIdx >= CurrentPath.Count - 1) + return null; + + var currentPos = CurrentPath[currentIdx]; + var nextPos = CurrentPath[currentIdx + 1]; + + // X축 이동이 더 큰 경우 + if (Math.Abs(nextPos.X - currentPos.X) > Math.Abs(nextPos.Y - currentPos.Y)) + { + return nextPos.X > currentPos.X ? Direction.Forward : Direction.Backward; + } + // Y축 이동이 더 큰 경우 + else + { + return nextPos.Y > currentPos.Y ? Direction.Forward : Direction.Backward; + } + } } public class PathNode diff --git a/Cs_HMI/SubProject/AGVControl/Models/RFIDPoint.cs b/Cs_HMI/SubProject/AGVControl/Models/RFIDPoint.cs index fae5d37..87e05ef 100644 --- a/Cs_HMI/SubProject/AGVControl/Models/RFIDPoint.cs +++ b/Cs_HMI/SubProject/AGVControl/Models/RFIDPoint.cs @@ -11,6 +11,7 @@ namespace AGVControl.Models public bool IsBidirectional { get; set; } // 양방향 연결 여부 public bool IsRotatable { get; set; } // 회전 가능 여부 public Direction? FixedDirection { get; set; } // 고정 방향(없으면 null) + public bool IsTerminal { get; set; } // 종단 여부 public RectangleF Bounds { get; set; } public RFIDPoint() @@ -18,6 +19,7 @@ namespace AGVControl.Models IsRotatable = false; // 기본값은 회전 불가능 IsBidirectional = true; // 기본값은 양방향 FixedDirection = null; + IsTerminal = false; // 기본값은 종단 아님 } } } \ No newline at end of file diff --git a/Cs_HMI/SubProject/BMS/BMS.cs b/Cs_HMI/SubProject/BMS/BMS.cs index c20eee5..ad2967c 100644 --- a/Cs_HMI/SubProject/BMS/BMS.cs +++ b/Cs_HMI/SubProject/BMS/BMS.cs @@ -200,6 +200,14 @@ namespace arDev Current_LevelA = LastReceiveBuffer[23]; //<- 23번자료는 byte이므로 소수점이잇는 데이터로 직접 계산한다 Current_DataTime = DateTime.Now; + + //250620 jwlee 추가 + int temp1 = (LastReceiveBuffer[27] << 8) | LastReceiveBuffer[28]; + int temp2 = (LastReceiveBuffer[29] << 8) | LastReceiveBuffer[30]; + + Current_temp1 = (temp1 - 2731) / 10f; + Current_temp2 = (temp2 - 2731) / 10f; + CheckManualCharge(); Recv0 = true; @@ -333,6 +341,16 @@ namespace arDev /// public int Current_Amp { get; set; } + /// + /// BMS 온도값1 + /// + public double Current_temp1 { get; set; } + + /// + /// BMS 온도값2 + /// + public double Current_temp2 { get; set; } + /// /// 총 전류량 /// diff --git a/Cs_HMI/SubProject/BMS/BMS.csproj b/Cs_HMI/SubProject/BMS/BMS.csproj index 8b9baea..a10e852 100644 --- a/Cs_HMI/SubProject/BMS/BMS.csproj +++ b/Cs_HMI/SubProject/BMS/BMS.csproj @@ -46,12 +46,7 @@ - - - - {14e8c9a5-013e-49ba-b435-efefc77dd623} - CommData - + \ No newline at end of file diff --git a/Cs_HMI/SubProject/BMS/RS232.cs b/Cs_HMI/SubProject/BMS/RS232.cs new file mode 100644 index 0000000..0cd07a5 --- /dev/null +++ b/Cs_HMI/SubProject/BMS/RS232.cs @@ -0,0 +1,485 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel; +using System.Threading; +using System.Threading.Tasks; + +public abstract partial class arRS232 : IDisposable +{ + protected System.IO.Ports.SerialPort _device; + protected ManualResetEvent _mre; + protected byte[] LastReceiveBuffer = new byte[] { }; + /// + /// 최종 전송 메세지 + /// + public byte[] lastSendBuffer = new byte[] { }; + + protected List tempBuffer = new List(); + protected Boolean findSTX = false; + public string errorMessage { get; set; } + public DateTime LastConnTime { get; set; } + public DateTime LastConnTryTime { get; set; } + public DateTime lastSendTime; + /// + /// 메세지 수신시 사용하는 내부버퍼 + /// + protected List _buffer = new List(); + + + // public byte[] LastRecvData; + public string LastRecvString + { + get + { + if (LastReceiveBuffer == null) return String.Empty; + else return System.Text.Encoding.Default.GetString(LastReceiveBuffer); + } + } + /// + /// 마지막으로 데이터를 받은 시간 + /// + public DateTime lastRecvTime; + + + public int WriteError = 0; + public string WriteErrorMessage = string.Empty; + public int WaitTimeout { get; set; } = 1000; + public int MinRecvLength { get; set; } = 1; + /// + /// 포트이름 + /// + [Description("시리얼 포트 이름")] + [Category("설정"), DisplayName("Port Name")] + public string PortName + { + get + { + if (_device == null) return string.Empty; + else return _device.PortName; + } + set + { + if (this.IsOpen) + { + Message?.Invoke(this, new MessageEventArgs("포트가 열려있어 포트이름을 변경할 수 없습니다", true)); + } + else if (String.IsNullOrEmpty(value) == false) + _device.PortName = value; + else + { + Message?.Invoke(this, new MessageEventArgs("No PortName", true)); + } + } + } + + public int BaudRate + { + get + { + if (_device == null) return 0; + else return _device.BaudRate; + } + set + { + if (this.IsOpen) + { + Message?.Invoke(this, new MessageEventArgs("포트가 열려있어 BaudRate(를) 변경할 수 없습니다", true)); + } + else if (value != 0) + _device.BaudRate = value; + else Message?.Invoke(this, new MessageEventArgs("No baud rate", true)); + } + } + + + public arRS232() + { + _device = new System.IO.Ports.SerialPort(); + this.BaudRate = 9600; + + _device.DataReceived += barcode_DataReceived; + _device.ErrorReceived += this.barcode_ErrorReceived; + _device.WriteTimeout = 5000; + _device.ReadTimeout = 5000; + // _device.DtrEnable = false; + _device.ReadBufferSize = 8192; + _device.WriteBufferSize = 8192; + + errorMessage = string.Empty; + lastRecvTime = DateTime.Parse("1982-11-23"); + LastConnTime = DateTime.Parse("1982-11-23"); + LastConnTryTime = DateTime.Parse("1982-11-23"); + lastRecvTime = DateTime.Parse("1982-11-23"); + this._mre = new ManualResetEvent(true); + } + + ~arRS232() + { + Dispose(false); + } + + + // Flag: Has Dispose already been called? + bool disposed = false; + + // Public implementation of Dispose pattern callable by consumers. + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + // Protected implementation of Dispose pattern. + protected virtual void Dispose(bool disposing) + { + if (disposed) + return; + + if (disposing) + { + // Free any other managed objects here. + // + } + + _device.DataReceived -= barcode_DataReceived; + _device.ErrorReceived -= this.barcode_ErrorReceived; + + // Free any unmanaged objects here. + // + disposed = true; + } + + public Boolean Open() + { + try + { + _device.Open(); + return IsOpen; + } + catch (Exception ex) + { + errorMessage = ex.Message; + Message.Invoke(this, new MessageEventArgs(ex.Message, true)); + return false; + } + } + public string GetHexString(Byte[] input) + { + System.Text.StringBuilder sb = new System.Text.StringBuilder(); + foreach (byte b in input) + sb.Append(" " + b.ToString("X2")); + return sb.ToString(); + } + + /// + /// 포트가 열려있는지 확인 + /// + [Description("현재 시리얼포트가 열려있는지 확인합니다")] + [Category("정보"), DisplayName("Port Open")] + public Boolean IsOpen + { + get + { + if (_device == null) return false; + return _device.IsOpen; + } + } + + public virtual void Close(Boolean PortClose = true) + { + if (_device != null && _device.IsOpen) + { + _device.DiscardInBuffer(); + _device.DiscardOutBuffer(); + if (PortClose) _device.Close(); //dispose에서는 포트를 직접 클리어하지 않게 해뒀다. + } + } + protected Boolean RaiseRecvData() + { + return RaiseRecvData(LastReceiveBuffer.ToArray(), false); + } + /// + /// 수신받은 메세지를 발생 시킵니다 + /// + /// + /// + public virtual Boolean RaiseRecvData(byte[] Data, bool udpatelastbuffer) + { + //181206 - 최종수신 메세지 기록 + lastRecvTime = DateTime.Now; + if (udpatelastbuffer && Data != null) + { + if (LastReceiveBuffer == null || LastReceiveBuffer.Length != Data.Length) + { + LastReceiveBuffer = new byte[Data.Length]; + Array.Copy(Data, LastReceiveBuffer, Data.Length); + } + } + + try + { + Message?.Invoke(this, new MessageEventArgs(Data, true)); //recvmessage + if (ProcessRecvData(Data) == false) + { + //Message?.Invoke(this, new MessageEventArgs(Data, true)); //recvmessage + Message?.Invoke(this, new MessageEventArgs(this.errorMessage, true)); //errormessage + return false; + } + else + { + + return true; + } + } + catch (Exception ex) + { + this.errorMessage = ex.Message; + this.Message?.Invoke(this, new MessageEventArgs(ex.Message, true)); + return false; + } + } + + /// + /// 수신받은 자료를 처리한다 + /// + /// + /// + public abstract bool ProcessRecvData(byte[] data); + + #region "Internal Events" + + void barcode_ErrorReceived(object sender, System.IO.Ports.SerialErrorReceivedEventArgs e) + { + Message?.Invoke(this, new MessageEventArgs(e.ToString(), true)); + } + + byte[] buffer = new byte[] { }; + void barcode_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) + { + + try + { + int ReadCount = _device.BytesToRead; + + buffer = new byte[ReadCount]; + _device.Read(buffer, 0, buffer.Length); + + System.Text.StringBuilder LogMsg = new StringBuilder(); + + byte[] remainBuffer; + Repeat: + if (CustomParser(buffer, out remainBuffer)) + { + //분석완료이므로 받은 데이터를 버퍼에 기록한다 + if (LastReceiveBuffer == null || (LastReceiveBuffer.Length != tempBuffer.Count)) + Array.Resize(ref LastReceiveBuffer, tempBuffer.Count); + Array.Copy(tempBuffer.ToArray(), LastReceiveBuffer, tempBuffer.Count); + tempBuffer.Clear(); + + //수신메세지발생 + RaiseRecvData(); + if (remainBuffer != null && remainBuffer.Length > 0) + { + //버퍼를 변경해서 다시 전송을 해준다. + Array.Resize(ref buffer, remainBuffer.Length); + Array.Copy(remainBuffer, buffer, remainBuffer.Length); + goto Repeat; //남은 버퍼가 있다면 진행을 해준다. + } + } + + } + catch (Exception ex) + { + if (IsOpen) + { + //_device.DiscardInBuffer(); + //_device.DiscardOutBuffer(); + } + errorMessage = ex.Message; + this.Message?.Invoke(this, new MessageEventArgs(ex.Message, true)); + } + + } + + + #endregion + + #region "External Events" + + + /// + /// 오류 및 기타 일반 메세지 + /// + public event EventHandler Message; + + #endregion + + #region "Event Args" + + /// + /// 데이터를 수신할떄 사용함(RAW 포함) + /// + public class ReceiveDataEventArgs : EventArgs + { + private byte[] _buffer = null; + + /// + /// 바이트배열의 버퍼값 + /// + public byte[] Value { get { return _buffer; } } + + /// + /// 버퍼(바이트배열)의 데이터를 문자로 반환합니다. + /// + public string StrValue + { + get + { + //return string.Empty; + + if (_buffer == null || _buffer.Length < 1) return string.Empty; + else return System.Text.Encoding.Default.GetString(_buffer); + } + } + public ReceiveDataEventArgs(byte[] buffer) + { + _buffer = buffer; + } + } + + /// + /// 메세지를 강제 발생 + /// + /// + /// + protected virtual void RaiseMessage(MessageType mt, string message) + { + this.Message?.Invoke(this, new MessageEventArgs(mt, message)); + } + public enum MessageType + { + Normal, + Error, + Send, + Recv, + } + + public class MessageEventArgs : EventArgs + { + public MessageType MsgType { get; set; } + private string _message = string.Empty; + + /// + /// Recv,Send,Normal,Error 모두 지원 + /// + public string Message { get { return _message; } } + + private byte[] _data = null; + + /// + /// Recv,Send에서만 값이 존재 합니다 + /// + public byte[] Data { get { return _data; } } + public MessageEventArgs(string Message, bool isError = false) + { + if (isError) MsgType = MessageType.Error; + else MsgType = MessageType.Normal; + _message = Message; + } + public MessageEventArgs(MessageType msgtype, string Message) + { + MsgType = msgtype; + _message = Message; + _data = System.Text.Encoding.Default.GetBytes(Message); + } + + public MessageEventArgs(byte[] buffer, bool isRecv = true) + { + if (isRecv) MsgType = MessageType.Recv; + else MsgType = MessageType.Send; + _data = new byte[buffer.Length]; + Array.Copy(buffer, _data, Data.Length); + _message = System.Text.Encoding.Default.GetString(_data); + } + + } + + #endregion + + + + protected abstract bool CustomParser(byte[] buf, out byte[] remainBuffer); + + /// + /// 데이터수신시간이 설정값보다 x 2.5를 초과하면 false 가 반환됨 + /// + public Boolean IsValid + { + get + { + if (IsOpen == false) return false; + if (lastRecvTime.Year == 1982) return false; + var ts = DateTime.Now - lastRecvTime; + if (ts.TotalSeconds > 5) return false; + return true; + } + } + protected bool WriteData(string cmd) + { + return WriteData(System.Text.Encoding.Default.GetBytes(cmd)); + } + /// + /// 포트에 쓰기(barcode_DataReceived 이벤트로 메세지수신) + /// + protected Boolean WriteData(byte[] data) + { + Boolean bRet = false; + + //171205 : 타임아웃시간추가 + if (!_mre.WaitOne(WaitTimeout)) + { + errorMessage = $"WriteData:MRE:WaitOne:TimeOut {WaitTimeout}ms"; + this.Message?.Invoke(this, new MessageEventArgs(errorMessage, true)); + return false; + } + + _mre.Reset(); + + //Array.Resize(ref data, data.Length + 2); + + try + { + lastSendTime = DateTime.Now; + if (lastSendBuffer == null) lastSendBuffer = new byte[data.Length]; //171113 + else Array.Resize(ref lastSendBuffer, data.Length); + Array.Copy(data, lastSendBuffer, data.Length); + + for (int i = 0; i < data.Length; i++) + _device.Write(data, i, 1); + + //_device.Write(data, 0, data.Length); + + //171113 + this.Message?.Invoke(this, new MessageEventArgs(data, false)); + + bRet = true; + WriteError = 0; + WriteErrorMessage = string.Empty; + } + catch (Exception ex) + { + // this.isinit = false; + this.Message?.Invoke(this, new MessageEventArgs(ex.Message, true)); + bRet = false; + WriteError += 1; //연속쓰기오류횟수 + WriteErrorMessage = ex.Message; + } + finally + { + _mre.Set(); + } + return bRet; + } +} \ No newline at end of file diff --git a/Emulator/AGVEmulator/Form1.Designer.cs b/Emulator/AGVEmulator/Form1.Designer.cs index 61e522c..b71d024 100644 --- a/Emulator/AGVEmulator/Form1.Designer.cs +++ b/Emulator/AGVEmulator/Form1.Designer.cs @@ -30,34 +30,34 @@ namespace AGVEmulator private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - AGVEmulator.UC.AgvViewer.ptdata ptdata1 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata2 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata3 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata4 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata5 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata6 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata7 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata8 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata9 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata10 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata11 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata12 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata13 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata14 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata15 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata16 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata17 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata18 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata19 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata20 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata21 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata22 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata23 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata24 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata25 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata26 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata27 = new AGVEmulator.UC.AgvViewer.ptdata(); - AGVEmulator.UC.AgvViewer.ptdata ptdata28 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata85 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata86 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata87 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata88 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata89 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata90 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata91 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata92 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata93 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata94 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata95 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata96 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata97 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata98 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata99 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata100 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata101 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata102 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata103 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata104 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata105 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata106 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata107 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata108 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata109 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata110 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata111 = new AGVEmulator.UC.AgvViewer.ptdata(); + AGVEmulator.UC.AgvViewer.ptdata ptdata112 = new AGVEmulator.UC.AgvViewer.ptdata(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.rtBMS = new arCtl.LogTextBox(); @@ -132,6 +132,8 @@ namespace AGVEmulator this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage3 = new System.Windows.Forms.TabPage(); this.panel3 = new System.Windows.Forms.Panel(); + this.nudIDAgv = new System.Windows.Forms.NumericUpDown(); + this.label7 = new System.Windows.Forms.Label(); this.numericUpDown2 = new System.Windows.Forms.NumericUpDown(); this.button1 = new System.Windows.Forms.Button(); this.nudTagNo = new System.Windows.Forms.NumericUpDown(); @@ -152,8 +154,12 @@ namespace AGVEmulator this.sbBMS = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); this.sbCAL = new System.Windows.Forms.ToolStripStatusLabel(); - this.label7 = new System.Windows.Forms.Label(); - this.nudIDAgv = new System.Windows.Forms.NumericUpDown(); + this.trbT1 = new System.Windows.Forms.TrackBar(); + this.trbT2 = new System.Windows.Forms.TrackBar(); + this.label8 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.label11 = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit(); @@ -179,11 +185,13 @@ namespace AGVEmulator this.tabPage2.SuspendLayout(); this.tabPage3.SuspendLayout(); this.panel3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nudIDAgv)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudTagNo)).BeginInit(); this.toolStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.nudIDAgv)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.trbT1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.trbT2)).BeginInit(); this.SuspendLayout(); // // groupBox1 @@ -221,6 +229,12 @@ namespace AGVEmulator // // panel1 // + this.panel1.Controls.Add(this.label11); + this.panel1.Controls.Add(this.label10); + this.panel1.Controls.Add(this.label9); + this.panel1.Controls.Add(this.label8); + this.panel1.Controls.Add(this.trbT2); + this.panel1.Controls.Add(this.trbT1); this.panel1.Controls.Add(this.btc8); this.panel1.Controls.Add(this.btc4); this.panel1.Controls.Add(this.btc7); @@ -1016,120 +1030,120 @@ namespace AGVEmulator this.agvViewer1.lastmarkdir = ""; this.agvViewer1.lasttag = ""; this.agvViewer1.lasttagdir = ""; - ptdata1.active = false; - ptdata1.data = "NOT"; - ptdata1.pos = 30F; - ptdata2.active = false; - ptdata2.data = "QA"; - ptdata2.pos = 200F; - ptdata3.active = false; - ptdata3.data = "CHG"; - ptdata3.pos = 300F; - ptdata4.active = false; - ptdata4.data = "QC"; - ptdata4.pos = 400F; - ptdata5.active = false; - ptdata5.data = "#FVI-1"; - ptdata5.pos = 500F; - ptdata6.active = false; - ptdata6.data = "#FVI-2"; - ptdata6.pos = 600F; - ptdata7.active = false; - ptdata7.data = "#FVI-3"; - ptdata7.pos = 700F; - ptdata8.active = false; - ptdata8.data = "#FVI-4"; - ptdata8.pos = 800F; - ptdata9.active = false; - ptdata9.data = "#FVI-5"; - ptdata9.pos = 900F; - ptdata10.active = false; - ptdata10.data = "POT"; - ptdata10.pos = 970F; + ptdata85.active = false; + ptdata85.data = "NOT"; + ptdata85.pos = 30F; + ptdata86.active = false; + ptdata86.data = "QA"; + ptdata86.pos = 200F; + ptdata87.active = false; + ptdata87.data = "CHG"; + ptdata87.pos = 300F; + ptdata88.active = false; + ptdata88.data = "QC"; + ptdata88.pos = 400F; + ptdata89.active = false; + ptdata89.data = "#FVI-1"; + ptdata89.pos = 500F; + ptdata90.active = false; + ptdata90.data = "#FVI-2"; + ptdata90.pos = 600F; + ptdata91.active = false; + ptdata91.data = "#FVI-3"; + ptdata91.pos = 700F; + ptdata92.active = false; + ptdata92.data = "#FVI-4"; + ptdata92.pos = 800F; + ptdata93.active = false; + ptdata93.data = "#FVI-5"; + ptdata93.pos = 900F; + ptdata94.active = false; + ptdata94.data = "POT"; + ptdata94.pos = 970F; this.agvViewer1.listMRK = new AGVEmulator.UC.AgvViewer.ptdata[] { - ptdata1, - ptdata2, - ptdata3, - ptdata4, - ptdata5, - ptdata6, - ptdata7, - ptdata8, - ptdata9, - ptdata10}; - ptdata11.active = false; - ptdata11.data = "9000"; - ptdata11.pos = 80F; - ptdata12.active = false; - ptdata12.data = "9001"; - ptdata12.pos = 120F; - ptdata13.active = false; - ptdata13.data = "9010"; - ptdata13.pos = 180F; - ptdata14.active = false; - ptdata14.data = "9011"; - ptdata14.pos = 220F; - ptdata15.active = false; - ptdata15.data = "9020"; - ptdata15.pos = 280F; - ptdata16.active = false; - ptdata16.data = "9021"; - ptdata16.pos = 320F; - ptdata17.active = false; - ptdata17.data = "9030"; - ptdata17.pos = 380F; - ptdata18.active = false; - ptdata18.data = "9031"; - ptdata18.pos = 420F; - ptdata19.active = false; - ptdata19.data = "9040"; - ptdata19.pos = 480F; - ptdata20.active = false; - ptdata20.data = "9041"; - ptdata20.pos = 520F; - ptdata21.active = false; - ptdata21.data = "9050"; - ptdata21.pos = 580F; - ptdata22.active = false; - ptdata22.data = "9051"; - ptdata22.pos = 620F; - ptdata23.active = false; - ptdata23.data = "9060"; - ptdata23.pos = 680F; - ptdata24.active = false; - ptdata24.data = "9061"; - ptdata24.pos = 720F; - ptdata25.active = false; - ptdata25.data = "9070"; - ptdata25.pos = 780F; - ptdata26.active = false; - ptdata26.data = "9071"; - ptdata26.pos = 820F; - ptdata27.active = false; - ptdata27.data = "9000"; - ptdata27.pos = 10F; - ptdata28.active = false; - ptdata28.data = "9001"; - ptdata28.pos = 50F; + ptdata85, + ptdata86, + ptdata87, + ptdata88, + ptdata89, + ptdata90, + ptdata91, + ptdata92, + ptdata93, + ptdata94}; + ptdata95.active = false; + ptdata95.data = "9000"; + ptdata95.pos = 80F; + ptdata96.active = false; + ptdata96.data = "9001"; + ptdata96.pos = 120F; + ptdata97.active = false; + ptdata97.data = "9010"; + ptdata97.pos = 180F; + ptdata98.active = false; + ptdata98.data = "9011"; + ptdata98.pos = 220F; + ptdata99.active = false; + ptdata99.data = "9020"; + ptdata99.pos = 280F; + ptdata100.active = false; + ptdata100.data = "9021"; + ptdata100.pos = 320F; + ptdata101.active = false; + ptdata101.data = "9030"; + ptdata101.pos = 380F; + ptdata102.active = false; + ptdata102.data = "9031"; + ptdata102.pos = 420F; + ptdata103.active = false; + ptdata103.data = "9040"; + ptdata103.pos = 480F; + ptdata104.active = false; + ptdata104.data = "9041"; + ptdata104.pos = 520F; + ptdata105.active = false; + ptdata105.data = "9050"; + ptdata105.pos = 580F; + ptdata106.active = false; + ptdata106.data = "9051"; + ptdata106.pos = 620F; + ptdata107.active = false; + ptdata107.data = "9060"; + ptdata107.pos = 680F; + ptdata108.active = false; + ptdata108.data = "9061"; + ptdata108.pos = 720F; + ptdata109.active = false; + ptdata109.data = "9070"; + ptdata109.pos = 780F; + ptdata110.active = false; + ptdata110.data = "9071"; + ptdata110.pos = 820F; + ptdata111.active = false; + ptdata111.data = "9000"; + ptdata111.pos = 10F; + ptdata112.active = false; + ptdata112.data = "9001"; + ptdata112.pos = 50F; this.agvViewer1.listTAG = new AGVEmulator.UC.AgvViewer.ptdata[] { - ptdata11, - ptdata12, - ptdata13, - ptdata14, - ptdata15, - ptdata16, - ptdata17, - ptdata18, - ptdata19, - ptdata20, - ptdata21, - ptdata22, - ptdata23, - ptdata24, - ptdata25, - ptdata26, - ptdata27, - ptdata28}; + ptdata95, + ptdata96, + ptdata97, + ptdata98, + ptdata99, + ptdata100, + ptdata101, + ptdata102, + ptdata103, + ptdata104, + ptdata105, + ptdata106, + ptdata107, + ptdata108, + ptdata109, + ptdata110, + ptdata111, + ptdata112}; this.agvViewer1.Location = new System.Drawing.Point(241, 0); this.agvViewer1.Name = "agvViewer1"; this.agvViewer1.Size = new System.Drawing.Size(899, 120); @@ -1192,6 +1206,34 @@ namespace AGVEmulator this.panel3.Size = new System.Drawing.Size(364, 622); this.panel3.TabIndex = 15; // + // nudIDAgv + // + this.nudIDAgv.Font = new System.Drawing.Font("굴림", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.nudIDAgv.Location = new System.Drawing.Point(6, 249); + this.nudIDAgv.Maximum = new decimal(new int[] { + 9999999, + 0, + 0, + 0}); + this.nudIDAgv.Name = "nudIDAgv"; + this.nudIDAgv.Size = new System.Drawing.Size(98, 38); + this.nudIDAgv.TabIndex = 13; + this.nudIDAgv.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.nudIDAgv.Value = new decimal(new int[] { + 10, + 0, + 0, + 0}); + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(32, 220); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(45, 12); + this.label7.TabIndex = 12; + this.label7.Text = "AGV ID"; + // // numericUpDown2 // this.numericUpDown2.Font = new System.Drawing.Font("굴림", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129))); @@ -1388,33 +1430,69 @@ namespace AGVEmulator this.sbCAL.Size = new System.Drawing.Size(19, 17); this.sbCAL.Text = "●"; // - // label7 + // trbT1 // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(32, 220); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(45, 12); - this.label7.TabIndex = 12; - this.label7.Text = "AGV ID"; + this.trbT1.LargeChange = 10; + this.trbT1.Location = new System.Drawing.Point(442, 7); + this.trbT1.Maximum = 990; + this.trbT1.Name = "trbT1"; + this.trbT1.Size = new System.Drawing.Size(172, 45); + this.trbT1.SmallChange = 5; + this.trbT1.TabIndex = 14; + this.trbT1.Value = 200; + this.trbT1.Scroll += new System.EventHandler(this.trbT1_Scroll); // - // nudIDAgv + // trbT2 // - this.nudIDAgv.Font = new System.Drawing.Font("굴림", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129))); - this.nudIDAgv.Location = new System.Drawing.Point(6, 249); - this.nudIDAgv.Maximum = new decimal(new int[] { - 9999999, - 0, - 0, - 0}); - this.nudIDAgv.Name = "nudIDAgv"; - this.nudIDAgv.Size = new System.Drawing.Size(98, 38); - this.nudIDAgv.TabIndex = 13; - this.nudIDAgv.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - this.nudIDAgv.Value = new decimal(new int[] { - 10, - 0, - 0, - 0}); + this.trbT2.LargeChange = 10; + this.trbT2.Location = new System.Drawing.Point(442, 58); + this.trbT2.Maximum = 990; + this.trbT2.Name = "trbT2"; + this.trbT2.Size = new System.Drawing.Size(172, 45); + this.trbT2.SmallChange = 5; + this.trbT2.TabIndex = 15; + this.trbT2.Value = 200; + this.trbT2.Scroll += new System.EventHandler(this.trbT2_Scroll); + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(392, 18); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(44, 12); + this.label8.TabIndex = 16; + this.label8.Text = "Temp1"; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(391, 72); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(44, 12); + this.label9.TabIndex = 17; + this.label9.Text = "Temp2"; + // + // label10 + // + this.label10.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.label10.ForeColor = System.Drawing.Color.White; + this.label10.Location = new System.Drawing.Point(620, 12); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(75, 24); + this.label10.TabIndex = 18; + this.label10.Text = "Curr"; + this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label11 + // + this.label11.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.label11.ForeColor = System.Drawing.Color.White; + this.label11.Location = new System.Drawing.Point(620, 68); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(75, 24); + this.label11.TabIndex = 19; + this.label11.Text = "Curr"; + this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // Form1 // @@ -1462,13 +1540,15 @@ namespace AGVEmulator this.tabPage3.ResumeLayout(false); this.panel3.ResumeLayout(false); this.panel3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nudIDAgv)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nudTagNo)).EndInit(); this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.nudIDAgv)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.trbT1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.trbT2)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -1571,6 +1651,12 @@ namespace AGVEmulator private System.Windows.Forms.Button button1; private System.Windows.Forms.Label label7; private System.Windows.Forms.NumericUpDown nudIDAgv; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.TrackBar trbT2; + private System.Windows.Forms.TrackBar trbT1; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.Label label10; } } diff --git a/Emulator/AGVEmulator/Form1.cs b/Emulator/AGVEmulator/Form1.cs index a11d1a9..337ad4a 100644 --- a/Emulator/AGVEmulator/Form1.cs +++ b/Emulator/AGVEmulator/Form1.cs @@ -101,6 +101,8 @@ namespace AGVEmulator serAGV.BaudRate = 57600; // serPLC.BaudRate = 57600; trackBar1_Scroll(null, null); + trbT2_Scroll(null, null); + trbT1_Scroll(null, null); timer1.Start(); //plc inout 이름 설정 @@ -219,7 +221,7 @@ namespace AGVEmulator agvViewer1.MarkTouched += AgvViewer1_MarkTouched; agvViewer1.Command += AgvViewer1_Command; } - + void MakeViewer() { //태그목록 @@ -340,7 +342,7 @@ namespace AGVEmulator button18.PerformClick(); } - + char GetGroupItemCheckbox(GroupBox grp) @@ -411,8 +413,8 @@ namespace AGVEmulator - - + + private void button5_Click(object sender, EventArgs e) { AGV.WriteData("ACK"); @@ -474,7 +476,7 @@ namespace AGVEmulator - + private void Form1_FormClosed(object sender, FormClosedEventArgs e) { @@ -568,15 +570,30 @@ namespace AGVEmulator private void button6_Click(object sender, EventArgs e) { var target = (byte)nudIDAgv.Value; - var tagno =(uint) nudTagNo.Value; - this.XBE.SendGotoTag( target, tagno); + var tagno = (uint)nudTagNo.Value; + this.XBE.SendGotoTag(target, tagno); } private void button1_Click(object sender, EventArgs e) { var target = (byte)nudIDAgv.Value; var tagno = (uint)numericUpDown2.Value; - this.XBE.SendCurrentPos(target,tagno); + this.XBE.SendCurrentPos(target, tagno); + } + + UInt16 Temp1, Temp2; + private void trbT1_Scroll(object sender, EventArgs e) + { + //값에 /10해서 표시한다. + Temp1 =(UInt16) trbT1.Value; + label10.Text = $"{Temp1 / 10f}º"; + + } + + private void trbT2_Scroll(object sender, EventArgs e) + { + Temp2 = (UInt16)trbT2.Value; + label11.Text = $"{Temp2 / 10f}º"; } private void toolStripButton1_Click(object sender, EventArgs e) diff --git a/Emulator/AGVEmulator/RunCode/_BMS.cs b/Emulator/AGVEmulator/RunCode/_BMS.cs index b1cd756..638be43 100644 --- a/Emulator/AGVEmulator/RunCode/_BMS.cs +++ b/Emulator/AGVEmulator/RunCode/_BMS.cs @@ -26,6 +26,7 @@ namespace AGVEmulator this.cellvolt[i] = (UInt16)rnd.Next(3300, 3350); } Array.Copy(this.cellvolt, 0, e.cellVolt, 0, 8); + this.btc1.Invoke(new Action(() => { var idx = 0; @@ -53,6 +54,8 @@ namespace AGVEmulator e.MaxA = (int)BMS_MaxA; e.Remain = BMS_Remain; e.Volt = BMS_Volt; + e.Temp1 = this.Temp1; + e.Temp2 = this.Temp2; } diff --git a/Emulator/AGVEmulator/devBMS.cs b/Emulator/AGVEmulator/devBMS.cs index 0b00cc0..c21351b 100644 --- a/Emulator/AGVEmulator/devBMS.cs +++ b/Emulator/AGVEmulator/devBMS.cs @@ -14,12 +14,16 @@ namespace AGVEmulator public float Remain { get; set; } public int CurA { get; set; } public int MaxA { get; set; } + public UInt16 Temp1 { get; set; } + public UInt16 Temp2 { get; set; } public RequestBatteryDataArgs() { this.Volt = 25; this.Remain = 79f; this.CurA = 40; this.MaxA = 80; + Temp1 = 0; + Temp2 = 0; } } public class RequestVoltageDataArgs : EventArgs @@ -52,8 +56,8 @@ namespace AGVEmulator var barrFD77 = sampleFD77.Split(' ').ToList().Select(t => Convert.ToByte(t, 16)).ToArray(); //normal if (data.First() != 0xDD || data.Last() != 0x77) - { - RaiseMessage(MessageType.Error, "stx,etx error"); + { + RaiseMessage(MessageType.Error, $"stx,etx error data={data.HexString()}"); return false; } var sts = data[1]; @@ -89,6 +93,14 @@ namespace AGVEmulator var perc = (byte)(int)p.Remain; Array.Copy(new byte[] { perc }, 0, basic_payload, 19, 1); + //temp1 + var temp1 = BitConverter.GetBytes((UInt16)(p.Temp1 + 2731)).Reverse().ToArray(); + Array.Copy(temp1, 0, basic_payload, 23,2); + + //temp2 + var temp2 = BitConverter.GetBytes((UInt16)(p.Temp2 + 2731)).Reverse().ToArray(); + Array.Copy(temp2, 0, basic_payload, 25, 2); + var datalen = (byte)basic_payload.Length; var payload_cs = new List(); payload_cs.Add(datalen); @@ -115,7 +127,7 @@ namespace AGVEmulator //Array.Copy(BitConverter.GetBytes(chksum).Reverse().ToArray(), 0, barrFD77, 20, 2); - RaiseMessage(MessageType.Normal, $"Volt:{p.Volt}v,Remain:{p.Remain}%"); + RaiseMessage(MessageType.Normal, $"Volt:{p.Volt}v,Remain:{p.Remain}%,temp1:{p.Temp1/10f},Temp2:{p.Temp2/10f}"); var sendstr = System.Text.Encoding.Default.GetString(barr0D); RaiseMessage(MessageType.Normal, "Tx:" + barr0D.HexString()); @@ -137,7 +149,7 @@ namespace AGVEmulator { var volt = p.cellVolt[i]; var arr_cellvolt = BitConverter.GetBytes(volt).Reverse().ToArray(); - Array.Copy(arr_cellvolt, 0, payload, ( i * 2), arr_cellvolt.Length); + Array.Copy(arr_cellvolt, 0, payload, (i * 2), arr_cellvolt.Length); } //makechecksum