PLC连接显示

master
CZ 6 months ago
parent 46caac2f8b
commit 8a3286edc0

@ -11,6 +11,9 @@ public static class ModbusDecoder
public static T Decode<T>(byte[] bytes, T t) where T : class, new() public static T Decode<T>(byte[] bytes, T t) where T : class, new()
{ {
try
{
List<object?> fields = t.GetType().GetProperties() List<object?> fields = t.GetType().GetProperties()
.Where(it => it.PropertyType.GetGenericTypeDefinition() == typeof(ModbusProperty<>)) .Where(it => it.PropertyType.GetGenericTypeDefinition() == typeof(ModbusProperty<>))
.Select(p => p.GetValue(t)).ToList(); .Select(p => p.GetValue(t)).ToList();
@ -110,6 +113,11 @@ public static class ModbusDecoder
} }
} }
}
catch (Exception ex)
{
}
return t; return t;
} }

@ -1,4 +1,6 @@
using HybirdFrameworkCore.Autofac.Attribute; using HslCommunication.ModBus;
using HslCommunication;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkDriver.ModbusTcpMaster; using HybirdFrameworkDriver.ModbusTcpMaster;
using HybirdFrameworkDriver.TcpServer; using HybirdFrameworkDriver.TcpServer;
using HybirdFrameworkEntity.DbModel; using HybirdFrameworkEntity.DbModel;
@ -16,6 +18,7 @@ namespace HybirdFrameworkServices
[Scope("SingleInstance")] [Scope("SingleInstance")]
public class EquipmentInit public class EquipmentInit
{ {
#region
BsNetEqmParamInfoRepository _bsNetEqmParamInfoRepository; BsNetEqmParamInfoRepository _bsNetEqmParamInfoRepository;
public EquipmentInit(BsNetEqmParamInfoRepository bsNetEqmParamInfoRepository) public EquipmentInit(BsNetEqmParamInfoRepository bsNetEqmParamInfoRepository)
{ {
@ -40,28 +43,6 @@ namespace HybirdFrameworkServices
DestAddr = "1", DestAddr = "1",
}; };
// //PLC删除
// IEnumerable<IGrouping<int, BsNetEqmParamInfo>> queryConnectParams =;
// _bsNetEqmParamInfoRepository.QueryConnectParams(new List<int>() { 1, 2, 101 });
// int count = 0;
// IEnumerable<IGrouping<int, BsNetEqmParamInfo>> connectParams =
//queryConnectParams as IGrouping<int, BsNetEqmParamInfo>[] ?? queryConnectParams.ToArray();
// foreach (IGrouping<int, BsNetEqmParamInfo> device in connectParams)
// {
// Console.WriteLine(device.Key);
// count = device.Key switch
// {
// //1 => ConnectCharger(device),
// //101 => ConnectCharger(device),
// //2 => ConnectWaterCooler(device),
// 3 => ConnectPlc(device),
// _ =>
// // 处理所有其他情况,可能抛出异常、记录日志或返回默认值
// throw new InvalidOperationException("Unknown device key: " + device.Key),
// };
// }
ConnectPlc(bsNetEqmParamInfo); ConnectPlc(bsNetEqmParamInfo);
} }
@ -72,17 +53,15 @@ namespace HybirdFrameworkServices
/// <returns></returns> /// <returns></returns>
public int ConnectPlc(/*IGrouping<int, BsNetEqmParamInfo> param*/ BsNetEqmParamInfo p) public int ConnectPlc(/*IGrouping<int, BsNetEqmParamInfo> param*/ BsNetEqmParamInfo p)
{ {
/*int connectNum = 0;
foreach (var p in param)
{
connectNum++;*/
Thread thread = new Thread(() => ConnectPlcAsync(p)); Thread thread = new Thread(() => ConnectPlcAsync(p));
thread.Start(); thread.Start();
/*}*/
return 0; return 0;
} }
/// <summary>
/// 连接PLC
/// </summary>
/// <param name="p"></param>
private void ConnectPlcAsync(BsNetEqmParamInfo p) private void ConnectPlcAsync(BsNetEqmParamInfo p)
{ {
bool connected = false; bool connected = false;
@ -94,12 +73,11 @@ namespace HybirdFrameworkServices
master = new ModbusTcpMaster() master = new ModbusTcpMaster()
{ {
Ip = "127.0.0.1", Ip = "172.0.20.66",
Port = 102, Port = 502,
}; };
master.ReadAction = BatchReadPlc;//启动线程一直读 master.ReadAction = BatchReadPlc;//启动线程一直读
master.Duration = 3000; master.Duration = 3000;
master.Duration = 3000;
connected = master.Connect(); connected = master.Connect();
if (connected) if (connected)
@ -111,6 +89,7 @@ namespace HybirdFrameworkServices
} }
ModbusSession modbusSession = new ModbusSession(master); ModbusSession modbusSession = new ModbusSession(master);
master.connectId = master.Ip + master.Port;
SessionMgr.RegisterModbusSession(master.connectId, modbusSession); SessionMgr.RegisterModbusSession(master.connectId, modbusSession);
SessionMgr.SetAttrModbus(modbusSession, "eqm_sn", p.EqmSn); SessionMgr.SetAttrModbus(modbusSession, "eqm_sn", p.EqmSn);
PlcInfo waterColdInfo = new PlcInfo(master.connectId, p.EqmSn); PlcInfo waterColdInfo = new PlcInfo(master.connectId, p.EqmSn);
@ -121,14 +100,34 @@ namespace HybirdFrameworkServices
*/ */
private static void BatchReadPlc(ModbusTcpMaster master) private static void BatchReadPlc(ModbusTcpMaster master)
{ {
int sn = (int)SessionMgr.GetAttrModbus(master.connectId, "eqm_sn"); while (true)
{
int sn = 3;//(int)SessionMgr.GetAttrModbus(master.connectId, "eqm_sn");
ChargerStaticInfo.PlcInfos.TryGetValue(sn, out PlcInfo plcInfo); ChargerStaticInfo.PlcInfos.TryGetValue(sn, out PlcInfo plcInfo);
if (plcInfo == null) if (plcInfo != null)
{
var bytes01 = master.BatchRead(1, 115);
if (bytes01 != null)
{ {
return; ModbusDecoder.Decode<HostToPlc>(bytes01, plcInfo.hostToPlc);
} }
var bytes02 = master.BatchRead(201, 222);
if (bytes02 != null)
{
ModbusDecoder.Decode<PlcToHost>(bytes02, plcInfo.plcToHost);
}
var bytes03 = master.BatchRead(701, 10);
if (bytes03 != null)
{
ModbusDecoder.Decode<PlcFault>(bytes03, plcInfo.plcFault);
}
//OperateResult<byte[]> result2 = ModbusTcpNet.Read("x=3;201", 222);
}
/*
if (plcInfo != null)
{
byte[]? bytes01 = master.BatchRead(0, 22); byte[]? bytes01 = master.BatchRead(0, 22);
if (bytes01 != null) if (bytes01 != null)
{ {
@ -161,5 +160,12 @@ namespace HybirdFrameworkServices
plcInfo.PlcReadAndWritten1.MeterReset = master.ModbusTcpNet.ByteTransform.TransUInt16(bytes08, 0); plcInfo.PlcReadAndWritten1.MeterReset = master.ModbusTcpNet.ByteTransform.TransUInt16(bytes08, 0);
} }
*/
}
}
#endregion PLC
} }
} }

