标签变量参数更改

This commit is contained in:
2025-07-09 10:12:36 +08:00
parent db6bd32bdc
commit 6a2ce24cbb
2 changed files with 39 additions and 2 deletions

View File

@@ -116,6 +116,42 @@ namespace CapMachine.Wpf.Models.Tag
}
/// <summary>
/// ******* 从ShortValueTag中获取PVModel模型-定制的 ********
/// 需要提前知道这个标签是CapTag标签否则为空
/// 尝试获取CapTag标签的PVModel模型
/// 压缩机通信的标签
/// </summary>
/// <param name="tagName">标签名称</param>
/// <param name="pVModel">输出的pVModel模型如果获取失败则为null</param>
/// <returns>是否成功获取PV模型</returns>
public bool TryGetCapPVModelByShortValueTag(string tagName, out MeterValueAttrCell? pVModel)
{
lock (PvLock)
{
pVModel = null;
if (string.IsNullOrEmpty(tagName))
return false;
// 尝试从字典中获取标签
if (DicTags.TryGetValue(tagName, out var tag))
{
// 尝试将标签转换为ShortValueTag
if (tag is ShortValueTag capTag)
{
pVModel = capTag.PVModel;
return true;
}
return false;
}
return false;
}
}
/// <summary>
/// 尝试获取标签的PVModel模型

View File

@@ -1413,7 +1413,7 @@ namespace CapMachine.Wpf.Services
while (ThreadEnable)
{
await Task.Delay(20);
await Task.Delay(100);
//await Task.CompletedTask;
DiagnosticsTime.Reset();
@@ -1467,7 +1467,7 @@ namespace CapMachine.Wpf.Services
if (itemCanLinGroup.Value.Group == "压缩机")
{
//尝试获取模型信息
if (TagManger.TryGetCapPVModel(itemCanLinGroup.Key, out QuickAttrCell? pVModel))
if (TagManger.TryGetCapPVModelByShortValueTag(itemCanLinGroup.Key, out MeterValueAttrCell? pVModel))
{
switch (ConfigService.CanLinRunStateModel.CurSysSelectedCanLin)
{
@@ -1490,6 +1490,7 @@ namespace CapMachine.Wpf.Services
SiemensDrive.Write(pVModel!.Address!.Replace("W", ""), (short)(LinDriveService.GetLdfValueByName(itemCanLinGroup.Value.NameNoUnit) * itemCanLinGroup.Value.Precision));
break;
case CanLinEnum.No:
break;
default:
break;