Exemple #1
0
def api_switch_state(request, actual=''):
    '''
    Get list of all switch states (Actual or Predicted)
    Returns something like this:

    [{"sw13to152": {"phase_C_state": "CLOSED", "phase_B_state": "CLOSED", "phase_A_state": "CLOSED"}}, {"sw61to6101": {"phase_C_state": "CLOSED", "phase_B_state": "CLOSED", "phase_A_state": "CLOSED"}}, {"sw18to135": {"phase_C_state": "CLOSED", "phase_B_state": "CLOSED", "phase_A_state": "CLOSED"}}]
    '''
    switch_state = {}
    elements_list = analyze.categorize_object_name("ieee123")['sw']
    if actual.lower() == 'actual':
        switch_state = analyze.get_actual_switch_states(elements_list)
        return JsonResponse(switch_state, safe=False)
    elif actual.lower() == 'predicted':
        switch_state = analyze.get_predicted_switch_states(elements_list)
        return JsonResponse(switch_state, safe=False)
    else:
        return JsonResponse(
            {
                'status':
                'false',
                'message':
                'Unknown state type: \'%s\'. Must be \'actual\' or \'predicted\''
                % actual
            },
            status=500)
Exemple #2
0
def api_sensors(request, element_query="list"):
    elements_list = analyze.categorize_object_name("ieee123")['sensor']
    return api_objects(request, "sensor", elements_list, element_query)
Exemple #3
0
def api_switches(request, element_query="list"):
    elements_list = analyze.categorize_object_name("ieee123")['sw']
    return api_objects(request, "sw", elements_list, element_query)
Exemple #4
0
def api_lines(request, element_query="list"):
    elements_list = analyze.categorize_object_name("ieee123")['line']
    return api_objects(request, "line", elements_list, element_query)
Exemple #5
0
def api_meters(request, element_query="list"):
    elements_list = analyze.categorize_object_name("ieee123")['meter']
    # import pdb; pdb.set_trace()
    return api_objects(request, "meter_", elements_list, element_query)