|
|
|
@ -2,7 +2,11 @@
|
|
|
|
|
using HslCommunication.Core.Address;
|
|
|
|
|
using HslCommunication.ModBus;
|
|
|
|
|
using HybirdFrameworkCore.Utils;
|
|
|
|
|
using HybirdFrameworkDriver.ModbusTcpMaster;
|
|
|
|
|
using HybirdFrameworkDriver.TcpServer;
|
|
|
|
|
using HybirdFrameworkServices.Init.Entity;
|
|
|
|
|
using HybirdFrameworkServices.Plc;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
@ -13,6 +17,7 @@ using System.Reflection;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using static StackExchange.Redis.Role;
|
|
|
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button;
|
|
|
|
|
|
|
|
|
|
namespace WinFormStarter
|
|
|
|
@ -50,15 +55,14 @@ namespace WinFormStarter
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
PlcReadAndWritten PlcReadAndWritten;
|
|
|
|
|
PlcReadonly PlcReadonly;
|
|
|
|
|
PlcTurnsRatio PlcTurnsRatio;
|
|
|
|
|
PlcDate PlcDate = new PlcDate();
|
|
|
|
|
|
|
|
|
|
public FrmPLCConnect()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 连接
|
|
|
|
|
private void BtnConnect_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//简单判断
|
|
|
|
@ -90,203 +94,555 @@ namespace WinFormStarter
|
|
|
|
|
LblConState.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "连接失败";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 读取
|
|
|
|
|
private void BtnCollectionAssignment_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OperateResult<byte[]> read1 = _client.Read("x=3;100", 164);
|
|
|
|
|
OperateResult<byte[]> read2 = _client.Read("x=3;39424", 110);
|
|
|
|
|
OperateResult<byte[]> read3 = _client.Read("x=3;40960", 18);
|
|
|
|
|
|
|
|
|
|
PlcReadAndWritten = ModelConvert.Decode<PlcReadAndWritten>(read1.Content);
|
|
|
|
|
PlcReadonly = ModelConvert.Decode<PlcReadonly>(read1.Content);
|
|
|
|
|
PlcTurnsRatio = ModelConvert.Decode<PlcTurnsRatio>(read1.Content);
|
|
|
|
|
|
|
|
|
|
textBox1.Text = PlcReadAndWritten.ProgrammingEnable.ToString();
|
|
|
|
|
textBox2.Text = PlcReadAndWritten.Modbus1Addres.ToString();
|
|
|
|
|
textBox3.Text = PlcReadAndWritten.BaudRate.ToString();
|
|
|
|
|
textBox4.Text = PlcReadAndWritten.CheckBit.ToString();
|
|
|
|
|
textBox5.Text = PlcReadAndWritten.Seconds.ToString();
|
|
|
|
|
textBox6.Text = PlcReadAndWritten.Points.ToString();
|
|
|
|
|
textBox7.Text = PlcReadAndWritten.When.ToString();
|
|
|
|
|
textBox8.Text = PlcReadAndWritten.Weeks.ToString();
|
|
|
|
|
textBox9.Text = PlcReadAndWritten.Day.ToString();
|
|
|
|
|
textBox10.Text = PlcReadAndWritten.Month.ToString();
|
|
|
|
|
textBox11.Text = PlcReadAndWritten.Years.ToString();
|
|
|
|
|
textBox12.Text = PlcReadAndWritten.Modbus1Addres2.ToString();
|
|
|
|
|
textBox13.Text = PlcReadAndWritten.Reserve.ToString();
|
|
|
|
|
textBox14.Text = PlcReadAndWritten.VoltageRatio.ToString();
|
|
|
|
|
textBox17.Text = PlcReadAndWritten.CurrentRatio.ToString();
|
|
|
|
|
textBox18.Text = PlcReadAndWritten.PulsePerSecond.ToString();
|
|
|
|
|
textBox19.Text = PlcReadAndWritten.CurrentReversal.ToString();
|
|
|
|
|
textBox20.Text = PlcReadAndWritten.MeterReset.ToString();
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo==null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
textBox1.Text = plcInfo.PlcReadAndWritten1.ProgrammingEnable.ToString();
|
|
|
|
|
textBox2.Text = plcInfo.PlcReadAndWritten1.Modbus1Addres.ToString();
|
|
|
|
|
textBox3.Text = plcInfo.PlcReadAndWritten1.BaudRate.ToString();
|
|
|
|
|
textBox4.Text = plcInfo.PlcReadAndWritten1.CheckBit.ToString();
|
|
|
|
|
textBox5.Text = plcInfo.PlcReadAndWritten2.Seconds.ToString();
|
|
|
|
|
textBox6.Text = plcInfo.PlcReadAndWritten2.Points.ToString();
|
|
|
|
|
textBox7.Text = plcInfo.PlcReadAndWritten2.When.ToString();
|
|
|
|
|
textBox8.Text = plcInfo.PlcReadAndWritten2.Weeks.ToString();
|
|
|
|
|
textBox9.Text = plcInfo.PlcReadAndWritten2.Day.ToString();
|
|
|
|
|
textBox10.Text = plcInfo.PlcReadAndWritten2.Month.ToString();
|
|
|
|
|
textBox11.Text = plcInfo.PlcReadAndWritten2.Years.ToString();
|
|
|
|
|
textBox12.Text = plcInfo.PlcReadAndWritten2.Modbus1Addres2.ToString();
|
|
|
|
|
textBox13.Text = plcInfo.PlcReadAndWritten2.Reserve.ToString();
|
|
|
|
|
textBox14.Text = plcInfo.PlcReadAndWritten2.VoltageRatio.ToString();
|
|
|
|
|
textBox15.Text = plcInfo.PlcReadAndWritten2.CurrentRatio.ToString();
|
|
|
|
|
textBox16.Text = plcInfo.PlcReadAndWritten1.PulsePerSecond.ToString();
|
|
|
|
|
textBox17.Text = plcInfo.PlcReadAndWritten1.CurrentReversal.ToString();
|
|
|
|
|
textBox18.Text = plcInfo.PlcReadAndWritten1.MeterReset.ToString();
|
|
|
|
|
string datetime = plcInfo.PlcReadAndWritten2.Years + "-" +
|
|
|
|
|
plcInfo.PlcReadAndWritten2.Month + "-" +
|
|
|
|
|
plcInfo.PlcReadAndWritten2.Day + " " +
|
|
|
|
|
plcInfo.PlcReadAndWritten2.When + ":" +
|
|
|
|
|
plcInfo.PlcReadAndWritten2.Points + ":" +
|
|
|
|
|
plcInfo.PlcReadAndWritten2.Seconds;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 切换数据
|
|
|
|
|
bool now;
|
|
|
|
|
private void BtnToggle_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
now = !now;
|
|
|
|
|
if (now)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#region
|
|
|
|
|
label31.Text = PlcReadonly.GroupHaveAll.ToString();
|
|
|
|
|
label29.Text = PlcReadonly.GroupHaveTip.ToString();
|
|
|
|
|
label27.Text = PlcReadonly.GroupHavePeak.ToString();
|
|
|
|
|
label25.Text = PlcReadonly.GroupHaveFlat.ToString();
|
|
|
|
|
label19.Text = PlcReadonly.GroupHaveValley.ToString();
|
|
|
|
|
label40.Text = PlcReadonly.ForwardHaveAll.ToString();
|
|
|
|
|
label38.Text = PlcReadonly.ForwardHaveTip.ToString();
|
|
|
|
|
label36.Text = PlcReadonly.ForwardHavePeak.ToString();
|
|
|
|
|
label34.Text = PlcReadonly.ForwardHaveFlat.ToString();
|
|
|
|
|
label32.Text = PlcReadonly.ForwardHaveValley.ToString();
|
|
|
|
|
label50.Text = PlcReadonly.ReverseHaveAll.ToString();
|
|
|
|
|
label48.Text = PlcReadonly.ReverseHaveTip.ToString();
|
|
|
|
|
label46.Text = PlcReadonly.ReverseHavePeak.ToString();
|
|
|
|
|
label44.Text = PlcReadonly.ReverseHaveFlat.ToString();
|
|
|
|
|
label42.Text = PlcReadonly.ReverseHaveValley.ToString();
|
|
|
|
|
label60.Text = PlcReadonly.GroupNoAll1.ToString();
|
|
|
|
|
label58.Text = PlcReadonly.GroupNoTip1.ToString();
|
|
|
|
|
label56.Text = PlcReadonly.GroupNoPeak1.ToString();
|
|
|
|
|
label54.Text = PlcReadonly.GroupNoFlat1.ToString();
|
|
|
|
|
label52.Text = PlcReadonly.GroupNoValley1.ToString();
|
|
|
|
|
label70.Text = PlcReadonly.GroupNoAll2.ToString();
|
|
|
|
|
label68.Text = PlcReadonly.GroupNoTip2.ToString();
|
|
|
|
|
label66.Text = PlcReadonly.GroupNoPeak2.ToString();
|
|
|
|
|
label64.Text = PlcReadonly.GroupNoFlat2.ToString();
|
|
|
|
|
label62.Text = PlcReadonly.GroupNoValley2.ToString();
|
|
|
|
|
label80.Text = PlcReadonly.QuadrantNoAll1.ToString();
|
|
|
|
|
label78.Text = PlcReadonly.QuadrantNoTip1.ToString();
|
|
|
|
|
label76.Text = PlcReadonly.QuadrantNoPeak1.ToString();
|
|
|
|
|
label74.Text = PlcReadonly.QuadrantNoFlat1.ToString();
|
|
|
|
|
label72.Text = PlcReadonly.QuadrantNoValley1.ToString();
|
|
|
|
|
label90.Text = PlcReadonly.QuadrantNoAll2.ToString();
|
|
|
|
|
label88.Text = PlcReadonly.QuadrantNoTip2.ToString();
|
|
|
|
|
label86.Text = PlcReadonly.QuadrantNoPeak2.ToString();
|
|
|
|
|
label84.Text = PlcReadonly.QuadrantNoFlat2.ToString();
|
|
|
|
|
label82.Text = PlcReadonly.QuadrantNoValley2.ToString();
|
|
|
|
|
label100.Text = PlcReadonly.QuadrantNoAll3.ToString();
|
|
|
|
|
label98.Text = PlcReadonly.QuadrantNoTip3.ToString();
|
|
|
|
|
label96.Text = PlcReadonly.QuadrantNoPeak3.ToString();
|
|
|
|
|
label94.Text = PlcReadonly.QuadrantNoFlat3.ToString();
|
|
|
|
|
label92.Text = PlcReadonly.QuadrantNoValley3.ToString();
|
|
|
|
|
label110.Text = PlcReadonly.QuadrantNoAll4.ToString();
|
|
|
|
|
label108.Text = PlcReadonly.QuadrantNoTip4.ToString();
|
|
|
|
|
label106.Text = PlcReadonly.QuadrantNoPeak4.ToString();
|
|
|
|
|
label104.Text = PlcReadonly.QuadrantNoFlat4.ToString();
|
|
|
|
|
label102.Text = PlcReadonly.QuadrantNoValley4.ToString();
|
|
|
|
|
label120.Text = PlcReadonly.ForwardHaveApparentAll.ToString();
|
|
|
|
|
label118.Text = PlcReadonly.ForwardHaveApparentTip.ToString();
|
|
|
|
|
label116.Text = PlcReadonly.ForwardHaveApparentPeak.ToString();
|
|
|
|
|
label114.Text = PlcReadonly.ForwardHaveApparentFlat.ToString();
|
|
|
|
|
label112.Text = PlcReadonly.ForwardHaveApparentValley.ToString();
|
|
|
|
|
label130.Text = PlcReadonly.ReverseHaveApparentAll.ToString();
|
|
|
|
|
label128.Text = PlcReadonly.ReverseHaveApparentTip.ToString();
|
|
|
|
|
label126.Text = PlcReadonly.ReverseHaveApparentPeak.ToString();
|
|
|
|
|
label124.Text = PlcReadonly.ReverseHaveApparentFlat.ToString();
|
|
|
|
|
label122.Text = PlcReadonly.ReverseHaveApparentValley.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
label140.Text = PlcReadonly.PhaseVoltageA.ToString();
|
|
|
|
|
label138.Text = PlcReadonly.PhaseVoltageB.ToString();
|
|
|
|
|
label136.Text = PlcReadonly.PhaseVoltageC.ToString();
|
|
|
|
|
label134.Text = PlcReadonly.PhaseElectricityA.ToString();
|
|
|
|
|
label132.Text = PlcReadonly.PhaseElectricityB.ToString();
|
|
|
|
|
label172.Text = PlcReadonly.PhaseElectricityC.ToString();
|
|
|
|
|
|
|
|
|
|
label150.Text = PlcReadonly.TotalActivePower.ToString();
|
|
|
|
|
label148.Text = PlcReadonly.TotalActivePowerA.ToString();
|
|
|
|
|
label146.Text = PlcReadonly.TotalActivePowerB.ToString();
|
|
|
|
|
label144.Text = PlcReadonly.TotalActivePowerC.ToString();
|
|
|
|
|
|
|
|
|
|
label160.Text = PlcReadonly.TotalReactivePower.ToString();
|
|
|
|
|
label158.Text = PlcReadonly.TotalReactivePowerA.ToString();
|
|
|
|
|
label156.Text = PlcReadonly.TotalReactivePowerB.ToString();
|
|
|
|
|
label144.Text = PlcReadonly.TotalReactivePowerC.ToString();
|
|
|
|
|
|
|
|
|
|
label170.Text = PlcReadonly.TotalApparentPower.ToString();
|
|
|
|
|
label168.Text = PlcReadonly.TotalApparentPowerA.ToString();
|
|
|
|
|
label166.Text = PlcReadonly.TotalApparentPowerB.ToString();
|
|
|
|
|
label164.Text = PlcReadonly.TotalApparentPowerC.ToString();
|
|
|
|
|
|
|
|
|
|
label192.Text = PlcReadonly.OverallPowerFactor.ToString();
|
|
|
|
|
label190.Text = PlcReadonly.OverallPowerFactorA.ToString();
|
|
|
|
|
label188.Text = PlcReadonly.OverallPowerFactorB.ToString();
|
|
|
|
|
label184.Text = PlcReadonly.OverallPowerFactorC.ToString();
|
|
|
|
|
|
|
|
|
|
label174.Text = PlcReadonly.PhaseAngleA.ToString();
|
|
|
|
|
label162.Text = PlcReadonly.PhaseAngleB.ToString();
|
|
|
|
|
label152.Text = PlcReadonly.PhaseAngleC.ToString();
|
|
|
|
|
label142.Text = PlcReadonly.LineFrequency.ToString();
|
|
|
|
|
|
|
|
|
|
label184.Text = PlcReadonly.PhaseLineVoltageA.ToString();
|
|
|
|
|
label182.Text = PlcReadonly.PhaseLineVoltageB.ToString();
|
|
|
|
|
label180.Text = PlcReadonly.PhaseLineVoltageC.ToString();
|
|
|
|
|
label178.Text = PlcReadonly.ThreePhaseMeanLineVoltage.ToString();
|
|
|
|
|
label176.Text = PlcReadonly.ThreePhaseMeanPhaseVoltage.ToString();
|
|
|
|
|
label31.Text = plcInfo.PlcReadonly.GroupHaveAll.ToString();
|
|
|
|
|
label29.Text = plcInfo.PlcReadonly.GroupHaveTip.ToString();
|
|
|
|
|
label27.Text = plcInfo.PlcReadonly.GroupHavePeak.ToString();
|
|
|
|
|
label25.Text = plcInfo.PlcReadonly.GroupHaveFlat.ToString();
|
|
|
|
|
label19.Text = plcInfo.PlcReadonly.GroupHaveValley.ToString();
|
|
|
|
|
label40.Text = plcInfo.PlcReadonly.ForwardHaveAll.ToString();
|
|
|
|
|
label38.Text = plcInfo.PlcReadonly.ForwardHaveTip.ToString();
|
|
|
|
|
label36.Text = plcInfo.PlcReadonly.ForwardHavePeak.ToString();
|
|
|
|
|
label34.Text = plcInfo.PlcReadonly.ForwardHaveFlat.ToString();
|
|
|
|
|
label32.Text = plcInfo.PlcReadonly.ForwardHaveValley.ToString();
|
|
|
|
|
label50.Text = plcInfo.PlcReadonly.ReverseHaveAll.ToString();
|
|
|
|
|
label48.Text = plcInfo.PlcReadonly.ReverseHaveTip.ToString();
|
|
|
|
|
label46.Text = plcInfo.PlcReadonly.ReverseHavePeak.ToString();
|
|
|
|
|
label44.Text = plcInfo.PlcReadonly.ReverseHaveFlat.ToString();
|
|
|
|
|
label42.Text = plcInfo.PlcReadonly.ReverseHaveValley.ToString();
|
|
|
|
|
label60.Text = plcInfo.PlcReadonly.GroupNoAll1.ToString();
|
|
|
|
|
label58.Text = plcInfo.PlcReadonly.GroupNoTip1.ToString();
|
|
|
|
|
label56.Text = plcInfo.PlcReadonly.GroupNoPeak1.ToString();
|
|
|
|
|
label54.Text = plcInfo.PlcReadonly.GroupNoFlat1.ToString();
|
|
|
|
|
label52.Text = plcInfo.PlcReadonly.GroupNoValley1.ToString();
|
|
|
|
|
label70.Text = plcInfo.PlcReadonly.GroupNoAll2.ToString();
|
|
|
|
|
label68.Text = plcInfo.PlcReadonly.GroupNoTip2.ToString();
|
|
|
|
|
label66.Text = plcInfo.PlcReadonly.GroupNoPeak2.ToString();
|
|
|
|
|
label64.Text = plcInfo.PlcReadonly.GroupNoFlat2.ToString();
|
|
|
|
|
label62.Text = plcInfo.PlcReadonly.GroupNoValley2.ToString();
|
|
|
|
|
label80.Text = plcInfo.PlcReadonly.QuadrantNoAll1.ToString();
|
|
|
|
|
label78.Text = plcInfo.PlcReadonly.QuadrantNoTip1.ToString();
|
|
|
|
|
label76.Text = plcInfo.PlcReadonly.QuadrantNoPeak1.ToString();
|
|
|
|
|
label74.Text = plcInfo.PlcReadonly.QuadrantNoFlat1.ToString();
|
|
|
|
|
label72.Text = plcInfo.PlcReadonly.QuadrantNoValley1.ToString();
|
|
|
|
|
label90.Text = plcInfo.PlcReadonly.QuadrantNoAll2.ToString();
|
|
|
|
|
label88.Text = plcInfo.PlcReadonly.QuadrantNoTip2.ToString();
|
|
|
|
|
label86.Text = plcInfo.PlcReadonly.QuadrantNoPeak2.ToString();
|
|
|
|
|
label84.Text = plcInfo.PlcReadonly.QuadrantNoFlat2.ToString();
|
|
|
|
|
label82.Text = plcInfo.PlcReadonly.QuadrantNoValley2.ToString();
|
|
|
|
|
label100.Text = plcInfo.PlcReadonly.QuadrantNoAll3.ToString();
|
|
|
|
|
label98.Text = plcInfo.PlcReadonly.QuadrantNoTip3.ToString();
|
|
|
|
|
label96.Text = plcInfo.PlcReadonly.QuadrantNoPeak3.ToString();
|
|
|
|
|
label94.Text = plcInfo.PlcReadonly.QuadrantNoFlat3.ToString();
|
|
|
|
|
label92.Text = plcInfo.PlcReadonly.QuadrantNoValley3.ToString();
|
|
|
|
|
label110.Text = plcInfo.PlcReadonly.QuadrantNoAll4.ToString();
|
|
|
|
|
label108.Text = plcInfo.PlcReadonly.QuadrantNoTip4.ToString();
|
|
|
|
|
label106.Text = plcInfo.PlcReadonly.QuadrantNoPeak4.ToString();
|
|
|
|
|
label104.Text = plcInfo.PlcReadonly.QuadrantNoFlat4.ToString();
|
|
|
|
|
label102.Text = plcInfo.PlcReadonly.QuadrantNoValley4.ToString();
|
|
|
|
|
label120.Text = plcInfo.PlcReadonly.ForwardHaveApparentAll.ToString();
|
|
|
|
|
label118.Text = plcInfo.PlcReadonly.ForwardHaveApparentTip.ToString();
|
|
|
|
|
label116.Text = plcInfo.PlcReadonly.ForwardHaveApparentPeak.ToString();
|
|
|
|
|
label114.Text = plcInfo.PlcReadonly.ForwardHaveApparentFlat.ToString();
|
|
|
|
|
label112.Text = plcInfo.PlcReadonly.ForwardHaveApparentValley.ToString();
|
|
|
|
|
label130.Text = plcInfo.PlcReadonly.ReverseHaveApparentAll.ToString();
|
|
|
|
|
label128.Text = plcInfo.PlcReadonly.ReverseHaveApparentTip.ToString();
|
|
|
|
|
label126.Text = plcInfo.PlcReadonly.ReverseHaveApparentPeak.ToString();
|
|
|
|
|
label124.Text = plcInfo.PlcReadonly.ReverseHaveApparentFlat.ToString();
|
|
|
|
|
label122.Text = plcInfo.PlcReadonly.ReverseHaveApparentValley.ToString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
label140.Text = plcInfo.PlcReadonly.PhaseVoltageA.ToString();
|
|
|
|
|
label138.Text = plcInfo.PlcReadonly.PhaseVoltageB.ToString();
|
|
|
|
|
label136.Text = plcInfo.PlcReadonly.PhaseVoltageC.ToString();
|
|
|
|
|
label134.Text = plcInfo.PlcReadonly.PhaseElectricityA.ToString();
|
|
|
|
|
label132.Text = plcInfo.PlcReadonly.PhaseElectricityB.ToString();
|
|
|
|
|
label172.Text = plcInfo.PlcReadonly.PhaseElectricityC.ToString();
|
|
|
|
|
|
|
|
|
|
label150.Text = plcInfo.PlcReadonly.TotalActivePower.ToString();
|
|
|
|
|
label148.Text = plcInfo.PlcReadonly.TotalActivePowerA.ToString();
|
|
|
|
|
label146.Text = plcInfo.PlcReadonly.TotalActivePowerB.ToString();
|
|
|
|
|
label144.Text = plcInfo.PlcReadonly.TotalActivePowerC.ToString();
|
|
|
|
|
|
|
|
|
|
label160.Text = plcInfo.PlcReadonly.TotalReactivePower.ToString();
|
|
|
|
|
label158.Text = plcInfo.PlcReadonly.TotalReactivePowerA.ToString();
|
|
|
|
|
label156.Text = plcInfo.PlcReadonly.TotalReactivePowerB.ToString();
|
|
|
|
|
label144.Text = plcInfo.PlcReadonly.TotalReactivePowerC.ToString();
|
|
|
|
|
|
|
|
|
|
label170.Text = plcInfo.PlcReadonly.TotalApparentPower.ToString();
|
|
|
|
|
label168.Text = plcInfo.PlcReadonly.TotalApparentPowerA.ToString();
|
|
|
|
|
label166.Text = plcInfo.PlcReadonly.TotalApparentPowerB.ToString();
|
|
|
|
|
label164.Text = plcInfo.PlcReadonly.TotalApparentPowerC.ToString();
|
|
|
|
|
|
|
|
|
|
label192.Text = plcInfo.PlcReadonly.OverallPowerFactor.ToString();
|
|
|
|
|
label190.Text = plcInfo.PlcReadonly.OverallPowerFactorA.ToString();
|
|
|
|
|
label188.Text = plcInfo.PlcReadonly.OverallPowerFactorB.ToString();
|
|
|
|
|
label184.Text = plcInfo.PlcReadonly.OverallPowerFactorC.ToString();
|
|
|
|
|
|
|
|
|
|
label174.Text = plcInfo.PlcReadonly.PhaseAngleA.ToString();
|
|
|
|
|
label162.Text = plcInfo.PlcReadonly.PhaseAngleB.ToString();
|
|
|
|
|
label152.Text = plcInfo.PlcReadonly.PhaseAngleC.ToString();
|
|
|
|
|
label142.Text = plcInfo.PlcReadonly.LineFrequency.ToString();
|
|
|
|
|
|
|
|
|
|
label184.Text = plcInfo.PlcReadonly.PhaseLineVoltageA.ToString();
|
|
|
|
|
label182.Text = plcInfo.PlcReadonly.PhaseLineVoltageB.ToString();
|
|
|
|
|
label180.Text = plcInfo.PlcReadonly.PhaseLineVoltageC.ToString();
|
|
|
|
|
label178.Text = plcInfo.PlcReadonly.ThreePhaseMeanLineVoltage.ToString();
|
|
|
|
|
label176.Text = plcInfo.PlcReadonly.ThreePhaseMeanPhaseVoltage.ToString();
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
if (now)
|
|
|
|
|
{
|
|
|
|
|
#region
|
|
|
|
|
label31.Text = PlcTurnsRatio.GroupHaveAll.ToString();
|
|
|
|
|
label29.Text = PlcTurnsRatio.GroupHaveTip.ToString();
|
|
|
|
|
label27.Text = PlcTurnsRatio.GroupHavePeak.ToString();
|
|
|
|
|
label25.Text = PlcTurnsRatio.GroupHaveFlat.ToString();
|
|
|
|
|
label19.Text = PlcTurnsRatio.GroupHaveValley.ToString();
|
|
|
|
|
label40.Text = PlcTurnsRatio.ForwardHaveAll.ToString();
|
|
|
|
|
label38.Text = PlcTurnsRatio.ForwardHaveTip.ToString();
|
|
|
|
|
label36.Text = PlcTurnsRatio.ForwardHavePeak.ToString();
|
|
|
|
|
label34.Text = PlcTurnsRatio.ForwardHaveFlat.ToString();
|
|
|
|
|
label32.Text = PlcTurnsRatio.ForwardHaveValley.ToString();
|
|
|
|
|
label50.Text = PlcTurnsRatio.ReverseHaveAll.ToString();
|
|
|
|
|
label48.Text = PlcTurnsRatio.ReverseHaveTip.ToString();
|
|
|
|
|
label46.Text = PlcTurnsRatio.ReverseHavePeak.ToString();
|
|
|
|
|
label44.Text = PlcTurnsRatio.ReverseHaveFlat.ToString();
|
|
|
|
|
label42.Text = PlcTurnsRatio.ReverseHaveValley.ToString();
|
|
|
|
|
label60.Text = PlcTurnsRatio.GroupNoAll1.ToString();
|
|
|
|
|
label58.Text = PlcTurnsRatio.GroupNoTip1.ToString();
|
|
|
|
|
label56.Text = PlcTurnsRatio.GroupNoPeak1.ToString();
|
|
|
|
|
label54.Text = PlcTurnsRatio.GroupNoFlat1.ToString();
|
|
|
|
|
label52.Text = PlcTurnsRatio.GroupNoValley1.ToString();
|
|
|
|
|
label70.Text = PlcTurnsRatio.GroupNoAll2.ToString();
|
|
|
|
|
label68.Text = PlcTurnsRatio.GroupNoTip2.ToString();
|
|
|
|
|
label66.Text = PlcTurnsRatio.GroupNoPeak2.ToString();
|
|
|
|
|
label64.Text = PlcTurnsRatio.GroupNoFlat2.ToString();
|
|
|
|
|
label62.Text = PlcTurnsRatio.GroupNoValley2.ToString();
|
|
|
|
|
label80.Text = PlcTurnsRatio.QuadrantNoAll1.ToString();
|
|
|
|
|
label78.Text = PlcTurnsRatio.QuadrantNoTip1.ToString();
|
|
|
|
|
label76.Text = PlcTurnsRatio.QuadrantNoPeak1.ToString();
|
|
|
|
|
label74.Text = PlcTurnsRatio.QuadrantNoFlat1.ToString();
|
|
|
|
|
label72.Text = PlcTurnsRatio.QuadrantNoValley1.ToString();
|
|
|
|
|
label90.Text = PlcTurnsRatio.QuadrantNoAll2.ToString();
|
|
|
|
|
label88.Text = PlcTurnsRatio.QuadrantNoTip2.ToString();
|
|
|
|
|
label86.Text = PlcTurnsRatio.QuadrantNoPeak2.ToString();
|
|
|
|
|
label84.Text = PlcTurnsRatio.QuadrantNoFlat2.ToString();
|
|
|
|
|
label82.Text = PlcTurnsRatio.QuadrantNoValley2.ToString();
|
|
|
|
|
label100.Text = PlcTurnsRatio.QuadrantNoAll3.ToString();
|
|
|
|
|
label98.Text = PlcTurnsRatio.QuadrantNoTip3.ToString();
|
|
|
|
|
label96.Text = PlcTurnsRatio.QuadrantNoPeak3.ToString();
|
|
|
|
|
label94.Text = PlcTurnsRatio.QuadrantNoFlat3.ToString();
|
|
|
|
|
label92.Text = PlcTurnsRatio.QuadrantNoValley3.ToString();
|
|
|
|
|
label110.Text = PlcTurnsRatio.QuadrantNoAll4.ToString();
|
|
|
|
|
label108.Text = PlcTurnsRatio.QuadrantNoTip4.ToString();
|
|
|
|
|
label106.Text = PlcTurnsRatio.QuadrantNoPeak4.ToString();
|
|
|
|
|
label104.Text = PlcTurnsRatio.QuadrantNoFlat4.ToString();
|
|
|
|
|
label102.Text = PlcTurnsRatio.QuadrantNoValley4.ToString();
|
|
|
|
|
label120.Text = PlcTurnsRatio.ForwardHaveApparentAll.ToString();
|
|
|
|
|
label118.Text = PlcTurnsRatio.ForwardHaveApparentTip.ToString();
|
|
|
|
|
label116.Text = PlcTurnsRatio.ForwardHaveApparentPeak.ToString();
|
|
|
|
|
label114.Text = PlcTurnsRatio.ForwardHaveApparentFlat.ToString();
|
|
|
|
|
label112.Text = PlcTurnsRatio.ForwardHaveApparentValley.ToString();
|
|
|
|
|
label130.Text = PlcTurnsRatio.ReverseHaveApparentAll.ToString();
|
|
|
|
|
label128.Text = PlcTurnsRatio.ReverseHaveApparentTip.ToString();
|
|
|
|
|
label126.Text = PlcTurnsRatio.ReverseHaveApparentPeak.ToString();
|
|
|
|
|
label124.Text = PlcTurnsRatio.ReverseHaveApparentFlat.ToString();
|
|
|
|
|
label122.Text = PlcTurnsRatio.ReverseHaveApparentValley.ToString();
|
|
|
|
|
label31.Text = plcInfo.PlcTurnsRatio.GroupHaveAll.ToString();
|
|
|
|
|
label29.Text = plcInfo.PlcTurnsRatio.GroupHaveTip.ToString();
|
|
|
|
|
label27.Text = plcInfo.PlcTurnsRatio.GroupHavePeak.ToString();
|
|
|
|
|
label25.Text = plcInfo.PlcTurnsRatio.GroupHaveFlat.ToString();
|
|
|
|
|
label19.Text = plcInfo.PlcTurnsRatio.GroupHaveValley.ToString();
|
|
|
|
|
label40.Text = plcInfo.PlcTurnsRatio.ForwardHaveAll.ToString();
|
|
|
|
|
label38.Text = plcInfo.PlcTurnsRatio.ForwardHaveTip.ToString();
|
|
|
|
|
label36.Text = plcInfo.PlcTurnsRatio.ForwardHavePeak.ToString();
|
|
|
|
|
label34.Text = plcInfo.PlcTurnsRatio.ForwardHaveFlat.ToString();
|
|
|
|
|
label32.Text = plcInfo.PlcTurnsRatio.ForwardHaveValley.ToString();
|
|
|
|
|
label50.Text = plcInfo.PlcTurnsRatio.ReverseHaveAll.ToString();
|
|
|
|
|
label48.Text = plcInfo.PlcTurnsRatio.ReverseHaveTip.ToString();
|
|
|
|
|
label46.Text = plcInfo.PlcTurnsRatio.ReverseHavePeak.ToString();
|
|
|
|
|
label44.Text = plcInfo.PlcTurnsRatio.ReverseHaveFlat.ToString();
|
|
|
|
|
label42.Text = plcInfo.PlcTurnsRatio.ReverseHaveValley.ToString();
|
|
|
|
|
label60.Text = plcInfo.PlcTurnsRatio.GroupNoAll1.ToString();
|
|
|
|
|
label58.Text = plcInfo.PlcTurnsRatio.GroupNoTip1.ToString();
|
|
|
|
|
label56.Text = plcInfo.PlcTurnsRatio.GroupNoPeak1.ToString();
|
|
|
|
|
label54.Text = plcInfo.PlcTurnsRatio.GroupNoFlat1.ToString();
|
|
|
|
|
label52.Text = plcInfo.PlcTurnsRatio.GroupNoValley1.ToString();
|
|
|
|
|
label70.Text = plcInfo.PlcTurnsRatio.GroupNoAll2.ToString();
|
|
|
|
|
label68.Text = plcInfo.PlcTurnsRatio.GroupNoTip2.ToString();
|
|
|
|
|
label66.Text = plcInfo.PlcTurnsRatio.GroupNoPeak2.ToString();
|
|
|
|
|
label64.Text = plcInfo.PlcTurnsRatio.GroupNoFlat2.ToString();
|
|
|
|
|
label62.Text = plcInfo.PlcTurnsRatio.GroupNoValley2.ToString();
|
|
|
|
|
label80.Text = plcInfo.PlcTurnsRatio.QuadrantNoAll1.ToString();
|
|
|
|
|
label78.Text = plcInfo.PlcTurnsRatio.QuadrantNoTip1.ToString();
|
|
|
|
|
label76.Text = plcInfo.PlcTurnsRatio.QuadrantNoPeak1.ToString();
|
|
|
|
|
label74.Text = plcInfo.PlcTurnsRatio.QuadrantNoFlat1.ToString();
|
|
|
|
|
label72.Text = plcInfo.PlcTurnsRatio.QuadrantNoValley1.ToString();
|
|
|
|
|
label90.Text = plcInfo.PlcTurnsRatio.QuadrantNoAll2.ToString();
|
|
|
|
|
label88.Text = plcInfo.PlcTurnsRatio.QuadrantNoTip2.ToString();
|
|
|
|
|
label86.Text = plcInfo.PlcTurnsRatio.QuadrantNoPeak2.ToString();
|
|
|
|
|
label84.Text = plcInfo.PlcTurnsRatio.QuadrantNoFlat2.ToString();
|
|
|
|
|
label82.Text = plcInfo.PlcTurnsRatio.QuadrantNoValley2.ToString();
|
|
|
|
|
label100.Text = plcInfo.PlcTurnsRatio.QuadrantNoAll3.ToString();
|
|
|
|
|
label98.Text = plcInfo.PlcTurnsRatio.QuadrantNoTip3.ToString();
|
|
|
|
|
label96.Text = plcInfo.PlcTurnsRatio.QuadrantNoPeak3.ToString();
|
|
|
|
|
label94.Text = plcInfo.PlcTurnsRatio.QuadrantNoFlat3.ToString();
|
|
|
|
|
label92.Text = plcInfo.PlcTurnsRatio.QuadrantNoValley3.ToString();
|
|
|
|
|
label110.Text = plcInfo.PlcTurnsRatio.QuadrantNoAll4.ToString();
|
|
|
|
|
label108.Text = plcInfo.PlcTurnsRatio.QuadrantNoTip4.ToString();
|
|
|
|
|
label106.Text = plcInfo.PlcTurnsRatio.QuadrantNoPeak4.ToString();
|
|
|
|
|
label104.Text = plcInfo.PlcTurnsRatio.QuadrantNoFlat4.ToString();
|
|
|
|
|
label102.Text = plcInfo.PlcTurnsRatio.QuadrantNoValley4.ToString();
|
|
|
|
|
label120.Text = plcInfo.PlcTurnsRatio.ForwardHaveApparentAll.ToString();
|
|
|
|
|
label118.Text = plcInfo.PlcTurnsRatio.ForwardHaveApparentTip.ToString();
|
|
|
|
|
label116.Text = plcInfo.PlcTurnsRatio.ForwardHaveApparentPeak.ToString();
|
|
|
|
|
label114.Text = plcInfo.PlcTurnsRatio.ForwardHaveApparentFlat.ToString();
|
|
|
|
|
label112.Text = plcInfo.PlcTurnsRatio.ForwardHaveApparentValley.ToString();
|
|
|
|
|
label130.Text = plcInfo.PlcTurnsRatio.ReverseHaveApparentAll.ToString();
|
|
|
|
|
label128.Text = plcInfo.PlcTurnsRatio.ReverseHaveApparentTip.ToString();
|
|
|
|
|
label126.Text = plcInfo.PlcTurnsRatio.ReverseHaveApparentPeak.ToString();
|
|
|
|
|
label124.Text = plcInfo.PlcTurnsRatio.ReverseHaveApparentFlat.ToString();
|
|
|
|
|
label122.Text = plcInfo.PlcTurnsRatio.ReverseHaveApparentValley.ToString();
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//TODO::没有数据写入,稍后添加
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 方法
|
|
|
|
|
|
|
|
|
|
#endregion 写入方法
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void BtnWrite01_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox1.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if(plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult=session.Write<UInt16>(PlcDate.ProgrammingEnable);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite02_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox2.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.Modbus1Addres);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite03_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox3.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.BaudRate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite04_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox4.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.CheckBit);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite05_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox5.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.Seconds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite06_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox6.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.Points);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite07_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox7.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.When);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite08_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox8.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.Weeks);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite09_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox9.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.Day);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite10_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox10.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.Month);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite11_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox11.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.Years);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite12_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox12.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.Modbus1Addres2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite13_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox13.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.Reserve);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite14_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox14.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.VoltageRatio);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite15_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox15.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.CurrentRatio);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite16_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox16.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.PulsePerSecond);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite17_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox15.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.CurrentReversal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnWrite18_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
bool bConvert = int.TryParse(this.textBox16.Text, out int iValue);
|
|
|
|
|
if (!bConvert)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入有效值");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
|
|
|
|
|
if (plcInfo == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("PLC未连接");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ModbusSession session = SessionMgr.GetModbusSession(plcInfo.ChannelId);
|
|
|
|
|
bool bResult = session.Write<UInt16>(PlcDate.MeterReset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 进制数据转换
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|