def set_adc_postfilter(global_data: Dict[str, Any]) -> None:
    """Set ADC postfilter.

    Args:
        global_data: Dictionary with global variables

    Returns:
        None

    """
    if '0' not in global_data["BOARDS"]:
        print(Fore.LIGHTMAGENTA_EX + "No analog input board available at",
              Fore.CYAN + "MODBUS address",
              Fore.CYAN + str(global_data["MODBUS_ADDRESS"]))
    else:
        print(Fore.CYAN + "Set ADC postfilter:")
        labels = [
            '27 SPS, 47 dB rejection, 36.7 ms settling',
            '25 SPS, 62 dB rejection, 40 ms settling',
            '20 SPS, 86 dB rejection, 50 ms settling',
            '16.67 SPS, 92 dB rejection, 60 ms settling', 'disable postfilter'
        ]
        for index, _ in enumerate(labels):
            print(Fore.YELLOW + '\t' + str(index) + ' for ' + labels[index])
        cs_addr, reg_val = utilities.request_reconfig_data(global_data)
        utilities.write_output_holding_reg(
            global_data, [global_data["MODBUS_ADDRESS"], cs_addr, 2], reg_val)
def set_adc_output_data_rate(global_data: Dict[str, Any]) -> None:
    """Set ADC output data rate.

    Args:
        global_data: Dictionary with global variables

    Returns:
        None

    """
    if '0' not in global_data["BOARDS"]:
        print(Fore.LIGHTMAGENTA_EX + "No analog input board available at",
              Fore.CYAN + "MODBUS address",
              Fore.CYAN + str(global_data["MODBUS_ADDRESS"]))
    else:
        print(Fore.CYAN + "Set ADC output data rate:")
        labels = [
            '31250 SPS', '31250 SPS', '31250 SPS', '31250 SPS', '31250 SPS',
            '31250 SPS', '15625 SPS', '10417 SPS', '5208 SPS', '2597 SPS',
            '1007 SPS', '503.8 SPS', '381 SPS', '200.3 SPS', '100.5 SPS',
            '59.52 SPS', '49.68 SPS', '20.01 SPS', '16.63 SPS', '10 SPS',
            '5 SPS', '2.5 SPS', '1.25 SPS'
        ]
        for index, _ in enumerate(labels):
            print(Fore.YELLOW + '\t' + str(index) + ' for ' + labels[index])
        cs_addr, reg_val = utilities.request_reconfig_data(global_data)
        utilities.write_output_holding_reg(
            global_data, [global_data["MODBUS_ADDRESS"], cs_addr, 3], reg_val)
def send_hart_command_0(global_data: Dict[str, Any]) -> None:
    """Send HART command 0.

    Args:
        global_data: Dictionary with global variables

    Returns:
        None

    """
    if '0' not in global_data["BOARDS"]:
        print(Fore.CYAN + "No analog input board available at",
              Fore.CYAN + "MODBUS address",
              Fore.CYAN + str(global_data["MODBUS_ADDRESS"]))
    else:
        print(Fore.CYAN + "Send HART command zero:")
        print(Fore.YELLOW + '\t' + '1 to send HART command 0')
        cs_addr, reg_val = utilities.request_reconfig_data(global_data)
        utilities.write_output_holding_reg(
            global_data, [global_data["MODBUS_ADDRESS"], cs_addr, 5], reg_val)
        if reg_val == 1:
            sleep(2)
            registers = read_analog_input_regs_cn0414(
                global_data, [global_data["MODBUS_ADDRESS"], cs_addr, 25], 30)
            response = ''
            for index, _ in enumerate(registers):
                response += str(hex(registers[index]).upper()[2:]) + " "
            print(Fore.GREEN + "DEVICE RESPONSE: " + Fore.YELLOW + response)
def send_hart_command_0(global_data: Dict[str, Any]) -> None:
    """Send HART command 0.

    Args:
        global_data: Dictionary with global variables

    Returns:
        None

    """
    if '1' not in global_data["BOARDS"]:
        print(Fore.CYAN + "No analog output board available at",
              Fore.CYAN + "MODBUS address",
              Fore.CYAN + str(global_data["MODBUS_ADDRESS"]))
    else:
        print(Fore.CYAN + "Send HART command zero:")
        print(Fore.YELLOW + '\t' + '1 to send HART command 0')
        cs_addr, reg_val = utilities.request_reconfig_data(global_data)
        utilities.write_output_holding_reg(
            global_data, [global_data["MODBUS_ADDRESS"], cs_addr, 5], reg_val)
def select_hart_channel(global_data: Dict[str, Any]) -> None:
    """Select HART channel.

    Args:
        global_data: Dictionary with global variables

    Returns:
        None

    """
    if '1' not in global_data["BOARDS"]:
        print(Fore.CYAN + "No analog output board available at",
              Fore.CYAN + "MODBUS address",
              Fore.CYAN + str(global_data["MODBUS_ADDRESS"]))
    else:
        print(Fore.CYAN + "Select HART channel:")
        labels = ['Channel 1', 'Channel 2', 'Channel 3', 'Channel 4']
        for index, _ in enumerate(labels):
            print(Fore.YELLOW + '\t' + str(index) + ' for ' + labels[index])
        cs_addr, reg_val = utilities.request_reconfig_data(global_data)
        utilities.write_output_holding_reg(
            global_data, [global_data["MODBUS_ADDRESS"], cs_addr, 6], reg_val)
def set_adc_output_code(global_data: Dict[str, Any]) -> None:
    """Set ADC output data coding.

    Args:
        global_data: Dictionary with global variables

    Returns:
        None

    """
    if '0' not in global_data["BOARDS"]:
        print(Fore.LIGHTMAGENTA_EX + "No analog input board available at",
              Fore.CYAN + "MODBUS address",
              Fore.CYAN + str(global_data["MODBUS_ADDRESS"]))
    else:
        print(Fore.CYAN + "Set ADC output code:")
        labels = ['bipolar coding', 'unipolar coding']
        for index, _ in enumerate(labels):
            print(Fore.YELLOW + '\t' + str(index) + ' for ' + labels[index])
        cs_addr, reg_val = utilities.request_reconfig_data(global_data)
        utilities.write_output_holding_reg(
            global_data, [global_data["MODBUS_ADDRESS"], cs_addr, 0], reg_val)