Browse Source

添加资源,总览页面添加图表,其它逻辑修正

master
sc 2 months ago
parent
commit
4449530bb7
  1. 3
      ConvertMoels/StatexmlConvert.cs
  2. 20
      ERR/ERR2025-08-28.txt
  3. 9
      Properties/Resources.Designer.cs
  4. 3
      Properties/Resources.en-US.resx
  5. 3
      Properties/Resources.resx
  6. 3
      Properties/Resources.zh-CN.resx
  7. 3
      Properties/Resources.zh-TW.resx
  8. 8
      UserClass/AsyncTcpClient.cs
  9. 31
      UserControls/info.xaml
  10. 77
      UserControls/info.xaml.cs
  11. 8
      View/MonitorView.xaml
  12. 52
      View/MonitorView.xaml.cs
  13. 3
      View/Whole.xaml.cs
  14. 46
      ViewModel/MainWindowViewModel.cs

3
ConvertMoels/StatexmlConvert.cs

@ -29,7 +29,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ConvertMoels
else if (i == "800") Staten = "LinkOff";//未连接 else if (i == "800") Staten = "LinkOff";//未连接
else if (i == "801") Staten = "Link";//连接成功 else if (i == "801") Staten = "Link";//连接成功
else if (i == "899") Staten = "LinkOff";//关闭连接 else if (i == "899") Staten = "LinkOff";//关闭连接
else if (i == "True") Staten = "Lock";//锁 else if (i == "True") Staten = "Visible";//
else if (i == "False") Staten = "Collapsed";//
return Staten; return Staten;
} }

20
ERR/ERR2025-08-28.txt

@ -0,0 +1,20 @@
[2025-08-28 17:45:02];[Error] ||
[2025-08-28 17:45:02];[Error source] ||.Net SqlClient Data Provider
[2025-08-28 17:45:02];[Error message] ||在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: Named Pipes Provider, error: 40 - 无法打开到 SQL Server 的连接)
[2025-08-28 17:45:02];[Error area] || 在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
在 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
在 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
在 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
在 System.Data.SqlClient.SqlConnection.Open()
在 SunlightCentralizedControlManagement_SCCM_.ViewModel.ManualDyelotModel..ctor() 位置 C:\Users\Administrator\source\repos\SunlightCentralizedControlManagement(SCCM)\ViewModel\ManualDyelotModel.cs:行号 35

9
Properties/Resources.Designer.cs