@ -56,10 +56,10 @@ namespace HybirdFrameworkServices.Init.Entity
public int EqmSn; public int EqmSn;
public PlcReadAndWrite1 PlcReadAndWritten1 { get; set; } public HostToPlc hostToPlc=new HostToPlc();
public PlcReadAndWrite2 PlcReadAndWritten2 { get; set; } public PlcToHost plcToHost =new PlcToHost();
public PlcReadonly PlcReadonly { get; set; } public PlcFault plcFault = new PlcFault();
public PlcTurnsRatio PlcTurnsRatio { get; set; }
public PlcInfo(string channelId, int eqmSn) public PlcInfo(string channelId, int eqmSn)
{ {
@ -67,12 +67,20 @@ namespace HybirdFrameworkServices.Init.Entity
EqmSn = eqmSn; EqmSn = eqmSn;
} }
public bool WriteUint16(string addr, ModbusProperty<UInt16> value) public bool WriteUint16(ModbusProperty<UInt16> value)
{ {
bool bResult = false; bool bResult = false;
ModbusSession session = SessionMgr.GetModbusSession(ChannelId); ModbusSession session = SessionMgr.GetModbusSession(ChannelId);
bResult = session.Write<UInt16>(value); bResult = session.Write<UInt16>(value);
return bResult; return bResult;
} }
public bool Writeint16(ModbusProperty<Int16> value)
{
bool bResult = false;
ModbusSession session = SessionMgr.GetModbusSession(ChannelId);
bResult = session.Write<Int16>(value);
return bResult;
}
} }
} }

@ -0,0 +1,87 @@
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkDriver.ModbusTcpMaster;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HybirdFrameworkServices.Plc
{
public class HostToPlc
{
public ModbusProperty<short> ProtocolVersion1 { get; set; } = new(40001); // 协议版本
public ModbusProperty<short> ProtocolVersion2 { get; set; } = new(40002); // 协议版本
public ModbusProperty<short> ProtocolVersion3 { get; set; } = new(40003); // 协议版本
public ModbusProperty<ushort> CommunicationDiagnosis { get; set; } = new(40004); // 通讯诊断
public ModbusProperty<ushort> ModeControl { get; set; } = new(40005); // 模式控制
public ModbusProperty<ushort> EquipmentControl { get; set; } = new(40006); // 设备控制
public ModbusProperty<ushort> ExhaustFanControl { get; set; } = new(40007); // 排风扇控制
public ModbusProperty<ushort> LightingControl { get; set; } = new(40008); // 灯光控制
public ModbusProperty<ushort> Standby1 { get; set; } = new(40009); // 备用
public ModbusProperty<ushort> Standby2 { get; set; } = new(40010); // 备用
public ModbusProperty<ushort> Seconds { get; set; } = new(40011); // 对时时钟:秒
public ModbusProperty<ushort> Points { get; set; } = new(40012); // 对时时钟:分
public ModbusProperty<ushort> Hour { get; set; } = new(40013); // 对时时钟:时
public ModbusProperty<ushort> Day { get; set; } = new(40014); // 对时时钟:天
public ModbusProperty<ushort> Month { get; set; } = new(40015); // 对时时钟:月
public ModbusProperty<ushort> Years { get; set; } = new(40016); // 对时时钟:年
public ModbusProperty<string> Standby3 { get; set; } = new(40017, length: 4); // 备用3
public ModbusProperty<string> ChargingStatus { get; set; } = new(40021, length: 40); // 仓位充电状态
public ModbusProperty<short> ChargingStatus01 { get; set; } = new(40021); // 仓位充电状态
public ModbusProperty<short> ChargingStatus02 { get; set; } = new(40022); // 仓位充电状态
public ModbusProperty<short> ChargingStatus03 { get; set; } = new(40023); // 仓位充电状态
public ModbusProperty<short> ChargingStatus04 { get; set; } = new(40024); // 仓位充电状态
public ModbusProperty<short> ChargingStatus05 { get; set; } = new(40025); // 仓位充电状态
public ModbusProperty<short> ChargingStatus06 { get; set; } = new(40026); // 仓位充电状态
public ModbusProperty<short> ChargingStatus07 { get; set; } = new(40027); // 仓位充电状态
public ModbusProperty<short> ChargingStatus08 { get; set; } = new(40028); // 仓位充电状态
public ModbusProperty<short> ChargingStatus09 { get; set; } = new(40029); // 仓位充电状态
public ModbusProperty<short> ChargingStatus10 { get; set; } = new(40030); // 仓位充电状态
public ModbusProperty<short> ChargingStatus11 { get; set; } = new(40031); // 仓位充电状态
public ModbusProperty<short> ChargingStatus12 { get; set; } = new(40032); // 仓位充电状态
public ModbusProperty<short> ChargingStatus13 { get; set; } = new(40033); // 仓位充电状态
public ModbusProperty<short> ChargingStatus14 { get; set; } = new(40034); // 仓位充电状态
public ModbusProperty<short> ChargingStatus15 { get; set; } = new(40035); // 仓位充电状态
public ModbusProperty<short> ChargingStatus16 { get; set; } = new(40036); // 仓位充电状态
public ModbusProperty<short> ChargingStatus17 { get; set; } = new(40037); // 仓位充电状态
public ModbusProperty<short> ChargingStatus18 { get; set; } = new(40038); // 仓位充电状态
public ModbusProperty<short> ChargingStatus19 { get; set; } = new(40039); // 仓位充电状态
public ModbusProperty<short> ChargingStatus20 { get; set; } = new(40040); // 仓位充电状态
public ModbusProperty<string> BatteryType { get; set; } = new(40061, length: 40); // 仓位所在电池型号
public ModbusProperty<short> BatteryType01 { get; set; } = new(40061); // 仓位所在电池型号
public ModbusProperty<short> BatteryType02 { get; set; } = new(40062); // 仓位所在电池型号
public ModbusProperty<short> BatteryType03 { get; set; } = new(40063); // 仓位所在电池型号
public ModbusProperty<short> BatteryType04 { get; set; } = new(40064); // 仓位所在电池型号
public ModbusProperty<short> BatteryType05 { get; set; } = new(40065); // 仓位所在电池型号
public ModbusProperty<short> BatteryType06 { get; set; } = new(40066); // 仓位所在电池型号
public ModbusProperty<short> BatteryType07 { get; set; } = new(40067); // 仓位所在电池型号
public ModbusProperty<short> BatteryType08 { get; set; } = new(40068); // 仓位所在电池型号
public ModbusProperty<short> BatteryType09 { get; set; } = new(40069); // 仓位所在电池型号
public ModbusProperty<short> BatteryType10 { get; set; } = new(40070); // 仓位所在电池型号
public ModbusProperty<short> BatteryType11 { get; set; } = new(40071); // 仓位所在电池型号
public ModbusProperty<short> BatteryType12 { get; set; } = new(40072); // 仓位所在电池型号
public ModbusProperty<short> BatteryType13 { get; set; } = new(40073); // 仓位所在电池型号
public ModbusProperty<short> BatteryType14 { get; set; } = new(40074); // 仓位所在电池型号
public ModbusProperty<short> BatteryType15 { get; set; } = new(40075); // 仓位所在电池型号
public ModbusProperty<short> BatteryType16 { get; set; } = new(40076); // 仓位所在电池型号
public ModbusProperty<short> BatteryType17 { get; set; } = new(40077); // 仓位所在电池型号
public ModbusProperty<short> BatteryType18 { get; set; } = new(40078); // 仓位所在电池型号
public ModbusProperty<short> BatteryType19 { get; set; } = new(40079); // 仓位所在电池型号
public ModbusProperty<short> BatteryType20 { get; set; } = new(40080); // 仓位所在电池型号
public ModbusProperty<ushort> VehicleParkingLocation { get; set; } = new(40101); // 车辆驻车位置
public ModbusProperty<ushort> VehicleParkingStatus { get; set; } = new(40102); // 车辆驻车状态
public ModbusProperty<ushort> LightIn { get; set; } = new(40103); // "三色灯控制整站状态(入口)"
public ModbusProperty<ushort> LightOut { get; set; } = new(40104); // "三色灯控制整站状态(出口)"
public ModbusProperty<ushort> StopCommand { get; set; } = new(40105); // 电池包锁止异常,暂停命令
public ModbusProperty<string> Standby4 { get; set; } = new(40106, length: 5); // 备用4
public ModbusProperty<ushort> TaskType { get; set; } = new(40111); // 任务类型
public ModbusProperty<ushort> EntrySelection { get; set; } = new(40112); // 入仓位选择
public ModbusProperty<ushort> ExitSelection { get; set; } = new(40113); // 出仓仓位选择
public ModbusProperty<ushort> BatteryPackType { get; set; } = new(40114); // 电池包类型
public ModbusProperty<ushort> TaskEnablement { get; set; } = new(40115); // 任务使能
}
}

