diff --git a/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 b/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 index 3af6b3d..e4617a7 100644 Binary files a/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 and b/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/IoTGateway/project-colors.json b/.vs/IoTGateway/project-colors.json index a8450a7..98c07dd 100644 --- a/.vs/IoTGateway/project-colors.json +++ b/.vs/IoTGateway/project-colors.json @@ -65,7 +65,17 @@ "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 } }, - "NextColorIndex": 12 + "NextColorIndex": 14 } \ No newline at end of file diff --git a/.vs/IoTGateway/v17/.futdcache.v1 b/.vs/IoTGateway/v17/.futdcache.v1 index 51ef064..9b4eb9f 100644 Binary files a/.vs/IoTGateway/v17/.futdcache.v1 and b/.vs/IoTGateway/v17/.futdcache.v1 differ diff --git a/.vs/IoTGateway/v17/.suo b/.vs/IoTGateway/v17/.suo index f4aa5d9..dc82b2e 100644 Binary files a/.vs/IoTGateway/v17/.suo and b/.vs/IoTGateway/v17/.suo differ diff --git a/.vs/IoTGateway/v17/fileList.bin b/.vs/IoTGateway/v17/fileList.bin index 621eee2..c86d8a3 100644 Binary files a/.vs/IoTGateway/v17/fileList.bin and b/.vs/IoTGateway/v17/fileList.bin differ diff --git a/Dockerfile b/Dockerfile index 413ba56..8d50774 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,8 +19,6 @@ COPY ["IoTGateway.Model/IoTGateway.Model.csproj", "IoTGateway.Model/"] COPY ["WalkingTec.Mvvm/WalkingTec.Mvvm.Core/WalkingTec.Mvvm.Core.csproj", "WalkingTec.Mvvm/WalkingTec.Mvvm.Core/"] COPY ["Plugins/PluginInterface/PluginInterface.csproj", "Plugins/PluginInterface/"] COPY ["IoTGateway.DataAccess/IoTGateway.DataAccess.csproj", "IoTGateway.DataAccess/"] -COPY ["Plugins/Drivers/DriverSiemensS7/DriverSiemensS7.csproj", "Plugins/Drivers/DriverSiemensS7/"] -COPY ["Plugins/Drivers/DriverModbusMaster/DriverModbusMaster.csproj", "Plugins/Drivers/DriverModbusMaster/"] COPY ["WalkingTec.Mvvm/WalkingTec.Mvvm.TagHelpers.LayUI/WalkingTec.Mvvm.TagHelpers.LayUI.csproj", "WalkingTec.Mvvm/WalkingTec.Mvvm.TagHelpers.LayUI/"] COPY ["WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/WalkingTec.Mvvm.Mvc.csproj", "WalkingTec.Mvvm/WalkingTec.Mvvm.Mvc/"] diff --git a/IoTGateway.DataAccess/Migrations/20211217052811_expression.Designer.cs b/IoTGateway.DataAccess/Migrations/20211217052811_expression.Designer.cs new file mode 100644 index 0000000..adad74f --- /dev/null +++ b/IoTGateway.DataAccess/Migrations/20211217052811_expression.Designer.cs @@ -0,0 +1,794 @@ +// +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("20211217052811_expression")] + partial class expression + { + 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("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/20211217052811_expression.cs b/IoTGateway.DataAccess/Migrations/20211217052811_expression.cs new file mode 100644 index 0000000..1c5b14b --- /dev/null +++ b/IoTGateway.DataAccess/Migrations/20211217052811_expression.cs @@ -0,0 +1,34 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace IoTGateway.DataAccess.Migrations +{ + public partial class expression : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ValueFactor", + table: "DeviceVariables"); + + migrationBuilder.AddColumn( + name: "Expressions", + table: "DeviceVariables", + type: "TEXT", + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Expressions", + table: "DeviceVariables"); + + migrationBuilder.AddColumn( + name: "ValueFactor", + table: "DeviceVariables", + type: "REAL", + nullable: false, + defaultValue: 0.0); + } + } +} diff --git a/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs b/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs index a624960..2734928 100644 --- a/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs +++ b/IoTGateway.DataAccess/Migrations/DataContextModelSnapshot.cs @@ -124,6 +124,9 @@ namespace IoTGateway.DataAccess.Migrations b.Property("DeviceId") .HasColumnType("TEXT"); + b.Property("Expressions") + .HasColumnType("TEXT"); + b.Property("Method") .HasColumnType("TEXT"); @@ -133,9 +136,6 @@ namespace IoTGateway.DataAccess.Migrations b.Property("ProtectType") .HasColumnType("INTEGER"); - b.Property("ValueFactor") - .HasColumnType("REAL"); - b.HasKey("ID"); b.HasIndex("DeviceId"); diff --git a/IoTGateway.Model/DeviceVariable.cs b/IoTGateway.Model/DeviceVariable.cs index 979ac72..544fe3f 100644 --- a/IoTGateway.Model/DeviceVariable.cs +++ b/IoTGateway.Model/DeviceVariable.cs @@ -19,11 +19,11 @@ namespace IoTGateway.Model [Display(Name = "地址")] public string DeviceAddress { get; set; } - [Display(Name = "数据类型")] + [Display(Name = "类型")] public PluginInterface.DataTypeEnum DataType { get; set; } - [Display(Name = "倍率")] - public double ValueFactor { get; set; } + [Display(Name = "表达式")] + public string Expressions { get; set; } [Display(Name = "权限")] public ProtectTypeEnum ProtectType { get; set; } diff --git a/IoTGateway.Model/IVariable.cs b/IoTGateway.Model/IVariable.cs index dbf9a32..b69920f 100644 --- a/IoTGateway.Model/IVariable.cs +++ b/IoTGateway.Model/IVariable.cs @@ -17,8 +17,8 @@ namespace IoTGateway.Model [Display(Name = "数据类型")] public PluginInterface.DataTypeEnum DataType { get; set; } - [Display(Name = "倍率")] - public double ValueFactor { get; set; } + [Display(Name = "表达式")] + public string Expressions { get; set; } [Display(Name = "权限")] public ProtectTypeEnum ProtectType { get; set; } diff --git a/IoTGateway.ViewModel/BasicData/DeviceVMs/CopyVM.cs b/IoTGateway.ViewModel/BasicData/DeviceVMs/CopyVM.cs index 165131f..16fde44 100644 --- a/IoTGateway.ViewModel/BasicData/DeviceVMs/CopyVM.cs +++ b/IoTGateway.ViewModel/BasicData/DeviceVMs/CopyVM.cs @@ -74,7 +74,7 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVMs DataType = deviceVariable.DataType, Method = deviceVariable.Method, ProtectType = deviceVariable.ProtectType, - ValueFactor = deviceVariable.ValueFactor, + Expressions = deviceVariable.Expressions, DeviceAddress = deviceVariable.DeviceAddress }; DC.Set().Add(newDeviceVariable); diff --git a/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableBatchVM.cs b/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableBatchVM.cs index 5b2ae97..0d8d2aa 100644 --- a/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableBatchVM.cs +++ b/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableBatchVM.cs @@ -53,8 +53,8 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVariableVMs public String DeviceAddress { get; set; } [Display(Name = "数据类型")] public DataTypeEnum? DataType { get; set; } - [Display(Name = "倍率")] - public Double? ValueFactor { get; set; } + [Display(Name = "表达式")] + public string Expression { get; set; } [Display(Name = "权限")] public ProtectTypeEnum? ProtectType { get; set; } diff --git a/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableImportVM.cs b/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableImportVM.cs index bafe895..4460fd6 100644 --- a/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableImportVM.cs +++ b/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableImportVM.cs @@ -23,8 +23,8 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVariableVMs public ExcelPropety DeviceAddress_Excel = ExcelPropety.CreateProperty(x => x.DeviceAddress); [Display(Name = "数据类型")] public ExcelPropety DataType_Excel = ExcelPropety.CreateProperty(x => x.DataType); - [Display(Name = "倍率")] - public ExcelPropety ValueFactor_Excel = ExcelPropety.CreateProperty(x => x.ValueFactor); + [Display(Name = "表达式")] + public ExcelPropety Expressions_Excel = ExcelPropety.CreateProperty(x => x.Expressions); [Display(Name = "权限")] public ExcelPropety ProtectType_Excel = ExcelPropety.CreateProperty(x => x.ProtectType); public ExcelPropety Device_Excel = ExcelPropety.CreateProperty(x => x.DeviceId); diff --git a/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableListVM.cs b/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableListVM.cs index 79f15eb..01f543b 100644 --- a/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableListVM.cs +++ b/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableListVM.cs @@ -50,20 +50,21 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVariableVMs protected override IEnumerable> InitGridHeader() { return new List>{ - this.MakeGridHeader(x => x.Name).SetSort(true).SetWidth(120), + this.MakeGridHeader(x => x.Name).SetSort(true).SetWidth(100), //this.MakeGridHeader(x => x.Description), this.MakeGridHeader(x => x.Method).SetSort(true).SetWidth(160), this.MakeGridHeader(x => x.DeviceAddress).SetSort(true).SetWidth(80), - this.MakeGridHeader(x => x.DataType).SetSort(true).SetWidth(110), + this.MakeGridHeader(x => x.DataType).SetSort(true).SetWidth(80), this.MakeGridHeader(x => x.Value).SetWidth(80), + this.MakeGridHeader(x => x.CookedValue).SetWidth(80), this.MakeGridHeader(x => x.State).SetWidth(80), - this.MakeGridHeader(x => x.ValueFactor).SetSort(true).SetWidth(80), + this.MakeGridHeader(x => x.Expressions).SetSort(true).SetWidth(80), //this.MakeGridHeader(x => x.ProtectType).SetSort(true), this.MakeGridHeader(x => x.DeviceName_view).SetSort(true).SetWidth(90), this.MakeGridHeader(x=> "detail").SetHide().SetFormat((a,b)=>{ return "false"; }), - this.MakeGridHeaderAction(width: 150) + this.MakeGridHeaderAction(width: 115) }; } @@ -76,6 +77,7 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVariableVMs if (DapThread?.DeviceValues != null && DapThread.DeviceValues.ContainsKey(item.ID)) { item.Value = DapThread.DeviceValues[item.ID].Value?.ToString(); + item.CookedValue = DapThread.DeviceValues[item.ID].CookedValue?.ToString(); item.State = DapThread.DeviceValues[item.ID].StatusType.ToString(); } } @@ -98,7 +100,7 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVariableVMs Method = x.Method, DeviceAddress = x.DeviceAddress, DataType = x.DataType, - ValueFactor = x.ValueFactor, + Expressions = x.Expressions, ProtectType = x.ProtectType, DeviceName_view = x.Device.DeviceName, }) @@ -112,8 +114,10 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVariableVMs { [Display(Name = "设备名")] public String DeviceName_view { get; set; } - [Display(Name = "值")] + [Display(Name = "原值")] public String Value { get; set; } + [Display(Name = "值")] + public String CookedValue { get; set; } [Display(Name = "状态")] public String State { get; set; } diff --git a/IoTGateway.ViewModel/MqttServer/MqttClientVMs/MqttClientListVM.cs b/IoTGateway.ViewModel/MqttServer/MqttClientVMs/MqttClientListVM.cs new file mode 100644 index 0000000..33d5226 --- /dev/null +++ b/IoTGateway.ViewModel/MqttServer/MqttClientVMs/MqttClientListVM.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using WalkingTec.Mvvm.Core; +using WalkingTec.Mvvm.Core.Extensions; +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; +using IoTGateway.Model; +using Microsoft.Extensions.Primitives; +using MQTTnet.Server; +using MQTTnet.Server.Status; +using MQTTnet.Formatter; + +namespace IoTGateway.ViewModel.MqttClient.MqttServerVMs +{ + public partial class MqttClientListVM : BasePagedListVM + { + protected override IEnumerable> InitGridHeader() + { + return new List>{ + this.MakeGridHeader(x => x.ClientId), + this.MakeGridHeader(x => x.Endpoint), + this.MakeGridHeader(x => x.ReceivedApplicationMessagesCount), + this.MakeGridHeader(x => x.SentApplicationMessagesCount), + this.MakeGridHeader(x => x.ReceivedPacketsCount), + this.MakeGridHeader(x => x.SentPacketsCount), + this.MakeGridHeader(x => x.BytesSent), + this.MakeGridHeader(x => x.BytesReceived), + this.MakeGridHeader(x => x.PendingApplicationMessagesCount), + this.MakeGridHeader(x => x.MqttProtocolVersion) + }; + } + + protected override void InitListVM() + { + base.InitListVM(); + } + protected override void InitVM() + { + base.InitVM(); + } + public override void AfterDoSearcher() + { + } + public override void DoSearch() + { + var mqttServer = Wtm.ServiceProvider.GetService(typeof(IMqttServer)) as IMqttServer; + foreach (var client in mqttServer.GetClientStatusAsync().Result) + { + MqttClient_View mqttClient_ = new MqttClient_View + { + ClientId = client.ClientId, + BytesReceived = client.BytesReceived, + BytesSent = client.BytesSent, + MqttProtocolVersion = client.ProtocolVersion, + ReceivedApplicationMessagesCount = client.ReceivedApplicationMessagesCount, + ReceivedPacketsCount = client.ReceivedPacketsCount, + SentApplicationMessagesCount = client.SentApplicationMessagesCount, + SentPacketsCount = client.SentPacketsCount, + PendingApplicationMessagesCount = client.Session.PendingApplicationMessagesCount + + }; + this.EntityList.Add(mqttClient_); + } + int i = 0; + } + } + public class MqttClient_View : TopBasePoco + { + [Display(Name = "客户端Id")] + public string ClientId { get; set; } + + [Display(Name = "Endpoint")] + public string Endpoint { get; set; } + + [Display(Name = "收消息数")] + public long ReceivedApplicationMessagesCount { get; set; } + + [Display(Name = "收发消息数")] + public long SentApplicationMessagesCount { get; set; } + + [Display(Name = "收包数")] + public long ReceivedPacketsCount { get; set; } + + [Display(Name = "发包数")] + public long SentPacketsCount { get; set; } + + [Display(Name = "发字节数")] + public long BytesSent { get; set; } + + [Display(Name = "收字节数")] + public long BytesReceived { get; set; } + + [Display(Name = "未决消息数")] + public long PendingApplicationMessagesCount { get; set; } + + [Display(Name = "协议版本")] + public MqttProtocolVersion MqttProtocolVersion { get; set; } + } + +} diff --git a/IoTGateway.ViewModel/MqttServer/MqttClientVMs/MqttClientSearcher.cs b/IoTGateway.ViewModel/MqttServer/MqttClientVMs/MqttClientSearcher.cs new file mode 100644 index 0000000..a9dcf54 --- /dev/null +++ b/IoTGateway.ViewModel/MqttServer/MqttClientVMs/MqttClientSearcher.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WalkingTec.Mvvm.Core; + +namespace IoTGateway.ViewModel.MqttClient.MqttServerVMs +{ + public partial class MqttClientSearcher: BaseSearcher + { + } +} diff --git a/IoTGateway/Areas/BasicData/Controllers/DeviceVariableController.cs b/IoTGateway/Areas/BasicData/Controllers/DeviceVariableController.cs index e75425c..91ac455 100644 --- a/IoTGateway/Areas/BasicData/Controllers/DeviceVariableController.cs +++ b/IoTGateway/Areas/BasicData/Controllers/DeviceVariableController.cs @@ -43,7 +43,6 @@ namespace IoTGateway.Controllers public ActionResult Create() { var vm = Wtm.CreateVM(); - vm.Entity.ValueFactor = 1; return PartialView(vm); } diff --git a/IoTGateway/Areas/BasicData/Views/DeviceVariable/BatchEdit.cshtml b/IoTGateway/Areas/BasicData/Views/DeviceVariable/BatchEdit.cshtml index 369cb94..6d1cc6d 100644 --- a/IoTGateway/Areas/BasicData/Views/DeviceVariable/BatchEdit.cshtml +++ b/IoTGateway/Areas/BasicData/Views/DeviceVariable/BatchEdit.cshtml @@ -7,7 +7,7 @@ - + diff --git a/IoTGateway/Areas/BasicData/Views/DeviceVariable/Create.cshtml b/IoTGateway/Areas/BasicData/Views/DeviceVariable/Create.cshtml index 0134ed4..7c6eba3 100644 --- a/IoTGateway/Areas/BasicData/Views/DeviceVariable/Create.cshtml +++ b/IoTGateway/Areas/BasicData/Views/DeviceVariable/Create.cshtml @@ -9,9 +9,10 @@ - + + 表达式可以进行简单的数学计算,其中raw为原值参与计算 diff --git a/IoTGateway/Areas/BasicData/Views/DeviceVariable/Delete.cshtml b/IoTGateway/Areas/BasicData/Views/DeviceVariable/Delete.cshtml index 1d0bb00..5450bd5 100644 --- a/IoTGateway/Areas/BasicData/Views/DeviceVariable/Delete.cshtml +++ b/IoTGateway/Areas/BasicData/Views/DeviceVariable/Delete.cshtml @@ -9,7 +9,7 @@ - + diff --git a/IoTGateway/Areas/BasicData/Views/DeviceVariable/Details.cshtml b/IoTGateway/Areas/BasicData/Views/DeviceVariable/Details.cshtml index cb60b25..5d8a4ce 100644 --- a/IoTGateway/Areas/BasicData/Views/DeviceVariable/Details.cshtml +++ b/IoTGateway/Areas/BasicData/Views/DeviceVariable/Details.cshtml @@ -8,7 +8,7 @@ - + diff --git a/IoTGateway/Areas/BasicData/Views/DeviceVariable/Edit.cshtml b/IoTGateway/Areas/BasicData/Views/DeviceVariable/Edit.cshtml index 7d35eed..d41a4d7 100644 --- a/IoTGateway/Areas/BasicData/Views/DeviceVariable/Edit.cshtml +++ b/IoTGateway/Areas/BasicData/Views/DeviceVariable/Edit.cshtml @@ -9,9 +9,10 @@ - + + 表达式可以进行简单的数学计算,其中raw为原值参与计算 diff --git a/IoTGateway/Areas/BasicData/Views/DeviceVariable/Index.cshtml b/IoTGateway/Areas/BasicData/Views/DeviceVariable/Index.cshtml index ccb0222..b3225a5 100644 --- a/IoTGateway/Areas/BasicData/Views/DeviceVariable/Index.cshtml +++ b/IoTGateway/Areas/BasicData/Views/DeviceVariable/Index.cshtml @@ -11,5 +11,5 @@ - + diff --git a/IoTGateway/Areas/MqttServer/Controllers/MqttClientController.cs b/IoTGateway/Areas/MqttServer/Controllers/MqttClientController.cs new file mode 100644 index 0000000..62ee527 --- /dev/null +++ b/IoTGateway/Areas/MqttServer/Controllers/MqttClientController.cs @@ -0,0 +1,46 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using WalkingTec.Mvvm.Core; +using WalkingTec.Mvvm.Mvc; +using WalkingTec.Mvvm.Core.Extensions; +using IoTGateway.ViewModel.BasicData.DeviceVMs; +using MQTTnet.Server; +using IoTGateway.ViewModel.MqttClient.MqttServerVMs; + +namespace IoTGateway.Controllers +{ + [Area("MqttServer")] + [ActionDescription("客户端状态")] + public partial class MqttClientController : BaseController + { + + #region Search + [ActionDescription("Sys.Search")] + public ActionResult Index() + { + var vm = Wtm.CreateVM(); + return PartialView(vm); + } + + [ActionDescription("Sys.Search")] + [HttpPost] + public string Search(MqttClientSearcher searcher) + { + var vm = Wtm.CreateVM(passInit: true); + if (ModelState.IsValid) + { + vm.Searcher = searcher; + return vm.GetJson(false); + } + else + { + return vm.GetError(); + } + } + #endregion + + + + } +} diff --git a/IoTGateway/Areas/MqttServer/Views/MqttClient/Index.cshtml b/IoTGateway/Areas/MqttServer/Views/MqttClient/Index.cshtml new file mode 100644 index 0000000..984357e --- /dev/null +++ b/IoTGateway/Areas/MqttServer/Views/MqttClient/Index.cshtml @@ -0,0 +1,7 @@ +@model IoTGateway.ViewModel.MqttClient.MqttServerVMs.MqttClientListVM +@inject IStringLocalizer Localizer; + + + + + diff --git a/IoTGateway/IoTGateway.csproj b/IoTGateway/IoTGateway.csproj index 9c1f322..f9281df 100644 --- a/IoTGateway/IoTGateway.csproj +++ b/IoTGateway/IoTGateway.csproj @@ -26,8 +26,6 @@ - - diff --git a/IoTGateway/iotgateway.db b/IoTGateway/iotgateway.db index 5335f6b..3226771 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 537ff64..6860169 100644 --- a/Plugins/Plugin/DeviceThread.cs +++ b/Plugins/Plugin/DeviceThread.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using IoTGateway.DataAccess; using IoTGateway.Model; using WalkingTec.Mvvm.Core; +using DynamicExpresso; namespace Plugin { @@ -21,6 +22,7 @@ namespace Plugin private Task task { get; set; } = null; private DateTime TsStartDt = new DateTime(1970, 1, 1); private CancellationTokenSource tokenSource = new CancellationTokenSource(); + private Interpreter interpreter = new Interpreter(); public DeviceThread(Device device, IDriver driver, string ProjectId, MyMqttClient myMqttClient) { @@ -80,15 +82,17 @@ namespace Plugin ret = (DriverReturnValueModel)method.Invoke(Driver, new object[1] { ioarg }); DeviceValues[item.ID] = ret; - if (!(item.ValueFactor == 1 || item.ValueFactor == 0)) - ret.Value = ret.Value == null ? null : double.Parse(ret.Value?.ToString()) * item.ValueFactor; + if (ret.StatusType == VaribaleStatusTypeEnum.Good && !string.IsNullOrWhiteSpace(item.Expressions?.Trim())) + ret.CookedValue = interpreter.Eval(item.Expressions.Replace("raw", ret.Value.ToString())); + else + ret.CookedValue = ret.Value; if (ret.StatusType == VaribaleStatusTypeEnum.Bad) Console.WriteLine(Driver.Connect()); - payLoad.Values[item.Name] = ret.Value; + payLoad.Values[item.Name] = ret.CookedValue; } - payLoad.TS = (long)(DateTime.Now- TsStartDt).TotalMilliseconds; + payLoad.TS = (long)(DateTime.Now - TsStartDt).TotalMilliseconds; if (DeviceValues.Any(x => x.Value.StatusType != VaribaleStatusTypeEnum.Good)) { diff --git a/Plugins/Plugin/Plugin.csproj b/Plugins/Plugin/Plugin.csproj index 630c7d0..c3d0565 100644 --- a/Plugins/Plugin/Plugin.csproj +++ b/Plugins/Plugin/Plugin.csproj @@ -5,6 +5,7 @@ + diff --git a/Plugins/PluginInterface/DriverReturnValueModel.cs b/Plugins/PluginInterface/DriverReturnValueModel.cs index 726201c..e3a4fbe 100644 --- a/Plugins/PluginInterface/DriverReturnValueModel.cs +++ b/Plugins/PluginInterface/DriverReturnValueModel.cs @@ -9,6 +9,7 @@ namespace PluginInterface public class DriverReturnValueModel { public object Value { get; set; } + public object CookedValue { get; set; } public string Message { get; set; } public VaribaleStatusTypeEnum StatusType { get; set; } } diff --git a/appsettings.json b/appsettings.json index ca8a8bb..d1541c9 100644 --- a/appsettings.json +++ b/appsettings.json @@ -14,7 +14,7 @@ }, "WTM": { "LogLevel": { - "Default": "Error" + "Default": "Information" } } },