diff --git a/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 b/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2
index 2a9d283..4c6cf33 100644
Binary files a/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 and b/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 differ
diff --git a/.vs/IoTGateway/v16/.suo b/.vs/IoTGateway/v16/.suo
index 6163207..5ff1237 100644
Binary files a/.vs/IoTGateway/v16/.suo and b/.vs/IoTGateway/v16/.suo differ
diff --git a/IoTGateway.DataAccess/Migrations/20211220151947_disperse.Designer.cs b/IoTGateway.DataAccess/Migrations/20211220151947_disperse.Designer.cs
new file mode 100644
index 0000000..d1123a1
--- /dev/null
+++ b/IoTGateway.DataAccess/Migrations/20211220151947_disperse.Designer.cs
@@ -0,0 +1,797 @@
+//
+using System;
+using IoTGateway.DataAccess;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace IoTGateway.DataAccess.Migrations
+{
+ [DbContext(typeof(DataContext))]
+ [Migration("20211220151947_disperse")]
+ partial class disperse
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "5.0.9");
+
+ modelBuilder.Entity("IoTGateway.Model.Device", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("AutoStart")
+ .HasColumnType("INTEGER");
+
+ b.Property("CreateBy")
+ .HasColumnType("TEXT");
+
+ b.Property("CreateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("Description")
+ .HasColumnType("TEXT");
+
+ b.Property("DeviceName")
+ .HasColumnType("TEXT");
+
+ b.Property("DeviceTypeEnum")
+ .HasColumnType("INTEGER");
+
+ b.Property("DriverId")
+ .HasColumnType("TEXT");
+
+ b.Property("Index")
+ .HasColumnType("INTEGER");
+
+ b.Property("ParentId")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateBy")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateTime")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.HasIndex("DriverId");
+
+ b.HasIndex("ParentId");
+
+ b.ToTable("Devices");
+ });
+
+ modelBuilder.Entity("IoTGateway.Model.DeviceConfig", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("CreateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("CreateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("Description")
+ .HasColumnType("TEXT");
+
+ b.Property("DeviceConfigName")
+ .HasColumnType("TEXT");
+
+ b.Property("DeviceId")
+ .HasColumnType("TEXT");
+
+ b.Property("EnumInfo")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("Value")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.HasIndex("DeviceId");
+
+ b.ToTable("DeviceConfigs");
+ });
+
+ modelBuilder.Entity("IoTGateway.Model.DeviceVariable", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("DataType")
+ .HasColumnType("INTEGER");
+
+ b.Property("Description")
+ .HasColumnType("TEXT");
+
+ b.Property("DeviceAddress")
+ .HasColumnType("TEXT");
+
+ b.Property("DeviceId")
+ .HasColumnType("TEXT");
+
+ b.Property("Expressions")
+ .HasColumnType("TEXT");
+
+ b.Property("Method")
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .HasColumnType("TEXT");
+
+ b.Property("ProtectType")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("ID");
+
+ b.HasIndex("DeviceId");
+
+ b.ToTable("DeviceVariables");
+ });
+
+ modelBuilder.Entity("IoTGateway.Model.Driver", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("AssembleName")
+ .HasColumnType("TEXT");
+
+ b.Property("AuthorizesNum")
+ .HasColumnType("INTEGER");
+
+ b.Property("CreateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("CreateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("DriverName")
+ .HasColumnType("TEXT");
+
+ b.Property("FileName")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateTime")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.ToTable("Drivers");
+ });
+
+ modelBuilder.Entity("IoTGateway.Model.SystemConfig", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("CreateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("CreateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("Disperse")
+ .HasColumnType("INTEGER");
+
+ b.Property("GatewayName")
+ .HasColumnType("TEXT");
+
+ b.Property("MqttIp")
+ .HasColumnType("TEXT");
+
+ b.Property("MqttPort")
+ .HasColumnType("INTEGER");
+
+ b.Property("MqttUName")
+ .HasColumnType("TEXT");
+
+ b.Property("MqttUPwd")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateTime")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.ToTable("SystemConfig");
+ });
+
+ modelBuilder.Entity("WalkingTec.Mvvm.Core.ActionLog", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("ActionName")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("ActionTime")
+ .HasColumnType("TEXT");
+
+ b.Property("ActionUrl")
+ .HasMaxLength(250)
+ .HasColumnType("TEXT");
+
+ b.Property("CreateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("CreateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("Duration")
+ .HasColumnType("REAL");
+
+ b.Property("IP")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("ITCode")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("LogType")
+ .HasColumnType("INTEGER");
+
+ b.Property("ModuleName")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("Remark")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateTime")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.ToTable("ActionLogs");
+ });
+
+ modelBuilder.Entity("WalkingTec.Mvvm.Core.DataPrivilege", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("CreateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("CreateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("Domain")
+ .HasColumnType("TEXT");
+
+ b.Property("GroupCode")
+ .HasColumnType("TEXT");
+
+ b.Property("RelateId")
+ .HasColumnType("TEXT");
+
+ b.Property("TableName")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("UserCode")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.ToTable("DataPrivileges");
+ });
+
+ modelBuilder.Entity("WalkingTec.Mvvm.Core.FileAttachment", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("ExtraInfo")
+ .HasColumnType("TEXT");
+
+ b.Property("FileData")
+ .HasColumnType("BLOB");
+
+ b.Property("FileExt")
+ .IsRequired()
+ .HasMaxLength(10)
+ .HasColumnType("TEXT");
+
+ b.Property("FileName")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("HandlerInfo")
+ .HasColumnType("TEXT");
+
+ b.Property("Length")
+ .HasColumnType("INTEGER");
+
+ b.Property("Path")
+ .HasColumnType("TEXT");
+
+ b.Property("SaveMode")
+ .HasColumnType("TEXT");
+
+ b.Property("UploadTime")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.ToTable("FileAttachments");
+ });
+
+ modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkGroup", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("CreateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("CreateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("GroupCode")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("TEXT");
+
+ b.Property("GroupName")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("GroupRemark")
+ .HasColumnType("TEXT");
+
+ b.Property("TenantCode")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateTime")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.ToTable("FrameworkGroups");
+ });
+
+ modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkMenu", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("ActionName")
+ .HasColumnType("TEXT");
+
+ b.Property("ClassName")
+ .HasColumnType("TEXT");
+
+ b.Property("DisplayOrder")
+ .IsRequired()
+ .HasColumnType("INTEGER");
+
+ b.Property("Domain")
+ .HasColumnType("TEXT");
+
+ b.Property("FolderOnly")
+ .HasColumnType("INTEGER");
+
+ b.Property("Icon")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("IsInherit")
+ .HasColumnType("INTEGER");
+
+ b.Property("IsInside")
+ .IsRequired()
+ .HasColumnType("INTEGER");
+
+ b.Property("IsPublic")
+ .HasColumnType("INTEGER");
+
+ b.Property("MethodName")
+ .HasColumnType("TEXT");
+
+ b.Property("ModuleName")
+ .HasColumnType("TEXT");
+
+ b.Property("PageName")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("ParentId")
+ .HasColumnType("TEXT");
+
+ b.Property("ShowOnMenu")
+ .HasColumnType("INTEGER");
+
+ b.Property("Url")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.HasIndex("ParentId");
+
+ b.ToTable("FrameworkMenus");
+ });
+
+ modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkRole", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("CreateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("CreateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("RoleCode")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("TEXT");
+
+ b.Property("RoleName")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("RoleRemark")
+ .HasColumnType("TEXT");
+
+ b.Property("TenantCode")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateTime")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.ToTable("FrameworkRoles");
+ });
+
+ modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkUser", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("Address")
+ .HasMaxLength(200)
+ .HasColumnType("TEXT");
+
+ b.Property("CellPhone")
+ .HasColumnType("TEXT");
+
+ b.Property("CreateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("CreateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("Email")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("Gender")
+ .HasColumnType("INTEGER");
+
+ b.Property("HomePhone")
+ .HasMaxLength(30)
+ .HasColumnType("TEXT");
+
+ b.Property("ITCode")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("IsValid")
+ .HasColumnType("INTEGER");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasMaxLength(32)
+ .HasColumnType("TEXT");
+
+ b.Property("PhotoId")
+ .HasColumnType("TEXT");
+
+ b.Property("TenantCode")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("ZipCode")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.HasIndex("PhotoId");
+
+ b.ToTable("FrameworkUsers");
+ });
+
+ modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkUserGroup", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("CreateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("CreateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("GroupCode")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("UserCode")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.ToTable("FrameworkUserGroups");
+ });
+
+ modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkUserRole", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("CreateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("CreateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("RoleCode")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("UserCode")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.ToTable("FrameworkUserRoles");
+ });
+
+ modelBuilder.Entity("WalkingTec.Mvvm.Core.FunctionPrivilege", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("Allowed")
+ .IsRequired()
+ .HasColumnType("INTEGER");
+
+ b.Property("CreateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("CreateTime")
+ .HasColumnType("TEXT");
+
+ b.Property("MenuItemId")
+ .HasColumnType("TEXT");
+
+ b.Property("RoleCode")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateBy")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdateTime")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.HasIndex("MenuItemId");
+
+ b.ToTable("FunctionPrivileges");
+ });
+
+ modelBuilder.Entity("WalkingTec.Mvvm.Core.PersistedGrant", b =>
+ {
+ b.Property("ID")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("CreationTime")
+ .HasColumnType("TEXT");
+
+ b.Property("Expiration")
+ .HasColumnType("TEXT");
+
+ b.Property("RefreshToken")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("Type")
+ .HasMaxLength(50)
+ .HasColumnType("TEXT");
+
+ b.Property("UserCode")
+ .HasColumnType("TEXT");
+
+ b.HasKey("ID");
+
+ b.ToTable("PersistedGrants");
+ });
+
+ modelBuilder.Entity("IoTGateway.Model.Device", b =>
+ {
+ b.HasOne("IoTGateway.Model.Driver", "Driver")
+ .WithMany()
+ .HasForeignKey("DriverId");
+
+ b.HasOne("IoTGateway.Model.Device", "Parent")
+ .WithMany("Children")
+ .HasForeignKey("ParentId");
+
+ b.Navigation("Driver");
+
+ b.Navigation("Parent");
+ });
+
+ modelBuilder.Entity("IoTGateway.Model.DeviceConfig", b =>
+ {
+ b.HasOne("IoTGateway.Model.Device", "Device")
+ .WithMany("DeviceConfigs")
+ .HasForeignKey("DeviceId");
+
+ b.Navigation("Device");
+ });
+
+ modelBuilder.Entity("IoTGateway.Model.DeviceVariable", b =>
+ {
+ b.HasOne("IoTGateway.Model.Device", "Device")
+ .WithMany("DeviceVariables")
+ .HasForeignKey("DeviceId");
+
+ b.Navigation("Device");
+ });
+
+ modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkMenu", b =>
+ {
+ b.HasOne("WalkingTec.Mvvm.Core.FrameworkMenu", "Parent")
+ .WithMany("Children")
+ .HasForeignKey("ParentId");
+
+ b.Navigation("Parent");
+ });
+
+ modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkUser", b =>
+ {
+ b.HasOne("WalkingTec.Mvvm.Core.FileAttachment", "Photo")
+ .WithMany()
+ .HasForeignKey("PhotoId")
+ .OnDelete(DeleteBehavior.Restrict);
+
+ b.Navigation("Photo");
+ });
+
+ modelBuilder.Entity("WalkingTec.Mvvm.Core.FunctionPrivilege", b =>
+ {
+ b.HasOne("WalkingTec.Mvvm.Core.FrameworkMenu", "MenuItem")
+ .WithMany("Privileges")
+ .HasForeignKey("MenuItemId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("MenuItem");
+ });
+
+ modelBuilder.Entity("IoTGateway.Model.Device", b =>
+ {
+ b.Navigation("Children");
+
+ b.Navigation("DeviceConfigs");
+
+ b.Navigation("DeviceVariables");
+ });
+
+ modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkMenu", b =>
+ {
+ b.Navigation("Children");
+
+ b.Navigation("Privileges");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/IoTGateway.DataAccess/Migrations/20211220151947_disperse.cs b/IoTGateway.DataAccess/Migrations/20211220151947_disperse.cs
new file mode 100644
index 0000000..23d8451
--- /dev/null
+++ b/IoTGateway.DataAccess/Migrations/20211220151947_disperse.cs
@@ -0,0 +1,24 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace IoTGateway.DataAccess.Migrations
+{
+ public partial class disperse : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "Disperse",
+ table: "SystemConfig",
+ type: "INTEGER",
+ nullable: false,
+ defaultValue: false);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "Disperse",
+ table: "SystemConfig");
+ }
+ }
+}
diff --git a/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs b/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs
index 2734928..ff4c994 100644
--- a/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs
+++ b/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs
@@ -193,6 +193,9 @@ namespace IoTGateway.DataAccess.Migrations
b.Property("CreateTime")
.HasColumnType("TEXT");
+ b.Property("Disperse")
+ .HasColumnType("INTEGER");
+
b.Property("GatewayName")
.HasColumnType("TEXT");
diff --git a/IoTGateway.Model/SystemConfig.cs b/IoTGateway.Model/SystemConfig.cs
index 07dc854..ad68b9e 100644
--- a/IoTGateway.Model/SystemConfig.cs
+++ b/IoTGateway.Model/SystemConfig.cs
@@ -15,5 +15,7 @@ namespace IoTGateway.Model
public string MqttUName { get; set; }
[Display(Name = "Mqtt密码")]
public string MqttUPwd { get; set; }
+ [Display(Name = "离散输出")]
+ public bool Disperse { get; set; }
}
}
\ No newline at end of file
diff --git a/IoTGateway.ViewModel/Config/SystemConfigVMs/SystemConfigListVM.cs b/IoTGateway.ViewModel/Config/SystemConfigVMs/SystemConfigListVM.cs
index 77ab872..c7cf5c5 100644
--- a/IoTGateway.ViewModel/Config/SystemConfigVMs/SystemConfigListVM.cs
+++ b/IoTGateway.ViewModel/Config/SystemConfigVMs/SystemConfigListVM.cs
@@ -37,6 +37,7 @@ namespace IoTGateway.ViewModel.Config.SystemConfigVMs
this.MakeGridHeader(x => x.MqttPort),
this.MakeGridHeader(x => x.MqttUName),
this.MakeGridHeader(x => x.MqttUPwd),
+ this.MakeGridHeader(x => x.Disperse),
this.MakeGridHeaderAction(width: 200)
};
}
@@ -52,6 +53,7 @@ namespace IoTGateway.ViewModel.Config.SystemConfigVMs
MqttPort = x.MqttPort,
MqttUName = x.MqttUName,
MqttUPwd = x.MqttUPwd,
+ Disperse = x.Disperse,
})
.OrderBy(x => x.ID);
return query;
diff --git a/IoTGateway/Areas/Config/Views/SystemConfig/Edit.cshtml b/IoTGateway/Areas/Config/Views/SystemConfig/Edit.cshtml
index 2acf3ab..e8c410f 100644
--- a/IoTGateway/Areas/Config/Views/SystemConfig/Edit.cshtml
+++ b/IoTGateway/Areas/Config/Views/SystemConfig/Edit.cshtml
@@ -2,13 +2,15 @@
@inject IStringLocalizer Localizer;
-
-
-
-
-
-
-
+ 注意:tb只能使用非离散输出模式,否则平台无法解析
+
+
+
+
+
+
+
+
diff --git a/IoTGateway/Areas/Config/Views/SystemConfig/Index.cshtml b/IoTGateway/Areas/Config/Views/SystemConfig/Index.cshtml
index 6eee90f..9d0e60b 100644
--- a/IoTGateway/Areas/Config/Views/SystemConfig/Index.cshtml
+++ b/IoTGateway/Areas/Config/Views/SystemConfig/Index.cshtml
@@ -2,7 +2,8 @@
@inject IStringLocalizer Localizer;
-
-
+
+
-
+注意:tb只能使用非离散输出模式,否则平台无法解析
+
diff --git a/IoTGateway/iotgateway.db b/IoTGateway/iotgateway.db
index 629522e..9deebb0 100644
Binary files a/IoTGateway/iotgateway.db and b/IoTGateway/iotgateway.db differ
diff --git a/Plugins/Plugin/DeviceThread.cs b/Plugins/Plugin/DeviceThread.cs
index dbe013c..5476241 100644
--- a/Plugins/Plugin/DeviceThread.cs
+++ b/Plugins/Plugin/DeviceThread.cs
@@ -113,7 +113,7 @@ namespace Plugin
{
payLoad.DeviceStatus = DeviceStatusTypeEnum.Good;
sendModel[Device.DeviceName] = new List { payLoad };
- myMqttClient.Publish("v1/gateway/telemetry", sendModel);
+ myMqttClient.Publish(Device,sendModel);
}
}
diff --git a/Plugins/Plugin/MyMqttClient.cs b/Plugins/Plugin/MyMqttClient.cs
index a11274f..2e3cbc9 100644
--- a/Plugins/Plugin/MyMqttClient.cs
+++ b/Plugins/Plugin/MyMqttClient.cs
@@ -21,6 +21,7 @@ namespace Plugin
{
private static IMqttClient _mqttClient = null;
private static MqttClientOptionsBuilder builder = null;
+ private SystemConfig systemConfig = null;
public MyMqttClient()
{
InitClient();
@@ -34,8 +35,8 @@ namespace Plugin
using (var DC = new DataContext(IoTBackgroundService.connnectSetting, IoTBackgroundService.DBType))
{
- var systemManage = DC.Set().FirstOrDefault();
- if (systemManage == null)
+ systemConfig = DC.Set().FirstOrDefault();
+ if (systemConfig == null)
Console.WriteLine("配置信息错误,无法启动");
else
{
@@ -46,9 +47,9 @@ namespace Plugin
builder = new MqttClientOptionsBuilder()
.WithCommunicationTimeout(TimeSpan.FromSeconds(60))
.WithKeepAlivePeriod(TimeSpan.FromSeconds(20))
- .WithTcpServer(systemManage.MqttIp, systemManage.MqttPort)
- .WithClientId(systemManage.MqttUName + Guid.NewGuid().ToString())
- .WithCredentials(systemManage.MqttUName, systemManage.MqttUPwd);
+ .WithTcpServer(systemConfig.MqttIp, systemConfig.MqttPort)
+ .WithClientId(systemConfig.MqttUName + Guid.NewGuid().ToString())
+ .WithCredentials(systemConfig.MqttUName, systemConfig.MqttUPwd);
_mqttClient.ConnectAsync(builder.Build());
}
@@ -58,12 +59,32 @@ namespace Plugin
{
}
-
+
}
- public void Publish(string Topic, Dictionary> SendModel)
+ public void Publish(Device device, Dictionary> SendModel)
{
- _mqttClient.PublishAsync(Topic, JsonConvert.SerializeObject(SendModel));
+ try
+ {
+ string TopicBase = "v1/gateway/telemetry";
+ if (!systemConfig.Disperse)
+ _mqttClient.PublishAsync(TopicBase, JsonConvert.SerializeObject(SendModel));
+ else
+ {
+ foreach (var payload in SendModel[device.DeviceName])
+ {
+ foreach (var kv in payload.Values)
+ {
+ _mqttClient.PublishAsync($"{TopicBase}/{device.DeviceName}/{kv.Key}", kv.Value.ToString());
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+
+ }
+
}
private void OnReceived(MqttApplicationMessageReceivedEventArgs obj)