示例#1
0
def process_ble(file_tuple, slotsize=10, default=-100):
    try:
        # Get Sensor ID from path
        pop1, pop2 = file_tuple
        no1 = pop1[0:9]
        no2 = pop2[0:9]

        params = {
            "chunk_len": slotsize,
        }

        # Prepare results dictionary
        rv = {}
        rv["metadata"] = create_metadata([pop1, pop2], SCRIPT, params=params)

        # Compute results
        rv["results"] = compute(pop1, pop2, default=-100, slotsize=slotsize,
                                mode=MODE_BLE)

        # Save timestamp of finished processing
        rv["metadata"]["processing_end"] = \
            datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")

        # Save result json to file
        path = derive_result_path(no1, "ble", SCRIPT, no2, params=params)
        with open(path, "w") as fo:
            fo.write(dumps(rv, indent=4, sort_keys=True))

        # Redundant save for the other direction (Sensor2 -> Sensor1)
        # path = derive_result_path(no2, "ble", SCRIPT, no1, params=params)
        # with open(path, "w") as fo:
        #     fo.write(dumps(rv, indent=4, sort_keys=True))
    except Exception:
        print("Exception on BLE pair", file_tuple)
        traceback.print_exc()
def process_lux(pop, slotsize=60, fp_len=128, delta_rel=THRES_REL, delta_abs=THRES_ABS):
    # Get sensor number from path
    sensor = pop[0:9]

    params = {
        "chunk_len": slotsize,
        "fp_len": fp_len,
        "delta_rel": delta_rel,
        "delta_abs": delta_abs
    }

    # Get metadata
    rv = {}
    rv["metadata"] = create_metadata([pop], SCRIPT, params=params)

    # Compute and save the features
    print("[Acc] Computing features for Sensor", sensor)
    rv["results"] = compute(pop,
                            slotsize=slotsize,
                            fp_len=fp_len,
                            delta_rel=delta_rel,
                            delta_abs=delta_abs)

    # Save timestamp of finished processing
    rv["metadata"]["processing_end"] = \
        datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")

    # Save result json to file
    path = derive_result_path(sensor, "lux", SCRIPT, params=params)
    with open(path, "w") as fo:
        fo.write(dumps(rv, indent=4, sort_keys=True))
示例#3
0
def process_bar(files_tuple):
    pop1, pop2 = files_tuple
    # Get sensor number from path
    no1 = pop1[0:9]
    no2 = pop2[0:9]

    # Generate metadata
    rv = {}
    rv["metadata"] = create_metadata([pop1, pop2], SCRIPT)

    # Compute and save the features
    print("[BAR ] Computing features for Sensors", no1, "and", no2)
    rv["results"] = compute(pop1, pop2, bar=True)

    # Save timestamp of finished processing
    rv["metadata"]["processing_end"] = \
        datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")

    # Save result json to file
    path = derive_result_path(no1, "press", SCRIPT, no2)
    with open(path, "w") as fo:
        fo.write(dumps(rv, indent=4, sort_keys=True))