diff --git a/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 b/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 index d17502c..082e9af 100644 Binary files a/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 and b/.vs/IoTGateway/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/IoTGateway/v17/.futdcache.v1 b/.vs/IoTGateway/v17/.futdcache.v1 index 192a8d7..4f62e7d 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 70ea09d..cb15862 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 85df554..3816e83 100644 Binary files a/.vs/IoTGateway/v17/fileList.bin and b/.vs/IoTGateway/v17/fileList.bin differ diff --git a/IoTGateway/Controllers/HomeController.cs b/IoTGateway/Controllers/HomeController.cs index b116aff..5d8a025 100644 --- a/IoTGateway/Controllers/HomeController.cs +++ b/IoTGateway/Controllers/HomeController.cs @@ -10,6 +10,8 @@ using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; +using Plugin; +using PluginInterface; using WalkingTec.Mvvm.Core; using WalkingTec.Mvvm.Core.Auth; using WalkingTec.Mvvm.Core.Extensions; @@ -19,6 +21,11 @@ namespace IoTGateway.Controllers { public class HomeController : BaseController { + private readonly DeviceService _deviceService; + public HomeController(DeviceService deviceService) + { + _deviceService = deviceService; + } [AllRights] public IActionResult Index() { @@ -39,6 +46,61 @@ namespace IoTGateway.Controllers return PartialView(); } + public IActionResult GetDeviceChart() + { + var data = new List(); + + + data.Add(new ChartData + { + Value = _deviceService.DeviceThreads.Where(x => !x.Device.AutoStart).Count(), + Category = "停止", + Series = "Device" + }); + + data.Add(new ChartData + { + Value = _deviceService.DeviceThreads.Where(x => x.Device.AutoStart && x.Driver.IsConnected).Count(), + Category = "运行", + Series = "Device", + }); + + data.Add(new ChartData + { + Value = _deviceService.DeviceThreads.Where(x => x.Device.AutoStart && !x.Driver.IsConnected).Count(), + Category = "异常", + Series = "Device" + }); + var rv = data.ToChartData(); + return Json(rv); + } + + public IActionResult GetDeviceVariableChart() + { + var data = new List(); + foreach (var deviceThread in _deviceService.DeviceThreads.OrderBy(x => x.Device.DeviceName)) + { + data.Add(new ChartData + { + Category = deviceThread.Device.DeviceName, + Value = deviceThread.DeviceValues.Where(x => x.Value.StatusType != VaribaleStatusTypeEnum.Good).Count(), + Series = "Others" + }); + + data.Add(new ChartData + { + Category = deviceThread.Device.DeviceName, + Value = deviceThread.DeviceValues.Where(x => x.Value.StatusType == VaribaleStatusTypeEnum.Good).Count(), + Series = "Good" + }); + + + } + + var rv = data.ToChartData(); + return Json(rv); + } + public IActionResult GetActionChart() { var areas = GlobaInfo.AllModule.Select(x => x.Area).Distinct(); diff --git a/IoTGateway/Views/Home/FrontPage.cshtml b/IoTGateway/Views/Home/FrontPage.cshtml index de6cfde..e2cddc1 100644 --- a/IoTGateway/Views/Home/FrontPage.cshtml +++ b/IoTGateway/Views/Home/FrontPage.cshtml @@ -55,6 +55,22 @@ + +
+
+
设备状态
+
+ +
+
+
+
+
+
设备变量状态
+
+ +
+
diff --git a/Plugins/Plugin/MyMqttClient.cs b/Plugins/Plugin/MyMqttClient.cs index 7cdd84b..fe1b897 100644 --- a/Plugins/Plugin/MyMqttClient.cs +++ b/Plugins/Plugin/MyMqttClient.cs @@ -93,7 +93,7 @@ namespace Plugin foreach (var kv in payload.Values) { //更新到UAService - _uaNodeManager.UpdateNode($"{device.Parent.DeviceName}.{device.DeviceName}.{kv.Key}", kv.Value); + _uaNodeManager?.UpdateNode($"{device.Parent.DeviceName}.{device.DeviceName}.{kv.Key}", kv.Value); } }