更新了Tag的字段属性和Can配置的修复
This commit is contained in:
@@ -675,6 +675,8 @@ namespace CapMachine.Wpf.CanDrive
|
||||
//关闭设备
|
||||
USB_DEVICE.USB_CloseDevice(DevHandle);
|
||||
OpenState = false;
|
||||
IsCycleRevice = false;
|
||||
IsCycleSend = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
64
CapMachine.Wpf/Models/AutoHandSwtichCondition.cs
Normal file
64
CapMachine.Wpf/Models/AutoHandSwtichCondition.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using HslCommunication;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 手自动切换的条件
|
||||
/// </summary>
|
||||
public class AutoHandSwtichCondition : BindableBase
|
||||
{
|
||||
private bool _IsCanSwitch;
|
||||
/// <summary>
|
||||
/// 是否可切换
|
||||
/// </summary>
|
||||
public bool IsCanSwitch
|
||||
{
|
||||
get { return _IsCanSwitch; }
|
||||
set { _IsCanSwitch = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 全部报警地址
|
||||
/// </summary>
|
||||
public string? AlarmAddress { get; set; } = "V3.0";
|
||||
|
||||
/// <summary>
|
||||
/// 报警结果
|
||||
/// </summary>
|
||||
public OperateResult<bool>? AlarmStateResult { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 手动状态地址
|
||||
/// </summary>
|
||||
public string? HandStateAddress { get; set; } = "M0.0";
|
||||
|
||||
/// <summary>
|
||||
/// 手动状态结果
|
||||
/// </summary>
|
||||
public OperateResult<bool>? HandStateResult { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 汇总结果
|
||||
/// </summary>
|
||||
/// <param name="AlarmState"></param>
|
||||
/// <param name="HandState"></param>
|
||||
/// <returns></returns>
|
||||
public void SumResult()
|
||||
{
|
||||
if (AlarmStateResult!.IsSuccess && HandStateResult!.IsSuccess)
|
||||
{
|
||||
//IsCanSwitch = AlarmStateResult.Content==false && HandStateResult.Content==false;
|
||||
IsCanSwitch = HandStateResult.Content==false;
|
||||
//return IsCanSwitch;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ namespace CapMachine.Wpf.Models.Tag
|
||||
/// <summary>
|
||||
/// 工程值 Mv
|
||||
/// </summary>
|
||||
short EngMvValue { get; set; }
|
||||
double EngMvValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工程值的字符串 Mv
|
||||
|
||||
@@ -235,11 +235,11 @@ namespace CapMachine.Wpf.Models.Tag
|
||||
}
|
||||
|
||||
|
||||
private short _EngMvValue;
|
||||
private double _EngMvValue;
|
||||
/// <summary>
|
||||
/// 工程值 MV
|
||||
/// </summary>
|
||||
public short EngMvValue
|
||||
public double EngMvValue
|
||||
{
|
||||
get { return _EngMvValue; }
|
||||
set
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace CapMachine.Wpf.Services
|
||||
{
|
||||
if (ToomossCanDrive.IsCycleRevice == false)
|
||||
{
|
||||
if (CmdData.Count > 0)
|
||||
if (ListCanDbcModel.Count > 0)
|
||||
{
|
||||
ToomossCanDrive.IsCycleRevice = true;
|
||||
ToomossCanDrive.StartCycleReviceCanMsg();
|
||||
|
||||
@@ -96,6 +96,11 @@ namespace CapMachine.Wpf.Services
|
||||
/// </summary>
|
||||
public List<RecordInfo> HistoryData { get; set; } = new List<RecordInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// 手自动切换的条件
|
||||
/// </summary>
|
||||
public AutoHandSwtichCondition AutoHandSwtichConditionState { get; set; } = new AutoHandSwtichCondition();
|
||||
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
@@ -125,7 +130,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 });
|
||||
@@ -203,9 +208,9 @@ namespace CapMachine.Wpf.Services
|
||||
Unit = "MpaA",
|
||||
PVAddress = "VW102",//地址信息
|
||||
SVAddress = "VW202",
|
||||
MVAddress = "VW246",
|
||||
MVAddress = "VW242",
|
||||
IsMeter = true,
|
||||
AutoHandSwitchAddress = "VW244",
|
||||
AutoHandSwitchAddress = "VW240",
|
||||
Precision = 1000,
|
||||
DecimalPoint = 3,
|
||||
Samp = 1,
|
||||
@@ -223,9 +228,9 @@ namespace CapMachine.Wpf.Services
|
||||
Unit = "MpaA",
|
||||
PVAddress = "VW104",//地址信息
|
||||
SVAddress = "VW204",
|
||||
MVAddress = "VW250",
|
||||
MVAddress = "VW246",
|
||||
IsMeter = true,
|
||||
AutoHandSwitchAddress = "VW248",
|
||||
AutoHandSwitchAddress = "VW244",
|
||||
Precision = 1000,
|
||||
DecimalPoint = 3,
|
||||
Samp = 1,
|
||||
@@ -243,9 +248,9 @@ namespace CapMachine.Wpf.Services
|
||||
Unit = "℃",
|
||||
PVAddress = "VW106",//地址信息
|
||||
SVAddress = "VW206",
|
||||
MVAddress = "VW254",
|
||||
MVAddress = "VW250",
|
||||
IsMeter = true,
|
||||
AutoHandSwitchAddress = "VW252",
|
||||
AutoHandSwitchAddress = "VW248",
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
@@ -263,9 +268,9 @@ namespace CapMachine.Wpf.Services
|
||||
Unit = "℃",
|
||||
PVAddress = "VW108",//地址信息
|
||||
SVAddress = "VW208",
|
||||
MVAddress = "VW258",
|
||||
MVAddress = "VW254",
|
||||
IsMeter = true,
|
||||
AutoHandSwitchAddress = "VW256",
|
||||
AutoHandSwitchAddress = "VW252",
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
@@ -283,9 +288,9 @@ namespace CapMachine.Wpf.Services
|
||||
Unit = "℃",
|
||||
PVAddress = "VW110",//地址信息
|
||||
SVAddress = "VW210",
|
||||
MVAddress = "VW262",
|
||||
MVAddress = "VW258",
|
||||
IsMeter = true,
|
||||
AutoHandSwitchAddress = "VW260",
|
||||
AutoHandSwitchAddress = "VW256",
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
@@ -303,9 +308,9 @@ namespace CapMachine.Wpf.Services
|
||||
Unit = "V",
|
||||
PVAddress = "VW112",//地址信息
|
||||
SVAddress = "VW212",
|
||||
MVAddress = "",
|
||||
MVAddress = "VW262",
|
||||
IsMeter = true,
|
||||
AutoHandSwitchAddress = "",
|
||||
AutoHandSwitchAddress = "VW260",
|
||||
Precision = 10,
|
||||
DecimalPoint = 1,
|
||||
Samp = 1,
|
||||
@@ -1097,26 +1102,26 @@ 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;
|
||||
|
||||
////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
|
||||
// {
|
||||
////仿真数据
|
||||
//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;
|
||||
}
|
||||
else
|
||||
{
|
||||
LinkState = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(itemTag.Value.SVAddress))
|
||||
{
|
||||
@@ -1139,7 +1144,7 @@ namespace CapMachine.Wpf.Services
|
||||
if (OperateResultMVShort.IsSuccess)
|
||||
{
|
||||
//TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = OperateResultMVShort.Content;
|
||||
TagManger.GetTagByName<short>(itemTag.Value.Name).EngMvValue = OperateResultMVShort.Content;
|
||||
TagManger.GetTagByName<short>(itemTag.Value.Name).EngMvValue = OperateResultMVShort.Content*1.0/10;
|
||||
LinkState = true;
|
||||
}
|
||||
else
|
||||
@@ -1148,6 +1153,11 @@ namespace CapMachine.Wpf.Services
|
||||
}
|
||||
}
|
||||
|
||||
//手自动切换按钮条件
|
||||
AutoHandSwtichConditionState.AlarmStateResult= SiemensDrive.ReadBool(AutoHandSwtichConditionState.AlarmAddress);
|
||||
AutoHandSwtichConditionState.HandStateResult= SiemensDrive.ReadBool(AutoHandSwtichConditionState.HandStateAddress);
|
||||
AutoHandSwtichConditionState.SumResult();
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -407,6 +407,19 @@ namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
ListWriteCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>(Mapper.Map<List<CanLinRWConfigDto>>(WirteData));
|
||||
|
||||
//加载把当前的配置信息给指令
|
||||
CanDriveService.CmdData.Clear();
|
||||
foreach (var item in WirteData)
|
||||
{
|
||||
CanDriveService.CmdData.Add(new CanCmdData()
|
||||
{
|
||||
ConfigName = item.Name,
|
||||
MsgName = item.MsgFrameName,
|
||||
SignalName = item.SignalName,
|
||||
SignalCmdValue = double.TryParse(item.DefautValue, out double result) == true ? result : 0,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
var ReadData = SelectCanLinConfigPro.CanLinConfigContents!.Where(a => a.RWInfo == RW.Read).ToList();
|
||||
if (ReadData != null && ReadData.Count > 0)
|
||||
|
||||
@@ -334,10 +334,10 @@ namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
switch (ChannelValue.Type)
|
||||
{
|
||||
case "MV":
|
||||
case "MV"://10的倍率
|
||||
if (!string.IsNullOrEmpty(item.Value.MVAddress))
|
||||
{
|
||||
var Result = MachineRtDataService.SiemensDrive.Write(item.Value.MVAddress, (short)((double)ChannelValue.Value));
|
||||
var Result = MachineRtDataService.SiemensDrive.Write(item.Value.MVAddress, (short)((double)ChannelValue.Value * 10));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -405,6 +405,10 @@ namespace CapMachine.Wpf.ViewModels
|
||||
var FindData = ListHandSwitchData.FirstOrDefault(a => a.Name == Name);
|
||||
if (FindData != null)
|
||||
{
|
||||
if (Name == "自动")
|
||||
{
|
||||
//手动切换是可以自由的切换,不受限制
|
||||
|
||||
//ToDo
|
||||
Console.WriteLine($"{FindData.Name}-{FindData.ActionAddress}-{FindData.StateAddress}-{Data}");
|
||||
var Result = MachineRtDataService.SiemensDrive.Write(FindData.ActionAddress, (bool)Data);
|
||||
@@ -412,6 +416,25 @@ namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//其他的手自动切换受条件过滤处理
|
||||
if (!MachineRtDataService.AutoHandSwtichConditionState.IsCanSwitch)
|
||||
{
|
||||
System.Windows.MessageBox.Show("当前的切换需要在【手动】和【无报警】的情况下进行");
|
||||
return;
|
||||
}
|
||||
|
||||
//满足条件进行操作,只进行True操作,PLC会处理的
|
||||
Console.WriteLine($"{FindData.Name}-{FindData.ActionAddress}-{FindData.StateAddress}-{Data}");
|
||||
var Result = MachineRtDataService.SiemensDrive.Write(FindData.ActionAddress, true);
|
||||
if (Result.IsSuccess)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//FindData.State = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@
|
||||
<Setter Property="Width" Value="80" />
|
||||
</Style>
|
||||
<Style x:Key="TextBlockStyle" TargetType="TextBlock">
|
||||
<Setter Property="Width" Value="75" />
|
||||
<Setter Property="Width" Value="110" />
|
||||
<Setter Property="FontSize" Value="18" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
@@ -416,7 +416,7 @@
|
||||
FontFamily="/Assets/Fonts/#iconfont"
|
||||
FontSize="18"
|
||||
Text="" />
|
||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="循环周期" />
|
||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="循环周期(ms)" />
|
||||
<TextBox Style="{StaticResource TextBoxStyle}" Text="{Binding SelectedCANConfigExdDto.Cycle}" />
|
||||
</StackPanel>
|
||||
|
||||
@@ -430,7 +430,7 @@
|
||||
FontFamily="/Assets/Fonts/#iconfont"
|
||||
FontSize="18"
|
||||
Text="" />
|
||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="连接状态" />
|
||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="CAN连接状态" />
|
||||
<Border
|
||||
Width="90"
|
||||
Margin="5,10"
|
||||
|
||||
@@ -492,10 +492,10 @@
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="/Assets/Fonts/#iconfont"
|
||||
FontSize="26"
|
||||
Foreground="OrangeRed"
|
||||
Foreground="Red"
|
||||
Text="" />
|
||||
<TextBlock
|
||||
Foreground="OrangeRed"
|
||||
FontSize="20"
|
||||
Style="{StaticResource TitelStyle}"
|
||||
Text="报警:" />
|
||||
|
||||
@@ -824,7 +824,7 @@
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<!-- HandValueParameter="{Binding MVValue}" -->
|
||||
<!-- HandValueParameter="{Binding MVValue}" IsEnabled="{Binding MachineRtDataService.AutoHandSwtichConditionState.IsCanSwitch}" -->
|
||||
<DataTemplate>
|
||||
<StackPanel Margin="0,2,2,2" Orientation="Horizontal">
|
||||
<ToggleButton
|
||||
@@ -1019,16 +1019,16 @@
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="冷凝器进水温"
|
||||
CellUnit="{Binding Cond1TempTag.Unit}"
|
||||
CellValue="{Binding Cond1TempTag.EngPvValueStr}" />
|
||||
CellUnit="{Binding CondInTempTag.Unit}"
|
||||
CellValue="{Binding CondInTempTag.EngPvValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="1194"
|
||||
Canvas.Top="360"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Top"
|
||||
CellTitle="冷凝器出水温"
|
||||
CellUnit="{Binding CondInTempTag.Unit}"
|
||||
CellValue="{Binding CondInTempTag.EngPvValueStr}" />
|
||||
CellUnit="{Binding Cond1TempTag.Unit}"
|
||||
CellValue="{Binding Cond1TempTag.EngPvValueStr}" />
|
||||
<Controls:ValueShow
|
||||
Canvas.Left="1217"
|
||||
Canvas.Top="136"
|
||||
|
||||
Reference in New Issue
Block a user