Ejemplo n.º 1
0
    def __init__(self):
        """DriverStation constructor.

        The single DriverStation instance is created statically with the
        instance static member variable, you should never create a
        DriverStation instance.
        """

        if not hasattr(DriverStation,
                       'instance') or DriverStation.instance is not None:
            raise ValueError(
                "Do not create DriverStation instances, use DriverStation.getInstance() instead"
            )

        self.joystickMutex = threading.RLock()

        self.joystickAxes = [
            hal.JoystickAxes() for _ in range(self.kJoystickPorts)
        ]
        self.joystickPOVs = [
            hal.JoystickPOVs() for _ in range(self.kJoystickPorts)
        ]
        self.joystickButtons = [
            hal.JoystickButtons() for _ in range(self.kJoystickPorts)
        ]

        self.joystickAxesCache = [
            hal.JoystickAxes() for _ in range(self.kJoystickPorts)
        ]
        self.joystickPOVsCache = [
            hal.JoystickPOVs() for _ in range(self.kJoystickPorts)
        ]
        self.joystickButtonsCache = [
            hal.JoystickButtons() for _ in range(self.kJoystickPorts)
        ]

        self.controlWordMutex = threading.RLock()
        self.controlWordCache = hal.ControlWord()
        self.lastControlWordUpdate = 0

        # vars not initialized in constructor
        self.nextMessageTime = 0.0

        self.threadKeepAlive = True
        self.waitForDataPredicate = False

        self.userInDisabled = False
        self.userInAutonomous = False
        self.userInTeleop = False
        self.userInTest = False

        # Rest of constructor

        self.thread = threading.Thread(target=self._run,
                                       name="FRCDriverStation")
        self.thread.daemon = True
        self.thread.start()
Ejemplo n.º 2
0
    def __init__(self):
        """DriverStation constructor.

        The single DriverStation instance is created statically with the
        instance static member variable, you should never create a
        DriverStation instance.
        """
        if not hasattr(DriverStation, "instance") or DriverStation.instance is not None:
            raise ValueError(
                "Do not create DriverStation instances, use DriverStation.getInstance() instead"
            )

        # robotpy doesn't need to do this
        # hal.initialize(500, 0)
        self.waitForDataCount = 0
        self.waitForDataCond = threading.Condition()

        self.cacheDataMutex = threading.RLock()

        self.joystickAxes = [hal.JoystickAxes() for _ in range(self.kJoystickPorts)]
        self.joystickPOVs = [hal.JoystickPOVs() for _ in range(self.kJoystickPorts)]
        self.joystickButtons = [
            hal.JoystickButtons() for _ in range(self.kJoystickPorts)
        ]
        self.matchInfo = MatchInfoData()

        self.joystickButtonsPressed = [0 for _ in range(self.kJoystickPorts)]
        self.joystickButtonsReleased = [0 for _ in range(self.kJoystickPorts)]

        self.joystickAxesCache = [
            hal.JoystickAxes() for _ in range(self.kJoystickPorts)
        ]
        self.joystickPOVsCache = [
            hal.JoystickPOVs() for _ in range(self.kJoystickPorts)
        ]
        self.joystickButtonsCache = [
            hal.JoystickButtons() for _ in range(self.kJoystickPorts)
        ]
        self.matchInfoCache = hal.MatchInfo()

        self.controlWordMutex = threading.RLock()
        self.controlWordCache = hal.ControlWord()
        self.lastControlWordUpdate = 0

        self.matchDataSender = MatchDataSender()

        # vars not initialized in constructor
        self.nextMessageTime = 0.0

        self.threadKeepAlive = True
        self.waitForDataPredicate = False

        self.userInDisabled = False
        self.userInAutonomous = False
        self.userInTeleop = False
        self.userInTest = False

        # Rest of constructor

        self.thread = threading.Thread(target=self._run, name="FRCDriverStation")
        self.thread.daemon = True
        self.thread.start()