1.集成MqttServer,可查看当前客户端列表 2.增加表达式

This commit is contained in:
dd 2021-12-17 15:51:25 +08:00
parent 570c1a613c
commit f71b582da4
32 changed files with 1049 additions and 36 deletions

View File

@ -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
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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/"]

View File

@ -0,0 +1,794 @@
// <auto-generated />
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<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<bool>("AutoStart")
.HasColumnType("INTEGER");
b.Property<string>("CreateBy")
.HasColumnType("TEXT");
b.Property<DateTime?>("CreateTime")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasColumnType("TEXT");
b.Property<string>("DeviceName")
.HasColumnType("TEXT");
b.Property<int>("DeviceTypeEnum")
.HasColumnType("INTEGER");
b.Property<Guid?>("DriverId")
.HasColumnType("TEXT");
b.Property<uint>("Index")
.HasColumnType("INTEGER");
b.Property<Guid?>("ParentId")
.HasColumnType("TEXT");
b.Property<string>("UpdateBy")
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("TEXT");
b.HasKey("ID");
b.HasIndex("DriverId");
b.HasIndex("ParentId");
b.ToTable("Devices");
});
modelBuilder.Entity("IoTGateway.Model.DeviceConfig", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("CreateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("CreateTime")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasColumnType("TEXT");
b.Property<string>("DeviceConfigName")
.HasColumnType("TEXT");
b.Property<Guid?>("DeviceId")
.HasColumnType("TEXT");
b.Property<string>("EnumInfo")
.HasColumnType("TEXT");
b.Property<string>("UpdateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("TEXT");
b.Property<string>("Value")
.HasColumnType("TEXT");
b.HasKey("ID");
b.HasIndex("DeviceId");
b.ToTable("DeviceConfigs");
});
modelBuilder.Entity("IoTGateway.Model.DeviceVariable", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<int>("DataType")
.HasColumnType("INTEGER");
b.Property<string>("Description")
.HasColumnType("TEXT");
b.Property<string>("DeviceAddress")
.HasColumnType("TEXT");
b.Property<Guid?>("DeviceId")
.HasColumnType("TEXT");
b.Property<string>("Expressions")
.HasColumnType("TEXT");
b.Property<string>("Method")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<int>("ProtectType")
.HasColumnType("INTEGER");
b.HasKey("ID");
b.HasIndex("DeviceId");
b.ToTable("DeviceVariables");
});
modelBuilder.Entity("IoTGateway.Model.Driver", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("AssembleName")
.HasColumnType("TEXT");
b.Property<int>("AuthorizesNum")
.HasColumnType("INTEGER");
b.Property<string>("CreateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("CreateTime")
.HasColumnType("TEXT");
b.Property<string>("DriverName")
.HasColumnType("TEXT");
b.Property<string>("FileName")
.HasColumnType("TEXT");
b.Property<string>("UpdateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("Drivers");
});
modelBuilder.Entity("IoTGateway.Model.SystemConfig", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("CreateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("CreateTime")
.HasColumnType("TEXT");
b.Property<string>("GatewayName")
.HasColumnType("TEXT");
b.Property<string>("MqttIp")
.HasColumnType("TEXT");
b.Property<int>("MqttPort")
.HasColumnType("INTEGER");
b.Property<string>("MqttUName")
.HasColumnType("TEXT");
b.Property<string>("MqttUPwd")
.HasColumnType("TEXT");
b.Property<string>("UpdateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("SystemConfig");
});
modelBuilder.Entity("WalkingTec.Mvvm.Core.ActionLog", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("ActionName")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<DateTime>("ActionTime")
.HasColumnType("TEXT");
b.Property<string>("ActionUrl")
.HasMaxLength(250)
.HasColumnType("TEXT");
b.Property<string>("CreateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("CreateTime")
.HasColumnType("TEXT");
b.Property<double>("Duration")
.HasColumnType("REAL");
b.Property<string>("IP")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("ITCode")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<int>("LogType")
.HasColumnType("INTEGER");
b.Property<string>("ModuleName")
.HasMaxLength(255)
.HasColumnType("TEXT");
b.Property<string>("Remark")
.HasColumnType("TEXT");
b.Property<string>("UpdateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("ActionLogs");
});
modelBuilder.Entity("WalkingTec.Mvvm.Core.DataPrivilege", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("CreateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("CreateTime")
.HasColumnType("TEXT");
b.Property<string>("Domain")
.HasColumnType("TEXT");
b.Property<string>("GroupCode")
.HasColumnType("TEXT");
b.Property<string>("RelateId")
.HasColumnType("TEXT");
b.Property<string>("TableName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("UpdateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("TEXT");
b.Property<string>("UserCode")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("DataPrivileges");
});
modelBuilder.Entity("WalkingTec.Mvvm.Core.FileAttachment", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("ExtraInfo")
.HasColumnType("TEXT");
b.Property<byte[]>("FileData")
.HasColumnType("BLOB");
b.Property<string>("FileExt")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("TEXT");
b.Property<string>("FileName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("HandlerInfo")
.HasColumnType("TEXT");
b.Property<long>("Length")
.HasColumnType("INTEGER");
b.Property<string>("Path")
.HasColumnType("TEXT");
b.Property<string>("SaveMode")
.HasColumnType("TEXT");
b.Property<DateTime>("UploadTime")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("FileAttachments");
});
modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkGroup", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("CreateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("CreateTime")
.HasColumnType("TEXT");
b.Property<string>("GroupCode")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("GroupName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("GroupRemark")
.HasColumnType("TEXT");
b.Property<string>("TenantCode")
.HasColumnType("TEXT");
b.Property<string>("UpdateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("FrameworkGroups");
});
modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkMenu", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("ActionName")
.HasColumnType("TEXT");
b.Property<string>("ClassName")
.HasColumnType("TEXT");
b.Property<int?>("DisplayOrder")
.IsRequired()
.HasColumnType("INTEGER");
b.Property<string>("Domain")
.HasColumnType("TEXT");
b.Property<bool>("FolderOnly")
.HasColumnType("INTEGER");
b.Property<string>("Icon")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<bool>("IsInherit")
.HasColumnType("INTEGER");
b.Property<bool?>("IsInside")
.IsRequired()
.HasColumnType("INTEGER");
b.Property<bool>("IsPublic")
.HasColumnType("INTEGER");
b.Property<string>("MethodName")
.HasColumnType("TEXT");
b.Property<string>("ModuleName")
.HasColumnType("TEXT");
b.Property<string>("PageName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<Guid?>("ParentId")
.HasColumnType("TEXT");
b.Property<bool>("ShowOnMenu")
.HasColumnType("INTEGER");
b.Property<string>("Url")
.HasColumnType("TEXT");
b.HasKey("ID");
b.HasIndex("ParentId");
b.ToTable("FrameworkMenus");
});
modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkRole", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("CreateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("CreateTime")
.HasColumnType("TEXT");
b.Property<string>("RoleCode")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("RoleName")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("RoleRemark")
.HasColumnType("TEXT");
b.Property<string>("TenantCode")
.HasColumnType("TEXT");
b.Property<string>("UpdateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("FrameworkRoles");
});
modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkUser", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("Address")
.HasMaxLength(200)
.HasColumnType("TEXT");
b.Property<string>("CellPhone")
.HasColumnType("TEXT");
b.Property<string>("CreateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("CreateTime")
.HasColumnType("TEXT");
b.Property<string>("Email")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<int?>("Gender")
.HasColumnType("INTEGER");
b.Property<string>("HomePhone")
.HasMaxLength(30)
.HasColumnType("TEXT");
b.Property<string>("ITCode")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<bool>("IsValid")
.HasColumnType("INTEGER");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(32)
.HasColumnType("TEXT");
b.Property<Guid?>("PhotoId")
.HasColumnType("TEXT");
b.Property<string>("TenantCode")
.HasColumnType("TEXT");
b.Property<string>("UpdateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("TEXT");
b.Property<string>("ZipCode")
.HasColumnType("TEXT");
b.HasKey("ID");
b.HasIndex("PhotoId");
b.ToTable("FrameworkUsers");
});
modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkUserGroup", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("CreateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("CreateTime")
.HasColumnType("TEXT");
b.Property<string>("GroupCode")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("UpdateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("TEXT");
b.Property<string>("UserCode")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("FrameworkUserGroups");
});
modelBuilder.Entity("WalkingTec.Mvvm.Core.FrameworkUserRole", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<string>("CreateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("CreateTime")
.HasColumnType("TEXT");
b.Property<string>("RoleCode")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("UpdateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("TEXT");
b.Property<string>("UserCode")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ID");
b.ToTable("FrameworkUserRoles");
});
modelBuilder.Entity("WalkingTec.Mvvm.Core.FunctionPrivilege", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<bool?>("Allowed")
.IsRequired()
.HasColumnType("INTEGER");
b.Property<string>("CreateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("CreateTime")
.HasColumnType("TEXT");
b.Property<Guid>("MenuItemId")
.HasColumnType("TEXT");
b.Property<string>("RoleCode")
.HasColumnType("TEXT");
b.Property<string>("UpdateBy")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("TEXT");
b.HasKey("ID");
b.HasIndex("MenuItemId");
b.ToTable("FunctionPrivileges");
});
modelBuilder.Entity("WalkingTec.Mvvm.Core.PersistedGrant", b =>
{
b.Property<Guid>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<DateTime>("CreationTime")
.HasColumnType("TEXT");
b.Property<DateTime>("Expiration")
.HasColumnType("TEXT");
b.Property<string>("RefreshToken")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Type")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("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
}
}
}

View File

@ -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<string>(
name: "Expressions",
table: "DeviceVariables",
type: "TEXT",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Expressions",
table: "DeviceVariables");
migrationBuilder.AddColumn<double>(
name: "ValueFactor",
table: "DeviceVariables",
type: "REAL",
nullable: false,
defaultValue: 0.0);
}
}
}

