SV2功能增加

一些功能的修复
This commit is contained in:
2025-05-21 12:17:46 +08:00
parent 03fd92ac86
commit 34ec76fda5
11 changed files with 507 additions and 83 deletions

View File

@@ -225,10 +225,9 @@
</Grid>
</TabItem>
</TabControl>
</Grid>
<Border
@@ -236,12 +235,23 @@
Margin="1,2,1,2"
Background="Gray"
CornerRadius="3">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="12"
Foreground="White"
Text="{Binding ElementName=MeterInstance, Path=MeterName}" />
Text="{Binding ElementName=MeterInstance, Path=MeterName}">
<TextBlock.ContextMenu>
<ContextMenu>
<!--
ContextMenu在WPF中是一个特殊元素它不在常规视觉树中而是在独立的窗口中
这导致ElementName绑定可能无法正常工作,没有使用Command处理所以用这个方式来获取
-->
<MenuItem Click="ExdMenuClick" Header="更多控制" />
</ContextMenu>
</TextBlock.ContextMenu>
</TextBlock>
</Border>
</Grid>
</materialDesign:Card>

View File

@@ -43,6 +43,22 @@ namespace CapMachine.Shared.Controls
}
}
/// <summary>
/// ContextMenu在WPF中是一个特殊元素它不在常规视觉树中而是在独立的窗口中
/// 这导致ElementName绑定可能无法正常工作,所以用这个方式来获取
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ExdMenuClick(object sender, RoutedEventArgs e)
{
if (ExdCommand != null && ExdCommand.CanExecute(ExdCommandParameter))
{
ExdCommandParameter = this;
ExdCommand.Execute(ExdCommandParameter);
}
}
/// <summary>
/// 仪表名称
/// </summary>
@@ -192,6 +208,32 @@ namespace CapMachine.Shared.Controls
//public event PropertyChangedEventHandler? PropertyChanged;
/// <summary>
/// 拓展控制切换 命令
/// </summary>
public ICommand ExdCommand
{
get { return (ICommand)GetValue(ExdCommandProperty); }
set { SetValue(ExdCommandProperty, value); }
}
public static readonly DependencyProperty ExdCommandProperty =
DependencyProperty.Register("ExdCommand", typeof(ICommand), typeof(Meter), new PropertyMetadata(default(ICommand)));
/// <summary>
/// ExdCommand 参数
/// </summary>
public object ExdCommandParameter
{
get
{
return (object)base.GetValue(Meter.ExdCommandParameterProperty);
}
set
{
base.SetValue(Meter.ExdCommandParameterProperty, value);
}
}
public static readonly DependencyProperty ExdCommandParameterProperty = DependencyProperty.Register("ExdCommandParameter", typeof(object), typeof(Meter), new PropertyMetadata());
@@ -376,5 +418,6 @@ namespace CapMachine.Shared.Controls
}
}
}
}

View File

@@ -206,7 +206,8 @@ namespace CapMachine.Wpf
containerRegistry.RegisterDialog<DialogLimitConfigView, DialogLimitConfigViewModel>();
containerRegistry.RegisterDialog<DialogSuperHeatCoolConfigView, DialogSuperHeatCoolConfigViewModel>();
containerRegistry.RegisterDialog<DialogLogicRuleView, DialogLogicRuleViewModel>();
containerRegistry.RegisterDialog<DialogMeterExdView, DialogMeterExdViewModel>();
containerRegistry.RegisterDialog<SplashScreenView, SplashScreenViewModel>();

View File

@@ -0,0 +1,30 @@
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CapMachine.Wpf.Models
{
/// <summary>
/// 仪表命令消息
/// </summary>
public class MeterCmdMsg:BindableBase
{
private string _Name;
/// <summary>
/// 名称
/// </summary>
public string Name
{
get { return _Name; }
set { _Name = value;RaisePropertyChanged(); }
}
/// <summary>
/// 参数 SV2
/// </summary>
public string Par { get; set; }
}
}

View File

