Beispiel #1
0
        public byte SendMessage(RP6_DIRECTION_ENUM direction)
        {
            _moveMessage.Action = (byte)Actions.RP6_MOVE;
            _moveMessage.Data[0] = (byte)direction;
            _moveMessage.DataLen = 1;

            return _arduino.Write(_moveMessage);
        }
Beispiel #2
0
        public byte SendMessage(RP6_DIRECTION_ENUM direction)
        {
            _moveMessage.Action  = (byte)Actions.RP6_MOVE;
            _moveMessage.Data[0] = (byte)direction;
            _moveMessage.DataLen = 1;

            return(_arduino.Write(_moveMessage));
        }
Beispiel #3
0
        //Send message to arduino
        #region


        private void controlTimer_Tick_1(object sender, EventArgs e)
        {
            if (forwards && !left && !right && lastState != RP6_DIRECTION_ENUM.RP6_FORWARD)
            {
                lastState = RP6_DIRECTION_ENUM.RP6_FORWARD;
                this.pictureBox1.Image = Properties.Resources.forwards;
                __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_FORWARD);
            }
            if (left && !forwards && !backwards && lastState != RP6_DIRECTION_ENUM.RP6_LEFT)
            {
                lastState = RP6_DIRECTION_ENUM.RP6_LEFT;
                this.pictureBox1.Image = Properties.Resources.left;
                __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_LEFT);
            }
            if (right && !forwards && !backwards && lastState != RP6_DIRECTION_ENUM.RP6_RIGHT)
            {
                lastState = RP6_DIRECTION_ENUM.RP6_RIGHT;
                this.pictureBox1.Image = Properties.Resources.right;
                __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_RIGHT);
            }
            if (backwards && !left && !right && lastState != RP6_DIRECTION_ENUM.RP6_BACKWARD)
            {
                lastState = RP6_DIRECTION_ENUM.RP6_BACKWARD;
                this.pictureBox1.Image = Properties.Resources.backwards;
                __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_BACKWARD);
            }
            if (forwards && left && lastState != RP6_DIRECTION_ENUM.RP6_FORWARD_LEFT)
            {
                lastState = RP6_DIRECTION_ENUM.RP6_FORWARD_LEFT;
                this.pictureBox1.Image = Properties.Resources.forwardsLeft;
                __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_FORWARD_LEFT);
            }
            if (forwards && right && lastState != RP6_DIRECTION_ENUM.RP6_FORWARD_RIGHT)
            {
                lastState = RP6_DIRECTION_ENUM.RP6_FORWARD_RIGHT;
                this.pictureBox1.Image = Properties.Resources.forwardsRight;
                __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_FORWARD_RIGHT);
            }
            if (backwards && left && lastState != RP6_DIRECTION_ENUM.RP6_BACKWARD_LEFT)
            {
                lastState = RP6_DIRECTION_ENUM.RP6_BACKWARD_LEFT;
                this.pictureBox1.Image = Properties.Resources.backwardsLeft;
                __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_BACKWARD_LEFT);
            }
            if (backwards && right && lastState != RP6_DIRECTION_ENUM.RP6_BACKWARD_RIGHT)
            {
                lastState = RP6_DIRECTION_ENUM.RP6_BACKWARD_RIGHT;
                this.pictureBox1.Image = Properties.Resources.backwardsRight;
                __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_BACKWARD_RIGHT);
            }
            if (!forwards && !backwards && !left && !right)
            {
                lastState = RP6_DIRECTION_ENUM.RP6_STOP;
                this.pictureBox1.Image = Properties.Resources.noMovement;
                __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_STOP);
            }
        }
Beispiel #4
0
        public byte MoveArduino(RP6_DIRECTION_ENUM direction)
        {
            if (Program._TrainConnection != null &&
                Program._TrainConnection._ARDUINO2IP != null &&
                Program._TrainConnection._ARDUINO2IP.Count > 0)
            {
                Arduino a = Program._TrainConnection.connectedTrains[0];

                _sMessage.EndPoint = Program._TrainConnection._ARDUINO2IP[a];

                _sMessage.TrainMessage.Action  = (byte)Actions.RP6_MOVE;
                _sMessage.TrainMessage.Data[0] = (byte)direction;
                _sMessage.TrainMessage.DataLen = 1;

                Program._CTrafficMessage.SendMessageEx(_sMessage, endPoint);
                return((byte)1);
            }
            return((byte)0);
        }