View File

@ -124,6 +124,9 @@ namespace IoTGateway.DataAccess.Migrations
b.Property<Guid?>("DeviceId")
.HasColumnType("TEXT");
b.Property<string>("Expressions")
.HasColumnType("TEXT");
b.Property<string>("Method")
.HasColumnType("TEXT");
@ -133,9 +136,6 @@ namespace IoTGateway.DataAccess.Migrations
b.Property<int>("ProtectType")
.HasColumnType("INTEGER");
b.Property<double>("ValueFactor")
.HasColumnType("REAL");
b.HasKey("ID");
b.HasIndex("DeviceId");

View File

@ -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; }

View File

@ -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; }

View File

@ -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<DeviceVariable>().Add(newDeviceVariable);

View File

@ -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; }

View File

@ -23,8 +23,8 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVariableVMs
public ExcelPropety DeviceAddress_Excel = ExcelPropety.CreateProperty<DeviceVariable>(x => x.DeviceAddress);
[Display(Name = "数据类型")]
public ExcelPropety DataType_Excel = ExcelPropety.CreateProperty<DeviceVariable>(x => x.DataType);
[Display(Name = "倍率")]
public ExcelPropety ValueFactor_Excel = ExcelPropety.CreateProperty<DeviceVariable>(x => x.ValueFactor);
[Display(Name = "表达式")]
public ExcelPropety Expressions_Excel = ExcelPropety.CreateProperty<DeviceVariable>(x => x.Expressions);
[Display(Name = "权限")]
public ExcelPropety ProtectType_Excel = ExcelPropety.CreateProperty<DeviceVariable>(x => x.ProtectType);
public ExcelPropety Device_Excel = ExcelPropety.CreateProperty<DeviceVariable>(x => x.DeviceId);

