def main(argv):
    """Makes each peristaltic pump turn to both sides and stop."""

    # First initialize the device manager. This is mandatory to use any of the available
    # peristaltic pumps. Pump objects are created during the initialization of the DeviceManager.
    DeviceManager.init("peristaltic_pump")

    # The name of the pump to be tested is received as an argument.
    mode = argv[1]
    pump_name = argv[2]

    try:
        # Get pump object for the pump to be tested.
        pump = DeviceManager.peristaltic_pumps[pump_name]
    except KeyError:
        print('Pump [{}] does not exist.'.format(pump_name))
        raise

    if mode == "start":
        if int(argv[3]) == 0:
            pump_direction = False
        else:
            pump_direction = True
        pump.start(pump_direction)
    elif mode == "stop":
        pump.stop()
        DeviceManager.clean_finalize() # This ensures a clean exit
Example #2
0
def main():
    """Prints the measurements from the EC and PH probes to stdout."""

    # First initialize the device manager. This is mandatory to use any of the available
    # probes. Probe objects are created during the initialization of the DeviceManager.
    DeviceManager.init()

    probes = DeviceManager.probes

    # From this point on we use exclusively functions inside the probe class,
    # NOT the DeviceManager module.

    print('Displaying probe measurements...')

    try:
        while True:
            print("measurements: ", probes.get_measurements())
            sleep(1)
    except KeyboardInterrupt:
        # If a keyboard interrupt is detected then it exits cleanly!
        print('Finishing up!')
    finally:
        # Freeing up resources is done through the device manager as it is the one that knows
        # what pumps exist.
        DeviceManager.clean_finalize()  # This ensures a clean exit
Example #3
0
def main():
    """Prints the temperature measured by the water thermometer to stdout."""

    # First initialize the device manager. This is mandatory to use the water thermometer.
    # A water thermometer object is created during the initialization of the DeviceManager.
    DeviceManager.init("water_thermometer")

    water_thermometer = DeviceManager.water_thermometer

    # From this point on we use exclusively functions inside the WaterThermometer class,
    # NOT the DeviceManager module.

    print('Displaying water temperature measurements...')

    try:
        while True:
            print("Temperature: ",
                  str(water_thermometer.get_temperature_measurement()))
            sleep(3)
    except KeyboardInterrupt:
        # If a keyboard interrupt is detected then it exits cleanly!
        print('Finishing up!')
    finally:
        # Freeing up resources is done through the device manager as it is the one that knows
        # if the water thermometer exists.
        DeviceManager.clean_finalize()  # This ensures a clean exit
def main(argv):
    # First initialize the device manager.
    DeviceManager.init("solenoid_valve")

    valve = DeviceManager.solenoid_valve

    # From this point on we use exclusively functions inside the SolenoidValve class,
    # NOT the DeviceManager module.

    mode = argv[1]

    print (mode)
    if mode == "open":
        valve.open()
    elif mode == "close":
        valve.close()
        DeviceManager.clean_finalize() # This ensures a clean exit
Example #5
0
def main(argv):
    """Makes each peristaltic pump turn to both sides and stop."""

    # First initialize the device manager. This is mandatory to use the stepper motor.
    # A stepper motor object is created during the initialization of the DeviceManager.
    DeviceManager.init("stepper_motor")

    stepper = DeviceManager.stepper

    mode = argv[1]

    # From this point on we use exclusively functions inside the StepperMotor class,
    # NOT the DeviceManager module.

    if (mode == "start"):
        stepper.start(dir_forward=True)
    elif (mode == "stop"):
        stepper.stop()
        DeviceManager.clean_finalize()  # This ensures a clean exit
def main(argv):
    """Makes the water pump turn on and off."""

    # First initialize the device manager. This is mandatory to use any of the available
    # probes. Probe objects are created during the initialization of the DeviceManager.
    DeviceManager.init("water_pump")

    pump = DeviceManager.water_pump

    mode = argv[1]

    # From this point on we use exclusively functions inside the probe class,
    # NOT the DeviceManager module.

    if mode == "start":
        pump.start()
    elif mode == "stop":
        pump.stop()
        DeviceManager.clean_finalize()  # This ensures a clean exit
Example #7
0
def main():
    """Prints the weight measured by the group of load cells to stdout."""

    # First initialize the device manager. This is mandatory to use the group of load cells.
    # A load cell group object is created during the initialization of the DeviceManager.
    DeviceManager.init("load_cells")

    cells = DeviceManager.load_cells_object

    # From this point on we use exclusively functions inside the LoadCells class,
    # NOT the DeviceManager module.top

    try:
        while True:
            #Sleep both here and in the thread loop result in better CPU usage than just putting "pass" in the main while loop.
            sleep(0.2)
            #print(str(cells.get_weight_measurement() / 1))
            #sleep(0.5)
    finally:
        # Freeing up resources is done through the device manager as it is the one that knows
        # if the group of load cells exists.
        DeviceManager.clean_finalize()  # This ensures a clean exit