/************************************************************************
* Endress + Hauser Wetzer GmbH + Co KG                                  
*                                                                       
* Project-Name:    G3PA - TMT84 Profibus-PA Temperature Head Transmitter
*                  Enum entrys      
*                                                                       
* File-Name:       PBPA_EH_1551_0101_methods.inc
*                                                                       
* Revision:        1.00.02                                                  
*                  Compatible to Firmware 01.00.xx
* Date::           feb. 2009                                             
*                                                                       
* Original Author: Christian Schneid                                    
*                                                                       
* ----------------------------------------------------------------------
* Description:   Device Description for TMT84.                          
* ----------------------------------------------------------------------
*                                                                       
*/

#define PDM
//#define DTM

// Abfrage Makro für Ohm Sensortypen (für method_set_trans1_input_range und trans1_input_range)
#define DEF_LIN_TYPE_RTD_1      ((ivar_value(trans1_lin_type) >= 102) && (ivar_value(trans1_lin_type) <= 126)) || ((ivar_value(trans1_lin_type) >= 240) && (ivar_value(trans1_lin_type) <= 246))
#define DEF_LIN_TYPE_OHM_1      ((ivar_value(trans1_lin_type) == 0) && ((ivar_value(trans1_input_range) == 128) || (ivar_value(trans1_input_range) == 129)))
#define DEF_LIN_TYPE_TC_1       ((ivar_value(trans1_lin_type) >= 128) && (ivar_value(trans1_lin_type) <= 140))
#define DEF_LIN_TYPE_MV_1       ((ivar_value(trans1_lin_type) == 0) && ((ivar_value(trans1_input_range) == 0) || (ivar_value(trans1_input_range) == 1)))
#define DEF_LIN_TYPE_NO_SENSOR_1 (ivar_value(trans1_lin_type) == 251)

#define DEF_LIN_TYPE_RTD_2      ((ivar_value(trans2_lin_type) >= 102) && (ivar_value(trans2_lin_type) <= 126)) || ((ivar_value(trans2_lin_type) >= 240) && (ivar_value(trans2_lin_type) <= 246))
#define DEF_LIN_TYPE_OHM_2      ((ivar_value(trans2_lin_type) == 0) && ((ivar_value(trans2_input_range) == 128) || (ivar_value(trans2_input_range) == 129)))
#define DEF_LIN_TYPE_TC_2       ((ivar_value(trans2_lin_type) >= 128) && (ivar_value(trans2_lin_type) <= 140))
#define DEF_LIN_TYPE_MV_2       ((ivar_value(trans2_lin_type) == 0) && ((ivar_value(trans2_input_range) == 0) || (ivar_value(trans2_input_range) == 1)))
#define DEF_LIN_TYPE_NO_SENSOR_2 (ivar_value(trans2_lin_type) == 251)

#define BLOCK_MODE_MAN 0x10

#define ROUND_TO_3_DECIMALS_PDM                                    \
if ( f_tmp >= 0 ) { f_tmp = floor( (f_tmp*1000.0)+0.5) / 1000.0; } \
else { f_tmp = ceil( (f_tmp*1000.0)-0.5) / 1000.0; }

#define ROUND_TO_2_DECIMALS_PDM                                  \
if ( f_tmp >= 0 ) { f_tmp = floor( (f_tmp*100.0)+0.5) / 100.0; } \
else { f_tmp = ceil( (f_tmp*100.0)-0.5) / 100.0; }

#define ROUND_TO_3_DECIMALS_DTM                                                           \
if ( f_tmp >= 0 ) { f_tmp = f_tmp * 1000.0;  i_tmp = f_tmp + 0.5; f_tmp = i_tmp/1000.0; } \
else { f_tmp = f_tmp * 1000.0;  i_tmp = f_tmp - 0.5; f_tmp = i_tmp/1000.0; }              

#define ROUND_TO_2_DECIMALS_DTM                                                           \
if ( f_tmp >= 0 ) { f_tmp = f_tmp * 100.0;  i_tmp = f_tmp + 0.5; f_tmp = i_tmp/100.0; }   \
else { f_tmp = f_tmp * 100.0;  i_tmp = f_tmp - 0.5; f_tmp = i_tmp/100.0; }              

#ifdef _V600_
// Flag for Online/Offline Handling in Methods
VARIABLE isOnline
{
    LABEL "is Online";    
#ifdef DTM
    CLASS LOCAL & CW_UNSYNCRONIZED_STORAGES;
#endif        
#ifdef PDM
    ACCESS ONLINE;
    CLASS LOCAL;
#endif        
    TYPE UNSIGNED_INTEGER(1)
    {
        DEFAULT_VALUE 0;
    }
}

METHOD method_read_and_check_hw_write_protection
{
    LABEL "";
    CLASS INPUT;
    ACCESS ONLINE;    
    DEFINITION
    {
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 1 )
        {
            ReadCommand(read_phys_hw_write_protection);
            save_values();
            if ( ivar_value(phys_hw_write_protection) == 1)
            {
                ACKNOWLEDGE("Writing to device not possible. Hardware write protection is active.");
            }
        }
    }       
}

/* Handling of Display Channels */

METHOD post_write_action_read_back_disp_source_1
{
    ACCESS ONLINE;
    DEFINITION
    {   
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 1 )
        {
            ReadCommand(read_phys_disp_source_1);
            save_values();
        }
    }
}
#endif
METHOD post_edit_disp_source_1
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            if (ivar_value(disp_source_1) == 0)
            {
                if ( (ivar_value(disp_source_2) == 0) && (ivar_value(disp_source_3) == 0) )
                {
                    iassign(disp_source_1,1);
                    save_values();
                }
            }       
	#ifdef _V600_
        }
	#endif
    }
}
#ifdef _V600_
METHOD post_write_action_read_back_disp_source_2
{
    ACCESS ONLINE;
    DEFINITION
    {   
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 1 )
        {
            ReadCommand(read_phys_disp_source_2);
            save_values();
        }
    }
}
#endif
METHOD post_edit_disp_source_2
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            if (ivar_value(disp_source_2) == 0)
            {
                if ( (ivar_value(disp_source_1) == 0) && (ivar_value(disp_source_3) == 0) )
                {
                    iassign(disp_source_2,1);
                    save_values();
                }
            }       
	#ifdef _V600_
        }
	#endif
    }
}
#ifdef _V600_
METHOD post_write_action_read_back_disp_source_3
{
    ACCESS ONLINE;
    DEFINITION
    {   
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 1 )
        {
            ReadCommand(read_phys_disp_source_3);
            save_values();
        }
    }
}
#endif
METHOD post_edit_disp_source_3
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            if (ivar_value(disp_source_3) == 0)
            {
                if ( (ivar_value(disp_source_1) == 0) && (ivar_value(disp_source_2) == 0) )
                {
                    iassign(disp_source_3,1);
                    save_values();
                }
            }       
	#ifdef _V600_
        }
	#endif
    }
}

METHOD post_read_status_signal
{
	ACCESS ONLINE;
	DEFINITION
	{
		ReadCommand(read_phys_diagnostic_code_integer);
		if(phys_diagnostic_code_integer == 1194340400)
		{
			iassign(status_signal, STATUS_SIGNAL_OK);
		}
		else
		{
			if(phys_diagnostic_code_integer >1174405120 && phys_diagnostic_code_integer < 1191182336)
			{
				iassign(status_signal, STATUS_SIGNAL_FAILURE);
			}
			else
			{
				if(phys_diagnostic_code_integer > 1291845632 && phys_diagnostic_code_integer < 1308622848)
				{
					iassign(status_signal, STATUS_SIGNAL_MAINTENANCE);
				}
				else
				{
					if(phys_diagnostic_code_integer > 1124073472 && phys_diagnostic_code_integer < 1140850688)
					{
						iassign(status_signal, STATUS_SIGNAL_CHECK);
					}
					else
					{
						if(phys_diagnostic_code_integer > 1392508928 && phys_diagnostic_code_integer < 1409286144)
						{
							iassign(status_signal, STATUS_SIGNAL_SPECIFICATION);
						}
					}
				}
			}
		}
		save_values();
	}
}

/* Local Variables */
VARIABLE status_signal
{
	LABEL "Status signal|de|Statussignal";
	CLASS LOCAL;
	HANDLING READ;
	TYPE ENUMERATED
	{
		ENUM_STATUS_SIGNAL
	}
	DEFAULT_VALUE STATUS_SIGNAL_OK;
}

VARIABLE loc_bias_1
{
    CLASS LOCAL;
    LABEL " ";
    TYPE FLOAT
    {
        DEFAULT_VALUE 0.0;
    }
}

VARIABLE loc_trans1_external_reference_junction_value
{
    CLASS LOCAL;
    LABEL " ";
    TYPE FLOAT
    {
        DEFAULT_VALUE 0.0;
    }   
}

VARIABLE loc_cvd_max_1
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT
    {
        DEFAULT_VALUE 100.0;
    }
}

VARIABLE loc_cvd_min_1
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT
    {
        DEFAULT_VALUE 0.0;
    }
}


VARIABLE loc_poly_coeff_max_1
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT
    {
        DEFAULT_VALUE 100.0;
    }
}

VARIABLE loc_poly_coeff_min_1
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT
    {
        DEFAULT_VALUE 0.0;
    }
}

VARIABLE loc_upper_sensor_limit_1
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT;
}


VARIABLE loc_lower_sensor_limit_1
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT;
}

VARIABLE loc_sens_drift_limit_1
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT
    {
        DEFAULT_VALUE 0.1;
    }
}

VARIABLE loc_threshold_value_1
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT
    {
        DEFAULT_VALUE 999.9;
    }
}


VARIABLE loc_old_unit_1
{
    CLASS LOCAL;
    LABEL " ";
    TYPE UNSIGNED_INTEGER(2)
    {
        DEFAULT_VALUE 1001;
    }
}

METHOD method_post_read_save_loc_old_unit_1
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
			iassign(loc_old_unit_1,ivar_value(trans1_primary_value_unit));
			save_values();
	#ifdef _V600_
		}
	#endif
	}
}

VARIABLE loc_bias_2
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT
    {
        DEFAULT_VALUE 0.0;
    }
}

VARIABLE loc_trans2_external_reference_junction_value
{
    CLASS LOCAL;
    LABEL " ";
    TYPE FLOAT
    {
        DEFAULT_VALUE 0.0;
    }   
}

VARIABLE loc_cvd_max_2
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT
    {
        DEFAULT_VALUE 100.0;
    }
}

VARIABLE loc_cvd_min_2
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT
    {
        DEFAULT_VALUE 0.0;
    }
}

VARIABLE loc_poly_coeff_max_2
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT
    {
        DEFAULT_VALUE 0.0;
    }
}

VARIABLE loc_poly_coeff_min_2
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT
    {
        DEFAULT_VALUE 100.0;
    }
}

VARIABLE loc_upper_sensor_limit_2
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT;
}


VARIABLE loc_lower_sensor_limit_2
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT;
}


VARIABLE loc_sens_drift_limit_2
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT
    {
        DEFAULT_VALUE 0.1;
    }
}

VARIABLE loc_threshold_value_2
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    FLOAT
    {
        DEFAULT_VALUE 999.9;
    }
}


VARIABLE loc_old_unit_2
{
    CLASS       LOCAL;
    LABEL   " ";
    TYPE    UNSIGNED_INTEGER(2)
    {
        DEFAULT_VALUE 1001; 
    }   
}

METHOD method_post_read_save_loc_old_unit_2
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
			iassign(loc_old_unit_2,ivar_value(trans2_primary_value_unit));
			save_values();
	#ifdef _V600_
		}
	#endif
	}
}

#ifdef _V600_
METHOD method_post_edit_read_device_values_1_online
{
    CLASS INPUT;
    ACCESS ONLINE;
    DEFINITION
    {
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 1 )
        {
            ReadCommand(read_trans1_bias_1);        
            ReadCommand(read_trans1_upper_sensor_limit);        
            ReadCommand(read_trans1_lower_sensor_limit);        
            ReadCommand(read_trans1_threshold_value);        
            ReadCommand(read_trans1_sens_drift_limit);                                                    
        }
    }
}

METHOD method_post_edit_read_device_values_2_online
{
    CLASS INPUT;
    ACCESS ONLINE;
    DEFINITION
    {
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 1 )
        {
            ReadCommand(read_trans2_bias_1);        
            ReadCommand(read_trans2_upper_sensor_limit);        
            ReadCommand(read_trans2_lower_sensor_limit);        
            ReadCommand(read_trans2_threshold_value);        
            ReadCommand(read_trans2_sens_drift_limit);                                                    
        }
    }
}
#endif
// OFFLINE - This method diables display channels if the correlation lin_type is set to "No Sensor"
METHOD method_post_edit_set_display_channels_offline
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        int i_tmp;
        float f_tmp;

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            if (ivar_value(trans1_lin_type) == 251)
            {
                if (ivar_value(disp_source_1) == 1 || ivar_value(disp_source_1) == 2)
                {
                    iassign(disp_source_1,0);
                }
                if (ivar_value(disp_source_2) == 1 || ivar_value(disp_source_2) == 2)
                {
                    iassign(disp_source_2,0);
                }
                if (ivar_value(disp_source_3) == 1 || ivar_value(disp_source_3) == 2)
                {
                    iassign(disp_source_3,0);
                }
            }
            if (ivar_value(trans2_lin_type) == 251)
            {
                if (ivar_value(disp_source_1) == 4 || ivar_value(disp_source_1) == 8)
                {
                    iassign(disp_source_1,0);
                }
                if (ivar_value(disp_source_2) == 4 || ivar_value(disp_source_2) == 8)
                {
                    iassign(disp_source_2,0);
                }
                if (ivar_value(disp_source_3) == 4 || ivar_value(disp_source_3) == 8)
                {
                    iassign(disp_source_3,0);
                }
            }
            save_values();
	#ifdef _V600_
        }
	#endif
    }        
}

