Compare commits

..
62 Commits
Author SHA1 Message Date
sc eb2828aab0 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2026-01-04 23:26:01 +08:00
sc 33b970eff9 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2026-01-04 23:26:00 +08:00
sc 5caf92be59 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2026-01-04 23:24:46 +08:00
sc 437b8957ce Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2026-01-04 23:24:44 +08:00
sc a68fb9ae01 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-27 22:10:41 +08:00
sc 68b98ac7e4 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-27 22:10:39 +08:00
sc 2329ac9abc Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-26 01:35:33 +08:00
sc b062420be1 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-26 01:35:30 +08:00
sc a248c41163 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-25 20:18:34 +08:00
sc 2b676adbba 修正错误 2025-10-25 20:18:31 +08:00
sc 00a5cd3ec7 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-15 22:14:27 +08:00
sc abfcf6e36a Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-15 22:14:26 +08:00
sc 1df7212414 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-15 20:49:37 +08:00
sc 751a2b092f Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-15 20:49:34 +08:00
sc 8a5e0ecfd9 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-15 00:09:05 +08:00
sc ebcd5b7182 串口通讯部分修改 2025-10-15 00:09:03 +08:00
sc 7f905617fa Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-10 02:02:24 +08:00
sc 54d8cc7266 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-10 02:02:21 +08:00
sc 33e83fa5d6 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-10 00:56:15 +08:00
sc 927c38853d 添加485串口线路指令 2025-10-10 00:56:14 +08:00
sc 552d45485d Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-08 23:35:40 +08:00
sc 17a5d6b718 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-08 23:35:38 +08:00
sc 34d3e6c292 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-08 23:19:40 +08:00
sc 5b60ea4765 添加数据库 2025-10-08 23:19:39 +08:00
sc b2817d1b01 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-08 23:18:50 +08:00
sc 7403914ba5 串口功能逻辑,810,811,812指令修改 2025-10-08 23:18:48 +08:00
sc 878d49c4a0 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-08 00:04:22 +08:00
sc e457b0ab21 添加去重逻辑 2025-10-08 00:04:20 +08:00
sc b0ce5bc8f9 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-07 19:52:43 +08:00
sc d3375fd6ac 处理lock (Machines.Rows.SyncRoot)并发写datatable问题 2025-10-07 19:52:42 +08:00
sc 7671f0ef08 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-07 00:24:31 +08:00
sc 25e6ae1563 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-07 00:24:29 +08:00
sc e020333b82 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-07 00:03:53 +08:00
sc 8914ea3660 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-07 00:03:51 +08:00
sc c1da97611d Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-06 22:06:10 +08:00
sc daaa2b5514 添加资源,修改机台设置页面,添加任务开始页面,修改网络连接错误 2025-10-06 22:06:08 +08:00
sc 2c40ac5be0 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-06 00:52:17 +08:00
sc 21500886f0 修复引用添加822指令 2025-10-06 00:52:16 +08:00
sc c5e1978f6a Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-05 21:21:05 +08:00
sc 9a374a0a87 添加 2025-10-05 21:21:04 +08:00
sc f9949c5ec5 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-05 21:05:12 +08:00
sc 91212f03d2 添加资源 2025-10-05 21:05:08 +08:00
sc 31a84a640d Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-05 00:26:27 +08:00
sc 9bdf575674 添加资源 2025-10-05 00:26:26 +08:00
sc 8adea70012 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-03 22:50:28 +08:00
sc 3f9730507e Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-03 22:50:19 +08:00
sc 7fad98f58b Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-02 23:40:29 +08:00
sc 61dbaa3c33 设备连线逻辑修改 2025-10-02 23:40:21 +08:00
sc 5e063092cf Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-01 17:04:54 +08:00
sc 574f468a5e 工艺排程与工艺传输问题错误修正 2025-10-01 17:04:52 +08:00
sc e9f83ea182 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-09-30 21:23:53 +08:00
sc ab5dfa85e1 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-09-30 21:23:45 +08:00
sc 8512e720dd Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-09-30 20:06:39 +08:00
sc 81ab1623ba Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-09-30 20:06:33 +08:00
sc 6cbed8fa62 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-09-30 00:54:04 +08:00
sc 60baf3554a Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-09-30 00:53:59 +08:00
sc 1ef9b8517c Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-09-30 00:47:24 +08:00
sc d5042d92ff Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-09-30 00:47:20 +08:00
sc 4a1c5b7eac Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-09-29 01:05:07 +08:00
sc 896c2bdf9c 数据库 2025-09-29 01:05:03 +08:00
sc 99217977ec Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-09-29 01:02:35 +08:00
sc 8d0b37f0e2 日志显示,修改缓冲区 2025-09-29 01:02:28 +08:00
34 changed files with 3047 additions and 1268 deletions

No files matched your search

BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
[SYS]
Language=zh-CN
DyelotsDispenser=True
COMP1=COM7
COMP2=COM8
COMP3=COM9
COMP4=COM10
BAUD1 = 57600
BAUD2= 57600
BAUD3 =57600
BAUD4 =57600
[SQL_SERVER]
SQL1=www.scserverddns.top\EXPRESS ,21344
SQL2=BatchDyeingCentral
SQL3=SQL SERVER
SQL4=sa
SQL5=SC971216@server
[SN]
SN3=5BEE2D9CF3E1A8DD
SN2=BED2E58B6EBB4BD4
SN1=5BEE2D9CF3E1A8DD
[VOICE]
V1=-2
V2=100
+5 -3
View File
@@ -1,4 +1,5 @@
using SunlightCentralizedControlManagement_SCCM_.ViewModel; using SunlightCentralizedControlManagement_SCCM_.UserClass;
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using System; using System;
using System.Data; using System.Data;
using System.Data.SqlClient; using System.Data.SqlClient;
@@ -82,9 +83,10 @@ namespace SunlightCentralizedControlManagement_SCCM_
} }
} }
} }
catch (Exception) catch (Exception ex)
{ {
System.Windows.MessageBox.Show(Properties.Resources.NPERR, "SCCM", MessageBoxButton.OK, MessageBoxImage.Error); LogGing.ERRDATA(ex);
System.Windows.MessageBox.Show("Unable to start. Check the log for details.", "SCCM", MessageBoxButton.OK, MessageBoxImage.Error);
} }
} }
+18
View File
@@ -32,7 +32,9 @@ namespace SunlightCentralizedControlManagement_SCCM_
{ {
public static string user_; public static string user_;
public static DataTable InfData = new DataTable(); public static DataTable InfData = new DataTable();
// public static string[] Inf_string ;
public UserInformation userInformation; public UserInformation userInformation;
// public UserInf userInf;
public MainWindow() public MainWindow()
{ {
@@ -74,6 +76,22 @@ namespace SunlightCentralizedControlManagement_SCCM_
if (userInformation.WindowState == WindowState.Minimized) userInformation.WindowState = WindowState.Normal; if (userInformation.WindowState == WindowState.Minimized) userInformation.WindowState = WindowState.Normal;
} }
} }
/* private void UserInfTable(string dat)//触发行改变事件
{
userInf.Inf_DAT = dat;
if (userInf == null || !userInf.IsLoaded)//窗口不存在及创建
{
userInf = new UserInf();
userInf.Topmost = true;
userInf.Show();
userInf.Activate();
}
else
{//窗口纯在及置顶
userInf.Activate();
if (userInf.WindowState == WindowState.Minimized) userInf.WindowState = WindowState.Normal;
}
}*/
private void ButtonPopUpLogout_Click(object sender, RoutedEventArgs e) private void ButtonPopUpLogout_Click(object sender, RoutedEventArgs e)
{ {
+28 -1
View File
@@ -19,7 +19,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。 // (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources { public class Resources {
@@ -1284,6 +1284,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
} }
} }
/// <summary>
/// 查找类似 Machines 的本地化字符串。
/// </summary>
public static string Machines {
get {
return ResourceManager.GetString("Machines", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Malfunction 的本地化字符串。 /// 查找类似 Malfunction 的本地化字符串。
/// </summary> /// </summary>
@@ -2004,6 +2013,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
} }
} }
/// <summary>
/// 查找类似 ProgramName 的本地化字符串。
/// </summary>
public static string ProgramName {
get {
return ResourceManager.GetString("ProgramName", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 ProportionalValves 的本地化字符串。 /// 查找类似 ProportionalValves 的本地化字符串。
/// </summary> /// </summary>
@@ -2400,6 +2418,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
} }
} }
/// <summary>
/// 查找类似 Start 的本地化字符串。
/// </summary>
public static string Start {
get {
return ResourceManager.GetString("Start", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 StartDate 的本地化字符串。 /// 查找类似 StartDate 的本地化字符串。
/// </summary> /// </summary>
+9
View File
@@ -1083,4 +1083,13 @@
<data name="Swing" xml:space="preserve"> <data name="Swing" xml:space="preserve">
<value>Swing</value> <value>Swing</value>
</data> </data>
<data name="Start" xml:space="preserve">
<value>Start</value>
</data>
<data name="ProgramName" xml:space="preserve">
<value>Program Name</value>
</data>
<data name="Machines" xml:space="preserve">
<value>Machines</value>
</data>
</root> </root>
+9
View File
@@ -1083,4 +1083,13 @@
<data name="Swing" xml:space="preserve"> <data name="Swing" xml:space="preserve">
<value>Swing</value> <value>Swing</value>
</data> </data>
<data name="Start" xml:space="preserve">
<value>Start</value>
</data>
<data name="ProgramName" xml:space="preserve">
<value>ProgramName</value>
</data>
<data name="Machines" xml:space="preserve">
<value>Machines</value>
</data>
</root> </root>
+9
View File
@@ -1083,4 +1083,13 @@
<data name="Swing" xml:space="preserve"> <data name="Swing" xml:space="preserve">
<value>摆布</value> <value>摆布</value>
</data> </data>
<data name="Start" xml:space="preserve">
<value>开始</value>
</data>
<data name="ProgramName" xml:space="preserve">
<value>工艺名</value>
</data>
<data name="Machines" xml:space="preserve">
<value>机台</value>
</data>
</root> </root>
+9 -4
View File
@@ -1080,11 +1080,16 @@
<data name="_Auto" xml:space="preserve"> <data name="_Auto" xml:space="preserve">
<value>手/自動</value> <value>手/自動</value>
</data> </data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Swing" type="System.Resources.ResXNullRef, System.Windows.Forms">
<value />
</data>
<data name="Swing" xml:space="preserve"> <data name="Swing" xml:space="preserve">
<value>擺佈</value> <value>擺佈</value>
</data> </data>
<data name="Start" xml:space="preserve">
<value>開始</value>
</data>
<data name="ProgramName" xml:space="preserve">
<value>工藝名</value>
</data>
<data name="Machines" xml:space="preserve">
<value>機器</value>
</data>
</root> </root>
@@ -77,6 +77,9 @@
<Prefer32Bit>true</Prefer32Bit> <Prefer32Bit>true</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="SkiaSharp">
<HintPath>bin\Debug\SkiaSharp.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
@@ -132,6 +135,7 @@
<Compile Include="UserClass\CSV.cs" /> <Compile Include="UserClass\CSV.cs" />
<Compile Include="UserClass\DataGridHelper.cs" /> <Compile Include="UserClass\DataGridHelper.cs" />
<Compile Include="UserClass\DataTableForToObservableCollection.cs" /> <Compile Include="UserClass\DataTableForToObservableCollection.cs" />
<Compile Include="UserClass\DataTableManager .cs" />
<Compile Include="UserClass\get_local_ip_address.cs" /> <Compile Include="UserClass\get_local_ip_address.cs" />
<Compile Include="UserClass\HardwareSN.cs" /> <Compile Include="UserClass\HardwareSN.cs" />
<Compile Include="UserClass\IniFile.cs" /> <Compile Include="UserClass\IniFile.cs" />
@@ -150,6 +154,12 @@
<Compile Include="UserControls\DispenseMacInfo.xaml.cs"> <Compile Include="UserControls\DispenseMacInfo.xaml.cs">
<DependentUpon>DispenseMacInfo.xaml</DependentUpon> <DependentUpon>DispenseMacInfo.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="WindowsView\UserWorkOrder.xaml.cs">
<DependentUpon>UserWorkOrder.xaml</DependentUpon>
</Compile>
<Compile Include="WindowsView\UserInf.xaml.cs">
<DependentUpon>UserInf.xaml</DependentUpon>
</Compile>
<Compile Include="WindowsView\UserInformation.xaml.cs"> <Compile Include="WindowsView\UserInformation.xaml.cs">
<DependentUpon>UserInformation.xaml</DependentUpon> <DependentUpon>UserInformation.xaml</DependentUpon>
</Compile> </Compile>
@@ -289,6 +299,14 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="WindowsView\UserWorkOrder.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="WindowsView\UserInf.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="WindowsView\UserInformation.xaml"> <Page Include="WindowsView\UserInformation.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -525,6 +543,11 @@
<Content Include="Fonts\font-awesome-4.7.0\css\font-awesome.css" /> <Content Include="Fonts\font-awesome-4.7.0\css\font-awesome.css" />
<Content Include="Fonts\font-awesome-4.7.0\css\font-awesome.min.css" /> <Content Include="Fonts\font-awesome-4.7.0\css\font-awesome.min.css" />
<Content Include="Fonts\font-awesome-4.7.0\fonts\fontawesome-webfont.svg" /> <Content Include="Fonts\font-awesome-4.7.0\fonts\fontawesome-webfont.svg" />
<Resource Include="lmage\IconParkExtend.png" />
<Resource Include="lmage\IconParkExtendR.png" />
<Resource Include="lmage\IconParkExtendY.png" />
<Resource Include="lmage\IconParkInfo.png" />
<Resource Include="lmage\IconParkUsbOne.png" />
<Resource Include="lmage\00.png" /> <Resource Include="lmage\00.png" />
<Resource Include="lmage\1000-1.png" /> <Resource Include="lmage\1000-1.png" />
<Resource Include="lmage\1000-2.png" /> <Resource Include="lmage\1000-2.png" />
+111 -47
View File
@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
@@ -59,30 +60,33 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
portclient.Closed = (client, e) => { return EasyTask.CompletedTask; };//从端口断开连接,当连接不成功时不会触发。 portclient.Closed = (client, e) => { return EasyTask.CompletedTask; };//从端口断开连接,当连接不成功时不会触发。
portclient.Received = (client, e) => portclient.Received = (client, e) =>
{ {
//接受重置事件状态
_responseEvent.Set(); _responseEvent.Set();
string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8), string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8),
@"\n", RegexOptions.IgnoreCase); @"\n", RegexOptions.IgnoreCase);
for (int i = 0; i < sArray.Length; i++) for (int i = 0; i < sArray.Length; i++)
{ {
if (sArray[i].Length>5) if (sArray[i].Length > 5)
{ {
return EasyTask.CompletedTask; ;
string SYSAPI = sArray[i].Substring(0, 5); string SYSAPI = sArray[i].Substring(0, 5);
string Station = ClipBetween(sArray[i], '[', ']'); string Station = ClipBetween(sArray[i], '[', ']');
string DAT = sArray[i].Substring(sArray[i].IndexOf("]") + 1); string DAT = sArray[i].Substring(sArray[i].IndexOf("]") + 1);
if (SYSAPI == "SC800") if (SYSAPI == "SC800")
{ {
try try
{ {
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数 Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化 _new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" + lock (MainWindowViewModel.Machines.Rows.SyncRoot)
Station + "' AND Serial = 'PORT1'").First(); {
drEmployee.BeginEdit(); DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" + Station + "' AND Serial = 'PORT1'").First();
drEmployee["State"] = "802"; drEmployee.BeginEdit();
drEmployee.EndEdit(); drEmployee["State"] = "802";
drEmployee.AcceptChanges(); drEmployee.EndEdit();
drEmployee.AcceptChanges();
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -93,32 +97,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
Dictionary<string, object> _dat;
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } }, MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } },
"WorkOrder ='" + DAT + "'", null); "WorkOrder ='" + _dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "'", null);
} }
catch (Exception ex) catch (Exception ex)
{ {
LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++;
} }
} }//回复的工单记录状态后就位111
else if (SYSAPI == "SC811") else if (SYSAPI == "SC811")
{ {
try try
{ {
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 113 } }, DAT = DAT.Substring(DAT.IndexOf("]") + 1);
"WorkOrder ='" + DAT + "'", null); Dictionary<string, object> _dat;
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
MainWindowViewModel.SQLiteHelpers.Update("WorkorderSteps", new Dictionary<string, object> { { "Mode", 1 } },
"WorkOrder ='" + _dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "' AND Step ='" +
_dat.GetValue("Step") + "'", null);
int x = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from WorkorderSteps where WorkOrder='" +
_dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "' AND Mode <> '1'", null).Tables[0].Rows.Count;
if (x == 0)
{
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 113 } },
"WorkOrder ='" + _dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "'", null);
}
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
} }//回复的工单明细状态后就位113
else if (SYSAPI == "SC812") else if (SYSAPI == "SC812")
{ {
try try
{ {
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
Dictionary<string, object> _dat;
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 101 } }, MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 101 } },
"WorkOrder ='" + DAT + "'", null); "WorkOrder ='" + _dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "'", null);
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
} }//回复的工单设置状态后就位101
else if (SYSAPI == "SC827") else if (SYSAPI == "SC827")
{ {
try try
@@ -132,33 +154,37 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数 Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化 _new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" + string mac;
Station + "' AND Serial = 'PORT1'").First(); lock (MainWindowViewModel.Machines.Rows.SyncRoot)
drEmployee.BeginEdit(); {
drEmployee["ERR"] = _new.GetValue("ERR"); DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" + Station + "' AND Serial = 'PORT1'").First();
drEmployee["LOCK"] = _new.GetValue("LOCK"); mac = drEmployee["Name"].ToString();
drEmployee["Message"] = _new.GetValue("Status"); drEmployee.BeginEdit();
drEmployee["WorkOrder"] = _new.GetValue("WorkNumder"); drEmployee["ERR"] = _new.GetValue("ERR");
drEmployee["Temperature"] = _new.GetValue("MTT"); drEmployee["LOCK"] = _new.GetValue("LOCK");
drEmployee["WaterLevel"] = _new.GetValue("MTL"); drEmployee["Message"] = _new.GetValue("Status");
drEmployee["Process"] = _new.GetValue("Process"); drEmployee["WorkOrder"] = _new.GetValue("Work");
drEmployee["Step"] = _new.GetValue("Step"); drEmployee["Temperature"] = _new.GetValue("MTT");
drEmployee["UserButton"] = _new.GetValue("UserButton"); drEmployee["WaterLevel"] = _new.GetValue("MTL");
if (_new.GetValue("UserInfoStart").ToString() != "900") drEmployee["Process"] = _new.GetValue("Process");
{ drEmployee["UserInfoStart"] = _new.GetValue("UserInfoStart"); } drEmployee["Step"] = _new.GetValue("Step");
drEmployee["UserInfo"] = _new.GetValue("UserInfo"); drEmployee["UserButton"] = _new.GetValue("UserB");
drEmployee["WORK_RUN"] = _new.GetValue("WORK_RUN"); if (_new.GetValue("InfoS").ToString() != "900")
drEmployee["RUN_STEPID"] = _new.GetValue("RUN_STEPID"); { drEmployee["UserInfoStart"] = _new.GetValue("InfoS"); }
drEmployee["CALL"] = _new.GetValue("CALL"); drEmployee["UserInfo"] = _new.GetValue("Info");
drEmployee.EndEdit(); drEmployee["WORK_RUN"] = _new.GetValue("RUN");
drEmployee.AcceptChanges(); drEmployee["RUN_STEPID"] = _new.GetValue("STEPID");
drEmployee["CALL"] = _new.GetValue("CALL");
drEmployee.EndEdit();
drEmployee.AcceptChanges();
}
if (_new.GetValue("Status").ToString() != "----------") if (_new.GetValue("Status").ToString() != "----------")
{ {
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数 Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
Chart_new.Add("WorkOrder", _new.GetValue("WorkNumder")); Chart_new.Add("WorkOrder", _new.GetValue("Work"));
Chart_new.Add("Machine", _new.GetValue("Machine")); //Chart_new.Add("Machine", mac);
Chart_new.Add("Time", _new.GetValue("Time")); //Chart_new.Add("Time", _new.GetValue("Time"));
Chart_new.Add("MST", _new.GetValue("MST")); Chart_new.Add("MST", _new.GetValue("MST"));
Chart_new.Add("MTT", _new.GetValue("MTT")); Chart_new.Add("MTT", _new.GetValue("MTT"));
Chart_new.Add("MTL", _new.GetValue("MTL")); Chart_new.Add("MTL", _new.GetValue("MTL"));
@@ -174,7 +200,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
MainWindowViewModel.SQLiteChartAdress.InsertData("Chart", Chart_new);// 执行插入 MainWindowViewModel.SQLiteChartAdress.InsertData("Chart", Chart_new);// 执行插入
} }
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex)
{
LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++;
}
}//当前信息 }//当前信息
else if (SYSAPI == "SC831") else if (SYSAPI == "SC831")
{ {
@@ -236,6 +265,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
}//系统设置表 }//系统设置表
else if (SYSAPI == "SC859")
{
try
{
}
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
}//信息
else if (SYSAPI == "SC910") else if (SYSAPI == "SC910")
{ {
try try
@@ -262,6 +299,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
return EasyTask.CompletedTask; ; return EasyTask.CompletedTask; ;
}; };
await portclient.SetupAsync(new TouchSocketConfig() await portclient.SetupAsync(new TouchSocketConfig()
.SetMaxBufferSize(1024 * 1024 * 10)
.SetSerialPortOption(new SerialPortOption() .SetSerialPortOption(new SerialPortOption()
{ {
BaudRate = BAUD,//波特率 BaudRate = BAUD,//波特率
@@ -274,7 +312,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
.ConfigurePlugins(a => .ConfigurePlugins(a =>
{ {
//a.Add<MyPlugin>(); //a.Add<MyPlugin>();
})); }
));
try try
{ {
await portclient.ConnectAsync(); await portclient.ConnectAsync();
@@ -368,8 +407,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8), string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8),
@"\n", RegexOptions.IgnoreCase); @"\n", RegexOptions.IgnoreCase);
return EasyTask.CompletedTask; ; return EasyTask.CompletedTask; ;
}; };
await portclient.SetupAsync(new TouchSocketConfig() await portclient.SetupAsync(new TouchSocketConfig()
@@ -381,7 +418,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
PortName = com,//COM PortName = com,//COM
StopBits = System.IO.Ports.StopBits.One,//停止位 StopBits = System.IO.Ports.StopBits.One,//停止位
}) })
.SetSerialDataHandlingAdapter(() => new PeriodPackageAdapter() { CacheTimeout = TimeSpan.FromMilliseconds(100) }) .SetSerialDataHandlingAdapter(() => new PeriodPackageAdapter() { CacheTimeout = TimeSpan.FromMilliseconds(500) })
.ConfigurePlugins(a => .ConfigurePlugins(a =>
{ {
//a.Add<MyPlugin>(); //a.Add<MyPlugin>();
@@ -406,12 +443,39 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
var t = CRCcheck16.ToCRC16(command);
_responseEvent.Reset(); _responseEvent.Reset();
serialPortClients.Send(command); // 发送指令 serialPortClients.Send(command); // 发送指令
// 等待500毫秒或直到收到响应
_responseEvent.Wait(TimeSpan.FromMilliseconds(1000)); // 等待500毫秒或直到收到响应
// 重置事件状态 if (!_responseEvent.Wait(TimeSpan.FromMilliseconds(1000)))
_responseEvent.Set(); {
_responseEvent.Set();
//清楚了解状态
string Station = ClipBetween(command, '[', ']');
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" +
Station + "' AND Serial = 'PORT1'").First();
if (drEmployee.Field<int>("State") != 800)
{
drEmployee.BeginEdit();
drEmployee["State"] = "800";
drEmployee["WorkOrder"] = "------";
drEmployee["Dyelot"] = "";
drEmployee["Temperature"] = 0.0;
drEmployee["WaterLevel"] = 0.0;
drEmployee["Process"] = "";
drEmployee["Step"] = "";
drEmployee["Message"] = "";
drEmployee["SYSKEY"] = "";
drEmployee["WORK_RUN"] = "-1";
drEmployee["ERR"] = false;
drEmployee.EndEdit();
drEmployee.AcceptChanges();
}
}
}
} }
catch (Exception) { } catch (Exception) { }
} }
+171 -119
View File
@@ -6,6 +6,7 @@ using ScottPlot.Colormaps;
using SkiaSharp; using SkiaSharp;
using SunlightCentralizedControlManagement_SCCM_.View; using SunlightCentralizedControlManagement_SCCM_.View;
using SunlightCentralizedControlManagement_SCCM_.ViewModel; using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@@ -22,10 +23,11 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Documents;
using System.Xml.Linq; using System.Xml.Linq;
using TouchSocket.Core; using TouchSocket.Core;
using TouchSocket.Sockets;
using TouchSocket.SerialPorts; using TouchSocket.SerialPorts;
using TouchSocket.Sockets;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper; using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
using static SunlightCentralizedControlManagement_SCCM_.View.MachinesView; using static SunlightCentralizedControlManagement_SCCM_.View.MachinesView;
using static System.Windows.Forms.AxHost; using static System.Windows.Forms.AxHost;
@@ -47,12 +49,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); lock (MainWindowViewModel.Machines.Rows.SyncRoot)
drEmployee.BeginEdit(); {
drEmployee["State"] = "801"; DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
drEmployee.EndEdit(); drEmployee.BeginEdit();
drEmployee.AcceptChanges(); drEmployee["State"] = "801";
drEmployee.EndEdit();
drEmployee.AcceptChanges();
}
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_OK"); LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_OK");
} }
catch (Exception ex) catch (Exception ex)
@@ -66,21 +70,24 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); lock (MainWindowViewModel.Machines.Rows.SyncRoot)
drEmployee.BeginEdit(); {
drEmployee["State"] = "800"; DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
drEmployee["WorkOrder"] = "------"; drEmployee.BeginEdit();
drEmployee["Dyelot"] = ""; drEmployee["State"] = "800";
drEmployee["Temperature"] = 0.0; drEmployee["WorkOrder"] = "------";
drEmployee["WaterLevel"] = "----"; drEmployee["Dyelot"] = "";
drEmployee["Process"] = ""; drEmployee["Temperature"] = 0.0;
drEmployee["Step"] = ""; drEmployee["WaterLevel"] = 0.0;
drEmployee["Message"] = ""; drEmployee["Process"] = "";
drEmployee["SYSKEY"] = ""; drEmployee["Step"] = "";
drEmployee["WORK_RUN"] = "-1"; drEmployee["Message"] = "";
drEmployee["ERR"] = false; drEmployee["SYSKEY"] = "";
drEmployee.EndEdit(); drEmployee["WORK_RUN"] = "-1";
drEmployee.AcceptChanges(); drEmployee["ERR"] = false;
drEmployee.EndEdit();
drEmployee.AcceptChanges();
}
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_STOP"); LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_STOP");
} }
catch (Exception ex) catch (Exception ex)
@@ -93,21 +100,24 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); lock (MainWindowViewModel.Machines.Rows.SyncRoot)
drEmployee.BeginEdit(); {
drEmployee["State"] = "800"; DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
drEmployee["WorkOrder"] = "------"; drEmployee.BeginEdit();
drEmployee["Dyelot"] = ""; drEmployee["State"] = "800";
drEmployee["Temperature"] = 0.0; drEmployee["WorkOrder"] = "------";
drEmployee["WaterLevel"] = "----"; drEmployee["Dyelot"] = "";
drEmployee["Process"] = ""; drEmployee["Temperature"] = 0.0;
drEmployee["Step"] = ""; drEmployee["WaterLevel"] = 0.0;
drEmployee["Message"] = ""; drEmployee["Process"] = "";
drEmployee["SYSKEY"] = ""; drEmployee["Step"] = "";
drEmployee["WORK_RUN"] = "-1"; drEmployee["Message"] = "";
drEmployee["ERR"] = false; drEmployee["SYSKEY"] = "";
drEmployee.EndEdit(); drEmployee["WORK_RUN"] = "-1";
drEmployee.AcceptChanges(); drEmployee["ERR"] = false;
drEmployee.EndEdit();
drEmployee.AcceptChanges();
}
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_INTERRUPT"); LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_INTERRUPT");
} }
catch (Exception ex) catch (Exception ex)
@@ -128,14 +138,17 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
DAT = DAT.Substring(DAT.IndexOf("]") + 1); DAT = DAT.Substring(DAT.IndexOf("]") + 1);
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数 Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
Chart_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化 Chart_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); lock (MainWindowViewModel.Machines.Rows.SyncRoot)
drEmployee.BeginEdit(); {
drEmployee["SYSKEY"] = Chart_new.GetValue("SYSKEY").ToString(); DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
// drEmployee["NAME"] = Chart_new.GetValue("MACHINE").ToString(); drEmployee.BeginEdit();
drEmployee["Groups"] = Chart_new.GetValue("GROUP").ToString(); drEmployee["SYSKEY"] = Chart_new.GetValue("SYSKEY").ToString();
drEmployee["State"] = "802"; // drEmployee["NAME"] = Chart_new.GetValue("MACHINE").ToString();
drEmployee.EndEdit(); drEmployee["Groups"] = Chart_new.GetValue("GROUP").ToString();
drEmployee.AcceptChanges(); drEmployee["State"] = "802";
drEmployee.EndEdit();
drEmployee.AcceptChanges();
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -146,9 +159,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
DAT = DAT.Substring(DAT.IndexOf("]") + 1); DAT = DAT.Substring(DAT.IndexOf("]") + 1);
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } }, MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } },
"WorkOrder ='" + DAT + "'", null); "WorkOrder ='" + DAT + "'", null);
// Dictionary<string, object> _dat;
// _dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
// MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } },
// "WorkOrder ='" + _dat.GetValue("WorkOrder") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "'", null);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -160,8 +178,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
try try
{ {
DAT = DAT.Substring(DAT.IndexOf("]") + 1); DAT = DAT.Substring(DAT.IndexOf("]") + 1);
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 113 } },
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } },
"WorkOrder ='" + DAT + "'", null); "WorkOrder ='" + DAT + "'", null);
// Dictionary<string, object> _dat;
// _dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
// MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 113 } },
// "WorkOrder ='" + _dat.GetValue("WorkOrder") + "' AND ReDye ='"+ _dat.GetValue("ReDye") + "'", null);
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
} }
@@ -175,6 +198,33 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
} }
else if (SYSAPI == "SC822")
{
try
{
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
DataTable dataTable = JsonConvert.DeserializeObject<DataTable>(DAT).Copy();//反序列化
Application.Current.Dispatcher.Invoke(() =>
{
UserWorkOrder userWorkOrder = new UserWorkOrder();
userWorkOrder.WorkOrderTable = dataTable;
userWorkOrder.Show();
});
}
catch (Exception)
{
Application.Current.Dispatcher.Invoke(() =>
{
UserInf userInf = new UserInf();
userInf.Inf_DAT = "没有等待中的工艺";
userInf.Show();
userInf.Activate();
});
// LogGing.LogGingDATA("[ERR='" + ex + "']=Exception");
MainWindowViewModel.ERR_c++;
}
}
else if (SYSAPI == "SC827") else if (SYSAPI == "SC827")
{ {
try try
@@ -184,38 +234,41 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
foreach (DataRow sourceRow in dataTable.Rows) foreach (DataRow sourceRow in dataTable.Rows)
{ {
// 创建新行(基于目标表结构) lock (MainWindowViewModel.Dyelot_CALL.Rows.SyncRoot)
DataRow newRow = MainWindowViewModel.Dyelot_CALL.NewRow();
// 复制源表中存在的列数据
foreach (DataColumn column in dataTable.Columns)
{ {
if (MainWindowViewModel.Dyelot_CALL.Columns.Contains(column.ColumnName)) // 创建新行(基于目标表结构)
DataRow newRow = MainWindowViewModel.Dyelot_CALL.NewRow();
// 复制源表中存在的列数据
foreach (DataColumn column in dataTable.Columns)
{ {
newRow[column.ColumnName] = sourceRow[column.ColumnName]; if (MainWindowViewModel.Dyelot_CALL.Columns.Contains(column.ColumnName))
{
newRow[column.ColumnName] = sourceRow[column.ColumnName];
}
} }
MainWindowViewModel.Dyelot_CALL.Rows.Add(newRow);
Dictionary<string, object> Product_ = new Dictionary<string, object>();//缓存函数
Product_.Add("State", 202);
Product_.Add("Dyelot", newRow.Field<string>("Dyelot"));
Product_.Add("Step", newRow.Field<int>("Step"));
Product_.Add("ProductCode", newRow.Field<string>("ProductCode"));
Product_.Add("Amount", newRow.Field<object>("Amount"));
Product_.Add("DispenseEndTime", newRow.Field<object>("DispenseEndTime"));
newRow.BeginEdit();
newRow["State"] = 202;
newRow.EndEdit();
MainWindowViewModel.SQLiteHelpers.InsertData("DyelotHistory", MainWindowViewModel.SQLiteHelpers.ToDictionary(newRow));// 执行插入
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{
ID = Convert.ToInt16(MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines,
"ID", "Name='" + newRow.Field<string>("Machine") + "'")),
DAT = "SC828" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines,
"SYSKEY", "Name='" + newRow.Field<string>("Machine") + "'") + Product_.ToJsonString()
});
} }
MainWindowViewModel.Dyelot_CALL.Rows.Add(newRow);
Dictionary<string, object> Product_ = new Dictionary<string, object>();//缓存函数
Product_.Add("State", 202);
Product_.Add("Dyelot", newRow.Field<string>("Dyelot"));
Product_.Add("Step", newRow.Field<int>("Step"));
Product_.Add("ProductCode", newRow.Field<string>("ProductCode"));
Product_.Add("Amount", newRow.Field<object>("Amount"));
Product_.Add("DispenseEndTime", newRow.Field<object>("DispenseEndTime"));
newRow.BeginEdit();
newRow["State"] = 202;
newRow.EndEdit();
MainWindowViewModel.SQLiteHelpers.InsertData("DyelotHistory", MainWindowViewModel.SQLiteHelpers.ToDictionary(newRow));// 执行插入
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{
ID = Convert.ToInt16(MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines,
"ID", "Name='" + newRow.Field<string>("Machine") + "'")),
DAT = "SC828" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines,
"SYSKEY", "Name='" + newRow.Field<string>("Machine") + "'") + Product_.ToJsonString()
});
} }
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
@@ -227,32 +280,37 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
DAT = DAT.Substring(DAT.IndexOf("]") + 1); DAT = DAT.Substring(DAT.IndexOf("]") + 1);
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数 Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化 _new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); string mac;
drEmployee.BeginEdit(); // 首先确保 DataTable 使用线程安全的访问方式
drEmployee["ERR"] = _new.GetValue("ERR"); lock (MainWindowViewModel.Machines.Rows.SyncRoot)
drEmployee["LOCK"] = _new.GetValue("LOCK"); {
drEmployee["Message"] = _new.GetValue("Status"); DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
drEmployee["WorkOrder"] = _new.GetValue("WorkNumder"); mac = drEmployee["Name"].ToString();
drEmployee["Temperature"] = _new.GetValue("MTT"); drEmployee.BeginEdit();
drEmployee["WaterLevel"] = _new.GetValue("MTL"); drEmployee["ERR"] = _new.GetValue("ERR");
drEmployee["Process"] = _new.GetValue("Process"); drEmployee["LOCK"] = _new.GetValue("LOCK");
drEmployee["Step"] = _new.GetValue("Step"); drEmployee["Message"] = _new.GetValue("Status");
drEmployee["UserButton"] = _new.GetValue("UserButton"); drEmployee["WorkOrder"] = _new.GetValue("WorkNumder");
if (_new.GetValue("UserInfoStart").ToString() != "900") drEmployee["Temperature"] = _new.GetValue("MTT");
{ drEmployee["UserInfoStart"] = _new.GetValue("UserInfoStart"); } drEmployee["WaterLevel"] = _new.GetValue("MTL");
drEmployee["UserInfo"] = _new.GetValue("UserInfo"); drEmployee["Process"] = _new.GetValue("Process");
drEmployee["WORK_RUN"] = _new.GetValue("WORK_RUN"); drEmployee["Step"] = _new.GetValue("Step");
drEmployee["RUN_STEPID"] = _new.GetValue("RUN_STEPID"); drEmployee["UserButton"] = _new.GetValue("UserButton");
drEmployee["CALL"] = _new.GetValue("CALL"); if (_new.GetValue("UserInfoStart").ToString() != "900")
drEmployee.EndEdit(); { drEmployee["UserInfoStart"] = _new.GetValue("UserInfoStart"); }
drEmployee.AcceptChanges(); drEmployee["UserInfo"] = _new.GetValue("UserInfo");
drEmployee["WORK_RUN"] = _new.GetValue("WORK_RUN");
drEmployee["RUN_STEPID"] = _new.GetValue("RUN_STEPID");
drEmployee["CALL"] = _new.GetValue("CALL");
drEmployee.EndEdit();
drEmployee.AcceptChanges();
}
if (_new.GetValue("Status").ToString() != "----------") if (_new.GetValue("Status").ToString() != "----------")
{ {
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数 Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
Chart_new.Add("WorkOrder", _new.GetValue("WorkNumder")); Chart_new.Add("WorkOrder", _new.GetValue("WorkNumder"));
Chart_new.Add("Machine", _new.GetValue("Machine")); Chart_new.Add("Machine", mac);
Chart_new.Add("Time", _new.GetValue("Time")); Chart_new.Add("Time", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
Chart_new.Add("MST", _new.GetValue("MST")); Chart_new.Add("MST", _new.GetValue("MST"));
Chart_new.Add("MTT", _new.GetValue("MTT")); Chart_new.Add("MTT", _new.GetValue("MTT"));
Chart_new.Add("MTL", _new.GetValue("MTL")); Chart_new.Add("MTL", _new.GetValue("MTL"));
@@ -279,7 +337,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
MainWindowViewModel.dt_TP = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化 MainWindowViewModel.dt_TP = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
} }//步骤信息
else if (SYSAPI == "SC832") else if (SYSAPI == "SC832")
{ {
try try
@@ -351,7 +409,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
MachinesView.LOG_dataTable = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化 MachinesView.LOG_dataTable = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
} }//信息
else if (SYSAPI == "SC910") else if (SYSAPI == "SC910")
{ {
try try
@@ -372,6 +430,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
}//细节错误 }//细节错误
else if (SYSAPI == "SC921")
{
try
{
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
}
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
}//错误
else if (SYSAPI == "SC980") else if (SYSAPI == "SC980")
{ {
DAT = DAT.Substring(DAT.IndexOf("]") + 1); DAT = DAT.Substring(DAT.IndexOf("]") + 1);
@@ -383,38 +449,24 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
//载入配置 //载入配置
await tcpClient.SetupAsync(new TouchSocketConfig() await tcpClient.SetupAsync(new TouchSocketConfig()
.SetMaxBufferSize(1024*1024) .SetMaxBufferSize(1024* 1024*100)
.SetMinBufferSize(1024*64) .SetMinBufferSize(1024*1024)
.SetRemoteIPHost(ip + ":" + port) .SetRemoteIPHost(ip + ":" + port)
.ConfigurePlugins(a => .ConfigurePlugins(a =>
{ {
//触发型重连
// a.UseTcpReconnection();
//使用Polling轮询连接插件 //使用Polling轮询连接插件
a.UseTcpReconnection() a.UseTcpReconnection()
.UsePolling(TimeSpan.FromSeconds(5)); .UsePolling(TimeSpan.FromSeconds(5));
}) })
.ConfigureContainer(a => .ConfigureContainer(a =>
{ {
// a.AddConsoleLogger();//添加一个日志注入
}));
// Result result = await }
));
await tcpClient.TryConnectAsync(); await tcpClient.TryConnectAsync();
// return result.IsSuccess;
/* try
{
await tcpClient.ConnectAsync();//调用连接,当连接不成功时,会抛出异常。
return true;
}
catch
{
return false;
}*/
} }
} }
} }
+360
View File
@@ -0,0 +1,360 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{
/// <summary>
/// 线程安全的 DataTable 管理器
/// 提供对 DataTable 的安全并发访问
/// </summary>
public class DataTableManager : IDisposable
{
private DataTable _dataTable;
private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim();
private bool _disposed = false;
#region 构造函数
public DataTableManager()
{
_dataTable = new DataTable();
}
public DataTableManager(DataTable dataTable)
{
_dataTable = dataTable ?? throw new ArgumentNullException(nameof(dataTable));
}
public DataTableManager(string tableName)
{
_dataTable = new DataTable(tableName);
}
#endregion
#region 基本操作
/// <summary>
/// 安全地添加列
/// </summary>
public void AddColumn(string columnName, Type dataType)
{
ExecuteWriteOperation(table =>
{
table.Columns.Add(columnName, dataType);
});
}
/// <summary>
/// 安全地添加行
/// </summary>
public void AddRow(params object[] values)
{
ExecuteWriteOperation(table =>
{
DataRow newRow = table.NewRow();
for (int i = 0; i < Math.Min(values.Length, table.Columns.Count); i++)
{
newRow[i] = values[i] ?? DBNull.Value;
}
table.Rows.Add(newRow);
});
}
/// <summary>
/// 安全地更新单元格值
/// </summary>
public bool UpdateCell(int rowIndex, string columnName, object value)
{
return ExecuteWriteOperation(table =>
{
if (IsValidRowIndex(table, rowIndex) && table.Columns.Contains(columnName))
{
table.Rows[rowIndex][columnName] = value ?? DBNull.Value;
return true;
}
return false;
});
}
/// <summary>
/// 安全地删除行
/// </summary>
public bool DeleteRow(int rowIndex)
{
return ExecuteWriteOperation(table =>
{
if (IsValidRowIndex(table, rowIndex))
{
table.Rows[rowIndex].Delete();
return true;
}
return false;
});
}
#endregion
#region 查询操作
/// <summary>
/// 安全地获取行
/// </summary>
public DataRow GetRow(int rowIndex)
{
return ExecuteReadOperation(table =>
{
return IsValidRowIndex(table, rowIndex) ? table.Rows[rowIndex] : null;
});
}
/// <summary>
/// 安全地查找行(使用筛选条件)
/// </summary>
public DataRow[] FindRows(string filterExpression)
{
return ExecuteReadOperation(table =>
{
try
{
return string.IsNullOrEmpty(filterExpression)
? table.Select()
: table.Select(filterExpression);
}
catch (EvaluateException)
{
return new DataRow[0];
}
});
}
/// <summary>
/// 安全地获取行数
/// </summary>
public int GetRowCount()
{
return ExecuteReadOperation(table => table.Rows.Count);
}
/// <summary>
/// 安全地检查行是否存在
/// </summary>
public bool RowExists(int rowIndex)
{
return ExecuteReadOperation(table => IsValidRowIndex(table, rowIndex));
}
#endregion
#region 批量操作
/// <summary>
/// 安全地批量添加行
/// </summary>
public void BulkAddRows(IEnumerable<object[]> rowsData)
{
ExecuteWriteOperation(table =>
{
foreach (var rowData in rowsData)
{
DataRow newRow = table.NewRow();
for (int i = 0; i < Math.Min(rowData.Length, table.Columns.Count); i++)
{
newRow[i] = rowData[i] ?? DBNull.Value;
}
table.Rows.Add(newRow);
}
});
}
/// <summary>
/// 安全地清空所有数据
/// </summary>
public void Clear()
{
ExecuteWriteOperation(table =>
{
table.Clear();
});
}
#endregion
#region 数据导出
/// <summary>
/// 获取数据快照(线程安全的副本)
/// </summary>
public DataTable GetSnapshot()
{
return ExecuteReadOperation(table =>
{
return table.Copy(); // 创建数据的独立副本
});
}
/// <summary>
/// 获取只读视图
/// </summary>
public DataView GetReadOnlyView()
{
return ExecuteReadOperation(table =>
{
return new DataView(table) { AllowEdit = false };
});
}
/// <summary>
/// 导出到新 DataTable(包含结构)
/// </summary>
public DataTable ExportToDataTable()
{
return ExecuteReadOperation(table =>
{
DataTable exported = table.Clone();
exported.Merge(table, false, MissingSchemaAction.Add);
return exported;
});
}
#endregion
#region 锁操作核心
/// <summary>
/// 执行读取操作(共享锁)
/// </summary>
private T ExecuteReadOperation<T>(Func<DataTable, T> operation)
{
_lock.EnterReadLock();
try
{
return operation(_dataTable);
}
finally
{
_lock.ExitReadLock();
}
}
/// <summary>
/// 执行写入操作(独占锁)
/// </summary>
private void ExecuteWriteOperation(Action<DataTable> operation)
{
_lock.EnterWriteLock();
try
{
operation(_dataTable);
_dataTable.AcceptChanges();
}
finally
{
_lock.ExitWriteLock();
}
}
private T ExecuteWriteOperation<T>(Func<DataTable, T> operation)
{
_lock.EnterWriteLock();
try
{
var result = operation(_dataTable);
_dataTable.AcceptChanges();
return result;
}
finally
{
_lock.ExitWriteLock();
}
}
private bool IsValidRowIndex(DataTable table, int rowIndex)
{
return rowIndex >= 0 && rowIndex < table.Rows.Count;
}
#endregion
#region 高级功能
/// <summary>
/// 带超时的安全操作
/// </summary>
public bool TryUpdateCell(int rowIndex, string columnName, object value, int timeoutMs = 5000)
{
if (_lock.TryEnterWriteLock(timeoutMs))
{
try
{
if (IsValidRowIndex(_dataTable, rowIndex) && _dataTable.Columns.Contains(columnName))
{
_dataTable.Rows[rowIndex][columnName] = value ?? DBNull.Value;
_dataTable.AcceptChanges();
return true;
}
return false;
}
finally
{
_lock.ExitWriteLock();
}
}
return false;
}
/// <summary>
/// 执行事务性操作
/// </summary>
public void ExecuteTransaction(Action<DataTable> transaction)
{
_lock.EnterWriteLock();
try
{
// 开始事务
_dataTable.BeginLoadData();
try
{
transaction(_dataTable);
_dataTable.AcceptChanges();
}
catch
{
_dataTable.RejectChanges();
throw;
}
finally
{
_dataTable.EndLoadData();
}
}
finally
{
_lock.ExitWriteLock();
}
}
#endregion
#region 属性和清理
public string TableName
{
get => ExecuteReadOperation(table => table.TableName);
set => ExecuteWriteOperation(table => table.TableName = value);
}
public DataColumnCollection Columns
{
get => ExecuteReadOperation(table => table.Columns);
}
public void Dispose()
{
if (!_disposed)
{
_lock?.Dispose();
_dataTable?.Dispose();
_disposed = true;
}
GC.SuppressFinalize(this);
}
~DataTableManager()
{
Dispose();
}
#endregion
}
}
+1 -16
View File
@@ -179,24 +179,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
Dictionary<string, object> WorkOrder_DAT = new Dictionary<string, object>();//缓存函数 Dictionary<string, object> WorkOrder_DAT = new Dictionary<string, object>();//缓存函数
for (int x = 0; x < dat.Rows.Count; x++) for (int x = 0; x < dat.Rows.Count; x++)
{ {
WorkOrder_DAT = MainWindowViewModel.SQLiteHelpers.ToDictionary(dat.Rows[x]);
WorkOrder_DAT.Add("WorkOrder", WorkOrder_); WorkOrder_DAT.Add("WorkOrder", WorkOrder_);
WorkOrder_DAT.Add("Dyelot", Dyelot_); WorkOrder_DAT.Add("Dyelot", Dyelot_);
WorkOrder_DAT.Add("ProgramID", dat.Rows[x]["ProgramID"]);
WorkOrder_DAT.Add("Program", dat.Rows[x]["Program"]);
WorkOrder_DAT.Add("Step", dat.Rows[x]["Step"]);
WorkOrder_DAT.Add("StepID", dat.Rows[x]["StepID"]);
WorkOrder_DAT.Add("StepName", dat.Rows[x]["StepName"]);
WorkOrder_DAT.Add("ParameterName", dat.Rows[x]["ParameterName"]);
WorkOrder_DAT.Add("Parameter1", dat.Rows[x]["Parameter1"]);
WorkOrder_DAT.Add("Parameter2", dat.Rows[x]["Parameter2"]);
WorkOrder_DAT.Add("Parameter3", dat.Rows[x]["Parameter3"]);
WorkOrder_DAT.Add("Parameter4", dat.Rows[x]["Parameter4"]);
WorkOrder_DAT.Add("Parameter5", dat.Rows[x]["Parameter5"]);
WorkOrder_DAT.Add("Parameter6", dat.Rows[x]["Parameter6"]);
WorkOrder_DAT.Add("Parameter7", dat.Rows[x]["Parameter7"]);
WorkOrder_DAT.Add("Parameter8", dat.Rows[x]["Parameter8"]);
WorkOrder_DAT.Add("Parameter9", dat.Rows[x]["Parameter9"]);
WorkOrder_DAT.Add("Parameter10", dat.Rows[x]["Parameter10"]);
MainWindowViewModel.SQLiteHelpers.InsertData("WorkorderSteps", WorkOrder_DAT);//行插入 MainWindowViewModel.SQLiteHelpers.InsertData("WorkorderSteps", WorkOrder_DAT);//行插入
WorkOrder_DAT.Clear(); WorkOrder_DAT.Clear();
} }
+1
View File
@@ -65,6 +65,7 @@
<DataGridTextColumn Binding="{Binding Serial}" Width="0" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding Serial}" Width="0" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Station}" Width="0" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding Station}" Width="0" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding ID}" Width="0" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding ID}" Width="0" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Model}" Width="0" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Type}" Width="0" IsReadOnly="True"/> <DataGridTextColumn Binding="{Binding Type}" Width="0" IsReadOnly="True"/>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
+141 -121
View File
@@ -36,15 +36,16 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
// 获取所有可用串口端口,并添加到comboBoxCOM // 获取所有可用串口端口,并添加到comboBoxCOM
// string[] ports = System.IO.Ports.SerialPort.GetPortNames(); // string[] ports = System.IO.Ports.SerialPort.GetPortNames();
string[] ports = { "PORT1", "PORT2", "PORT3", "PORT4" };
comboBoxCOM0.ItemsSource = ports; comboBoxCOM0.ItemsSource = ports;
comboBoxCOM0.Text = Configini.IniReadvalue("SYS", "COM"); comboBoxCOM0.Text = Configini.IniReadvalue("SYS", "COM");
comboBoxMachine.ItemsSource = MainWindowViewModel.Machines.AsEnumerable().Select(rowdata => rowdata.Field<string>("name")).ToList();//转换机台 comboBoxMachine.ItemsSource = MainWindowViewModel.Machines.AsEnumerable().Select(rowdata => rowdata.Field<string>("name")).ToList();//转换机台
string[] type_ = { "828", "838" };
comboBoxtype.ItemsSource = type_; comboBoxtype.ItemsSource = type_;
} }
private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini"); string[] ports = { "PORT1", "PORT2", "PORT3", "PORT4" };
string[] type_ = { "828", "838" };
string link_model = "838" ;
private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini");
//private string SYS_machines = null; //private string SYS_machines = null;
int ID_; int ID_;
private void UserControl_Loaded(object sender, RoutedEventArgs e) private void UserControl_Loaded(object sender, RoutedEventArgs e)
@@ -70,91 +71,107 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
private void Save_Click(object sender, RoutedEventArgs e) private void Save_Click(object sender, RoutedEventArgs e)
{ {
if (string.IsNullOrEmpty(Station.Text)) Station.Text = "255";
if (!string.IsNullOrEmpty(comboBoxMachine.Text)) if (!string.IsNullOrEmpty(comboBoxMachine.Text))
{ {
Dictionary<string, object> Machines_DAT = new Dictionary<string, object>();//缓存函数 Dictionary<string, object> Machines_DAT = new Dictionary<string, object>();//缓存函数
if (MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from Machines where name ='" + comboBoxMachine.Text + "'", null).Tables[0].Rows.Count == 0) if (MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from Machines where name ='" + comboBoxMachine.Text + "'", null).Tables[0].Rows.Count == 0)
{ {
DataRow dat_= MainWindowViewModel.Machines.NewRow(); lock (MainWindowViewModel.Machines.Rows.SyncRoot)
dat_.BeginEdit();
dat_["Name"] = comboBoxMachine.Text;
dat_["Groups"] = TextMachineGroup.Text;
dat_["IP"] = IP.Text;
dat_["PORT"] = PORT.Text;
dat_["Serial"] = comboBoxCOM0.Text;
dat_["Type"] = comboBoxtype.Text;
dat_["Station"] = Station.Text;
dat_["ID"] = 999;
dat_["ERR"] = false;
dat_["AUTO"] = false;
dat_["CALL"] = false;
dat_["LOCK"] = false;
dat_["State"] = 800;
dat_["Temperature"] = 0;
dat_["WaterLevel"] = 0;
dat_["WORK_RUN"] = -1;
dat_["UserInfoStart"] = 900;
if (comboBoxtype.Text == "838")
{ dat_["Desktop"] = true; }
else { dat_["Desktop"] = false; }
dat_.EndEdit();
MainWindowViewModel.Machines.Rows.Add(dat_);
DatSteps(MainWindowViewModel.Machines);
MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);//
for (int x = 0; x < MainWindowViewModel.Machines.Rows.Count; x++)
{ {
Machines_DAT.Add("ID", MainWindowViewModel.Machines.Rows[x]["ID"]); DataRow dat_ = MainWindowViewModel.Machines.NewRow();
Machines_DAT.Add("Name", MainWindowViewModel.Machines.Rows[x]["Name"]); dat_.BeginEdit();
Machines_DAT.Add("IP", MainWindowViewModel.Machines.Rows[x]["IP"]); dat_["Name"] = comboBoxMachine.Text;
Machines_DAT.Add("PORT", MainWindowViewModel.Machines.Rows[x]["PORT"]); dat_["Groups"] = TextMachineGroup.Text;
Machines_DAT.Add("Serial", MainWindowViewModel.Machines.Rows[x]["Serial"]); dat_["IP"] = IP.Text;
Machines_DAT.Add("Station", MainWindowViewModel.Machines.Rows[x]["Station"]); dat_["PORT"] = PORT.Text;
Machines_DAT.Add("Groups", MainWindowViewModel.Machines.Rows[x]["Groups"]); dat_["Serial"] = comboBoxCOM0.Text;
Machines_DAT.Add("Desktop", MainWindowViewModel.Machines.Rows[x]["Desktop"]); dat_["Model"] = comboBoxtype.Text;
Machines_DAT.Add("Dispense", MainWindowViewModel.Machines.Rows[x]["Dispense"]); dat_["Station"] = Station.Text;
Machines_DAT.Add("Type", MainWindowViewModel.Machines.Rows[x]["Type"]); dat_["ID"] = 999;
MainWindowViewModel.SQLiteHelpers.InsertData("Machines", Machines_DAT);//行插入 dat_["ERR"] = false;
Machines_DAT.Clear(); dat_["AUTO"] = false;
dat_["CALL"] = false;
dat_["LOCK"] = false;
dat_["State"] = 800;
dat_["Temperature"] = 0;
dat_["WaterLevel"] = 0;
dat_["WORK_RUN"] = -1;
dat_["UserInfoStart"] = 900;
if (comboBoxtype.Text.Contains(link_model))
{
dat_["Desktop"] = true;
dat_["Type"] = true;
}
else
{
dat_["Desktop"] = false;
dat_["Type"] = false;
}
dat_.EndEdit();
MainWindowViewModel.Machines.Rows.Add(dat_);
DatSteps(MainWindowViewModel.Machines);
MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);//
for (int x = 0; x < MainWindowViewModel.Machines.Rows.Count; x++)
{
Machines_DAT.Add("ID", MainWindowViewModel.Machines.Rows[x]["ID"]);
Machines_DAT.Add("Name", MainWindowViewModel.Machines.Rows[x]["Name"]);
Machines_DAT.Add("IP", MainWindowViewModel.Machines.Rows[x]["IP"]);
Machines_DAT.Add("PORT", MainWindowViewModel.Machines.Rows[x]["PORT"]);
Machines_DAT.Add("Serial", MainWindowViewModel.Machines.Rows[x]["Serial"]);
Machines_DAT.Add("Station", MainWindowViewModel.Machines.Rows[x]["Station"]);
Machines_DAT.Add("Groups", MainWindowViewModel.Machines.Rows[x]["Groups"]);
Machines_DAT.Add("Desktop", MainWindowViewModel.Machines.Rows[x]["Desktop"]);
Machines_DAT.Add("Dispense", MainWindowViewModel.Machines.Rows[x]["Dispense"]);
Machines_DAT.Add("Type", MainWindowViewModel.Machines.Rows[x]["Type"]);
Machines_DAT.Add("Model", MainWindowViewModel.Machines.Rows[x]["Model"]);
MainWindowViewModel.SQLiteHelpers.InsertData("Machines", Machines_DAT);//行插入
Machines_DAT.Clear();
}
} }
} }
else else
{ {
DataRow dr = MainWindowViewModel.Machines.Rows[ID_]; lock (MainWindowViewModel.Machines.Rows.SyncRoot)
dr.BeginEdit();
dr["Name"] = comboBoxMachine.Text;
dr["Groups"] = TextMachineGroup.Text;
dr["IP"] = IP.Text;
dr["PORT"] = PORT.Text;
dr["Serial"] = comboBoxCOM0.Text;
dr["Type"] = comboBoxtype.Text;
dr["Station"] = Station.Text;
dr["ID"] = 999;
dr["ERR"] = false;
dr["AUTO"] = false;
dr["CALL"] = false;
dr["LOCK"] = false;
dr["State"] = 800;
dr["Temperature"] = 0;
dr["WaterLevel"] = 0;
dr["WORK_RUN"] = -1;
dr["UserInfoStart"] = 900;
dr.EndEdit();
MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);//
for (int x = 0; x < MainWindowViewModel.Machines.Rows.Count; x++)
{ {
Machines_DAT.Add("ID", MainWindowViewModel.Machines.Rows[x]["ID"]); DataRow dr = MainWindowViewModel.Machines.Rows[ID_];
Machines_DAT.Add("Name", MainWindowViewModel.Machines.Rows[x]["Name"]); dr.BeginEdit();
Machines_DAT.Add("IP", MainWindowViewModel.Machines.Rows[x]["IP"]); dr["Name"] = comboBoxMachine.Text;
Machines_DAT.Add("PORT", MainWindowViewModel.Machines.Rows[x]["PORT"]); dr["Groups"] = TextMachineGroup.Text;
Machines_DAT.Add("Serial", MainWindowViewModel.Machines.Rows[x]["Serial"]); dr["IP"] = IP.Text;
Machines_DAT.Add("Station", MainWindowViewModel.Machines.Rows[x]["Station"]); dr["PORT"] = PORT.Text;
Machines_DAT.Add("Groups", MainWindowViewModel.Machines.Rows[x]["Groups"]); dr["Serial"] = comboBoxCOM0.Text;
Machines_DAT.Add("Desktop", MainWindowViewModel.Machines.Rows[x]["Desktop"]); dr["Model"] = comboBoxtype.Text;
Machines_DAT.Add("Dispense", MainWindowViewModel.Machines.Rows[x]["Dispense"]); dr["Station"] = Station.Text;
Machines_DAT.Add("Type", MainWindowViewModel.Machines.Rows[x]["Type"]); if (comboBoxtype.Text.Contains(link_model))
Machines_DAT.Add("LOCK", "FALSE"); {
MainWindowViewModel.SQLiteHelpers.InsertData("Machines", Machines_DAT);//行插入 dr["Desktop"] = true;
Machines_DAT.Clear(); dr["Type"] = true;
}
else
{
dr["Desktop"] = false;
dr["Type"] = false;
}
dr.EndEdit();
MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);//
for (int x = 0; x < MainWindowViewModel.Machines.Rows.Count; x++)
{
Machines_DAT.Add("ID", MainWindowViewModel.Machines.Rows[x]["ID"]);
Machines_DAT.Add("Name", MainWindowViewModel.Machines.Rows[x]["Name"]);
Machines_DAT.Add("IP", MainWindowViewModel.Machines.Rows[x]["IP"]);
Machines_DAT.Add("PORT", MainWindowViewModel.Machines.Rows[x]["PORT"]);
Machines_DAT.Add("Serial", MainWindowViewModel.Machines.Rows[x]["Serial"]);
Machines_DAT.Add("Station", MainWindowViewModel.Machines.Rows[x]["Station"]);
Machines_DAT.Add("Groups", MainWindowViewModel.Machines.Rows[x]["Groups"]);
Machines_DAT.Add("Desktop", MainWindowViewModel.Machines.Rows[x]["Desktop"]);
Machines_DAT.Add("Dispense", MainWindowViewModel.Machines.Rows[x]["Dispense"]);
Machines_DAT.Add("Type", MainWindowViewModel.Machines.Rows[x]["Type"]);
Machines_DAT.Add("Model", MainWindowViewModel.Machines.Rows[x]["Model"]);
Machines_DAT.Add("LOCK", "FALSE");
MainWindowViewModel.SQLiteHelpers.InsertData("Machines", Machines_DAT);//行插入
Machines_DAT.Clear();
}
} }
} }
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView; Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
@@ -178,9 +195,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
MessageBoxResult vr = System.Windows.MessageBox.Show(Properties.Resources.Delete + comboBoxMachine.Text, "SCCM", MessageBoxButton.OKCancel, MessageBoxImage.Question); MessageBoxResult vr = System.Windows.MessageBox.Show(Properties.Resources.Delete + comboBoxMachine.Text, "SCCM", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (vr == MessageBoxResult.OK) // 如果是确定,就执行下面代码 if (vr == MessageBoxResult.OK) // 如果是确定,就执行下面代码
{ {
MainWindowViewModel.Machines.Rows.RemoveAt(ID_ - 1); lock (MainWindowViewModel.Machines.Rows.SyncRoot)
DatSteps(MainWindowViewModel.Machines); {
MainWindowViewModel.Machines.Rows.RemoveAt(ID_ - 1);
DatSteps(MainWindowViewModel.Machines);
}
Dictionary<string, object> Machines_DAT = new Dictionary<string, object>();//缓存函数 Dictionary<string, object> Machines_DAT = new Dictionary<string, object>();//缓存函数
MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);// MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);//
@@ -224,45 +243,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
} }
private void Test_Click(object sender, RoutedEventArgs e)//测试按钮 private void Test_Click(object sender, RoutedEventArgs e)//测试按钮
{ {
if (comboBoxtype.Text == "828")
{ if (comboBoxtype.Text.Contains(link_model))
if (!string.IsNullOrEmpty(comboBoxCOM0.Text) && !string.IsNullOrEmpty(Station.Text)) {//网络
{
textlog.Text = "TEST";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 255));
//------------使用ping类------
string host = IP.Text;
Ping p1 = new Ping();
PingReply reply = p1.Send(host); //发送主机名或Ip地址
//StringBuilder sbuilder;
if (reply.Status == IPStatus.Success)
{
try
{
textlog.Text = "Link succeed";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0));
}
catch (Exception)
{
textlog.Text = "Link failed";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 0));
}
}
else
{
textlog.Text = "No links";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0));
}
}
else
{
textlog.Text = "Invalid";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0));
}
}
else if (comboBoxtype.Text == "838")
{
if (!string.IsNullOrEmpty(IP.Text) && !string.IsNullOrEmpty(PORT.Text)) if (!string.IsNullOrEmpty(IP.Text) && !string.IsNullOrEmpty(PORT.Text))
{ {
textlog.Text = "TEST"; textlog.Text = "TEST";
@@ -320,6 +303,43 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
} }
} }
else
{//串口
if (!string.IsNullOrEmpty(comboBoxCOM0.Text) && !string.IsNullOrEmpty(Station.Text))
{
textlog.Text = "TEST";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 255));
//------------使用ping类------
string host = IP.Text;
Ping p1 = new Ping();
PingReply reply = p1.Send(host); //发送主机名或Ip地址
//StringBuilder sbuilder;
if (reply.Status == IPStatus.Success)
{
try
{
textlog.Text = "Link succeed";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0));
}
catch (Exception)
{
textlog.Text = "Link failed";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 0));
}
}
else
{
textlog.Text = "No links";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0));
}
}
else
{
textlog.Text = "Invalid";
textlog.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0));
}
}
} }
} }
} }
+98 -48
View File
@@ -99,7 +99,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
} }
private void ListViewItem_LOG(object sender, MouseButtonEventArgs e) private void ListViewItem_LOG(object sender, MouseButtonEventArgs e)
{ {
if (LOG_ > 3) { LOG_ = 0; } if (LOG_ >= 3) { LOG_ = 0; }
else else
{ LOG_++; } { LOG_++; }
@@ -108,29 +108,33 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
SYS_GRID.Visibility = Visibility.Collapsed; SYS_GRID.Visibility = Visibility.Collapsed;
SET_GRID.Visibility = Visibility.Collapsed; SET_GRID.Visibility = Visibility.Collapsed;
view = 3; view = 3;
LOG_dataTable.Clear();
Dictionary<string, object> dat_859 =new Dictionary<string, object>(); Dictionary<string, object> dat_859 =new Dictionary<string, object>();
if (LOG_ == 0) if (LOG_ == 0)
{ {
MAC_name.Text = machine+ "(SERVER)";
dat_859.Add("INSTRUCTION", "SERVER"); dat_859.Add("INSTRUCTION", "SERVER");
dat_859.Add("TIME_S", DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss")); dat_859.Add("TIME_S", DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss"));
dat_859.Add("TIME_E", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")); dat_859.Add("TIME_E", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
} }
else if (LOG_ == 1) else if (LOG_ == 1)
{ {
MAC_name.Text = machine + "(OperationLog)";
dat_859.Add("INSTRUCTION", "OperationLog"); dat_859.Add("INSTRUCTION", "OperationLog");
dat_859.Add("TIME_S", DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss")); dat_859.Add("TIME_S", DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss"));
dat_859.Add("TIME_E", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")); dat_859.Add("TIME_E", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
} }
else if (LOG_ == 2) else if (LOG_ == 2)
{ {
MAC_name.Text = machine + "(IOLog)";
dat_859.Add("INSTRUCTION", "IOLog"); dat_859.Add("INSTRUCTION", "IOLog");
dat_859.Add("TIME_S", DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss")); dat_859.Add("TIME_S", DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss"));
dat_859.Add("TIME_E", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")); dat_859.Add("TIME_E", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
} }
else else
{ {
MAC_name.Text = machine + "(ERRLog)";
dat_859.Add("INSTRUCTION", "ERRLog"); dat_859.Add("INSTRUCTION", "ERRLog");
dat_859.Add("TIME_S", DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss")); dat_859.Add("TIME_S", DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss"));
dat_859.Add("TIME_E", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")); dat_859.Add("TIME_E", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
@@ -143,12 +147,19 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if ((State_ == 101) || (State_ == 201) || (State_ == 202) || (State_ == 309))//获得细节信息 if ((State_ == 101) || (State_ == 201) || (State_ == 202) || (State_ == 309))//获得细节信息
{ {
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString if (drEmployee.Field<bool>("Type"))//
{ {//网络
ID = index, MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
DAT = "SC859" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") {
+dat_859.ToJsonString() ID = index,
}); DAT = "SC859" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
+ dat_859.ToJsonString()
});
}
else
{//串口
}
} }
} }
} }
@@ -234,11 +245,18 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString if (drEmployee.Field<bool>("Type"))//
{ {//网络
ID = index, MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
DAT = "SC862" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + datagrid_v.ToJsonString() {
});//发送862指令修改系统设置 ID = index,
DAT = "SC862" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + datagrid_v.ToJsonString()
});//发送862指令修改系统设置
}
else
{//串口
}
} }
SysSet_view = true; SysSet_view = true;
} }
@@ -248,7 +266,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
string newValue = (e.EditingElement as TextBox).Text;//获得输入单元格信息 string newValue = (e.EditingElement as TextBox).Text;//获得输入单元格信息
int rownum = SET_Grid.SelectedIndex;//获取鼠标选中行并定义变量 int rownum = SET_Grid.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效 if (rownum != -1)//判断鼠标定位是否有效
{ {
string ID = (SET_Grid.Columns[1].GetCellContent(SET_Grid.Items[rownum]) as TextBlock).Text;//定位第1列, string ID = (SET_Grid.Columns[1].GetCellContent(SET_Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
Dictionary<string, object> datagrid_v = new Dictionary<string, object>();//缓存函数 Dictionary<string, object> datagrid_v = new Dictionary<string, object>();//缓存函数
@@ -257,11 +275,18 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString if (drEmployee.Field<bool>("Type"))//
{ {//网络
ID = index, MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
DAT = "SC861" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") +datagrid_v.ToJsonString() {
});//发送861指令修改程序设置 ID = index,
DAT = "SC861" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + datagrid_v.ToJsonString()
});//发送861指令修改程序设置
}
else
{//串口
}
} }
ParameterSet_view = true; ParameterSet_view = true;
} }
@@ -282,42 +307,67 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
if (!string.IsNullOrEmpty(machine)) if (!string.IsNullOrEmpty(machine))
{ {
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int State_ = Convert.ToInt16(drEmployee.Field<object>("State"));
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); if (drEmployee.Field<bool>("Type"))//
if ((State_ == 101) || (State_ == 201) || (State_ == 202) || (State_ == 309))//获得细节信息 {//网络
{ int State_ = Convert.ToInt16(drEmployee.Field<object>("State"));
if (view == 0) int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if ((State_ == 101) || (State_ == 201) || (State_ == 202) || (State_ == 309))//获得细节信息
{ {
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString if (view == 0)
{ {
ID = index, MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
DAT = "SC851" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") {
}); ID = index,
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString DAT = "SC851" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
});
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{
ID = index,
DAT = "SC852" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
});
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{
ID = index,
DAT = "SC853" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
});
}
else if (view == 1)
{ {
ID = index, MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
DAT = "SC852" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") {
}); ID = index,
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString DAT = "SC854" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
});
}
else if (view == 2)
{ {
ID = index, MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
DAT = "SC853" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") {
}); ID = index,
} else if (view==1) DAT = "SC855" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
{ });
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString }
{
ID = index,
DAT = "SC854" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'")
});
} }
else if (view == 2) }
else
{//串口
int State_ = Convert.ToInt16(drEmployee.Field<object>("State"));
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if ((State_ == 101) || (State_ == 201) || (State_ == 202) || (State_ == 309))//获得细节信息
{ {
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString if (view == 0)
{ {
ID = index,
DAT = "SC855" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") }
}); else if (view == 1)
{
}
else if (view == 2)
{
}
} }
} }
} }
+8 -3
View File
@@ -20,6 +20,8 @@
<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"/> <MenuItem Header="{x:Static lang:Resources._Auto}" Click="MenuItem_AUTO_XML"/>
<MenuItem Header="{x:Static lang:Resources.Stop}" Click="MenuItem_Stop_XML"/>
<MenuItem Header="{x:Static lang:Resources.Start}" Click="MenuItem_Start_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"/>
@@ -35,11 +37,12 @@
<RowDefinition Height="60"/> <RowDefinition Height="60"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<DataGrid Grid.Row="0" Grid.Column="0" x:Name="Griddata" AlternationCount="2" IsReadOnly="True" <DataGrid Grid.Row="0" Grid.Column="0" x:Name="Griddata" AlternationCount="2" IsReadOnly="True"
SelectionChanged="Griddata_SelectionChanged" SelectionChanged="Griddata_SelectionChanged" EnableRowVirtualization="True" EnableColumnVirtualization="True"
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
d:ItemsSource="{d:SampleData ItemCount=999}" AutoGenerateColumns="False" MinColumnWidth="30" d:ItemsSource="{d:SampleData ItemCount=999}" AutoGenerateColumns="False" MinColumnWidth="30"
ItemsSource="{Binding Path=TechnologicalMachine_View,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding Path=TechnologicalMachine_View,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
Background="White" GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Background="White" GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right"
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False" CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="True"
CanUserDeleteRows="False" SelectionMode="Single" FontSize="15" Focusable="True" > CanUserDeleteRows="False" SelectionMode="Single" FontSize="15" Focusable="True" >
<DataGrid.RowStyle > <DataGrid.RowStyle >
<Style TargetType="{x:Type DataGridRow}"> <Style TargetType="{x:Type DataGridRow}">
@@ -171,6 +174,8 @@
<ColumnDefinition MinWidth="1200"/> <ColumnDefinition MinWidth="1200"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<DataGrid Grid.Column="2" x:Name="Gridstep" AlternationCount="2" SelectionChanged="Gridstep_SelectionChanged" <DataGrid Grid.Column="2" x:Name="Gridstep" AlternationCount="2" SelectionChanged="Gridstep_SelectionChanged"
EnableRowVirtualization="True" EnableColumnVirtualization="True"
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
d:ItemsSource="{d:SampleData ItemCount=90}" AutoGenerateColumns="False" MinColumnWidth="30" d:ItemsSource="{d:SampleData ItemCount=90}" AutoGenerateColumns="False" MinColumnWidth="30"
ItemsSource="{Binding Path=TechnologicalProcess_View,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding Path=TechnologicalProcess_View,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" Background="White" HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" Background="White"
@@ -309,10 +314,10 @@
<TextBlock Grid.Column="0" x:Name="machin_LOG" TextWrapping="Wrap" FontSize="27" VerticalAlignment="Top" Height="40" Background="#FF2793FF" Foreground="White" FontWeight="Bold"/> <TextBlock Grid.Column="0" x:Name="machin_LOG" TextWrapping="Wrap" FontSize="27" VerticalAlignment="Top" Height="40" Background="#FF2793FF" Foreground="White" FontWeight="Bold"/>
<Grid Margin="0,40,0,0" Grid.ColumnSpan="2" Grid.Column="0" > <Grid Margin="0,40,0,0" Grid.ColumnSpan="2" Grid.Column="0" >
<rdp:RemoteDesktopWpf x:Name="rdp" Visibility="Collapsed" /> <rdp:RemoteDesktopWpf x:Name="rdp" Visibility="Collapsed" />
<ContentControl x:Name="Picture" Background="White"/>
<ScrollViewer VerticalScrollBarVisibility="Auto" PanningMode="VerticalOnly"> <ScrollViewer VerticalScrollBarVisibility="Auto" PanningMode="VerticalOnly">
<TextBlock x:Name="log" Text="{Binding Sys_machine}" TextWrapping="Wrap" FontSize="25" Background="White"/> <TextBlock x:Name="log" Text="{Binding Sys_machine}" TextWrapping="Wrap" FontSize="25" Background="White"/>
</ScrollViewer> </ScrollViewer>
<ContentControl x:Name="Picture" Background="White"/>
</Grid> </Grid>
<GridSplitter Grid.Row="0" Grid.Column="1" Width="5" HorizontalAlignment="Center" Background="#FF00204E"/> <GridSplitter Grid.Row="0" Grid.Column="1" Width="5" HorizontalAlignment="Center" Background="#FF00204E"/>
</Grid> </Grid>
+673 -130
View File
@@ -1,5 +1,5 @@
using LiveChartsCore.Geo; using LiveChartsCore.Geo;
using SkiaSharp; using SkiaSharp;
using SunlightCentralizedControlManagement_SCCM_.UserClass; using SunlightCentralizedControlManagement_SCCM_.UserClass;
using SunlightCentralizedControlManagement_SCCM_.ViewModel; using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using SunlightCentralizedControlManagement_SCCM_.WindowsView; using SunlightCentralizedControlManagement_SCCM_.WindowsView;
@@ -28,6 +28,8 @@ using System.Xml.Linq;
using TouchSocket.Core; using TouchSocket.Core;
using TouchSocket.Sockets; using TouchSocket.Sockets;
using VncSharpWpf; using VncSharpWpf;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
using static SunlightCentralizedControlManagement_SCCM_.ViewModel.MainWindowViewModel;
using static SunlightCentralizedControlManagement_SCCM_.WindowsView.ViewStep; using static SunlightCentralizedControlManagement_SCCM_.WindowsView.ViewStep;
using static System.Net.WebRequestMethods; using static System.Net.WebRequestMethods;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar; using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
@@ -80,6 +82,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
private void Griddata_SelectionChanged(object sender, SelectionChangedEventArgs e)//设备列表 private void Griddata_SelectionChanged(object sender, SelectionChangedEventArgs e)//设备列表
{ {
if (rdp.IsConnected) rdp.Disconnect();
int rownum = Griddata.SelectedIndex;//获取鼠标选中行并定义变量 int rownum = Griddata.SelectedIndex;//获取鼠标选中行并定义变量
string mac_s = "800"; string mac_s = "800";
if (rownum != -1)//判断鼠标定位是否有效 if (rownum != -1)//判断鼠标定位是否有效
@@ -119,7 +122,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
} }
else else
{ {
MessageBox.Show(Properties.Resources.TMNR, "800", MessageBoxButton.OK, MessageBoxImage.Information); // // MessageBox.Show(Properties.Resources.TMNR, "800", MessageBoxButton.OK, MessageBoxImage.Information); //
} }
} }
@@ -139,8 +142,270 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
} }
} }
private void MenuItem_LOCK_XML(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrEmpty(machine))
{
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{
bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("LOCK");
Dictionary<string, object> dat_ = new Dictionary<string, object>();
dat_.Clear();
if (!mode)
{
dat_.Add("NAME", "LOCK");
dat_.Add("VALUE", "True");
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "True");
}
else
{
dat_.Add("NAME", "LOCK");
dat_.Add("VALUE", "False");
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "False");
}
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("SYSKEY") + dat_.ToJsonString()
});
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
});
}
}
if (!mode)
{
MessageBox.Show(machine + Properties.Resources.user_lock, "800", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
MessageBox.Show(machine + Properties.Resources.user_unlock, "800", MessageBoxButton.OK, MessageBoxImage.Information);
}
}
}
}//锁定
private void MenuItem_AUTO_XML(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrEmpty(machine))
{
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{
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"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("SYSKEY") + dat_.ToJsonString()
});
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
});
}
}
}
}
}//手自动
private void MenuItem_Stop_XML(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrEmpty(machine))
{
Dictionary<string, object> dat_821 = new Dictionary<string, object>();
dat_821.Clear();
dat_821.Add("INSTRUCTION", "STOP");
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
});
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
}
}
}//停止
private void MenuItem_Start_XML(object sender, RoutedEventArgs e)
{
if (!string.IsNullOrEmpty(machine))
{
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{
ID = index,
DAT = "SC822" + drEmployee.Field<string>("SYSKEY")
});
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC822" + drEmployee.Field<string>("Station")
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC822" + drEmployee.Field<string>("Station")
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC822" + drEmployee.Field<string>("Station")
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC822" + drEmployee.Field<string>("Station")
});
}
}
}
}//开始
private void ListViewItem_DyeingMachine(object sender, MouseButtonEventArgs e) private void ListViewItem_DyeingMachine(object sender, MouseButtonEventArgs e)
{ {
if (rdp.IsConnected)rdp.Disconnect();
machines_info = 0; machines_info = 0;
log.Visibility = Visibility.Visible; log.Visibility = Visibility.Visible;
rdp.Visibility = Visibility.Collapsed; rdp.Visibility = Visibility.Collapsed;
@@ -166,7 +431,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
} }
return result; return result;
} }
private async void ListViewItem_Screen(object sender, MouseButtonEventArgs e) private void ListViewItem_Screen(object sender, MouseButtonEventArgs e)
{ {
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
string host = drEmployee.Field<string>("IP"); string host = drEmployee.Field<string>("IP");
@@ -182,27 +447,25 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
log.Visibility = Visibility.Collapsed; log.Visibility = Visibility.Collapsed;
Picture.Visibility = Visibility.Collapsed; Picture.Visibility = Visibility.Collapsed;
rdp.Visibility = Visibility.Visible; rdp.Visibility = Visibility.Visible;
// RemoteDesktopWpf remoteDesktopWpf = new RemoteDesktopWpf(); // RemoteDesktopWpf remoteDesktopWpf = new RemoteDesktopWpf();
// Picture.Content = remoteDesktopWpf; // Picture.Content = remoteDesktopWpf;
if (await PingTest(host)) if (!rdp.IsConnected)
{ {
if (!rdp.IsConnected) try
{ {
try rdp.VncPort = port;
{ rdp.Passwd = password;
rdp.VncPort = port; rdp.Connect(host, true, false);
rdp.Passwd = password;
rdp.Connect(host, true, false);
}
catch (Exception ex)
{
LogGing.ERRDATA(ex);
}
} }
} catch (Exception ex)
{
LogGing.ERRDATA(ex);
}
}
}//远程 }//远程
private void ListViewItem_Receipt(object sender, MouseButtonEventArgs e) private void ListViewItem_Receipt(object sender, MouseButtonEventArgs e)
{ {
if (rdp.IsConnected) rdp.Disconnect();
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
if (!drEmployee.Field<bool>("Dispense")) if (!drEmployee.Field<bool>("Dispense"))
{ {
@@ -211,12 +474,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
} }
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString if (drEmployee.Field<bool>("Type"))
{ {//网络
ID = index, MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
DAT = "SC833" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") {
}); ID = index,
DAT = "SC833" + drEmployee.Field<string>("SYSKEY")
});
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC833" + drEmployee.Field<string>("Station")
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC833" + drEmployee.Field<string>("Station")
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC833" + drEmployee.Field<string>("Station")
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC833" + drEmployee.Field<string>("Station")
});
}
}
machines_info = 2; machines_info = 2;
log.Visibility = Visibility.Collapsed; log.Visibility = Visibility.Collapsed;
rdp.Visibility = Visibility.Collapsed; rdp.Visibility = Visibility.Collapsed;
@@ -225,77 +525,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dyelotView.DyelotDatatable(Product_DAT); dyelotView.DyelotDatatable(Product_DAT);
Picture.Content = dyelotView; Picture.Content = dyelotView;
}//单据 }//单据
private void MenuItem_LOCK_XML(object sender, RoutedEventArgs e)
{
bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("LOCK");
Dictionary<string, object> dat_ = new Dictionary<string, object>();
dat_.Clear();
if (!mode)
{
dat_.Add("NAME", "LOCK");
dat_.Add("VALUE", "True");
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "True");
}
else
{
dat_.Add("NAME", "LOCK");
dat_.Add("VALUE", "False");
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "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()
});
if (!mode) { MessageBox.Show(machine + Properties.Resources.user_lock, "800", MessageBoxButton.OK, MessageBoxImage.Information);
} else {
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)
{ {
if (rdp.IsConnected) rdp.Disconnect();
log.Visibility = Visibility.Collapsed; log.Visibility = Visibility.Collapsed;
rdp.Visibility = Visibility.Collapsed; rdp.Visibility = Visibility.Collapsed;
Picture.Visibility = Visibility.Visible; Picture.Visibility = Visibility.Visible;
Picture.Content = new View.CurveDiagram(true, "", "", "", workOrder); Picture.Content = new View.CurveDiagram(false, machine, DateTime.Now.AddHours(-8).ToString("yyyy/MM/dd HH:mm:ss"), DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), workOrder);
machines_info = 3; machines_info = 3;
}//曲线 }//曲线
private void ListViewItem_Resume(object sender, MouseButtonEventArgs e) private void ListViewItem_Resume(object sender, MouseButtonEventArgs e)
{ {
IsInteractive = false; IsInteractive = false;
@@ -306,11 +544,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dat_821.Add("INSTRUCTION", "CONTINUE"); dat_821.Add("INSTRUCTION", "CONTINUE");
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString if (drEmployee.Field<bool>("Type"))
{ {//网络
ID = index, MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() {
}); ID = index,
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
});
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
} }
Insert.IsHitTestVisible = false; Insert.IsHitTestVisible = false;
edit.IsHitTestVisible = false; edit.IsHitTestVisible = false;
@@ -329,11 +605,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dat_821.Add("INSTRUCTION", "PAUSE"); dat_821.Add("INSTRUCTION", "PAUSE");
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString if (drEmployee.Field<bool>("Type"))
{ {//网络
ID = index, MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() {
}); ID = index,
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
});
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
} }
Insert.IsHitTestVisible = true; Insert.IsHitTestVisible = true;
edit.IsHitTestVisible = true; edit.IsHitTestVisible = true;
@@ -353,11 +667,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dat_821.Add("INSTRUCTION", "STOP"); dat_821.Add("INSTRUCTION", "STOP");
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString if (drEmployee.Field<bool>("Type"))
{ {//网络
ID = index, MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() {
}); ID = index,
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
});
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
} }
}//停止 }//停止
private void ListViewItem_edit(object sender, MouseButtonEventArgs e) private void ListViewItem_edit(object sender, MouseButtonEventArgs e)
@@ -415,11 +767,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString if (drEmployee.Field<bool>("Type"))
{ {//网络
ID = index, MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() {
}); ID = index,
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
});
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
TechnologicalProcess_bool = true; TechnologicalProcess_bool = true;
} }
private void ListViewItem_Jump(object sender, MouseButtonEventArgs e) private void ListViewItem_Jump(object sender, MouseButtonEventArgs e)
@@ -443,11 +833,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString if (drEmployee.Field<bool>("Type"))
{ {//网络
ID = index, MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() {
}); ID = index,
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
});
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
TechnologicalProcess_bool = true; TechnologicalProcess_bool = true;
}//跳步 }//跳步
@@ -506,11 +934,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString if (drEmployee.Field<bool>("Type"))
{ {//网络
ID = index, MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() {
}); ID = index,
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
});
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
} }
private void ListViewItem_Delete(object sender, MouseButtonEventArgs e) private void ListViewItem_Delete(object sender, MouseButtonEventArgs e)
@@ -523,11 +989,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dat_821.Add("ID", ID); dat_821.Add("ID", ID);
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString if (drEmployee.Field<bool>("Type"))
{ {//网络
ID = index, MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() {
}); ID = index,
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
});
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
MainWindowViewModel.dt_TP.Select("Step="+ID).First().Delete(); MainWindowViewModel.dt_TP.Select("Step="+ID).First().Delete();
MainWindowViewModel.dt_TP.AcceptChanges(); MainWindowViewModel.dt_TP.AcceptChanges();
@@ -570,6 +1074,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
} }
} }
private void MenuItem_Delete(object sender, RoutedEventArgs e)//右键删除 private void MenuItem_Delete(object sender, RoutedEventArgs e)//右键删除
{ {
int rownum = Gridstep.SelectedIndex;//获取鼠标选中行并定义变量 int rownum = Gridstep.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效 if (rownum != -1)//判断鼠标定位是否有效
@@ -583,11 +1088,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dat_821.Add("ID", ID); dat_821.Add("ID", ID);
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString if (drEmployee.Field<bool>("Type"))
{ {//网络
ID = index, MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() {
}); ID = index,
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
});
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
MainWindowViewModel.dt_TP.Select("Step=" + ID).First().Delete(); MainWindowViewModel.dt_TP.Select("Step=" + ID).First().Delete();
MainWindowViewModel.dt_TP.AcceptChanges(); MainWindowViewModel.dt_TP.AcceptChanges();
@@ -640,7 +1183,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC832" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") DAT = "SC832" + drEmployee.Field<string>("SYSKEY")
}); });
}//信息 }//信息
else if (machines_info == 1) else if (machines_info == 1)
@@ -658,7 +1201,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC831" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") DAT = "SC831" + drEmployee.Field<string>("SYSKEY")
}); });
} }
else else
+5 -5
View File
@@ -280,7 +280,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
{ {
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
{ {
Interval = TimeSpan.FromSeconds(1)//秒 Interval = TimeSpan.FromSeconds(5)//秒
}; };
timer1s.Tick += Tick_Event_1S; timer1s.Tick += Tick_Event_1S;
timer1s.Start(); timer1s.Start();
@@ -288,11 +288,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
public static bool UI; public static bool UI;
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
{ {
if (UI) // if (UI)
{ // {
GanttChartNEW(); GanttChartNEW();
UI= false; // UI= false;
} // }
} }
} }
} }
+3 -1
View File
@@ -1,4 +1,6 @@
using SunlightCentralizedControlManagement_SCCM_.UserClass;
using SunlightCentralizedControlManagement_SCCM_.UserClass;
using SunlightCentralizedControlManagement_SCCM_.ViewModel; using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using SunlightCentralizedControlManagement_SCCM_.WindowsView; using SunlightCentralizedControlManagement_SCCM_.WindowsView;
using System; using System;
+17 -14
View File
@@ -160,21 +160,24 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
var STLB_items = new List<DateTimePoint>(); var STLB_items = new List<DateTimePoint>();
var STTC_items = new List<DateTimePoint>(); var STTC_items = new List<DateTimePoint>();
var STLC_items = new List<DateTimePoint>(); var STLC_items = new List<DateTimePoint>();
for (var i = 0; i < CDB_Count; i=i+10) for (var i = 0; i < CDB_Count; i=i+4)
{ {
DateTime TIME = Convert.ToDateTime(CDB.Rows[i].Field<string>("Time")); try
MTT_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MTT"))); {
MTL_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MTL"))); DateTime TIME = Convert.ToDateTime(CDB.Rows[i].Field<string>("Time"));
// MTH_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MTH"))); MTT_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MTT")));
MST_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MST"))); MTL_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MTL")));
MUT_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MUT"))); // MTH_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MTH")));
STTA_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTA"))); MST_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MST")));
STLA_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLA"))); MUT_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("MUT")));
STTB_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTB"))); STTA_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTA")));
STLB_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLB"))); STLA_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLA")));
STTC_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTC"))); STTB_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTB")));
STLC_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLC"))); STLB_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLB")));
STTC_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STTC")));
STLC_items.Add(new DateTimePoint(TIME, CDB.Rows[i].Field<double>("STLC")));
}
catch (Exception) { }
} }
MTT_values = new ObservableCollection<DateTimePoint>(MTT_items); MTT_values = new ObservableCollection<DateTimePoint>(MTT_items);
File diff suppressed because it is too large. Load diff
+23
View File
@@ -0,0 +1,23 @@
<Window x:Class="SunlightCentralizedControlManagement_SCCM_.WindowsView.UserInf"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.WindowsView"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
WindowStartupLocation="CenterScreen"
Loaded ="Window_Loaded"
ResizeMode="NoResize"
mc:Ignorable="d"
Title="SUNLIGHT 800" Height="400" Width="800">
<Grid>
<Grid Margin="0,0,0,100">
<TextBox x:Name="INF_DATA" Margin="140,20,20,20" TextWrapping="Wrap" FontSize="30" IsReadOnly="True" BorderBrush="#FF673AB7" BorderThickness="2,2,2,2" Cursor="Hand" />
<Image Height="100" Width="100" FlowDirection="LeftToRight" HorizontalAlignment="Left" Margin="20,0,0,0" Source="/Lmage/IconParkInfo.png" VerticalAlignment="Center"/>
</Grid>
<Button Content="{x:Static lang:Resources.YES}" HorizontalAlignment="Left" Height="45" Margin="50,70,20,20"
VerticalAlignment="Bottom" Width="100" Click="YES_Click" HorizontalContentAlignment="Center"/>
<Button Content="{x:Static lang:Resources.NO}" HorizontalAlignment="Right" Height="45" Margin="50,70,20,20"
VerticalAlignment="Bottom" Width="100" Click="YES_Click"/>
</Grid>
</Window>
+47
View File
@@ -0,0 +1,47 @@
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
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.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.Xml.Linq;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
{
/// <summary>
/// ViewProgram.xaml 的交互逻辑
/// </summary>
public partial class UserInf : Window
{
public string Inf_DAT;//信息
public UserInf()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
INF_DATA.Text = Inf_DAT;
}
private void YES_Click(object sender, RoutedEventArgs e)//确认
{
this.Close(); //关闭窗口
}
}
}
+93
View File
@@ -0,0 +1,93 @@
<Window x:Class="SunlightCentralizedControlManagement_SCCM_.WindowsView.UserWorkOrder"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.WindowsView"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
WindowStartupLocation="CenterScreen"
Loaded ="Window_Loaded"
ResizeMode="NoResize"
mc:Ignorable="d"
Title="SUNLIGHT 800" Height="400" Width="800">
<Grid>
<DataGrid Grid.Row="0" Grid.Column="0" x:Name="WorkOrder" AlternationCount="2" IsReadOnly="True"
SelectedCellsChanged="WorkOrder_SelectedCellsChanged" EnableRowVirtualization="True" EnableColumnVirtualization="True"
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling" AutoGenerateColumns="False" MinColumnWidth="30"
Background="White" GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right"
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="True"
CanUserDeleteRows="False" SelectionMode="Single" FontSize="15" Focusable="True" Margin="0,0,0,132" >
<DataGrid.RowStyle >
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Height" Value="30" />
<Setter Property="FontSize" Value="25" />
<Setter Property="VerticalAlignment" Value="Center"/>
<Style.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="#FFFFFFFF" />
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="#FFF0F0F0" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False"/>
<DataTrigger Binding="{Binding lock}" Value="True">
<Setter Property="Background" Value="Red"/>
</DataTrigger>
<DataTrigger Binding="{Binding State}" Value="309">
<Setter Property="Background" Value="Red"/>
</DataTrigger>
<DataTrigger Binding="{Binding State}" Value="308">
<Setter Property="Background" Value="Yellow"/>
</DataTrigger>
<DataTrigger Binding="{Binding State}" Value="800">
<Setter Property="IsHitTestVisible" Value="False"/>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="MinWidth" Value="20"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#FFC0C0C0"/>
<Setter Property="BorderBrush" Value="#FFC0C0C0"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
<DataGrid.Resources>
<Style x:Key="CellStyle" TargetType="{x:Type DataGridCell}">
<Setter Property="Focusable" Value="False"/>
<Setter Property="Background" Value="#FFFFFFFF"/>
<Setter Property="BorderBrush" Value="#FFFFFFFF"/>
<Setter Property="Foreground" Value="#000000"/>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<!--列信息绑定-->
<DataGridTextColumn Header="{x:Static lang:Resources.WorkOrder}" Binding="{Binding WorkOrder}" Width="200" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.ProgramName}" Binding="{Binding ProgramName}" Width="200" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.StartTime}" Binding="{Binding StartTime}" Width="250" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Machines}" Binding="{Binding Machines}" Width="100" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.ColorNumber}" Binding="{Binding ColorNumber}" Width="200" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Client}" Binding="{Binding Client}" Width="200" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.ClothWeight}" Binding="{Binding ClothWeight}" Width="200" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.ClothSpecies}" Binding="{Binding ClothSpecies}" Width="200" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.BathRatio}" Binding="{Binding BathRatio}" Width="200" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Total}" Binding="{Binding Total}" Width="200" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.USER}" Binding="{Binding USER}" Width="150" IsReadOnly="True"/>
<DataGridTextColumn Header="{x:Static lang:Resources.ColorName}" Binding="{Binding ColorName}" Width="200" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
<Image Height="100" Width="100" FlowDirection="LeftToRight" HorizontalAlignment="Left" Margin="20,0,0,20" Source="/Lmage/IconParkInfo.png" VerticalAlignment="Bottom"/>
<Button Content="{x:Static lang:Resources.Start}" HorizontalAlignment="Right" Height="45" Margin="50,70,200,20" IsEnabled="False" x:Name="Start"
VerticalAlignment="Bottom" Width="100" Click="Start_Click" HorizontalContentAlignment="Center"/>
<Button Content="{x:Static lang:Resources.Quit}" HorizontalAlignment="Right" Height="45" Margin="50,70,20,20"
VerticalAlignment="Bottom" Width="100" Click="Quit_Click" HorizontalContentAlignment="Center"/>
</Grid>
</Window>
+139
View File
@@ -0,0 +1,139 @@
using ScottPlot.TickGenerators.TimeUnits;
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
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.Forms;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.Xml.Linq;
using TouchSocket.Core;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
using static SunlightCentralizedControlManagement_SCCM_.ViewModel.MainWindowViewModel;
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
{
/// <summary>
/// ViewProgram.xaml 的交互逻辑
/// </summary>
public partial class UserWorkOrder : Window
{
public DataTable WorkOrderTable = new DataTable();//信息
private string WorkOrder_=null;
private string machine_ = null;
public UserWorkOrder()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
WorkOrder.ItemsSource = WorkOrderTable.DefaultView;
}
private void Start_Click(object sender, RoutedEventArgs e)//确认
{
Dictionary<string, object> dat_821 = new Dictionary<string, object>();
dat_821.Clear();
dat_821.Add("INSTRUCTION", "START");
dat_821.Add("WorkOrder", WorkOrder_);
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine_ + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
string dat = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString();
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{
ID = index,
DAT = dat
});
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
bool exists = stringQueueSerial_1.Any(item => item.ID == index && item.DAT == dat);
if (!exists)
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = dat
});
}
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
bool exists = stringQueueSerial_2.Any(item => item.ID == index && item.DAT == dat);
if (!exists)
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = dat
});
}
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
bool exists = stringQueueSerial_3.Any(item => item.ID == index && item.DAT == dat);
if (!exists)
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = dat
});
}
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
bool exists = stringQueueSerial_4.Any(item => item.ID == index && item.DAT == dat);
if (!exists)
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = dat
});
}
}
}
}
this.Close();
}
private void Quit_Click(object sender, RoutedEventArgs e)//退出
{
this.Close(); //关闭窗口
}
private void WorkOrder_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
{
int rownum = WorkOrder.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效
{
WorkOrder_ = (WorkOrder.Columns[0].GetCellContent(WorkOrder.Items[rownum]) as TextBlock).Text;//定位第0列,
machine_ = (WorkOrder.Columns[3].GetCellContent(WorkOrder.Items[rownum]) as TextBlock).Text;//定位第0列,
Start.IsEnabled = true;
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB