更新CAN和数据中心的关联实时数据
This commit is contained in:
@@ -6,6 +6,7 @@ using CapMachine.Wpf.Models.Tag;
|
||||
using CapMachine.Wpf.PrismEvent;
|
||||
using HslCommunication;
|
||||
using HslCommunication.Profinet.Siemens;
|
||||
using ImTools;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using NPOI.HSSF.Record.Chart;
|
||||
using NPOI.SS.Formula.Atp;
|
||||
@@ -579,7 +580,7 @@ namespace CapMachine.Wpf.Services
|
||||
Name = "压缩机表面温度1[℃]",//名称带单位
|
||||
NameNoUnit = "压缩机表面温度1",//无单位名称
|
||||
EnName = "CapSurfTemp1",//英文名称
|
||||
Group = "CAN",//分组
|
||||
Group = "程序",//分组
|
||||
MinValue = 0,
|
||||
MaxValue = 100,
|
||||
Unit = "℃",
|
||||
@@ -598,7 +599,7 @@ namespace CapMachine.Wpf.Services
|
||||
Name = "压缩机表面温度2[℃]",//名称带单位
|
||||
NameNoUnit = "压缩机表面温度2",//无单位名称
|
||||
EnName = "CapSurfTemp2",//英文名称
|
||||
Group = "CAN",//分组
|
||||
Group = "程序",//分组
|
||||
MinValue = 0,
|
||||
MaxValue = 100,
|
||||
Unit = "℃",
|
||||
@@ -617,7 +618,7 @@ namespace CapMachine.Wpf.Services
|
||||
Name = "压缩机表面温度3[℃]",//名称带单位
|
||||
NameNoUnit = "压缩机表面温度3",//无单位名称
|
||||
EnName = "CapSurfTemp3",//英文名称
|
||||
Group = "CAN",//分组
|
||||
Group = "程序",//分组
|
||||
MinValue = 0,
|
||||
MaxValue = 100,
|
||||
Unit = "℃",
|
||||
@@ -664,7 +665,7 @@ namespace CapMachine.Wpf.Services
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 100,
|
||||
DecimalPoint = 1,
|
||||
DecimalPoint = 2,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
Index = "",
|
||||
@@ -683,7 +684,7 @@ namespace CapMachine.Wpf.Services
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 100,
|
||||
DecimalPoint = 1,
|
||||
DecimalPoint = 2,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
Index = "",
|
||||
@@ -702,7 +703,7 @@ namespace CapMachine.Wpf.Services
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 1,
|
||||
DecimalPoint = 1,
|
||||
DecimalPoint = 0,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
Index = "",
|
||||
@@ -1112,27 +1113,38 @@ namespace CapMachine.Wpf.Services
|
||||
|
||||
TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.IsShow = IsValueShow;
|
||||
|
||||
//仿真数据
|
||||
TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = (short)Random.Next(1, 100);
|
||||
TagManger.GetTagByName<short>(itemTag.Value.Name).EngPvValue = (short)Random.Next(1, 100) * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
|
||||
LinkState = false;
|
||||
////仿真数据
|
||||
////TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = (short)Random.Next(1, 100);
|
||||
////TagManger.GetTagByName<short>(itemTag.Value.Name).EngPvValue = (short)Random.Next(1, 100) * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
|
||||
////LinkState = false;
|
||||
|
||||
////PLC 数据
|
||||
//if (!string.IsNullOrEmpty(itemTag.Value.PVAddress))
|
||||
//{
|
||||
// OperateResultShort = SiemensDrive.ReadInt16(itemTag.Value.PVAddress);
|
||||
// if (OperateResultShort.IsSuccess)
|
||||
// {
|
||||
// TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = SiemensDrive.ReadInt16(itemTag.Value.PVAddress).Content;
|
||||
// TagManger.GetTagByName<short>(itemTag.Value.Name)!.EngPvValue = TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
|
||||
// LinkState = true;
|
||||
//PLC 数据
|
||||
if (!string.IsNullOrEmpty(itemTag.Value.PVAddress))
|
||||
{
|
||||
OperateResultShort = SiemensDrive.ReadInt16(itemTag.Value.PVAddress);
|
||||
if (OperateResultShort.IsSuccess)
|
||||
{
|
||||
TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = SiemensDrive.ReadInt16(itemTag.Value.PVAddress).Content;
|
||||
TagManger.GetTagByName<short>(itemTag.Value.Name)!.EngPvValue = TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
|
||||
LinkState = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LinkState = false;
|
||||
}
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// LinkState = false;
|
||||
// }
|
||||
//}
|
||||
//CAN数据读取 //回读CAN通信的数据到集合中
|
||||
//CAN组合并且在循环接收数据中时,才读取数据
|
||||
if (itemTag.Value.Group == "CAN")
|
||||
{
|
||||
//回读CAN通信的DBC集合数据到集合中
|
||||
itemTag.Value.EngPvValue = CanDriveService.GetDbcValueByName(itemTag.Value.NameNoUnit);
|
||||
}
|
||||
}
|
||||
else //地址为空,PLC驱动不读取数据
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(itemTag.Value.SVAddress))
|
||||
{
|
||||
@@ -1206,6 +1218,8 @@ namespace CapMachine.Wpf.Services
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user