Exemplo n.º 1
0
def temp_query_data(request):
    dic={}
    data=get_from_queue()
    print("query_data", data)
    dic['data']=data
    json_dump=json.dumps(dic, cls=NpEncoder)
    return JsonResponse(json_dump, safe=False)
Exemplo n.º 2
0
def query_data(requset):
    dic = {}
    data = get_from_queue()
    data = data[:, ::32]
    print(data.shape, get_queue_remainder())
    dic["data"] = data.tolist()
    json_dump = json.dumps(dic)
    return JsonResponse(json_dump, safe=False)
Exemplo n.º 3
0
def query_data(request):
    dic = {}
    data = get_from_queue() # data.shape => (8, 2048)

    # print("data:", data)

    # sample the data for display
    sampling_interval_for_display = 1024
    time_interval = 1 / 2048 * sampling_interval_for_display
    data_for_display = data[:,::sampling_interval_for_display]
    now_time = time.time()
    print("data for display", data_for_display)
    print(now_time)
    temp_display_dic = []
    for i in range(data_for_display.shape[0]):
        _temp_dic = []
        for j in range(data_for_display.shape[1]):
            _temp_dic.append({
                "x" : now_time + time_interval * j,
                "y" : data_for_display[i][j]
            })
        temp_display_dic.append(_temp_dic)
    dic["data"] = temp_display_dic
    print("data", temp_display_dic)
    
    # predict the label
    data_for_predict = data.T.reshape([-1, 128, 8])
    result = predict_label(data_for_predict)
    result = np.argmax(result, axis=1)
    print("predicted result",result)
    dic["label"] = result.tolist()

    # build return value
    json_dump = json.dumps(dic)

    return JsonResponse(json_dump, safe=False)
Exemplo n.º 4
0
def query_data_new(request):
    temp_dic = get_from_queue()
    json_dump = json.dumps(temp_dic)
    return JsonResponse(json_dump, safe=False)
Exemplo n.º 5
0
def temp_output():
    while True:
        time.sleep(1 / 32)
        print(get_from_queue().shape)
        print(get_queue_remainder(), time.time())