/************************************************************************************/
/*  Copyright (C)           Mettler-Toledo All Rights Reserved                      */
/*  Product:                M400PA Module                                           */
/*                                                                                  */
/*  Device:                 M400PA Module for PROFIBUS PA                           */
/*  Description:            Device Description File                                 */
/*  Dictionary:             SIPADC01.dct and MTdct.dct                              */
/*                                                                                  */
/*  Revision:  1.0                                                                  */
/*  Date:      2013-09-30                                                           */
/*  Author:    Ning Dekui                                                           */
/************************************************************************************/
MANUFACTURER            0x8E,
DEVICE_TYPE             0x01,
DEVICE_REVISION         0x01,
DD_REVISION             0x01

#define DEVICE_NAME          "M400 PA"
#define DEF_TRANSMITTER_NAME "M400 PA series"
#define DEF_TRANSMITTER_PN   "30026617"

#include "SI_FileM.inc"
#include "SI_HlpM.inc"
#include "SI_OptM.inc"
//raus!!!!  fbi	#include "SIPAST_CommError.inc"

#define	YT1_LABEL	[MT_Output_Value_AI_1]
#define	YT1_VALUE	func1_AI_1_out_value
#define	YT1_LRV		func1_AI_1_out_lower_range_value
#define	YT1_URV		func1_AI_1_out_upper_range_value

#define	YT2_LABEL	[MT_Output_Value_AI_2]
#define	YT2_VALUE	func1_AI_2_out_value
#define	YT2_LRV		func1_AI_2_out_lower_range_value
#define	YT2_URV		func1_AI_2_out_upper_range_value

#define	YT3_LABEL	[MT_Output_Value_AI_3]
#define	YT3_VALUE	func1_AI_3_out_value
#define	YT3_LRV		func1_AI_3_out_lower_range_value
#define	YT3_URV		func1_AI_3_out_upper_range_value

#define	YT4_LABEL	[MT_Output_Value_AI_4]
#define	YT4_VALUE	func1_AI_4_out_value
#define	YT4_LRV		func1_AI_4_out_lower_range_value
#define	YT4_URV		func1_AI_4_out_upper_range_value

#include "SI_YT.inc"

/*
#include "SI_MainMenu.inc"
#include "SI_ViewM.inc"
*/

#include "defmacros.inc"
#include "Phys_Blk.inc"
#include "TB1_Blk1.inc"
#include "AI4_Blk1.inc"
#include "AO1_Blk5.inc"
#include "DI2_Blk6.inc"
#include "DO2_Blk8.inc"

#define DEVICE_MANUAL_FILENAME "Manual_M400_PA_en_03_14.pdf"
METHOD methodOpenDeviceManual
{
	LABEL "Device Manual" ;
//	ACCESS OFFLINE ;
	DEFINITION
	{
		ShellExecute(DEVICE_MANUAL_FILENAME) ;
	}
}
#define DEVICE_MANUAL_FILENAME2 "M400 PA parameters_05_14.pdf"
METHOD methodOpenparameter
{
	LABEL "Device Parameters" ;
//	ACCESS OFFLINE ;
	DEFINITION
	{
		ShellExecute(DEVICE_MANUAL_FILENAME2) ;
	}
}
#define DEVICE_MANUAL_FILENAME3 "QSG_M400_PA_en_04_14.pdf"
METHOD methodOpenQuickSetupGuide
{
	LABEL "Quick Setup Guide" ;
//	ACCESS OFFLINE ;
	DEFINITION
	{
		ShellExecute(DEVICE_MANUAL_FILENAME3) ;
	}
}


/***********************************************************************/
/*****  Menu: Specialist  **********************************************/
/***********************************************************************/

MENU Menu_Main_Specialist
{
    LABEL        [main_menu];
    ITEMS
    {
        Menu_File,
        Menu_S_Device,
        Menu_S_View,
        Menu_Options,
        Menu_Help
    }
}

/***********************************************************************/
/*****  Menu: Maintenance  *********************************************/
/***********************************************************************/

MENU Menu_Main_Maintenance
{
    LABEL        [main_menu];
    ITEMS
    {
        Menu_File,
        Menu_M_Device,
        Menu_S_View,
        Menu_Options,
        Menu_Help
    }
}