View File

@ -50,20 +50,21 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVariableVMs
protected override IEnumerable<IGridColumn<DeviceVariable_View>> InitGridHeader()
{
return new List<GridColumn<DeviceVariable_View>>{
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; }

View File

@ -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<MqttClient_View, MqttClientSearcher>
{
protected override IEnumerable<IGridColumn<MqttClient_View>> InitGridHeader()
{
return new List<GridColumn<MqttClient_View>>{
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; }
}
}

View File

@ -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
{
}
}

View File

@ -43,7 +43,6 @@ namespace IoTGateway.Controllers
public ActionResult Create()
{
var vm = Wtm.CreateVM<DeviceVariableVM>();
vm.Entity.ValueFactor = 1;
return PartialView(vm);
}

View File

@ -7,7 +7,7 @@
<wt:textbox field="LinkedVM.Name" />
<wt:textbox field="LinkedVM.DeviceAddress" />
<wt:combobox field="LinkedVM.DataType" />
<wt:textbox field="LinkedVM.ValueFactor" />
<wt:textbox field="LinkedVM.Expression" />
<wt:combobox field="LinkedVM.ProtectType" />
</wt:row>
<wt:hidden field="Ids" />

View File

@ -9,9 +9,10 @@
<wt:combobox field="Entity.Method" items="AllMethods" required="true" />
<wt:textbox field="Entity.DeviceAddress" />
<wt:combobox field="Entity.DataType" />
<wt:textbox field="Entity.ValueFactor"/>
<wt:textbox field="Entity.Expressions"/>
<wt:combobox field="Entity.ProtectType" />
</wt:row>
<wt:quote>表达式可以进行简单的数学计算,其中raw为原值参与计算</wt:quote>
<wt:row align="AlignEnum.Right">
<wt:submitbutton />
<wt:closebutton />

