通过Mqtt 方式将数据写入IotDB
This commit is contained in:
parent
c86a8248d1
commit
0a5c546053
1
.gitignore
vendored
1
.gitignore
vendored
@ -18,3 +18,4 @@ bin-release/
|
||||
# information for Eclipse / Flash Builder.
|
||||
/LK/appsettings.json
|
||||
/LK/appsettings.json
|
||||
/.vs
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -33,6 +33,8 @@ namespace IoTGateway.Model
|
||||
[Display(Name = "中移OneNet")]
|
||||
OneNET = 5,
|
||||
[Display(Name = "ThingsCloud")]
|
||||
ThingsCloud = 6
|
||||
ThingsCloud = 6,
|
||||
[Display(Name = "IotDB")]
|
||||
IotDB = 99
|
||||
}
|
||||
}
|
Binary file not shown.
BIN
IoTGateway/iotgateway.db-shm
Normal file
BIN
IoTGateway/iotgateway.db-shm
Normal file
Binary file not shown.
BIN
IoTGateway/iotgateway.db-wal
Normal file
BIN
IoTGateway/iotgateway.db-wal
Normal file
Binary file not shown.
@ -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<TBRpcRequest>(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
|
||||
{
|
||||
|
19
Plugins/PluginInterface/IotDB/IotTsData.cs
Normal file
19
Plugins/PluginInterface/IotDB/IotTsData.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PluginInterface.IotDB
|
||||
{
|
||||
/// <summary>
|
||||
/// IotDB时序数据库,测点数据json定义
|
||||
/// </summary>
|
||||
public class IotTsData
|
||||
{
|
||||
public string device { get; set; }
|
||||
public List<string> measurements { get; set; }
|
||||
public List<object> values { get; set; }
|
||||
public long timestamp { get; set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
Loading…
Reference in New Issue
Block a user