// ONLINE - This method diables display channels if the correlation lin_type is set to "No Sensor"
#ifdef _V600_
METHOD method_post_edit_set_display_channels_online
{
    CLASS INPUT;
    ACCESS ONLINE;
    DEFINITION
    {
        int i_tmp;
        float f_tmp;
        int configChanged;
        int is_Online;

        configChanged = 0;

        is_Online = ivar_value(isOnline);
        if (is_Online == 1 )
        {
            if (ivar_value(trans1_lin_type) == 251)
            {
                if (ivar_value(disp_source_1) == 1 || ivar_value(disp_source_1) == 2)
                {
                    iassign(disp_source_1,0);
                    configChanged = 1;
                }
                if (ivar_value(disp_source_2) == 1 || ivar_value(disp_source_2) == 2)
                {
                    iassign(disp_source_2,0);
                    configChanged = 1;                    
                }
                if (ivar_value(disp_source_3) == 1 || ivar_value(disp_source_3) == 2)
                {
                    iassign(disp_source_3,0);
                    configChanged = 1;                    
                }
            }
            if (ivar_value(trans2_lin_type) == 251)
            {
                if (ivar_value(disp_source_1) == 4 || ivar_value(disp_source_1) == 8)
                {
                    iassign(disp_source_1,0);
                    configChanged = 1;                    
                }
                if (ivar_value(disp_source_2) == 4 || ivar_value(disp_source_2) == 8)
                {
                    iassign(disp_source_2,0);
                    configChanged = 1;                    
                }
                if (ivar_value(disp_source_3) == 4 || ivar_value(disp_source_3) == 8)
                {
                    iassign(disp_source_3,0);
                    configChanged = 1;                    
                }
            }
            if (configChanged == 1)
            {
                save_values();
                WriteCommand(write_phys_disp_source_1);        
                WriteCommand(write_phys_disp_source_2);        
                WriteCommand(write_phys_disp_source_3);                
            }
        }
    }        
}
#endif
// This Method sets the PV-Mode to "PV=SV1" if Trans 1 or Trans 2 ist set to "No Sensor"
METHOD method_post_edit_sensor_measure_type_offline
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        int input_range;
        int temperature_unit;

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            //ACKNOWLEDGE("method_post_edit_sensor_measure_type_offline");

            if ( // trans1==mV or Ohm ; trans2== mV or Ohm
                 ( (ivar_value(trans1_lin_type) == 0 && ivar_value(trans2_lin_type) == 0) ) 
               )
            {
                if ( (ivar_value(trans1_input_range) == 0 || ivar_value(trans1_input_range) == 1  ) && // trans1==mV
                     (ivar_value(trans2_input_range) == 128 || ivar_value(trans2_input_range) == 129) ) // trans2==Ohm
                {
                    if(ivar_value(trans1_sensor_measure_type) != 0)
                    {
                        iassign(trans1_sensor_measure_type,0);     
                    }
                    if(ivar_value(trans2_sensor_measure_type) != 0)
                    {
                        iassign(trans2_sensor_measure_type,0);     
                    }
                }
                else if ( (ivar_value(trans1_input_range) == 128 || ivar_value(trans1_input_range) == 129) && // trans1==Ohm
                          (ivar_value(trans2_input_range) ==   0 || ivar_value(trans2_input_range) ==   1) )   // trans2==mV
                {
                    if(ivar_value(trans1_sensor_measure_type) != 0)
                    {
                        iassign(trans1_sensor_measure_type,0);     
                    }
                    if(ivar_value(trans2_sensor_measure_type) != 0)
                    {
                        iassign(trans2_sensor_measure_type,0);     
                    }
                }
            }
            else if ( ivar_value(trans1_lin_type) == 251 || // No Sensor
                      ivar_value(trans2_lin_type) == 251 || // No Sensor
                      (ivar_value(trans1_lin_type) == 0 && ivar_value(trans2_lin_type)  > 0) || // trans1==Ohm or mV ; trans2==temperatur
                      (ivar_value(trans1_lin_type)  > 0 && ivar_value(trans2_lin_type) == 0)    // trans1==temperatur ; trans2==Ohm or mV
                    )
            {
                    if(ivar_value(trans1_sensor_measure_type) != 0)
                    {
                        iassign(trans1_sensor_measure_type,0);     
                    }
                    if(ivar_value(trans2_sensor_measure_type) != 0)
                    {
                        iassign(trans2_sensor_measure_type,0);     
                    }
            }
            save_values();
	#ifdef _V600_
        }
	#endif
    }
}

// OFFLINE
// This Method sets the PV-Mode to "PV=SV1" if Trans 1 and Trans 2 have incompatible 
// measurements eg. mV and Ohm
#ifdef _V600_
METHOD method_post_edit_sensor_measure_type_online
{
    CLASS INPUT;
    ACCESS ONLINE;
    DEFINITION
    {
        int input_range;
        int temperature_unit;
        int configChangedFlag;
        int is_Online;

        configChangedFlag = 0;

        is_Online = ivar_value(isOnline);
        if (is_Online == 1 )  // to avoid blue stars online
        {
            //ACKNOWLEDGE("method_post_edit_sensor_measure_type_online");

            if ( // trans1==mV or Ohm ; trans2== mV or Ohm
                 ( (ivar_value(trans1_lin_type) == 0 && ivar_value(trans2_lin_type) == 0) ) 
               )
            {
                if ( (ivar_value(trans1_input_range) == 0 || ivar_value(trans1_input_range) == 1  ) && // trans1==mV
                     (ivar_value(trans2_input_range) == 128 || ivar_value(trans2_input_range) == 129) ) // trans2==Ohm
                {
                    if(ivar_value(trans1_sensor_measure_type) != 0)
                    {
                        iassign(trans1_sensor_measure_type,0);     
                        configChangedFlag = 1;
                    }
                    if(ivar_value(trans2_sensor_measure_type) != 0)
                    {
                        iassign(trans2_sensor_measure_type,0);     
                        configChangedFlag = 1;
                    }
                }
                else if ( (ivar_value(trans1_input_range) == 128 || ivar_value(trans1_input_range) == 129) && // trans1==Ohm
                          (ivar_value(trans2_input_range) ==   0 || ivar_value(trans2_input_range) ==   1) )   // trans2==mV
                {
                    if(ivar_value(trans1_sensor_measure_type) != 0)
                    {
                        iassign(trans1_sensor_measure_type,0);     
                        configChangedFlag = 1;
                    }
                    if(ivar_value(trans2_sensor_measure_type) != 0)
                    {
                        iassign(trans2_sensor_measure_type,0);     
                        configChangedFlag = 1;
                    }
                }
            }
            else if ( ivar_value(trans1_lin_type) == 251 || // No Sensor
                      ivar_value(trans2_lin_type) == 251 || // No Sensor
                      (ivar_value(trans1_lin_type) == 0 && ivar_value(trans2_lin_type)  > 0) || // trans1==Ohm or mV ; trans2==temperatur
                      (ivar_value(trans1_lin_type)  > 0 && ivar_value(trans2_lin_type) == 0)    // trans1==temperatur ; trans2==Ohm or mV
                    )
            {
                    if(ivar_value(trans1_sensor_measure_type) != 0)
                    {
                        iassign(trans1_sensor_measure_type,0);     
                        configChangedFlag = 1;
                    }
                    if(ivar_value(trans2_sensor_measure_type) != 0)
                    {
                        iassign(trans2_sensor_measure_type,0);     
                        configChangedFlag = 1;
                    }
            }
            if (configChangedFlag == 1)
            {
                save_values();
                WriteCommand(write_trans1_sensor_measure_type);
                WriteCommand(write_trans2_sensor_measure_type);
            }
        }
    }
}
#endif

METHOD method_post_edit_set_trans1_primary_value_unit_offline
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        int input_range;
        int temperature_unit;
	
	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            //ACKNOWLEDGE("method_post_edit_set_trans1_primary_value_unit_offline");

            // wenn "keine Linearisierung" ausgewählt
            if (ivar_value(trans1_lin_type) == 0)
            {
                // abfragen des input range 
                input_range = ivar_value(trans1_input_range);

                // setzen der Einheit mV 
                if ((input_range == 0 || input_range == 1)) // mV
                {
                    iassign(trans1_primary_value_unit,1243);        // linear [mV]
                    iassign(trans1_sensor_connection,0);            // reset sensor connection
                }
                // setzen der Einheit Ohm 
                else if ((input_range == 128) || (input_range == 129))
                {
                    iassign(trans1_primary_value_unit,1281);       // linear [Ohm]
                }
            }
            else
            { // temperaturmessung
                temperature_unit = ivar_value(trans1_primary_value_unit);

                // wenn keine Temperatureinheit und kein Prozent eingestellt war, zurück auf Celsius 
                if ((temperature_unit < 1000) || ((temperature_unit > 1003) && (temperature_unit < 1342) ))
                {
                    iassign(trans1_primary_value_unit,1001);            // Temperature [°C]
                }
            }
            save_values();
	#ifdef _V600_
        }
	#endif
    }
}
#ifdef _V600_
METHOD method_post_edit_set_trans1_primary_value_unit_online
{
    CLASS INPUT;
    ACCESS ONLINE;
    DEFINITION
    {
        int input_range;
        int temperature_unit;
        int configChanged;
        int is_Online;

        configChanged = 0;              

        is_Online = ivar_value(isOnline);
        //ACKNOWLEDGE("method_post_edit_set_trans1_primary_value_unit_online");
        if (is_Online == 1 )
        {
            // wenn "keine Linearisierung" ausgewählt
            if (ivar_value(trans1_lin_type) == 0)
            {
                // abfragen des input range 
                input_range = ivar_value(trans1_input_range);

                // setzen der Einheit mV 
                if ((input_range == 0 || input_range == 1)) // mV
                {
                    iassign(trans1_primary_value_unit,1243);        // linear [mV]
                    iassign(trans1_sensor_connection,0);            // reset sensor connection
                }
                // setzen der Einheit Ohm 
                else if ((input_range == 128) || (input_range == 129))
                {
                    iassign(trans1_primary_value_unit,1281);       // linear [Ohm]
                }
                configChanged = 1;
            }
            else // temperature sensor type was selected
            {
                temperature_unit = ivar_value(trans1_primary_value_unit);

                // wenn keine Temperatureinheit oder Prozent eingestellt ist, dann zurück auf Celsius
                if ((temperature_unit == 1243) || (temperature_unit == 1281))
                {
                    iassign(trans1_primary_value_unit,1001);            // set unit [°C]
                    configChanged = 1;
                }
            }
            if (configChanged==1)
            {
                save_values();
                WriteCommand(write_trans1_primary_value_unit);
                WriteCommand(write_trans1_sensor_connection);   
            }
        }
    }
}
#endif

METHOD  method_post_edit_set_trans1_input_range_offline
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        int primary_value_unit; 

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            //ACKNOWLEDGE("method_post_edit_set_trans1_input_range_offline");

            // wenn "keine Linearisierung" ausgewählt
            if (ivar_value(trans1_lin_type) == 0)
            {
                primary_value_unit = ivar_value(trans1_primary_value_unit);
                if (primary_value_unit == 1243)                 // linear [mV]
                {
                    // falls nicht bereits der mV-Bereich ausgewaehlt ist
                    if (ivar_value(trans1_input_range) != 0)
                    {
                        iassign(trans1_input_range,0);
                        iassign(trans1_sensor_connection,0);
                    }
                }
                else if (primary_value_unit == 1281)            // linear [Ohm]
                {
                    // falls nicht bereits ein Ohm-Bereich ausgewaehlt ist
                    if ((ivar_value(trans1_input_range) < 128) || (ivar_value(trans1_input_range) > 129))
                    {
                        iassign(trans1_input_range,128);
                    }
                }
            }
            // RTD's:
            else if (DEF_LIN_TYPE_RTD_1)
            {
                // falls nicht bereits ein Ohm-Bereich ausgewaehlt ist
                if ((ivar_value(trans1_input_range) < 128) || (ivar_value(trans1_input_range) > 129))
                {
                    iassign(trans1_input_range,128);
                }
            }
            // Thermo-Elemente:
            else if (((ivar_value(trans1_lin_type) >= 128)  && (ivar_value(trans1_lin_type) <= 144)) || (ivar_value(trans1_lin_type) <= 241))
            {
                // falls nicht bereits ein mV-Bereich ausgewaehlt ist
                if (ivar_value(trans1_input_range) != 0)
                {
                    iassign(trans1_input_range,0);
                    iassign(trans1_sensor_connection,0);
                }
            }
            // Default
            else
            {
                iassign(trans1_input_range, 128);
            }
            save_values();
	#ifdef _V600_
        }
	#endif
    }
}

