From c414944cd6607a745f52d24efc730d1f63f815aa Mon Sep 17 00:00:00 2001
From: applelon <380149513@qq.com>
Date: Mon, 18 Apr 2022 14:07:44 +0800
Subject: [PATCH] init
---
.../BPASmartClient.DRCoffee.csproj | 7 +
BPASmartClient.DRCoffee/Class1.cs | 8 +
.../BPASmartClient.Device.csproj | 7 +
BPASmartClient.Device/IDevice.cs | 13 +
BPASmartClient.Device/IDeviceStatus.cs | 12 +
.../BPASmartClient.DeviceProxy.csproj | 7 +
BPASmartClient.DeviceProxy/Class1.cs | 8 +
.../BPASmartClient.GSIceCream.csproj | 7 +
BPASmartClient.GSIceCream/Class1.cs | 8 +
BPASmartClient.Helper/APIHelper.cs | 94 +++++++
BPASmartClient.Helper/ActionManage.cs | 128 +++++++++
.../BPASmartClient.Helper.csproj | 28 ++
BPASmartClient.Helper/DataStorage.cs | 43 ++++
BPASmartClient.Helper/Delay.cs | 75 ++++++
BPASmartClient.Helper/DelayRTrig.cs | 73 ++++++
BPASmartClient.Helper/DelayTTrig.cs | 67 +++++
BPASmartClient.Helper/ExpandMethod.cs | 100 +++++++
BPASmartClient.Helper/Json.cs | 95 +++++++
BPASmartClient.Helper/LocaPath.cs | 26 ++
BPASmartClient.Helper/RTrig.cs | 40 +++
BPASmartClient.Helper/Singleton.cs | 31 +++
BPASmartClient.Helper/SystemHelper.cs | 237 +++++++++++++++++
BPASmartClient.Helper/TTrig.cs | 39 +++
BPASmartClient.Helper/TextHelper.cs | 64 +++++
BPASmartClient.Helper/ThreadManage.cs | 164 ++++++++++++
BPASmartClient.Helper/UniversalHelper.cs | 49 ++++
.../BPASmartClient.Http.csproj | 7 +
BPASmartClient.Http/Class1.cs | 8 +
BPASmartClient.IoT/BPASmartClient.IoT.csproj | 7 +
BPASmartClient.IoT/Class1.cs | 8 +
.../BPASmartClient.KLMCoffee.csproj | 7 +
BPASmartClient.KLMCoffee/Class1.cs | 8 +
.../BPASmartClient.Lebai.csproj | 7 +
BPASmartClient.Lebai/Class1.cs | 8 +
.../BPASmartClient.MQTT.csproj | 16 ++
BPASmartClient.MQTT/MqttHelper.cs | 183 +++++++++++++
.../BPASmartClient.Message.csproj | 7 +
BPASmartClient.Message/MessageLog.cs | 67 +++++
.../BPASmartClient.Modbus.csproj | 7 +
BPASmartClient.Modbus/Class1.cs | 8 +
.../BPASmartClient.MorkD.csproj | 7 +
BPASmartClient.MorkD/Class1.cs | 8 +
.../BPASmartClient.MorkS.csproj | 7 +
BPASmartClient.MorkS/Class1.cs | 8 +
.../BPASmartClient.MorkT.csproj | 7 +
.../BPASmartClient.SCChip.csproj | 7 +
BPASmartClient.SCChip/Class1.cs | 8 +
.../BPASmartClient.SerialPort.csproj | 15 ++
BPASmartClient.SerialPort/SerialParameter.cs | 50 ++++
BPASmartClient.SerialPort/SerialPortClient.cs | 243 ++++++++++++++++++
.../BPASmartClient.Socket.csproj | 7 +
BPASmartClient.Socket/Class1.cs | 8 +
.../BPASmartClient.Status.csproj | 7 +
BPASmartClient.Status/Class1.cs | 8 +
.../BPASmartClient.ViewModel.csproj | 9 +
BPASmartClient.ViewModel/Class1.cs | 8 +
BPASmartClient/App.xaml | 9 +
BPASmartClient/App.xaml.cs | 17 ++
BPASmartClient/AssemblyInfo.cs | 10 +
BPASmartClient/BPASmartClient.csproj | 10 +
BPASmartClient/MainWindow.xaml | 12 +
BPASmartClient/MainWindow.xaml.cs | 28 ++
SmartClient.sln | 180 +++++++++++++
63 files changed, 2451 insertions(+)
create mode 100644 BPASmartClient.DRCoffee/BPASmartClient.DRCoffee.csproj
create mode 100644 BPASmartClient.DRCoffee/Class1.cs
create mode 100644 BPASmartClient.Device/BPASmartClient.Device.csproj
create mode 100644 BPASmartClient.Device/IDevice.cs
create mode 100644 BPASmartClient.Device/IDeviceStatus.cs
create mode 100644 BPASmartClient.DeviceProxy/BPASmartClient.DeviceProxy.csproj
create mode 100644 BPASmartClient.DeviceProxy/Class1.cs
create mode 100644 BPASmartClient.GSIceCream/BPASmartClient.GSIceCream.csproj
create mode 100644 BPASmartClient.GSIceCream/Class1.cs
create mode 100644 BPASmartClient.Helper/APIHelper.cs
create mode 100644 BPASmartClient.Helper/ActionManage.cs
create mode 100644 BPASmartClient.Helper/BPASmartClient.Helper.csproj
create mode 100644 BPASmartClient.Helper/DataStorage.cs
create mode 100644 BPASmartClient.Helper/Delay.cs
create mode 100644 BPASmartClient.Helper/DelayRTrig.cs
create mode 100644 BPASmartClient.Helper/DelayTTrig.cs
create mode 100644 BPASmartClient.Helper/ExpandMethod.cs
create mode 100644 BPASmartClient.Helper/Json.cs
create mode 100644 BPASmartClient.Helper/LocaPath.cs
create mode 100644 BPASmartClient.Helper/RTrig.cs
create mode 100644 BPASmartClient.Helper/Singleton.cs
create mode 100644 BPASmartClient.Helper/SystemHelper.cs
create mode 100644 BPASmartClient.Helper/TTrig.cs
create mode 100644 BPASmartClient.Helper/TextHelper.cs
create mode 100644 BPASmartClient.Helper/ThreadManage.cs
create mode 100644 BPASmartClient.Helper/UniversalHelper.cs
create mode 100644 BPASmartClient.Http/BPASmartClient.Http.csproj
create mode 100644 BPASmartClient.Http/Class1.cs
create mode 100644 BPASmartClient.IoT/BPASmartClient.IoT.csproj
create mode 100644 BPASmartClient.IoT/Class1.cs
create mode 100644 BPASmartClient.KLMCoffee/BPASmartClient.KLMCoffee.csproj
create mode 100644 BPASmartClient.KLMCoffee/Class1.cs
create mode 100644 BPASmartClient.Lebai/BPASmartClient.Lebai.csproj
create mode 100644 BPASmartClient.Lebai/Class1.cs
create mode 100644 BPASmartClient.MQTT/BPASmartClient.MQTT.csproj
create mode 100644 BPASmartClient.MQTT/MqttHelper.cs
create mode 100644 BPASmartClient.Message/BPASmartClient.Message.csproj
create mode 100644 BPASmartClient.Message/MessageLog.cs
create mode 100644 BPASmartClient.Modbus/BPASmartClient.Modbus.csproj
create mode 100644 BPASmartClient.Modbus/Class1.cs
create mode 100644 BPASmartClient.MorkD/BPASmartClient.MorkD.csproj
create mode 100644 BPASmartClient.MorkD/Class1.cs
create mode 100644 BPASmartClient.MorkS/BPASmartClient.MorkS.csproj
create mode 100644 BPASmartClient.MorkS/Class1.cs
create mode 100644 BPASmartClient.MorkT/BPASmartClient.MorkT.csproj
create mode 100644 BPASmartClient.SCChip/BPASmartClient.SCChip.csproj
create mode 100644 BPASmartClient.SCChip/Class1.cs
create mode 100644 BPASmartClient.SerialPort/BPASmartClient.SerialPort.csproj
create mode 100644 BPASmartClient.SerialPort/SerialParameter.cs
create mode 100644 BPASmartClient.SerialPort/SerialPortClient.cs
create mode 100644 BPASmartClient.Socket/BPASmartClient.Socket.csproj
create mode 100644 BPASmartClient.Socket/Class1.cs
create mode 100644 BPASmartClient.Status/BPASmartClient.Status.csproj
create mode 100644 BPASmartClient.Status/Class1.cs
create mode 100644 BPASmartClient.ViewModel/BPASmartClient.ViewModel.csproj
create mode 100644 BPASmartClient.ViewModel/Class1.cs
create mode 100644 BPASmartClient/App.xaml
create mode 100644 BPASmartClient/App.xaml.cs
create mode 100644 BPASmartClient/AssemblyInfo.cs
create mode 100644 BPASmartClient/BPASmartClient.csproj
create mode 100644 BPASmartClient/MainWindow.xaml
create mode 100644 BPASmartClient/MainWindow.xaml.cs
create mode 100644 SmartClient.sln
diff --git a/BPASmartClient.DRCoffee/BPASmartClient.DRCoffee.csproj b/BPASmartClient.DRCoffee/BPASmartClient.DRCoffee.csproj
new file mode 100644
index 00000000..dbc15171
--- /dev/null
+++ b/BPASmartClient.DRCoffee/BPASmartClient.DRCoffee.csproj
@@ -0,0 +1,7 @@
+
+
+
+ net6.0
+
+
+
diff --git a/BPASmartClient.DRCoffee/Class1.cs b/BPASmartClient.DRCoffee/Class1.cs
new file mode 100644
index 00000000..66097ed2
--- /dev/null
+++ b/BPASmartClient.DRCoffee/Class1.cs
@@ -0,0 +1,8 @@
+using System;
+
+namespace BPASmartClient.DRCoffee
+{
+ public class Class1
+ {
+ }
+}
diff --git a/BPASmartClient.Device/BPASmartClient.Device.csproj b/BPASmartClient.Device/BPASmartClient.Device.csproj
new file mode 100644
index 00000000..dbc15171
--- /dev/null
+++ b/BPASmartClient.Device/BPASmartClient.Device.csproj
@@ -0,0 +1,7 @@
+
+
+
+ net6.0
+
+
+
diff --git a/BPASmartClient.Device/IDevice.cs b/BPASmartClient.Device/IDevice.cs
new file mode 100644
index 00000000..620bdfe4
--- /dev/null
+++ b/BPASmartClient.Device/IDevice.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.Device
+{
+ public interface IDevice
+ {
+
+ }
+}
diff --git a/BPASmartClient.Device/IDeviceStatus.cs b/BPASmartClient.Device/IDeviceStatus.cs
new file mode 100644
index 00000000..6ab5e918
--- /dev/null
+++ b/BPASmartClient.Device/IDeviceStatus.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.Device
+{
+ internal class IDeviceStatus
+ {
+ }
+}
diff --git a/BPASmartClient.DeviceProxy/BPASmartClient.DeviceProxy.csproj b/BPASmartClient.DeviceProxy/BPASmartClient.DeviceProxy.csproj
new file mode 100644
index 00000000..dbc15171
--- /dev/null
+++ b/BPASmartClient.DeviceProxy/BPASmartClient.DeviceProxy.csproj
@@ -0,0 +1,7 @@
+
+
+
+ net6.0
+
+
+
diff --git a/BPASmartClient.DeviceProxy/Class1.cs b/BPASmartClient.DeviceProxy/Class1.cs
new file mode 100644
index 00000000..9fae3eee
--- /dev/null
+++ b/BPASmartClient.DeviceProxy/Class1.cs
@@ -0,0 +1,8 @@
+using System;
+
+namespace BPASmartClient.DeviceProxy
+{
+ public class Class1
+ {
+ }
+}
diff --git a/BPASmartClient.GSIceCream/BPASmartClient.GSIceCream.csproj b/BPASmartClient.GSIceCream/BPASmartClient.GSIceCream.csproj
new file mode 100644
index 00000000..dbc15171
--- /dev/null
+++ b/BPASmartClient.GSIceCream/BPASmartClient.GSIceCream.csproj
@@ -0,0 +1,7 @@
+
+
+
+ net6.0
+
+
+
diff --git a/BPASmartClient.GSIceCream/Class1.cs b/BPASmartClient.GSIceCream/Class1.cs
new file mode 100644
index 00000000..3bf73622
--- /dev/null
+++ b/BPASmartClient.GSIceCream/Class1.cs
@@ -0,0 +1,8 @@
+using System;
+
+namespace BPASmartClient.GSIceCream
+{
+ public class Class1
+ {
+ }
+}
diff --git a/BPASmartClient.Helper/APIHelper.cs b/BPASmartClient.Helper/APIHelper.cs
new file mode 100644
index 00000000..af029136
--- /dev/null
+++ b/BPASmartClient.Helper/APIHelper.cs
@@ -0,0 +1,94 @@
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+using System.Web;
+using Newtonsoft.Json;
+using HBLConsole.Service;
+
+namespace BPASmartClient.Helper
+{
+ public class APIHelper
+ {
+
+ private volatile static APIHelper _Instance;
+ public static APIHelper GetInstance => _Instance ?? (_Instance = new APIHelper());
+ private APIHelper() { }
+
+ public string PostData(string url, string data, string head)
+ {
+ byte[] b = Encoding.UTF8.GetBytes(data);//把字符串转换为二进制
+ HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
+ request.Proxy = null;
+ request.ContentType = "application/json";
+ request.Method = "POST"; //设置请求方法
+ request.ContentLength = b.Length; //设置长度
+ request.Headers["Authorize"] = head;
+ Stream postStream = request.GetRequestStream(); //requst流
+ postStream.Write(b, 0, b.Length); //写入POST数据,二进制类型的
+ postStream.Close(); //关闭
+ HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //获取response
+ Stream stream = response.GetResponseStream(); // 得到response响应流
+ StreamReader sr = new StreamReader(stream);
+ string str = sr.ReadToEnd(); //读取流
+
+ sr.Close();
+ stream.Close();
+ return str;
+ }
+
+ public string GetData(string url, string head)
+ {
+ HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
+ request.Method = "GET";
+ request.Accept = "text/html, application/xhtml+xml, */*";
+ request.ContentType = "application/json";
+ request.Headers["Authorize"] = head;
+ byte[] buffer = Encoding.UTF8.GetBytes(head);
+ request.ContentLength = buffer.Length;
+ request.GetRequestStream().Write(buffer, 0, buffer.Length);
+ HttpWebResponse response = (HttpWebResponse)request.GetResponse();
+ using (StreamReader myStreamReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
+ {
+ return myStreamReader.ReadToEnd();
+ }
+ }
+
+ public string HttpRequest(string url, string head, object data, RequestType requestType)
+ {
+ if (requestType == RequestType.POST)
+ {
+ return PostData(url, JsonConvert.SerializeObject(data), head);
+ }
+ else
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append("?");
+ foreach (System.Reflection.PropertyInfo p in data.GetType().GetProperties())
+ {
+ if (sb.ToString().Last() != '?')
+ {
+ sb.Append("&");
+ }
+ sb.Append(p.Name);
+ sb.Append("=");
+ sb.Append(p.GetValue(data));
+ }
+ return GetData(url + sb.ToString(), head);
+ }
+ }
+
+ }
+
+ public enum RequestType
+ {
+ POST,
+ PUT,
+ DELETE,
+ GET
+ }
+}
diff --git a/BPASmartClient.Helper/ActionManage.cs b/BPASmartClient.Helper/ActionManage.cs
new file mode 100644
index 00000000..d257033d
--- /dev/null
+++ b/BPASmartClient.Helper/ActionManage.cs
@@ -0,0 +1,128 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Collections.Concurrent;
+
+namespace BPASmartClient.Helper
+{
+ public class ActionManage
+ {
+
+ private volatile static ActionManage _Instance;
+ public static ActionManage GetInstance => _Instance ?? (_Instance = new ActionManage());
+ private ActionManage() { }
+
+ private static ConcurrentDictionary actions = new ConcurrentDictionary();
+
+ static readonly object SendLock = new object();
+ static readonly object SendParLock = new object();
+ static readonly object RegisterLock = new object();
+
+ ///
+ /// 注销委托
+ ///
+ ///
+ public void CancelRegister(string key)
+ {
+ if (actions.ContainsKey(key))
+ actions.TryRemove(key, out Delegation t);
+ }
+
+ ///
+ /// 执行注册过的委托
+ ///
+ /// 注册委托的key
+ /// 委托参数
+ /// 委托回调
+ public void Send(string key, object par, Action Callback = null)
+ {
+ lock (SendLock)
+ if (actions.ContainsKey(key)) actions[key].ActionPar.Invoke(par, Callback);
+ //if (actions[key].ActionPar != null)
+ //{
+ // actions[key].ActionPar(par);
+ // if (Callback != null) Callback();
+ //}
+ }
+
+ ///
+ /// 执行注册过的委托
+ ///
+ /// 注册委托的key
+ /// 委托回调
+ public void Send(string key, Action Callback = null)
+ {
+ lock (SendLock)
+ if (actions.ContainsKey(key)) actions[key].ActionBus?.Invoke(Callback);
+ }
+
+ public object SendResult(string key, object par = null)
+ {
+ lock (SendLock)
+ if (actions.ContainsKey(key))
+ if (par == null)
+ {
+ if (actions[key].FuncObj != null)
+ return actions[key].FuncObj;
+ }
+ else
+ {
+ if (actions[key].FuncPar != null)
+ return actions[key].FuncPar(par);
+ }
+ return default;
+ }
+
+ public void Register(T action, string key)
+ {
+ lock (RegisterLock)
+ {
+ if (action != null)
+ {
+ if (!actions.ContainsKey(key))
+ {
+ if (action is Action actionBus)
+ actions.TryAdd(key, new Delegation() { ActionBus = actionBus });
+
+ if (action is Action