From 006c98e5650b530e5220f279c1e803fefe69d40d Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期二, 25 十一月 2025 15:47:33 +0800
Subject: [PATCH] 优化一些东西;
---
Plugin.CurrentSensorControl/BurnInSettingModal.xaml | 1
Plugin.CurrentSensorControl/BurnInSettingModal.xaml.cs | 2
ModBusTcpController/Properties/AssemblyInfo.cs | 5 -
HMI.Core/HMI.Core.csproj | 7 --
WPFProject/WPFProject.csproj | 1
Plugin.TsExecution/TsExecution.xaml.cs | 23 +++++++
ModBusTcpController/ModBusTcpController.cs | 8 +-
Plugin.TsExecution/TsExecution.xaml | 15 ++++
Plugin.CurrentSensorControl/BurnInOvenCollection.xaml | 2
Plugin.CurrentSensorControl/ControlPage.xaml.cs | 43 +++++++++++++
Plugin.TsExecution/SingleControl.xaml | 6 +-
Plugin.CurrentSensorControl/BurnInOven.xaml | 4
Plugin.CurrentSensorControl/ControlPage.xaml | 10 ++
13 files changed, 102 insertions(+), 25 deletions(-)
diff --git a/HMI.Core/HMI.Core.csproj b/HMI.Core/HMI.Core.csproj
index 7ee41cc..a5fcd43 100644
--- a/HMI.Core/HMI.Core.csproj
+++ b/HMI.Core/HMI.Core.csproj
@@ -85,18 +85,11 @@
<Reference Include="System.Data.SQLite">
<HintPath>..\Libs\System.Data.SQLite.dll</HintPath>
</Reference>
- <Reference Include="System.Data.SQLite.EF6">
- <HintPath>..\Libs\System.Data.SQLite.EF6.dll</HintPath>
- </Reference>
- <Reference Include="System.Data.SQLite.Linq">
- <HintPath>..\Libs\System.Data.SQLite.Linq.dll</HintPath>
- </Reference>
<Reference Include="System.Messaging" />
<Reference Include="System.Numerics" />
<Reference Include="System.Web" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
diff --git a/ModBusTcpController/ModBusTcpController.cs b/ModBusTcpController/ModBusTcpController.cs
index 9597de8..e431966 100644
--- a/ModBusTcpController/ModBusTcpController.cs
+++ b/ModBusTcpController/ModBusTcpController.cs
@@ -48,19 +48,19 @@
return res?.IsSuccess == true;
}
- public bool ReadDIInt(string address, out int? res, out string msg)
+ public bool ReadDIInt(string address, out int res, out string msg)
{
var result = client?.ReadInt32($"x=2;{address}");
msg = result?.Message;
- res = result?.Content;
+ res = result?.Content ?? 0;
return result?.IsSuccess == true;
}
- public bool ReadDOInt(string address, out int? res, out string msg)
+ public bool ReadDOInt(string address, out int res, out string msg)
{
var result = client?.ReadInt32(address);
msg = result?.Message;
- res = result?.Content;
+ res = result?.Content ?? 0;
return result?.IsSuccess == true;
}
diff --git a/ModBusTcpController/Properties/AssemblyInfo.cs b/ModBusTcpController/Properties/AssemblyInfo.cs
index ccc4c44..bfe46a3 100644
--- a/ModBusTcpController/Properties/AssemblyInfo.cs
+++ b/ModBusTcpController/Properties/AssemblyInfo.cs
@@ -1,5 +1,4 @@
锘縰sing System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 鏈夊叧绋嬪簭闆嗙殑涓�鑸俊鎭敱浠ヤ笅
@@ -29,5 +28,5 @@
// 鐢熸垚鍙�
// 淇鍙�
//
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.0.0.1")]
+[assembly: AssemblyFileVersion("1.0.0.1")]
diff --git a/Plugin.CurrentSensorControl/BurnInOven.xaml b/Plugin.CurrentSensorControl/BurnInOven.xaml
index dfbdb6f..70a9740 100644
--- a/Plugin.CurrentSensorControl/BurnInOven.xaml
+++ b/Plugin.CurrentSensorControl/BurnInOven.xaml
@@ -13,7 +13,7 @@
xmlns:pw="https://opensource.panuon.com/wpf"
xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:dp="clr-namespace:HMI.UI.DpUtil;assembly=HMI.UI"
- d:DesignHeight="450" d:DesignWidth="800">
+ d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Style x:Key="ovenTb" TargetType="TextBox" BasedOn="{StaticResource EditorTextBoxStyle}">
<Setter Property="Height" Value="20"/>
@@ -22,7 +22,7 @@
</Style>
</UserControl.Resources>
- <GroupBox Header="{Binding Header}">
+ <GroupBox Header="{Binding Header}" Background="#FFF" >
<Grid dp:GridHelper.Space="5" dp:GridHelper.SpaceIgnore="ALL">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
diff --git a/Plugin.CurrentSensorControl/BurnInOvenCollection.xaml b/Plugin.CurrentSensorControl/BurnInOvenCollection.xaml
index 7ff27fb..8842c51 100644
--- a/Plugin.CurrentSensorControl/BurnInOvenCollection.xaml
+++ b/Plugin.CurrentSensorControl/BurnInOvenCollection.xaml
@@ -13,7 +13,7 @@
xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:dp="clr-namespace:HMI.UI.DpUtil;assembly=HMI.UI"
d:DesignHeight="450" d:DesignWidth="800">
- <Grid x:Name="mainGrid" dp:GridHelper.Space="6">
+ <Grid x:Name="mainGrid" dp:GridHelper.Space="6" dp:GridHelper.SpaceIgnore="ALL">
</Grid>
</UserControl>
diff --git a/Plugin.CurrentSensorControl/BurnInSettingModal.xaml b/Plugin.CurrentSensorControl/BurnInSettingModal.xaml
index 4c559d0..04af3e2 100644
--- a/Plugin.CurrentSensorControl/BurnInSettingModal.xaml
+++ b/Plugin.CurrentSensorControl/BurnInSettingModal.xaml
@@ -10,6 +10,7 @@
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
Title="Form"
+ InteropOwnersMask ="False"
Width="1200"
Height="900"
WindowStartupLocation="CenterOwner"
diff --git a/Plugin.CurrentSensorControl/BurnInSettingModal.xaml.cs b/Plugin.CurrentSensorControl/BurnInSettingModal.xaml.cs
index 4269ecb..7954cf6 100644
--- a/Plugin.CurrentSensorControl/BurnInSettingModal.xaml.cs
+++ b/Plugin.CurrentSensorControl/BurnInSettingModal.xaml.cs
@@ -101,6 +101,7 @@
private void DoExport()
{
SaveFileDialog sfd = new SaveFileDialog();
+ sfd.Filter = "Excel 鏂囦欢 (*.xls)|*.xls";
if (sfd.ShowDialog() == true)
{
ExcelHelper.ExportExcel(sfd.FileName, Datasource);
@@ -110,6 +111,7 @@
private void DoImport()
{
OpenFileDialog ofd = new OpenFileDialog();
+ ofd.Filter = "Excel 鏂囦欢 (*.xls)|*.xls";
if (ofd.ShowDialog() == true)
{
try
diff --git a/Plugin.CurrentSensorControl/ControlPage.xaml b/Plugin.CurrentSensorControl/ControlPage.xaml
index 102c624..630ef3c 100644
--- a/Plugin.CurrentSensorControl/ControlPage.xaml
+++ b/Plugin.CurrentSensorControl/ControlPage.xaml
@@ -60,13 +60,19 @@
</ControlTemplate>
</TabControl.Template>
<TabItem Header="鑰佸寲璋冭瘯">
- <Grid dp:GridHelper.Space="5" dp:GridHelper.SpaceIgnore="ALL">
+ <Grid dp:GridHelper.Space="5" Background="#f3f9ff">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
- <StackPanel Orientation="Horizontal">
+ <StackPanel Orientation="Horizontal" Height="30" dp:StackPanelHelper.ChildSpace="10" Margin="6,0,6,0">
<Button Style="{StaticResource SettingBtn}" x:Name="burnInSettingBtn" Click="Button_Click"/>
+
+ <pu:Switch CheckedContent="闈欓煶ON" x:Name="lightSw"
+CheckedBackground="Green"
+Background="{StaticResource DangerColor}"
+IsChecked="{Binding PlcMute,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
+Content="闈欓煶OFF"/>
</StackPanel>
<local:BurnInOvenCollection Grid.Row="1" Grid.Column="0" x:Name="ovenCollection"/>
diff --git a/Plugin.CurrentSensorControl/ControlPage.xaml.cs b/Plugin.CurrentSensorControl/ControlPage.xaml.cs
index fb11a44..85d9f42 100644
--- a/Plugin.CurrentSensorControl/ControlPage.xaml.cs
+++ b/Plugin.CurrentSensorControl/ControlPage.xaml.cs
@@ -5,6 +5,7 @@
using HMI.Core.Util;
using HMI.UI.Util;
using HMI.Util;
+using HslCommunication.Profinet.Siemens;
using log4net;
using Microsoft.Win32;
using Plugin.CurrentSensorControl.Entity;
@@ -13,6 +14,7 @@
using System.Timers;
using System.Windows;
using System.Windows.Controls;
+using System.Xml.Linq;
namespace Plugin.CurrentSensorControl
{
@@ -28,10 +30,33 @@
private System.Timers.Timer timer;
private System.Timers.Timer opcTimer;
- private SCADAApi api;
public static ILog Logger { get; private set; }
private volatile bool needRead = false;
+
+ private SiemensS7Net api;
+
+ private bool plcMute = false;
+ public bool PlcMute
+ {
+ get => plcMute;
+ set
+ {
+ try
+ {
+ string name = $"PLC_Mute";
+ if (S7Context.WriteData(api, name, value))
+ {
+ plcMute = value;
+ OnPropertyChanged(nameof(PlcMute));
+ }
+ }
+ catch (Exception ex)
+ {
+
+ }
+ }
+ }
public ControlPage()
{
@@ -46,6 +71,7 @@
opcTimer.Interval = 1000;
S7Context.Init(SystemSetting.Instance.PlcIp, SystemSetting.Instance.PlcPort);
+ api = S7Context.Get($"1");
DataContext = this;
InitializeComponent();
@@ -73,6 +99,19 @@
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
timer.Enabled = false;
+ try
+ {
+ if (S7Context.GetData(api, "PLC_Mute", out object val))
+ {
+ plcMute = (bool)val;
+ OnPropertyChanged("PlcMute");
+ }
+ }
+ catch (Exception ex)
+ {
+
+ }
+
try
{
foreach (var ctl in controls)
@@ -299,7 +338,7 @@
private void DoDelete(SensorData data)
{
- if (MsgBoxHelper2.WarnChoose("鍒犻櫎?") == MessageBoxResult.OK)
+ if (MsgBoxHelper2.WarnChoose("纭畾瑕佸垹闄ゅ悧?") == MessageBoxResult.OK)
{
var index = Datasource.IndexOf(data);
if (index >= 0)
diff --git a/Plugin.TsExecution/SingleControl.xaml b/Plugin.TsExecution/SingleControl.xaml
index de1842d..613494d 100644
--- a/Plugin.TsExecution/SingleControl.xaml
+++ b/Plugin.TsExecution/SingleControl.xaml
@@ -343,9 +343,7 @@
pu:DataGridHelper.ColumnHeaderFontSize="{Binding ActualWidth,
ElementName=control,
Converter={StaticResource fc}, ConverterParameter='11,1093,14'}"
- FontSize="{Binding ActualWidth,
- ElementName=control,
-Converter={StaticResource fc}, ConverterParameter='11,1093,14'}"
+ FontSize="{DynamicResource tableFontSize}"
pu:DataGridHelper.ColumnHeaderPadding="3"
dp:DataGridHelper.ShowRowNumber="True"
VirtualizingPanel.IsContainerVirtualizable="True"
@@ -369,6 +367,8 @@
<Setter Property="Padding" Value="5"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
+
+ <Style TargetType="ScrollBar" BasedOn="{StaticResource ScrollStyle_Mobile}"/>
</DataGrid.Resources>
<DataGrid.Columns>
diff --git a/Plugin.TsExecution/TsExecution.xaml b/Plugin.TsExecution/TsExecution.xaml
index 72fd7e1..ba22f58 100644
--- a/Plugin.TsExecution/TsExecution.xaml
+++ b/Plugin.TsExecution/TsExecution.xaml
@@ -11,12 +11,19 @@
xmlns:dp="clr-namespace:HMI.UI.DpUtil;assembly=HMI.UI"
xmlns:ScottPlot="clr-namespace:ScottPlot.WPF;assembly=ScottPlot.WPF"
mc:Ignorable="d"
- xmlns:ui="clr-namespace:HMI.UI;assembly=HMI.UI"
+ xmlns:sys="clr-namespace:System;assembly=mscorlib"
+ xmlns:ui="clr-namespace:HMI.UI;assembly=HMI.UI"
Padding="10"
Loaded="PluginControl_Loaded"
SizeChanged="PluginControl_SizeChanged"
Background="{StaticResource WorkspaceBackground}"
d:DesignHeight="450" d:DesignWidth="800">
+ <UserControl.Resources>
+ <ResourceDictionary>
+ <sys:Double x:Key="tableFontSize">20</sys:Double>
+ </ResourceDictionary>
+ </UserControl.Resources>
+
<Grid>
<Grid>
<Grid.ColumnDefinitions>
@@ -90,6 +97,12 @@
PreEditing="RequirePassword"
Value="{Binding CurrentWorkorder,Mode=TwoWay}"/>
</StackPanel>
+
+ <StackPanel Orientation="Horizontal" dp:StackPanelHelper.ChildSpace="5">
+ <Label FontSize="20" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Padding="0" Content="瀛椾綋澶у皬"/>
+ <ComboBox Name="CbFontSize" Width="60" ItemsSource="{Binding FontSizeSource}"
+ SelectionChanged="CbFontSize_SelectionChanged"/>
+ </StackPanel>
</StackPanel>
diff --git a/Plugin.TsExecution/TsExecution.xaml.cs b/Plugin.TsExecution/TsExecution.xaml.cs
index 2b498b2..447b893 100644
--- a/Plugin.TsExecution/TsExecution.xaml.cs
+++ b/Plugin.TsExecution/TsExecution.xaml.cs
@@ -122,6 +122,10 @@
}
}
+ public List<double> FontSizeSource { get; set; } = new List<double> {
+ 10,11,12,13,14,15,16,17,18,19,20
+ };
+
private Pie pie;
private string CountIniPath;
private bool IsOptRequirePassword;
@@ -572,6 +576,9 @@
{
pass = Convert.ToInt32(IniFileHelper.ReadIniData("Count", "Pass", "0", CountIniPath));
fail = Convert.ToInt32(IniFileHelper.ReadIniData("Count", "Fail", "0", CountIniPath));
+ var fontSize = Convert.ToDouble(IniFileHelper.ReadIniData("Config", "TableFontSize", "12", CountIniPath));
+ this.Resources["tableFontSize"] = fontSize;
+ CbFontSize.SelectedItem = fontSize;
}
private string csvDir;
@@ -1438,5 +1445,21 @@
{
}
+
+ private void CbFontSize_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ try
+ {
+ if (e.AddedItems != null && e.AddedItems.Count > 0)
+ {
+ var fontSize = (double)e.AddedItems[0];
+ this.Resources["tableFontSize"] = fontSize;
+ IniFileHelper.WriteIniData("Config", "TableFontSize", fontSize.ToString(), CountIniPath);
+ }
+ }
+ catch
+ {
+ }
+ }
}
}
\ No newline at end of file
diff --git a/WPFProject/WPFProject.csproj b/WPFProject/WPFProject.csproj
index 7880d4c..ab7c4b2 100644
--- a/WPFProject/WPFProject.csproj
+++ b/WPFProject/WPFProject.csproj
@@ -570,6 +570,7 @@
move /y "$(TargeDir)ConnectionUtil.dll" $(TargeDir)Libs\ConnectionUtil.dll"
move /y "$(TargeDir)HMI.StdControl.dll" $(TargeDir)Libs\HMI.StdControl.dll"
move /y "$(TargeDir)S7Driver.dll" $(TargeDir)Libs\S7Driver.dll"
+move /y "$(TargeDir)HslCommunication.dll" $(TargeDir)Libs\HslCommunication.dll"
move /y "$(TargeDir)HMI.LogUtil.dll" $(TargeDir)Api\HMI.LogUtil.dll"
move /y "$(TargeDir)HMI.SerialData.Util.dll" $(TargeDir)Api\HMI.SerialData.Util.dll"
--
Gitblit v1.9.1