METHOD method_post_edit_set_trans1_default_values_offline
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        int primary_value_unit; 

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            primary_value_unit = ivar_value(trans1_primary_value_unit);

            //ACKNOWLEDGE("method_post_edit_set_trans1_default_values");
            /* CalVanDusen */
            if (ivar_value(trans1_lin_type) == 244)
            {
                fassign(trans1_cal_vandusen_A, 0.0039083);
                fassign(trans1_cal_vandusen_B,-0.0000005775);
                fassign(trans1_cal_vandusen_C,0);
                fassign(trans1_cal_vandusen_R0,100.0);
                // check unit and set Callendar Van Dusen default ranges
                if ( ivar_value(trans1_primary_value_unit) == 1000) // Kelvin
                {
                    fassign(trans1_cvd_min, 273.15);        
                    fassign(trans1_cvd_max, 373.15);
                }
                else if ( ivar_value(trans1_primary_value_unit) == 1001) // Celsius
                {
                    fassign(trans1_cvd_min,   0);        
                    fassign(trans1_cvd_max, 100);
                }
                else if ( ivar_value(trans1_primary_value_unit) == 1002) // Fahrenheit
                {
                    fassign(trans1_cvd_min,  32);        
                    fassign(trans1_cvd_max, 212);
                }
                else if ( ivar_value(trans1_primary_value_unit) == 1003) // Rankine
                {
                    fassign(trans1_cvd_min, 491.67);        
                    fassign(trans1_cvd_max, 671.67);
                }
            }
            /* Polynom Nickel */
            else if (ivar_value(trans1_lin_type) == 245)
            {
                fassign(trans1_poly_coeff_A,0.0054963);
                fassign(trans1_poly_coeff_B,0.0000067556);
                fassign(trans1_poly_coeff_C,0);
                fassign(trans1_poly_coeff_R0,100.0);
                // check unit and set Polynom Nickel default ranges
                if ( ivar_value(trans1_primary_value_unit) == 1000) // Kelvin
                {
                    fassign(trans1_poly_coeff_min, 213.15);        
                    fassign(trans1_poly_coeff_max, 373.15);
                }
                else if ( ivar_value(trans1_primary_value_unit) == 1001) // Celsius
                {
                    fassign(trans1_poly_coeff_min, -60);        
                    fassign(trans1_poly_coeff_max, 100);
                }
                else if ( ivar_value(trans1_primary_value_unit) == 1002) // Fahrenheit
                {
                    fassign(trans1_poly_coeff_min, -76);        
                    fassign(trans1_poly_coeff_max, 212);
                }
                else if ( ivar_value(trans1_primary_value_unit) == 1003) // Rankine
                {
                    fassign(trans1_poly_coeff_min, 383.67);        
                    fassign(trans1_poly_coeff_max, 671.67);
                }
            }
            /* Polynom Copper */
            else if (ivar_value(trans1_lin_type) == 246)
            {
                fassign(trans1_poly_coeff_A,0.00428);
                fassign(trans1_poly_coeff_B,-0.00000062032);
                fassign(trans1_poly_coeff_C,0.00000000085154);
                fassign(trans1_poly_coeff_R0,100.0);
                // check unit and set Polynom Copper default ranges
                if ( ivar_value(trans1_primary_value_unit) == 1000) // Kelvin
                {
                    fassign(trans1_poly_coeff_min, 273.15);        
                    fassign(trans1_poly_coeff_max, 473.15);
                }
                else if ( ivar_value(trans1_primary_value_unit) == 1001) // Celsius
                {
                    fassign(trans1_poly_coeff_min,   0);        
                    fassign(trans1_poly_coeff_max, 200);
                }
                else if ( ivar_value(trans1_primary_value_unit) == 1002) // Fahrenheit
                {
                    fassign(trans1_poly_coeff_min,  32);        
                    fassign(trans1_poly_coeff_max, 392);
                }
                else if ( ivar_value(trans1_primary_value_unit) == 1003) // Rankine
                {
                    fassign(trans1_poly_coeff_min, 491.67);        
                    fassign(trans1_poly_coeff_max, 851.67);
                }
            }
            else if ( ivar_value(trans1_lin_type) == 0 )
            {
                //ACKNOWLEDGE("switch (ivar_value(trans1_input_range))");  
                if ( ivar_value(trans1_input_range) == 0)
                {
                    fassign(trans1_lower_sensor_limit,-5.0); 
                    fassign(trans1_upper_sensor_limit,30.0); 
                }
                else if ( ivar_value(trans1_input_range) == 1)
                {
                    fassign(trans1_lower_sensor_limit,-20.0); 
                    fassign(trans1_upper_sensor_limit,100.0); 
                }
                else if ( ivar_value(trans1_input_range) == 128)
                {
                    fassign(trans1_lower_sensor_limit,10.0); 
                    fassign(trans1_upper_sensor_limit,400.0); 
                }
                else if ( ivar_value(trans1_input_range) == 129)
                {
                    fassign(trans1_lower_sensor_limit,10.0); 
                    fassign(trans1_upper_sensor_limit,2000.0); 
                }
            }
            else // RTD or TC
            {
                ////ACKNOWLEDGE("If-Zweig Trans1 Default Values");  

                /* Untere Sensorgrenzen */
                switch (ivar_value(trans1_lin_type))
                {
                // unteren Bereich setzen
                case 131:
                case 134:
                case 135:
                case 138: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_lower_sensor_limit,3.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_lower_sensor_limit,-270.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_lower_sensor_limit, -454.00); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_lower_sensor_limit, 5.67); 
                                break; 
                            }
                        }
                        break;
                    }
                case 120: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_lower_sensor_limit,203.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_lower_sensor_limit,-70.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_lower_sensor_limit,  -94.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_lower_sensor_limit,365.67); 
                                break; 
                            }
                        }
                        break;
                    }                
                case 123: 
                case 125:
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_lower_sensor_limit,213.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_lower_sensor_limit,-60.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_lower_sensor_limit,  -76.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_lower_sensor_limit,383.67); 
                                break;  
                            }
                        }
                        break;
                    }
                case 126:
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_lower_sensor_limit,173.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_lower_sensor_limit,-100.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_lower_sensor_limit,  -148.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_lower_sensor_limit,311.67); 
                                break; 
                            }
                        }
                        break;
                    }                
                case 128: 
                case 129: 
                case 130: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_lower_sensor_limit,273.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_lower_sensor_limit,0.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_lower_sensor_limit,  32.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_lower_sensor_limit,491.67); 
                                break; 
                            }
                        }
                        break;
                    }                    
                case 133:
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_lower_sensor_limit,63.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_lower_sensor_limit,-210.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_lower_sensor_limit,  -346.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_lower_sensor_limit,113.67); 
                                break;  
                            }
                        }
                        break;
                    }                
                case 136:
                case 137:
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_lower_sensor_limit,223.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_lower_sensor_limit,-50.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_lower_sensor_limit,  -58.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_lower_sensor_limit,401.67); 
                                break;    
                            }
                        }
                        break;
                    }   
                case 244:
                    {
                        fassign(trans1_lower_sensor_limit,fvar_value(trans1_cvd_min)); 
                        break;
                    }   
                case 245:
                case 246:
                    {
                        fassign(trans1_lower_sensor_limit,fvar_value(trans1_poly_coeff_min)); 
                        break;
                    }                                           
                default:
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_lower_sensor_limit,73.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_lower_sensor_limit,-200.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_lower_sensor_limit,  -328.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_lower_sensor_limit,131.67); 
                                break;

                            }
                        }
                    }
                    break;
                }


                /* Obere Sensorgrenzen */
                switch (ivar_value(trans1_lin_type))
                {
                case 104:
                case 105:
                case 123:
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,523.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 250.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  482.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,941.67); 
                                break;

                            }
                        }
                        break;
                    }
                case 108: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,922.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 649.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  1200.20); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,1659.87); 
                                break;

                            }
                        }
                        break;
                    }
                case 120: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,543.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 270.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  518.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,977.67); 
                                break;

                            }
                        }
                        break;
                    }   
                case 125: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,423.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 150.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  302.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,761.67); 
                                break;

                            }
                        }
                        break;
                    }    
                case 126: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,533.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 260.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  500.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,959.67); 
                                break;    
                            }
                        }
                        break;
                    } 
                case 128: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,2093.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 1820.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  3308.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,3767.67); 
                                break;    
                            }
                        }
                        break;
                    } 
                case 129: 
                case 130: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,2588.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 2315.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  4199.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,4658.67); 
                                break;    
                            }
                        }
                        break;
                    }   
                case 131: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,1273.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 1000.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  1832.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,2291.67); 
                                break;    
                            }
                        }  
                        break;
                    }
                case 133: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,1473.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 1200.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  2192.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,2651.67); 
                                break;    
                            }
                        }
                        break;
                    } 
                case 134: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,1645.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 1372.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  2501.60); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,2961.27); 
                                break;    
                            }
                        }
                        break;
                    }  
                case 135: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,1573.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 1300.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  2372.00); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,2831.67); 
                                break;    
                            }
                        } 
                        break;
                    } 
                case 136: 
                case 137: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,2041.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 1768.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  3214.40); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,3674.07); 
                                break;    
                            }
                        }
                        break;
                    }   
                case 138: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,673.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 400.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  752.00); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,1211.67); 
                                break;    
                            }
                        }
                        break;
                    } 
                case 139: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,1173.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 900.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  1652.00); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,2111.67); 
                                break;    
                            }
                        }                    
                        break;
                    }  
                case 140: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,873.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 600.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  1112.00); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,1571.67); 
                                break;    
                            }
                        }                    
                        break;
                    }   
                case 240:
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,1373.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 1100.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  2012.00); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,2471.67); 
                                break;    
                            }
                        } 
                        break;
                    }   
                case 242: 
                case 243: 
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,473.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 200.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  392.00); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,851.67); 
                                break;    
                            }
                        } 
                        break;
                    }
                case 244: 
                    {
                        fassign(trans1_upper_sensor_limit,fvar_value(trans1_cvd_max)); 
                        break;
                    }   
                case 245:
                case 246: {
                        fassign(trans1_upper_sensor_limit,fvar_value(trans1_poly_coeff_max)); 
                        break;
                    }                                                                                                                                                                
                default:  
                    {
                        switch (ivar_value(trans1_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans1_upper_sensor_limit,1123.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans1_upper_sensor_limit, 850.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans1_upper_sensor_limit,  1562.00); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans1_upper_sensor_limit,2021.67); 
                                break;    
                            }
                        }                    
                        break;
                    }
                }
            }
            //ACKNOWLEDGE("End Set Trans1 Default Values");  
            save_values();
	#ifdef _V600_
        }
	#endif
    }
}

METHOD method_post_edit_set_trans2_lin_type_offline
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            // je nachdem, welche Sensorconnection Transducer 1 ausgewählt wird, muss Sensortyp 2 gesetzt werden
            if ( (ivar_value(trans1_sensor_connection) == 2) && (ivar_value(trans1_lin_type) != 251) )
            {
                // je nachdem, welche Sensorconnection Transducer 1 ausgewählt ist, muss Sensortyp 2 gesetzt werden
                    if ( ! ((DEF_LIN_TYPE_NO_SENSOR_2) || (DEF_LIN_TYPE_MV_2) || (DEF_LIN_TYPE_TC_2)) )
                    {
                    // setzen auf "No Sensor" und 3-Leiter 
					iassign(trans2_lin_type,251);
                        iassign(trans2_sensor_connection,1);
                save_values();
					}
			}
	#ifdef _V600_
		}
	#endif
	}
}
#ifdef _V600_
METHOD method_post_edit_set_trans2_lin_type_online
{
    CLASS INPUT;
    ACCESS ONLINE;
    DEFINITION
    {
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 1 )
        {
            // je nachdem, welche Sensorconnection Transducer 1 ausgewählt ist, muss Sensortyp 2 gesetzt werden            
                if ( ivar_value(trans1_sensor_connection) == 2) // 4-Leiter
            {
                    if ( ! ((DEF_LIN_TYPE_NO_SENSOR_2) || (DEF_LIN_TYPE_MV_2) || (DEF_LIN_TYPE_TC_2)) )
            {
                    // setzen auf "No Sensor" und 3-Leiter 
					iassign(trans2_lin_type,251);
                        iassign(trans2_sensor_connection,1);
                save_values();
                WriteCommand(write_trans2_lin_type);
                    WriteCommand(write_trans2_sensor_connection);
                    }
            }
        }
    }
}
#endif

/* **************** TRANSDUCER Block Slot 2 ************************/

// ------ fehlende Profil Methoden ---------
METHOD method_post_edit_set_trans2_primary_value_unit_offline
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {   
        int input_range;
        int temperature_unit;

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            //ACKNOWLEDGE("method_post_edit_set_trans2_primary_value_unit_offline");

            if (ivar_value(trans2_lin_type) == 0)
            {
                if (ivar_value(trans1_sensor_connection) == 2)
                {
                    iassign(trans2_input_range,0);
                    iassign(trans2_sensor_connection,0);
                    iassign(trans2_primary_value_unit,1243);
                }

                input_range = ivar_value(trans2_input_range);
                if ((input_range >= 0) && (input_range <= 9))
                {
                    iassign(trans2_primary_value_unit,1243);       // linear [mV]
                    iassign(trans2_sensor_connection,0);
                }
                else
                {
                    if ((input_range >= 128) && (input_range <= 137))
                    {
                        iassign(trans2_primary_value_unit,1281);        // linear [Ohm]
                    }
                }

            }
            else
            {
                temperature_unit = ivar_value(trans2_primary_value_unit);

                // wenn keine Temperatureinheit und kein Prozent eingestellt war, zurück auf Celsius 
                if ((temperature_unit < 1000) || 
                    ((temperature_unit > 1003) && (temperature_unit < 1342))
                   )
                {
                    iassign(trans2_primary_value_unit,1001);            // Temperature [°C]
                }
            }
            save_values();
	#ifdef _V600_
        }
	#endif
    }
}

#ifdef _V600_
METHOD method_post_edit_set_trans2_primary_value_unit_online
{
    CLASS INPUT;
    ACCESS ONLINE;
    DEFINITION
    {
        int input_range;
        int temperature_unit;
        int configChanged;
        int is_Online;

        configChanged = 0;

        is_Online = ivar_value(isOnline);
        if (is_Online == 1 )
        {

            ////ACKNOWLEDGE("method_post_edit_set_trans2_primary_value_unit_online");

            if (ivar_value(trans2_lin_type) == 0)
            {
                if (ivar_value(trans1_sensor_connection) == 2)
                {
                    iassign(trans2_input_range,0);
                    iassign(trans2_sensor_connection,0);
                    iassign(trans2_primary_value_unit,1243);
                    configChanged = 1;
                }

                input_range = ivar_value(trans2_input_range);
                if ((input_range >= 0) && (input_range <= 9))
                {
                    iassign(trans2_primary_value_unit,1243);       // linear [mV]
                    iassign(trans2_sensor_connection,0);
                    configChanged = 1;
                }
                else
                {
                    if ((input_range >= 128) && (input_range <= 137))
                    {
                        iassign(trans2_primary_value_unit,1281);        // linear [Ohm]
                        configChanged = 1;
                    }
                }

            }
            else
            {
                temperature_unit = ivar_value(trans2_primary_value_unit);

                // wenn keine Temperatureinheit und kein Prozent eingestellt war, zurück auf Celsius 
                if ((temperature_unit < 1000) || 
                    ((temperature_unit > 1003) && (temperature_unit < 1342))
                   )
                {
                    iassign(trans2_primary_value_unit,1001);            // Temperature [°C]
                    configChanged = 1;
                }
            }
            if (configChanged == 1)
            {
                save_values();
                WriteCommand(write_trans2_primary_value_unit);
                WriteCommand(write_trans2_sensor_connection);
                WriteCommand(write_trans2_input_range);
                ReadCommand(read_trans2_primary_value_unit);
                ReadCommand(read_trans2_sensor_connection);
                ReadCommand(read_trans2_input_range);
            }
        }
    }
}
#endif



