public JoystickStateListener(IJoystick js, PacketBuilder pb, JoystickStateStore holder)
 {
     this.joystick = js;
     this.handle = js.WaitHandle;
     this.packetBuilder = pb;
     this.holder = holder;
 }
        public CommunicationServer(JoystickStateStore stateStore)
        {
            this.stateStore = stateStore;
            port = SerialPortSingleton.Instance;

            if (!port.IsOpen)
                port.Open();

            inputBuffer = new List<byte>(Constants.InputBufferSize);
            outputBuffer = new List<byte>(Constants.OutputBufferSize);
        }
        private void initializeComponents()
        {
            initializeViews();

            initializeJoysticks();
            JoystickStateStore stateStore = new JoystickStateStore();

            initializeCommunicationServer(stateStore);

            pilotView.Show();
            coPilotView.Show();
        }
Esempio n. 4
0
        private void initializeComponents()
        {
            initializeViews();

            initializeJoysticks();
            JoystickStateStore stateStore = new JoystickStateStore();
            initializeJoystickListeners(stateStore);

            initializeCameraController();

            initializeTopSideActionsControllers();

            initializeCommunicationServer(stateStore);

            pilotView.Show();
            coPilotView.Show();

            SerialPortSingleton.Instance.Write(Constants.InitializationPacket,
                0, Constants.InitializationPacket.Length);
        }
Esempio n. 5
0
 private void initializeJoystickListeners(JoystickStateStore stateStore)
 {
     initializePilotJoystickListener(stateStore);
     initializeCoPilotRightJoystickListener(stateStore);
 }
Esempio n. 6
0
        private void initializeCoPilotRightJoystickListener(JoystickStateStore stateStore)
        {
            ManipulatorRightPacketBuilder rightPacketBuilder =
                new ManipulatorRightPacketBuilder(coPilotRightJoystick);
            coPilotRightStickListener = new JoystickStateListener(coPilotRightJoystick,
                rightPacketBuilder, stateStore);

            RunInBackgroundThread(coPilotRightStickListener.Listen);
        }
Esempio n. 7
0
 private void initializeCommunicationServer(JoystickStateStore stateStore)
 {
     ICommunicationServer comServer = new CommunicationServer(stateStore);
     RunInBackgroundThread(comServer.Serve);
     new RovStateReceivedHandler(comServer, (IPilotViewHandler)pilotView, (ICoPilotViewHandler)coPilotView);
 }
Esempio n. 8
0
        private void initializePilotJoystickListener(JoystickStateStore stateStore)
        {
            MainPacketBuilder mainPacketBuilder = new MainPacketBuilder(pilotJoystick);
            pilotStickListener = new JoystickStateListener(pilotJoystick,
                mainPacketBuilder, stateStore);

            RunInBackgroundThread(pilotStickListener.Listen);
        }
 public CommunicationServerMock(JoystickStateStore stateStore)
 {
     this.stateStore = stateStore;
     inputBuffer = new List<byte>(5);
     random = new Random();
 }
Esempio n. 10
0
        private void JoystickTracker_Load(object sender, EventArgs e)
        {
            joystick = new Joystick(this.Handle, 0, 250, JoystickType.MainController);
            System.Threading.WaitHandle waitHandle = new System.Threading.AutoResetEvent(false);
            joystick.Acquire(waitHandle);

            stateStore = new JoystickStateStore();

            if(Joystick.GetNumberOfJoysticks() > 1)
            {
                joystick2 = new Joystick(this.Handle, 0, 250, JoystickType.ManipulatorRight);
                System.Threading.WaitHandle waitHandle2 = new System.Threading.AutoResetEvent(false);
                joystick2.Acquire(waitHandle2);
                manipPacketBuilder = new ManipulatorRightPacketBuilder(joystick2);

                JoystickStateListener interruptListener2 = new JoystickStateListener(joystick2, manipPacketBuilder, stateStore);
                listener2 = new Thread(interruptListener2.Listen);
                listener2.IsBackground = true;
                listener2.Start();
            }

            mainpacketbuilder = new MainPacketBuilder(joystick);

            JoystickStateListener interruptListener = new JoystickStateListener(joystick, mainpacketbuilder, stateStore);
            interruptListener.JoystickStateChanged += JoystickState_Changed;
            listener = new Thread(interruptListener.Listen);
            listener.IsBackground = true;
            listener.Start();

            CommunicationServer comServer = new CommunicationServer(stateStore);
            comServer.RovStateReceived += RovState_Received;
            comThread = new Thread(comServer.Serve);
            comThread.IsBackground = true;
            comThread.Start();

            SerialPortSingleton.Instance.Write(Constants.InitializationPacket,
                0, Constants.InitializationPacket.Length);
        }