更新了Tag的字段属性和Can配置的修复

This commit is contained in:
2025-01-06 10:06:36 +08:00
parent 3a5674054d
commit e5ebd9113a
11 changed files with 166 additions and 54 deletions

View File

@@ -675,6 +675,8 @@ namespace CapMachine.Wpf.CanDrive
//关闭设备 //关闭设备
USB_DEVICE.USB_CloseDevice(DevHandle); USB_DEVICE.USB_CloseDevice(DevHandle);
OpenState = false; OpenState = false;
IsCycleRevice = false;
IsCycleSend = false;
} }
} }

View 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;
}
}
}
}

View File

@@ -54,7 +54,7 @@ namespace CapMachine.Wpf.Models.Tag
/// <summary> /// <summary>
/// 工程值 Mv /// 工程值 Mv
/// </summary> /// </summary>
short EngMvValue { get; set; } double EngMvValue { get; set; }
/// <summary> /// <summary>
/// 工程值的字符串 Mv /// 工程值的字符串 Mv

View File

@@ -235,11 +235,11 @@ namespace CapMachine.Wpf.Models.Tag
} }
private short _EngMvValue; private double _EngMvValue;
/// <summary> /// <summary>
/// 工程值 MV /// 工程值 MV
/// </summary> /// </summary>
public short EngMvValue public double EngMvValue
{ {
get { return _EngMvValue; } get { return _EngMvValue; }
set set

View File

@@ -143,7 +143,7 @@ namespace CapMachine.Wpf.Services
{ {
if (ToomossCanDrive.IsCycleRevice == false) if (ToomossCanDrive.IsCycleRevice == false)
{ {
if (CmdData.Count > 0) if (ListCanDbcModel.Count > 0)
{ {
ToomossCanDrive.IsCycleRevice = true; ToomossCanDrive.IsCycleRevice = true;
ToomossCanDrive.StartCycleReviceCanMsg(); ToomossCanDrive.StartCycleReviceCanMsg();

View File

@@ -96,6 +96,11 @@ namespace CapMachine.Wpf.Services
/// </summary> /// </summary>
public List<RecordInfo> HistoryData { get; set; } = new List<RecordInfo>(); public List<RecordInfo> HistoryData { get; set; } = new List<RecordInfo>();
/// <summary>
/// 手自动切换的条件
/// </summary>
public AutoHandSwtichCondition AutoHandSwtichConditionState { get; set; } = new AutoHandSwtichCondition();
/// <summary> /// <summary>
/// 实例化函数 /// 实例化函数
/// </summary> /// </summary>
@@ -125,7 +130,7 @@ namespace CapMachine.Wpf.Services
#region #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]", "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>("吸气压力", "吸气压力[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 }); //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", Unit = "MpaA",
PVAddress = "VW102",//地址信息 PVAddress = "VW102",//地址信息
SVAddress = "VW202", SVAddress = "VW202",
MVAddress = "VW246", MVAddress = "VW242",
IsMeter = true, IsMeter = true,
AutoHandSwitchAddress = "VW244", AutoHandSwitchAddress = "VW240",
Precision = 1000, Precision = 1000,
DecimalPoint = 3, DecimalPoint = 3,
Samp = 1, Samp = 1,
@@ -223,9 +228,9 @@ namespace CapMachine.Wpf.Services
Unit = "MpaA", Unit = "MpaA",
PVAddress = "VW104",//地址信息 PVAddress = "VW104",//地址信息
SVAddress = "VW204", SVAddress = "VW204",
MVAddress = "VW250", MVAddress = "VW246",
IsMeter = true, IsMeter = true,
AutoHandSwitchAddress = "VW248", AutoHandSwitchAddress = "VW244",
Precision = 1000, Precision = 1000,
DecimalPoint = 3, DecimalPoint = 3,
Samp = 1, Samp = 1,
@@ -243,9 +248,9 @@ namespace CapMachine.Wpf.Services
Unit = "℃", Unit = "℃",
PVAddress = "VW106",//地址信息 PVAddress = "VW106",//地址信息
SVAddress = "VW206", SVAddress = "VW206",
MVAddress = "VW254", MVAddress = "VW250",
IsMeter = true, IsMeter = true,
AutoHandSwitchAddress = "VW252", AutoHandSwitchAddress = "VW248",
Precision = 10, Precision = 10,
DecimalPoint = 1, DecimalPoint = 1,
Samp = 1, Samp = 1,
@@ -263,9 +268,9 @@ namespace CapMachine.Wpf.Services
Unit = "℃", Unit = "℃",
PVAddress = "VW108",//地址信息 PVAddress = "VW108",//地址信息
SVAddress = "VW208", SVAddress = "VW208",
MVAddress = "VW258", MVAddress = "VW254",
IsMeter = true, IsMeter = true,
AutoHandSwitchAddress = "VW256", AutoHandSwitchAddress = "VW252",
Precision = 10, Precision = 10,
DecimalPoint = 1, DecimalPoint = 1,
Samp = 1, Samp = 1,
@@ -283,9 +288,9 @@ namespace CapMachine.Wpf.Services
Unit = "℃", Unit = "℃",
PVAddress = "VW110",//地址信息 PVAddress = "VW110",//地址信息
SVAddress = "VW210", SVAddress = "VW210",
MVAddress = "VW262", MVAddress = "VW258",
IsMeter = true, IsMeter = true,
AutoHandSwitchAddress = "VW260", AutoHandSwitchAddress = "VW256",
Precision = 10, Precision = 10,
DecimalPoint = 1, DecimalPoint = 1,
Samp = 1, Samp = 1,
@@ -303,9 +308,9 @@ namespace CapMachine.Wpf.Services
Unit = "V", Unit = "V",
PVAddress = "VW112",//地址信息 PVAddress = "VW112",//地址信息
SVAddress = "VW212", SVAddress = "VW212",
MVAddress = "", MVAddress = "VW262",
IsMeter = true, IsMeter = true,
AutoHandSwitchAddress = "", AutoHandSwitchAddress = "VW260",
Precision = 10, Precision = 10,
DecimalPoint = 1, DecimalPoint = 1,
Samp = 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)!.IsShow = IsValueShow;
//仿真数据 ////仿真数据
TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = (short)Random.Next(1, 100); //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; //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; //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)) if (!string.IsNullOrEmpty(itemTag.Value.SVAddress))
{ {
@@ -1139,7 +1144,7 @@ namespace CapMachine.Wpf.Services
if (OperateResultMVShort.IsSuccess) if (OperateResultMVShort.IsSuccess)
{ {
//TagManger.GetTagInfoValueByName<short>(itemTag.Value.Name)!.Value = OperateResultMVShort.Content; //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; LinkState = true;
} }
else else
@@ -1148,6 +1153,11 @@ namespace CapMachine.Wpf.Services
} }
} }
//手自动切换按钮条件
AutoHandSwtichConditionState.AlarmStateResult= SiemensDrive.ReadBool(AutoHandSwtichConditionState.AlarmAddress);
AutoHandSwtichConditionState.HandStateResult= SiemensDrive.ReadBool(AutoHandSwtichConditionState.HandStateAddress);
AutoHandSwtichConditionState.SumResult();
break; break;
default: default:
break; break;

View File

@@ -407,6 +407,19 @@ namespace CapMachine.Wpf.ViewModels
{ {
ListWriteCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>(Mapper.Map<List<CanLinRWConfigDto>>(WirteData)); 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(); var ReadData = SelectCanLinConfigPro.CanLinConfigContents!.Where(a => a.RWInfo == RW.Read).ToList();
if (ReadData != null && ReadData.Count > 0) if (ReadData != null && ReadData.Count > 0)

View File

@@ -334,10 +334,10 @@ namespace CapMachine.Wpf.ViewModels
{ {
switch (ChannelValue.Type) switch (ChannelValue.Type)
{ {
case "MV": case "MV"://10的倍率
if (!string.IsNullOrEmpty(item.Value.MVAddress)) 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;
} }
break; break;
@@ -405,6 +405,10 @@ namespace CapMachine.Wpf.ViewModels
var FindData = ListHandSwitchData.FirstOrDefault(a => a.Name == Name); var FindData = ListHandSwitchData.FirstOrDefault(a => a.Name == Name);
if (FindData != null) if (FindData != null)
{ {
if (Name == "自动")
{
//手动切换是可以自由的切换,不受限制
//ToDo //ToDo
Console.WriteLine($"{FindData.Name}-{FindData.ActionAddress}-{FindData.StateAddress}-{Data}"); Console.WriteLine($"{FindData.Name}-{FindData.ActionAddress}-{FindData.StateAddress}-{Data}");
var Result = MachineRtDataService.SiemensDrive.Write(FindData.ActionAddress, (bool)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; //FindData.State = false;
} }
} }

View File

@@ -273,7 +273,7 @@
<Setter Property="Width" Value="80" /> <Setter Property="Width" Value="80" />
</Style> </Style>
<Style x:Key="TextBlockStyle" TargetType="TextBlock"> <Style x:Key="TextBlockStyle" TargetType="TextBlock">
<Setter Property="Width" Value="75" /> <Setter Property="Width" Value="110" />
<Setter Property="FontSize" Value="18" /> <Setter Property="FontSize" Value="18" />
<Setter Property="HorizontalAlignment" Value="Center" /> <Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Center" />
@@ -416,7 +416,7 @@
FontFamily="/Assets/Fonts/#iconfont" FontFamily="/Assets/Fonts/#iconfont"
FontSize="18" FontSize="18"
Text="&#xe9f8;" /> Text="&#xe9f8;" />
<TextBlock Style="{StaticResource TextBlockStyle}" Text="循环周期" /> <TextBlock Style="{StaticResource TextBlockStyle}" Text="循环周期(ms)" />
<TextBox Style="{StaticResource TextBoxStyle}" Text="{Binding SelectedCANConfigExdDto.Cycle}" /> <TextBox Style="{StaticResource TextBoxStyle}" Text="{Binding SelectedCANConfigExdDto.Cycle}" />
</StackPanel> </StackPanel>
@@ -430,7 +430,7 @@
FontFamily="/Assets/Fonts/#iconfont" FontFamily="/Assets/Fonts/#iconfont"
FontSize="18" FontSize="18"
Text="&#xe8fa;" /> Text="&#xe8fa;" />
<TextBlock Style="{StaticResource TextBlockStyle}" Text="连接状态" /> <TextBlock Style="{StaticResource TextBlockStyle}" Text="CAN连接状态" />
<Border <Border
Width="90" Width="90"
Margin="5,10" Margin="5,10"

View File

@@ -492,10 +492,10 @@
VerticalAlignment="Center" VerticalAlignment="Center"
FontFamily="/Assets/Fonts/#iconfont" FontFamily="/Assets/Fonts/#iconfont"
FontSize="26" FontSize="26"
Foreground="OrangeRed" Foreground="Red"
Text="&#xe636;" /> Text="&#xe636;" />
<TextBlock <TextBlock
Foreground="OrangeRed" FontSize="20"
Style="{StaticResource TitelStyle}" Style="{StaticResource TitelStyle}"
Text="报警:" /> Text="报警:" />
@@ -824,7 +824,7 @@
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ItemsControl.ItemsPanel> </ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<!-- HandValueParameter="{Binding MVValue}" --> <!-- HandValueParameter="{Binding MVValue}" IsEnabled="{Binding MachineRtDataService.AutoHandSwtichConditionState.IsCanSwitch}" -->
<DataTemplate> <DataTemplate>
<StackPanel Margin="0,2,2,2" Orientation="Horizontal"> <StackPanel Margin="0,2,2,2" Orientation="Horizontal">
<ToggleButton <ToggleButton
@@ -1019,16 +1019,16 @@
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
CellTitle="冷凝器进水温" CellTitle="冷凝器进水温"
CellUnit="{Binding Cond1TempTag.Unit}" CellUnit="{Binding CondInTempTag.Unit}"
CellValue="{Binding Cond1TempTag.EngPvValueStr}" /> CellValue="{Binding CondInTempTag.EngPvValueStr}" />
<Controls:ValueShow <Controls:ValueShow
Canvas.Left="1194" Canvas.Left="1194"
Canvas.Top="360" Canvas.Top="360"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
CellTitle="冷凝器出水温" CellTitle="冷凝器出水温"
CellUnit="{Binding CondInTempTag.Unit}" CellUnit="{Binding Cond1TempTag.Unit}"
CellValue="{Binding CondInTempTag.EngPvValueStr}" /> CellValue="{Binding Cond1TempTag.EngPvValueStr}" />
<Controls:ValueShow <Controls:ValueShow
Canvas.Left="1217" Canvas.Left="1217"
Canvas.Top="136" Canvas.Top="136"