diff --git a/IoTGateway.ViewModel/BasicData/DeviceConfigVMs/DeviceConfigListVM.cs b/IoTGateway.ViewModel/BasicData/DeviceConfigVMs/DeviceConfigListVM.cs index ed772c8..e8f8d45 100644 --- a/IoTGateway.ViewModel/BasicData/DeviceConfigVMs/DeviceConfigListVM.cs +++ b/IoTGateway.ViewModel/BasicData/DeviceConfigVMs/DeviceConfigListVM.cs @@ -20,7 +20,7 @@ namespace IoTGateway.ViewModel.BasicData.DeviceConfigVMs { this.MakeStandardAction("DeviceConfig", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"BasicData", dialogWidth: 800), this.MakeStandardAction("DeviceConfig", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "BasicData", dialogWidth: 800), - //this.MakeStandardAction("DeviceConfig", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "BasicData", dialogWidth: 800), + this.MakeStandardAction("DeviceConfig", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "BasicData", dialogWidth: 800), this.MakeStandardAction("DeviceConfig", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "BasicData", dialogWidth: 800), this.MakeStandardAction("DeviceConfig", GridActionStandardTypesEnum.BatchEdit, Localizer["Sys.BatchEdit"], "BasicData", dialogWidth: 800), //this.MakeStandardAction("DeviceConfig", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "BasicData", dialogWidth: 800), diff --git a/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableListVM.cs b/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableListVM.cs index 7b9576a..d48722e 100644 --- a/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableListVM.cs +++ b/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableListVM.cs @@ -78,7 +78,7 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVariableVMs }), this.MakeGridHeader(x => x.Expressions).SetWidth(150), this.MakeGridHeader(x => x.IsUpload).SetWidth(80), - //this.MakeGridHeader(x => x.ProtectType).SetSort(true), + this.MakeGridHeader(x => x.ProtectType).SetWidth(80).SetSort(true), this.MakeGridHeader(x => x.DeviceName_view).SetSort(true).SetWidth(90), this.MakeGridHeader(x => x.Alias).SetSort(true).SetWidth(90), this.MakeGridHeader(x => x.Timestamp).SetWidth(100).SetFormat((a,b)=>{ diff --git a/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableVM.cs b/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableVM.cs index 5fb9b27..e7865a4 100644 --- a/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableVM.cs +++ b/IoTGateway.ViewModel/BasicData/DeviceVariableVMs/DeviceVariableVM.cs @@ -10,6 +10,7 @@ using IoTGateway.Model; using Plugin; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Primitives; +using PluginInterface; namespace IoTGateway.ViewModel.BasicData.DeviceVariableVMs { @@ -25,7 +26,11 @@ namespace IoTGateway.ViewModel.BasicData.DeviceVariableVMs protected override void InitVM() { - this.Entity.IsUpload = true; + if (this.ControllerName.ToLower().Contains("add")) + { + this.Entity.IsUpload = true; + this.Entity.ProtectType = ProtectTypeEnum.ReadWrite; + } AllDevices = DC.Set().AsNoTracking().Where(x => x.DeviceTypeEnum == DeviceTypeEnum.Device) .OrderBy(x => x.Parent.Index).ThenBy(x => x.Parent.DeviceName) .OrderBy(x => x.Index).ThenBy(x => x.DeviceName) diff --git a/IoTGateway/Areas/BasicData/Views/DeviceConfig/Edit.cshtml b/IoTGateway/Areas/BasicData/Views/DeviceConfig/Edit.cshtml index 80d772f..253d079 100644 --- a/IoTGateway/Areas/BasicData/Views/DeviceConfig/Edit.cshtml +++ b/IoTGateway/Areas/BasicData/Views/DeviceConfig/Edit.cshtml @@ -3,7 +3,7 @@ - @**@ + @{ if (!string.IsNullOrEmpty(Model.Entity.EnumInfo)) { @@ -15,7 +15,7 @@ } } - @**@ + @**@ diff --git a/Plugins/Plugin/DeviceThread.cs b/Plugins/Plugin/DeviceThread.cs index f8f2224..d10bd8a 100644 --- a/Plugins/Plugin/DeviceThread.cs +++ b/Plugins/Plugin/DeviceThread.cs @@ -74,7 +74,7 @@ namespace Plugin { if (driver.IsConnected) { - foreach (var deviceVariables in Device.DeviceVariables!.GroupBy(x => x.Alias)) + foreach (var deviceVariables in Device.DeviceVariables.Where(x=>x.ProtectType!= ProtectTypeEnum.WriteOnly).GroupBy(x => x.Alias)) { string deviceName = string.IsNullOrWhiteSpace(deviceVariables.Key) ? Device.DeviceName @@ -158,7 +158,7 @@ namespace Plugin payLoad.TS = (long)(DateTime.UtcNow - _tsStartDt).TotalMilliseconds; - if (deviceVariables.All(x => x.StatusType == VaribaleStatusTypeEnum.Good)) + if (deviceVariables.Where(x=>x.IsUpload&&x.ProtectType!=ProtectTypeEnum.WriteOnly).All(x => x.StatusType == VaribaleStatusTypeEnum.Good)) { payLoad.DeviceStatus = DeviceStatusTypeEnum.Good; sendModel[deviceName] = new List { payLoad }; @@ -173,7 +173,7 @@ namespace Plugin } //只要有读取异常且连接正常就断开 - if (Device.DeviceVariables!.Any(x => x.StatusType != VaribaleStatusTypeEnum.Good) && driver.IsConnected) + if (Device.DeviceVariables.Where(x => x.IsUpload && x.ProtectType != ProtectTypeEnum.WriteOnly).Any(x => x.StatusType != VaribaleStatusTypeEnum.Good) && driver.IsConnected) { driver.Close(); driver.Dispose(); @@ -261,7 +261,7 @@ namespace Plugin deviceVariable = Device.DeviceVariables.FirstOrDefault(x => x.Name == para.Key && x.Alias == e.DeviceName); - if (deviceVariable != null) + if (deviceVariable != null&& deviceVariable.ProtectType!= ProtectTypeEnum.ReadOnly) { DriverAddressIoArgModel ioArgModel = new() { @@ -280,7 +280,7 @@ namespace Plugin else { rpcResponse.IsSuccess = false; - rpcResponse.Description += $"未能找到变量:{para.Key},"; + rpcResponse.Description += $"未能找到支持写入的变量:{para.Key},"; } } diff --git a/Plugins/PluginInterface/ProtectTypeEnum.cs b/Plugins/PluginInterface/ProtectTypeEnum.cs index a57be30..0f4a106 100644 --- a/Plugins/PluginInterface/ProtectTypeEnum.cs +++ b/Plugins/PluginInterface/ProtectTypeEnum.cs @@ -13,5 +13,7 @@ namespace PluginInterface ReadOnly, [Display(Name = "读写")] ReadWrite, + [Display(Name = "只写")] + WriteOnly, } }