反写到PLC中的数据更改逻辑
This commit is contained in:
@@ -81,6 +81,41 @@ namespace CapMachine.Wpf.Models.Tag
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 需要提前知道这个标签是CapTag标签,否则为空
|
||||
/// 尝试获取CapTag标签的PVModel模型
|
||||
/// 压缩机通信的标签
|
||||
/// </summary>
|
||||
/// <param name="tagName">标签名称</param>
|
||||
/// <param name="pVModel">输出的pVModel模型,如果获取失败则为null</param>
|
||||
/// <returns>是否成功获取PV模型</returns>
|
||||
public bool TryGetCapPVModel(string tagName, out QuickAttrCell? pVModel)
|
||||
{
|
||||
lock (PvLock)
|
||||
{
|
||||
pVModel = null;
|
||||
|
||||
if (string.IsNullOrEmpty(tagName))
|
||||
return false;
|
||||
|
||||
// 尝试从字典中获取标签
|
||||
if (DicTags.TryGetValue(tagName, out var tag))
|
||||
{
|
||||
// 尝试将标签转换为ShortControlTag
|
||||
if (tag is CapTag capTag)
|
||||
{
|
||||
pVModel = capTag.PVModel;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 尝试获取标签的PVModel模型
|
||||
/// 给数据记录使用
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1004,7 +1004,7 @@
|
||||
VerticalAlignment="Center"
|
||||
CellTitle="转速"
|
||||
CellUnit="{Binding SpeedTag.Unit}"
|
||||
CellValue="{Binding SpeedTag.EngPvValueStr}" />
|
||||
CellValue="{Binding SpeedTag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="301"
|
||||
Canvas.Top="162"
|
||||
@@ -1012,7 +1012,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="电压"
|
||||
CellUnit="{Binding ComCapBusVolTag.Unit}"
|
||||
CellValue="{Binding ComCapBusVolTag.EngPvValueStr}" />
|
||||
CellValue="{Binding ComCapBusVolTag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="301"
|
||||
Canvas.Top="212"
|
||||
@@ -1020,7 +1020,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="电流"
|
||||
CellUnit="{Binding ComCapBusCurTag.Unit}"
|
||||
CellValue="{Binding ComCapBusCurTag.EngPvValueStr}" />
|
||||
CellValue="{Binding ComCapBusCurTag.PVModel.EngValueStr}" />
|
||||
<!-- CellUnit="{Binding ComCapPwTag.Unit}" -->
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="301"
|
||||
@@ -1029,7 +1029,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="功率"
|
||||
CellUnit="{Binding ComCapPwTag.Unit}"
|
||||
CellValue="{Binding ComCapPwTag.EngPvValueStr}" />
|
||||
CellValue="{Binding ComCapPwTag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="89"
|
||||
Canvas.Top="183"
|
||||
@@ -1037,7 +1037,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="排气口压力"
|
||||
CellUnit="{Binding ExPressTag.Unit}"
|
||||
CellValue="{Binding ExPressTag.EngPvValueStr}" />
|
||||
CellValue="{Binding ExPressTag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="90"
|
||||
Canvas.Top="239"
|
||||
@@ -1045,7 +1045,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="排气口温度"
|
||||
CellUnit="{Binding ExTempTag.Unit}"
|
||||
CellValue="{Binding ExTempTag.EngPvValueStr}" />
|
||||
CellValue="{Binding ExTempTag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="89"
|
||||
Canvas.Top="306"
|
||||
@@ -1053,7 +1053,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="吸气口压力"
|
||||
CellUnit="{Binding InhPressTag.Unit}"
|
||||
CellValue="{Binding InhPressTag.EngPvValueStr}" />
|
||||
CellValue="{Binding InhPressTag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="90"
|
||||
Canvas.Top="362"
|
||||
@@ -1061,7 +1061,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="吸气口温度"
|
||||
CellUnit="{Binding InhTempTag.Unit}"
|
||||
CellValue="{Binding InhTempTag.EngPvValueStr}" />
|
||||
CellValue="{Binding InhTempTag.PVModel.EngValueStr}" />
|
||||
<!--<Controls:ValueShow
|
||||
Canvas.Left="551"
|
||||
Canvas.Top="272"
|
||||
@@ -1077,7 +1077,7 @@
|
||||
VerticalAlignment="Center"
|
||||
CellTitle="阀前温度"
|
||||
CellUnit="{Binding TxvFrTempTag.Unit}"
|
||||
CellValue="{Binding TxvFrTempTag.EngPvValueStr}" />
|
||||
CellValue="{Binding TxvFrTempTag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="1003"
|
||||
Canvas.Top="239"
|
||||
@@ -1085,7 +1085,7 @@
|
||||
VerticalAlignment="Center"
|
||||
CellTitle="阀前压力"
|
||||
CellUnit="{Binding TxvFrPressTag.Unit}"
|
||||
CellValue="{Binding TxvFrPressTag.EngPvValueStr}" />
|
||||
CellValue="{Binding TxvFrPressTag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="635"
|
||||
Canvas.Top="420"
|
||||
@@ -1093,7 +1093,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="吸气混合器温度"
|
||||
CellUnit="{Binding OS2TempTag.Unit}"
|
||||
CellValue="{Binding OS2TempTag.EngPvValueStr}" />
|
||||
CellValue="{Binding OS2TempTag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="1076"
|
||||
Canvas.Top="360"
|
||||
@@ -1101,7 +1101,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="冷凝器进水温"
|
||||
CellUnit="{Binding CondInTempTag.Unit}"
|
||||
CellValue="{Binding CondInTempTag.EngPvValueStr}" />
|
||||
CellValue="{Binding CondInTempTag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="1194"
|
||||
Canvas.Top="360"
|
||||
@@ -1109,7 +1109,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="冷凝器出水温"
|
||||
CellUnit="{Binding Cond1TempTag.Unit}"
|
||||
CellValue="{Binding Cond1TempTag.EngPvValueStr}" />
|
||||
CellValue="{Binding Cond1TempTag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="1217"
|
||||
Canvas.Top="136"
|
||||
@@ -1246,7 +1246,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="润滑油流量"
|
||||
CellUnit="{Binding LubeFlowTag.Unit}"
|
||||
CellValue="{Binding LubeFlowTag.EngPvValueStr}" />
|
||||
CellValue="{Binding LubeFlowTag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="723"
|
||||
Canvas.Top="23"
|
||||
@@ -1254,7 +1254,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="冷媒流量"
|
||||
CellUnit="{Binding VRVTag.Unit}"
|
||||
CellValue="{Binding VRVTag.EngPvValueStr}" />
|
||||
CellValue="{Binding VRVTag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="1060"
|
||||
Canvas.Top="149"
|
||||
@@ -1262,7 +1262,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="COND2温度"
|
||||
CellUnit="{Binding Cond2TempTag.Unit}"
|
||||
CellValue="{Binding Cond2TempTag.EngPvValueStr}" />
|
||||
CellValue="{Binding Cond2TempTag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="1280"
|
||||
Canvas.Top="87"
|
||||
@@ -1270,7 +1270,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="阀前压力P3"
|
||||
CellUnit="{Binding TxvFrPressP3Tag.Unit}"
|
||||
CellValue="{Binding TxvFrPressP3Tag.EngPvValueStr}" />
|
||||
CellValue="{Binding TxvFrPressP3Tag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="1280"
|
||||
Canvas.Top="142"
|
||||
@@ -1278,7 +1278,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="阀前温度T3"
|
||||
CellUnit="{Binding TxvFrTempT3Tag.Unit}"
|
||||
CellValue="{Binding TxvFrTempT3Tag.EngPvValueStr}" />
|
||||
CellValue="{Binding TxvFrTempT3Tag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="1280"
|
||||
Canvas.Top="197"
|
||||
@@ -1286,7 +1286,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="过冷度"
|
||||
CellUnit="{Binding SubcoolingTag.Unit}"
|
||||
CellValue="{Binding SubcoolingTag.EngPvValueStr}" />
|
||||
CellValue="{Binding SubcoolingTag.PVModel.EngValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="448"
|
||||
Canvas.Top="147"
|
||||
@@ -1294,7 +1294,7 @@
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="COND1入口温度T4"
|
||||
CellUnit="{Binding Cond1TempT4Tag.Unit}"
|
||||
CellValue="{Binding Cond1TempT4Tag.EngPvValueStr}" />
|
||||
CellValue="{Binding Cond1TempT4Tag.PVModel.EngValueStr}" />
|
||||
|
||||
|
||||
</Canvas>
|
||||
|
||||
Reference in New Issue
Block a user