Exemple #1
0
def create_example_dataframe():
    """
    This is a helper function to display a example for plot_timeseries.py
    :return: a dataframe
    """
    CONFIG = config.Config()
    ORION_CB = orion.Orion(CONFIG)
    oak = create_entity(ORION_CB)
    quantum = ts.QuantumLeap(CONFIG)

    notify_url = "http://quantumleap:8668/v2/notify"

    sub_id = create_subscription(orion_cb=ORION_CB,
                                 quantum=quantum,
                                 entity=oak,
                                 notify_url=notify_url)

    update_attribute(orion_cb=ORION_CB, entity=oak, attribute_name="height")

    ORION_CB.update_attribute(oak.id, "leaves", "brown")

    dataframe = get_timeseries_data_as_df(quantum=quantum, entity=oak)

    # delete entity in crate DB
    quantum.delete_entity(oak.id)

    # delete subscriptions
    ORION_CB.delete_all_subscriptions()

    return dataframe
Exemple #2
0
def create_example_dataframe():
    """
    This is a helper function to display a example for plot_timeseries.py
    :return: a dataframe
    """
    CONFIG = config.Config()
    ORION_CB = ocb.Orion(CONFIG)
    oak = create_entity(ORION_CB)
    quantum = ts.QuantumLeap(CONFIG)
    """
    Function creates a test entity and registers it with the context broker 
    :param orion_cb: A Orion Context Broker Instance
    :return: An NGSI Entity object
    """
    oak = {
        "id": "Oak_nr_44",
        "type": "Tree",
        "height": {
            "value": 11,
            "type": "Integer"
        },
        "age": {
            "value": 7.5,
            "type": "Float"
        },
        "leaves": {
            "value": "green",
            "type": "String"
        },
    }
    oak_entity = ocb.Entity(oak)

    ORION_CB.post_json(oak_entity.get_json())
    return oak_entity
Exemple #3
0
    return dataframe


if __name__ == "__main__":
    #print(create_example_dataframe())

    # setup logging
    # before the first initalization the log_config.yaml.example file needs to be modified

    config.setup_logging()

    path_to_config = os.path.join(str(Path().resolve().parent), "config.json")

    # Reading the config
    CONFIG = config.Config(path_to_config)

    # creating an instance of the ORION context broker
    ORION_CB = ocb.Orion(CONFIG)

    #    ORION_CB.fiware_service = None

    # create an example entity
    oak = create_entity(ORION_CB)

    # create an instance of Quantumleap
    quantum = ts.QuantumLeap(CONFIG)

    #    quantum.fiware_service = None
    """ 
    throttling = 0
Exemple #4
0
    print(device)

    device.delete_attribute("pressure", "active")

    agent.post_group(device_group)
    agent.update_group(device_group)
    agent.get_groups(device_group)
    agent.post_device(device_group, device)
    agent.update_device(device_group, device, {})

    print(agent.get_device(device_group, device))
    print(ocb.get_all_entities())
    print(ocb.get_entity('urn:Room:002'))

    agent.delete_device(device_group, device)
    agent.delete_group(device_group)


if __name__ == "__main__":
    # setup logging
    # before the first initalization the log_config.yaml.example file needs to be modified

    path_to_config = os.path.join(str(Path().resolve().parent), "config.json")
    config.setup_logging()

    # Read and check configuration
    conf = config.Config(path_to_config)

    iota(conf)