コード例 #1
0
def main(argv):
    import_manager = Import_Manager()
    thread_manager = Thread_Manager()
    usb_manager = USB_Manager()

    usb_manager.index()

    arguments = Arguments("settings.json",
                          argv,
                          positionals=[{
                              "name": "rf_sensor_class",
                              "help": "Sensor class to use for the RF sensor",
                              "type": "class",
                              "module": "zigbee.RF_Sensor",
                              "required": True
                          }])

    rf_sensor_class = arguments.get_positional_value("rf_sensor_class")
    rf_sensor_type = import_manager.load_class(rf_sensor_class,
                                               relative_module="zigbee")
    rf_sensor = rf_sensor_type(arguments,
                               thread_manager,
                               get_location,
                               receive_packet,
                               location_valid,
                               usb_manager=usb_manager)

    arguments.check_help()

    try:
        rf_sensor.activate()

        print("RF sensor has joined the network.")
        while True:
            if rf_sensor.id == 0:
                # The ground station does not need to start in order to receive
                # measurements, so do not bother giving this possibility.
                time.sleep(1)
            else:
                # Wait for the user to determine when to perform measurements
                # and when to stop. Add a newline so that the messages do not
                # mess up other output.
                raw_input("Press Enter to start measurements...\n")
                rf_sensor.start()

                raw_input("Press Enter to stop measurements...\n")
                rf_sensor.stop()
    except:
        traceback.print_exc()
        thread_manager.destroy()
        usb_manager.clear()
コード例 #2
0
def main(argv):
    import_manager = Import_Manager()
    thread_manager = Thread_Manager()
    usb_manager = USB_Manager()

    usb_manager.index()

    arguments = Arguments("settings.json", argv, positionals=[{
        "name": "rf_sensor_class",
        "help": "Sensor class to use for the RF sensor",
        "type": "class",
        "module": "zigbee.RF_Sensor",
        "required": True
    }])

    rf_sensor_class = arguments.get_positional_value("rf_sensor_class")
    rf_sensor_type = import_manager.load_class(rf_sensor_class,
                                               relative_module="zigbee")
    rf_sensor = rf_sensor_type(arguments, thread_manager, get_location,
                               receive_packet, location_valid, usb_manager=usb_manager)

    arguments.check_help()

    try:
        rf_sensor.activate()

        print("RF sensor has joined the network.")
        while True:
            if rf_sensor.id == 0:
                # The ground station does not need to start in order to receive 
                # measurements, so do not bother giving this possibility.
                time.sleep(1)
            else:
                # Wait for the user to determine when to perform measurements 
                # and when to stop. Add a newline so that the messages do not 
                # mess up other output.
                raw_input("Press Enter to start measurements...\n")
                rf_sensor.start()

                raw_input("Press Enter to stop measurements...\n")
                rf_sensor.stop()
    except:
        traceback.print_exc()
        thread_manager.destroy()
        usb_manager.clear()
コード例 #3
0
def main(argv):
    thread_manager = Thread_Manager()
    arguments = Arguments("settings.json", argv) 

    try:
        infrared_sensor = Infrared_Sensor(arguments, thread_manager)
    except OSError as e:
        arguments.error("Could not configure infrared sensor: {}".format(e))

    arguments.check_help()

    try:
        infrared_sensor.register("start", start_callback)
        infrared_sensor.register("stop", stop_callback)
        infrared_sensor.activate()

        while True:
            time.sleep(1)
    except:
        thread_manager.destroy()
コード例 #4
0
def main(argv):
    # Initialize, read parameters from input and set up problems
    stamp = int(time.time())

    thread_manager = Thread_Manager()
    import_manager = Import_Manager()
    arguments = Arguments("settings.json", argv)

    runner = Planning_Runner(arguments, thread_manager, import_manager,
                             iteration_callback)

    arguments.check_help()

    t_max = runner.get_iteration_limit()
    size = runner.get_population_size()

    print("Settings: Algorithm {}, mu={}, t_max={}".format(
        runner.algorithm.get_name(), size, t_max))
    print("Steps: {}".format(runner.algorithm.steps))

    indices = runner.start()

    # Show feasible solutions in a sorted manner.
    if len(indices) == 0:
        print("No feasible solutions found after {} iterations!".format(t_max))
        return

    print("Search variables an objective values for feasible solutions:")
    # If we have fewer nondominated solutions than the total number of
    # individuals, then only show the nondominated ones. Otherwise, just show
    # all feasible solutions.
    c = 0
    for i in indices:
        c += 1

        positions, unsnappable = runner.get_positions_plot(i, c, len(indices))
        if positions.size == 0:
            continue

        print("{}. {} ({})".format(i, runner.get_objectives(i), unsnappable))

        do_data("positions-{}-{}".format(stamp, c), positions.tolist())
        do_plot("display-{}-{}.eps".format(stamp, c))

    # Plot the pareto front between the two objectives.
    print("Pareto front after t={}".format(t_max))

    runner.make_pareto_plot()

    do_plot("front-{}.eps".format(stamp))