Esempio n. 1
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.
        """

        SensorBase.checkAnalogInputChannel(channel)

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

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

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

        self.__finalizer = weakref.finalize(self, _freeAnalogInput, self._port)
Esempio n. 2
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)
    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)
Esempio n. 4
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)
Esempio n. 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)