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 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 SpeedUp() { if (mSpeed.Value < kSpeedCount) { mSpeed.Update(mSpeed.Value + 1); } AcceptCheckout.Start(); }
public void On() { if (!mOutput.IsSet) { mJournal.Debug(string.Format("Реле (ОС) {0} вкл.", mOutput.Specification.Id), MessageLevel.System); } mTask.Start(); mOutput.Update(true); }
private static void OnErrorCaller(ISignal sensor) { var handler = OnError; if (handler != null) { handler(sensor); } mState.Update(2); }
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)); }
/// <summary> /// Поднимаем скорость на одну ступеньку /// </summary> public static void ConveyorSpeedUp() { if (mConveyorSpeed.Value < kConveyorSpeedCount - 1) { mConveyorSpeed.Update(mConveyorSpeed.Value + 1); } if (mIsConveyorActive) { ConveyorOn(); } //mJournal.Debug(string.Format("speed up: {0}:{1}", mode, mode == EngineMode.Motion ? mMotionSpeed.ValueAsInt : mConveyorSpeed.ValueAsInt), MessageLevel.System); }
public Encoder(ISignalsFactory signals) { mEncoderPoint = signals.GetSignal("encoder.point"); // TODO: debug only /* * mEncoderPoint.OnChange += * signal => * { * if (Math.Abs(signal.ValueAsInt) != 1) * { * Console.WriteLine("compensation: {0}", * signal.ValueAsInt > 0 * ? string.Format("right at {0}", signal.Value) * : string.Format("left at {0}", signal.Value)); * } * else * Console.WriteLine("compensation set to none"); * }; */ mEncoderPoint.Update(1.0f); mZeroPoint = signals.GetSignal("encoder.settings.zero").ValueAsInt; mIsEnabled = signals.GetSignal("encoder.settings.enable").IsSet; // load compensation table mCompensationTable = new ushort[30]; mCompensationTable[0] = 0; for (var i = 1; i < mCompensationTable.Length; i++) { mCompensationTable[i] = (ushort)signals.GetSignal("encoder.settings.limit." + i).ValueAsInt; } }
private void ConfigureDataStore() { mService = new TcpDatastore(mJournal, mDataStore, 1, mPort); mDataStore.DataStoreWrittenTo += (sender, args) => { switch (args.ModbusDataType) { case ModbusDataType.HoldingRegister: { //local sensors if (args.StartAddress == 1000) { mKeyboard.Update(args.Data.B[6]); // если отчет содержит данные об угле поворота, то вычисляем его if (args.Data.B.Count > 7) { mEncoder.UpdateAngle(args.Data.B[7]); //mJournal.Warning(string.Format("Update angle sensor: {0}", args.Data.B[7]), MessageLevel.User); } foreach (var sensor in mSensors.Where(sensor => sensor.IsEnable)) { sensor.GetSignal().Update(args.Data.B[sensor.GetChannel()]); } } } break; } }; }
/// <summary> /// Выставляем режим работы частотников /// </summary> /// <param name="mode"></param> public static bool SetMode(EngineMode mode) { switch (mode) { case EngineMode.Deactivate: { Mode = mode; // сбрасывааем скорость для режима ХОД mMotionSpeed.Update(0); } break; case EngineMode.Motion: //case EngineMode.Conveyor: { if (Mode == EngineMode.Deactivate) { Mode = mode; } } break; } return(mode == Mode); }
public void UpdateAngle(ushort data) { int rv; if (data >= mZeroPoint) { rv = (data - mZeroPoint); } else { rv = (1024 + data - mZeroPoint); } if (rv > 512) { rv = ~(1023 - rv); } mEncoderPoint.Update(UpdateCompensation((short)((rv * 360.0) / 1023))); }
/// <summary> /// Сбрасываем ошибку на частотниках /// </summary> public static void ResetFault() { mIsNeedResetFault = true; mConveyorState.Update((uint)EquipmentState.Stop); }