MENU upload_variables
{
    LABEL        [menu_load_to_device];
    ITEMS
    {
        /* PHYSICAL BLOCK    */
        phys_tag_desc,
        phys_descriptor,
        phys_message,
        phys_install_date,
        phys_local_operation_enable,
        phys_strategy,
        phys_alert_key,

        /* TRANDSDUCER BLOCK 1: */
        trans1_tag_desc,
//        trans1_strategy,
//        trans1_alert_key,
/* load_to_device   Modbus Address : 500    */
        trans1_auto_recognize,
        trans1_sensor_type,
        trans1_primary_value_aver,
        trans1_secondary_value_aver,
        trans1_third_value_aver,
        trans1_fourth_value_aver,
        trans1_alarm_flags,
/* load_to_device   Modbus Address : 1000   */
        IF (SENSOR_CHANNEL_ANALOG)
        {
            trans1_temp_sensor_type,
            IF(trans1_temp_sensor_type == 4)
            {
                trans1_temp_fixed_value_degc,
                trans1_temp_cal_fixed_value,
            }
        }
/* load_to_device   Modbus Address : 1200   */
        IF(SENSOR_PH || SENSOR_CO2)
        {
            trans1_ph_buffer_mode,
            trans1_ph_slope_display,
            trans1_ph_offset_display,
        }
        IF(SENSOR_PH)
        {
            trans1_ph_stc_ref_mode,
            trans1_ph_stc_ref_temp,
            trans1_ph_stc_ref_value,
            trans1_ph_ip,
        }
        IF(SENSOR_CO2)
        {
            trans1_ph_salinity,
            trans1_ph_hco3,
            trans1_ph_totpres_unit,
            trans1_ph_totpres,
        }
/* load_to_device   Modbus Address : 1100   */
        trans1_cal_drift,
//        trans1_cal_point,
//        trans1_cal_unit,
//        trans1_cal_recode,
//        trans1_cal_recode_point,
//        trans1_cal_save_type,
//        trans1_entry_cal_edit,
//        trans1_entry_cal_point,
//        trans1_cal_mode,
/* load_to_device   Modbus Address : 1300   */
        IF(SENSOR_O2||SENSOR_O2_OPT)
        {
            trans1_o2_cal_pre_unit,
            trans1_o2_cal_pre_value,
            trans1_o2_pro_pre_select,
            trans1_o2_pro_pre_mode,
            trans1_o2_pro_pre_unit,
            trans1_o2_pro_pre_value,
            trans1_ain_4ma_pre,
            trans1_ain_4ma_pre_unit,
            trans1_ain_20ma_pre,
            trans1_ain_20ma_pre_unit,
            trans1_o2_sailinity,
            trans1_o2_meas_humidity,
            //trans1_cal_meas_humidity,
        }
        IF(SENSOR_O2)
        {
            trans1_o2_meas_polar,
            trans1_o2_cal_polar,
        }
        IF(SENSOR_O2_OPT)
        {
            trans1_led_mode,
            trans1_led_toff,
            trans1_sample_rate,
            trans1_proccal_mode,
        }
/* load_to_device   Modbus Address : 1400   */
        IF(SENSOR_COND)
        {
            trans1_pv_com_mode,
            trans1_sv_com_mode,
            trans1_tv_com_mode,
            trans1_qv_com_mode,
            trans1_cal_com_mode,
            trans1_pv_linear_val,
            trans1_sv_linear_val,
            trans1_tv_linear_val,
            trans1_qv_linear_val,
            trans1_cal_linear_val,
        }
/* load_to_device   Modbus Address : 1500   */
        IF(SENSOR_CO2_B)
        {
            trans1_co2_solub_mode,
            IF(trans1_co2_solub_mode == 3)
            {
                trans1_co2_soulb_value,
                trans1_co2_temp_factor,
            }
        }
/* load_to_device   Modbus Address : 2000   */
//        IF(SENSOR_DIGITAL_CONNECT_ONLY)
//        {
//            trans1_sensor_name,
//            trans1_sensor_pn,
//           trans1_sensor_sn,
//            trans1_sensor_fw,
//            trans1_sensor_hw,
//            trans1_functions_enable_flag,
/* load_to_device   Modbus Address : 2100   */
//            IF((trans1_functions_enable_flag & _OPERATION_DAY_ENABLE) && SENSOR_DIGITAL_CONNECT_ONLY)
//            {
//                trans1_operationg_days,
//            }
//            IF((trans1_functions_enable_flag & _MAX_TEMP_DATE_ENABLE) && SENSOR_DIGITAL_CONNECT_ONLY)
//            {
//                trans1_max_temperature,
//                trans1_max_temperture_date,
//            }
//            IF((trans1_functions_enable_flag & _TTM_ENABLE) && SENSOR_DIGITAL_CONNECT_ONLY)
//            {
//                trans1_cur_ttm_in_days,
//                trans1_cur_ttm_in_per,
//            }
//            IF((trans1_functions_enable_flag & _ACT_ENABLE) && SENSOR_DIGITAL_CONNECT_ONLY)
//            {
//                trans1_cur_act_in_days,
//                trans1_cur_act_in_per,
//            }
//            IF((trans1_functions_enable_flag & _DLI_ENABLE) && SENSOR_DIGITAL_CONNECT_ONLY)
//            {
//                trans1_dli_in_days,
//                trans1_dli_in_per,
//            }
//            IF((trans1_functions_enable_flag & _CIP_ENABLE) && SENSOR_DIGITAL_CONNECT_ONLY)
//            {
//                trans1_cip_cur_counter,
//            }
//            IF((trans1_functions_enable_flag & _SIP_ENABLE) && SENSOR_DIGITAL_CONNECT_ONLY)
//            {
//                trans1_sip_cur_counter,
//            }
//            IF((trans1_functions_enable_flag & _AUTOCLAVE_ENABLE) && SENSOR_DIGITAL_CONNECT_ONLY)
//            {
//                trans1_autoclave_counter,
//            }
//        }
	IF(SENSOR_CHANNEL_DIGITAL)
	{
        	trans1_cip_temperature,
        	trans1_cip_limit,
        	trans1_sip_temperature,
        	trans1_sip_limit,
        	trans1_autoclave_limit,
        	trans1_max_ttm_in_days,
        	trans1_max_act_in_days,
        	trans1_ph_stress_adj,
	}
        IF(SENSOR_O3 && SENSOR_CONNECTED)
        {
            trans1_san_max_cycles,
            trans1_conc_max,
            trans1_conc_min,
            trans1_cycle_time,
        }
//        trans1_last_cal_date,
//        trans1_enable_flag,
//        trans1_offset_unit1_code,
//        trans1_offset_unit2_code,
//        trans1_slope_unit1_code,
//        trans1_slope_unit2_code,
//        trans1_offset_with_unit1,
//        trans1_offset_with_unit2,
//        trans1_slope_with_unit1,
//        trans1_slope_with_unit2,
//        trans1_mv_offset,
//        trans1_pt_slope,
//        trans1_pt_offset,
//        trans1_ntc22k_offset,
//        trans1_fact_date,
//        trans1_fact_o1,
//        trans1_fact_o2,
//        trans1_fact_s1,
//        trans1_fact_s2,
//        trans1_history_block_enable,
//        trans1_1st_date,
//        trans1_1st_o1,
//        trans1_1st_o2,
//        trans1_1st_s1,
//        trans1_1st_s2,
//        trans1_cal1_date,
//        trans1_cal1_o1,
//        trans1_cal1_o2,
//        trans1_cal1_s1,
//        trans1_cal1_s2,
//        trans1_cal2_date,
//        trans1_cal2_o1,
//        trans1_cal2_o2,
//        trans1_cal2_s1,
//        trans1_cal2_s2,
//        trans1_cal3_date,
//        trans1_cal3_o1,
//        trans1_cal3_o2,
//        trans1_cal3_s1,
//        trans1_cal3_s2,
//        trans1_transmitter_name,
//        trans1_transmitter_pn,
//        trans1_transmitter_model,
//        trans1_transmitter_model_id,
//        trans1_transmitter_sn,
//        trans1_mainboard_fw,
//        trans1_mainboard_hw,
//        trans1_sensorboard_fw,
//        trans1_sensorboard_hw,
//        trans1_ffboard_fw,
//        trans1_ffboard_hw,
//        trans1_protocol_version,
//        trans1_soft_lock,

        /* FUNCTION BLOCK 1: AI 1    */
        func1_AI_1_tag_desc,
        func1_AI_1_batch_id,
        func1_AI_1_batch_unit,
        func1_AI_1_batch_operation,
        func1_AI_1_batch_phase,
        func1_AI_1_channel,
        func1_AI_1_lin_type,
        func1_AI_1_pv_ftime,
        func1_AI_1_pv_upper_range_value,
        func1_AI_1_pv_lower_range_value,
        func1_AI_1_out_upper_range_value,
        func1_AI_1_out_lower_range_value,
        func1_AI_1_out_unit,
        func1_AI_1_out_decimal_point,
        func1_AI_1_alarm_hys,
        func1_AI_1_hi_hi_lim,
        func1_AI_1_hi_lim,
        func1_AI_1_lo_lim,
        func1_AI_1_lo_lo_lim,
        func1_AI_1_FSafeType,
        func1_AI_1_FSafeValue,
        func1_AI_1_out_unit_text,

        /* FUNCTION BLOCK 2: AI 2    */
        func1_AI_2_tag_desc,
        func1_AI_2_batch_id,
        func1_AI_2_batch_unit,
        func1_AI_2_batch_operation,
        func1_AI_2_batch_phase,
        func1_AI_2_channel,
        func1_AI_2_lin_type,
        func1_AI_2_pv_ftime,
        func1_AI_2_pv_upper_range_value,
        func1_AI_2_pv_lower_range_value,
        func1_AI_2_out_upper_range_value,
        func1_AI_2_out_lower_range_value,
        func1_AI_2_out_unit,
        func1_AI_2_out_decimal_point,
        func1_AI_2_alarm_hys,
        func1_AI_2_hi_hi_lim,
        func1_AI_2_hi_lim,
        func1_AI_2_lo_lim,
        func1_AI_2_lo_lo_lim,
        func1_AI_2_FSafeType,
        func1_AI_2_FSafeValue,
        func1_AI_2_out_unit_text,

        /* FUNCTION BLOCK 3: AI 3    */
        func1_AI_3_tag_desc,
        func1_AI_3_batch_id,
        func1_AI_3_batch_unit,
        func1_AI_3_batch_operation,
        func1_AI_3_batch_phase,
        func1_AI_3_channel,
        func1_AI_3_lin_type,
        func1_AI_3_pv_ftime,
        func1_AI_3_pv_upper_range_value,
        func1_AI_3_pv_lower_range_value,
        func1_AI_3_out_upper_range_value,
        func1_AI_3_out_lower_range_value,
        func1_AI_3_out_unit,
        func1_AI_3_out_decimal_point,
        func1_AI_3_alarm_hys,
        func1_AI_3_hi_hi_lim,
        func1_AI_3_hi_lim,
        func1_AI_3_lo_lim,
        func1_AI_3_lo_lo_lim,
        func1_AI_3_FSafeType,
        func1_AI_3_FSafeValue,
        func1_AI_3_out_unit_text,

        /* FUNCTION BLOCK 4: AI 4    */
        func1_AI_4_tag_desc,
        func1_AI_4_batch_id,
        func1_AI_4_batch_unit,
        func1_AI_4_batch_operation,
        func1_AI_4_batch_phase,
        func1_AI_4_channel,
        func1_AI_4_lin_type,
        func1_AI_4_pv_ftime,
        func1_AI_4_pv_upper_range_value,
        func1_AI_4_pv_lower_range_value,
        func1_AI_4_out_upper_range_value,
        func1_AI_4_out_lower_range_value,
        func1_AI_4_out_unit,
        func1_AI_4_out_decimal_point,
        func1_AI_4_alarm_hys,
        func1_AI_4_hi_hi_lim,
        func1_AI_4_hi_lim,
        func1_AI_4_lo_lim,
        func1_AI_4_lo_lo_lim,
        func1_AI_4_FSafeType,
        func1_AI_4_FSafeValue,
        func1_AI_4_out_unit_text,

        /* FUNCTION BLOCK 5: AO 1    */
        func3_AO_1_tag_desc,
        func3_AO_1_batch_id,
        func3_AO_1_batch_unit,
        func3_AO_1_batch_operation,
        func3_AO_1_batch_phase,
        //func3_AO_1_in_channel,
        //func3_AO_1_out_channel,
        func3_AO_1_pv_upper_range_value,
        func3_AO_1_pv_lower_range_value,
        func3_AO_1_pv_unit,
        func3_AO_1_pv_decimal_point,
        func3_AO_1_out_upper_range_value,
        func3_AO_1_out_lower_range_value,
        func3_AO_1_out_unit,
        func3_AO_1_out_decimal_point,
        func3_AO_1_fsafe_type,
        func3_AO_1_fsafe_time,
        func3_AO_1_fsafe_value,
        func3_AO_1_increase_close,

        /* FUNCTION BLOCK 6: DI 1    */
        func4_DI_1_tag_desc,
        func4_DI_1_batch_id,
        func4_DI_1_batch_unit,
        func4_DI_1_batch_operation,
        func4_DI_1_batch_phase,
        //func4_DI_1_channel,
        func4_DI_1_invert,
        func4_DI_1_fsafe_type,
        func4_DI_1_fsafe_value,

        /* FUNCTION BLOCK 7: DI 2    */
        func4_DI_2_tag_desc,
        func4_DI_2_batch_id,
        func4_DI_2_batch_unit,
        func4_DI_2_batch_operation,
        func4_DI_2_batch_phase,
        //func4_DI_2_channel,
        func4_DI_2_invert,
        func4_DI_2_fsafe_type,
        func4_DI_2_fsafe_value,

        /* FUNCTION BLOCK 8: DO 1    */
        func5_DO_1_tag_desc,
        func5_DO_1_batch_id,
        func5_DO_1_batch_unit,
        func5_DO_1_batch_operation,
        func5_DO_1_batch_phase,
        //func5_DO_1_channel,
        func5_DO_1_invert,
        func5_DO_1_fsafe_type,
        func5_DO_1_fsafe_time,
        func5_DO_1_fsafe_value,

        /* FUNCTION BLOCK 9: DO 2    */
        func5_DO_2_tag_desc,
        func5_DO_2_batch_id,
        func5_DO_2_batch_unit,
        func5_DO_2_batch_operation,
        func5_DO_2_batch_phase,
        //func5_DO_2_channel,
        func5_DO_2_invert,
        func5_DO_2_fsafe_type,
        func5_DO_2_fsafe_time,
        func5_DO_2_fsafe_value
    }
    PRE_READ_ACTIONS
    {
        method_pre_write_phys_write_locking
    }
}