View File

@ -9,7 +9,7 @@
<wt:display field="Entity.Method" />
<wt:display field="Entity.DeviceAddress" />
<wt:display field="Entity.DataType" />
<wt:display field="Entity.ValueFactor" />
<wt:display field="Entity.Expressions" />
<wt:display field="Entity.ProtectType" />
<wt:display field="Entity.Device.DeviceName" />
</wt:row>

View File

@ -8,7 +8,7 @@
<wt:display field="Entity.Method" />
<wt:display field="Entity.DeviceAddress" />
<wt:display field="Entity.DataType" />
<wt:display field="Entity.ValueFactor" />
<wt:display field="Entity.Expressions" />
<wt:display field="Entity.ProtectType" />
<wt:display field="Entity.Device.DeviceName" />
</wt:row>

View File

@ -9,9 +9,10 @@
<wt:combobox field="Entity.Method" items=AllMethods />
<wt:textbox field="Entity.DeviceAddress" />
<wt:combobox field="Entity.DataType" />
<wt:textbox field="Entity.ValueFactor" />
<wt:textbox field="Entity.Expressions" />
<wt:combobox field="Entity.ProtectType" />
</wt:row>
<wt:quote>表达式可以进行简单的数学计算,其中raw为原值参与计算</wt:quote>
<wt:hidden field="Entity.ID" />
<wt:row align="AlignEnum.Right">
<wt:submitbutton />

View File

@ -11,5 +11,5 @@
<wt:combobox field="Searcher.DataType" empty-text="@Localizer["Sys.All"]" />
</wt:row>
</wt:searchpanel>
<wt:grid vm="@Model" url="/BasicData/DeviceVariable/Search" />
<wt:grid vm="@Model" url="/BasicData/DeviceVariable/Search" hidden-grid-index="true"/>
</wt:treecontainer>

View File

@ -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<MqttClientListVM>();
return PartialView(vm);
}
[ActionDescription("Sys.Search")]
[HttpPost]
public string Search(MqttClientSearcher searcher)
{
var vm = Wtm.CreateVM<MqttClientListVM>(passInit: true);
if (ModelState.IsValid)
{
vm.Searcher = searcher;
return vm.GetJson(false);
}
else
{
return vm.GetError();
}
}
#endregion
}
}

View File

@ -0,0 +1,7 @@
@model IoTGateway.ViewModel.MqttClient.MqttServerVMs.MqttClientListVM
@inject IStringLocalizer<Program> Localizer;
<wt:searchpanel vm="@Model" reset-btn="true">
<wt:row items-per-row="ItemsPerRowEnum.Three">
</wt:row>
</wt:searchpanel>
<wt:grid vm="@Model" url="/MqttServer/MqttClient/Search"/>

View File

@ -26,8 +26,6 @@
<ProjectReference Include="..\IoTGateway.Model\IoTGateway.Model.csproj" />
<ProjectReference Include="..\IoTGateway.DataAccess\IoTGateway.DataAccess.csproj" />
<ProjectReference Include="..\IoTGateway.ViewModel\IoTGateway.ViewModel.csproj" />
<ProjectReference Include="..\Plugins\Drivers\DriverModbusMaster\DriverModbusMaster.csproj" />
<ProjectReference Include="..\Plugins\Drivers\DriverSiemensS7\DriverSiemensS7.csproj" />
<ProjectReference Include="..\Plugins\Plugin\Plugin.csproj" />
<ProjectReference Include="..\WalkingTec.Mvvm\WalkingTec.Mvvm.Mvc\WalkingTec.Mvvm.Mvc.csproj" />
<ProjectReference Include="..\WalkingTec.Mvvm\WalkingTec.Mvvm.TagHelpers.LayUI\WalkingTec.Mvvm.TagHelpers.LayUI.csproj" />

Binary file not shown.

View File

@ -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))
{

View File

@ -5,6 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DynamicExpresso.Core" Version="2.9.7" />
<PackageReference Include="MQTTnet" Version="3.1.1" />
</ItemGroup>

View File

@ -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; }
}

View File

@ -14,7 +14,7 @@
},
"WTM": {
"LogLevel": {
"Default": "Error"
"Default": "Information"
}
}
},