METHOD method_post_edit_set_trans2_input_range_offline
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        int primary_value_unit; 

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            ////ACKNOWLEDGE("method_post_edit_set_trans2_input_range");        

            if (ivar_value(trans2_lin_type) == 0)
            {
                if (ivar_value(trans1_sensor_connection) == 2)
                {
                    iassign(trans2_input_range,0); 
                    iassign(trans2_primary_value_unit,1243); 
                }

                primary_value_unit = ivar_value(trans2_primary_value_unit);
                if (primary_value_unit == 1243)                 // linear [mV]
                {
                    // falls nicht bereits der mV-Bereich ausgewaehlt ist
                    if (ivar_value(trans2_input_range) != 0)
                    {
                        iassign(trans2_input_range,0);
                    }
                }
                else if (primary_value_unit == 1281)        // linear [Ohm]
                {
                    // falls nicht bereits ein Ohm-Bereich ausgewaehlt ist
                    if ((ivar_value(trans2_input_range) < 128) || (ivar_value(trans2_input_range) > 129))
                    {
                        iassign(trans2_input_range,128);
                    }
                }
            }
            // RTD's:
            else if (DEF_LIN_TYPE_RTD_2)
            {
                // falls nicht bereits ein Ohm-Bereich ausgewaehlt ist
                if ((ivar_value(trans2_input_range) < 128) || (ivar_value(trans2_input_range) > 129))
                {
                    iassign(trans2_input_range,128);
                }
            }
            // Thermo-Elemente:
            else if (DEF_LIN_TYPE_TC_2)
            {
                // falls nicht bereits ein mV-Bereich ausgewaehlt ist
                if (ivar_value(trans2_input_range) != 0)
                {
                    iassign(trans2_input_range,0);
                }
            }
            // Default
            else
            {
                iassign(trans2_input_range, 128);
            }
            save_values();
	#ifdef _V600_
        }
	#endif
    }
}

METHOD method_post_edit_set_trans2_default_values_offline
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        int primary_value_unit;

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            primary_value_unit = ivar_value(trans2_primary_value_unit);

            if (ivar_value(trans2_lin_type) == 244)
            {
                fassign(trans2_cal_vandusen_A, 0.0039083);
                fassign(trans2_cal_vandusen_B,-0.0000005775);
                fassign(trans2_cal_vandusen_C,0);
                fassign(trans2_cal_vandusen_R0,100.0);
                // check unit and set Callendar Van Dusen default ranges
                if ( ivar_value(trans2_primary_value_unit) == 1000) // Kelvin
                {
                    fassign(trans2_cvd_min, 273.15);        
                    fassign(trans2_cvd_max, 373.15);
                }
                else if ( ivar_value(trans2_primary_value_unit) == 1001) // Celsius
                {
                    fassign(trans2_cvd_min,   0);        
                    fassign(trans2_cvd_max, 100);
                }
                else if ( ivar_value(trans2_primary_value_unit) == 1002) // Fahrenheit
                {
                    fassign(trans2_cvd_min,  32);        
                    fassign(trans2_cvd_max, 212);
                }
                else if ( ivar_value(trans2_primary_value_unit) == 1003) // Rankine
                {
                    fassign(trans2_cvd_min, 491.67);        
                    fassign(trans2_cvd_max, 671.67);
                }
            }
            /* Polynom Nickel */
            if (ivar_value(trans2_lin_type) == 245)
            {
                fassign(trans2_poly_coeff_A,0.0054963);
                fassign(trans2_poly_coeff_B,0.0000067556);
                fassign(trans2_poly_coeff_C,0);
                fassign(trans2_poly_coeff_R0,100.0);
                // check unit and set Polynom Nickel default ranges
                if ( ivar_value(trans2_primary_value_unit) == 1000) // Kelvin
                {
                    fassign(trans2_poly_coeff_min, 213.15);        
                    fassign(trans2_poly_coeff_max, 373.15);
                }
                else if ( ivar_value(trans2_primary_value_unit) == 1001) // Celsius
                {
                    fassign(trans2_poly_coeff_min, -60);        
                    fassign(trans2_poly_coeff_max, 100);
                }
                else if ( ivar_value(trans2_primary_value_unit) == 1002) // Fahrenheit
                {
                    fassign(trans2_poly_coeff_min, -76);        
                    fassign(trans2_poly_coeff_max, 212);
                }
                else if ( ivar_value(trans2_primary_value_unit) == 1003) // Rankine
                {
                    fassign(trans2_poly_coeff_min, 383.67);        
                    fassign(trans2_poly_coeff_max, 671.67);
                }
            }
            /* Polynom Copper */
            if (ivar_value(trans2_lin_type) == 246)
            {
                fassign(trans2_poly_coeff_A,0.00428);
                fassign(trans2_poly_coeff_B,-0.00000062032);
                fassign(trans2_poly_coeff_C,0.00000000085154);
                fassign(trans2_poly_coeff_R0,100.0);
                // check unit and set Polynom Copper default ranges
                if ( ivar_value(trans2_primary_value_unit) == 1000) // Kelvin
                {
                    fassign(trans2_poly_coeff_min, 273.15);        
                    fassign(trans2_poly_coeff_max, 473.15);
                }
                else if ( ivar_value(trans2_primary_value_unit) == 1001) // Celsius
                {
                    fassign(trans2_poly_coeff_min,   0);        
                    fassign(trans2_poly_coeff_max, 200);
                }
                else if ( ivar_value(trans2_primary_value_unit) == 1002) // Fahrenheit
                {
                    fassign(trans2_poly_coeff_min,  32);        
                    fassign(trans2_poly_coeff_max, 392);
                }
                else if ( ivar_value(trans2_primary_value_unit) == 1003) // Rankine
                {
                    fassign(trans2_poly_coeff_min, 491.67);        
                    fassign(trans2_poly_coeff_max, 851.67);
                }
            }

            if ( (ivar_value(trans2_primary_value_unit) != 1243) && (ivar_value(trans2_primary_value_unit) != 1281) )
            {
                ////ACKNOWLEDGE("If-Zweig Trans1 Default Values");  

                /* zum setzen der Sensorgrenzen auf °C stellen, diese werden dann gesetzt */  
                //iassign(trans2_primary_value_unit,1001);

                /* Untere Sensorgrenzen */
                switch (ivar_value(trans2_lin_type))
                {
                // unteren Bereich setzen
                case 131:
                case 134:
                case 135:
                case 138: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_lower_sensor_limit,3.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_lower_sensor_limit,-270.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_lower_sensor_limit, -454.00); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_lower_sensor_limit, 5.67); 
                                break; 
                            }
                        }
                        break;
                    }
                case 120: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_lower_sensor_limit,203.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_lower_sensor_limit,-70.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_lower_sensor_limit,  -94.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_lower_sensor_limit,365.67); 
                                break; 
                            }
                        }
                        break;
                    }                
                case 123: 
                case 125:
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_lower_sensor_limit,213.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_lower_sensor_limit,-60.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_lower_sensor_limit,  -76.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_lower_sensor_limit,383.67); 
                                break;  
                            }
                        }
                        break;
                    }
                case 126:
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_lower_sensor_limit,173.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_lower_sensor_limit,-100.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_lower_sensor_limit,  -148.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_lower_sensor_limit,311.67); 
                                break; 
                            }
                        }
                        break;
                    }                
                case 128: 
                case 129: 
                case 130: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_lower_sensor_limit,273.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_lower_sensor_limit,0.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_lower_sensor_limit,  32.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_lower_sensor_limit,491.67); 
                                break; 
                            }
                        }
                        break;
                    }                    
                case 133:
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_lower_sensor_limit,63.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_lower_sensor_limit,-210.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_lower_sensor_limit,  -346.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_lower_sensor_limit,113.67); 
                                break;  
                            }
                        }
                        break;
                    }                
                case 136:
                case 137:
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_lower_sensor_limit,223.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_lower_sensor_limit,-50.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_lower_sensor_limit,  -58.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_lower_sensor_limit,401.67); 
                                break;    
                            }
                        }
                        break;
                    }   
                case 244:
                    {
                        fassign(trans2_lower_sensor_limit,fvar_value(trans2_cvd_min)); 
                        break;
                    }   
                case 245:
                case 246:
                    {
                        fassign(trans2_lower_sensor_limit,fvar_value(trans2_poly_coeff_min)); 
                        break;
                    }                                           
                default:
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_lower_sensor_limit,73.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_lower_sensor_limit,-200.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_lower_sensor_limit,  -328.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_lower_sensor_limit,131.67); 
                                break;

                            }
                        }
                    }
                    break;
                }


                /* Obere Sensorgrenzen */
                switch (ivar_value(trans2_lin_type))
                {
                case 104:
                case 105:
                case 123:
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,523.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 250.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  482.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,941.67); 
                                break;

                            }
                        }
                        break;
                    }
                case 108: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,922.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 649.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  1200.20); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,1659.87); 
                                break;

                            }
                        }
                        break;
                    }
                case 120: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,543.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 270.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  518.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,977.67); 
                                break;

                            }
                        }
                        break;
                    }   
                case 125: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,423.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 150.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  302.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,761.67); 
                                break;

                            }
                        }
                        break;
                    }    
                case 126: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,533.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 260.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  500.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,959.67); 
                                break;    
                            }
                        }
                        break;
                    } 
                case 128: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,2093.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 1820.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  3308.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,3767.67); 
                                break;    
                            }
                        }
                        break;
                    } 
                case 129: 
                case 130: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,2588.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 2315.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  4199.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,4658.67); 
                                break;    
                            }
                        }
                        break;
                    }   
                case 131: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,1273.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 1000.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  1832.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,2291.67); 
                                break;    
                            }
                        }  
                        break;
                    }
                case 133: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,1473.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 1200.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  2192.0); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,2651.67); 
                                break;    
                            }
                        }
                        break;
                    } 
                case 134: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,1645.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 1372.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  2501.60); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,2961.27); 
                                break;    
                            }
                        }
                        break;
                    }  
                case 135: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,1573.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 1300.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  2372.00); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,2831.67); 
                                break;    
                            }
                        } 
                        break;
                    } 
                case 136: 
                case 137: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,2041.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 1768.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  3214.40); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,3674.07); 
                                break;    
                            }
                        }
                        break;
                    }   
                case 138: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,673.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 400.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  752.00); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,1211.67); 
                                break;    
                            }
                        }
                        break;
                    } 
                case 139: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,1173.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 900.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  1652.00); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,2111.67); 
                                break;    
                            }
                        }                    
                        break;
                    }  
                case 140: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,873.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 600.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  1112.00); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,1571.67); 
                                break;    
                            }
                        }                    
                        break;
                    }   
                case 240:
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,1373.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 1100.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  2012.00); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,2471.67); 
                                break;    
                            }
                        } 
                        break;
                    }   
                case 242: 
                case 243: 
                    {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,473.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 200.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  392.00); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,851.67); 
                                break;    
                            }
                        } 
                        break;
                    }
                case 244: 
                    {
                        fassign(trans2_upper_sensor_limit,fvar_value(trans2_cvd_max)); 
                        break;
                    }   
                case 245:
                case 246: {
                        fassign(trans2_upper_sensor_limit,fvar_value(trans2_poly_coeff_max)); 
                        break;
                    }                                                                                                                                                                
                default:  {
                        switch (ivar_value(trans2_primary_value_unit))
                        {
                        case 1000:
                            {
                                fassign(trans2_upper_sensor_limit,1123.15); 
                                break;
                            }
                        case 1001:
                            {
                                fassign(trans2_upper_sensor_limit, 850.0); 
                                break;
                            }
                        case 1002:
                            {
                                fassign(trans2_upper_sensor_limit,  1562.00); 
                                break;
                            }
                        case 1003:
                            {
                                fassign(trans2_upper_sensor_limit,2021.67); 
                                break;    
                            }
                        }                    
                        break;
                    }
                }

                /* Zurücksetzen auf vorherige Einheit. Werte werden automatisch zurückgerechnet */
                //iassign(trans2_primary_value_unit,primary_value_unit);

            }
            else // lin_type == keine Linearsierung
            {
                ////ACKNOWLEDGE("Else-Zweig Trans1 Default Values");  

                switch (ivar_value(trans2_input_range))
                {
                case 0:   {
                        fassign(trans2_lower_sensor_limit, -5.0); 
                        fassign(trans2_upper_sensor_limit, 30.0); 
                        break;
                    }
                case 1:   {
                        fassign(trans2_lower_sensor_limit, -20.0); 
                        fassign(trans2_upper_sensor_limit, 100.0); 
                        break;
                    }
                case 128: {
                        fassign(trans2_lower_sensor_limit, 10.0); 
                        fassign(trans2_upper_sensor_limit, 400.0); 
                        break;
                    }
                case 129: {
                        fassign(trans2_lower_sensor_limit, 10.0); 
                        fassign(trans2_upper_sensor_limit, 2000.0); 
                        break;
                    }
                }
            } 
            save_values();
	#ifdef _V600_
        }
	#endif
    }
}  