MENU download_variables
{
    LABEL  [menu_load_to_PC];
    ITEMS
    {
        phys_device_man_id,
        phys_device_id,

        phys_tag_desc,
        func1_AI_1_tag_desc,
        func1_AI_2_tag_desc,
        func1_AI_3_tag_desc,
        func1_AI_4_tag_desc,
        func3_AO_1_tag_desc,
        func4_DI_1_tag_desc,
        func4_DI_2_tag_desc,
        func5_DO_1_tag_desc,
        func5_DO_2_tag_desc,

        phys_descriptor,
        phys_message,
        phys_install_date,
        phys_device_ser_num,

        phys_st_rev,
//        phys_software_rev,
//        phys_hardware_rev,
        phys_blk_profile,
        phys_blk_profile_rev,
        phys_blk_dd_reference,
        phys_blk_dd_rev,
        phys_device_certification,

        phys_diagnosis,
        phys_diagnosis_extension,
        

        /* FUNCTION BLOCK 1: AI 1    */
        func1_AI_1_st_rev,
        func1_AI_1_target_mode,
        func1_AI_1_actual_mode,
        func1_AI_1_pv_lower_range_value,
        func1_AI_1_pv_upper_range_value,
        func1_AI_1_out_lower_range_value,
        func1_AI_1_out_upper_range_value,
        func1_AI_1_out_unit,
        func1_AI_1_out_decimal_point,
        func1_AI_1_pv_ftime,
        func1_AI_1_lo_lo_lim,
        func1_AI_1_lo_lim,
        func1_AI_1_hi_lim,
        func1_AI_1_hi_hi_lim,
        func1_AI_1_alarm_hys,
        func1_AI_1_FSafeType,
        func1_AI_1_FSafeValue,
        func1_AI_1_batch_id,
        func1_AI_1_batch_unit,
        func1_AI_1_batch_operation,
        func1_AI_1_batch_phase,

        /* FUNCTION BLOCK 2: AI 2    */
        func1_AI_2_st_rev,
        func1_AI_2_target_mode,
        func1_AI_2_actual_mode,
        func1_AI_2_pv_lower_range_value,
        func1_AI_2_pv_upper_range_value,
        func1_AI_2_out_lower_range_value,
        func1_AI_2_out_upper_range_value,
        func1_AI_2_out_unit,
        func1_AI_2_out_decimal_point,
        func1_AI_2_pv_ftime,
        func1_AI_2_lo_lo_lim,
        func1_AI_2_lo_lim,
        func1_AI_2_hi_lim,
        func1_AI_2_hi_hi_lim,
        func1_AI_2_alarm_hys,
        func1_AI_2_FSafeType,
        func1_AI_2_FSafeValue,
        func1_AI_2_batch_id,
        func1_AI_2_batch_unit,
        func1_AI_2_batch_operation,
        func1_AI_2_batch_phase,

        /* FUNCTION BLOCK 3: AI 3    */
        func1_AI_3_st_rev,
        func1_AI_3_target_mode,
        func1_AI_3_actual_mode
        func1_AI_3_pv_lower_range_value,
        func1_AI_3_pv_upper_range_value,
        func1_AI_3_out_lower_range_value,
        func1_AI_3_out_upper_range_value,
        func1_AI_3_out_unit,
        func1_AI_3_out_decimal_point,
        func1_AI_3_pv_ftime,
        func1_AI_3_lo_lo_lim,
        func1_AI_3_lo_lim,
        func1_AI_3_hi_lim,
        func1_AI_3_hi_hi_lim,
        func1_AI_3_alarm_hys,
        func1_AI_3_FSafeType,
        func1_AI_3_FSafeValue,
        func1_AI_3_batch_id,
        func1_AI_3_batch_unit,
        func1_AI_3_batch_operation,
        func1_AI_3_batch_phase,

        /* FUNCTION BLOCK 4: AI 4    */
        func1_AI_4_st_rev,
        func1_AI_4_target_mode,
        func1_AI_4_actual_mode,
        func1_AI_4_pv_lower_range_value,
        func1_AI_4_pv_upper_range_value,
        func1_AI_4_out_lower_range_value,
        func1_AI_4_out_upper_range_value,
        func1_AI_4_out_unit,
        func1_AI_4_out_decimal_point,
        func1_AI_4_pv_ftime,
        func1_AI_4_lo_lo_lim,
        func1_AI_4_lo_lim,
        func1_AI_4_hi_lim,
        func1_AI_4_hi_hi_lim,
        func1_AI_4_alarm_hys,
        func1_AI_4_FSafeType,
        func1_AI_4_FSafeValue,
        func1_AI_4_batch_id,
        func1_AI_4_batch_unit,
        func1_AI_4_batch_operation,
        func1_AI_4_batch_phase,

        /* FUNCTION BLOCK 5: AO 1    */
        func3_AO_1_st_rev,
        func3_AO_1_target_mode,
        //func3_AO_1_in_channel,
        //func3_AO_1_out_channel,
        func3_AO_1_increase_close,
        func3_AO_1_pv_upper_range_value,
        func3_AO_1_pv_lower_range_value,
        func3_AO_1_pv_unit,
        func3_AO_1_pv_decimal_point,
        func3_AO_1_out_upper_range_value,
        func3_AO_1_out_lower_range_value,
        func3_AO_1_out_unit,
        func3_AO_1_out_decimal_point,
        func3_AO_1_fsafe_type,
        func3_AO_1_fsafe_time,
        func3_AO_1_fsafe_value,
        func3_AO_1_batch_id,
        func3_AO_1_batch_unit,
        func3_AO_1_batch_operation,
        func3_AO_1_batch_phase,

        /* FUNCTION BLOCK 6: DI 1    */
        func4_DI_1_st_rev,
        //func4_DI_1_channel,
        func4_DI_1_invert,
        func4_DI_1_batch_id,
        func4_DI_1_batch_unit,
        func4_DI_1_batch_operation,
        func4_DI_1_batch_phase,
        func4_DI_1_fsafe_type,
        func4_DI_1_fsafe_value,

        /* FUNCTION BLOCK 7: DI 2    */
        func4_DI_2_st_rev,
        //func4_DI_2_channel,
        func4_DI_2_invert,
        func4_DI_2_batch_id,
        func4_DI_2_batch_unit,
        func4_DI_2_batch_operation,
        func4_DI_2_batch_phase,
        func4_DI_2_fsafe_type,
        func4_DI_2_fsafe_value,

        /* FUNCTION BLOCK 8: DO 1    */
        func5_DO_1_st_rev,
        //func5_DO_1_out_channel,
        func5_DO_1_invert,
        func5_DO_1_batch_id,
        func5_DO_1_batch_unit,
        func5_DO_1_batch_operation,
        func5_DO_1_batch_phase,
        func5_DO_1_fsafe_type,
        func5_DO_1_fsafe_time,
        func5_DO_1_fsafe_value,

        /* FUNCTION BLOCK 9: DO 2    */
        func5_DO_2_st_rev,
        //func5_DO_2_out_channel,
        func5_DO_2_invert,
        func5_DO_2_batch_id,
        func5_DO_2_batch_unit,
        func5_DO_2_batch_operation,
        func5_DO_2_batch_phase,
        func5_DO_2_fsafe_type,
        func5_DO_2_fsafe_time,
        func5_DO_2_fsafe_value,

        /* ANALOG INPUT FUNCTION BLOCK CHANNEL    */
        func1_AI_1_channel,
        func1_AI_2_channel,
        func1_AI_3_channel,
        func1_AI_4_channel,

        trans1_transmitter_pn,
        trans1_transmitter_sn,
        trans1_mainboard_fw,
        trans1_mainboard_hw,
        trans1_ffboard_fw,
        trans1_ffboard_hw,
        //trans1_protocol_version,        

        /* load_to_PC   Modbus Address : 500    */
        trans1_auto_recognize,
        trans1_sensor_type,
        //trans1_sensor_channel,
        trans1_primary_value_aver,
        trans1_secondary_value_aver,
        trans1_third_value_aver,
        trans1_fourth_value_aver,
        trans1_alarm_flags,

        /* load_to_PC   Modbus Address : 1000    */
        trans1_temp_sensor_type,
        trans1_temp_fixed_value_degc,
        trans1_temp_cal_fixed_value,
        trans1_raw_temp_unit,

	    /* load_to_PC   Modbus Address : 1100    */
	    trans1_cal_flags,
	    trans1_cal_drift,

        /* load_to_PC   Modbus Address : 1200    */
        trans1_ph_buffer_mode,
        trans1_ph_slope_display,
        trans1_ph_offset_display,

        trans1_ph_stc_ref_mode,
        trans1_ph_stc_ref_temp,
        trans1_ph_stc_ref_value,
        trans1_ph_ip,

        trans1_ph_salinity,
        trans1_ph_hco3,
        trans1_ph_totpres_unit,
        trans1_ph_totpres,

        /* load_to_PC   Modbus Address : 1300    */
        trans1_o2_cal_pre_unit,
        trans1_o2_cal_pre_value,
        trans1_o2_pro_pre_select,
        trans1_o2_pro_pre_mode,
        trans1_o2_pro_pre_unit,
        trans1_o2_pro_pre_value,
        trans1_ain_4ma_pre,
        trans1_ain_4ma_pre_unit,
        trans1_ain_20ma_pre,
        trans1_ain_20ma_pre_unit,
        trans1_o2_sailinity,
        trans1_o2_meas_humidity,
        //trans1_cal_meas_humidity,
        trans1_o2_meas_polar,
        trans1_o2_cal_polar,

        trans1_led_mode,
        trans1_led_toff,
        trans1_sample_rate,
        trans1_proccal_mode,

        /* load_to_PC   Modbus Address : 1400    */
        trans1_pv_com_mode,
        trans1_sv_com_mode,
        trans1_tv_com_mode,
        trans1_qv_com_mode,
        trans1_pv_linear_val,
        trans1_sv_linear_val,
        trans1_tv_linear_val,
        trans1_qv_linear_val,
        trans1_cal_com_mode,
        trans1_cal_linear_val,

        /* load_to_PC   Modbus Address : 1500    */
        trans1_co2_solub_mode,
        trans1_co2_soulb_value,
        trans1_co2_temp_factor,

        /* load_to_PC   Modbus Address : 2250    */
        IF(SENSOR_O3 && SENSOR_CONNECTED)
        {
            trans1_san_max_cycles,
            trans1_conc_max,
            trans1_conc_min,
            trans1_cycle_time,
        }

        /* load_to_PC   Modbus Address : 2000    */
        IF(SENSOR_DIGITAL_CONNECT_ONLY)
        {
            trans1_sensor_name,
            trans1_sensor_pn,
            trans1_sensor_sn,
            trans1_sensor_fw,
            trans1_sensor_hw,
            trans1_functions_enable_flag,
        }
        /* load_to_PC   Modbus Address : 2200    */
    	IF(SENSOR_CHANNEL_DIGITAL)
    	{
            trans1_cip_temperature,
            trans1_cip_limit,
            trans1_sip_temperature,
            trans1_sip_limit,
            trans1_autoclave_limit,
            trans1_max_ttm_in_days,
            trans1_max_act_in_days,
            trans1_ph_stress_adj,
            trans1_reset_cycle_ctr,
            trans1_sensor_status_change,
    	}
        /* load_to_PC   Modbus Address : 1600    */
    	IF(SENSOR_ANALOG_DIGITAL_CONNECTED)
    	{
    	    trans1_last_cal_date,
    	    trans1_enable_flag,
    	    trans1_offset_unit1_code,
    	    trans1_offset_unit2_code,
    	    trans1_slope_unit1_code,
    	    trans1_slope_unit2_code,


    	    trans1_offset_with_unit1,
    	    trans1_offset_with_unit2,
    	    trans1_slope_with_unit1,
    	    trans1_slope_with_unit2,

    	    trans1_mv_offset,
    	    trans1_pt_slope,
    	    trans1_pt_offset,
    	    trans1_ntc22k_offset,
    	}

    	/* load_to_PC   Modbus Address : 1700    */
        IF(SENSOR_DIGITAL_CONNECT_ONLY)
        {
            trans1_history_block_enable,
            trans1_fact_date,
            trans1_fact_o1,
            trans1_fact_o2,
            trans1_fact_s1,
            trans1_fact_s2,

            IF(trans1_history_block_enable & 0x01)
            {
                trans1_1st_date,
                trans1_1st_o1,
                trans1_1st_o2,
                trans1_1st_s1,
                trans1_1st_s2,
            }
            IF(trans1_history_block_enable & 0x02)
            {
                trans1_cal1_date,
                trans1_cal1_o1,
                trans1_cal1_o2,
                trans1_cal1_s1,
                trans1_cal1_s2,
            }
            IF(trans1_history_block_enable & 0x04)
            {
                trans1_cal2_date,
                trans1_cal2_o1,
                trans1_cal2_o2,
                trans1_cal2_s1,
                trans1_cal2_s2,
            }
            IF(trans1_history_block_enable & 0x08)
            {
                trans1_cal3_date,
                trans1_cal3_o1,
                trans1_cal3_o2,
                trans1_cal3_s1,
                trans1_cal3_s2,
            }
        }
    }
	PRE_READ_ACTIONS
	{
		pre_read_download_variables
	}
}

