Ejemplo n.º 1
0
        private void DriverStationStateChanged(object sender, DriverStationStateChangedArgs e)
        {
            byte[] data = new byte[6];
            if (e.robot == false)
            {
                return;
            }

            switch (e.state.RobotMode)
            {
            case DriverStationState.Mode.Auto:
                data[3] |= cAutonomous;
                break;

            case DriverStationState.Mode.Teleop:
                data[3] |= cTeleoperated;
                break;

            case DriverStationState.Mode.Test:
                data[3] |= cTest;
                break;
            }

            if (e.state.Enabled)
            {
                data[3] |= cEnabled;
            }

            List <DSJoystick> joys = e.state.Joysticks;

            if (joys != null)
            {
                foreach (DSJoystick ds in joys)
                {
                    AddJoystickData(ref data, ds.Axis, ds.Buttons, ds.Povs);
                }
            }

            try
            {
                m_sender.BeginSend(data, data.Length, new AsyncCallback(SendCallback), null);
            }
            catch
            {
            }
        }
Ejemplo n.º 2
0
 private void StateChanged(object sender, DriverStationStateChangedArgs e)
 {
     if (InvokeRequired)
     {
         try
         {
             this.Invoke(new StateChangedDelegate(StateChanged), new object[] { e.state });
         }
         catch
         {
         }
     }
     else
     {
         StateChanged(e.state);
     }
 }