From c4319f52d0a7513f66949cdb6673900c88716216 Mon Sep 17 00:00:00 2001 From: shark219-hub Date: Thu, 28 Nov 2024 17:31:14 +0900 Subject: [PATCH] =?UTF-8?q?KA=20=ED=95=A9=EC=82=B0=20=EA=B0=92=EC=9D=84=20?= =?UTF-8?q?1000=20=EB=B0=B0=ED=95=98=EC=97=AC=20Indicator=20=EB=A1=9C=20?= =?UTF-8?q?=EC=A0=84=EC=86=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TEST/DigitalIndicator/Form1.cs | 8 ++------ cVMS.NET_CS/Device/DigitalIndicator.cs | 15 +++++++------- cVMS.NET_CS/HMI/MainDisplay/DispCtrl.cs | 17 ---------------- cVMS.NET_CS/RunCode/Step/_STEP_RUN.cs | 23 +++++++++++----------- cVMS.NET_CS/Setting/Frm_Config.Designer.cs | 4 ++++ cVMS.NET_CS/Setting/Frm_Config.cs | 2 +- 6 files changed, 27 insertions(+), 42 deletions(-) diff --git a/TEST/DigitalIndicator/Form1.cs b/TEST/DigitalIndicator/Form1.cs index 40ea76f..13e8bbe 100644 --- a/TEST/DigitalIndicator/Form1.cs +++ b/TEST/DigitalIndicator/Form1.cs @@ -65,8 +65,8 @@ namespace DigitalIndicator dev.DataBits = 8; // 데이터 비트 dev.Parity = System.IO.Ports.Parity.None; dev.StopBits = System.IO.Ports.StopBits.One; - dev.ReadTimeout = 2000; - dev.WriteTimeout = 2000; + dev.ReadTimeout = 1500; + dev.WriteTimeout = 1500; try { @@ -81,10 +81,6 @@ namespace DigitalIndicator // Modbus 마스터 생성 modbus = ModbusSerialMaster.CreateRtu(dev); } - - - - } private void timer1_Tick(object sender, EventArgs e) diff --git a/cVMS.NET_CS/Device/DigitalIndicator.cs b/cVMS.NET_CS/Device/DigitalIndicator.cs index fbb12cb..87ffc65 100644 --- a/cVMS.NET_CS/Device/DigitalIndicator.cs +++ b/cVMS.NET_CS/Device/DigitalIndicator.cs @@ -37,6 +37,13 @@ namespace vmsnet return WriteValue(buffer); } + UInt16[] splitI32(Int32 value) + { + var hValue = (UInt16)(value >> 16); + var lValue = (UInt16)(value & 0xFFFF); + return new ushort[] { hValue, lValue }; + } + public bool WriteValue(UInt16[] values) { if (IsOpen == false) @@ -49,6 +56,7 @@ namespace vmsnet ErrorMessage = "모드버스가 초기화 되지 않았습니다"; return false; } + try { master.WriteMultipleRegisters(this.SlaveID, 0, values); @@ -61,12 +69,5 @@ namespace vmsnet } } - UInt16[] splitI32(Int32 value) - { - var hValue = (UInt16)(value >> 16); - var lValue = (UInt16)(value & 0xFFFF); - return new ushort[] { hValue, lValue }; - } - } } diff --git a/cVMS.NET_CS/HMI/MainDisplay/DispCtrl.cs b/cVMS.NET_CS/HMI/MainDisplay/DispCtrl.cs index 457c6a2..3c7614a 100644 --- a/cVMS.NET_CS/HMI/MainDisplay/DispCtrl.cs +++ b/cVMS.NET_CS/HMI/MainDisplay/DispCtrl.cs @@ -1450,23 +1450,6 @@ namespace vmsnet.HMI String Kaunit = grp._ampunit;// +grp._ampidx.ToString() + "/" + grp._ampdecpos.ToString(); String MaxKA = grp._amp.ToString("#0.00"); //Console.WriteLine($"{grp.이름} : {MaxKA} {grp._ampunit}"); - //if (grp.이름 == "EL2500E") MaxKA = "0.01"; - - - /**************************************************************************************/ - /* 작성자: 이재웅, 작성일: 2024-11-19, 작성내용: 8개 전해조의 합산 전류량[KA] Modbus 전송 부분 */ - /**************************************************************************************/ - - //using (var client = new JdModbus("COM3", new RtuConfigure() { BaudRate = 115200 })) - //{ - // client.Connect(); - - // ushort[] grpKA = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; // 전력량 배열 (예시) - // byte slaveaddr = 3; - // client.WriteHoldingRegisters(RelayControl.mKA, grpKA, slaveaddr); - //} - - /**************************************************************************************/ Fontsize = g.MeasureString(MaxKA, FONT_KA); SizeF FontSizeu = g.MeasureString(Kaunit, FONT_KU); diff --git a/cVMS.NET_CS/RunCode/Step/_STEP_RUN.cs b/cVMS.NET_CS/RunCode/Step/_STEP_RUN.cs index c6ced90..6a5b8d3 100644 --- a/cVMS.NET_CS/RunCode/Step/_STEP_RUN.cs +++ b/cVMS.NET_CS/RunCode/Step/_STEP_RUN.cs @@ -55,9 +55,15 @@ namespace vmsnet //데이터를 요청하고 처리하는 코드 필요 RUN_GETDATA(); + /* 데이터형식 : PUB.Values[mc, unit, ch-1] + * 전해조A [CH2] : PUB.Values[0, 0, 2-1] : 3002 + * [CH2] 실제값 : 3.002 + */ + //인디케이터 디스플레이 if (PUB.indicator.IsOpen) { + var _ampdecpos = 3; PUB.KA1_SUM = 0f; foreach(var item in PUB.KA1_IndexList) { @@ -68,13 +74,9 @@ namespace vmsnet try { - var _ampdecpos = 3; PUB.KA1_SUM += (float)(PUB.Values[di1, di2, di3 - 1] / (Math.Pow(10, _ampdecpos))); } - catch - { - - } + catch { } } PUB.KA2_SUM = 0f; @@ -87,15 +89,14 @@ namespace vmsnet try { - var _ampdecpos = 3; PUB.KA2_SUM += (float)(PUB.Values[di1, di2, di3 - 1] / (Math.Pow(10, _ampdecpos))); } - catch - { - - } + catch { } } - var SUMKA = PUB.KA1_SUM + PUB.KA2_SUM; + + // '9.000 × 1,000 = 9,000' 식처럼 1000 배 만든다. + var SUMKA = (PUB.KA1_SUM + PUB.KA2_SUM) * (Math.Pow(10, _ampdecpos)); + // '9,000'을 전송한 후 Indicator 에서 왼쪽으로 소수점을 '3' 칸 이동시켜서 Display 하는 작업이 필요 PUB.indicator.SetKA((Int32)SUMKA); } return StepResult.Wait; diff --git a/cVMS.NET_CS/Setting/Frm_Config.Designer.cs b/cVMS.NET_CS/Setting/Frm_Config.Designer.cs index efa7f39..037c2f1 100644 --- a/cVMS.NET_CS/Setting/Frm_Config.Designer.cs +++ b/cVMS.NET_CS/Setting/Frm_Config.Designer.cs @@ -1467,6 +1467,7 @@ namespace vmsnet // this.BindingNavigatorPositionItem.AccessibleName = "위치"; this.BindingNavigatorPositionItem.AutoSize = false; + this.BindingNavigatorPositionItem.Font = new System.Drawing.Font("맑은 고딕", 9F); this.BindingNavigatorPositionItem.Name = "BindingNavigatorPositionItem"; this.BindingNavigatorPositionItem.Size = new System.Drawing.Size(70, 31); this.BindingNavigatorPositionItem.Text = "0"; @@ -1727,6 +1728,7 @@ namespace vmsnet // this.ToolStripTextBox3.AccessibleName = "위치"; this.ToolStripTextBox3.AutoSize = false; + this.ToolStripTextBox3.Font = new System.Drawing.Font("맑은 고딕", 9F); this.ToolStripTextBox3.Name = "ToolStripTextBox3"; this.ToolStripTextBox3.Size = new System.Drawing.Size(70, 31); this.ToolStripTextBox3.Text = "0"; @@ -2247,6 +2249,7 @@ namespace vmsnet // this.ToolStripTextBox2.AccessibleName = "위치"; this.ToolStripTextBox2.AutoSize = false; + this.ToolStripTextBox2.Font = new System.Drawing.Font("맑은 고딕", 9F); this.ToolStripTextBox2.Name = "ToolStripTextBox2"; this.ToolStripTextBox2.Size = new System.Drawing.Size(70, 31); this.ToolStripTextBox2.Text = "0"; @@ -2674,6 +2677,7 @@ namespace vmsnet // this.ToolStripTextBox1.AccessibleName = "위치"; this.ToolStripTextBox1.AutoSize = false; + this.ToolStripTextBox1.Font = new System.Drawing.Font("맑은 고딕", 9F); this.ToolStripTextBox1.Name = "ToolStripTextBox1"; this.ToolStripTextBox1.Size = new System.Drawing.Size(70, 31); this.ToolStripTextBox1.Text = "0"; diff --git a/cVMS.NET_CS/Setting/Frm_Config.cs b/cVMS.NET_CS/Setting/Frm_Config.cs index 5c28838..012fd00 100644 --- a/cVMS.NET_CS/Setting/Frm_Config.cs +++ b/cVMS.NET_CS/Setting/Frm_Config.cs @@ -1022,7 +1022,7 @@ namespace vmsnet } private void button3_Click(object sender, EventArgs e) - { + { // KA indicator 테스트 var valuebuffer = new ushort[20]; valuebuffer[0] = 100; for (int i = 1; i < valuebuffer.Length; i++) valuebuffer[i] = 0;