Ejemplo n.º 1
0
def __cal_flow_ratio(frame):
    field = data_field.find_flow_ratio_field()
    if len(frame) <= field.end_address:
        return None
    flow_ratio = math.byte_arr_convert_int(
        frame[field.begin_address:field.end_address + 1])
    return float(flow_ratio / 100.0)
Ejemplo n.º 2
0
def __cal_temperature(frame):
    field = data_field.find_temperature_field()
    if len(frame) <= field.end_address:
        return None
    temperature = math.byte_arr_convert_int(
        frame[field.begin_address:field.end_address + 1])
    return float(temperature / 10.0)
Ejemplo n.º 3
0
def __cal_power(frame):
    field = data_field.find_power_field()
    if len(frame) <= field.end_address:
        return None
    power = math.byte_arr_convert_int(
        frame[field.begin_address:field.end_address + 1])
    return power
Ejemplo n.º 4
0
def get_field_val(frame, opr_type):
    """
    获取域值
    :param frame:
    :param opr_type:
    :return:
    """
    # 数据域在数组中开始的索引
    __DATA_FIELD_BEGIN_INDEX = 4
    # 数据域在数组中结束的索引
    __DATA_FIELD_END_INDEX = 6
    if opr_type == Operator.RECHARGE:
        return math.byte_arr_convert_int(
            frame[__DATA_FIELD_BEGIN_INDEX:__DATA_FIELD_END_INDEX])
    elif opr_type == Operator.SET_FLOW_RATIO:
        return math.byte_arr_convert_int(
            frame[__DATA_FIELD_BEGIN_INDEX:__DATA_FIELD_END_INDEX]) / 100.0
    elif opr_type == Operator.SET_METER_ADDRESS:
        return math.byte_arr_convert_int(
            frame[__DATA_FIELD_BEGIN_INDEX:__DATA_FIELD_END_INDEX])
Ejemplo n.º 5
0
def __cal_total_flow(frame):
    int_field = data_field.find_total_flow_int_field()
    float_field = data_field.find_total_flow_float_field()
    res = 0.0
    if len(frame) > int_field.end_address:
        res += math.byte_arr_convert_int(
            frame[int_field.begin_address:int_field.end_address + 1])
    if len(frame) > float_field.end_address:
        res += math.calculate_double(
            frame[float_field.begin_address:float_field.end_address + 1])

    return float(res)
Ejemplo n.º 6
0
def __cal_surplus_gas(frame):
    """
    获取剩余气量
    :param frame:
    :return:
    """
    field = data_field.find_surplus_gas_field()
    if len(frame) <= field.end_address:
        return None
    surplus_gas = math.byte_arr_convert_int(
        frame[field.begin_address:field.end_address + 1])
    return surplus_gas