METHOD method_post_edit_func1_set_status_limit
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        int quality;
        int block_mode;

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            ////ACKNOWLEDGE("method_post_edit_func1_set_status_limit");

            quality = ivar_value(func1_AI_simulate_status_quality);
            if ((quality == 0x20) || (quality == 0x30))
                iassign(func1_AI_simulate_status_limit, 0);

            block_mode  = ivar_value(func1_AI_target_mode);
            quality     = ivar_value(func1_AI_out_status_quality);
            if ((block_mode == BLOCK_MODE_MAN) && ((quality == 0x20) || (quality == 0x30)))
            {
                iassign(func1_AI_out_status_limit, 0);
            }
            save_values();
	#ifdef _V600_
        }
	#endif
    }
}

METHOD method_post_edit_check_func1_AI_alarm_hys
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        float   hi_hi_lim, lo_lo_lim, hyst, hyst_new, fDiff ;
        long    var_id[2];

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            ////ACKNOWLEDGE("method_post_edit_check_func1_AI_alarm_hys");

            hi_hi_lim = fvar_value(func1_AI_hi_hi_lim);
            lo_lo_lim = fvar_value(func1_AI_lo_lo_lim);
            fDiff = hi_hi_lim-lo_lo_lim ;
            hyst = fvar_value(func1_AI_alarm_hys);

            if ( fDiff < 0 )
                fDiff = - fDiff ;

            if ((hyst < 0) || (hyst >= fDiff) )
            {
                hyst_new = fDiff * 0.05;
                fassign (func1_AI_alarm_hys, hyst_new);
                var_id[0] = VARID (func1_AI_alarm_hys);
                var_id[1] = VARID (func1_AI_out_unit);
                ////ACKNOWLEDGE ([alert_alarm_hys],var_id);
            }
            save_values();
	#ifdef _V600_
        }
	#endif
    }
}                    



METHOD method_post_edit_func2_set_status_limit
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        int quality;
        int block_mode;

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            ////ACKNOWLEDGE("method_post_edit_func2_set_status_limit");

            quality = ivar_value(func2_AI_simulate_status_quality);
            if ((quality == 0x20) || (quality == 0x30))
                iassign(func2_AI_simulate_status_limit, 0);

            block_mode  = ivar_value(func2_AI_target_mode);
            quality     = ivar_value(func2_AI_out_status_quality);
            if ((block_mode == BLOCK_MODE_MAN) && ((quality == 0x20) || (quality == 0x30)))
                iassign(func2_AI_out_status_limit, 0);
            save_values();
	#ifdef _V600_
        }
	#endif
    }
}

METHOD method_post_edit_check_func2_AI_alarm_hys
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        float   hi_hi_lim, lo_lo_lim, hyst, hyst_new, fDiff ;
        long    var_id[2];

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            ////ACKNOWLEDGE("method_post_edit_check_func2_AI_alarm_hys");

            hi_hi_lim = fvar_value(func2_AI_hi_hi_lim);
            lo_lo_lim = fvar_value(func2_AI_lo_lo_lim);
            fDiff = hi_hi_lim-lo_lo_lim ;
            hyst = fvar_value(func2_AI_alarm_hys);

            if ( fDiff < 0 )
                fDiff = - fDiff ;

            if ((hyst < 0) || (hyst >= fDiff) )
            {
                hyst_new = fDiff * 0.05;
                fassign (func2_AI_alarm_hys, hyst_new);
                var_id[0] = VARID (func2_AI_alarm_hys);
                var_id[1] = VARID (func2_AI_out_unit);
                ////ACKNOWLEDGE ([alert_alarm_hys],var_id);
            }
            save_values();
	#ifdef _V600_
        }
	#endif
    }
}

METHOD method_post_edit_func3_set_status_limit
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        int quality;
        int block_mode;

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            ////ACKNOWLEDGE("method_post_edit_func3_set_status_limit");

            quality = ivar_value(func3_AI_simulate_status_quality);
            if ((quality == 0x20) || (quality == 0x30))
                iassign(func3_AI_simulate_status_limit, 0);

            block_mode  = ivar_value(func3_AI_target_mode);
            quality     = ivar_value(func3_AI_out_status_quality);
            if ((block_mode == BLOCK_MODE_MAN) && ((quality == 0x20) || (quality == 0x30)))
                iassign(func3_AI_out_status_limit, 0);

            save_values();
	#ifdef _V600_
        }
	#endif
    }
}

METHOD method_post_edit_check_func3_AI_alarm_hys
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        float   hi_hi_lim, lo_lo_lim, hyst, hyst_new, fDiff ;
        long    var_id[2];

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            ////ACKNOWLEDGE("method_post_edit_check_func3_AI_alarm_hys");

            hi_hi_lim = fvar_value(func3_AI_hi_hi_lim);
            lo_lo_lim = fvar_value(func3_AI_lo_lo_lim);
            fDiff = hi_hi_lim-lo_lo_lim ;
            hyst = fvar_value(func3_AI_alarm_hys);

            if ( fDiff < 0 )
                fDiff = - fDiff ;

            if ((hyst < 0) || (hyst >= fDiff) )
            {
                hyst_new = fDiff * 0.05;
                fassign (func3_AI_alarm_hys, hyst_new);
                var_id[0] = VARID (func3_AI_alarm_hys);
                var_id[1] = VARID (func3_AI_out_unit);
                ////ACKNOWLEDGE ([alert_alarm_hys],var_id);
            }

            save_values();
	#ifdef _V600_
        }
	#endif
    }
}

METHOD method_post_edit_func4_set_status_limit
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        int quality;
        int block_mode;

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            ////ACKNOWLEDGE("method_post_edit_func4_set_status_limit");

            quality = ivar_value(func4_AI_simulate_status_quality);
            if ((quality == 0x20) || (quality == 0x30))
                iassign(func4_AI_simulate_status_limit, 0);

            block_mode  = ivar_value(func4_AI_target_mode);
            quality     = ivar_value(func4_AI_out_status_quality);
            if ((block_mode == BLOCK_MODE_MAN) && ((quality == 0x20) || (quality == 0x30)))
                iassign(func4_AI_out_status_limit, 0);


            save_values();
	#ifdef _V600_
        }
	#endif
    }
}

METHOD method_post_edit_check_func4_AI_alarm_hys
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        float   hi_hi_lim, lo_lo_lim, hyst, hyst_new, fDiff ;
        long    var_id[2];

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            //ACKNOWLEDGE("method_post_edit_check_func4_AI_alarm_hys");

            hi_hi_lim = fvar_value(func4_AI_hi_hi_lim);
            lo_lo_lim = fvar_value(func4_AI_lo_lo_lim);
            fDiff = hi_hi_lim-lo_lo_lim ;
            hyst = fvar_value(func4_AI_alarm_hys);

            if ( fDiff < 0 )
                fDiff = - fDiff ;

            if ((hyst < 0) || (hyst >= fDiff) )
            {
                hyst_new = fDiff * 0.05;
                fassign (func4_AI_alarm_hys, hyst_new);
                var_id[0] = VARID (func4_AI_alarm_hys);
                var_id[1] = VARID (func4_AI_out_unit);
                ////ACKNOWLEDGE ([alert_alarm_hys],var_id);
            }

            save_values();
	#ifdef _V600_
        }
	#endif
    }
}



/********* UNITCONVERSION **********************/

METHOD method_post_edit_save_values_1_offline
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {

        int i_tmp;
        float f_tmp;

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            //ACKNOWLEDGE("method_post_edit_save_unit_values_1_offline");

            // save old unit value

            // save offset
            f_tmp = fvar_value(trans1_bias_1);
            fassign(loc_bias_1, f_tmp);

            // save ext_rj_value
            f_tmp = fvar_value(trans1_external_reference_junction_value); 
            fassign(loc_trans1_external_reference_junction_value, f_tmp);

            f_tmp = fvar_value(trans1_cvd_max); 
            fassign(loc_cvd_max_1, f_tmp);

            f_tmp = fvar_value(trans1_cvd_min);
            fassign(loc_cvd_min_1, f_tmp);

            f_tmp = fvar_value(trans1_poly_coeff_max); 
            fassign(loc_poly_coeff_max_1, f_tmp);

            f_tmp = fvar_value(trans1_poly_coeff_min); 
            fassign(loc_poly_coeff_min_1, f_tmp);

            f_tmp = fvar_value(trans1_upper_sensor_limit);
            fassign(loc_upper_sensor_limit_1, f_tmp);

            f_tmp = fvar_value(trans1_lower_sensor_limit);
            fassign(loc_lower_sensor_limit_1, f_tmp);

            f_tmp = fvar_value(trans1_sens_drift_limit); 
            fassign(loc_sens_drift_limit_1, f_tmp);

            f_tmp = fvar_value(trans1_threshold_value); 
            fassign(loc_threshold_value_1, f_tmp);

            ////ACKNOWLEDGE("End Save 1 Unit Values");

            save_values();
	#ifdef _V600_
        }
	#endif
    }

}

// this methods sets the entered CVD measurement-ranges to the sensor ranges
METHOD post_edit_set_cvd_range_to_sensor_range_offline
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        float f_tmp;
        int i_tmp;

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            if ( (ivar_value(trans1_lin_type) == 244) )
            {
                f_tmp = fvar_value(trans1_cvd_min);   
                fassign(trans1_lower_sensor_limit, f_tmp);

                f_tmp = fvar_value(trans1_cvd_max);   
                fassign(trans1_upper_sensor_limit, f_tmp);
            }
            if ( (ivar_value(trans2_lin_type) == 244) )
            {
                f_tmp = fvar_value(trans2_cvd_min);   
                fassign(trans2_lower_sensor_limit, f_tmp);

                f_tmp = fvar_value(trans2_cvd_max);   
                fassign(trans2_upper_sensor_limit, f_tmp);         
            }

            save_values();
	#ifdef _V600_
        }
	#endif
    }
}

// this methods sets the entered POLYNOM measurement-ranges to the sensor ranges
METHOD post_edit_set_poly_range_to_sensor_range_offline
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        float f_tmp;
        int i_tmp;
        int ivar_trans1_lin_type;
        int ivar_trans2_lin_type;

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            if ( (ivar_value(trans1_lin_type) == 245) || (ivar_value(trans1_lin_type) == 246) )
            {
                f_tmp = fvar_value(trans1_poly_coeff_min);   
                fassign(trans1_lower_sensor_limit, f_tmp);

                f_tmp = fvar_value(trans1_poly_coeff_max);   
                fassign(trans1_upper_sensor_limit, f_tmp);
            }
            if ( (ivar_value(trans1_lin_type) == 245) || (ivar_value(trans1_lin_type) == 246) )
            {
                f_tmp = fvar_value(trans2_poly_coeff_min);   
                fassign(trans2_lower_sensor_limit, f_tmp);

                f_tmp = fvar_value(trans2_poly_coeff_max);   
                fassign(trans2_upper_sensor_limit, f_tmp);            

                save_values();
            }
	#ifdef _V600_
        }
	#endif
    }
}



