private static void SpeedSettings() { mMotionSpeed = mSignals.GetSignal(SensorName.Derivative(SystemName.System, SignalName.Speed)); mMotionSpeed.Update(0); for (var i = 0; i < kMotionSpeedCount; i++) { var rv = mSignals.GetSignal(string.Format("{0}.settings.{1}", SensorName.Derivative(SystemName.System, SignalName.Speed), i + 1)); MotionFrequencies.Add(rv); } mConveyorSpeed = mSignals.GetSignal(SensorName.Derivative(SystemName.Conveyor, SignalName.Speed)); mConveyorSpeed.Update(0); for (var i = 0; i < kConveyorSpeedCount; i++) { var rv = mSignals.GetSignal(string.Format("{0}.settings.{1}", SensorName.Derivative(SystemName.Conveyor, SignalName.Speed), i + 1)); ConveyorFrequencies.Add(rv); } // Понижаем частоту, если долго не давили на педали ResetMotionSpeedToMin.OnTimeout += sender => { mJournal.Debug("Сброс скорости по таймеру", MessageLevel.System); mMotionSpeed.Update(0); }; }
public Relay(IJournal journal, RelayName name, ISignalsFactory signals) { mJournal = journal; mOutput = signals.GetSignal(SensorName.Relay(name)); // TODO: uncomment mFeedback = signals.GetSignal(SensorName.Relay(name, SignalName.Feedback)); if (mFeedback != null) { mFeedback.OnChange += FeedbackOnChange; } if (mOnTimeout == null) { mOnTimeout = signals.GetSignal("relay.feedback.on.timeout"); } if (mFeedback != null) { mOnTimeout.OnUpdate += signal => { var rv = signal.ValueAsInt < 1500 ? 1500 : signal.ValueAsInt > 6000 ? 6000 : signal.ValueAsInt; mJournal.Debug(string.Format("Таймер реле (ОС) установлен в {0} мс для {1}", rv, mOutput.Specification.Id), MessageLevel.System); mTask.SetTimeout(rv); }; } // задержка на контроль обратной связи по контактору по умолчанию mTask = new DelayedTask(mOnTimeout == null ? 3000 : mOnTimeout.ValueAsInt < 1500 ? 1500 : mOnTimeout.ValueAsInt > 6000 ? 6000 : mOnTimeout.ValueAsInt); mTask.OnTimeout += Checkout; }
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) { mPressureAlarmMin = signals.GetSignal(string.Format("{0}.alarm.min", SensorName.Cabel(SignalName.Pressure))).Value; mPressureAlarmMax = signals.GetSignal(string.Format("{0}.alarm.max", SensorName.Cabel(SignalName.Pressure))).Value; mPressureWarningMax = signals.GetSignal(string.Format("{0}.warning.max", SensorName.Cabel(SignalName.Pressure))).Value; mStartTrackingTimeout = signals.GetSignal("pump.alarm.startup.timeout").Value; // датчик давления в системе рулевого и его обработка mCabelPressure = new Sensor(SensorName.Cabel(SignalName.Pressure), signals) { OnUpdate = value => { if (mStartAt == DateTime.MaxValue) { return; } if (DateTime.Now.Subtract(mStartAt).TotalSeconds < mStartTrackingTimeout) { return; } if (value > mPressureAlarmMax) { if (OnError != null) { OnError(SystemStateCodes.Alarm.CabelPressureMax); } return; } if (value < mPressureAlarmMin) { if (OnError != null) { OnError(SystemStateCodes.Alarm.CabelPressureMin); } return; } if (value > mPressureWarningMax) { return; } if (OnWarning != null) { OnWarning(SystemStateCodes.Warning.CabelPressureMax); } } }; }
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)); }
static public void Init(ISignalsFactory signals) { mForwardDrive = signals.GetSignal(SensorName.Drive(SignalName.Forward)); if (mForwardDrive == null) { throw new NullReferenceException(SensorName.Drive(SignalName.Forward)); } mReverseDrive = signals.GetSignal(SensorName.Drive(SignalName.Reverse)); if (mReverseDrive == null) { throw new NullReferenceException(SensorName.Drive(SignalName.Reverse)); } }
public static void Initwago750494(Coupler wago, ISignalsFactory signals) { { W750493.Add(wago, 0, new List <ISignal> { signals.GetSignal(SensorName.Phase(1, SignalName.Voltage)) }); W750514.Add(wago, 518, new List <ISignal> { signals.GetSignal(SensorName.Relay(RelayName.Kv4)), // sound alarm signals.GetSignal(SensorName.Relay(RelayName.Kv11)), // pump on signals.GetSignal(SensorName.Relay(RelayName.Kv10)), // signals.GetSignal(SensorName.Relay(RelayName.Kv9)), // signals.GetSignal(SensorName.Relay(RelayName.RectifierReset)), // rectifier reset//null,//new Signal(SensorName.Relay(RelayName.Kv10)),//mode mix, signals.GetSignal(SensorName.Relay(RelayName.Kv1)), // rectifier active mode }); W7501405.Add(wago, 6, new List <ISignal> { signals.GetSignal(SensorName.Drive(SignalName.Forward)), // SignalType.Ushort), signals.GetSignal(SensorName.Drive(SignalName.Reverse)), // SignalType.Ushort), signals.GetSignal(SensorName.Cord(1)), //SignalType.Ushort), // F1 signals.GetSignal(SensorName.Cord(2)), //SignalType.Ushort), // F2 signals.GetSignal(SensorName.Cord(3)), //SignalType.Ushort), // F3 signals.GetSignal(SensorName.Cord(4)), //SignalType.Ushort), // F4 signals.GetSignal(SensorName.Cord(5)), //SignalType.Ushort), // F5 signals.GetSignal(SensorName.Cord(6)), //SignalType.Ushort), // F6 null, //new Signal(SensorName.Empty()), signals.GetSignal(SensorName.Relay(RelayName.Kv11, SignalName.Feedback)), //SignalType.Ushort),// K1 signals.GetSignal(SensorName.Relay(RelayName.Kv2, SignalName.Feedback)), //SignalType.Ushort),// K2 signals.GetSignal(SensorName.Relay(RelayName.Kv1, SignalName.Feedback)), //SignalType.Ushort),// K3 - signals.GetSignal(SensorName.Relay(RelayName.Kv9, SignalName.Feedback)), //SignalType.Ushort),// K4 //signals.GetSignal(SensorName.Relay(RelayName.Kv8, SignalName.Feedback)), //SignalType.Ushort),// K4 - signals.GetSignal(SensorName.Relay(RelayName.Kv10, SignalName.Feedback)), //SignalType.Ushort),// K5 - null, //signals.GetSignal(SensorName.Relay(RelayName.Kv10, SignalName.Feedback)), //SignalType.Ushort),// K6, now K4 null //new Signal(SensorName.Empty()) }); } }
private void ConfigureSensors() { mDataStore = DataStoreFactory.CreateDefaultDataStore(0, 0, 1200, 1200); mSensors = new List <Sensor> { new Sensor(SensorName.Filter(SignalName.Pressure), mSignals), new Sensor(SensorName.Steering(SignalName.Pressure), mSignals), new Sensor(SensorName.Cabel(SignalName.Pressure), mSignals), new Sensor(SensorName.Brake(SignalName.Pressure), mSignals), new Sensor(SensorName.Tank(SignalName.Level), mSignals), new Sensor(SensorName.Tank(SignalName.Temperature), mSignals) }; mKeyboard = mSignals.GetSignal(SensorName.Keyboard()); //mSignals.GetSignal(SensorName.Tank(SignalName.Level)).OnUpdate += signal => Console.WriteLine("Level: {0}", signal.Value); Keyboard.Init(mKeyboard); }
public static void Init(SignalsFactory signals, InvertorsService powers) { mTaskEngineStop = new DelayedTask(100); mTaskEngineStop.OnTimeout += sender => InternalStop(); // active mKv1Feedback = signals.GetSignal(SensorName.Relay(RelayName.Kv1, SignalName.Feedback)); mKv1Feedback.OnChange += sensor => { //Console.WriteLine("mKv1Feedback: {0}", sensor.Value); // выключился активный режим выпрямителя //if(sensor.Value == 0) // SetState(SystemState.Failure, sensor, args); }; // charge mKv2Feedback = signals.GetSignal(SensorName.Relay(RelayName.Kv2, SignalName.Feedback)); mKv2Feedback.OnChange += sensor => { //Console.WriteLine("mKv2Feedback: {0}", sensor.Value); // включился режим заряда выпрямителя /* * if (sensor.Value > 0) * { * if (mState != SystemState.Init) * SetState(SystemState.Failure, sensor, args); * } */ }; /* * mEngineSpeed = signals.GetSignal(SensorName.Derivative(SystemName.System, SignalName.Speed)) as LocalOutput; * if (mEngineSpeed == null) * throw new Exception("bad signal"); * * mEngineSpeed.Set(mCurrentSpeed); * //mEngineSpeed.OnChange += sensor => Console.WriteLine("Engine speed: {0}", args.Code); * AcceptCheckout.OnTimeout += sender => mEngineSpeed.Set(mCurrentSpeed); * * mInvertors = powers; * * foreach (var invertor in mInvertors.Invertors) * { * invertor.OnError += (sender, args) => * { * OnErrorCaller(sender, args); * * SetInvertorState(sender.Id, 2); * }; * } * * for (var i = 0; i < 4; i++) * { * var rv = new Cord(signals.GetSignal(SensorName.Cord((byte)(i + 2)))); * rv.OnChange += sensor => * { * if (sensor.Value <= 0) return; * * Console.WriteLine(sensor.Id); * OnErrorCaller(null, new EngineEventArgs { Sensor = sensor }); * }; * Cords.Add(rv); * } * * mKv8 = new Relay(RelayName.Kv8, signals); * mKv8.OnError += sensor => OnErrorCaller(null, new EngineEventArgs { Sensor = sensor }); * * State.Add(SensorName.Invertor(1), signals.GetSignal(SensorName.Derivative(SystemName.Uz, 2, SignalName.Status))); * State.Add(SensorName.Invertor(2), signals.GetSignal(SensorName.Derivative(SystemName.Uz, 3, SignalName.Status))); * State.Add(SensorName.Invertor(3), signals.GetSignal(SensorName.Derivative(SystemName.Uz, 4, SignalName.Status))); * State.Add(SensorName.Invertor(4), signals.GetSignal(SensorName.Derivative(SystemName.Uz, 5, 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(); }
public static void Init(IJournal journal, ISignalsFactory signals) { mLevelAlarmMin = signals.GetSignal("tank.level.alarm.min").Value; // Уровень в баке, авария mLevelWarnMin = signals.GetSignal("tank.level.warning.min").Value; // Уровень в баке, предупреждение mTempWarnMax = signals.GetSignal("tank.temperature.warning.max").Value; // Т в баке, предупреждение mTempAlarmMax = signals.GetSignal("tank.temperature.alarm.max").Value; // Т в баке, авария IsNormalState = true; mTankTemperature = new Sensor(SensorName.Tank(SignalName.Temperature), signals); mTankLevel = new Sensor(SensorName.Tank(SignalName.Level), signals) { OnUpdate = value => { if (value <= mLevelAlarmMin) { if (OnError != null) { OnError(SystemStateCodes.Alarm.TankLevelMin); } IsNormalState = false; return; } if (value > mLevelWarnMin) { return; } if (OnWarning != null) { OnWarning(SystemStateCodes.Warning.TankLevelMin); } // датчик температуры конструктивно выполнен в одном корпусе с датчиком уровня, но датчик уровня является приоритетным if (mTankTemperature.IsAvailable) { if (mTankTemperature.Value > mTempAlarmMax) { if (OnError != null) { OnError(SystemStateCodes.Alarm.TankTemperatureMin); } IsNormalState = false; return; } if (mTankTemperature.Value < mTempWarnMax) { return; } if (OnWarning != null) { OnWarning(SystemStateCodes.Warning.TankTemperatureMin); } } IsNormalState = true; } }; }
public static void Init(IJournal journal, ISignalsFactory signals) { mPressureAlarmMin = signals.GetSignal("pump.alarm.pressure.min").Value; mPressureAlarmMax = signals.GetSignal("pump.alarm.pressure.max").Value; mStartTrackingTimeout = signals.GetSignal("pump.alarm.startup.timeout").Value; mFilterPressureDifferenceWarnMax = signals.GetSignal("filter.pressure.warning.max").Value; mFilterPressureDifferenceAlarmMax = signals.GetSignal("filter.pressure.alarm.max").Value; // разница по давлению актуальна только при наличии датчика в гидромагистрали кузова, т.е. в нашем случае - рулевого mFilterPressure = new Sensor(SensorName.Filter(SignalName.Pressure), signals); // датчик давления в системе рулевого и его обработка mSteeringPressure = new Sensor(SensorName.Steering(SignalName.Pressure), signals) { OnUpdate = value => { if (mStartAt == DateTime.MaxValue) { return; } if (DateTime.Now.Subtract(mStartAt).TotalSeconds < mStartTrackingTimeout) { return; } if ((mPressureAlarmMax > value) && (value > mPressureAlarmMin)) { return; } if (OnError != null) { OnError(SystemStateCodes.Alarm.SystemPressureOutOfRange); return; } if (!mFilterPressure.IsAvailable) { return; } // проверка на разницу давления на фильтре, если датчик давления перед фильтром доступен var filterDifference = Math.Abs(value - mFilterPressure.Value); if (filterDifference > mFilterPressureDifferenceAlarmMax) { if (OnError != null) { OnError(SystemStateCodes.Alarm.FilterPressureMax); return; } } if (!(filterDifference > mFilterPressureDifferenceWarnMax)) { return; } if (OnWarning != null) { OnWarning(SystemStateCodes.Warning.FilterPressureMax); } } }; }