Esempio n. 1
0
    def __init__(self, channel):
        """Construct an analog output on a specified MXP channel.

        :param channel: The channel number to represent.
        """
        if not hal.checkAnalogOutputChannel(channel):
            raise IndexError(
                "Analog output channel %d cannot be allocated. Channel is not present."
                % channel)
        try:
            AnalogOutput.channels.allocate(self, channel)
        except IndexError as e:
            raise IndexError("Analog output channel %d is already allocated" %
                             channel) from e

        self.channel = channel

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

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

        self.__finalizer = weakref.finalize(self, _freeAnalogOutput,
                                            self._port)
Esempio n. 2
0
    def __init__(self, channel):
        """Construct an analog output on a specified MXP channel.

        :param channel: The channel number to represent.
        """
        SensorBase.checkAnalogOutputChannel(channel)
        
        self.channel = channel

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

        LiveWindow.addSensorChannel("AnalogOutput", channel, self)
        hal.report(hal.UsageReporting.kResourceType_AnalogChannel,
                      channel, 1)
        
        self.__finalizer = weakref.finalize(self, _freeAnalogOutput, self._port)
Esempio n. 3
0
    def __init__(self, channel: int) -> None:
        """Construct an analog output on a specified MXP channel.

        :param channel: The channel number to represent.
        """
        super().__init__()
        SensorUtil.checkAnalogOutputChannel(channel)

        self.channel = channel

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

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

        self.__finalizer = weakref.finalize(self, _freeAnalogOutput, self.port)
Esempio n. 4
0
    def __init__(self, channel):
        """Construct an analog output on a specified MXP channel.

        :param channel: The channel number to represent.
        """
        if not hal.checkAnalogOutputChannel(channel):
            raise IndexError("Analog output channel %d cannot be allocated. Channel is not present." % channel)
        try:
            AnalogOutput.channels.allocate(self, channel)
        except IndexError as e:
            raise IndexError("Analog output channel %d is already allocated" % channel) from e

        self.channel = channel

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

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