def start_sampling(self, frequency):
        cmd = CmdSampler()  # test what this does on a terminal

        with I2C.open(Host.I2C_SENSORS) as f:
            system_id = SystemID.load(Host)
            tag = None if system_id is None else system_id.message_tag()
            interface_conf = InterfaceConf.load(Host)
            interface = interface_conf.interface()
            gas_sensors = interface.gas_sensors(Host)
            ndir_monitor = None  # we don't use alphasenses for that.
            sht_conf = SHTConf.load(Host)
            sht = None if sht_conf is None else sht_conf.int_sht()

            runner = TimedRunner(cmd.interval, cmd.samples) if cmd.semaphore is None \
                else ScheduleRunner(cmd.semaphore, False)
            sampler = GasesSampler(runner, tag, ndir_monitor, sht, gas_sensors)
            sampler.start()

            for sample in sampler.samples():
                return JSONify.dumps(sample)

            sampler.stop()
Exemple #2
0
    if cmd.verbose:
        print("ndir_sampler: %s" % cmd, file=sys.stderr)

    try:
        # ------------------------------------------------------------------------------------------------------------
        # resources...

        # SystemID...
        system_id = SystemID.load(Host)

        tag = None if system_id is None else system_id.message_tag()

        I2C.Sensors.open()

        # Interface...
        interface_conf = InterfaceConf.load(Host)

        if interface_conf is None:
            print("ndir_sampler: InterfaceConf not available.",
                  file=sys.stderr)
            exit(1)

        interface = interface_conf.interface()

        if interface is None:
            print("ndir_sampler: Interface not available.", file=sys.stderr)
            exit(1)

        # NDIRConf...
        ndir_conf = NDIRConf.load(Host)