METHOD method_post_edit_convert_1_offline
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        int new_unit_1;
        int old_unit_1;
        float f_tmp;
        int i_tmp;

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            if (ivar_value(trans1_lin_type) != 0)
            {
                //ACKNOWLEDGE("method_post_edit_convert_1_offline");

                // make local variables actual 
                // offset
                f_tmp = fvar_value(trans1_bias_1);
                fassign(loc_bias_1, f_tmp);
                // save ext_rj_value
                f_tmp = fvar_value(trans1_external_reference_junction_value); 
                fassign(loc_trans1_external_reference_junction_value, f_tmp);
                // CVD max
                f_tmp = fvar_value(trans1_cvd_max); 
                fassign(loc_cvd_max_1, f_tmp);
                // CVD min
                f_tmp = fvar_value(trans1_cvd_min);
                fassign(loc_cvd_min_1, f_tmp);
                // poly max
                f_tmp = fvar_value(trans1_poly_coeff_max); 
                fassign(loc_poly_coeff_max_1, f_tmp);
                // poly min
                f_tmp = fvar_value(trans1_poly_coeff_min); 
                fassign(loc_poly_coeff_min_1, f_tmp);
                // upper sensor limit
                f_tmp = fvar_value(trans1_upper_sensor_limit);
                fassign(loc_upper_sensor_limit_1, f_tmp);
                // lower sensor limit
                f_tmp = fvar_value(trans1_lower_sensor_limit);
                fassign(loc_lower_sensor_limit_1, f_tmp);
                // sens drift limit
                f_tmp = fvar_value(trans1_sens_drift_limit); 
                fassign(loc_sens_drift_limit_1, f_tmp);
                // threshold value
                f_tmp = fvar_value(trans1_threshold_value); 
                fassign(loc_threshold_value_1, f_tmp);

                // get new unit
                new_unit_1 = ivar_value(trans1_primary_value_unit);
                old_unit_1 = ivar_value(loc_old_unit_1);

                // For DTM. Save unit for next time, because DTM does not call pre-edit
                iassign(loc_old_unit_1, new_unit_1);

                switch (old_unit_1)
                {
                case 1001: // °C 
                case 1342: // %
                    {
                        //ACKNOWLEDGE(" Alte Einheit Celsius erkannt");
                        // both °C or °C to %
                        // from Celsius to Fahrenheit  
                        if (new_unit_1 == 1002)
                        {
                            f_tmp = fvar_value(loc_bias_1);
                            f_tmp = f_tmp * 1.8; 
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans1_external_reference_junction_value);
                            f_tmp = f_tmp * 1.8 + 32; 
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_external_reference_junction_value, f_tmp);

                            f_tmp = fvar_value(loc_cvd_max_1);
                            f_tmp = (f_tmp * 1.8) + 32;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_1);
                            f_tmp = (f_tmp * 1.8) + 32;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            f_tmp = fvar_value(loc_poly_coeff_max_1);
                            f_tmp = (f_tmp * 1.8) + 32;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_1);
                            f_tmp = (f_tmp * 1.8) + 32;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_1);
                            f_tmp = (f_tmp * 1.8) + 32;
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_1);
                            f_tmp = (f_tmp * 1.8) + 32;
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_1);
                            f_tmp = (f_tmp * 1.8);
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_1);
                            f_tmp = (f_tmp * 1.8) + 32;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_threshold_value, f_tmp);

                        }
                        // from Celsius to Kelvin
                        else if (new_unit_1 == 1000)
                        {
                            f_tmp = fvar_value(loc_bias_1);
                            /*offset round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans1_external_reference_junction_value);
                            f_tmp = f_tmp + 273.15 ;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_external_reference_junction_value, f_tmp);                          

                            f_tmp = fvar_value(loc_cvd_max_1);
                            f_tmp = f_tmp + 273.15 ;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_1);
                            f_tmp = f_tmp + 273.15 ;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_1);
                            f_tmp = f_tmp + 273.15 ;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_1);
                            f_tmp = f_tmp + 273.15 ;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_1);
                            /*upper_sensor_limit round result to 2 decimals*/
                            f_tmp = f_tmp + 273.15 ;                   
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_1);
                            f_tmp = f_tmp + 273.15 ;
                            /*lower_sensor_limit round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_1);
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_1);
                            f_tmp = f_tmp + 273.15 ;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_threshold_value, f_tmp);
                        }
                        // from Celsius to Rankine
                        else if (new_unit_1 == 1003)
                        {
                            f_tmp = fvar_value(loc_bias_1);
                            f_tmp = f_tmp * 1.8;
                            /*offset round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_bias_1, f_tmp); 

                            f_tmp = fvar_value(loc_trans1_external_reference_junction_value);
                            f_tmp = (f_tmp + 273.15) * 1.8 ;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_external_reference_junction_value, f_tmp);                       

                            f_tmp = fvar_value(loc_cvd_max_1);
                            f_tmp = ( f_tmp + 273.15 ) * 1.8;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_1);
                            f_tmp = ( f_tmp + 273.15 ) * 1.8;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_1);
                            f_tmp = ( f_tmp + 273.15 ) * 1.8;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_1);
                            f_tmp = ( f_tmp + 273.15 ) * 1.8;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_1);
                            f_tmp = ( f_tmp + 273.15 ) * 1.8;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_1);
                            f_tmp = ( f_tmp + 273.15 ) * 1.8;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_1);
                            f_tmp = f_tmp * 1.8;
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_1);
                            f_tmp = ( f_tmp + 273.15 ) * 1.8;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_threshold_value, f_tmp);
                        }
                        else if ((new_unit_1 == 1001))
                        {
                            f_tmp = 0; //do nothing
                        }
                        else if ((new_unit_1 == 1342))
                        {
                            f_tmp = 0; //do nothing
                        }
                        // in else auf default zurückstellen im fall ohm,mv ? 
                        else
                        {
                            //ACKNOWLEDGE("Set to default values. old unit: °C or %" );
                            fassign(trans1_bias_1,                0.0);
                            fassign(trans1_cvd_max,               100.0);
                            fassign(trans1_cvd_min,               0.0);
                            fassign(trans1_upper_sensor_limit,    100.0);
                            fassign(trans1_lower_sensor_limit,    0.0);
                            fassign(trans1_poly_coeff_max,        10.0);
                            fassign(trans1_poly_coeff_min,        -60.0);
                            fassign(trans1_sens_drift_limit,      1.0);
                            fassign(trans1_threshold_value,       0.0);
                        }
                        break;
                    }
                case 1000:  
                    {
                        // both K or K to %
                        if ((new_unit_1 == 1000))
                        {
                            ;// do nothing
                        }
                        // from Kelvin to Fahrenheit  
                        else if (new_unit_1 == 1002)
                        {
                            f_tmp = fvar_value(loc_bias_1);
                            f_tmp = f_tmp * 1.8;
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans1_external_reference_junction_value);
                            f_tmp = (( f_tmp - 273.15 ) * 1.8 ) + 32 ;
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_external_reference_junction_value, f_tmp);

                            f_tmp = fvar_value(loc_cvd_max_1);
                            f_tmp = (( f_tmp - 273.15 ) * 1.8 ) + 32 ;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_1);
                            f_tmp = (( f_tmp - 273.15 ) * 1.8 ) + 32 ;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_1);
                            f_tmp = (( f_tmp - 273.15 ) * 1.8 ) + 32 ;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_1);
                            f_tmp = (( f_tmp - 273.15 ) * 1.8 ) + 32 ;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_1);
                            f_tmp = (( f_tmp - 273.15 ) * 1.8 ) + 32 ;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_1);
                            f_tmp = (( f_tmp - 273.15 ) * 1.8 ) + 32 ;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_1);
                            f_tmp = f_tmp * 1.8 ;
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_1);
                            f_tmp = (( f_tmp - 273.15 ) * 1.8 ) + 32 ;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_threshold_value, f_tmp);
                        }
                        // from Kelvin to Celsius  
                        else if (new_unit_1 == 1001 )
                        {
                            f_tmp = fvar_value(loc_bias_1);
                            /*offset round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans1_external_reference_junction_value);
                            f_tmp = f_tmp - 273.15;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_1);
                            f_tmp = f_tmp - 273.15;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_1);
                            f_tmp = f_tmp - 273.15;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_1);
                            f_tmp = f_tmp - 273.15;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_1);
                            f_tmp = f_tmp - 273.15;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_1);
                            f_tmp = f_tmp - 273.15;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_1);
                            f_tmp = f_tmp - 273.15;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_1);
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_1);
                            f_tmp = f_tmp - 273.15;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_threshold_value, f_tmp);
                        }
                        // from Kelvin to %  (Celsius values) 
                        else if (new_unit_1 == 1342)
                        {
                            f_tmp = fvar_value(loc_bias_1);
                            /*offset round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans1_external_reference_junction_value);
                            f_tmp = f_tmp - 273.15;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_1);
                            f_tmp = f_tmp - 273.15;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_1);
                            f_tmp = f_tmp - 273.15;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_1);
                            f_tmp = f_tmp - 273.15;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_1);
                            f_tmp = f_tmp - 273.15;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_1);
                            f_tmp = f_tmp - 273.15;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_1);
                            f_tmp = f_tmp - 273.15;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_1);
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_1);
                            f_tmp = f_tmp - 273.15;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_threshold_value, f_tmp);
                        }
                        // from Kelvin to Rankine
                        else if (new_unit_1 == 1003)
                        {
                            f_tmp = fvar_value(loc_bias_1);
                            f_tmp = f_tmp * 1.8;
                            /*offset round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans1_external_reference_junction_value);
                            f_tmp = f_tmp * 1.8;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_external_reference_junction_value, f_tmp);

                            f_tmp = fvar_value(loc_cvd_max_1);
                            f_tmp = f_tmp * 1.8;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_1);
                            f_tmp = f_tmp * 1.8;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_1);
                            f_tmp = f_tmp * 1.8;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_1);
                            f_tmp = f_tmp * 1.8;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_1);
                            f_tmp = f_tmp * 1.8;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_1);
                            f_tmp = f_tmp * 1.8;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_1);
                            f_tmp = f_tmp * 1.8;
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_1);
                            f_tmp = f_tmp * 1.8;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_threshold_value, f_tmp);
                        }
                        // in else auf default zurückstellen im fall ohm,mv ? 
                        else
                        {
                            //ACKNOWLEDGE("Set to default values. old unit: K" );
                            fassign(trans1_bias_1,              0);
                            fassign(trans1_cvd_max,             100);
                            fassign(trans1_cvd_min,             0);
                            fassign(trans1_upper_sensor_limit,  100);
                            fassign(trans1_lower_sensor_limit,  0);
                            fassign(trans1_poly_coeff_max,      10);
                            fassign(trans1_poly_coeff_min,      -60);
                            fassign(trans1_sens_drift_limit,    1);
                            fassign(trans1_threshold_value,     0);
                        }     
                        break;
                    }
                case 1002:  {
                        // both Fahrenheit or Fahrenheit to %
                        if (new_unit_1 == 1002)
                        {
                            ;// do nothing
                        }
                        // from Fahrenheit to Kelvin  
                        else if (new_unit_1 == 1000)
                        {
                            f_tmp = fvar_value(loc_bias_1);
                            f_tmp = f_tmp / 1.8;
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans1_external_reference_junction_value);
                            f_tmp = (( f_tmp - 32 ) / 1.8) + 273.15 ;
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_external_reference_junction_value, f_tmp);

                            f_tmp = fvar_value(loc_cvd_max_1);
                            f_tmp = (( f_tmp - 32 ) / 1.8) + 273.15 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_1);
                            f_tmp = (( f_tmp - 32 ) / 1.8) + 273.15 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_1);
                            f_tmp = (( f_tmp - 32 ) / 1.8) + 273.15 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_1);
                            f_tmp = (( f_tmp - 32 ) / 1.8) + 273.15 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_1);
                            f_tmp = (( f_tmp - 32 ) / 1.8) + 273.15 ;
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_1);
                            f_tmp = (( f_tmp - 32 ) / 1.8) + 273.15 ;
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_1);
                            f_tmp = ( f_tmp / 1.8) ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_1);
                            f_tmp = (( f_tmp - 32 ) / 1.8) + 273.15 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_threshold_value, f_tmp);
                        }
                        //from Fahrenheit to Celcius
                        else if (new_unit_1 == 1001 )
                        {
                            f_tmp = fvar_value(loc_bias_1);
                            f_tmp = f_tmp / 1.8;
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans1_external_reference_junction_value);
                            f_tmp = (f_tmp - 32) / 1.8 ;
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_external_reference_junction_value, f_tmp);

                            f_tmp = fvar_value(loc_cvd_max_1);
                            f_tmp = (f_tmp - 32) / 1.8 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_1);
                            f_tmp = (f_tmp - 32) / 1.8 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_1);
                            f_tmp = (f_tmp - 32) / 1.8 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_1);
                            f_tmp = (f_tmp - 32) / 1.8 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_1);
                            f_tmp = (f_tmp - 32) / 1.8 ;
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_1);
                            f_tmp = (f_tmp - 32) / 1.8 ;
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_1);
                            f_tmp = f_tmp / 1.8 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_1);
                            f_tmp = (f_tmp - 32) / 1.8 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_threshold_value, f_tmp);
                        }
                        //from Fahrenheit to %
                        else if (new_unit_1 == 1342)
                        {
                            f_tmp = fvar_value(loc_bias_1);
                            f_tmp = f_tmp / 1.8;
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans1_external_reference_junction_value);
                            f_tmp = (f_tmp - 32) / 1.8 ; 
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_external_reference_junction_value, f_tmp);

                            f_tmp = fvar_value(loc_cvd_max_1);
                            f_tmp = (f_tmp - 32) / 1.8 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_1);
                            f_tmp = (f_tmp - 32) / 1.8 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_1);
                            f_tmp = (f_tmp - 32) / 1.8 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_1);
                            f_tmp = (f_tmp - 32) / 1.8 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_1);
                            f_tmp = (f_tmp - 32) / 1.8 ;
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_1);
                            f_tmp = (f_tmp - 32) / 1.8 ;
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_1);
                            f_tmp = f_tmp / 1.8 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_1);
                            f_tmp = (f_tmp - 32) / 1.8 ;
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_threshold_value, f_tmp);
                        }
                        // from Fahrenheit to Rankine
                        else if (new_unit_1 == 1003)
                        {
                            f_tmp = fvar_value(loc_bias_1);
                            /*offset round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans1_external_reference_junction_value);
                            f_tmp = f_tmp + 459.67;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif                            
                            fassign(trans1_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_1);
                            f_tmp = f_tmp + 459.67;
                            /*cvd_max round result to 3 decimals*/ 
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_1);
                            f_tmp = f_tmp + 459.67;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_1);
                            f_tmp = f_tmp + 459.67;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_1);
                            f_tmp = f_tmp + 459.67;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_1);
                            f_tmp = f_tmp + 459.67;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_1);
                            f_tmp = f_tmp + 459.67;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_1);

                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_1);
                            f_tmp = f_tmp + 459.67;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_threshold_value, f_tmp);
                        }
                        // in else auf default zurückstellen im fall ohm,mv ? 
                        else
                        {
                            //ACKNOWLEDGE("Set to default values. old unit: F" );
                            fassign(trans1_bias_1,              0);
                            fassign(trans1_cvd_max,             100);
                            fassign(trans1_cvd_min,             0);
                            fassign(trans1_upper_sensor_limit,  100);
                            fassign(trans1_lower_sensor_limit,  0);
                            fassign(trans1_poly_coeff_max,      10);
                            fassign(trans1_poly_coeff_min,      -60);
                            fassign(trans1_sens_drift_limit,    1);
                            fassign(trans1_threshold_value,     0);
                        }                           
                        break;              
                    }
                case 1003:  {
                        // both Rankine
                        if ((new_unit_1 == 1003))
                        {
                            ;// do nothing
                        }
                        // from Rankine to Kelvin
                        else if (new_unit_1 == 1000)
                        {
                            f_tmp = fvar_value(loc_bias_1);
                            f_tmp = f_tmp / 1.8;
                            /*offset round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans1_external_reference_junction_value);
                            f_tmp = f_tmp / 1.8; 
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_1);
                            f_tmp = f_tmp / 1.8;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_1);
                            f_tmp = f_tmp / 1.8;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_1);
                            f_tmp = f_tmp / 1.8;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_1);
                            f_tmp = f_tmp / 1.8;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_1);
                            f_tmp = f_tmp / 1.8;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_1);
                            f_tmp = f_tmp / 1.8;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_1);
                            f_tmp = f_tmp / 1.8;
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_1);
                            f_tmp = f_tmp / 1.8;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_threshold_value, f_tmp);
                        }
                        // from Rankine to Celsius
                        else if (new_unit_1 == 1001)
                        {
                            f_tmp = fvar_value(loc_bias_1); 
                            f_tmp = f_tmp / 1.8;
                            /*offset round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans1_external_reference_junction_value);
                            f_tmp = ( f_tmp - 491.67 ) / 1.8;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_external_reference_junction_value, f_tmp);

                            f_tmp = fvar_value(loc_cvd_max_1);
                            f_tmp = ( f_tmp - 491.67 ) / 1.8;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_1);
                            f_tmp = ( f_tmp - 491.67 ) / 1.8;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_1);
                            f_tmp = ( f_tmp - 491.67 ) / 1.8;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_1);
                            f_tmp = ( f_tmp - 491.67 ) / 1.8;                    
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_1);
                            f_tmp = ( f_tmp - 491.67 ) / 1.8;                    
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_1);
                            f_tmp = ( f_tmp - 491.67 ) / 1.8;                    
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_1);
                            f_tmp =  f_tmp / 1.8;
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_1);
                            f_tmp = ( f_tmp - 491.67 ) / 1.8;                    
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_threshold_value, f_tmp);
                        }
                        // from Rankine to %
                        else if (new_unit_1 == 1342)
                        {
                            f_tmp = fvar_value(loc_bias_1); 
                            f_tmp = f_tmp / 1.8;
                            /*offset round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans1_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans1_external_reference_junction_value);
                            f_tmp = ( f_tmp - 491.67 ) / 1.8;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_external_reference_junction_value, f_tmp);

                            f_tmp = fvar_value(loc_cvd_max_1);
                            f_tmp = ( f_tmp - 491.67 ) / 1.8;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_1);
                            f_tmp = ( f_tmp - 491.67 ) / 1.8;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_1);
                            f_tmp = ( f_tmp - 491.67 ) / 1.8;                    
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_1);
                            f_tmp = ( f_tmp - 491.67 ) / 1.8;                    
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_1);
                            f_tmp = ( f_tmp - 491.67 ) / 1.8;                    
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_1);
                            f_tmp = ( f_tmp - 491.67 ) / 1.8;                    
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_1);
                            f_tmp =  f_tmp / 1.8;
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_1);
                            f_tmp = ( f_tmp - 491.67 ) / 1.8;                    
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_threshold_value, f_tmp);
                        }
                        // from Rankine to Fahrenheit
                        else if (new_unit_1 == 1002)
                        {
                            f_tmp = fvar_value(loc_bias_1);            
                            /*offset round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans1_external_reference_junction_value);
                            f_tmp = f_tmp -459.67;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_1);
                            f_tmp = f_tmp -459.67;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_1);
                            f_tmp = f_tmp -459.67;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_1);
                            f_tmp = f_tmp -459.67;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_1);
                            f_tmp = f_tmp -459.67;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_1);
                            f_tmp = f_tmp -459.67;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_1);
                            f_tmp = f_tmp -459.67;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_1);
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_1);
                            f_tmp = f_tmp -459.67;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif
                            fassign(trans1_threshold_value, f_tmp);
                        }
                        // in else auf default zurückstellen im fall ohm,mv ? 
                        else
                        {
                            //ACKNOWLEDGE("Set to default values. old unit: R" );
                            fassign(trans1_bias_1,              0);
                            fassign(trans1_cvd_max,             100);
                            fassign(trans1_cvd_min,             0);
                            fassign(trans1_upper_sensor_limit,  100);
                            fassign(trans1_lower_sensor_limit,  0);
                            fassign(trans1_poly_coeff_max,      10);
                            fassign(trans1_poly_coeff_min,      -60);
                            fassign(trans1_sens_drift_limit,    1);
                            fassign(trans1_threshold_value,     0);
                        }                                                                                
                        break;     
                    }
                }                                                                                    
                ////ACKNOWLEDGE("End 1 Edit Convert"); 

                f_tmp = ivar_value(trans1_primary_value_unit);
                iassign(loc_old_unit_1,f_tmp);

                save_values();
            }
	#ifdef _V600_
		}
	#endif
    }
}


/********* Transducer 2 **********************/


METHOD method_post_edit_convert_2_offline
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
        int new_unit_2;
        int old_unit_2;
        float f_tmp;
        int i_tmp;

	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            if (ivar_value(trans2_lin_type) != 0)
            {

                // first make local variables actual
                f_tmp = fvar_value(trans2_bias_1);
                /*offset round result to 2 decimals*/
                fassign(loc_bias_2, f_tmp);

                f_tmp = fvar_value(trans2_external_reference_junction_value);
                fassign(loc_trans2_external_reference_junction_value, f_tmp);        

                f_tmp = fvar_value(trans2_cvd_max);
                fassign(loc_cvd_max_2, f_tmp);

                f_tmp = fvar_value(trans2_cvd_min);
                fassign(loc_cvd_min_2, f_tmp);

                f_tmp = fvar_value(trans2_poly_coeff_max);
                fassign(loc_poly_coeff_max_2, f_tmp);

                f_tmp = fvar_value(trans2_poly_coeff_min);
                fassign(loc_poly_coeff_min_2, f_tmp);

                f_tmp = fvar_value(trans2_upper_sensor_limit);
                fassign(loc_upper_sensor_limit_2, f_tmp);

                f_tmp = fvar_value(trans2_lower_sensor_limit);
                fassign(loc_lower_sensor_limit_2, f_tmp);

                f_tmp = fvar_value(trans2_sens_drift_limit);
                fassign(loc_sens_drift_limit_2, f_tmp);

                f_tmp = fvar_value(trans2_threshold_value);
                fassign(loc_threshold_value_2, f_tmp);

                // get new unit and save old unit
                new_unit_2 = ivar_value(trans2_primary_value_unit);
                old_unit_2 = ivar_value(loc_old_unit_2);

                // For DTM. Save unit for next time, because DTM does not call pre-edit
                iassign(loc_old_unit_2, new_unit_2);

                switch (old_unit_2)
                {
                case 1001:
                case 1342:  
                    {
                        ////ACKNOWLEDGE("Old Unit Celsius 2");
                        // both °C or °C to %

                        // from Celsius to Fahrenheit  
                        if (new_unit_2 == 1002)
                        {
                            f_tmp = fvar_value(loc_bias_2);
                            f_tmp = f_tmp * 1.8;
                            /*offset round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans2_external_reference_junction_value);
                            f_tmp = (f_tmp * 1.8) + 32;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_2);
                            f_tmp = (f_tmp * 1.8) + 32;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_2);
                            f_tmp = (f_tmp * 1.8) + 32;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_2);
                            f_tmp = (f_tmp * 1.8) + 32;
                            fassign(trans2_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_2);
                            f_tmp = (f_tmp * 1.8) + 32;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_2);
                            f_tmp = (f_tmp * 1.8) + 32;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_2);
                            f_tmp = (f_tmp * 1.8) + 32;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_2);
                            f_tmp = f_tmp * 1.8;
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_2);
                            f_tmp = (f_tmp * 1.8) + 32;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_threshold_value, f_tmp);
                        }
                        // from Celsius to Kelvin
                        else if (new_unit_2 == 1000)
                        {
                            f_tmp = fvar_value(loc_bias_2);
                            /*offset round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans2_external_reference_junction_value);
                            f_tmp = f_tmp + 273.15;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_2);
                            f_tmp = f_tmp + 273.15;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_2);
                            f_tmp = f_tmp + 273.15;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_2);
                            f_tmp = f_tmp + 273.15;
                            fassign(trans2_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_2);
                            f_tmp = f_tmp + 273.15;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_2);
                            f_tmp = f_tmp + 273.15;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_2);
                            f_tmp = f_tmp + 273.15;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_2);                           
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_2);
                            f_tmp = f_tmp + 273.15;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_threshold_value, f_tmp);

                        }
                        // from Celsius to Rankine
                        else if (new_unit_2 == 1003)
                        {
                            f_tmp = fvar_value(loc_bias_2);
                            f_tmp = f_tmp * 1.8;
                            /*offset round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans2_external_reference_junction_value);
                            f_tmp = (f_tmp + 273.15) * 1.8;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_2);
                            f_tmp = (f_tmp + 273.15) * 1.8;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_2);
                            f_tmp = (f_tmp + 273.15) * 1.8;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_2);
                            f_tmp = (f_tmp + 273.15) * 1.8;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_2);
                            f_tmp = (f_tmp + 273.15) * 1.8;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_2);
                            f_tmp = (f_tmp + 273.15) * 1.8;
                            fassign(trans2_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_2);
                            f_tmp = (f_tmp + 273.15) * 1.8;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_2);
                            f_tmp = f_tmp * 1.8;
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_2);
                            f_tmp = (f_tmp + 273.15) * 1.8;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_threshold_value, f_tmp);
                        }
                        else if ((new_unit_2 == 1001))
                        {
                            f_tmp = 0;// do nothing
                        }
                        else if (new_unit_2 == 1342)
                        {
                            f_tmp = 0;// do nothing
                        }
                        // in else auf default zurückstellen im fall ohm,mv ? 
                        else
                        {
                            fassign(trans2_bias_1,              0);
                            fassign(trans2_cvd_max,             100);
                            fassign(trans2_cvd_min,             0);
                            fassign(trans2_upper_sensor_limit,  100);
                            fassign(trans2_lower_sensor_limit,  0);
                            fassign(trans2_poly_coeff_max,      10);
                            fassign(trans2_poly_coeff_min,      -60);
                            fassign(trans2_sens_drift_limit,    1);
                            fassign(trans2_threshold_value,     0);
                        }   
                        // in else auf default zurückstellen im fall ohm,mv,% ? 
                        break;
                    }
                case 1000:  {
                        // //ACKNOWLEDGE("Old Unit Kelvin 2");
                        // both K or K to %
                        if ((new_unit_2 == 1000))
                        {
                            // do nothing
                        }
                        // from Kelvin to Fahrenheit  
                        else if (new_unit_2 == 1002)
                        {
                            f_tmp = fvar_value(loc_bias_2);
                            f_tmp = f_tmp * 1.8;
                            /*offset round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans2_external_reference_junction_value);
                            f_tmp = (( f_tmp - 273.15 ) * 1.8) + 32;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_2);
                            f_tmp = (( f_tmp - 273.15 ) * 1.8) + 32;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_2);
                            f_tmp = (( f_tmp - 273.15 ) * 1.8) + 32;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_2);
                            f_tmp = (( f_tmp - 273.15 ) * 1.8) + 32;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_2);
                            f_tmp = (( f_tmp - 273.15 ) * 1.8) + 32;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_2);
                            f_tmp = (( f_tmp - 273.15 ) * 1.8) + 32;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_2);
                            f_tmp = (( f_tmp - 273.15 ) * 1.8) + 32;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_2);
                            f_tmp = f_tmp * 1.8;
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_2);
                            f_tmp = (( f_tmp - 273.15 ) * 1.8) + 32;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_threshold_value, f_tmp);
                        }
                        // from Kelvin to Celsius  
                        else if (new_unit_2 == 1001)
                        {
                            f_tmp = fvar_value(loc_bias_2);
                            /*offset round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans2_external_reference_junction_value);
                            f_tmp = f_tmp - 273.15;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_external_reference_junction_value, f_tmp);                     

                            f_tmp = fvar_value(loc_cvd_max_2);
                            f_tmp = f_tmp - 273.15;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_2);
                            f_tmp = f_tmp - 273.15;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_2);
                            f_tmp = f_tmp - 273.15;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_2);
                            f_tmp = f_tmp - 273.15;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_2);
                            f_tmp = f_tmp - 273.15;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_2);
                            f_tmp = f_tmp - 273.15;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_2);
                            fassign(trans2_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_2);
                            f_tmp = f_tmp - 273.15;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_threshold_value, f_tmp);
                        }
                        // from Kelvin to %
                        else if (new_unit_2 == 1342)
                        {
                            f_tmp = fvar_value(loc_bias_2);
                            /*offset round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans2_external_reference_junction_value);
                            f_tmp = f_tmp - 273.15;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_external_reference_junction_value, f_tmp);                     

                            f_tmp = fvar_value(loc_cvd_max_2);
                            f_tmp = f_tmp - 273.15;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_2);
                            f_tmp = f_tmp - 273.15;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_2);
                            f_tmp = f_tmp - 273.15;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_2);
                            f_tmp = f_tmp - 273.15;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_2);
                            f_tmp = f_tmp - 273.15;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_2);
                            f_tmp = f_tmp - 273.15;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_2);
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_2);
                            f_tmp = f_tmp - 273.15;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_threshold_value, f_tmp);
                        }
                        // from Kelvin to Rankine
                        else if (new_unit_2 == 1003)
                        {
                            f_tmp = fvar_value(loc_bias_2);
                            f_tmp = f_tmp * 1.8;
                            /*offset round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans2_external_reference_junction_value);
                            f_tmp = f_tmp * 1.8;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_2);
                            f_tmp = f_tmp * 1.8;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_2);
                            f_tmp = f_tmp * 1.8;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_2);
                            f_tmp = f_tmp * 1.8;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_2);
                            f_tmp = f_tmp * 1.8;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_2);
                            f_tmp = f_tmp * 1.8;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_2);
                            f_tmp = f_tmp * 1.8;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_2);
                            f_tmp = f_tmp * 1.8;
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_2);
                            f_tmp = f_tmp * 1.8;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_threshold_value, f_tmp);
                        }
                        // in else auf default zurückstellen im fall ohm,mv ? 
                        else
                        {
                            fassign(trans2_bias_1,              0);
                            fassign(trans2_cvd_max,             100);
                            fassign(trans2_cvd_min,             0);
                            fassign(trans2_upper_sensor_limit,  100);
                            fassign(trans2_lower_sensor_limit,  0);
                            fassign(trans2_poly_coeff_max,      10);
                            fassign(trans2_poly_coeff_min,      -60);
                            fassign(trans2_sens_drift_limit,    1);
                            fassign(trans2_threshold_value,     0);
                        }     
                        break;
                    }
                case 1002:  {
                        ////ACKNOWLEDGE("Old Unit Fahrenheit 2");
                        // both Fahrenheit 
                        if (new_unit_2 == 1002)
                        {
                            // do nothing
                        }
                        // from Fahrenheit to Kelvin  
                        else if (new_unit_2 == 1000)
                        {
                            f_tmp = fvar_value(loc_bias_2);
                            f_tmp = f_tmp / 1.8;
                            /*offset round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans2_external_reference_junction_value);
                            f_tmp = ((f_tmp - 32) / 1.8) + 273.15;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_2);
                            f_tmp = ((f_tmp - 32) / 1.8) + 273.15;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_2);
                            f_tmp = ((f_tmp - 32) / 1.8) + 273.15;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_2);
                            f_tmp = ((f_tmp - 32) / 1.8) + 273.15;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_2);
                            f_tmp = ((f_tmp - 32) / 1.8) + 273.15;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_2);
                            f_tmp = ((f_tmp - 32) / 1.8) + 273.15;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_2);
                            f_tmp = ((f_tmp - 32) / 1.8) + 273.15;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_2);
                            f_tmp = f_tmp / 1.8;
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_2);
                            f_tmp = ((f_tmp - 32) / 1.8) + 273.15;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_threshold_value, f_tmp);
                        }
                        //from Fahrenheit to Celcius
                        else if (new_unit_2 == 1001)
                        {
                            f_tmp = fvar_value(loc_bias_2);
                            f_tmp = f_tmp / 1.8;
                            /*offset round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans2_external_reference_junction_value);
                            f_tmp = (f_tmp - 32 ) / 1.8;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_2);
                            f_tmp = (f_tmp - 32 ) / 1.8;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_2);
                            f_tmp = (f_tmp - 32 ) / 1.8;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_2);
                            f_tmp = (f_tmp - 32 ) / 1.8;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_2);
                            f_tmp = (f_tmp - 32 ) / 1.8;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_2);
                            f_tmp = (f_tmp - 32 ) / 1.8;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_2);
                            f_tmp = (f_tmp - 32 ) / 1.8;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_2);
                            f_tmp = f_tmp / 1.8;
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_2);
                            f_tmp = (f_tmp - 32 ) / 1.8;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_threshold_value, f_tmp);
                        }
                        // from Fahrenheit to %
                        else if (new_unit_2 == 1342)
                        {
                            f_tmp = fvar_value(loc_bias_2);
                            f_tmp = f_tmp / 1.8;
                            /*offset round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans2_external_reference_junction_value);
                            f_tmp = (f_tmp - 32 ) / 1.8;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_2);
                            f_tmp = (f_tmp - 32 ) / 1.8;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_2);
                            f_tmp = (f_tmp - 32 ) / 1.8;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_2);
                            f_tmp = (f_tmp - 32 ) / 1.8;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_2);
                            f_tmp = (f_tmp - 32 ) / 1.8;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_2);
                            f_tmp = (f_tmp - 32 ) / 1.8;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_2);
                            f_tmp = (f_tmp - 32 ) / 1.8;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_2);
                            f_tmp = f_tmp / 1.8;
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_2);
                            f_tmp = (f_tmp - 32 ) / 1.8;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_threshold_value, f_tmp);
                        }
                        // from Fahrenheit to Rankine
                        else if (new_unit_2 == 1003)
                        {
                            f_tmp = fvar_value(loc_bias_2);
                            /*offset round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans2_external_reference_junction_value);
                            f_tmp = f_tmp + 459.67;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_2);
                            f_tmp = f_tmp + 459.67;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_2);
                            f_tmp = f_tmp + 459.67;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_2);
                            f_tmp = f_tmp + 459.67;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_2);
                            f_tmp = f_tmp + 459.67;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_2);
                            f_tmp = f_tmp + 459.67;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_2);
                            f_tmp = f_tmp + 459.67;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_2);
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_2);
                            f_tmp = f_tmp + 459.67;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_threshold_value, f_tmp);
                        }
                        // in else auf default zurückstellen im fall ohm,mv ? 
                        else
                        {
                            fassign(trans2_bias_1,              0);
                            fassign(trans2_cvd_max,             100);
                            fassign(trans2_cvd_min,             0);
                            fassign(trans2_upper_sensor_limit,  100);
                            fassign(trans2_lower_sensor_limit,  0);
                            fassign(trans2_poly_coeff_max,      10);
                            fassign(trans2_poly_coeff_min,      -60);
                            fassign(trans2_sens_drift_limit,    1);
                            fassign(trans2_threshold_value,     0);
                        }     
                        break;              
                    }
                case 1003:  {
                        ////ACKNOWLEDGE("Old Unit Rankine 2");
                        // both Rankine
                        if ((new_unit_2 == 1003) )
                        {
                            // do nothing
                        }
                        // from Rankine to Kelvin  
                        else if (new_unit_2 == 1000)
                        {
                            f_tmp = fvar_value(loc_bias_2);
                            f_tmp = f_tmp / 1.8;
                            /*offset round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans2_external_reference_junction_value);
                            f_tmp = f_tmp / 1.8;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_2);
                            f_tmp = f_tmp / 1.8;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_2);
                            f_tmp = f_tmp / 1.8;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_2);
                            f_tmp = f_tmp / 1.8;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_2);
                            f_tmp = f_tmp / 1.8;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_2);
                            f_tmp = f_tmp / 1.8;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_2);
                            f_tmp = f_tmp / 1.8;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_2);
                            f_tmp = f_tmp / 1.8;
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_2);
                            f_tmp = f_tmp / 1.8;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_threshold_value, f_tmp);
                        }
                        // from Rankine to Celsius
                        else if ((new_unit_2 == 1001))
                        {
                            f_tmp = fvar_value(loc_bias_2);
                            f_tmp = f_tmp / 1.8;
                            /*offset round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans2_external_reference_junction_value);
                            f_tmp = (f_tmp - 491.67) / 1.8;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_2);
                            f_tmp = (f_tmp - 491.67) / 1.8;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_2);
                            f_tmp = (f_tmp - 491.67) / 1.8;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_2);
                            f_tmp = (f_tmp - 491.67) / 1.8;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_2);
                            f_tmp = (f_tmp - 491.67) / 1.8;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_2);
                            f_tmp = (f_tmp - 491.67) / 1.8;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_2);
                            f_tmp = (f_tmp - 491.67) / 1.8;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_2);
                            f_tmp = f_tmp / 1.8;
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_2);
                            f_tmp = (f_tmp - 491.67) / 1.8;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_threshold_value, f_tmp);
                        }
                        // from Rankine to %
                        else if (new_unit_2 == 1342)
                        {
                            f_tmp = fvar_value(loc_bias_2);
                            f_tmp = f_tmp / 1.8;
                            /*offset round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans2_external_reference_junction_value);
                            f_tmp = (f_tmp - 491.67) / 1.8;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_2);
                            f_tmp = (f_tmp - 491.67) / 1.8;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_2);
                            f_tmp = (f_tmp - 491.67) / 1.8;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_2);
                            f_tmp = (f_tmp - 491.67) / 1.8;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_2);
                            f_tmp = (f_tmp - 491.67) / 1.8;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_2);
                            f_tmp = (f_tmp - 491.67) / 1.8;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_2);
                            f_tmp = (f_tmp - 491.67) / 1.8;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_2);
                            f_tmp = f_tmp / 1.8;
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_2);
                            f_tmp = (f_tmp - 491.67) / 1.8;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_threshold_value, f_tmp);
                        }
                        // from Rankine to Fahrenheit
                        else if (new_unit_2 == 1002)
                        {
                            f_tmp = fvar_value(loc_bias_2);
                            /*offset round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_bias_1, f_tmp);

                            f_tmp = fvar_value(loc_trans2_external_reference_junction_value);
                            f_tmp = f_tmp - 459.67;
                            /*rj_ext round result to 2 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_external_reference_junction_value, f_tmp);                    

                            f_tmp = fvar_value(loc_cvd_max_2);
                            f_tmp = f_tmp - 459.67;
                            /*cvd_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_max, f_tmp);

                            f_tmp = fvar_value(loc_cvd_min_2);
                            f_tmp = f_tmp - 459.67;
                            /*cvd_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_cvd_min, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_max_2);
                            f_tmp = f_tmp - 459.67;
                            /*poly_coeff_max round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_max, f_tmp);

                            f_tmp = fvar_value(loc_poly_coeff_min_2);
                            f_tmp = f_tmp - 459.67;
                            /*poly_coeff_min round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_poly_coeff_min, f_tmp);

                            f_tmp = fvar_value(loc_upper_sensor_limit_2);
                            f_tmp = f_tmp - 459.67;
                            /*upper_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_upper_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_lower_sensor_limit_2);
                            f_tmp = f_tmp - 459.67;
                            /*lower_sensor_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_2_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_2_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_lower_sensor_limit, f_tmp);

                            f_tmp = fvar_value(loc_sens_drift_limit_2);
                            /*sens_drift_limit round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_sens_drift_limit, f_tmp);

                            f_tmp = fvar_value(loc_threshold_value_2);
                            f_tmp = f_tmp - 459.67;
                            /*threshold_value round result to 3 decimals*/
#ifdef PDM 
                            ROUND_TO_3_DECIMALS_PDM;
#else
#ifdef DTM
                            ROUND_TO_3_DECIMALS_DTM;
#endif
#endif           
                            fassign(trans2_threshold_value, f_tmp);
                        }
                        // in else auf default zurückstellen im fall ohm,mv ? 
                        else
                        {
                            fassign(trans2_bias_1,              0);
                            fassign(trans2_cvd_max,             100);
                            fassign(trans2_cvd_min,             0);
                            fassign(trans2_upper_sensor_limit,  100);
                            fassign(trans2_lower_sensor_limit,  0);
                            fassign(trans2_poly_coeff_max,      10);
                            fassign(trans2_poly_coeff_min,      -60);
                            fassign(trans2_sens_drift_limit,    1);
                            fassign(trans2_threshold_value,     0);
                        }                                                                                  
                        break;      
                    }
                }                                                                                    
                //ACKNOWLEDGE("End Post Edit Convert 2");
                save_values();
            }
	#ifdef _V600_
		}
	#endif
    }
}

