public override void OnCommunication(CommunicationEventArgs e) { base.OnCommunication(e); if (e.Data.DirectiveType == DirectiveTypeEnum.Running) { HandleDeviceStatusChange(new IoStatusChangeEventArgs() { DeviceId = e.DeviceId, DeviceType = e.DeviceType, IoStatus = e.DeviceStatus, Delta = 0, Feedback = e.Data }); var x = e.Data as GasDirectiveData; if (x != null) { DeviceService.SaveGasRecord(new GasRecord() { CellCultivationId = CultivationService.GetLastCultivationId(), Concentration = x.Concentration, FlowRate = x.Flowrate, CreatedAt = DateTime.Now }); } Center.SyncGasWithServer(); } }
private void SaveRecord(bool isManual) { DeviceService.SavePumpRecord(new PumpRecord() { CellCultivationId = CultivationService.GetLastCultivationId(), DeviceId = Device.DeviceId, StartTime = StartTime, EndTime = DateTime.Now, FlowRate = Flowrate, Volume = Volume, IsManual = isManual }); }
public async Task Start() { InitControllers(); if (CurrentContext.SysCache.System == null) { LogFactory.Create().Warnning("SysCache.System is null"); return; } if (CurrentContext.SysCache.System.PumpIn == null && CurrentContext.SysCache.System.PumpOut == null) { LogFactory.Create().Warnning("SysCache.System in or out is null"); return; } OnSystemStatusChange(new RunStatusChangeEventArgs() { SysStatus = SysStatusEnum.Starting }); CultivationService.SaveCultivations(CurrentContext.SysCache.System); SyncSysStatusWithServer(); var pumpCtrls = Controllers.Where(each => each.Device.DeviceType == TargetDeviceTypeEnum.Pump).Select(each => each as PumpController).ToList(); var nonPumpCtrls = Controllers.Where(each => each.Device.DeviceType != TargetDeviceTypeEnum.Pump).ToList(); foreach (var ctrl in nonPumpCtrls) { var p = await ctrl.Start(); if (!p.Status && p.Code == "CANCEL") { return; } } AdjuestStartTimeWhenFirstRun(); var list = new List <Task <DeviceIOResult> >(); pumpCtrls.ForEach(each => { list.Add(each.Start()); }); await Task.WhenAny(list); }