@ -60,6 +60,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
} }
} }
/// <summary>
/// 查找类似 Manual/Automatic 的本地化字符串。
/// </summary>
public static string _Auto {
get {
return ResourceManager.GetString("_Auto", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 continue 的本地化字符串。 /// 查找类似 continue 的本地化字符串。
/// </summary> /// </summary>

3
Properties/Resources.en-US.resx

@ -1077,4 +1077,7 @@
<data name="DispenseException" xml:space="preserve"> <data name="DispenseException" xml:space="preserve">
<value>Dispense Exception</value> <value>Dispense Exception</value>
</data> </data>
<data name="_Auto" xml:space="preserve">
<value>Manual/Automatic</value>
</data>
</root> </root>

3
Properties/Resources.resx

@ -1077,4 +1077,7 @@
<data name="DispenseException" xml:space="preserve"> <data name="DispenseException" xml:space="preserve">
<value>DispenseException</value> <value>DispenseException</value>
</data> </data>
<data name="_Auto" xml:space="preserve">
<value>Manual/Automatic</value>
</data>
</root> </root>

3
Properties/Resources.zh-CN.resx

@ -1077,4 +1077,7 @@
<data name="DispenseException" xml:space="preserve"> <data name="DispenseException" xml:space="preserve">
<value>输送异常</value> <value>输送异常</value>
</data> </data>
<data name="_Auto" xml:space="preserve">
<value>手/自动</value>
</data>
</root> </root>

3
Properties/Resources.zh-TW.resx

@ -1077,4 +1077,7 @@
<data name="DispenseException" xml:space="preserve"> <data name="DispenseException" xml:space="preserve">
<value>輸送異常</value> <value>輸送異常</value>
</data> </data>
<data name="_Auto" xml:space="preserve">
<value />
</data>
</root> </root>

8
UserClass/AsyncTcpClient.cs

@ -388,7 +388,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
.SetRemoteIPHost(ip + ":" + port) .SetRemoteIPHost(ip + ":" + port)
.ConfigurePlugins(a => .ConfigurePlugins(a =>
{ {
// a.UseTcpReconnection();//触发型重连 //触发型重连
// a.UseTcpReconnection();
//使用Polling轮询连接插件
a.UseTcpReconnection()
.UsePolling(TimeSpan.FromSeconds(5));
}) })
.ConfigureContainer(a => .ConfigureContainer(a =>
{ {
@ -396,7 +400,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
})); }));
// Result result = await // Result result = await
_ = tcpClient.TryConnectAsync(); await tcpClient.TryConnectAsync();
// return result.IsSuccess; // return result.IsSuccess;
/* try /* try
{ {

31
UserControls/info.xaml

@ -5,20 +5,25 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.UserControls" xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.UserControls"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties" xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
mc:Ignorable="d" mc:Ignorable="d"
Loaded="UserControl_Loaded"
d:DesignHeight="400" d:DesignWidth="300" Background="White"> d:DesignHeight="400" d:DesignWidth="300" Background="White">
<Grid> <Grid Background="#FFBFBFBF">
<TextBlock x:Name="name" VerticalAlignment="Top" Height="50" Background="#FF646464" Text="-----" FontWeight="Bold" FontSize="36" /> <TextBlock x:Name="name" VerticalAlignment="Top" Height="50" Background="#FF646464" Text="-----" FontWeight="Bold" FontSize="36" />
<TextBlock x:Name="temp" VerticalAlignment="Top" Height="50" Text="---.-°C" FontWeight="Bold" FontSize="36" HorizontalAlignment="Right" Padding="5,0,5,0"/> <TextBlock x:Name="temp" VerticalAlignment="Top" Height="50" Text="---.-°C" FontWeight="Bold" FontSize="36" HorizontalAlignment="Right" Padding="5,0,5,0"/>
<TextBlock Text="{x:Static lang:Resources.process}" Height="30" FontWeight="Bold" FontSize="24" Margin="5,50,5,0" VerticalAlignment="Top" Focusable="False"/> <Grid Margin="2,50,2,2" Background="White">
<TextBlock Text="{x:Static lang:Resources.Step}" Height="30" FontWeight="Bold" FontSize="24" Margin="5,100,5,0" VerticalAlignment="Top" Focusable="False"/> <TextBlock Text="{x:Static lang:Resources.process}" Height="30" FontWeight="Bold" FontSize="24" Margin="5,0,5,0" VerticalAlignment="Top" Focusable="False"/>
<TextBlock Text="{x:Static lang:Resources.message}" Height="30" FontWeight="Bold" FontSize="24" Margin="5,150,5,0" VerticalAlignment="Top" Focusable="False"/> <TextBlock Text="{x:Static lang:Resources.Step}" Height="30" FontWeight="Bold" FontSize="24" Margin="5,50,5,0" VerticalAlignment="Top" Focusable="False"/>
<TextBlock Text="{x:Static lang:Resources.orders}" Height="30" FontWeight="Bold" FontSize="24" Margin="5,200,5,0" VerticalAlignment="Top" Focusable="False"/> <TextBlock Text="{x:Static lang:Resources.message}" Height="30" FontWeight="Bold" FontSize="24" Margin="5,100,5,0" VerticalAlignment="Top" Focusable="False"/>
<TextBlock x:Name="time" Text="----------------------------" Height="30" FontWeight="Bold" FontSize="24" Margin="5,250,5,0" VerticalAlignment="Top" Focusable="False"/> <TextBlock Text="{x:Static lang:Resources.orders}" Height="30" FontWeight="Bold" FontSize="24" Margin="5,150,5,0" VerticalAlignment="Top" Focusable="False"/>
<local:RoilingTextBlock Foreground="Black" x:Name="Process" Text="NO Information" FontSize="21" Height="30" Margin="120,50,0,0" VerticalAlignment="Top"/> <TextBlock x:Name="time" Text="----------------------------" Height="30" FontWeight="Bold" FontSize="24" Margin="5,180,5,0" VerticalAlignment="Top" Focusable="False"/>
<local:RoilingTextBlock Foreground="Black" x:Name="Step" Text="NO Information" FontSize="21" Height="30" Margin="120,100,0,0" VerticalAlignment="Top"/> <local:RoilingTextBlock Foreground="Black" x:Name="Process" Text="NO Information" FontSize="21" Height="30" Margin="120,0,0,0" VerticalAlignment="Top"/>
<local:RoilingTextBlock Foreground="Black" x:Name="Message" Text="NO Information" FontSize="21" Height="30" Margin="120,150,0,0" VerticalAlignment="Top"/> <local:RoilingTextBlock Foreground="Black" x:Name="Step" Text="NO Information" FontSize="21" Height="30" Margin="120,50,0,0" VerticalAlignment="Top"/>
<local:RoilingTextBlock Foreground="Black" x:Name="Orders" Text="NO Information" FontSize="21" Height="30" Margin="120,200,0,0" VerticalAlignment="Top"/> <local:RoilingTextBlock Foreground="Black" x:Name="Message" Text="NO Information" FontSize="21" Height="30" Margin="120,100,0,0" VerticalAlignment="Top"/>
<StackPanel x:Name="log" Margin="0,300,0,0"/> <local:RoilingTextBlock Foreground="Black" x:Name="Orders" Text="NO Information" FontSize="21" Height="30" Margin="120,150,0,0" VerticalAlignment="Top"/>
<lvc:CartesianChart x:Name="OscChart" Margin="0,200 ,0,0" EasingFunction="{x:Null}" ZoomMode="PanX"
Series="{Binding Series}" YAxes="{Binding YAxes}" XAxes="{Binding XAxes}"/>
</Grid>
</Grid> </Grid>
</UserControl> </UserControl>

77
UserControls/info.xaml.cs

@ -1,8 +1,18 @@
using ScottPlot.Plottables; using LiveChartsCore;
using LiveChartsCore.Defaults;
using LiveChartsCore.Kernel.Sketches;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.Painting;
using Newtonsoft.Json.Linq;
using ScottPlot.Plottables;
using SkiaSharp;
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Runtime.Serialization;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
@ -28,10 +38,75 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserControls
public info() public info()
{ {
InitializeComponent(); InitializeComponent();
DataContext = this; //new infoModel();
}
public void DataAdd()
{
} }
private readonly Random _random = new Random();
private readonly List<DateTimePoint> _values = new List<DateTimePoint>();
private readonly DateTimeAxis _customAxis;
public ObservableCollection<ISeries> Series { get; set; }
public static ObservableCollection<ObservableValue> ObservableValues { get; set; }
//x轴时间格式
public Axis[] XAxes { get; set; } =
{
new DateTimeAxis(TimeSpan.FromSeconds(5) , date => date.ToString("HH:mm"))
{
MinLimit = DateTime.Now.AddHours(-6).Ticks,
MaxLimit = DateTime.Now.AddHours(0.5).Ticks,
CrosshairLabelsBackground = SKColors.DarkGray.AsLvcColor(),
CrosshairLabelsPaint = new SolidColorPaint(SKColors.DarkSlateBlue, 1),
CrosshairPaint = new SolidColorPaint(SKColors.DarkSlateGray, 1),
},
};
//颜色
private static readonly SKColor s_blue = new SKColor(25, 118, 210);
private static readonly SKColor s_red = new SKColor(229, 57, 53);
public ICartesianAxis[] YAxes { get; set; } ={
new Axis //y在此轴上缩放
{
MinLimit =0,
MaxLimit =160,
NamePadding = new LiveChartsCore.Drawing.Padding(0, 20),
Padding = new LiveChartsCore.Drawing.Padding(0, 0, 20, 0),
TextSize = 12,
LabelsPaint = new SolidColorPaint(s_blue),
TicksPaint = new SolidColorPaint(s_blue),
SubticksPaint = new SolidColorPaint(s_blue),
DrawTicksPath = true,
CrosshairSnapEnabled = true,
Position = LiveChartsCore.Measure.AxisPosition.Start
},//温度轴
};
private static ObservableCollection<DateTimePoint> MTH_values;
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
var MTH_items = new List<DateTimePoint>();
MTH_values = new ObservableCollection<DateTimePoint>(MTH_items);
Series = new ObservableCollection<ISeries>
{
new LineSeries<DateTimePoint>
{
Name = Properties.Resources.Temperature,
Values = MTH_values,
Stroke = new SolidColorPaint(s_red, 2),
GeometrySize = 0,
GeometryStroke = new SolidColorPaint(s_red, 2),
Fill = null,
LineSmoothness = 0,
ScalesYAt = 2,
}
};
}
} }
} }

8
View/MonitorView.xaml

@ -19,6 +19,7 @@
<ConvertMoels:StatenToImageConvert x:Key="StatenToImageConvert"/> <ConvertMoels:StatenToImageConvert x:Key="StatenToImageConvert"/>
<ContextMenu x:Key="PersoncontextMenu"> <ContextMenu x:Key="PersoncontextMenu">
<MenuItem Header="{x:Static lang:Resources._lock}" Click="MenuItem_LOCK_XML"/> <MenuItem Header="{x:Static lang:Resources._lock}" Click="MenuItem_LOCK_XML"/>
<MenuItem Header="{x:Static lang:Resources._Auto}" Click="MenuItem_AUTO_XML"/>
</ContextMenu> </ContextMenu>
<ContextMenu x:Key="PersoncontextMenuStep"> <ContextMenu x:Key="PersoncontextMenuStep">
<MenuItem Header="{x:Static lang:Resources.edit}" Click="MenuItem_edit"/> <MenuItem Header="{x:Static lang:Resources.edit}" Click="MenuItem_edit"/>
@ -112,8 +113,11 @@
<materialDesign:PackIcon Width="25" Height="30" <materialDesign:PackIcon Width="25" Height="30"
Kind="{Binding Path=State,Converter={StaticResource StatexmlConvert}}" Kind="{Binding Path=State,Converter={StaticResource StatexmlConvert}}"
Foreground="{Binding Path=State,Converter={StaticResource StateToColorConvert}}"/> Foreground="{Binding Path=State,Converter={StaticResource StateToColorConvert}}"/>
<materialDesign:PackIcon Width="25" Height="30" <materialDesign:PackIcon Width="25" Height="30" Kind="Lock"
Kind="{Binding Path=LOCK,Converter={StaticResource StatexmlConvert}}" Visibility="{Binding Path=LOCK,Converter={StaticResource StatexmlConvert}}"
Foreground="{Binding Path=State,Converter={StaticResource StateToColorConvert}}"/>
<materialDesign:PackIcon Width="25" Height="30" Kind="HandBackRight"
Visibility="{Binding Path=AUTO,Converter={StaticResource StatexmlConvert}}"
Foreground="{Binding Path=State,Converter={StaticResource StateToColorConvert}}"/> Foreground="{Binding Path=State,Converter={StaticResource StateToColorConvert}}"/>
</StackPanel> </StackPanel>
</Grid> </Grid>

52
View/MonitorView.xaml.cs

@ -227,19 +227,21 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
}//单据 }//单据
private void MenuItem_LOCK_XML(object sender, RoutedEventArgs e) private void MenuItem_LOCK_XML(object sender, RoutedEventArgs e)
{ {
string mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<string>("LOCK"); bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("LOCK");
Dictionary<string, object> dat_821 = new Dictionary<string, object>(); Dictionary<string, object> dat_ = new Dictionary<string, object>();
dat_821.Clear(); dat_.Clear();
if (mode != "True") if (!mode)
{ {
dat_821.Add("LOCK", "True"); dat_.Add("NAME", "LOCK");
dat_.Add("VALUE", "True");
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "True"); MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "True");
} }
else else
{ {
dat_821.Add("LOCK", "FALSE"); dat_.Add("NAME", "LOCK");
dat_.Add("VALUE", "False");
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "False"); MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "False");
} }
@ -248,14 +250,43 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_.ToJsonString()
}); });
if (mode != "True") { MessageBox.Show(machine + Properties.Resources.user_lock, "800", MessageBoxButton.OK, MessageBoxImage.Information); if (!mode) { MessageBox.Show(machine + Properties.Resources.user_lock, "800", MessageBoxButton.OK, MessageBoxImage.Information);
} else { } else {
MessageBox.Show(machine + Properties.Resources.user_unlock, "800", MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show(machine + Properties.Resources.user_unlock, "800", MessageBoxButton.OK, MessageBoxImage.Information);
} }
}//锁定 }//锁定
private void MenuItem_AUTO_XML(object sender, RoutedEventArgs e)
{
bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("AUTO");
Dictionary<string, object> dat_ = new Dictionary<string, object>();
dat_.Clear();
if (!mode)
{
dat_.Add("NAME", "AUTO");
dat_.Add("VALUE", "True");
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "AUTO", "Name='" + machine + "'", "True");
}
else
{
dat_.Add("NAME", "AUTO");
dat_.Add("VALUE", "FALSE");
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "AUTO", "Name='" + machine + "'", "False");
}
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{
ID = index,
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_.ToJsonString()
});
}//手自动
private void ListViewItem_Curve(object sender, MouseButtonEventArgs e) private void ListViewItem_Curve(object sender, MouseButtonEventArgs e)
{ {
log.Visibility = Visibility.Collapsed; log.Visibility = Visibility.Collapsed;
@ -658,7 +689,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
public string Step { get; set; } public string Step { get; set; }
public string Message { get; set; } public string Message { get; set; }
public string State { get; set; } public string State { get; set; }
public string LOCK { get; set; } public bool LOCK { get; set; }
public bool AUTO { get; set; }
} }
public class TechnologicalP public class TechnologicalP

3
View/Whole.xaml.cs

@ -105,10 +105,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
else if (State_ == "201") else if (State_ == "201")
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(0, 255, 0)); } { inf[i].name.Background = new SolidColorBrush(Color.FromRgb(0, 255, 0)); }
else if (State_ == "202") else if (State_ == "202")
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(255, 255, 0)); } { inf[i].name.Background = new SolidColorBrush(Color.FromRgb(0, 255, 0)); }
else else
{ inf[i].name.Background = new SolidColorBrush(Color.FromRgb(255, 0, 0)); } { inf[i].name.Background = new SolidColorBrush(Color.FromRgb(255, 0, 0)); }
inf[i].temp.Text = Selet_Machines(MainWindowViewModel.Machines, "Temperature", i).ToString() + "°C"; inf[i].temp.Text = Selet_Machines(MainWindowViewModel.Machines, "Temperature", i).ToString() + "°C";
inf[i].Process.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "Process", i); inf[i].Process.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "Process", i);
inf[i].Step.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "Step", i); inf[i].Step.Text = (string)Selet_Machines(MainWindowViewModel.Machines, "Step", i);

46
ViewModel/MainWindowViewModel.cs

@ -258,18 +258,18 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
DAT = "SC830" + Selet_Machines(Machines, "SYSKEY", "ID='" + i + "'").ToString() DAT = "SC830" + Selet_Machines(Machines, "SYSKEY", "ID='" + i + "'").ToString()
});//信息插入队列 });//信息插入队列
string mode = Machines.Select("ID='" + i + "'").First().Field<string>("LOCK");//发送锁定状态 bool mode = Machines.Select("ID='" + i + "'").First().Field<bool>("LOCK");//发送锁定状态
if (mode == "True") if (mode)
{ {
Dictionary<string, object> dat_821 = new Dictionary<string, object>(); Dictionary<string, object> dat_829 = new Dictionary<string, object>();
dat_821.Clear(); dat_829.Clear();
dat_821.Add("LOCK", "True"); dat_829.Add("LOCK", "True");
DataRow drEmployee = Machines.Select("ID='" + i + "'").First(); DataRow drEmployee = Machines.Select("ID='" + i + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
stringQueue.Enqueue(new QueueString stringQueue.Enqueue(new QueueString
{ {
ID = index, ID = index,
DAT = "SC829" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() DAT = "SC829" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dat_829.ToJsonString()
}); });
} }
@ -315,7 +315,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
else { Time5++; } else { Time5++; }
if (Time60 > 60) if (Time60 > 60)
{ {
Tick_Event_60S(); // Tick_Event_60S();
Time60 = 0; Time60 = 0;
} }
else { Time60++; } else { Time60++; }
@ -607,7 +607,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
} }
} }
void Tick_Event_60S() async void Tick_Event_60S()
{ {
for (int i = 0; i < Machinesdata_Count; i++) for (int i = 0; i < Machinesdata_Count; i++)
{ {
@ -615,7 +615,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
{ {
MachiensTcpClient[i] = new TcpClient(); MachiensTcpClient[i] = new TcpClient();
DataRow dt = machinesdata[i]; DataRow dt = machinesdata[i];
_ = AsyncTcpClient.TcpClient(MachiensTcpClient[i] //建立tcp连接 await AsyncTcpClient.TcpClient(MachiensTcpClient[i] //建立tcp连接
, Selet_Machines(Machines, "IP", "ID='" + Convert.ToInt16(dt["ID"]) + "'" ).ToString() , Selet_Machines(Machines, "IP", "ID='" + Convert.ToInt16(dt["ID"]) + "'" ).ToString()
, Selet_Machines(Machines, "PORT", "ID='" + Convert.ToInt16(dt["ID"]) + "'").ToString()); , Selet_Machines(Machines, "PORT", "ID='" + Convert.ToInt16(dt["ID"]) + "'").ToString());
} }
@ -631,19 +631,23 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
machinesdata = Machines.Select("PORT>0 AND IP<>''", "id asc");//获取连接有效的组 machinesdata = Machines.Select("PORT>0 AND IP<>''", "id asc");//获取连接有效的组
Machinesdata_Count = machinesdata.Count(); Machinesdata_Count = machinesdata.Count();
for (int i = 0; i < Machinesdata_Count; i++) foreach (DataRow dataRow in Machines.Rows)
{ {
MachiensTcpClient[i] = new TcpClient(); dataRow.BeginEdit();
DataRow dt = machinesdata[i]; dataRow["State"] = 800;
Updata_Machines(Machines, "State", "ID='" + Convert.ToInt16(dt["ID"]) + "'", "800"); dataRow["Temperature"] = 0;
Updata_Machines(Machines, "Temperature", "ID='" + Convert.ToInt16(dt["ID"]) + "'", "0.0"); dataRow["WaterLevel"] = 0;
Updata_Machines(Machines, "WaterLevel", "ID='" + Convert.ToInt16(dt["ID"]) + "'", "0"); dataRow["WORK_RUN"] = -1;
Updata_Machines(Machines, "WORK_RUN", "ID='" + Convert.ToInt16(dt["ID"]) + "'", "-1"); dataRow["ERR"] = false;
Updata_Machines(Machines, "ERR", "ID='" + Convert.ToInt16(dt["ID"]) + "'", "False"); dataRow["LOCK"] = false;
Updata_Machines(Machines, "UserInfoStart", "ID='" + Convert.ToInt16(dt["ID"]) + "'", "900"); dataRow["AUTO"] = false;
_ = AsyncTcpClient.TcpClient(MachiensTcpClient[i] //建立tcp连接 dataRow["UserInfoStart"] = 900;
, Selet_Machines(Machines, "IP", "ID='" + Convert.ToInt16(dt["ID"]) + "'").ToString() dataRow.EndEdit();
, Selet_Machines(Machines, "PORT", "ID='" + Convert.ToInt16(dt["ID"]) + "'").ToString()); dataRow.AcceptChanges();
MachiensTcpClient[Convert.ToInt16(dataRow["ID"])]= new TcpClient();
_ = AsyncTcpClient.TcpClient(MachiensTcpClient[Convert.ToInt16(dataRow["ID"])] //建立tcp连接
, dataRow["IP"].ToString(), dataRow["PORT"].ToString());
} }
} }

Loading…
Cancel
Save