反写到PLC中的数据更改逻辑

This commit is contained in:
2025-06-19 21:25:47 +08:00
parent d71146d4ae
commit 919becb72f
3 changed files with 72 additions and 31 deletions

View File

@@ -1588,7 +1588,7 @@ namespace CapMachine.Wpf.Services
Precision = 1,
Unit = "℃",
DataType = TagDataType.Double,
PVModel = new QuickAttrCell() { Address = "VW310", EngValue = 0, EngValueStr = "", },
PVModel = new QuickAttrCell() { Address = "VW312", EngValue = 0, EngValueStr = "", },
RWInfo = RWInfo.CapRead,
});
@@ -2279,6 +2279,7 @@ namespace CapMachine.Wpf.Services
new PlcExdConfigCell(){ Name="吸排气阀",Address="V490",Precision=1},
new PlcExdConfigCell(){ Name="EV",Address="V492",Precision=1},
new PlcExdConfigCell(){ Name="压缩机使能",Address="V484",Precision=1},
new PlcExdConfigCell(){ Name="参数编号",Address="V488",Precision=1},
new PlcExdConfigCell(){ Name="PTC使能",Address="V486",Precision=1},
};
@@ -2597,7 +2598,7 @@ namespace CapMachine.Wpf.Services
if (TagManger.TryGetPVModel(itemCanLinGroup.Key, out MeterValueAttrCell? CanpVModel))
{
CanpVModel!.EngValue = CanDriveService.GetDbcSpeedValueBySpeedName("通讯转速");
SiemensDrive.Write(CanpVModel!.Address, (short)CanDriveService.GetDbcSpeedValueBySpeedName("通讯转速"));
SiemensDrive.Write(CanpVModel!.Address!.Replace("W", ""), (short)CanDriveService.GetDbcSpeedValueBySpeedName("通讯转速"));
//pVModel.EngSrcValue = 0;
}
break;
@@ -2606,7 +2607,7 @@ namespace CapMachine.Wpf.Services
if (TagManger.TryGetPVModel(itemCanLinGroup.Key, out MeterValueAttrCell? LinpVModel))
{
LinpVModel!.EngValue = LinDriveService.GetLdfSpeedValueBySpeedName("通讯转速");
SiemensDrive.Write(LinpVModel!.Address, (short)LinDriveService.GetLdfSpeedValueBySpeedName("通讯转速"));
SiemensDrive.Write(LinpVModel!.Address!.Replace("W", ""), (short)LinDriveService.GetLdfSpeedValueBySpeedName("通讯转速"));
}
break;
default:
@@ -2617,10 +2618,10 @@ namespace CapMachine.Wpf.Services
}
//只处理CANLIN的数据
if (itemCanLinGroup.Value.Group == "CANLIN")
if (itemCanLinGroup.Value.Group == "压缩机")
{
//尝试获取模型信息
if (TagManger.TryGetPVModel(itemCanLinGroup.Key, out MeterValueAttrCell? pVModel))
if (TagManger.TryGetCapPVModel(itemCanLinGroup.Key, out QuickAttrCell? pVModel))
{
switch (ConfigService.CanLinRunStateModel.CurSysSelectedCanLin)
{
@@ -2628,13 +2629,13 @@ namespace CapMachine.Wpf.Services
//取得压缩机的CANLIN数据到数据集合中
pVModel!.EngValue = CanDriveService.GetDbcValueByName(itemCanLinGroup.Value.NameNoUnit);
//写入到PLC中
SiemensDrive.Write(pVModel!.Address, (short)(CanDriveService.GetDbcValueByName(itemCanLinGroup.Value.NameNoUnit) * pVModel.Precision));
SiemensDrive.Write(pVModel!.Address!.Replace("W", ""), (short)(CanDriveService.GetDbcValueByName(itemCanLinGroup.Value.NameNoUnit)));
break;
case CanLinEnum.Lin:
//取得压缩机的CANLIN数据
pVModel!.EngValue = LinDriveService.GetLdfValueByName(itemCanLinGroup.Value.NameNoUnit);
//写入到PLC中
SiemensDrive.Write(pVModel!.Address, (short)(LinDriveService.GetLdfValueByName(itemCanLinGroup.Value.NameNoUnit) * pVModel.Precision));
SiemensDrive.Write(pVModel!.Address!.Replace("W", ""), (short)(LinDriveService.GetLdfValueByName(itemCanLinGroup.Value.NameNoUnit)));
break;
case CanLinEnum.No:
break;
@@ -3083,6 +3084,7 @@ namespace CapMachine.Wpf.Services
break;
}
//拓展参数
if (ProRunChannelData.ListStepExd != null && ProRunChannelData.ListStepExd.Count() > 0)
{
@@ -3102,7 +3104,8 @@ namespace CapMachine.Wpf.Services
default:
break;
}
continue;
//Console.WriteLine($"{ProRunChannelData.MeterName}拓展参数------------:{itemStepExd.Name}:{itemStepExd.Value}");
//continue;
}
var DataAdrees = ListPlcExdConfigCell.FirstOrDefault(a => a.Name == itemStepExd.Name);
@@ -3111,12 +3114,15 @@ namespace CapMachine.Wpf.Services
switch (itemStepExd.ValueType)
{
case ExdValueType.Bool:
var ResultBool = SiemensDrive.Write(DataAdrees.Address, (bool)itemStepExd.Value! == true ? 1 : 0);
if (!ResultBool.IsSuccess) Console.WriteLine($"{ProRunChannelData.MeterName}:{itemStepExd.Name}写入失败");
//Console.WriteLine($"{ProRunChannelData.MeterName}拓展参数------------:{itemStepExd.Name}-{DataAdrees.Address}:{itemStepExd.Value}");
var BoolVar = (bool)itemStepExd.Value!;
var ResultBool = SiemensDrive.Write(DataAdrees.Address, (short)(BoolVar! == true ? 1 : 0));
if (!ResultBool.IsSuccess) Console.WriteLine($"{ProRunChannelData.MeterName} 拓展参数------------:{itemStepExd.Name}写入失败");
break;
case ExdValueType.Short:
//Console.WriteLine($"{ProRunChannelData.MeterName}拓展参数------------:{itemStepExd.Name}-{DataAdrees.Address}:{itemStepExd.Value}");
var ResultShort = SiemensDrive.Write(DataAdrees.Address, (short)itemStepExd.Value!);
if (!ResultShort.IsSuccess) Console.WriteLine($"{ProRunChannelData.MeterName}:{itemStepExd.Name}写入失败");
if (!ResultShort.IsSuccess) Console.WriteLine($"{ProRunChannelData.MeterName} 拓展参数------------:{itemStepExd.Name}写入失败");
break;
case ExdValueType.Double:
break;