Beispiel #5
0
        public byte MoveArduino(RP6_DIRECTION_ENUM direction)
        {
            if (Program._TrainConnection != null &&
                Program._TrainConnection._ARDUINO2IP != null &&
                Program._TrainConnection._ARDUINO2IP.Count > 0)
            {
                Arduino a = Program._TrainConnection.connectedTrains[0];

                _sMessage.EndPoint = Program._TrainConnection._ARDUINO2IP[a];

                _sMessage.TrainMessage.Action = (byte)Actions.RP6_MOVE;
                _sMessage.TrainMessage.Data[0] = (byte)direction;
                _sMessage.TrainMessage.DataLen = 1;

                Program._CTrafficMessage.SendMessageEx(_sMessage, endPoint);
                return (byte)1;
            }
            return (byte)0;
        }
 private void controlTimer_Tick(object sender, EventArgs e)
 {
     if (_RP6Control != null)
     {
         if (nextStation)
         {
             nextStation = false;
             _RP6Control.NextStation();
         }
         if (forwards && !left && !right && lastState != RP6_DIRECTION_ENUM.RP6_FORWARD)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_FORWARD;
             this.controlPictureBox.Image = Properties.Resources.forwards;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_FORWARD);
         }
         if (left && !forwards && !backwards && lastState != RP6_DIRECTION_ENUM.RP6_LEFT)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_LEFT;
             this.controlPictureBox.Image = Properties.Resources.left;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_LEFT);
         }
         if (right && !forwards && !backwards && lastState != RP6_DIRECTION_ENUM.RP6_RIGHT)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_RIGHT;
             this.controlPictureBox.Image = Properties.Resources.right;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_RIGHT);
         }
         if (backwards && !left && !right && lastState != RP6_DIRECTION_ENUM.RP6_BACKWARD)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_BACKWARD;
             this.controlPictureBox.Image = Properties.Resources.backwards;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_BACKWARD);
         }
         if (forwards && left && lastState != RP6_DIRECTION_ENUM.RP6_FORWARD_LEFT)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_FORWARD_LEFT;
             this.controlPictureBox.Image = Properties.Resources.forwardsLeft;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_FORWARD_LEFT);
         }
         if (forwards && right && lastState != RP6_DIRECTION_ENUM.RP6_FORWARD_RIGHT)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_FORWARD_RIGHT;
             this.controlPictureBox.Image = Properties.Resources.forwardsRight;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_FORWARD_RIGHT);
         }
         if (backwards && left && lastState != RP6_DIRECTION_ENUM.RP6_BACKWARD_LEFT)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_BACKWARD_LEFT;
             this.controlPictureBox.Image = Properties.Resources.backwardsLeft;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_BACKWARD_LEFT);
         }
         if (backwards && right && lastState != RP6_DIRECTION_ENUM.RP6_BACKWARD_RIGHT)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_BACKWARD_RIGHT;
             this.controlPictureBox.Image = Properties.Resources.backwardsRight;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_BACKWARD_RIGHT);
         }
         if (!forwards && !backwards && !left && !right && lastState != RP6_DIRECTION_ENUM.RP6_STOP)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_STOP;
             this.controlPictureBox.Image = Properties.Resources.noMovement;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_STOP);
         }
     }
 }
 //Send message to arduino
 #region
 private void controlTimer_Tick(object sender, EventArgs e)
 {
     if (_RP6Control != null)
     {
         if (nextStation)
         {
             nextStation = false;
             _RP6Control.NextStation();
         }
         if (forwards && !left && !right && lastState != RP6_DIRECTION_ENUM.RP6_FORWARD)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_FORWARD;
             this.controlPictureBox.Image = Properties.Resources.forwards;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_FORWARD);
         }
         if (left && !forwards && !backwards && lastState != RP6_DIRECTION_ENUM.RP6_LEFT)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_LEFT;
             this.controlPictureBox.Image = Properties.Resources.left;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_LEFT);
         }
         if (right && !forwards && !backwards && lastState != RP6_DIRECTION_ENUM.RP6_RIGHT)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_RIGHT;
             this.controlPictureBox.Image = Properties.Resources.right;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_RIGHT);
         }
         if (backwards && !left && !right && lastState != RP6_DIRECTION_ENUM.RP6_BACKWARD)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_BACKWARD;
             this.controlPictureBox.Image = Properties.Resources.backwards;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_BACKWARD);
         }
         if (forwards && left && lastState != RP6_DIRECTION_ENUM.RP6_FORWARD_LEFT)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_FORWARD_LEFT;
             this.controlPictureBox.Image = Properties.Resources.forwardsLeft;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_FORWARD_LEFT);
         }
         if (forwards && right && lastState != RP6_DIRECTION_ENUM.RP6_FORWARD_RIGHT)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_FORWARD_RIGHT;
             this.controlPictureBox.Image = Properties.Resources.forwardsRight;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_FORWARD_RIGHT);
         }
         if (backwards && left && lastState != RP6_DIRECTION_ENUM.RP6_BACKWARD_LEFT)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_BACKWARD_LEFT;
             this.controlPictureBox.Image = Properties.Resources.backwardsLeft;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_BACKWARD_LEFT);
         }
         if (backwards && right && lastState != RP6_DIRECTION_ENUM.RP6_BACKWARD_RIGHT)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_BACKWARD_RIGHT;
             this.controlPictureBox.Image = Properties.Resources.backwardsRight;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_BACKWARD_RIGHT);
         }
         if (!forwards && !backwards && !left && !right && lastState != RP6_DIRECTION_ENUM.RP6_STOP)
         {
             lastState = RP6_DIRECTION_ENUM.RP6_STOP;
             this.controlPictureBox.Image = Properties.Resources.noMovement;
             _RP6Control.MoveArduino(RP6_DIRECTION_ENUM.RP6_STOP);
         }
     }
 }