// this method is needed bcause of the follwing scenario:
// - channel 1 is changed from RTD, 4-wire to TC. Then the wire_connection disapears an stays at 4-wire setting. 
//   Therfore the wire_connection has to be reset to 3-wireotherwise channel 2 does not provide the RTD and Ohm sensortypes.
#ifdef _V600_
METHOD method_post_edit_set_trans1_sensor_connection_online
{
    CLASS INPUT;
    ACCESS ONLINE;
    DEFINITION
    {
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 1 )
        {

            //ACKNOWLEDGE("method_post_edit_set_trans1_sensor_connection_online");
            // IF a "TC" or "mV" or "No Sensor" is set
            if ( (DEF_LIN_TYPE_TC_1) || (DEF_LIN_TYPE_MV_1) || (DEF_LIN_TYPE_NO_SENSOR_1) )
            {
                // set sensor connection to 3- wire            
                iassign(trans1_sensor_connection, 1);
                save_values();
            }
                WriteCommand(write_trans1_sensor_connection);
            }
        }
    }
#endif
METHOD method_post_edit_set_trans1_sensor_connection_offline
{
    CLASS INPUT;
    ACCESS OFFLINE;
    DEFINITION
    {
	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            //ACKNOWLEDGE("method_post_edit_set_trans1_sensor_connection_offline");
            // IF a "TC" or "mV" or "No Sensor" is set
            if ( (DEF_LIN_TYPE_TC_1) || (DEF_LIN_TYPE_MV_1) || (DEF_LIN_TYPE_NO_SENSOR_1) )
            {
                // set sensor connection to 3- wire            
                iassign(trans1_sensor_connection, 1);
                save_values();
            }
	#ifdef _V600_
        }
	#endif
    }
}