/*---------------------------------------------------------------------*/
/*    Menu: Device                                                     */
/*---------------------------------------------------------------------*/

MENU Menu_S_Device
{
    LABEL        [menu_Device];
    ITEMS
    {
        std_NodeAddress,
        SEPARATOR,
        std_LoadinDevice,
        std_LoadinPC,
        SEPARATOR,
        Menu_online,
        Menu_offline,
        Menu_calibration,
        Menu_ISM,
        Menu_SetDeviceTime,
        SEPARATOR,
        Menu_simulation,
        SEPARATOR,
        OnlineDialog_reset,
        OnlineDialog_write_locking,
        OnlineDialog_ident_number,
        SEPARATOR,
	methodOpenDeviceManual,
	methodOpenparameter,
	methodOpenQuickSetupGuide
    }
}
#if _PDM_ >= 800
MENU device_root_menu
{
    LABEL [device_setup];
    ITEMS
    {        
        std_NodeAddress,
        SEPARATOR,
        std_LoadinDevice,
        std_LoadinPC,
        SEPARATOR,
        Menu_online,
        Menu_offline,
        Menu_calibration,
        Menu_ISM,
        Menu_SetDeviceTime,
        SEPARATOR,
        Menu_simulation,
        SEPARATOR,
        OnlineDialog_reset,
        OnlineDialog_write_locking,
        OnlineDialog_ident_number,
        SEPARATOR,
	methodOpenDeviceManual,
	methodOpenparameter,
	methodOpenQuickSetupGuide                                            
    }
}
#endif


