示例#1
0
 private void OnBackLimitHit(object sender, EventArgs e)
 {
     if (LimitMode)
     {
         SensorModel sense = (SensorModel)sender;
         if (_state == MoveState.MoveFwd && sense.CurrentState == false)
         {
             _state = MoveState.MoveBack;
             Backward();
         }
     }
 }
示例#2
0
 public TeamControlModel(Int16 plat1, Int16 plat2, Int16 obs1, Int16 obs2,
                         Int16 hover, Int16 start, Int16 motor1, Int16 motor2, Int16 frontLim, Int16 backLim)
 {
     Platform1Led        = new LedModel(plat1);
     Platform2Led        = new LedModel(plat2);
     Obstacle1Led        = new LedModel(obs1);
     Obstacle2Led        = new LedModel(obs2);
     HoverLed            = new LedModel(hover);
     StartLed            = new LedModel(start);
     BackLimSwitch       = new SensorModel(backLim);
     FrontLimSwitch      = new SensorModel(frontLim);
     Motor               = new MotorModel(motor1, motor2, FrontLimSwitch, BackLimSwitch);
     Motor.LimitMode     = true;
     EnableLimitSwitches = true;
 }
示例#3
0
 private void OnFrontLimitHit(object sender, EventArgs e)
 {
     if (LimitMode)
     {
         SensorModel sense = (SensorModel)sender;
         if (_state == MoveState.MoveBack && sense.CurrentState == false)
         {
             _state = MoveState.Start;
             if (!_stopping)
             {
                 Play();
             }
             else
             {
                 _stopping = false;
                 Stop();
             }
         }
     }
 }
示例#4
0
 public MotorModel(short pinNumber1, short pinNumber2,
                   SensorModel frontLim, SensorModel backLim,
                   int fwdTime = Constants.defaultMotorFwdTime, int backTime = Constants.defaultMotorBackTime,
                   bool in1    = false, bool in2 = false)
 {
     this._pinNumber1          = pinNumber1;
     this._pinNumber2          = pinNumber2;
     this._in1                 = in1;
     this._in2                 = in2;
     ForwardTime               = fwdTime;
     _lastForwardTime          = ForwardTime;
     BackwardTime              = backTime;
     _lastBackwardTime         = BackwardTime;
     _forwardTimer             = new PauseableTimer(ForwardTime);
     _forwardTimer.Elapsed    += OnForwardTimerElapsed;
     _backwardTimer            = new PauseableTimer(BackwardTime);
     _backwardTimer.Elapsed   += OnBackwardTimerElapsed;
     frontLim.PropertyChanged += OnFrontLimitHit;
     backLim.PropertyChanged  += OnBackLimitHit;
     LimitMode                 = false;
 }