// this method is needed bcause of the follwing scenario:
// - channel 2 is changed from RTD, 3-wire to TC. Then the wire_connection disapears and would stay at 3-wire.
//   Therefore is has to be reset to 2-wire. Otherwise channel 1 does not provide 4-wire connection possibility.
#ifdef _V600_
METHOD method_post_edit_set_trans2_sensor_connection_online
{
    CLASS INPUT;
    ACCESS ONLINE;    
    DEFINITION
    {
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 1 )
        {
            ////ACKNOWLEDGE("method_post_edit_set_trans2_sensor_connection_online");
            // IF a TC or mV is set
            if ( ( (ivar_value(trans2_lin_type) >= 128) && (ivar_value(trans2_lin_type) <= 140) ) || 
                 ( (ivar_value(trans2_lin_type) == 0)   && ((ivar_value(trans2_input_range) == 0 || ivar_value(trans2_input_range) == 1)) )
               )
            {
                // set sensor connection to 2- wire            
                iassign(trans2_sensor_connection, 0);
                save_values();
                WriteCommand(write_trans2_sensor_connection);
            }
        }
    }
}
#endif
METHOD method_post_edit_set_trans2_sensor_connection_offline
{
    CLASS INPUT;
    ACCESS OFFLINE;    
    DEFINITION
    {
	#ifdef _V600_
        int is_Online;
        is_Online = ivar_value(isOnline);
        if (is_Online == 0 )
        {
	#endif
            //ACKNOWLEDGE("method_post_edit_set_trans2_sensor_connection_offline");
            // IF a TC or mV is set
            if ( ( (ivar_value(trans2_lin_type) >= 128) && (ivar_value(trans2_lin_type) <= 140) ) || 
                 ( (ivar_value(trans2_lin_type) == 0)   && ((ivar_value(trans2_input_range) == 0 || ivar_value(trans2_input_range) == 1)) )
               )
            {
                // set sensor connection to 2- wire            
                iassign(trans2_sensor_connection, 0);
            }
            save_values();
	#ifdef _V600_
        }
	#endif
    }
}


