opcua读取值JValue转为object

This commit is contained in:
2248356998 qq.com
2023-07-14 10:04:05 +08:00
parent 5ac412a582
commit ee3a37d3b9
3 changed files with 19 additions and 4 deletions

View File

@@ -179,7 +179,15 @@ public class OPCUAClient : CollectBase
var itemReads = _deviceVariables.Where(it => it.VariableAddress == data.id).ToList();
foreach (var item in itemReads)
{
var value = data.jToken;
object value;
if (data.jToken is JValue jValue)
{
value = jValue.Value;
}
else
{
value = data.jToken;
}
var quality = StatusCode.IsGood(data.dataValue.StatusCode);
var time = data.dataValue.SourceTimestamp;

View File

@@ -356,7 +356,7 @@
<MTooltip Bottom Context="tip">
<ActivatorContent>
<MButton Disabled=@(!UserResoures.IsHasPageWithRole("/tgruntime/devicevariable")) Class="mx-2" @attributes="@tip.Attrs" Dark Fab Small Loading=isRestart
OnClick=@(()=>NavigationManager.NavigateTo("/tgruntime/devicevariable?devicename="+item.Device?.Name))>
OnClick=@(()=>NavigationManager.NavigateTo("/tgruntime/devicevariable?uploaddevicename="+item.Device?.Name))>
<MIcon>mdi-information-outline</MIcon>
</MButton>
</ActivatorContent>
@@ -378,7 +378,7 @@
</MTooltip>
<MTooltip Bottom Context="tip">
<ActivatorContent>
<MButton Disabled=@(!UserResoures.IsHasButtonWithRole("tgdevicerestart")) Class="mx-2" @attributes="@tip.Attrs" Dark Fab Small Loading=isRestart OnClick=@(()=>Restart(item.DeviceId))>
<MButton Disabled=@(!UserResoures.IsHasButtonWithRole("tgdevicerestart")) Class="mx-2" @attributes="@tip.Attrs" Dark Fab Small Loading=isRestart OnClick=@(()=>UpRestart(item.DeviceId))>
<MIcon>mdi-restart</MIcon>
</MButton>
</ActivatorContent>

View File

@@ -32,7 +32,9 @@ namespace ThingsGateway.Web.Page
[Parameter]
[SupplyParameterFromQuery]
public string DeviceName { get; set; }
[Parameter]
[SupplyParameterFromQuery]
public string UploadDeviceName { get; set; }
VariablePageInput _searchModel { get; set; } = new();
[Inject]
IUploadDeviceService _uploadDeviceService { get; set; }
@@ -63,6 +65,11 @@ namespace ThingsGateway.Web.Page
_searchModel.DeviceName = DeviceName;
await datatableQuery();
}
if (_searchModel.UploadDeviceName != UploadDeviceName && !UploadDeviceName.IsNullOrEmpty())
{
_searchModel.UploadDeviceName = UploadDeviceName;
await datatableQuery();
}
CollectDeviceHostService = ServiceExtensions.GetBackgroundService<CollectDeviceWorker>();
_deviceGroups = _globalDeviceData.CollectDevices.Adapt<List<CollectDevice>>().GetTree();