Beispiel #8
0
 private void controlTimer_Tick_1(object sender, EventArgs e)
 {
     if (forwards && !left && !right && lastState != RP6_DIRECTION_ENUM.RP6_FORWARD)
     {
         lastState = RP6_DIRECTION_ENUM.RP6_FORWARD;
         this.pictureBox1.Image = Properties.Resources.forwards;
         __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_FORWARD);
     }
     if (left && !forwards && !backwards && lastState != RP6_DIRECTION_ENUM.RP6_LEFT)
     {
         lastState = RP6_DIRECTION_ENUM.RP6_LEFT;
         this.pictureBox1.Image = Properties.Resources.left;
         __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_LEFT);
     }
     if (right && !forwards && !backwards && lastState != RP6_DIRECTION_ENUM.RP6_RIGHT)
     {
         lastState = RP6_DIRECTION_ENUM.RP6_RIGHT;
         this.pictureBox1.Image = Properties.Resources.right;
         __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_RIGHT);
     }
     if (backwards && !left && !right && lastState != RP6_DIRECTION_ENUM.RP6_BACKWARD)
     {
         lastState = RP6_DIRECTION_ENUM.RP6_BACKWARD;
         this.pictureBox1.Image = Properties.Resources.backwards;
         __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_BACKWARD);
     }
     if (forwards && left && lastState != RP6_DIRECTION_ENUM.RP6_FORWARD_LEFT)
     {
         lastState = RP6_DIRECTION_ENUM.RP6_FORWARD_LEFT;
         this.pictureBox1.Image = Properties.Resources.forwardsLeft;
         __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_FORWARD_LEFT);
     }
     if (forwards && right && lastState != RP6_DIRECTION_ENUM.RP6_FORWARD_RIGHT)
     {
         lastState = RP6_DIRECTION_ENUM.RP6_FORWARD_RIGHT;
         this.pictureBox1.Image = Properties.Resources.forwardsRight;
         __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_FORWARD_RIGHT);
     }
     if (backwards && left && lastState != RP6_DIRECTION_ENUM.RP6_BACKWARD_LEFT)
     {
         lastState = RP6_DIRECTION_ENUM.RP6_BACKWARD_LEFT;
         this.pictureBox1.Image = Properties.Resources.backwardsLeft;
         __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_BACKWARD_LEFT);
     }
     if (backwards && right && lastState != RP6_DIRECTION_ENUM.RP6_BACKWARD_RIGHT)
     {
         lastState = RP6_DIRECTION_ENUM.RP6_BACKWARD_RIGHT;
         this.pictureBox1.Image = Properties.Resources.backwardsRight;
         __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_BACKWARD_RIGHT);
     }
     if (!forwards && !backwards && !left && !right)
     {
         lastState = RP6_DIRECTION_ENUM.RP6_STOP;
         this.pictureBox1.Image = Properties.Resources.noMovement;
         __RP6Control.SendMessage(RP6_DIRECTION_ENUM.RP6_STOP);
     }
 }