diff --git a/.gitignore b/.gitignore index b43ad92..ecdd399 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ bin-release/ # information for Eclipse / Flash Builder. /LK/appsettings.json /LK/appsettings.json +/.vs diff --git a/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 b/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 deleted file mode 100644 index b27cc55..0000000 Binary files a/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 and /dev/null differ diff --git a/.vs/IoTGateway/FileContentIndex/0c07d9e6-cadd-4bfc-b30d-70e3bb4a3b42.vsidx b/.vs/IoTGateway/FileContentIndex/0c07d9e6-cadd-4bfc-b30d-70e3bb4a3b42.vsidx deleted file mode 100644 index c127c75..0000000 Binary files a/.vs/IoTGateway/FileContentIndex/0c07d9e6-cadd-4bfc-b30d-70e3bb4a3b42.vsidx and /dev/null differ diff --git a/.vs/IoTGateway/FileContentIndex/49c1a143-e289-4b5e-94bd-d8f6eeec765c.vsidx b/.vs/IoTGateway/FileContentIndex/49c1a143-e289-4b5e-94bd-d8f6eeec765c.vsidx deleted file mode 100644 index 26f7868..0000000 Binary files a/.vs/IoTGateway/FileContentIndex/49c1a143-e289-4b5e-94bd-d8f6eeec765c.vsidx and /dev/null differ diff --git a/.vs/IoTGateway/FileContentIndex/541da243-50ad-45a8-9f68-40e68ae1c141.vsidx b/.vs/IoTGateway/FileContentIndex/541da243-50ad-45a8-9f68-40e68ae1c141.vsidx deleted file mode 100644 index afe0540..0000000 Binary files a/.vs/IoTGateway/FileContentIndex/541da243-50ad-45a8-9f68-40e68ae1c141.vsidx and /dev/null differ diff --git a/.vs/IoTGateway/FileContentIndex/c5f0783d-4c53-4bf1-87cc-2fa5e948d42a.vsidx b/.vs/IoTGateway/FileContentIndex/c5f0783d-4c53-4bf1-87cc-2fa5e948d42a.vsidx deleted file mode 100644 index babcc99..0000000 Binary files a/.vs/IoTGateway/FileContentIndex/c5f0783d-4c53-4bf1-87cc-2fa5e948d42a.vsidx and /dev/null differ diff --git a/.vs/IoTGateway/FileContentIndex/ffc12142-a2fd-4689-a65a-ee57200eab5d.vsidx b/.vs/IoTGateway/FileContentIndex/ffc12142-a2fd-4689-a65a-ee57200eab5d.vsidx deleted file mode 100644 index f0a7ab5..0000000 Binary files a/.vs/IoTGateway/FileContentIndex/ffc12142-a2fd-4689-a65a-ee57200eab5d.vsidx and /dev/null differ diff --git a/.vs/IoTGateway/FileContentIndex/read.lock b/.vs/IoTGateway/FileContentIndex/read.lock deleted file mode 100644 index e69de29..0000000 diff --git a/.vs/IoTGateway/config/applicationhost.config b/.vs/IoTGateway/config/applicationhost.config deleted file mode 100644 index bd44eab..0000000 --- a/.vs/IoTGateway/config/applicationhost.config +++ /dev/null @@ -1,1025 +0,0 @@ - - - - - - - -
-
-
-
-
-
-
-
- - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
- -
-
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
- -
-
- -
-
-
- - -
-
-
-
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.vs/IoTGateway/project-colors.json b/.vs/IoTGateway/project-colors.json deleted file mode 100644 index 1ae7f3b..0000000 --- a/.vs/IoTGateway/project-colors.json +++ /dev/null @@ -1,156 +0,0 @@ -{ - "Version": 1, - "ProjectMap": { - "61d79f77-09ef-4a98-a50b-043b1d72c111": { - "ProjectGuid": "61d79f77-09ef-4a98-a50b-043b1d72c111", - "DisplayName": "Plugin", - "ColorIndex": 0 - }, - "68abbdf2-1485-4756-9a94-6afa874d69a3": { - "ProjectGuid": "68abbdf2-1485-4756-9a94-6afa874d69a3", - "DisplayName": "IoTGateway", - "ColorIndex": 1 - }, - "00e91fc1-d5cf-416a-aaaf-61567e368dcd": { - "ProjectGuid": "00e91fc1-d5cf-416a-aaaf-61567e368dcd", - "DisplayName": "IoTGateway.ViewModel", - "ColorIndex": 2 - }, - "9e7c8c77-643f-45cf-8edc-5b032c51d563": { - "ProjectGuid": "9e7c8c77-643f-45cf-8edc-5b032c51d563", - "DisplayName": "IoTGateway.DataAccess", - "ColorIndex": 3 - }, - "c2978e5d-e71e-4882-8ef1-4014e8565a77": { - "ProjectGuid": "c2978e5d-e71e-4882-8ef1-4014e8565a77", - "DisplayName": "IoTGateway.Model", - "ColorIndex": 4 - }, - "7b432fc9-57e6-44bf-b8a7-2a1fb31d6add": { - "ProjectGuid": "7b432fc9-57e6-44bf-b8a7-2a1fb31d6add", - "DisplayName": "DriverModbusTCP", - "ColorIndex": 5 - }, - "16f2c5cc-d881-4fdf-82de-d6df3525d65d": { - "ProjectGuid": "16f2c5cc-d881-4fdf-82de-d6df3525d65d", - "DisplayName": "IoTGateway.Test", - "ColorIndex": 6 - }, - "a2fe74e1-b743-11d0-ae1a-00a0c90fffc3": { - "ProjectGuid": "a2fe74e1-b743-11d0-ae1a-00a0c90fffc3", - "DisplayName": "杂项文件", - "ColorIndex": -1 - }, - "e5f79995-ab61-41f4-820d-ba39967b406b": { - "ProjectGuid": "e5f79995-ab61-41f4-820d-ba39967b406b", - "DisplayName": "PluginInterface", - "ColorIndex": 7 - }, - "c2672620-8e65-486c-b967-c4c673f8da0f": { - "ProjectGuid": "c2672620-8e65-486c-b967-c4c673f8da0f", - "DisplayName": "WalkingTec.Mvvm.Core", - "ColorIndex": 8 - }, - "b370f699-965b-4d86-93b1-0f022c95b5c9": { - "ProjectGuid": "b370f699-965b-4d86-93b1-0f022c95b5c9", - "DisplayName": "WalkingTec.Mvvm.Mvc", - "ColorIndex": 9 - }, - "81cbfd0e-1d89-440a-8cc3-e32672504ff4": { - "ProjectGuid": "81cbfd0e-1d89-440a-8cc3-e32672504ff4", - "DisplayName": "WalkingTec.Mvvm.TagHelpers.LayUI", - "ColorIndex": 10 - }, - "402e5b3a-ad95-4b6a-a4b0-c8ffcbf494c3": { - "ProjectGuid": "402e5b3a-ad95-4b6a-a4b0-c8ffcbf494c3", - "DisplayName": "test", - "ColorIndex": 11 - }, - "b884fbe3-c8c5-471e-b629-12eca0fc5dac": { - "ProjectGuid": "b884fbe3-c8c5-471e-b629-12eca0fc5dac", - "DisplayName": "DriverSiemensS7", - "ColorIndex": 12 - }, - "4fc43620-00b1-48c1-a5a0-02fcc038fb08": { - "ProjectGuid": "4fc43620-00b1-48c1-a5a0-02fcc038fb08", - "DisplayName": "DriverModbusMaster", - "ColorIndex": 13 - }, - "25e57fd9-1e9b-4235-9ba8-214fa93fcbb7": { - "ProjectGuid": "25e57fd9-1e9b-4235-9ba8-214fa93fcbb7", - "DisplayName": "DriverOPCUaClient", - "ColorIndex": 14 - }, - "dabb562d-5eb7-4f9d-90ef-424c2bf63a4d": { - "ProjectGuid": "dabb562d-5eb7-4f9d-90ef-424c2bf63a4d", - "DisplayName": "DriverOPCUaClient", - "ColorIndex": 15 - }, - "0602dc6c-fb26-41b1-972e-298679826e3f": { - "ProjectGuid": "0602dc6c-fb26-41b1-972e-298679826e3f", - "DisplayName": "DriverMTConnect", - "ColorIndex": 0 - }, - "6d926cd7-5ff9-489b-9049-7030ae8059c9": { - "ProjectGuid": "6d926cd7-5ff9-489b-9049-7030ae8059c9", - "DisplayName": "DriverMitsubishi", - "ColorIndex": 1 - }, - "92e2bb84-c7ec-418e-879a-40b891cae6e7": { - "ProjectGuid": "92e2bb84-c7ec-418e-879a-40b891cae6e7", - "DisplayName": "DriverOmronFins", - "ColorIndex": 2 - }, - "c8c82c05-defd-4e79-9772-b5ea3d2e5d88": { - "ProjectGuid": "c8c82c05-defd-4e79-9772-b5ea3d2e5d88", - "DisplayName": "DriverAllenBradley", - "ColorIndex": 3 - }, - "1f9122c1-19de-4a8b-9a00-d59e592ecc3a": { - "ProjectGuid": "1f9122c1-19de-4a8b-9a00-d59e592ecc3a", - "DisplayName": "IoTGateway", - "ColorIndex": 4 - }, - "5c12ebfb-b152-48c6-aa52-71128f246594": { - "ProjectGuid": "5c12ebfb-b152-48c6-aa52-71128f246594", - "DisplayName": "Plugin", - "ColorIndex": 5 - }, - "96d436b4-4703-4448-a879-b69ace89ca11": { - "ProjectGuid": "96d436b4-4703-4448-a879-b69ace89ca11", - "DisplayName": "WalkingTec.Mvvm.Mvc", - "ColorIndex": 6 - }, - "8e2d91dc-dee4-4843-8d09-6fc06651527e": { - "ProjectGuid": "8e2d91dc-dee4-4843-8d09-6fc06651527e", - "DisplayName": "DriverModbusMaster", - "ColorIndex": 7 - }, - "7752ad8c-04bf-4bd2-9272-cda4f78fa954": { - "ProjectGuid": "7752ad8c-04bf-4bd2-9272-cda4f78fa954", - "DisplayName": "PluginInterface", - "ColorIndex": 8 - }, - "89de240e-5393-4dd4-87c9-3ad9d44b6e7e": { - "ProjectGuid": "89de240e-5393-4dd4-87c9-3ad9d44b6e7e", - "DisplayName": "WalkingTec.Mvvm.Core", - "ColorIndex": 9 - }, - "e63c22d5-5f9b-4671-b115-40721b27f09f": { - "ProjectGuid": "e63c22d5-5f9b-4671-b115-40721b27f09f", - "DisplayName": "IoTGateway.ViewModel", - "ColorIndex": 10 - }, - "44619988-9f09-4714-9532-a44faf8275fe": { - "ProjectGuid": "44619988-9f09-4714-9532-a44faf8275fe", - "DisplayName": "IoTGateway.Model", - "ColorIndex": 11 - }, - "27ff2d65-0bba-4c69-9dd7-311a4f21541e": { - "ProjectGuid": "27ff2d65-0bba-4c69-9dd7-311a4f21541e", - "DisplayName": "IoTGateway.DataAccess", - "ColorIndex": 12 - } - }, - "NextColorIndex": 13 -} \ No newline at end of file diff --git a/.vs/IoTGateway/v16/.suo b/.vs/IoTGateway/v16/.suo deleted file mode 100644 index 9f0983e..0000000 Binary files a/.vs/IoTGateway/v16/.suo and /dev/null differ diff --git a/.vs/IoTGateway/v17/.futdcache.v1 b/.vs/IoTGateway/v17/.futdcache.v1 deleted file mode 100644 index 0d07c6a..0000000 Binary files a/.vs/IoTGateway/v17/.futdcache.v1 and /dev/null differ diff --git a/.vs/IoTGateway/v17/.suo b/.vs/IoTGateway/v17/.suo deleted file mode 100644 index e4f7376..0000000 Binary files a/.vs/IoTGateway/v17/.suo and /dev/null differ diff --git a/.vs/IoTGateway/v17/TestStore/0/007.testlog b/.vs/IoTGateway/v17/TestStore/0/007.testlog deleted file mode 100644 index 3f0c85c..0000000 Binary files a/.vs/IoTGateway/v17/TestStore/0/007.testlog and /dev/null differ diff --git a/.vs/IoTGateway/v17/TestStore/0/testlog.manifest b/.vs/IoTGateway/v17/TestStore/0/testlog.manifest deleted file mode 100644 index 006f9b0..0000000 Binary files a/.vs/IoTGateway/v17/TestStore/0/testlog.manifest and /dev/null differ diff --git a/.vs/IoTGateway/v17/fileList.bin b/.vs/IoTGateway/v17/fileList.bin deleted file mode 100644 index a1cc34b..0000000 Binary files a/.vs/IoTGateway/v17/fileList.bin and /dev/null differ diff --git a/.vs/ProjectEvaluation/iotgateway.metadata.v2 b/.vs/ProjectEvaluation/iotgateway.metadata.v2 deleted file mode 100644 index ad78594..0000000 Binary files a/.vs/ProjectEvaluation/iotgateway.metadata.v2 and /dev/null differ diff --git a/.vs/ProjectEvaluation/iotgateway.projects.v2 b/.vs/ProjectEvaluation/iotgateway.projects.v2 deleted file mode 100644 index b06c94f..0000000 Binary files a/.vs/ProjectEvaluation/iotgateway.projects.v2 and /dev/null differ diff --git a/IoTGateway.Model/SystemConfig.cs b/IoTGateway.Model/SystemConfig.cs index 4748b37..b6e3dad 100644 --- a/IoTGateway.Model/SystemConfig.cs +++ b/IoTGateway.Model/SystemConfig.cs @@ -33,6 +33,8 @@ namespace IoTGateway.Model [Display(Name = "中移OneNet")] OneNET = 5, [Display(Name = "ThingsCloud")] - ThingsCloud = 6 + ThingsCloud = 6, + [Display(Name = "IotDB")] + IotDB = 99 } } \ No newline at end of file diff --git a/IoTGateway/iotgateway.db b/IoTGateway/iotgateway.db index d386b05..a12bdfb 100644 Binary files a/IoTGateway/iotgateway.db and b/IoTGateway/iotgateway.db differ diff --git a/IoTGateway/iotgateway.db-shm b/IoTGateway/iotgateway.db-shm new file mode 100644 index 0000000..7991072 Binary files /dev/null and b/IoTGateway/iotgateway.db-shm differ diff --git a/IoTGateway/iotgateway.db-wal b/IoTGateway/iotgateway.db-wal new file mode 100644 index 0000000..7d5b694 Binary files /dev/null and b/IoTGateway/iotgateway.db-wal differ diff --git a/Plugins/Plugin/MyMqttClient.cs b/Plugins/Plugin/MyMqttClient.cs index 9e43c3c..f446243 100644 --- a/Plugins/Plugin/MyMqttClient.cs +++ b/Plugins/Plugin/MyMqttClient.cs @@ -10,6 +10,7 @@ using MQTTnet.Client.Receiving; using MQTTnet.Protocol; using Newtonsoft.Json; using PluginInterface; +using PluginInterface.IotDB; using PluginInterface.IoTSharp; using PluginInterface.ThingsBoard; using Quickstarts.ReferenceServer; @@ -156,7 +157,8 @@ namespace Plugin else if (e.ApplicationMessage.Topic.StartsWith($"devices/") && e.ApplicationMessage.Topic.Contains("/rpc/request/")) { ReceiveIsRpc(e); - }else if(e.ApplicationMessage.Topic== "gateway/command/send") + } + else if (e.ApplicationMessage.Topic == "gateway/command/send") { ReceiveTcRpc(e); } @@ -178,7 +180,7 @@ namespace Plugin try { tBRpcRequest = JsonConvert.DeserializeObject(e.ApplicationMessage.ConvertPayloadToString()); - if(!string.IsNullOrWhiteSpace(tBRpcRequest.RequestData.Method)) + if (!string.IsNullOrWhiteSpace(tBRpcRequest.RequestData.Method)) { OnExcRpc?.Invoke(Client, new RpcRequest() { @@ -487,6 +489,25 @@ namespace Plugin UploadTCTelemetryDataAsync(device.DeviceName, payload.Values); } break; + case IoTPlatformType.IotDB: + { + foreach (var payload in SendModel[device.DeviceName]) + { + if (payload.DeviceStatus != DeviceStatusTypeEnum.Good) + continue; + + IotTsData tsData = new IotTsData() + { + device = device.DeviceName, + timestamp = payload.TS, + measurements = payload.Values.Keys.ToList(), + values = payload.Values.Values.ToList() + }; + Client.PublishAsync(device.DeviceName, JsonConvert.SerializeObject(tsData)); + } + + break; + } case IoTPlatformType.AliCloudIoT: case IoTPlatformType.TencentIoTHub: case IoTPlatformType.BaiduIoTCore: @@ -495,7 +516,7 @@ namespace Plugin break; } } - + foreach (var payload in SendModel[device.DeviceName]) { foreach (var kv in payload.Values) @@ -545,7 +566,7 @@ namespace Plugin } } - public async Task DeviceDisconnected(string DeviceName) + public async Task DeviceDisconnected(string DeviceName) { try { diff --git a/Plugins/PluginInterface/IotDB/IotTsData.cs b/Plugins/PluginInterface/IotDB/IotTsData.cs new file mode 100644 index 0000000..c048a0e --- /dev/null +++ b/Plugins/PluginInterface/IotDB/IotTsData.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PluginInterface.IotDB +{ + /// + /// IotDB时序数据库,测点数据json定义 + /// + public class IotTsData + { + public string device { get; set; } + public List measurements { get; set; } + public List values { get; set; } + public long timestamp { get; set; } + } +} diff --git a/Plugins/PluginInterface/PluginInterface.csproj b/Plugins/PluginInterface/PluginInterface.csproj index 933c8b2..4079917 100644 --- a/Plugins/PluginInterface/PluginInterface.csproj +++ b/Plugins/PluginInterface/PluginInterface.csproj @@ -1,4 +1,4 @@ - + net6.0