private void ParentHub_UpdateMachineLoad(string id, MachineLoad info) { if (id != ConnectionId) { return; } Load = info; }
public ModuleHubWrapper(string id, MainHub parentHub) { ConnectionId = id; MainHub.UpdatedMachineInfo += ParentHub_UpdatedMachineInfo; MainHub.UpdateMachineLoad += ParentHub_UpdateMachineLoad; TargedModule = new Module(id); Load = new MachineLoad(); }
public async Task <MachineLoad> GetMachineLoad() { MachineLoad load = new MachineLoad { CPULoad = GetCPULoad(), MemoryLoad = 100.0 - (GetFreeRAM() / (_machineInfo.AllMemory / 100.0)) }; load.MemoryLoad = Math.Round(load.MemoryLoad, 1); return(load); }
public virtual async Task UpdateMachineLoad() { try { MachineLoad load = await _serviceCollector.GetMachineLoad(); await _hubConnection.InvokeAsync("RecieveModuleActivity", load); } catch (Exception e) { _logger.LogError(e, "Connect: Error occure collect machine load."); } }
//public DateTime LastLoadUpdate { get; set; } public ModuleHubWrapper() { TargedModule = new Module(); Load = new MachineLoad(); }
public async Task RecieveModuleActivity(MachineLoad machineLoad) { //_logger.LogDebug($"Update machine load on machine {Context.ConnectionId} \n CPU Load: {machineLoad.CPULoad}% , Memory Load {machineLoad.MemoryLoad}%"); UpdateMachineLoad?.Invoke(Context.ConnectionId, machineLoad); }