public FanObject GetFanObject(int fanOjbectNum) { var fanObjectVm = new FanObject {FanObjectId = fanOjbectNum}; using (var unit = new RepoUnit()) { if (isFanLogEmpty(unit, fanOjbectNum)) return null; var fanLog = unit.FanLog.LastRecord(f => f.FanNumber == fanOjbectNum); fanObjectVm.Parameters.AddRange( fanLog.AnalogSignalLogs.Select( s => new Parameter { Name = s.SignalType.Type, Value = s.SignalValue, State = SystemStateService.GetParameterState(s.SignalType.Type,s.SignalValue) })); fanObjectVm.Doors.AddRange(fanLog.DoorsLogs.Select(d => new Door {Type = d.DoorType.Type, State = d.DoorState.State, StateId = d.DoorStateId, TypeId = d.DoorTypeId})); fanObjectVm.WorkingFanNumber = GetWorkingFanNumber(fanLog.Fan1State_Id, fanLog.Fan2State_Id); fanObjectVm.Date = fanLog.Date; } return fanObjectVm; }
private ParameterVm getFanStateParameter(FanObject fanObject) { return _fanService.GetFanMode(fanObject.WorkingFanNumber, fanObject.Doors); }
private ParameterVm getFanNumberParameter(FanObject fanObject) { var parameter = new ParameterVm {Value = fanObject.WorkingFanNumber == 0 ? "АВАРИЯ" : string.Format("№{0}", fanObject.WorkingFanNumber), Name = "Вентилятор в работе"}; parameter.State = SystemStateService.GetFanState(fanObject.WorkingFanNumber); return parameter; }
private void setFanMode(FanObject fanObject) { var value = new StringBuilder(); var state = StateEnum.Ok; //Get if reverse or normal var fanMode = _fanService.GetFanMode(fanObject.WorkingFanNumber, fanObject.Doors); state = fanMode.State; value.Append(fanMode.Value); //Check if working fan number is correct var fanState = SystemStateService.GetFanState(fanObject.WorkingFanNumber); if (fanState == StateEnum.Dangerous || fanMode.State == StateEnum.Dangerous) { state = StateEnum.Dangerous; if (fanState == StateEnum.Dangerous) value.Append("\nВентилятор остановлен"); else if (fanMode.State == StateEnum.Dangerous) value.Append("\nЛяды не собраны"); } SystemState = new ParameterVm { Value = value.ToString(), State = state }; }
public void Update(FanObject fanObject) { _fanObjectId = fanObject.FanObjectId; setFanMode(fanObject); setWorkingFan(fanObject.WorkingFanNumber); setDoorsState(fanObject.Doors); setOnOffModeState(); }
private List<Parameter> getThermometerValues(FanObject fanObject) { return new List<Parameter> {fanObject.Parameters[2]}; }
private List<Parameter> getIndicatorValues(FanObject fanObject) { return new List<Parameter> { fanObject.Parameters[0], fanObject.Parameters[1]}; }