示例#1
0
        private void ParentHub_UpdateMachineLoad(string id, MachineLoad info)
        {
            if (id != ConnectionId)
            {
                return;
            }

            Load = info;
        }
示例#2
0
        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);
        }
示例#4
0
        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.");
            }
        }
示例#5
0
        //public DateTime LastLoadUpdate { get; set; }

        public ModuleHubWrapper()
        {
            TargedModule = new Module();
            Load         = new MachineLoad();
        }
示例#6
0
 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);
 }