@ -0,0 +1,23 @@
using HybirdFrameworkDriver.ModbusTcpMaster;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HybirdFrameworkServices.Plc
{
public class PlcFault
{
public ModbusProperty<ushort> ErrorCode01 { get; set; } = new(40701); // 错误码
public ModbusProperty<ushort> ErrorCode02 { get; set; } = new(40702); // 错误码
public ModbusProperty<ushort> ErrorCode03 { get; set; } = new(40703); // 错误码
public ModbusProperty<ushort> ErrorCode04 { get; set; } = new(40704); // 错误码
public ModbusProperty<ushort> ErrorCode05 { get; set; } = new(40705); // 错误码
public ModbusProperty<ushort> ErrorCode06 { get; set; } = new(40706); // 错误码
public ModbusProperty<ushort> ErrorCode07 { get; set; } = new(40707); // 错误码
public ModbusProperty<ushort> ErrorCode08 { get; set; } = new(40708); // 错误码
public ModbusProperty<ushort> ErrorCode09 { get; set; } = new(40709); // 错误码
public ModbusProperty<ushort> ErrorCode10 { get; set; } = new(40710); // 错误码
}
}

@ -1,66 +0,0 @@
using HybirdFrameworkCore.Autofac.Attribute;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HybirdFrameworkServices.Plc
{
/// <summary>
/// 可读可写区
/// </summary>
public class PlcReadAndWrite1
{
/// <summary>
/// 写编程使能 写 0x5AA5,打开写使能
/// </summary>
[Property(0, 2, PropertyReadConstant.Byte)]
public ushort ProgrammingEnable { get; set; }
/// <summary>
/// 本机modbus地址
/// </summary>
[Property(2, 2, PropertyReadConstant.Byte)]
public ushort Modbus1Addres { get; set; }
/// <summary>
/// 波特率
/// <para>01200</para>
/// <para>12400</para>
/// <para>24800</para>
/// <para>39600</para>
/// <para>419200</para>
/// </summary>
[Property(4, 2, PropertyReadConstant.Byte)]
public ushort BaudRate { get; set; }
/// <summary>
/// 校验位
/// <para>0无</para>
/// <para>1奇</para>
/// <para>2偶</para>
/// </summary>
//[Property(2, 2, PropertyReadConstant.Byte)]
public ushort CheckBit { get; set; }
/// <summary>
/// 秒脉冲/无功电能选择
/// 0x5A02:秒脉冲输出
/// 其他:无功电能输出)
/// </summary>
//[Property(2, 2, PropertyReadConstant.Byte)]
public ushort PulsePerSecond { get; set; }
/// <summary>
/// 电流接线反向
/// <para>0x00:不反接(默认值) </para>
/// <para>0x01:反接</para>
/// </summary>
//[Property(2, 2, PropertyReadConstant.Byte)]
public ushort CurrentReversal { get; set; }
/// <summary>
/// 电表清零
/// 写 0x0000 清零,其他不清
/// </summary>
//[Property(2, 2, PropertyReadConstant.Byte)]
public ushort MeterReset { get; set; }
}
}

@ -1,68 +0,0 @@
using HybirdFrameworkCore.Autofac.Attribute;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HybirdFrameworkServices.Plc
{
public class PlcReadAndWrite2
{
/// <summary>
/// 秒
/// </summary>
[Property(2, 2, PropertyReadConstant.Byte)]
public byte Seconds { get; set; }
/// <summary>
/// 分
/// </summary>
[Property(2, 2, PropertyReadConstant.Byte)]
public byte Points { get; set; }
/// <summary>
/// 时
/// </summary>
[Property(2, 2, PropertyReadConstant.Byte)]
public byte When { get; set; }
/// <summary>
/// 周
/// </summary>
[Property(2, 2, PropertyReadConstant.Byte)]
public byte Weeks { get; set; }
/// <summary>
/// 日
/// </summary>
[Property(2, 2, PropertyReadConstant.Byte)]
public byte Day { get; set; }
/// <summary>
/// 月
/// </summary>
[Property(2, 2, PropertyReadConstant.Byte)]
public byte Month { get; set; }
/// <summary>
/// 年
/// </summary>
[Property(2, 2, PropertyReadConstant.Byte)]
public byte Years { get; set; }
/// <summary>
/// 本机modbus地址
/// </summary>
[Property(2, 2, PropertyReadConstant.Byte)]
public ushort Modbus1Addres2 { get; set; }
/// <summary>
/// 保留
/// </summary>
[Property(2, 2, PropertyReadConstant.Byte)]
public ushort Reserve { get; set; }
/// <summary>
/// 电压变比
/// </summary>
[Property(2, 2, PropertyReadConstant.Byte)]
public ushort VoltageRatio { get; set; }
/// <summary>
/// 电流变比
/// </summary>
[Property(2, 2, PropertyReadConstant.Byte)]
public ushort CurrentRatio { get; set; }
}
}