MENU Menu_M_Device
{
    LABEL        [menu_Device];
    ITEMS
    {
        std_NodeAddress,
        SEPARATOR,
        std_LoadinDevice,
        std_LoadinPC,
        SEPARATOR,
        Menu_online,
        Menu_offline,
        SEPARATOR,
	methodOpenDeviceManual,
	methodOpenparameter,
	methodOpenQuickSetupGuide
    }
}

MENU Menu_online
{
    LABEL [MT_Online_Conf];
    ITEMS
    {
        Menu_AI_on,
        Menu_AO_on,
        Menu_DI_on,
        Menu_DO_on
    }
}

MENU Menu_offline
{
    LABEL [MT_Offline_Conf];
    ITEMS
    {
       Menu_AI_off,
       Menu_AO_off,
       Menu_DI_off,
       Menu_DO_off
    }
}

MENU Menu_SetDeviceTime
{
    LABEL [MT_Menu_set_date_time];
    ITEMS
    {
        trans1_device_time
    }   
    PRE_READ_ACTIONS
    {
        method_pre_edit_action_date
    }
}

MENU Menu_ISM
{
    LABEL [MT_Menu_ISM];
    VALIDITY
        IF(SENSOR_CHANNEL_DIGITAL)    {TRUE;}
        ELSE                          {FALSE;}
    ITEMS
    {
        method_ISM_Change,
        method_ResetCIP,
        method_ResetSIP,
        method_ResetTTM,
        method_ResetDLI,
        method_ResetAutoclave,
        method_ResetSAN
    }
}


