diff --git a/BPASmartClient.Business/MainConsole.cs b/BPASmartClient.Business/MainConsole.cs index 944d44f4..e32c1a59 100644 --- a/BPASmartClient.Business/MainConsole.cs +++ b/BPASmartClient.Business/MainConsole.cs @@ -23,6 +23,8 @@ namespace BPASmartClient.Business Plugin.GetInstance().Init(); //主题初始化 TopicDefine.GetInstance().Initialize(Plugin.GetInstance().GetPlugin().GetDevices()); + //设备开启 + Plugin.GetInstance().GetPlugin().StartService(); } /// diff --git a/BPASmartClient.Business/Plugin/StatusMgr.cs b/BPASmartClient.Business/Plugin/StatusMgr.cs index 55ecd024..e3ee4cea 100644 --- a/BPASmartClient.Business/Plugin/StatusMgr.cs +++ b/BPASmartClient.Business/Plugin/StatusMgr.cs @@ -1,4 +1,5 @@ -using System; +using BPASmartClient.Helper; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -16,9 +17,22 @@ namespace BPASmartClient.Business //设备管理 private DeviceMgr deviceMgr; + private Dictionary> deviceStatus = new Dictionary>(); + public void Initialize() { deviceMgr = Plugin.GetInstance().GetPlugin(); + ThreadManage.GetInstance().StartLong(() => + { + while (running) + { + foreach (var device in deviceMgr.GetDevices()) + { + deviceStatus[device.DeviceId] = device.Status.GetStatus(); + } + Thread.Sleep(50); + } + }, "MQTT 消息处理"); } public void Dispose() diff --git a/BPASmartClient.Device/DeviceStatus.cs b/BPASmartClient.Device/DeviceStatus.cs index 5676a27e..9f113b5c 100644 --- a/BPASmartClient.Device/DeviceStatus.cs +++ b/BPASmartClient.Device/DeviceStatus.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,10 +9,16 @@ namespace BPASmartClient.Device { public class DeviceStatus { - public Dictionary status=new Dictionary(); + public ConcurrentDictionary status = new ConcurrentDictionary(); - public void Update(string key, object value) { - status[key] = value; + public void Update(string key, object value) + { + status.AddOrUpdate(key, value, (key, value) => value); + } + + public Dictionary GetStatus() + { + return status.ToDictionary(x => x.Key, x => x.Value); } } } diff --git a/BPASmartClient.OrderProxy/BPASmartClient.OrderProxy.csproj b/BPASmartClient.OrderProxy/BPASmartClient.OrderProxy.csproj deleted file mode 100644 index 132c02c5..00000000 --- a/BPASmartClient.OrderProxy/BPASmartClient.OrderProxy.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - net6.0 - enable - enable - - - diff --git a/BPASmartClient.Status/BPASmartClient.Status.csproj b/BPASmartClient.Status/BPASmartClient.Status.csproj deleted file mode 100644 index dbc15171..00000000 --- a/BPASmartClient.Status/BPASmartClient.Status.csproj +++ /dev/null @@ -1,7 +0,0 @@ - - - - net6.0 - - - diff --git a/BPASmartClient.Status/Class1.cs b/BPASmartClient.Status/Class1.cs deleted file mode 100644 index be4f8f1f..00000000 --- a/BPASmartClient.Status/Class1.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace BPASmartClient.Status -{ - public class Class1 - { - } -} diff --git a/SmartClient.sln b/SmartClient.sln index 23fcd700..7d87a49a 100644 --- a/SmartClient.sln +++ b/SmartClient.sln @@ -41,8 +41,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.Helper", "BP EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.Message", "BPASmartClient.Message\BPASmartClient.Message.csproj", "{C517D33F-8800-405E-9D59-E1F6CA201431}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.Status", "BPASmartClient.Status\BPASmartClient.Status.csproj", "{2C8DAB92-D5EB-4462-87C1-0BED75B26C54}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.IoT", "BPASmartClient.IoT\BPASmartClient.IoT.csproj", "{D3DBCC2D-086E-4E3A-B70A-22A79FB295CF}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient", "BPASmartClient\BPASmartClient.csproj", "{2BA531E8-7F85-4EBF-AE97-811CD7C83EF2}" @@ -57,8 +55,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.Socket", "BP EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.Peripheral", "BPASmartClient.Peripheral\BPASmartClient.Peripheral.csproj", "{9F5E2879-972A-45FB-913C-89E9F0CEB189}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.OrderProxy", "BPASmartClient.OrderProxy\BPASmartClient.OrderProxy.csproj", "{EBDFF87C-0B98-4BB5-8760-D86964E38A88}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MessageCommunication", "BPASmartClient.MessageCommunication\BPASmartClient.MessageCommunication.csproj", "{DCC07B39-E342-4841-B9E4-4D44DA2978FD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.EventBus", "BPASmartClient.EventBus\BPASmartClient.EventBus.csproj", "{C7FC5FC8-4C72-4CD3-973E-327BDA880DF5}" @@ -76,7 +72,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.CustomResour EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lebai.SDK", "Lebai.SDK\Lebai.SDK.csproj", "{3A55F68A-D526-4CFC-A5A6-B69FB76716C2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MORKSM.BK.PLC", "BPASmartClient.MORKSM.BK.PLC\BPASmartClient.MORKSM.BK.PLC.csproj", "{7F04A788-38B5-42CB-B601-70C657C953B8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MORKSM.BK.PLC", "BPASmartClient.MORKSM.BK.PLC\BPASmartClient.MORKSM.BK.PLC.csproj", "{7F04A788-38B5-42CB-B601-70C657C953B8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -136,10 +132,6 @@ Global {C517D33F-8800-405E-9D59-E1F6CA201431}.Debug|Any CPU.Build.0 = Debug|Any CPU {C517D33F-8800-405E-9D59-E1F6CA201431}.Release|Any CPU.ActiveCfg = Release|Any CPU {C517D33F-8800-405E-9D59-E1F6CA201431}.Release|Any CPU.Build.0 = Release|Any CPU - {2C8DAB92-D5EB-4462-87C1-0BED75B26C54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2C8DAB92-D5EB-4462-87C1-0BED75B26C54}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2C8DAB92-D5EB-4462-87C1-0BED75B26C54}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2C8DAB92-D5EB-4462-87C1-0BED75B26C54}.Release|Any CPU.Build.0 = Release|Any CPU {D3DBCC2D-086E-4E3A-B70A-22A79FB295CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D3DBCC2D-086E-4E3A-B70A-22A79FB295CF}.Debug|Any CPU.Build.0 = Debug|Any CPU {D3DBCC2D-086E-4E3A-B70A-22A79FB295CF}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -168,10 +160,6 @@ Global {9F5E2879-972A-45FB-913C-89E9F0CEB189}.Debug|Any CPU.Build.0 = Debug|Any CPU {9F5E2879-972A-45FB-913C-89E9F0CEB189}.Release|Any CPU.ActiveCfg = Release|Any CPU {9F5E2879-972A-45FB-913C-89E9F0CEB189}.Release|Any CPU.Build.0 = Release|Any CPU - {EBDFF87C-0B98-4BB5-8760-D86964E38A88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EBDFF87C-0B98-4BB5-8760-D86964E38A88}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EBDFF87C-0B98-4BB5-8760-D86964E38A88}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EBDFF87C-0B98-4BB5-8760-D86964E38A88}.Release|Any CPU.Build.0 = Release|Any CPU {DCC07B39-E342-4841-B9E4-4D44DA2978FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DCC07B39-E342-4841-B9E4-4D44DA2978FD}.Debug|Any CPU.Build.0 = Debug|Any CPU {DCC07B39-E342-4841-B9E4-4D44DA2978FD}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -218,7 +206,6 @@ Global {B399BCFF-82E8-4940-9CE5-B7DCDDFDC696} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} {A2A5CB83-11C7-4534-A65D-6F957B60EEFF} = {1A9920BA-7C8D-4BDC-8D7D-6544A71AF3CF} {C517D33F-8800-405E-9D59-E1F6CA201431} = {1A9920BA-7C8D-4BDC-8D7D-6544A71AF3CF} - {2C8DAB92-D5EB-4462-87C1-0BED75B26C54} = {6CEA3385-6F62-452A-8275-033A6037235D} {D3DBCC2D-086E-4E3A-B70A-22A79FB295CF} = {6CEA3385-6F62-452A-8275-033A6037235D} {2BA531E8-7F85-4EBF-AE97-811CD7C83EF2} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} {4E393E60-D39A-4118-8BD5-427DC72E9ACE} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} @@ -226,7 +213,6 @@ Global {7D290C8E-ACA7-4F03-91DF-D507FB3E2E87} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625} {F9AD1657-7FF9-470F-BE7F-2379ADAC0BB0} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625} {9F5E2879-972A-45FB-913C-89E9F0CEB189} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD} - {EBDFF87C-0B98-4BB5-8760-D86964E38A88} = {6CEA3385-6F62-452A-8275-033A6037235D} {DCC07B39-E342-4841-B9E4-4D44DA2978FD} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625} {C7FC5FC8-4C72-4CD3-973E-327BDA880DF5} = {1A9920BA-7C8D-4BDC-8D7D-6544A71AF3CF} {268012B6-C4FC-4C40-802C-74D5FAD3CA45} = {1A9920BA-7C8D-4BDC-8D7D-6544A71AF3CF}