@ -1,446 +0,0 @@
using HybirdFrameworkCore.Autofac.Attribute;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HybirdFrameworkServices.Plc
{
/// <summary>
/// 只读数据区
/// </summary>
public class PlcReadonly
{
/// <summary>
/// 组合有功总电能
/// </summary>
[Property(0, 4, PropertyReadConstant.Byte, 0.01)]
public Int32 GroupHaveAll { get; set; }
/// <summary>
/// 组合有功尖电能
/// </summary>
[Property(4, 4, PropertyReadConstant.Byte, 0.01)]
public float GroupHaveTip { get; set; }
/// <summary>
/// 组合有功峰电能
/// </summary>
[Property(8, 4, PropertyReadConstant.Byte, 0.01)]
public Int32 GroupHavePeak { get; set; }
/// <summary>
/// 组合有功平电能
/// </summary>
[Property(12, 4, PropertyReadConstant.Byte, 0.01)]
public Int32 GroupHaveFlat { get; set; }
/// <summary>
/// 组合有功谷电能
/// </summary>
[Property(16, 4, PropertyReadConstant.Byte, 0.01)]
public Int32 GroupHaveValley { get; set; }
/// <summary>
/// 正向有功总电能
/// </summary>
[Property(20, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ForwardHaveAll { get; set; }
/// <summary>
/// 正向有功尖电能
/// </summary>
[Property(24, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ForwardHaveTip { get; set; }
/// <summary>
/// 正向有功峰电能
/// </summary>
[Property(28, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ForwardHavePeak { get; set; }
/// <summary>
/// 正向有功平电能
/// </summary>
[Property(32, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ForwardHaveFlat { get; set; }
/// <summary>
/// 正向有功谷电能
/// </summary>
[Property(36, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ForwardHaveValley { get; set; }
/// <summary>
/// 反向有功总电能
/// </summary>
[Property(40, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ReverseHaveAll { get; set; }
/// <summary>
/// 反向有功尖电能
/// </summary>
[Property(44, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ReverseHaveTip { get; set; }
/// <summary>
/// 反向有功峰电能
/// </summary>
[Property(48, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ReverseHavePeak { get; set; }
/// <summary>
/// 反向有功平电能
/// </summary>
[Property(52, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ReverseHaveFlat { get; set; }
/// <summary>
/// 反向有功谷电能
/// </summary>
[Property(56, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ReverseHaveValley { get; set; }
/// <summary>
/// 组合无功1总电能
/// </summary>
[Property(60, 4, PropertyReadConstant.Byte, 0.01)]
public float GroupNoAll1 { get; set; }
/// <summary>
/// 组合无功1尖电能
/// </summary>
[Property(64, 4, PropertyReadConstant.Byte, 0.01)]
public Int32 GroupNoTip1 { get; set; }
/// <summary>
/// 组合无功1峰电能
/// </summary>
[Property(68, 4, PropertyReadConstant.Byte, 0.01)]
public Int32 GroupNoPeak1 { get; set; }
/// <summary>
/// 组合无功1平电能
/// </summary>
[Property(72, 4, PropertyReadConstant.Byte, 0.01)]
public Int32 GroupNoFlat1 { get; set; }
/// <summary>
/// 组合无功1谷电能
/// </summary>
[Property(76, 4, PropertyReadConstant.Byte, 0.01)]
public Int32 GroupNoValley1 { get; set; }
/// <summary>
/// 组合无功2总电能
/// </summary>
[Property(80, 4, PropertyReadConstant.Byte, 0.01)]
public Int32 GroupNoAll2 { get; set; }
/// <summary>
/// 组合无功2尖电能
/// </summary>
[Property(84, 4, PropertyReadConstant.Byte, 0.01)]
public Int32 GroupNoTip2 { get; set; }
/// <summary>
/// 组合无功2峰电能
/// </summary>
[Property(88, 4, PropertyReadConstant.Byte, 0.01)]
public Int32 GroupNoPeak2 { get; set; }
/// <summary>
/// 组合无功2平电能
/// </summary>
[Property(92, 4, PropertyReadConstant.Byte, 0.01)]
public Int32 GroupNoFlat2 { get; set; }
/// <summary>
/// 组合无功2谷电能
/// </summary>
[Property(96, 4, PropertyReadConstant.Byte, 0.01)]
public Int32 GroupNoValley2 { get; set; }
/// <summary>
/// 一象限无功总电能
/// </summary>
[Property(100, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoAll1 { get; set; }
/// <summary>
/// 一象限无功尖电能
/// </summary>
[Property(104, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoTip1 { get; set; }
/// <summary>
/// 一象限无功峰电能
/// </summary>
[Property(108, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoPeak1 { get; set; }
/// <summary>
/// 一象限无功平电能
/// </summary>
[Property(112, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoFlat1 { get; set; }
/// <summary>
/// 一象限无功谷电能
/// </summary>
[Property(116, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoValley1 { get; set; }
/// <summary>
/// 二象限无功总电能
/// </summary>
[Property(120, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoAll2 { get; set; }
/// <summary>
/// 二象限无功尖电能
/// </summary>
[Property(124, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoTip2 { get; set; }
/// <summary>
/// 二象限无功峰电能
/// </summary>
[Property(128, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoPeak2 { get; set; }
/// <summary>
/// 二象限无功平电能
/// </summary>
[Property(132, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoFlat2 { get; set; }
/// <summary>
/// 二象限无功谷电能
/// </summary>
[Property(136, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoValley2 { get; set; }
/// <summary>
/// 三象限无功总电能
/// </summary>
[Property(140, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoAll3 { get; set; }
/// <summary>
/// 三象限无功尖电能
/// </summary>
[Property(144, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoTip3 { get; set; }
/// <summary>
/// 三象限无功峰电能
/// </summary>
[Property(148, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoPeak3 { get; set; }
/// <summary>
/// 三象限无功平电能
/// </summary>
[Property(152, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoFlat3 { get; set; }
/// <summary>
/// 三象限无功谷电能
/// </summary>
[Property(156, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoValley3 { get; set; }
/// <summary>
/// 四象限无功总电能
/// </summary>
[Property(160, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoAll4 { get; set; }
/// <summary>
/// 四象限无功尖电能
/// </summary>
[Property(164, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoTip4 { get; set; }
/// <summary>
/// 四象限无功峰电能
/// </summary>
[Property(168, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoPeak4 { get; set; }
/// <summary>
/// 四象限无功平电能
/// </summary>
[Property(172, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoFlat4 { get; set; }
/// <summary>
/// 四象限无功谷电能
/// </summary>
[Property(176, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 QuadrantNoValley4 { get; set; }
/// <summary>
/// 正向视在总电能
/// </summary>
[Property(180, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ForwardHaveApparentAll { get; set; }
/// <summary>
/// 正向视在尖电能
/// </summary>
[Property(184, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ForwardHaveApparentTip { get; set; }
/// <summary>
/// 正向视在峰电能
/// </summary>
[Property(188, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ForwardHaveApparentPeak { get; set; }
/// <summary>
/// 正向视在平电能
/// </summary>
[Property(192, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ForwardHaveApparentFlat { get; set; }
/// <summary>
/// 正向视在谷电能
/// </summary>
[Property(196, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ForwardHaveApparentValley { get; set; }
/// <summary>
/// 反向视在总电能
/// </summary>
[Property(200, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ReverseHaveApparentAll { get; set; }
/// <summary>
/// 反向视在尖电能
/// </summary>
[Property(204, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ReverseHaveApparentTip { get; set; }
/// <summary>
/// 反向视在峰电能
/// </summary>
[Property(208, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ReverseHaveApparentPeak { get; set; }
/// <summary>
/// 反向视在平电能
/// </summary>
[Property(212, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ReverseHaveApparentFlat { get; set; }
/// <summary>
/// 反向视在谷电能
/// </summary>
[Property(216, 4, PropertyReadConstant.Byte, 0.01)]
public UInt32 ReverseHaveApparentValley { get; set; }
/// <summary>
/// A 相电压
/// </summary>
[Property(220, 4, PropertyReadConstant.Byte, 0.0001)]
public UInt32 PhaseVoltageA { get; set; }
/// <summary>
/// B 相电压
/// </summary>
[Property(224, 4, PropertyReadConstant.Byte, 0.0001)]
public UInt32 PhaseVoltageB { get; set; }
/// <summary>
/// C 相电压
/// </summary>
[Property(228, 4, PropertyReadConstant.Byte, 0.0001)]
public UInt32 PhaseVoltageC { get; set; }
/// <summary>
/// A 相电流
/// </summary>
[Property(232, 4, PropertyReadConstant.Byte, 0.0001)]
public UInt32 PhaseElectricityA { get; set; }
/// <summary>
/// B 相电流
/// </summary>
[Property(236, 4, PropertyReadConstant.Byte, 0.0001)]
public UInt32 PhaseElectricityB { get; set; }
/// <summary>
/// C 相电流
/// </summary>
[Property(240, 4, PropertyReadConstant.Byte, 0.0001)]
public UInt32 PhaseElectricityC { get; set; }
/// <summary>
/// 有功总功率
/// </summary>
[Property(244, 4, PropertyReadConstant.Byte, 0.0001)]
public Int32 TotalActivePower { get; set; }
/// <summary>
/// A 相有功总功率
/// </summary>
[Property(248, 4, PropertyReadConstant.Byte, 0.0001)]
public Int32 TotalActivePowerA { get; set; }
/// <summary>
/// B 相有功总功率
/// </summary>
[Property(252, 4, PropertyReadConstant.Byte, 0.0001)]
public Int32 TotalActivePowerB { get; set; }
/// <summary>
/// C 相有功总功率
/// </summary>
[Property(256, 4, PropertyReadConstant.Byte, 0.0001)]
public Int32 TotalActivePowerC { get; set; }
/// <summary>
/// 无功总功率
/// </summary>
[Property(260, 4, PropertyReadConstant.Byte, 0.0001)]
public Int32 TotalReactivePower { get; set; }
/// <summary>
/// A 相无功总功率
/// </summary>
[Property(264, 4, PropertyReadConstant.Byte, 0.0001)]
public Int32 TotalReactivePowerA { get; set; }
/// <summary>
/// B 相无功总功率
/// </summary>
[Property(268, 4, PropertyReadConstant.Byte, 0.0001)]
public Int32 TotalReactivePowerB { get; set; }
/// <summary>
/// C 相无功总功率
/// </summary>
[Property(272, 4, PropertyReadConstant.Byte, 0.0001)]
public UInt32 TotalReactivePowerC { get; set; }
/// <summary>
/// 总视在功率
/// </summary>
[Property(276, 4, PropertyReadConstant.Byte, 0.0001)]
public UInt32 TotalApparentPower { get; set; }
/// <summary>
/// A 相视在功率
/// </summary>
[Property(280, 4, PropertyReadConstant.Byte, 0.0001)]
public UInt32 TotalApparentPowerA { get; set; }
/// <summary>
/// B 相视在功率
/// </summary>
[Property(284, 4, PropertyReadConstant.Byte, 0.0001)]
public UInt32 TotalApparentPowerB { get; set; }
/// <summary>
/// C 相视在功率
/// </summary>
[Property(288, 4, PropertyReadConstant.Byte, 0.0001)]
public UInt32 TotalApparentPowerC { get; set; }
/// <summary>
/// 总功率因数
/// </summary>
[Property(292, 2, PropertyReadConstant.Byte, 0.001)]
public short OverallPowerFactor { get; set; }
/// <summary>
/// A 相功率因数
/// </summary>
[Property(294, 2, PropertyReadConstant.Byte, 0.001)]
public short OverallPowerFactorA { get; set; }
/// <summary>
/// B 相功率因数
/// </summary>
[Property(296, 2, PropertyReadConstant.Byte, 0.001)]
public short OverallPowerFactorB { get; set; }
/// <summary>
/// C 相功率因数
/// </summary>
[Property(298, 2, PropertyReadConstant.Byte, 0.001)]
public short OverallPowerFactorC { get; set; }
/// <summary>
/// A 相相角
/// </summary>
[Property(300, 2, PropertyReadConstant.Byte, 0.01)]
public ushort PhaseAngleA { get; set; }
/// <summary>
/// B 相相角
/// </summary>
[Property(302, 2, PropertyReadConstant.Byte, 0.01)]
public ushort PhaseAngleB { get; set; }
/// <summary>
/// C 相相角
/// </summary>
[Property(304, 2, PropertyReadConstant.Byte, 0.01)]
public ushort PhaseAngleC { get; set; }
/// <summary>
/// 电网频率
/// </summary>
[Property(306, 2, PropertyReadConstant.Byte, 0.01)]
public ushort LineFrequency { get; set; }
/// <summary>
/// A 相线电压
/// </summary>
[Property(308, 4, PropertyReadConstant.Byte, 0.0001)]
public float PhaseLineVoltageA { get; set; }
/// <summary>
/// B 相线电压
/// </summary>
[Property(312, 4, PropertyReadConstant.Byte, 0.0001)]
public float PhaseLineVoltageB { get; set; }
/// <summary>
/// C 相线电压
/// </summary>
[Property(316, 4, PropertyReadConstant.Byte, 0.0001)]
public float PhaseLineVoltageC { get; set; }
/// <summary>
/// 三相平均线电压
/// </summary>
[Property(320, 4, PropertyReadConstant.Byte, 0.0001)]
public float ThreePhaseMeanLineVoltage { get; set; }
/// <summary>
/// 三相平均相电压
/// </summary>
[Property(324, 4, PropertyReadConstant.Byte, 0.0001)]
public float ThreePhaseMeanPhaseVoltage { get; set; }
}
}

@ -0,0 +1,69 @@
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkDriver.ModbusTcpMaster;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HybirdFrameworkServices.Plc
{
/// <summary>
///
/// </summary>
public class PlcToHost
{
public ModbusProperty<ushort> ProtocolVersion1 { get; set; } = new(40201); // 协议版本
public ModbusProperty<ushort> ProtocolVersion2 { get; set; } = new(40202); // 协议版本
public ModbusProperty<ushort> ProtocolVersion3 { get; set; } = new(40203); // 协议版本
public ModbusProperty<ushort> CommunicationDiagnosis { get; set; } = new(40204); // 通讯诊断
public ModbusProperty<ushort> ModeControl { get; set; } = new(40205); // 模式状态
public ModbusProperty<ushort> DeviceSystemStatus { get; set; } = new(40206); // 设备系统状态
//public ModbusProperty<bool> type00 { get; set; } = new(400206,length:1, type: ModbusDataType.Bit); //BIT0:复位
//public ModbusProperty<bool> type01 { get; set; } = new(400206,length:1, type: ModbusDataType.Bit); //BIT1:启动
//public ModbusProperty<bool> type02 { get; set; } = new(400206,length:1, type: ModbusDataType.Bit); //BIT2:暂停
//public ModbusProperty<bool> type03 { get; set; } = new(400206,length:1, type: ModbusDataType.Bit); //BIT3:急停
//public ModbusProperty<bool> type04 { get; set; } = new(400206,length:1, type: ModbusDataType.Bit); //BIT4:
//public ModbusProperty<bool> type05 { get; set; } = new(400206,length:1, type: ModbusDataType.Bit); //BIT5:整站断电
//public ModbusProperty<bool> type06 { get; set; } = new(400206,length:1, type: ModbusDataType.Bit); //BIT6:自动运行中
//public ModbusProperty<bool> type07 { get; set; } = new(400206,length:1, type: ModbusDataType.Bit); //BIT7:PLC停机报警
//public ModbusProperty<bool> type08 { get; set; } = new(400206,length:1, type: ModbusDataType.Bit); //BIT8:PLC提示预警
public ModbusProperty<ushort> RemoteLocalControlState { get; set; } = new(40207); // 遥本控状态
public ModbusProperty<ushort> LightStatus { get; set; } = new(40208); // 灯光状态
public ModbusProperty<ushort> ExhaustFanStatus { get; set; } = new(40209); // 排风扇状态
public ModbusProperty<ushort> WaterStatusStation { get; set; } = new(40210); // 站内积水状态
public ModbusProperty<string> value09 { get; set; } = new(40211, length: 30); // 备用
public ModbusProperty<string> InPosition { get; set; } = new(40241, length: 40); // 在位状态
public ModbusProperty<string> value11 { get; set; } = new(40281, length: 20); // 备用
public ModbusProperty<ushort> CarStatus { get; set; } = new(40301); // 载行车设备状态
public ModbusProperty<ushort> value13 { get; set; } = new(40302); // 备用
public ModbusProperty<ushort> value14 { get; set; } = new(40303); // 备用
public ModbusProperty<ushort> value15 { get; set; } = new(40304); // 备用
public ModbusProperty<ushort> value16 { get; set; } = new(40305); // 备用
public ModbusProperty<short> PercentageTorqueX { get; set; } = new(40306); // x轴扭矩百分比
public ModbusProperty<short> PercentageTorqueY { get; set; } = new(40307); // y轴扭矩百分比
public ModbusProperty<short> PercentageTorqueZ { get; set; } = new(40308); // z轴扭矩百分比
public ModbusProperty<string> value20 { get; set; } = new(40309, length: 92); // 备用
public ModbusProperty<ushort> RadarStatesIn{ get; set; } = new(40401); // " 入口雷达状态"
public ModbusProperty<ushort> RadarStatesOut { get; set; } = new(40402); // " 出口雷达状态"
public ModbusProperty<ushort> SpotPhotoelectricSignal { get; set; } = new(40403); // 到位光电信号
public ModbusProperty<ushort> PhysicalButtonState { get; set; } = new(40404); // 实体按钮状态
public ModbusProperty<ushort> LightIn { get; set; } = new(40405); // "三色灯控制通道状态(入口)"
public ModbusProperty<ushort> LightOut { get; set; } = new(40406); // "三色灯控制通道状态(出口)"
public ModbusProperty<ushort> TaskType { get; set; } = new(40407); // "任务类型状态(是否允许允许执行任务)"
public ModbusProperty<ushort> TaskStates { get; set; } = new(40408); // 任务状态
public ModbusProperty<ushort> OperationalTrainNumber { get; set; } = new(40409); // 执行任务行车号
public ModbusProperty<ushort> ChannelLocationState { get; set; } = new(40410); // 通道定位状态
public ModbusProperty<short> DeviationX { get; set; } = new(40411); // x偏差
public ModbusProperty<short> DeviationY { get; set; } = new(40412); // y偏差
public ModbusProperty<short> DeviationZ { get; set; } = new(40413); // z偏差
public ModbusProperty<string> value44 { get; set; } = new(40414, length: 7); // 备用
}
}

@ -1,291 +0,0 @@
using HybirdFrameworkCore.Autofac.Attribute;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HybirdFrameworkServices.Plc
{
/// <summary>
/// 乘变比电能数据区(浮点数)(乘变比)
/// </summary>
public class PlcTurnsRatio
{
/// <summary>
/// 组合有功总电能
/// </summary>
[Property(0, 4, PropertyReadConstant.Byte)]
public float GroupHaveAll { get; set; }
/// <summary>
/// 组合有功尖电能
/// </summary>
[Property(4, 4, PropertyReadConstant.Byte)]
public float GroupHaveTip { get; set; }
/// <summary>
/// 组合有功峰电能
/// </summary>
[Property(8, 4, PropertyReadConstant.Byte)]
public float GroupHavePeak { get; set; }
/// <summary>
/// 组合有功平电能
/// </summary>
[Property(12, 4, PropertyReadConstant.Byte)]
public float GroupHaveFlat { get; set; }
/// <summary>
/// 组合有功谷电能
/// </summary>
[Property(16, 4, PropertyReadConstant.Byte)]
public float GroupHaveValley { get; set; }
/// <summary>
/// 正向有功总电能
/// </summary>
[Property(20, 4, PropertyReadConstant.Byte)]
public float ForwardHaveAll { get; set; }
/// <summary>
/// 正向有功尖电能
/// </summary>
[Property(24, 4, PropertyReadConstant.Byte)]
public float ForwardHaveTip { get; set; }
/// <summary>
/// 正向有功峰电能
/// </summary>
[Property(28, 4, PropertyReadConstant.Byte)]
public float ForwardHavePeak { get; set; }
/// <summary>
/// 正向有功平电能
/// </summary>
[Property(32, 4, PropertyReadConstant.Byte)]
public float ForwardHaveFlat { get; set; }
/// <summary>
/// 正向有功谷电能
/// </summary>
[Property(36, 4, PropertyReadConstant.Byte)]
public float ForwardHaveValley { get; set; }
/// <summary>
/// 反向有功总电能
/// </summary>
[Property(40, 4, PropertyReadConstant.Byte)]
public float ReverseHaveAll { get; set; }
/// <summary>
/// 反向有功尖电能
/// </summary>
[Property(44, 4, PropertyReadConstant.Byte)]
public float ReverseHaveTip { get; set; }
/// <summary>
/// 反向有功峰电能
/// </summary>
[Property(48, 4, PropertyReadConstant.Byte)]
public float ReverseHavePeak { get; set; }
/// <summary>
/// 反向有功平电能
/// </summary>
[Property(52, 4, PropertyReadConstant.Byte)]
public float ReverseHaveFlat { get; set; }
/// <summary>
/// 反向有功谷电能
/// </summary>
[Property(56, 4, PropertyReadConstant.Byte)]
public float ReverseHaveValley { get; set; }
/// <summary>
/// 组合无功1总电能
/// </summary>
[Property(60, 4, PropertyReadConstant.Byte)]
public float GroupNoAll1 { get; set; }
/// <summary>
/// 组合无功1尖电能
/// </summary>
[Property(64, 4, PropertyReadConstant.Byte)]
public float GroupNoTip1 { get; set; }
/// <summary>
/// 组合无功1峰电能
/// </summary>
[Property(68, 4, PropertyReadConstant.Byte)]
public float GroupNoPeak1 { get; set; }
/// <summary>
/// 组合无功1平电能
/// </summary>
[Property(72, 4, PropertyReadConstant.Byte)]
public float GroupNoFlat1 { get; set; }
/// <summary>
/// 组合无功1谷电能
/// </summary>
[Property(76, 4, PropertyReadConstant.Byte)]
public float GroupNoValley1 { get; set; }
/// <summary>
/// 组合无功2总电能
/// </summary>
[Property(80, 4, PropertyReadConstant.Byte)]
public float GroupNoAll2 { get; set; }
/// <summary>
/// 组合无功2尖电能
/// </summary>
[Property(84, 4, PropertyReadConstant.Byte)]
public float GroupNoTip2 { get; set; }
/// <summary>
/// 组合无功2峰电能
/// </summary>
[Property(88, 4, PropertyReadConstant.Byte)]
public float GroupNoPeak2 { get; set; }
/// <summary>
/// 组合无功2平电能
/// </summary>
[Property(92, 4, PropertyReadConstant.Byte)]
public float GroupNoFlat2 { get; set; }
/// <summary>
/// 组合无功2谷电能
/// </summary>
[Property(96, 4, PropertyReadConstant.Byte)]
public float GroupNoValley2 { get; set; }
/// <summary>
/// 一象限无功总电能
/// </summary>
[Property(100, 4, PropertyReadConstant.Byte)]
public float QuadrantNoAll1 { get; set; }
/// <summary>
/// 一象限无功尖电能
/// </summary>
[Property(104, 4, PropertyReadConstant.Byte)]
public float QuadrantNoTip1 { get; set; }
/// <summary>
/// 一象限无功峰电能
/// </summary>
[Property(108, 4, PropertyReadConstant.Byte)]
public float QuadrantNoPeak1 { get; set; }
/// <summary>
/// 一象限无功平电能
/// </summary>
[Property(112, 4, PropertyReadConstant.Byte)]
public float QuadrantNoFlat1 { get; set; }
/// <summary>
/// 一象限无功谷电能
/// </summary>
[Property(116, 4, PropertyReadConstant.Byte)]
public float QuadrantNoValley1 { get; set; }
/// <summary>
/// 二象限无功总电能
/// </summary>
[Property(120, 4, PropertyReadConstant.Byte)]
public float QuadrantNoAll2 { get; set; }
/// <summary>
/// 二象限无功尖电能
/// </summary>
[Property(124, 4, PropertyReadConstant.Byte)]
public float QuadrantNoTip2 { get; set; }
/// <summary>
/// 二象限无功峰电能
/// </summary>
[Property(128, 4, PropertyReadConstant.Byte)]
public float QuadrantNoPeak2 { get; set; }
/// <summary>
/// 二象限无功平电能
/// </summary>
[Property(132, 4, PropertyReadConstant.Byte)]
public float QuadrantNoFlat2 { get; set; }
/// <summary>
/// 二象限无功谷电能
/// </summary>
[Property(136, 4, PropertyReadConstant.Byte)]
public float QuadrantNoValley2 { get; set; }
/// <summary>
/// 三象限无功总电能
/// </summary>
[Property(140, 4, PropertyReadConstant.Byte)]
public float QuadrantNoAll3 { get; set; }
/// <summary>
/// 三象限无功尖电能
/// </summary>
[Property(144, 4, PropertyReadConstant.Byte)]
public float QuadrantNoTip3 { get; set; }
/// <summary>
/// 三象限无功峰电能
/// </summary>
[Property(148, 4, PropertyReadConstant.Byte)]
public float QuadrantNoPeak3 { get; set; }
/// <summary>
/// 三象限无功平电能
/// </summary>
[Property(152, 4, PropertyReadConstant.Byte)]
public float QuadrantNoFlat3 { get; set; }
/// <summary>
/// 三象限无功谷电能
/// </summary>
[Property(156, 4, PropertyReadConstant.Byte)]
public float QuadrantNoValley3 { get; set; }
/// <summary>
/// 四象限无功总电能
/// </summary>
[Property(160, 4, PropertyReadConstant.Byte)]
public float QuadrantNoAll4 { get; set; }
/// <summary>
/// 四象限无功尖电能
/// </summary>
[Property(164, 4, PropertyReadConstant.Byte)]
public float QuadrantNoTip4 { get; set; }
/// <summary>
/// 四象限无功峰电能
/// </summary>
[Property(168, 4, PropertyReadConstant.Byte)]
public float QuadrantNoPeak4 { get; set; }
/// <summary>
/// 四象限无功平电能
/// </summary>
[Property(172, 4, PropertyReadConstant.Byte)]
public float QuadrantNoFlat4 { get; set; }
/// <summary>
/// 四象限无功谷电能
/// </summary>
[Property(176, 4, PropertyReadConstant.Byte)]
public float QuadrantNoValley4 { get; set; }
/// <summary>
/// 正向视在总电能
/// </summary>
[Property(180, 4, PropertyReadConstant.Byte)]
public float ForwardHaveApparentAll { get; set; }
/// <summary>
/// 正向视在尖电能
/// </summary>
[Property(184, 4, PropertyReadConstant.Byte)]
public float ForwardHaveApparentTip { get; set; }
/// <summary>
/// 正向视在峰电能
/// </summary>
[Property(188, 4, PropertyReadConstant.Byte)]
public float ForwardHaveApparentPeak { get; set; }
/// <summary>
/// 正向视在平电能
/// </summary>
[Property(192, 4, PropertyReadConstant.Byte)]
public float ForwardHaveApparentFlat { get; set; }
/// <summary>
/// 正向视在谷电能
/// </summary>
[Property(196, 4, PropertyReadConstant.Byte)]
public float ForwardHaveApparentValley { get; set; }
/// <summary>
/// 反向视在总电能
/// </summary>
[Property(200, 4, PropertyReadConstant.Byte)]
public float ReverseHaveApparentAll { get; set; }
/// <summary>
/// 反向视在尖电能
/// </summary>
[Property(204, 4, PropertyReadConstant.Byte)]
public float ReverseHaveApparentTip { get; set; }
/// <summary>
/// 反向视在峰电能
/// </summary>
[Property(208, 4, PropertyReadConstant.Byte)]
public float ReverseHaveApparentPeak { get; set; }
/// <summary>
/// 反向视在平电能
/// </summary>
[Property(212, 4, PropertyReadConstant.Byte)]
public float ReverseHaveApparentFlat { get; set; }
/// <summary>
/// 反向视在谷电能
/// </summary>
[Property(216, 4, PropertyReadConstant.Byte)]
public float ReverseHaveApparentValley { get; set; }
}
}

@ -12,6 +12,7 @@ public partial class Form2 : Form
InitializeComponent(); InitializeComponent();
_server.Start(9000); _server.Start(9000);
new FrmPLCConnect().Show(); new FrmPlc().Show();
//new FrmPLCConnect().Show();
} }
} }

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

File diff suppressed because it is too large Load Diff

@ -1,648 +0,0 @@
using HslCommunication;
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;
using System.Data;
using System.Drawing;
using System.Linq;
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
{
public partial class FrmPLCConnect : Form
{
#region 连接参数
/// <summary>
/// ModbusTcp客户端
/// </summary>
public static ModbusTcpNet _client = null;
public string _ipaddr
{
get
{
return TxtIp.Text;
}
set { }
}
public int _port
{
get
{
return Convert.ToInt32(TxtPort.Text);
}
set { }
}
public byte _site
{
get
{
return Convert.ToByte(TxtSite.Text);
}
set { }
}
#endregion
PlcDate PlcDate = new PlcDate();
public FrmPLCConnect()
{
InitializeComponent();
}
#region 连接
private void BtnConnect_Click(object sender, EventArgs e)
{
//简单判断
if (string.IsNullOrEmpty(_ipaddr))
{
MessageBox.Show("IP地址不能为空");
return;
}
if (string.IsNullOrEmpty(TxtPort.Text))
{
MessageBox.Show("端口号不能为空");
return;
}
if (string.IsNullOrEmpty(TxtSite.Text))
{
MessageBox.Show("站号不能为空");
return;
}
_client = new ModbusTcpNet(_ipaddr, _port, _site);
OperateResult OptRet = _client.ConnectServer();
if (OptRet.IsSuccess)
{
LblConState.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "连接成功";
BtnCollectionAssignment.Enabled = true;
//OperateResult writeResult = _client.Write("x=6;1", "");
}
if (OptRet.IsSuccess)
{
LblConState.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "连接失败";
}
}
#endregion
#region 读取
private void BtnCollectionAssignment_Click(object sender, EventArgs e)
{
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 = 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 = 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
}
}
#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
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,555 @@
using HslCommunication.ModBus;
using HslCommunication;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using HybirdFrameworkDriver.ModbusTcpMaster;
using HybirdFrameworkServices.Init.Entity;
using HybirdFrameworkServices.Plc;
using HybirdFrameworkDriver.TcpServer;
using Newtonsoft.Json.Linq;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace WinFormStarter
{
public partial class FrmPlc : Form
{
public FrmPlc()
{
InitializeComponent();
}
ModbusTcpNet ModbusTcpNet;
int heart = 0;
private void BtnWrite01_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue04.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.CommunicationDiagnosis.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.CommunicationDiagnosis);
}
private void BtnWrite02_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue05.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.ModeControl.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.ModeControl);
}
private void BtnWrite03_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue06.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.EquipmentControl.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.EquipmentControl);
}
private void BtnWrite04_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue07.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.ExhaustFanControl.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.ExhaustFanControl);
}
private void BtnWrite05_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue08.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.LightingControl.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.LightingControl);
}
private void BtnWrite06_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue09.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.Seconds.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.Seconds);
}
private void BtnWrite07_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue10.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.Points.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.Points);
}
private void BtnWrite08_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue11.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.Hour.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.Hour);
}
private void BtnWrite09_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue12.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.Day.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.Day);
}
private void BtnWrite10_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue13.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.Month.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.Month);
}
private void BtnWrite11_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue14.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.Years.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.Years);
}
/// <summary>
/// 车辆驻车位置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BtnWrite14_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue15.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.VehicleParkingLocation.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.VehicleParkingLocation);
}
private void BtnWrite15_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue16.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.VehicleParkingStatus.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.VehicleParkingStatus);
}
/// <summary>
/// 三色灯
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BtnWrite16_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue17.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.LightIn.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.LightIn);
}
private void BtnWrite17_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue16.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.LightOut.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.LightOut);
}
/// <summary>
/// 锁止异常
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BtnWrite18_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue19.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.StopCommand.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.StopCommand);
}
private void button3_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue20.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.TaskType.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.TaskType);
}
/// <summary>
/// 入仓仓位选择
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue21.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.EntrySelection.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.EntrySelection);
}
private void button1_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue22.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.ExitSelection.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.ExitSelection);
}
private void button5_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue23.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.BatteryPackType.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.BatteryPackType);
}
private void button4_Click(object sender, EventArgs e)
{
bool bConvert = ushort.TryParse(this.txtValue24.Text, out ushort iValue);
if (!bConvert)
{
MessageBox.Show("请输入有效值");
return;
}
ChargerStaticInfo.PlcInfos.TryGetValue(1, out PlcInfo plcInfo);
if (plcInfo == null)
{
MessageBox.Show("PLC未连接");
return;
}
plcInfo.hostToPlc.TaskEnablement.Value = iValue;
bool bResult = plcInfo.WriteUint16(plcInfo.hostToPlc.TaskEnablement);
}
private void button6_Click(object sender, EventArgs e)
{
bool bConvert1 = short.TryParse(this.txtValue01.Text, out short iValue1);
bool bConvert2 = short.TryParse(this.txtValue02.Text, out short iValue2);
bool bConvert3 = short.TryParse(this.txtValue03.Text, out short iValue3);
ChargerStaticInfo.PlcInfos.TryGetValue(3, out PlcInfo plcInfo);
if (plcInfo != null)
{
HostToPlc hostToPlc = new HostToPlc();
hostToPlc.ProtocolVersion1.Value = iValue1;
hostToPlc.ProtocolVersion2.Value = iValue2;
hostToPlc.ProtocolVersion3.Value = iValue3;
plcInfo.Writeint16(hostToPlc.ProtocolVersion1);
plcInfo.Writeint16(hostToPlc.ProtocolVersion2);
plcInfo.Writeint16(hostToPlc.ProtocolVersion3);
}
}
/// <summary>
/// 把采集值显示上来
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BtnCollectionAssignment_Click(object sender, EventArgs e)
{
ChargerStaticInfo.PlcInfos.TryGetValue(3, out PlcInfo plcInfo);
if (plcInfo != null)
{
lblValue01.Text = plcInfo.plcToHost.ProtocolVersion1.Value + "." +
plcInfo.plcToHost.ProtocolVersion2.Value + "." +
plcInfo.plcToHost.ProtocolVersion3.Value;
lblValue02.Text = plcInfo.plcToHost.CommunicationDiagnosis.Value.ToString();
lblValue03.Text = plcInfo.plcToHost.ModeControl.Value.ToString();
lblValue04.Text = plcInfo.plcToHost.DeviceSystemStatus.Value.ToString();
lblValue05.Text = plcInfo.plcToHost.RemoteLocalControlState.Value.ToString();
lblValue06.Text = plcInfo.plcToHost.LightStatus.Value.ToString();
lblValue07.Text = plcInfo.plcToHost.ExhaustFanStatus.Value.ToString();
lblValue08.Text = plcInfo.plcToHost.WaterStatusStation.Value.ToString();
lblValue09.Text = plcInfo.plcToHost.InPosition.Value.ToString();
lblValue10.Text = plcInfo.plcToHost.CarStatus.Value.ToString();
lblValue11.Text = plcInfo.plcToHost.PercentageTorqueX.Value.ToString();
lblValue12.Text = plcInfo.plcToHost.PercentageTorqueY.Value.ToString();
lblValue13.Text = plcInfo.plcToHost.PercentageTorqueZ.Value.ToString();
lblValue14.Text = plcInfo.plcToHost.RadarStatesIn.Value.ToString();
lblValue15.Text = plcInfo.plcToHost.RadarStatesOut.Value.ToString();
lblValue16.Text = plcInfo.plcToHost.SpotPhotoelectricSignal.Value.ToString();
lblValue17.Text = plcInfo.plcToHost.PhysicalButtonState.Value.ToString();
lblValue18.Text = plcInfo.plcToHost.LightIn.Value.ToString();
lblValue19.Text = plcInfo.plcToHost.LightOut.Value.ToString();
lblValue20.Text = plcInfo.plcToHost.TaskType.Value.ToString();
lblValue21.Text = plcInfo.plcToHost.TaskStates.Value.ToString();
lblValue22.Text = plcInfo.plcToHost.OperationalTrainNumber.Value.ToString();
lblValue23.Text = plcInfo.plcToHost.ChannelLocationState.Value.ToString();
lblValue24.Text = plcInfo.plcToHost.DeviationX.Value.ToString();
lblValue25.Text = plcInfo.plcToHost.DeviationY.Value.ToString();
lblValue26.Text = plcInfo.plcToHost.DeviationZ.Value.ToString();
txtValue01.Text = plcInfo.hostToPlc.ProtocolVersion1.Value.ToString();
txtValue02.Text = plcInfo.hostToPlc.ProtocolVersion2.Value.ToString();
txtValue03.Text = plcInfo.hostToPlc.ProtocolVersion3.Value.ToString();
txtValue04.Text = plcInfo.hostToPlc.CommunicationDiagnosis.Value.ToString();
txtValue05.Text = plcInfo.hostToPlc.ModeControl.Value.ToString();
txtValue06.Text = plcInfo.hostToPlc.EquipmentControl.Value.ToString();
txtValue07.Text = plcInfo.hostToPlc.ExhaustFanControl.Value.ToString();
txtValue08.Text = plcInfo.hostToPlc.LightingControl.Value.ToString();
txtValue09.Text = plcInfo.hostToPlc.Seconds.Value.ToString();
txtValue10.Text = plcInfo.hostToPlc.Points.Value.ToString();
txtValue11.Text = plcInfo.hostToPlc.Hour.Value.ToString();
txtValue12.Text = plcInfo.hostToPlc.Day.Value.ToString();
txtValue13.Text = plcInfo.hostToPlc.Month.Value.ToString();
txtValue14.Text = plcInfo.hostToPlc.Years.Value.ToString();
txtValue15.Text = plcInfo.hostToPlc.VehicleParkingLocation.Value.ToString();
txtValue16.Text = plcInfo.hostToPlc.VehicleParkingStatus.Value.ToString();
txtValue17.Text = plcInfo.hostToPlc.LightIn.Value.ToString();
txtValue18.Text = plcInfo.hostToPlc.LightOut.Value.ToString();
txtValue19.Text = plcInfo.hostToPlc.StopCommand.Value.ToString();
txtValue20.Text = plcInfo.hostToPlc.TaskType.Value.ToString();
txtValue21.Text = plcInfo.hostToPlc.EntrySelection.Value.ToString();
txtValue22.Text = plcInfo.hostToPlc.ExitSelection.Value.ToString();
txtValue23.Text = plcInfo.hostToPlc.BatteryPackType.Value.ToString();
txtValue24.Text = plcInfo.hostToPlc.TaskEnablement.Value.ToString();
textBox1.Text = plcInfo.hostToPlc.ChargingStatus01.Value.ToString();
textBox2.Text = plcInfo.hostToPlc.ChargingStatus02.Value.ToString();
textBox3.Text = plcInfo.hostToPlc.ChargingStatus03.Value.ToString();
textBox4.Text = plcInfo.hostToPlc.ChargingStatus04.Value.ToString();
textBox5.Text = plcInfo.hostToPlc.ChargingStatus05.Value.ToString();
textBox6.Text = plcInfo.hostToPlc.ChargingStatus06.Value.ToString();
textBox7.Text = plcInfo.hostToPlc.ChargingStatus07.Value.ToString();
textBox8.Text = plcInfo.hostToPlc.ChargingStatus08.Value.ToString();
textBox9.Text = plcInfo.hostToPlc.ChargingStatus09.Value.ToString();
textBox10.Text = plcInfo.hostToPlc.ChargingStatus10.Value.ToString();
textBox11.Text = plcInfo.hostToPlc.ChargingStatus11.Value.ToString();
textBox12.Text = plcInfo.hostToPlc.ChargingStatus12.Value.ToString();
textBox13.Text = plcInfo.hostToPlc.ChargingStatus13.Value.ToString();
textBox14.Text = plcInfo.hostToPlc.ChargingStatus14.Value.ToString();
textBox15.Text = plcInfo.hostToPlc.ChargingStatus15.Value.ToString();
textBox16.Text = plcInfo.hostToPlc.ChargingStatus16.Value.ToString();
textBox17.Text = plcInfo.hostToPlc.ChargingStatus17.Value.ToString();
textBox18.Text = plcInfo.hostToPlc.ChargingStatus18.Value.ToString();
textBox19.Text = plcInfo.hostToPlc.ChargingStatus19.Value.ToString();
textBox20.Text = plcInfo.hostToPlc.ChargingStatus20.Value.ToString();
textBox21.Text = plcInfo.hostToPlc.BatteryType01.Value.ToString();
textBox22.Text = plcInfo.hostToPlc.BatteryType02.Value.ToString();
textBox23.Text = plcInfo.hostToPlc.BatteryType03.Value.ToString();
textBox24.Text = plcInfo.hostToPlc.BatteryType04.Value.ToString();
textBox25.Text = plcInfo.hostToPlc.BatteryType05.Value.ToString();
textBox26.Text = plcInfo.hostToPlc.BatteryType06.Value.ToString();
textBox27.Text = plcInfo.hostToPlc.BatteryType07.Value.ToString();
textBox28.Text = plcInfo.hostToPlc.BatteryType08.Value.ToString();
textBox29.Text = plcInfo.hostToPlc.BatteryType09.Value.ToString();
textBox30.Text = plcInfo.hostToPlc.BatteryType10.Value.ToString();
textBox31.Text = plcInfo.hostToPlc.BatteryType11.Value.ToString();
textBox32.Text = plcInfo.hostToPlc.BatteryType12.Value.ToString();
textBox33.Text = plcInfo.hostToPlc.BatteryType13.Value.ToString();
textBox34.Text = plcInfo.hostToPlc.BatteryType14.Value.ToString();
textBox35.Text = plcInfo.hostToPlc.BatteryType15.Value.ToString();
textBox36.Text = plcInfo.hostToPlc.BatteryType16.Value.ToString();
textBox37.Text = plcInfo.hostToPlc.BatteryType17.Value.ToString();
textBox38.Text = plcInfo.hostToPlc.BatteryType18.Value.ToString();
textBox39.Text = plcInfo.hostToPlc.BatteryType19.Value.ToString();
textBox40.Text = plcInfo.hostToPlc.BatteryType20.Value.ToString();
}
}
}
}

@ -2,7 +2,7 @@
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup /> <PropertyGroup />
<ItemGroup> <ItemGroup>
<Compile Update="FrmPLCConnect.cs"> <Compile Update="FrmPlc.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
</ItemGroup> </ItemGroup>

Loading…
Cancel
Save