MENU Menu_calibration
{
    LABEL [MT_Menu_cal];
    ITEMS
    {
        method_Ph_1p,
        method_Ph_2p,
        method_Ph_Process,
        method_CO2_1p,
        method_CO2_2p,
        method_CO2_Process,
        method_Orp_1p,
        method_Orp_process,
        method_O2_Process_Slope,
        method_O2_Process_Offset,
        method_O2_1p_Slope,
        method_O2_1p_Offset,
        method_Cond_1p,
        method_Cond_2p,
        method_Cond_Process,
        method_Resistivity_1p,
        method_Resistivity_2p,
        method_Resistivity_Process,
        method_Optical_DO_1p,
        method_Optical_DO_Pro,
        method_Optical_DO_2p,
        method_O3_1Point,
        method_O3_Process_Slope,
        method_O3_Process_Offset,
        method_CO2_Beverage_1point,
        method_CO2_Beverage_Process
    }
}

MENU Menu_simulation
{
    LABEL        [menu_dialog_simulation];
    ITEMS
    {
        Menu_simulate_AI,
        Menu_simulate_AO,
        Menu_simulate_DI,
        Menu_simulate_DO,
    }
}

MENU OnlineDialog_write_locking
{
    LABEL   [phys_write_locking];
    HELP    [phys_write_locking_help];
    ITEMS
    {
        trans1_soft_lock,
        phys_write_locking,
        phys_local_operation_enable,
        SEPARATOR,
        method_set
    }
}

