public static void Init(IJournal journal, ISignalsFactory signals) { mRelay = new Relay(journal, RelayName.Kv4, signals); mOnTimeout = signals.GetSignal("soundalarm.on.timeout"); mOnTimeout.OnUpdate += signal => { var rv = signal.ValueAsInt < 1500 ? 1500 : signal.ValueAsInt > 6000 ? 6000 : signal.ValueAsInt; journal.Debug(string.Format("Таймер вкл. сирены установлен в {0} мс", rv), MessageLevel.System); mTask.SetTimeout(rv); }; mOffTimeout = signals.GetSignal("soundalarm.off.timeout"); mOffTimeout.OnUpdate += signal => { var rv = signal.ValueAsInt < 2500 ? 2500 : signal.ValueAsInt > 10000 ? 10000 : signal.ValueAsInt; journal.Debug(string.Format("Таймер выкл. сирены установлен в {0} мс", rv), MessageLevel.System); mUnlockInterval = rv; }; // values by default mTask = new DelayedTask(mOnTimeout.ValueAsInt); // 1500 mUnlockInterval = mOffTimeout.ValueAsInt; // 5000 mTask.OnTimeout += ProcessTimerEvent; }
public static void Init(IJournal journal, SignalsFactory signals, InvertorsService powers) { mSpeed = signals.GetSignal(SensorName.Derivative(SystemName.Conveyor, SignalName.Speed)); if (mSpeed == null) { throw new Exception("bad signal"); } mSpeed.Update(mCurrentSpeed); //mSpeed.OnChange += sensor => Console.WriteLine("Conveyor speed: {0}"); AcceptCheckout.OnTimeout += sender => mSpeed.Update(mCurrentSpeed); mCord = new Cord(signals.GetSignal(SensorName.Cord(6))); mCord.OnChange += sensor => { if (sensor.Value > 0) { //Console.WriteLine("Conveyor: cord F6"); OnErrorCaller(sensor); } }; mKv9 = new Relay(journal, RelayName.Kv9, signals); mKv9.OnError += OnErrorCaller; mKv10 = new Relay(journal, RelayName.Kv10, signals); mKv10.OnError += OnErrorCaller; mState = signals.GetSignal(SensorName.Derivative(SystemName.Conveyor, SignalName.Status)); }
public static void Init(IJournal journal, ISignalsFactory signals) { mJournal = journal; TankSensorHandler.Init(journal, signals); //TankSensorHandler.OnError += OnErrorCaller; //TankSensorHandler.OnWarning += OnWarningCaller; BrakePressureHandler.Init(journal, signals); //BrakePressureHandler.OnError += OnErrorCaller; //BrakePressureHandler.OnWarning += OnWarningCaller; SteeringPressureHandler.Init(journal, signals); //SteeringPressureHandler.OnError += OnErrorCaller; //SteeringPressureHandler.OnWarning += OnWarningCaller; CabelPressureHandler.Init(journal, signals); //CabelPressureHandler.OnError += OnErrorCaller; //CabelPressureHandler.OnWarning += OnWarningCaller; AlarmStopTimeout = (ushort)(signals.GetSignal("pump.alarm.shutdown.timeout").Value *1000); // делаем отключение асинхронным - команда на стоп не связана с реальной остановкой двигателя mTaskPumpStop = new DelayedTask(100); mTaskPumpStop.OnTimeout += sender => { mTaskPumpStop.Stop(); // TODO: тут может понадобится пауза между отключением частотников и насосной станцией mRelay.Off(); mStartAt = DateTime.MaxValue; // выключаем if (mState.ValueAsInt != (uint)EquipmentState.Failure) { mState.Update((uint)EquipmentState.Stop); } }; mRelay = new Relay(journal, RelayName.Kv11, signals); mRelay.OnError += sensor => OnErrorCaller(SystemStateCodes.Alarm.Kv11OutOfControl); mCord = new Cord(signals.GetSignal(SensorName.Cord(1))); mCord.OnChange += sensor => { if (sensor.IsSet) { OnErrorCaller(SystemStateCodes.Alarm.Cord1OutOfControl); } }; mState = signals.GetSignal(SensorName.Derivative(SystemName.Pump, SignalName.Status)); }
public static void Init(IJournal journal, ISignalsFactory signals, string port, int baudrate) { mJournal = journal; mPortName = port; mSignals = signals; mConnection = new RS485Master(journal, mPortName, baudrate, false); SetState(SystemState.Init); SpeedSettings(); mUz2 = InitInvertor(1); mUz3 = InitInvertor(2); mUz4 = InitInvertor(3); mUz5 = InitInvertor(4); mConveyor = mUz4; //mLeft = mSignals.GetSignal(SensorName.Invertor(4, SignalName.Angle)); // uz5 //mRight = mSignals.GetSignal(SensorName.Invertor(1, SignalName.Angle)); // uz2 mUz2State = mSignals.GetSignal(SensorName.Derivative(SystemName.Uz, 2, SignalName.Status)); mUz3State = mSignals.GetSignal(SensorName.Derivative(SystemName.Uz, 3, SignalName.Status)); mUz4State = mSignals.GetSignal(SensorName.Derivative(SystemName.Uz, 4, SignalName.Status)); mUz5State = mSignals.GetSignal(SensorName.Derivative(SystemName.Uz, 5, SignalName.Status)); mConveyorState = mSignals.GetSignal(SensorName.Derivative(SystemName.Conveyor, SignalName.Status)); mState = new List <ISignal> { mUz2State, mUz3State, mUz4State, mUz5State, mConveyorState }; for (var i = 0; i < 5; i++) { var rv = new Cord(signals.GetSignal(SensorName.Cord((byte)(i + 2)))); rv.OnChange += sensor => { if (!sensor.IsSet) { return; } OnErrorWrapper(GetCordCode(sensor.Specification.Id)); // last action for (var j = 0; j < Cords.Count; j++) { if (Cords[j] != rv) { continue; } mState[j].Update((float)EquipmentState.Failure); return; } }; Cords.Add(rv); } mRectifierReset = new Relay(journal, RelayName.RectifierReset, signals); mKv1 = new Relay(journal, RelayName.Kv1, signals); mKv1.OnError += signal => OnErrorWrapper(SystemStateCodes.Alarm.Kv1OutOfControl); /* * mKv8 = new Relay(journal, RelayName.Kv8, signals); * mKv8.OnError += signal => * { * // TODO: конвейерный частотник * mUz4State.Update((uint)EquipmentState.Failure); * OnErrorWrapper(SystemStateCodes.Alarm.Kv8OutOfControl); * }; */ mKv9 = new Relay(journal, RelayName.Kv9, signals); mKv9.OnError += signal => { mConveyorState.Update((uint)EquipmentState.Failure); OnErrorWrapper(SystemStateCodes.Alarm.Kv9OutOfControl); }; mKv10 = new Relay(journal, RelayName.Kv10, signals); mKv10.OnError += signal => { mConveyorState.Update((uint)EquipmentState.Failure); OnErrorWrapper(SystemStateCodes.Alarm.Kv10OutOfControl); }; // Автоматическое выключение конвейера по ошибке mConveyorState.OnChange += signal => { if (signal.ValueAsInt == (int)EquipmentState.Failure) { ConveyorOff(); } }; for (byte i = 1; i < 5; i++) { var voltage = signals.GetSignal(SensorName.Invertor(i, SignalName.Voltage)); if (voltage != null) { Voltages.Add(voltage); } else { throw new NullReferenceException(); } } mConveyorState.Update((uint)EquipmentState.Stop); // charge mKv2Feedback = signals.GetSignal(SensorName.Relay(RelayName.Kv2, SignalName.Feedback)); // включился режим заряда выпрямителя mKv2Feedback.OnChange += sensor => { //if(sensor.IsSet) // mJournal.Debug(string.Format("{0}: {1}", sensor.Id, sensor.IsSet), MessageLevel.System) }; mTangage = mSignals.GetSignal("tangage"); // mEncoder = signals.GetSignal("encoder.point"); mThread = new Thread(Update); mThread.Start(); }