Ejemplo n.º 1
0
def pv_multiple_stream(database, var):

    # Get the list of IDs for the var name
    IDs = postgres_api.pv_internal(database, ret_id=var, front_end_abort=True)

    # get the configs for each ID
    configs, starts, ends, toggles, downloads = [], [], [], [], []
    for ID in IDs:
        configs.append(
            postgres_api.pv_meta_internal(database, ID, front_end_abort=True))
        starts.append("start-" + str(ID))
        ends.append("end-" + str(ID))
        toggles.append("toggle-" + str(ID))
        downloads.append("download-" + str(ID))

    # print config
    render_args = {
        "var": var,
        "IDs": IDs,
        "configs": configs,
        "starts": starts,
        "ends": ends,
        "toggles": toggles,
        "downloads": downloads,
        "database": database
    }
    return render_template('common/pv_multiple_stream.html', **render_args)
Ejemplo n.º 2
0
def build_data_browser_tree(checked=None):
    # get the redis instance names
    redis_names = [
    ]  #name for name,_ in app.config["REDIS_INSTANCES"].items()]
    # and the postgres isntance names
    postgres_names = [name for name in app.config["EPICS_INSTANCES"]]
    # build all of the trees
    trees = [postgres_api.pv_internal(name, front_end_abort=True) for name in postgres_names if postgres_api.is_valid_connection(name)] \
        + [online_metrics.build_link_tree(name, front_end_abort=True) for name in redis_names]

    # wrap them up at a top level
    tree_dict = {
        "text": "Data Browser",
        "expanded": True,
        "nodes": trees,
        "displayCheckbox": False,
    }
    # pre-check some instances
    if checked is None:
        checked = []
    for c in checked:
        database_type, database, ID = c
        # do a DFS down the nodes
        stack = [tree_dict]
        while len(stack) > 0:
            vertex = stack.pop()
            if "nodes" in vertex:
                stack = stack + vertex["nodes"]
            elif "ID" in vertex and "database" in vertex and "database_type" in vertex:
                if vertex["ID"] == ID and vertex[
                        "database"] == database and vertex[
                            "database_type"] == database_type:
                    vertex["state"] = {"checked": True}
                    # if we've found the vertex, we can exit the search
                    break
    return tree_dict
Ejemplo n.º 3
0
def pvTree(connection):
    return render_template('common/pvTree.html',
                           data=postgres_api.pv_internal(connection,
                                                         "pv_single_stream",
                                                         front_end_abort=True))