/*---------------------------------------------------------------------*/
/*    Menu: View                                                       */
/*---------------------------------------------------------------------*/
MENU Menu_S_View
{
    LABEL        [menu_View];
    ITEMS
    {
        OnlineWindow_display,
        OnlineWindow_yt,
        OnlineWindow_fun_display,
        OnlineWindow_ISM_Diagnostic,
        SEPARATOR,
        Menu_S_alarm,
        OnlineWindow_diagnosis,
        SEPARATOR,
        std_Funktionsleiste,
        std_Statuszeile,
        SEPARATOR,
        std_Update
    }
}
#if _PDM_ >= 800
MENU diagnostic_root_menu
{
    LABEL [menu_diagnosis];
#if _PDM_ < 800 
        STYLE WINDOW;
#endif
    ITEMS
    {
        OnlineWindow_diagnosis,
        OnlineWindow_fun_display,
        OnlineWindow_ISM_Diagnostic,
        Menu_S_alarm,
    }
}
#endif

#if _PDM_ >= 800
MENU process_variables_root_menu
{
  LABEL "Measured values|de|Meßwerte";
#if _PDM_ < 800 
    STYLE WINDOW;
#endif
    ITEMS
    {
        Page_display_func1_AI_1,
        Page_display_func1_AI_2,
        Page_display_func1_AI_3,
        Page_display_func1_AI_4,
        Page_display_AO_1,
        Page_display_out_func4_DI_1,
        Page_display_out_func4_DI_2,
        Page_display_measure_func5_DO_1,
        Page_display_measure_func5_DO_2
    }
}
#endif

MENU OnlineWindow_fun_display
{
    LABEL        [MT_Display_trans];
    ITEMS
    {
        Page_display_ph_dynamic,
        Page_display_co2_pharma_dynamic,
        Page_display_o2_dynamic,
        Page_display_COND_dynamic,
        Page_display_co2_beverage_dynamic,
        Page_display_o3_dynamic
    }
}

MENU OnlineWindow_display
{
    LABEL        [MT_Display_MeaVal];
    STYLE PAGE;
    ITEMS
    {
        Page_display_func1_AI_1,
        Page_display_func1_AI_2,
        Page_display_func1_AI_3,
        Page_display_func1_AI_4,
        Page_display_AO_1,
        Page_display_out_func4_DI_1,
        Page_display_out_func4_DI_2,
        Page_display_measure_func5_DO_1,
        Page_display_measure_func5_DO_2
    }
}

MENU Menu_S_alarm
{
    LABEL        [menu_dialog_alarm];
    ITEMS
    {
        OnlineWindow_S_alarm_func1_AI_1,
        OnlineWindow_S_alarm_func1_AI_2,
        OnlineWindow_S_alarm_func1_AI_3,
        OnlineWindow_S_alarm_func1_AI_4
    }
}

MENU OnlineWindow_diagnosis
{
    LABEL        [MT_Diagnosis];
    STYLE PAGE;
    ITEMS
    {
        Page_diagnosis_general,
        Page_diagnosis_extension,
        Page_diagnosis_phys_block,
        Page_diagnosis_trans1_block,
        Page_diagnosis_func1_AI_1,
        Page_diagnosis_func1_AI_2,
        Page_diagnosis_func1_AI_3,
        Page_diagnosis_func1_AI_4,
        Page_diagnosis_func3_AO_1,
        Page_diagnosis_func4_DI_1,
        Page_diagnosis_func4_DI_2,
        Page_diagnosis_func5_DO_1,
        Page_diagnosis_func5_DO_2
    }
}

#if _PDM_ >= 800
MENU offline_root_menu
{
   LABEL "Offline_root_menu";
   ITEMS
   { 
       Tab_s_info,
       Tab_s_trd,
       Tab_s_ai,
       Tab_s_ao,
       Tab_s_di,
       Tab_s_do
   }
}
#endif


/***********************************************************************/
/*****    Table: Specialist    *****************************************/
/***********************************************************************/

MENU Table_Main_Specialist
{
    LABEL    [MT_Table_Main_Specialist];
    ITEMS
    {
        Tab_s_info,
        Tab_s_trd,
        Tab_s_ai,
        Tab_s_ao,
        Tab_s_di,
        Tab_s_do
    }
}

