Beispiel #1
0
    def checkAnalogInputChannel(channel):
        """Check that the analog input number is value.
        Verify that the analog input number is one of the legal channel
        numbers.  Channel numbers are 0-based.

        :param channel: The channel number to check.
        """
        if not hal.checkAnalogInputChannel(channel):
            raise IndexError("Requested analog input channel number %d is out of range [0, %d)." % (channel, SensorUtil.kAnalogInputChannels))
    def __init__(self, channel):
        """Construct an analog channel.

        :param channel: The channel number to represent. 0-3 are on-board 4-7 are on the MXP port.
        """

        super().__init__()
        hal.checkAnalogInputChannel(channel)

        self.channel = channel
        self.accumulatorOffset = 0
        self.pidSource = self.PIDSourceType.kDisplacement

        port = hal.getPort(channel)
        self._port = hal.initializeAnalogInputPort(port)

        hal.report(hal.UsageReporting.kResourceType_AnalogChannel, channel)
        self.setName("AnalogInput", self.channel)

        self.__finalizer = weakref.finalize(self, _freeAnalogInput, self._port)
Beispiel #3
0
    def __init__(self, channel: int) -> None:
        """Construct an analog channel.

        :param channel: The channel number to represent. 0-3 are on-board 4-7 are on the MXP port.
        """

        super().__init__()
        hal.checkAnalogInputChannel(channel)

        self.channel = channel
        self.accumulatorOffset = 0
        self.pidSource = self.PIDSourceType.kDisplacement

        port = hal.getPort(channel)
        self.port = hal.initializeAnalogInputPort(port)

        hal.report(hal.UsageReporting.kResourceType_AnalogChannel, channel)
        self.setName("AnalogInput", self.channel)

        self.__finalizer = weakref.finalize(self, _freeAnalogInput, self.port)
Beispiel #4
0
    def checkAnalogInputChannel(channel: int) -> None:
        """Check that the analog input number is value.
        Verify that the analog input number is one of the legal channel
        numbers.  Channel numbers are 0-based.

        :param channel: The channel number to check.
        """
        if not hal.checkAnalogInputChannel(channel):
            raise IndexError(
                "Requested analog input channel number %d is out of range [0, %d)."
                % (channel, SensorUtil.kAnalogInputChannels)
            )
Beispiel #5
0
    def __init__(self, channel):
        """Construct an analog channel.
        :param channel: The channel number to represent. 0-3 are on-board 4-7 are on the MXP port.
        """
        if not hal.checkAnalogInputChannel(channel):
            raise IndexError("Analog input channel %d cannot be allocated. Channel is not present." % channel)
        try:
            AnalogInput.channels.allocate(self, channel)
        except IndexError as e:
            raise IndexError("Analog input channel %d is already allocated" % channel) from e

        self.channel = channel
        self.accumulatorOffset = 0

        port = hal.getPort(channel)
        self.port = hal.initializeAnalogInputPort(port)

        LiveWindow.addSensorChannel("AnalogInput", channel, self)
        hal.HALReport(hal.HALUsageReporting.kResourceType_AnalogChannel,
                      channel)
Beispiel #6
0
    def __init__(self, channel):
        """Construct an analog channel.
        :param channel: The channel number to represent. 0-3 are on-board 4-7 are on the MXP port.
        """
        if not hal.checkAnalogInputChannel(channel):
            raise IndexError(
                "Analog input channel %d cannot be allocated. Channel is not present."
                % channel)
        try:
            AnalogInput.channels.allocate(self, channel)
        except IndexError as e:
            raise IndexError("Analog input channel %d is already allocated" %
                             channel) from e

        self.channel = channel
        self.accumulatorOffset = 0

        port = hal.getPort(channel)
        self.port = hal.initializeAnalogInputPort(port)

        LiveWindow.addSensorChannel("AnalogInput", channel, self)
        hal.HALReport(hal.HALUsageReporting.kResourceType_AnalogChannel,
                      channel)