@@ -351,7 +351,8 @@ namespace CapMachine.Wpf.Services
if (ListCanDbcModel.Any(a => a.Name == Name))
{
//double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue, out double Result1);
return double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue.Split(" ")[0], out double Result) == true ? Result : 0;
//return double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue.Split(" ")[0], out double Result) == true ? Result : 0;
return double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue, out double Result) == true ? Result : 0;
}
return 0;
}
@@ -369,8 +370,9 @@ namespace CapMachine.Wpf.Services
if (ListCanDbcModel.Any(a => a.Name == Name))
{
//double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue, out double Result1);
return double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue.Split(" ")[0], out double Result) == true ? Result : 0;
//double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue, out double Result1);
//return double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue.Split(" ")[0], out double Result) == true ? Result : 0;
return double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue, out double Result) == true ? Result : 0;
}
return 0;
}

View File

@@ -1078,13 +1078,13 @@ namespace CapMachine.Wpf.Services
RWInfo = RWInfo.PLCRead,
});
//Qcool_5K 计算
//Qcool 计算 制冷量
TagManger.AddTag(new ShortValueTag()
{
Id = 33,
Name = "Qcool_5K[W]",
NameNoUnit = "Qcool_5K",
EnName = "Qcool_5K",
Name = "制冷量[W]",
NameNoUnit = "制冷量",
EnName = "Qcool",
Group = "计算",
MinValue = 0,
MaxValue = 100,
@@ -1102,9 +1102,9 @@ namespace CapMachine.Wpf.Services
TagManger.AddTag(new ShortValueTag()
{
Id = 34,
Name = "Qcool_Customer[W]",
NameNoUnit = "Qcool_Customer",
EnName = "Qcool_Customer",
Name = "制热量[W]",
NameNoUnit = "制热量",
EnName = "Qheat",
Group = "计算",
MinValue = 0,
MaxValue = 100,
@@ -1118,33 +1118,33 @@ namespace CapMachine.Wpf.Services
RWInfo = RWInfo.PCCalcu,
});
//Qheat 计算
TagManger.AddTag(new ShortValueTag()
{
Id = 35,
Name = "Qheat[W]",
NameNoUnit = "Qheat",
EnName = "Qheat",
Group = "计算",
MinValue = 0,
MaxValue = 100,
IsMeter = false,
DecimalPoint = 1,
Precision = 1,
Unit = "W",
DataType = TagDataType.Short,
PVModel = new MeterValueAttrCell() { Address = "VW212", EngValue = 0, EngValueStr = "", Block = "PV", BlockIndex = 1 },
////Qheat 计算
//TagManger.AddTag(new ShortValueTag()
//{
// Id = 35,
// Name = "Qheat[W]",
// NameNoUnit = "Qheat",
// EnName = "Qheat",
// Group = "计算",
// MinValue = 0,
// MaxValue = 100,
// IsMeter = false,
// DecimalPoint = 1,
// Precision = 1,
// Unit = "W",
// DataType = TagDataType.Short,
// PVModel = new MeterValueAttrCell() { Address = "VW212", EngValue = 0, EngValueStr = "", Block = "PV", BlockIndex = 1 },
RWInfo = RWInfo.PCCalcu,
});
// RWInfo = RWInfo.PCCalcu,
//});
//COP_Cooling_5K 计算
TagManger.AddTag(new ShortValueTag()
{
Id = 36,
Name = "COP_Cooling_5K[W]",
NameNoUnit = "COP_Cooling_5K",
EnName = "COP_Cooling_5K",
Name = "制冷性能系数[W]",
NameNoUnit = "制冷性能系数",
EnName = "COPCooling",
Group = "计算",
MinValue = 0,
MaxValue = 100,
@@ -1158,33 +1158,33 @@ namespace CapMachine.Wpf.Services
RWInfo = RWInfo.PCCalcu,
});
//COP_Cooling_Customer 计算
TagManger.AddTag(new ShortValueTag()
{
Id = 37,
Name = "COP_Cooling_Customer[W]",
NameNoUnit = "COP_Cooling_Customer",
EnName = "COP_Cooling_Customer",
Group = "计算",
MinValue = 0,
MaxValue = 100,
IsMeter = false,
DecimalPoint = 1,
Precision = 1,
Unit = "W",
DataType = TagDataType.Short,
PVModel = new MeterValueAttrCell() { Address = "VW216", EngValue = 0, EngValueStr = "", Block = "PV", BlockIndex = 1 },
////COP_Cooling_Customer 计算 制冷性能系数
//TagManger.AddTag(new ShortValueTag()
//{
// Id = 37,
// Name = "COP_Cooling_Customer[W]",
// NameNoUnit = "COP_Cooling_Customer",
// EnName = "COP_Cooling_Customer",
// Group = "计算",
// MinValue = 0,
// MaxValue = 100,
// IsMeter = false,
// DecimalPoint = 1,
// Precision = 1,
// Unit = "W",
// DataType = TagDataType.Short,
// PVModel = new MeterValueAttrCell() { Address = "VW216", EngValue = 0, EngValueStr = "", Block = "PV", BlockIndex = 1 },
RWInfo = RWInfo.PCCalcu,
});
// RWInfo = RWInfo.PCCalcu,
//});
//COP_Heating 计算
//COP_Heating 计算 制热性能系数
TagManger.AddTag(new ShortValueTag()
{
Id = 38,
Name = "COP_Heating[W]",
NameNoUnit = "COP_Heating",
EnName = "COP_Heating",
Name = "制热性能系数[W]",
NameNoUnit = "制热性能系数",
EnName = "COPHeating",
Group = "计算",
MinValue = 0,
MaxValue = 100,
@@ -1198,12 +1198,12 @@ namespace CapMachine.Wpf.Services
RWInfo = RWInfo.PCCalcu,
});
//VolumeEfficiency 计算
//VolumeEfficiency 计算 容积效率
TagManger.AddTag(new ShortValueTag()
{
Id = 39,
Name = "VolumeEfficiency[%]",
NameNoUnit = "VolumeEfficiency",
Name = "容积效率[%]",
NameNoUnit = "容积效率",
EnName = "VolumeEfficiency",
Group = "计算",
MinValue = 0,
@@ -1218,12 +1218,12 @@ namespace CapMachine.Wpf.Services
RWInfo = RWInfo.PCCalcu,
});
//IsentropyEfficiency 计算
//IsentropyEfficiency 计算 等熵效率
TagManger.AddTag(new ShortValueTag()
{
Id = 40,
Name = "IsentropyEfficiency[%]",
NameNoUnit = "IsentropyEfficiency",
Name = "等熵效率[%]",
NameNoUnit = "等熵效率",
EnName = "IsentropyEfficiency",
Group = "计算",
MinValue = 0,
@@ -1239,25 +1239,25 @@ namespace CapMachine.Wpf.Services
});
//IsentropyEfficiency 计算
TagManger.AddTag(new ShortValueTag()
{
Id = 41,
Name = "IsentropyEfficiency[%]",
NameNoUnit = "IsentropyEfficiency",
EnName = "IsentropyEfficiency",
Group = "计算",
MinValue = 0,
MaxValue = 100,
IsMeter = false,
DecimalPoint = 1,
Precision = 1,
Unit = "%",
DataType = TagDataType.Short,
PVModel = new MeterValueAttrCell() { Address = "VW222", EngValue = 0, EngValueStr = "", Block = "PV", BlockIndex = 1 },
////IsentropyEfficiency 计算 等熵效率
//TagManger.AddTag(new ShortValueTag()
//{
// Id = 41,
// Name = "IsentropyEfficiency[%]",
// NameNoUnit = "IsentropyEfficiency",
// EnName = "IsentropyEfficiency",
// Group = "计算",
// MinValue = 0,
// MaxValue = 100,
// IsMeter = false,
// DecimalPoint = 1,
// Precision = 1,
// Unit = "%",
// DataType = TagDataType.Short,
// PVModel = new MeterValueAttrCell() { Address = "VW222", EngValue = 0, EngValueStr = "", Block = "PV", BlockIndex = 1 },
RWInfo = RWInfo.PCCalcu,
});
// RWInfo = RWInfo.PCCalcu,
//});
// 过冷度 计算
@@ -2644,7 +2644,8 @@ namespace CapMachine.Wpf.Services
{
if (itemBlockReadTag.Key.Contains("转速"))
{
var dd = 1;
//转速不需要PLC读取
continue;
}
//需要从PLC读取的标签才算
if ((itemBlockReadTag.Value.RWInfo == RWInfo.PLCRead || itemBlockReadTag.Value.RWInfo == RWInfo.Control) && TagManger.TryGetPVModel(itemBlockReadTag.Key, out MeterValueAttrCell pVModel))

View File

@@ -0,0 +1,162 @@
using CapMachine.Core;
using CapMachine.Wpf.Dtos;
using CapMachine.Wpf.Models;
using CapMachine.Wpf.Services;
using Prism.Commands;
using Prism.Services.Dialogs;
using System.Collections.ObjectModel;
namespace CapMachine.Wpf.ViewModels
{
public class DialogMeterExdViewModel : DialogViewModel
{
/// <summary>
/// 实例化函数
/// </summary>
public DialogMeterExdViewModel(MachineRtDataService machineRtDataService)
{
Title = "拓展控制";
MachineRtDataService = machineRtDataService;
}
/// <summary>
/// 当前的仪表命令消息
/// </summary>
public MeterCmdMsg CurMeterCmdMsg { get; set; }
private string name;
/// <summary>
/// 名称
/// </summary>
public string Name
{
get { return name; }
set { name = value; RaisePropertyChanged(); }
}
private int _Value;
/// <summary>
/// 值和数据
/// </summary>
public int Value
{
get { return _Value; }
set { _Value = value; RaisePropertyChanged(); }
}
private DelegateCommand _SendDataCmd;
/// <summary>
/// 发送数据命令
/// </summary>
public DelegateCommand SendDataCmd
{
set
{
_SendDataCmd = value;
}
get
{
if (_SendDataCmd == null)
{
_SendDataCmd = new DelegateCommand(() => SendDataCmdMethod());
}
return _SendDataCmd;
}
}
/// <summary>
/// 发送数据命令方法
/// </summary>
private void SendDataCmdMethod()
{
switch (CurMeterCmdMsg.Name)
{
case "PTC功率":
//发送数据 SV2
MachineRtDataService.SiemensDrive.Write("VW434", (short)Value);
break;
default:
break;
}
}
private DelegateCommand saveCmd;
/// <summary>
/// 保存命令
/// </summary>
public DelegateCommand SaveCmd
{
set
{
saveCmd = value;
}
get
{
if (saveCmd == null)
{
saveCmd = new DelegateCommand(() => SaveCmdMethod());
}
return saveCmd;
}
}
/// <summary>
/// 保存命令方法
/// </summary>
/// <exception cref="NotImplementedException"></exception>
private void SaveCmdMethod()
{
DialogParameters pars = new DialogParameters
{
{ "NewData", "" }
};
RaiseRequestClose(new DialogResult(ButtonResult.OK, pars));
}
private DelegateCommand cancelCmd;
/// <summary>
/// 保存命令
/// </summary>
public DelegateCommand CancelCmd
{
set
{
cancelCmd = value;
}
get
{
if (cancelCmd == null)
{
cancelCmd = new DelegateCommand(() => CancelCmdMethod());
}
return cancelCmd;
}
}
public MachineRtDataService MachineRtDataService { get; }
/// <summary>
/// 取消命令方法
/// </summary>
/// <exception cref="NotImplementedException"></exception>
private void CancelCmdMethod()
{
RaiseRequestClose(new DialogResult(ButtonResult.Cancel));
}
/// <summary>
/// 窗口打开时的传递的参数
/// </summary>
/// <param name="parameters"></param>
public override void OnDialogOpened(IDialogParameters parameters)
{
//Name = parameters.GetValue<string>("Name");
CurMeterCmdMsg = parameters.GetValue<MeterCmdMsg>("MeterCmdMsg");
}
}
}

View File

@@ -54,7 +54,7 @@ namespace CapMachine.Wpf.ViewModels
//ListTag = new ObservableCollection<ITag>(TagManager.DicTags.Values.ToList());
RefreshListTag();
ListMeterTag = TagManager.DicTags.Values.Where(a => a.Group == "程序").OrderBy(a=>a.Id).ToList();
ListMeterTag = TagManager.DicTags.Values.Where(a => a.Group == "程序").OrderBy(a => a.Id).ToList();
SpeedTag = TagManager.DicTags.GetValueOrDefault("转速[rpm]");
ExPressTag = TagManager.DicTags.GetValueOrDefault("排气压力[BarA]");
@@ -454,6 +454,62 @@ namespace CapMachine.Wpf.ViewModels
}
private DelegateCommand<object> _ExdCmd;
/// <summary>
/// 拓展操作指令
/// </summary>
public DelegateCommand<object> ExdCmd
{
set
{
_ExdCmd = value;
}
get
{
if (_ExdCmd == null)
{
_ExdCmd = new DelegateCommand<object>((p) => ExdCmdCall(p));
}
return _ExdCmd;
}
}
/// <summary>
/// 操作指令执行方法
/// </summary>
/// <exception cref="NotImplementedException"></exception>
private void ExdCmdCall(object Par)
{
if (Par != null && Par is Meter)
{
//
var MeterControl = (Meter)Par;
//Console.WriteLine($"{MeterControl.MeterName}-{MeterControl.AutoHandState}");
//弹窗
DialogService.ShowDialog("DialogMeterExdView", new DialogParameters() { { "MeterCmdMsg", new MeterCmdMsg() {Name= MeterControl.MeterName,Par="SV2" } } }, (par) =>
{
if (par.Result == ButtonResult.OK)
{
//试验信息
var ListChartTabGroupDto = par.Parameters.GetValue<ExpInfoDto>("ReturnValue");
}
else if (par.Result == ButtonResult.Cancel)
{
//取消
}
});
}
}
private DelegateCommand<object> _HandValueCmd;
/// <summary>
/// 手动给值

View File

@@ -0,0 +1,90 @@
<UserControl
x:Class="CapMachine.Wpf.Views.DialogMeterExdView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CapMachine.Wpf.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="60" />
<RowDefinition />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Vertical">
<StackPanel
Margin="70,10"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="24"
Text="{Binding CurMeterCmdMsg.Name}"
TextAlignment="Center" />
</StackPanel>
</StackPanel>
<StackPanel
Grid.Row="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Vertical">
<StackPanel
Margin="70,10"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
Margin="10,0,5,0"
VerticalAlignment="Center"
FontFamily="/Assets/Fonts/#iconfont"
FontSize="24"
Foreground="Gray"
Text="&#xe9f8;" />
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="24"
Text="SV2"
TextAlignment="Center" />
<TextBox
Width="100"
VerticalAlignment="Center"
BorderBrush="Gray"
BorderThickness="1"
FontSize="24"
Text="{Binding Value}" />
<Button
Margin="10,0"
Command="{Binding SendDataCmd}"
Content="发送数据" />
</StackPanel>
</StackPanel>
<StackPanel
Grid.Row="2"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button
Margin="10,10"
Command="{Binding SaveCmd}"
Content="确定"
Foreground="White" />
<Button
Margin="10,0"
Command="{Binding CancelCmd}"
Content="取消"
Foreground="White" />
</StackPanel>
</Grid>
</UserControl>

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace CapMachine.Wpf.Views
{
/// <summary>
/// DialogMeterExdView.xaml 的交互逻辑
/// </summary>
public partial class DialogMeterExdView : UserControl
{
public DialogMeterExdView()
{
InitializeComponent();
}
}
}

View File

@@ -167,6 +167,7 @@
Margin="2,0"
AutoHandCommand="{Binding Source={StaticResource Proxy}, Path=Data.AutoHandCmd}"
AutoHandState="False"
ExdCommand="{Binding Source={StaticResource Proxy}, Path=Data.ExdCmd}"
HandValueCommand="{Binding Source={StaticResource Proxy}, Path=Data.HandValueCmd}"
HandValueMVParameter="{Binding MVModel.EngValue}"
HandValueSVParameter="{Binding SVModel.EngValue}"