一些优化:CAN和PLC地址的优化
This commit is contained in:
@@ -17,10 +17,16 @@ namespace CapMachine.Wpf.Services
|
||||
/// </summary>
|
||||
public class CanDriveService : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前选中的CanLinConfigPro 程序
|
||||
/// </summary>
|
||||
public CanLinConfigPro SelectedCanLinConfigPro { get; set; }
|
||||
public HighSpeedDataService HighSpeedDataService { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
public CanDriveService(HighSpeedDataService highSpeedDataService,IContainerProvider containerProvider)
|
||||
public CanDriveService(HighSpeedDataService highSpeedDataService, IContainerProvider containerProvider)
|
||||
{
|
||||
ToomossCanDrive = new ToomossCan(containerProvider);
|
||||
//高速数据服务
|
||||
@@ -51,7 +57,7 @@ namespace CapMachine.Wpf.Services
|
||||
//为DBC实时数据关联配置的名称
|
||||
foreach (var item in SelectedCanLinConfigPro.CanLinConfigContents)
|
||||
{
|
||||
var FindData = ListCanDbcModel.FindFirst(a => a.SignalName == item.Content);
|
||||
var FindData = ListCanDbcModel.FindFirst(a => a.SignalName == item.SignalName);
|
||||
if (FindData != null)
|
||||
{
|
||||
FindData.Name = item.Name;
|
||||
@@ -69,10 +75,93 @@ namespace CapMachine.Wpf.Services
|
||||
return ListCanDbcModel;
|
||||
}
|
||||
|
||||
|
||||
#region 程序驱动CAN
|
||||
|
||||
/// <summary>
|
||||
/// 当前选中的CanLinConfigPro 程序
|
||||
/// 要发送的CAN指令数据
|
||||
/// 在程序配置好后就确定要发送哪些数据
|
||||
/// </summary>
|
||||
public CanLinConfigPro SelectedCanLinConfigPro { get; set; }
|
||||
public HighSpeedDataService HighSpeedDataService { get; }
|
||||
public List<CanCmdData> CmdData { get; set; } = new List<CanCmdData>();
|
||||
|
||||
/// <summary>
|
||||
/// 发送消息给CAN 驱动
|
||||
/// </summary>
|
||||
public void SendMsgToCanDrive()
|
||||
{
|
||||
if (ToomossCanDrive.OpenState)
|
||||
{
|
||||
if (CmdData.Count > 0)
|
||||
{
|
||||
ToomossCanDrive.SendCanMsg(CmdData);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Windows.MessageBox.Show("未发现配置的数据内容", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 循环发送数据到CAN
|
||||
/// </summary>
|
||||
public void CycleSendMsg()
|
||||
{
|
||||
if (ToomossCanDrive.OpenState)
|
||||
{
|
||||
if (ToomossCanDrive.IsCycleSend == false)
|
||||
{
|
||||
if (CmdData.Count > 0)
|
||||
{
|
||||
ToomossCanDrive.IsCycleSend = true;
|
||||
ToomossCanDrive.CmdData = CmdData;
|
||||
ToomossCanDrive.StartCycleSendMsg();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Windows.MessageBox.Show("未发现配置的数据内容", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ToomossCanDrive.IsCycleSend = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///循环接收数据
|
||||
/// </summary>
|
||||
public void CycleReciveMsg()
|
||||
{
|
||||
if (ToomossCanDrive.OpenState)
|
||||
{
|
||||
if (ToomossCanDrive.IsCycleRevice == false)
|
||||
{
|
||||
if (CmdData.Count > 0)
|
||||
{
|
||||
ToomossCanDrive.IsCycleRevice = true;
|
||||
ToomossCanDrive.StartCycleReviceCanMsg();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Windows.MessageBox.Show("未发现配置的数据内容", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ToomossCanDrive.IsCycleRevice = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace CapMachine.Wpf.Services
|
||||
//Data!.MsgInfo = commMsg.MsgInfo;
|
||||
//Data!.Category = commMsg.Category;
|
||||
Data!.MsgData = commMsg.MsgData;
|
||||
Data!.Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
Data!.Time = commMsg.Time;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,15 +102,15 @@ namespace CapMachine.Wpf.Services
|
||||
/// <summary>
|
||||
/// 当前的报文消息集合
|
||||
/// </summary>
|
||||
private List<CommMsg> CurListMsg { get; set; } = new List<CommMsg>()
|
||||
{
|
||||
new CommMsg() { Category = "CAN2",MsgInfo = "0x000003E3",Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),MsgData = "33 00 00 00 37 00 04 00"},
|
||||
new CommMsg() { Category = "CAN1",MsgInfo = "0x000003E3",Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),MsgData = "33 00 00 00 37 00 04 00"},
|
||||
new CommMsg() { Category = "CAN2",MsgInfo = "0x000003E3",Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),MsgData = "33 00 00 00 37 00 04 00"},
|
||||
new CommMsg() { Category = "CAN3",MsgInfo = "0x000003E3",Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),MsgData = "33 00 00 00 37 00 04 00"},
|
||||
new CommMsg() { Category = "CAN4",MsgInfo = "0x000003E3",Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),MsgData = "33 00 00 00 37 00 04 00"},
|
||||
new CommMsg() { Category = "CAN5",MsgInfo = "0x000003E3",Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),MsgData = "33 00 00 00 37 00 04 00"},
|
||||
};
|
||||
private List<CommMsg> CurListMsg { get; set; } = new List<CommMsg>();
|
||||
//{
|
||||
// new CommMsg() { Category = "CAN2",MsgInfo = "0x000003E3",Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),MsgData = "33 00 00 00 37 00 04 00"},
|
||||
// new CommMsg() { Category = "CAN1",MsgInfo = "0x000003E3",Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),MsgData = "33 00 00 00 37 00 04 00"},
|
||||
// new CommMsg() { Category = "CAN2",MsgInfo = "0x000003E3",Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),MsgData = "33 00 00 00 37 00 04 00"},
|
||||
// new CommMsg() { Category = "CAN3",MsgInfo = "0x000003E3",Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),MsgData = "33 00 00 00 37 00 04 00"},
|
||||
// new CommMsg() { Category = "CAN4",MsgInfo = "0x000003E3",Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),MsgData = "33 00 00 00 37 00 04 00"},
|
||||
// new CommMsg() { Category = "CAN5",MsgInfo = "0x000003E3",Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),MsgData = "33 00 00 00 37 00 04 00"},
|
||||
//};
|
||||
|
||||
/// <summary>
|
||||
/// 周期定时器
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace CapMachine.Wpf.Services
|
||||
#region 标签管理
|
||||
|
||||
//【测试】
|
||||
//TagManger.AddTag(new Tag<short>("转速", "转速[rpm]", "Speed", "程序", "VW15000", 100, 0, 1, "rpm", new ShortTagValue(), true) { DecimalPoint = 0 });
|
||||
TagManger.AddTag(new Tag<short>("转速", "转速[rpm]", "Speed", "程序", "VW15000", 100, 0, 1, "rpm", new ShortTagValue(), true) { DecimalPoint = 0 });
|
||||
//TagManger.AddTag(new Tag<short>("排气压力", "排气压力[BarA]", "ExPress", "程序", "VW15002", 100, 0, 100, "BarA", new ShortTagValue(), true) { DecimalPoint = 2 });
|
||||
//TagManger.AddTag(new Tag<short>("吸气压力", "吸气压力[BarA]", "InhPress", "程序", "VW15004", 100, 0, 100, "BarA", new ShortTagValue(), true) { DecimalPoint = 2 });
|
||||
//TagManger.AddTag(new Tag<short>("吸气温度", "吸气温度[℃]", "InhTemp", "程序", "VW15006", 100, 0, 10, "℃", new ShortTagValue(), true) { DecimalPoint = 1 });
|
||||
@@ -181,7 +181,8 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "VW200",
|
||||
MVAddress = "VW250",
|
||||
IsMeter = true,
|
||||
Precision = 0,
|
||||
AutoHandSwitchAddress= "VW240",
|
||||
Precision = 1,
|
||||
DecimalPoint = 0,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -200,8 +201,9 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "VW202",
|
||||
MVAddress = "VW252",
|
||||
IsMeter = true,
|
||||
Precision = 3,
|
||||
DecimalPoint = 2,
|
||||
AutoHandSwitchAddress = "VW244",
|
||||
Precision = 1000,
|
||||
DecimalPoint = 3,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
Index = "",
|
||||
@@ -219,8 +221,9 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "VW204",
|
||||
MVAddress = "VW254",
|
||||
IsMeter = true,
|
||||
Precision = 3,
|
||||
DecimalPoint = 2,
|
||||
AutoHandSwitchAddress = "VW248",
|
||||
Precision = 1000,
|
||||
DecimalPoint = 3,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
Index = "",
|
||||
@@ -238,7 +241,8 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "VW206",
|
||||
MVAddress = "VW256",
|
||||
IsMeter = true,
|
||||
Precision = 1,
|
||||
AutoHandSwitchAddress = "VW252",
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -246,8 +250,8 @@ namespace CapMachine.Wpf.Services
|
||||
});
|
||||
TagManger.AddTag(new Tag<short>(new ShortTagValue())
|
||||
{
|
||||
Name = "COND1水温[℃]",//名称带单位
|
||||
NameNoUnit = "COND1水温",//无单位名称
|
||||
Name = "冷凝器出口水温[℃]",//名称带单位 COND1水温
|
||||
NameNoUnit = "冷凝器出口水温",//无单位名称
|
||||
EnName = "Cond1Temp",//英文名称
|
||||
Group = "程序",//分组
|
||||
MinValue = 0,
|
||||
@@ -257,7 +261,8 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "VW208",
|
||||
MVAddress = "VW258",
|
||||
IsMeter = true,
|
||||
Precision = 1,
|
||||
AutoHandSwitchAddress = "VW256",
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -265,8 +270,8 @@ namespace CapMachine.Wpf.Services
|
||||
});
|
||||
TagManger.AddTag(new Tag<short>(new ShortTagValue())
|
||||
{
|
||||
Name = "OS2温度[℃]",//名称带单位
|
||||
NameNoUnit = "OS2温度",//无单位名称
|
||||
Name = "吸气混合器温度[℃]",//名称带单位 OS2温度
|
||||
NameNoUnit = "吸气混合器温度",//无单位名称 OS2温度
|
||||
EnName = "OS2Temp",//英文名称
|
||||
Group = "程序",//分组
|
||||
MinValue = 0,
|
||||
@@ -276,7 +281,8 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "VW210",
|
||||
MVAddress = "VW260",
|
||||
IsMeter = true,
|
||||
Precision = 1,
|
||||
AutoHandSwitchAddress = "VW260",
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -295,7 +301,8 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "VW212",
|
||||
MVAddress = "",
|
||||
IsMeter = true,
|
||||
Precision = 1,
|
||||
AutoHandSwitchAddress = "",
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -314,7 +321,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 2,
|
||||
Precision = 100,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -333,7 +340,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 0,
|
||||
Precision = 1,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -352,7 +359,8 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "VW214",
|
||||
MVAddress = "",
|
||||
IsMeter = true,
|
||||
Precision = 1,
|
||||
AutoHandSwitchAddress = "",
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -371,7 +379,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 2,
|
||||
Precision = 100,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -390,7 +398,8 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "VW216",
|
||||
MVAddress = "",
|
||||
IsMeter = true,
|
||||
Precision = 1,
|
||||
AutoHandSwitchAddress = "",
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -409,7 +418,8 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "VW218",
|
||||
MVAddress = "",
|
||||
IsMeter = true,
|
||||
Precision = 1,
|
||||
AutoHandSwitchAddress = "",
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -428,7 +438,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 1,
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -447,7 +457,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 1,
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -466,8 +476,8 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 3,
|
||||
DecimalPoint = 1,
|
||||
Precision = 1000,
|
||||
DecimalPoint = 3,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
Index = "",
|
||||
@@ -485,7 +495,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 1,
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -504,8 +514,8 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 3,
|
||||
DecimalPoint = 1,
|
||||
Precision = 1000,
|
||||
DecimalPoint = 3,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
Index = "",
|
||||
@@ -517,13 +527,13 @@ namespace CapMachine.Wpf.Services
|
||||
EnName = "WaterTankInTemp",//英文名称
|
||||
Group = "程序",//分组
|
||||
MinValue = 0,
|
||||
MaxValue = 100,
|
||||
Unit = "℃",
|
||||
MaxValue = 100,
|
||||
PVAddress = "VW136",//地址信息
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 0,
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -542,7 +552,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 1,
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -561,7 +571,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 1,
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -580,7 +590,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 1,
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -599,7 +609,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 1,
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -618,7 +628,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 1,
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -637,7 +647,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 2,
|
||||
Precision = 100,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -656,7 +666,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 2,
|
||||
Precision = 100,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -675,7 +685,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 0,
|
||||
Precision = 1,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -694,7 +704,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 1,
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -713,7 +723,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 1,
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -732,7 +742,7 @@ namespace CapMachine.Wpf.Services
|
||||
SVAddress = "",
|
||||
MVAddress = "",
|
||||
IsMeter = false,
|
||||
Precision = 1,
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
ValueType = typeof(short),
|
||||
@@ -963,18 +973,24 @@ namespace CapMachine.Wpf.Services
|
||||
//TagManger.GetTagByName<short>(itemTag.Value.Name).EngValue = (short)Random.Next(1, 100) * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
|
||||
//LinkState = false;
|
||||
|
||||
|
||||
//PLC 数据
|
||||
OperateResultShort = SiemensDrive.ReadInt16(itemTag.Value.PVAddress);
|
||||
if (OperateResultShort.IsSuccess)
|
||||
if (!string.IsNullOrEmpty(itemTag.Value.PVAddress))
|
||||
{
|
||||
TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = SiemensDrive.ReadInt16(itemTag.Value.PVAddress).Content;
|
||||
TagManger.GetTagByName<short>(itemTag.Value.Name).EngValue = TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
|
||||
LinkState = true;
|
||||
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).EngValue = TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value * 1.0 / TagManger.GetTagByName<short>(itemTag.Value.Name)!.Precision;
|
||||
LinkState = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LinkState = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LinkState = false;
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
405
CapMachine.Wpf/Services/PPCService.cs
Normal file
405
CapMachine.Wpf/Services/PPCService.cs
Normal file
@@ -0,0 +1,405 @@
|
||||
using CapMachine.Shared.Controls;
|
||||
using CapMachine.Wpf.Models.Tag;
|
||||
using CapMachine.Wpf.PPCalculation;
|
||||
using Prism.Events;
|
||||
using Prism.Mvvm;
|
||||
using Prism.Services.Dialogs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CapMachine.Wpf.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 物性计算的服务
|
||||
/// </summary>
|
||||
public class PPCService : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 计算扫描 Task
|
||||
/// </summary>
|
||||
private static Task CalcTask { get; set; }
|
||||
public ConfigService ConfigService { get; }
|
||||
|
||||
private IEventAggregator _EventAggregator { get; set; }
|
||||
public DataRecordService DataRecordService { get; }
|
||||
public SysRunService SysRunServer { get; }
|
||||
public MachineRtDataService MachineRtDataService { get; }
|
||||
public IDialogService DialogService { get; }
|
||||
/// <summary>
|
||||
/// 标签中心
|
||||
/// </summary>
|
||||
public TagManager TagManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实例化
|
||||
/// </summary>
|
||||
public PPCService(ConfigService configService, IEventAggregator eventAggregator,
|
||||
DataRecordService dataRecordService, SysRunService sysRunService,
|
||||
MachineRtDataService machineRtDataService, IDialogService dialogService)
|
||||
{
|
||||
ConfigService = configService;
|
||||
//事件服务
|
||||
_EventAggregator = eventAggregator;
|
||||
DataRecordService = dataRecordService;
|
||||
SysRunServer = sysRunService;
|
||||
MachineRtDataService = machineRtDataService;
|
||||
DialogService = dialogService;
|
||||
TagManager = MachineRtDataService.TagManger;
|
||||
|
||||
//SpeedTag = TagManager.DicTags.GetValueOrDefault("转速[rpm]");
|
||||
//ExPressTag = TagManager.DicTags.GetValueOrDefault("排气压力[MpaA]");
|
||||
//ExTempTag = TagManager.DicTags.GetValueOrDefault("排气温度[℃]");
|
||||
InhPressTag = TagManager.DicTags.GetValueOrDefault("吸气压力[MpaA]");
|
||||
InhTempTag = TagManager.DicTags.GetValueOrDefault("吸气温度[℃]");
|
||||
//ComCapBusVolTag = TagManager.DicTags.GetValueOrDefault("通讯母线电压[V]");
|
||||
//ComCapBusCurTag = TagManager.DicTags.GetValueOrDefault("通讯母线电流[A]");
|
||||
//ComCapPwTag = TagManager.DicTags.GetValueOrDefault("通讯功率[W]");
|
||||
//OS2TempTag = TagManager.DicTags.GetValueOrDefault("吸气混合器温度[℃]");
|
||||
TxvFrTempTag = TagManager.DicTags.GetValueOrDefault("膨胀阀前温度[℃]");
|
||||
TxvFrPressTag = TagManager.DicTags.GetValueOrDefault("膨胀阀前压力[MpaA]");
|
||||
//Cond1TempTag = TagManager.DicTags.GetValueOrDefault("冷凝器出口水温[℃]");
|
||||
//CondInTempTag = TagManager.DicTags.GetValueOrDefault("冷凝器进口温度[℃]");
|
||||
|
||||
//RtScanDeviceStart();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 吸气压力
|
||||
/// </summary>
|
||||
public ITag InhPressTag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 吸气温度
|
||||
/// </summary>
|
||||
public ITag InhTempTag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 膨胀阀前温度
|
||||
/// </summary>
|
||||
public ITag TxvFrTempTag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 膨胀阀前压力
|
||||
/// </summary>
|
||||
public ITag TxvFrPressTag { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 过热度
|
||||
/// </summary>
|
||||
public double Superheat { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 过冷度
|
||||
/// </summary>
|
||||
public double Subcool { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 制冷剂
|
||||
/// </summary>
|
||||
public string Cryogen { get; set; } = "R134a";
|
||||
|
||||
/// <summary>
|
||||
/// 风量数据-乘以系数的后的最终结果
|
||||
/// </summary>
|
||||
private double AirVolumeData { get; set; } = 0.0;
|
||||
|
||||
/// <summary>
|
||||
/// 风量数据-公式计算的原始数据
|
||||
/// </summary>
|
||||
private double AirVolumeDataSource { get; set; } = 0;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 风量喷嘴启用信息数据
|
||||
/// </summary>
|
||||
private string RozzleEnableInfo { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 启用计算
|
||||
/// </summary>
|
||||
private bool RtCalcEnable { get; set; }=true;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// PLC扫描线程
|
||||
/// </summary>
|
||||
private void RtScanDeviceStart()
|
||||
{
|
||||
CalcTask = Task.Run(async () =>
|
||||
{
|
||||
//Stopwatch stopwatch = new Stopwatch();
|
||||
//物性的过热度和过冷度的相关物性计算
|
||||
while (RtCalcEnable)
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
try
|
||||
{
|
||||
|
||||
long iErr, kph = 1;
|
||||
|
||||
double te = 0.0, te1 = 0.0, p = 0.0, p1 = 0.0, d = 0.0, Dl = 0.0, Dv = 0.0, q = 0.0, h = 0.0, ee = 0.0, hh = 0.0, ss = 0.0, cp = 0.0, cv = 0.0, w = 0.0;
|
||||
double[] x = new double[20], xliq = new double[20], xvap = new double[20];
|
||||
double[] xlkg = new double[20], xvkg = new double[20];
|
||||
|
||||
double tk = 0.0, wm = 0.0, prevDeltaH = 0.0;//prevDeltaH 未使用
|
||||
|
||||
//textBox5.Text = "";
|
||||
|
||||
string hpath = @".\PPCalculation\REFPROP\FLUIDS";
|
||||
long size = hpath.Length;
|
||||
|
||||
hpath += new String(' ', 255 - (int)size);
|
||||
IRefProp64.SETPATHdll(hpath, ref size);
|
||||
|
||||
long numComps = 1;//冷媒个数
|
||||
//string hfld = "R1234YF.FLD"; R1234YF
|
||||
string hfld = "";
|
||||
if (Cryogen == "R134a")
|
||||
{
|
||||
hfld = "R134A.FLD";
|
||||
}
|
||||
else
|
||||
{
|
||||
hfld = "R134A.FLD";
|
||||
}
|
||||
//string hfld = "R134A.FLD";
|
||||
//string hfld = Convert.ToString(comboBox1.Text);//从控件获取数据
|
||||
size = hfld.Length;
|
||||
|
||||
hfld += new String(' ', 10000 - (int)size);
|
||||
|
||||
//string hfmix = "hmx.bnc" + new String(' ', 255);//原来的
|
||||
string hfmix = "hmx.bnc" + new String(' ', 255);//248
|
||||
string hrf = "DEF";
|
||||
string herr = new String(' ', 255);
|
||||
|
||||
iErr = 0;
|
||||
long hfldLen = hfld.Length, hfmixLen = hfmix.Length, hrfLen = hrf.Length, herrLen = herr.Length;
|
||||
|
||||
//numComps = -1;
|
||||
IRefProp64.SETUPdll(ref numComps, ref hfld, ref hfmix, ref hrf, ref iErr, ref herr, ref hfldLen, ref hfmixLen, ref hrfLen, ref herrLen);
|
||||
|
||||
double version = iErr / 10000.0;//错误信息
|
||||
if (iErr != 0)
|
||||
{
|
||||
//MessageBox.Show(herr, "RefProp SETUPdll() Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
IRefProp64.WMOLdll(x, ref wm);
|
||||
|
||||
//p = Convert.ToDouble(textBox2.Text) * 1000.0;//textBox2 Comp.吸气压力(Mpa)
|
||||
p = (InhPressTag.EngValue) * 1000.0;//textBox2 Comp.吸气压力(Mpa)
|
||||
kph = 1;
|
||||
|
||||
p1 = (TxvFrPressTag.EngValue) * 1000.0;//textBox3 Evap.膨胀阀前压力(Mpa)
|
||||
//p1 = Convert.ToDouble(textBox3.Text) * 1000.0;//textBox3 Evap.膨胀阀前压力(Mpa)
|
||||
IRefProp64.SATPdll(ref p, x, ref kph, ref te, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);
|
||||
|
||||
if (iErr == 0)
|
||||
Superheat = InhTempTag.EngValue - (te - 273.15);
|
||||
//textBox5.Text = String.Format("{0:n4}", Convert.ToDouble(textBox1.Text) - (te - 273.15));//textBox1 Comp.吸气温度(℃)
|
||||
else
|
||||
Superheat = 0;
|
||||
IRefProp64.SATPdll(ref p1, x, ref kph, ref te1, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);
|
||||
if (iErr == 0)
|
||||
Subcool = TxvFrTempTag.EngValue - (te1 - 273.15);//textBox4 Evap.膨胀阀前温度(℃)
|
||||
//GuoLengDu = (te1 - 273.15) - ListKRLogCellValue.Find(a => a.Name == "膨胀阀前温度").Value;//textBox4 Evap.膨胀阀前温度(℃)
|
||||
//textBox6.Text = String.Format("{0:n4}", Convert.ToDouble(textBox4.Text) - (te1 - 273.15));//textBox4 Evap.膨胀阀前温度(℃)
|
||||
else
|
||||
Subcool = 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//logger.Error(String.Format("ErrSource : {0} ErrMsg : {1}", ex.StackTrace.ToString(), ex.Message.ToString()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
#region 过热度和过冷度相关计算
|
||||
|
||||
/// <summary>
|
||||
/// 过热度和过冷度计算函数调用 风量的调用
|
||||
/// </summary>
|
||||
private void REFPROPSum()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
long iErr, kph = 1;
|
||||
|
||||
double te = 0.0, te1 = 0.0, p = 0.0, p1 = 0.0, d = 0.0, Dl = 0.0, Dv = 0.0, q = 0.0, h = 0.0, ee = 0.0, hh = 0.0, ss = 0.0, cp = 0.0, cv = 0.0, w = 0.0;
|
||||
double[] x = new double[20], xliq = new double[20], xvap = new double[20];
|
||||
double[] xlkg = new double[20], xvkg = new double[20];
|
||||
|
||||
|
||||
double tk = 0.0, wm = 0.0, prevDeltaH = 0.0;//prevDeltaH 未使用
|
||||
|
||||
//textBox5.Text = "";
|
||||
|
||||
|
||||
string hpath = @".\PPCalculation\REFPROP\FLUIDS";
|
||||
long size = hpath.Length;
|
||||
|
||||
hpath += new String(' ', 255 - (int)size);
|
||||
IRefProp64.SETPATHdll(hpath, ref size);
|
||||
|
||||
long numComps = 1;//冷媒个数
|
||||
//string hfld = "R1234YF.FLD";
|
||||
//string hfld = "R134A.FLD";
|
||||
string hfld = "";
|
||||
if (Cryogen == "R134a")
|
||||
{
|
||||
hfld = "R134A.FLD";
|
||||
}
|
||||
else
|
||||
{
|
||||
hfld = "R1234YF.FLD";
|
||||
|
||||
}
|
||||
|
||||
//string hfld = Convert.ToString(comboBox1.Text);//从控件获取数据
|
||||
size = hfld.Length;
|
||||
|
||||
hfld += new String(' ', 10000 - (int)size);
|
||||
|
||||
//string hfmix = "hmx.bnc" + new String(' ', 255);//原来的
|
||||
string hfmix = "hmx.bnc" + new String(' ', 248);
|
||||
string hrf = "DEF";
|
||||
string herr = new String(' ', 255);
|
||||
|
||||
iErr = 0;
|
||||
long hfldLen = hfld.Length, hfmixLen = hfmix.Length, hrfLen = hrf.Length, herrLen = herr.Length;
|
||||
|
||||
//numComps = -1;
|
||||
IRefProp64.SETUPdll(ref numComps, ref hfld, ref hfmix, ref hrf, ref iErr, ref herr, ref hfldLen, ref hfmixLen, ref hrfLen, ref herrLen);
|
||||
|
||||
|
||||
double version = iErr / 10000.0;//错误信息
|
||||
if (iErr != 0)
|
||||
{
|
||||
//MessageBox.Show(herr, "RefProp SETUPdll() Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
IRefProp64.WMOLdll(x, ref wm);
|
||||
|
||||
//p = Convert.ToDouble(textBox2.Text) * 1000.0;//textBox2 Comp.吸气压力(Mpa)
|
||||
//p = (ListRtKPMeter.Find(a => a.MeterName == "吸入压力").RtPV) * 1000.0;//textBox2 Comp.吸气压力(Mpa)
|
||||
p = (InhPressTag.EngValue) * 1000.0;//textBox2 Comp.吸气压力(Mpa)
|
||||
kph = 1;
|
||||
|
||||
//p1 = (ListKRLogCellValue.Find(a => a.Name == "膨胀阀前压力").Value) * 1000.0;//textBox3 Evap.膨胀阀前压力(Mpa)
|
||||
p1 = (TxvFrPressTag.EngValue) * 1000.0;//textBox3 Evap.膨胀阀前压力(Mpa)
|
||||
//p1 = Convert.ToDouble(textBox3.Text) * 1000.0;//textBox3 Evap.膨胀阀前压力(Mpa)
|
||||
|
||||
|
||||
IRefProp64.SATPdll(ref p, x, ref kph, ref te, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);
|
||||
|
||||
if (iErr == 0)
|
||||
|
||||
//GuoReDu = ListRtKPMeter.Find(a => a.MeterName == "吸入温度").RtPV - (te - 273.15);
|
||||
Superheat = InhTempTag.EngValue - (te - 273.15);
|
||||
//textBox5.Text = String.Format("{0:n4}", Convert.ToDouble(textBox1.Text) - (te - 273.15));//textBox1 Comp.吸气温度(℃)
|
||||
else
|
||||
Superheat = 0;
|
||||
|
||||
IRefProp64.SATPdll(ref p1, x, ref kph, ref te1, ref Dl, ref Dv, xliq, xvap, ref iErr, ref herr, ref herrLen);
|
||||
if (iErr == 0)
|
||||
//GuoLengDu = ListKRLogCellValue.Find(a => a.Name == "膨胀阀前温度").Value - (te1 - 273.15);//textBox4 Evap.膨胀阀前温度(℃)
|
||||
Subcool = TxvFrTempTag.EngValue - (te1 - 273.15);//textBox4 Evap.膨胀阀前温度(℃)
|
||||
|
||||
//textBox6.Text = String.Format("{0:n4}", Convert.ToDouble(textBox4.Text) - (te1 - 273.15));//textBox4 Evap.膨胀阀前温度(℃)
|
||||
|
||||
else
|
||||
Subcool = 0;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//logger.Error(String.Format("ErrSource : {0} ErrMsg : {1}", ex.StackTrace.ToString(), ex.Message.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 风量数据的计算
|
||||
/// </summary>
|
||||
private void AirVolumeDataSum()
|
||||
{
|
||||
//摄氏干球温度 Cd = 12号通道 蒸发器出口风洞温度 单位℃
|
||||
//var Cd = ListKRLogCellValue.Find(a => a.Name == "蒸发器出口风洞温度").Value;
|
||||
var Cd = 40;
|
||||
|
||||
//相对湿度% CRh = 11号通道 蒸发器出口湿度 单位%
|
||||
//var CRh = ListKRLogCellValue.Find(a => a.Name == "蒸发器出口湿度").Value;
|
||||
var CRh = 13.3;
|
||||
|
||||
//PKK-零调差压 31号通道(大气压减去测量点的气压)== 静压 单位pa
|
||||
//var PKK = ListKRLogCellValue.Find(a => a.Name == "静压").Value;
|
||||
var PKK = 0.9;
|
||||
|
||||
//BPRES - 测量的大气压 kPa:常数 kPa BPRES= 101.325Kpa
|
||||
var BPRES = 101.325;
|
||||
|
||||
//CDP - 测量到的喷嘴差压(Pa) 记录仪3号通道 蒸発风道差圧 单位pa
|
||||
//var CDP = ListKRLogCellValue.Find(a => a.Name == "蒸発风道差圧").Value;
|
||||
var CDP = 44;
|
||||
|
||||
//prmAirFlowFactor_i--喷嘴修正系数:设置为默认1.01
|
||||
var prmAirFlowFactor_i = 1.01;
|
||||
|
||||
AirVolumeData = AirCALCHepler.CVFCALC(Cd, CRh, PKK, BPRES, CDP, prmAirFlowFactor_i) * 60;
|
||||
|
||||
AirVolumeDataSource = AirVolumeData;
|
||||
|
||||
//系数的转换
|
||||
//AirCALCHepler.ListRozzle
|
||||
//RozzleEnableInfo
|
||||
|
||||
if (AirVolumeData >= 200 && AirVolumeData < 250)
|
||||
{
|
||||
if (RozzleEnableInfo.Contains("[40]") && RozzleEnableInfo.Contains("[50]") && !RozzleEnableInfo.Contains("[80]"))
|
||||
{
|
||||
AirVolumeData = AirVolumeData * 0.95;
|
||||
}
|
||||
}
|
||||
|
||||
if (AirVolumeData >= 250 && AirVolumeData < 300)
|
||||
{
|
||||
if (RozzleEnableInfo.Contains("[40]") && RozzleEnableInfo.Contains("[50]") && !RozzleEnableInfo.Contains("[80]"))
|
||||
{
|
||||
AirVolumeData = AirVolumeData * 1.05;
|
||||
}
|
||||
}
|
||||
|
||||
if (AirVolumeData >= 300 && AirVolumeData < 400)
|
||||
{
|
||||
if (!RozzleEnableInfo.Contains("[40]") && !RozzleEnableInfo.Contains("[50]") && RozzleEnableInfo.Contains("[80]"))
|
||||
{
|
||||
AirVolumeData = AirVolumeData * 1.125;
|
||||
}
|
||||
}
|
||||
|
||||
if (AirVolumeData >= 400 && AirVolumeData < 600)
|
||||
{
|
||||
if (RozzleEnableInfo.Contains("[40]") && !RozzleEnableInfo.Contains("[50]") && RozzleEnableInfo.Contains("[80]"))
|
||||
{
|
||||
AirVolumeData = AirVolumeData * 1.114;
|
||||
}
|
||||
}
|
||||
|
||||
//Console.WriteLine($"时间:{DateTime.Now.ToString()}摄氏干球温度 单位℃:{Cd} 相对湿度 单位%:{CRh}-零调差压 单位pa:{PKK}-大气压 单位Kpa:{BPRES}-喷嘴差压 单位Pa:{CDP}-喷嘴修正系数:{prmAirFlowFactor_i} 80通道风量结果:{Result}");
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user