Esempio n. 1
0
    def initialize(self) -> None:
        """Initializes manager."""
        self.logger.info("Initializing")

        # Clear reported values
        self.clear_reported_values()

        # Initialize health
        self.health = 100.0

        # Initialize driver
        try:
            self.driver = T6713Driver(
                name=self.name,
                i2c_lock=self.i2c_lock,
                bus=self.parameters["communication"]["bus"],
                mux=int(self.parameters["communication"]["mux"], 16),
                channel=self.parameters["communication"]["channel"],
                address=int(self.parameters["communication"]["address"], 16),
                simulate=self.simulate,
                mux_simulator=self.mux_simulator,
            )
        except DriverError as e:
            self.logger.exception("Manager unable to initialize")
            self.health = 0.0
            self.mode = Modes.ERROR
Esempio n. 2
0
def test_init() -> None:
    driver = T6713Driver(
        name="Test",
        i2c_lock=threading.RLock(),
        bus=2,
        address=0x77,
        simulate=True,
        mux_simulator=MuxSimulator(),
    )
Esempio n. 3
0
def test_read_co2() -> None:
    driver = T6713Driver(
        name="Test",
        i2c_lock=threading.RLock(),
        bus=2,
        address=0x77,
        simulate=True,
        mux_simulator=MuxSimulator(),
    )
    co2 = driver.read_co2()
    assert co2 == 546.0
Esempio n. 4
0
def test_read_status() -> None:
    driver = T6713Driver(
        name="Test",
        i2c_lock=threading.RLock(),
        bus=2,
        address=0x77,
        simulate=True,
        mux_simulator=MuxSimulator(),
    )
    status = driver.read_status()
    assert status.error_condition == False
    assert status.flash_error == False
    assert status.calibration_error == False
    assert status.rs232 == False
    assert status.rs485 == False
    assert status.i2c == False
    assert status.warm_up_mode == False
    assert status.single_point_calibration == False
Esempio n. 5
0
    def run(self, *args: Any, **kwargs: Any) -> None:
        """Runs driver."""

        # Run parent class
        super().run(*args, **kwargs)

        # Initialize driver
        self.driver = T6713Driver(
            name=self.args.name,
            i2c_lock=threading.RLock(),
            bus=self.bus,
            address=self.address,
            mux=self.mux,
            channel=self.channel,
        )

        # Check if reading status
        if self.args.status:
            status = self.driver.read_status()
            print("Status: {}".format(status))

        # Check if setting up sensor
        if self.args.setup:
            self.driver.setup()

        # Check if reading carbon dioxide
        elif self.args.co2:
            co2 = self.driver.read_co2()
            print("Co2: {} ppm".format(co2))

        # Check if resetting sensor
        elif self.args.reset:
            self.driver.reset()

        # Check if enabling abc logic
        elif self.args.enable_abc:
            self.driver.enable_abc_logic()

        # Check if disabling abc logic
        elif self.args.disable_abc:
            self.driver.disable_abc_logic()