MENU Tab_s_info
{
    LABEL    [MT_Tab_info];
    ITEMS
    {
        Tab_s_manuf_info,
        Tab_s_block_tag,
        Tab_s_get_info,
//        Tab_serial_numbers,
        Tab_device_revisions,
        Tab_s_certificates
    }
}

MENU Tab_s_block_tag
{
    LABEL    [MT_Tab_block_tag];
    ITEMS
    {
        phys_tag_desc,
        func1_AI_1_tag_desc,
        func1_AI_2_tag_desc,
        func1_AI_3_tag_desc,
        func1_AI_4_tag_desc,
        func3_AO_1_tag_desc,
        func4_DI_1_tag_desc,
        func4_DI_2_tag_desc,
        func5_DO_1_tag_desc,
        func5_DO_2_tag_desc
    }
}

//MENU Tab_serial_numbers
//{
//    LABEL   [MT_Tab_serial_numbers];
//    ITEMS
//    {
//        phys_device_ser_num   (READ_ONLY),
//    }
//}

MENU Tab_s_ai
{
    LABEL   [MT_AI_NUM_4];
    ITEMS
    {
        Tab_s_AI_1,
        Tab_s_AI_2,
        Tab_s_AI_3,
        Tab_s_AI_4
    }
}

MENU Tab_s_ao
{
    LABEL   [MT_AO_NUM_1];
    ITEMS
    {
        Tab_s_AO_1
    }
}

MENU Tab_s_di
{
    LABEL   [MT_DI_NUM_2];
    ITEMS
    {
        Tab_s_func4_DI_1,
        Tab_s_func4_DI_2
    }
}

MENU Tab_s_do
{
    LABEL   [MT_DO_NUM_2];
    ITEMS
    {
        Tab_s_func5_DO_1,
        Tab_s_func5_DO_2
    }
}

/******************************************************************************/
/*****    Table: Maintenance    ***********************************************/
/******************************************************************************/
MENU Table_Main_Maintenance
{
    LABEL    [MT_Table_Main_Maintenance];
    ITEMS
    {
        Tab_m_info,
        Tab_m_trd,
        Tab_m_ai,
        Tab_s_ao,
        Tab_s_di,
        Tab_s_do
    }
}

MENU Tab_m_info
{
    LABEL    [MT_Tab_info];
    ITEMS
    {
        Tab_m_manuf_info,       /* file Phys_Blk.inc */
        Tab_m_block_tag,
        Tab_m_get_info,         /* file Phys_Blk.inc */
//        Tab_serial_numbers,     /* file Phys_Blk.inc */
        Tab_device_revisions,   /* file Phys_Blk.inc */
        Tab_m_certificates      /* file Phys_Blk.inc */
    }
}

MENU Tab_m_block_tag
{
    LABEL    [MT_Tab_block_tag];
    ITEMS
    {
        phys_tag_desc  (READ_ONLY),
        func1_AI_1_tag_desc  (READ_ONLY),
        func1_AI_2_tag_desc  (READ_ONLY),
        func1_AI_3_tag_desc  (READ_ONLY),
        func1_AI_4_tag_desc  (READ_ONLY)
    }
}

MENU Tab_m_ai
{
    LABEL   [MT_AI_NUM_4];
    ITEMS
    {
        Tab_m_AI_1,
        Tab_m_AI_2,
        Tab_m_AI_3,
        Tab_m_AI_4
    }
}

MENU Tab_m_ao
{
    LABEL   [MT_AO_NUM_1];
    ITEMS
    {
        Tab_m_AO_1
    }
}

MENU Tab_m_di
{
    LABEL   [MT_DI_NUM_2];
    ITEMS
    {
        Tab_m_func4_DI_1,
        Tab_m_func4_DI_2
    }
}

MENU Tab_m_do
{
    LABEL   [MT_DO_NUM_2];
    ITEMS
    {
        Tab_m_func5_DO_1,
        Tab_m_func5_DO_2
    }
}

METHOD std_NodeAddress
{
    LABEL        [menu_Device_NodeAddress];
    DEFINITION
    {
    }
}

METHOD std_LoadinDevice
{
    LABEL        [menu_Device_LoadinDevice];
    DEFINITION
    {
    }
}

METHOD std_LoadinPC
{
    LABEL        [menu_Device_LoadinPC];
    DEFINITION
    {
    }
}

METHOD std_Funktionsleiste
{
    LABEL        [menu_View_Toolbar];
    DEFINITION
    {
    }
}

METHOD std_Statuszeile
{
    LABEL        [menu_View_Statusbar];
    DEFINITION
    {
    }
}

METHOD std_Update
{
    LABEL        [menu_View_Update];
    DEFINITION
    {
    }
}

METHOD method_set
{
    LABEL        [MT_Write];
    HELP         [transfer_help];
    DEFINITION
    {
    }
}

METHOD  method_pre_write_phys_write_locking
{
    LABEL   [method_pre_write_phys_write_locking];
    DEFINITION
    {
        int ret;
        ReadCommand (read_phys_write_locking);
        if ( phys_write_locking == 0 )
        {
            ret = ACKNOWLEDGE([label_DeviceIsWriteProtected]);
            if (ret) process_abort();
        }
    }
}

METHOD  pre_read_download_variables
{
	CLASS		INPUT;
	LABEL       "Pre read download variables";
	DEFINITION
	{
		int ret;

		ret = ReadCommand (read_trans1_sensor_type);
		if (ret >= ID_FC_ERROR)	process_abort();

		ret = ReadCommand (read_trans1_cal_flags);
		if (ret >= ID_FC_ERROR)	process_abort();

		ret = ReadCommand (read_trans1_functions_enable_flag);
		if (ret >= ID_FC_ERROR)	process_abort();

		ret = ReadCommand (read_trans1_history_block_enable);
		if (ret >= ID_FC_ERROR)	process_abort();
	}
}
