#######################################################################################
#######################################################################################
#NIDD_VER: MNL17_1610_008_00
#MNL
#Migration from FL17_MNL_Macro to SBTS17 - 	
#24.02.2017/ v0.1 /first draft /L.Preuss
#
# HAI, v.02, 23.06.2017 PR253987: [SBTS17][RP001738][LN] MNLENT/SYNC/CLOCK/TOP MO is incomplete after conversion from FL16A
#######################################################################################

#######################################################################################
#######################################################################################

if ( objects_count "MRBTS" ) == 0 abort_file
if ( objects_count "MRBTS/MNL" ) == 0 abort_file
if ( objects_count "MRBTS/LNBTS" ) == 0 abort_file

define "versionLnbts" "none"
define "version" "none"
for_objects "MRBTS" define "mrbtsRoot" $current_dist_name
for_objects "MRBTS/MNL" define "mnlRoot" $current_dist_name
for_objects "MRBTS/MNL/MNLENT" define "mnlentRoot" $current_dist_name
for_objects "MRBTS/LNBTS" define "lnbtsRoot" $current_dist_name

define "tempVersion" get_version mnlRoot
define "tempVersion2" replace tempVersion "(.*(MNL17).*)|^(?!MNL17).*" "$2" flags "g"
if tempVersion2 == "MNL17" define "version" "MNL17_1610_008"
if ( tempVersion2 ) == ""
    begin
        define "tempVersion2" replace tempVersion "(.*(MNL18_Macro).*)|^(?!MNL18_Macro).*" "$2" flags "g"
        if ( tempVersion2 ) == "MNL18_Macro"
            begin
                define "version" "MNL17_1610_008"
            end
    end

define "tempVersion3" get_version lnbtsRoot
define "tempVersion4" replace tempVersion3 "(.*(FL17).*)|^(?!FL17).*" "$2" flags "g"
if tempVersion4 == "FL17" define "versionLnbts" "xL17_1610_006"
if ( tempVersion4 ) == ""
    begin
        define "tempVersion4" replace tempVersion3 "(.*(FL18).*)|^(?!FL18).*" "$2" flags "g"
        if ( tempVersion4 ) == "FL18"
            define "versionLnbts" "xL17_1610_006"
    end

if versionLnbts == "none" abort_file
if version == "none" abort_file
#######################################################################################

#######################################################################################
#######################################################################################
#Add AMGR MO

define "amgrDN" mnlRoot JOIN "/AMGR-1"
add_object amgrDN

#add_param amgrDN "btsAccountLockoutDuration" "15"

for_objects "MRBTS/LNBTS/FTM/AMGR"
	begin
		if ( param_exist $current_dist_name "checkCnumPasswdExpiry" ) add_param amgrDN "checkCnumPasswdExpiry" get_param $current_dist_name "checkCnumPasswdExpiry"
			else add_param amgrDN "checkCnumPasswdExpiry" "false"
	end


#######################################################################################

#######################################################################################
#######################################################################################
#Add LUAC MO
		
define "luacDN" amgrDN JOIN "/LUAC-1"

for_objects "MRBTS/LNBTS/FTM/AMGR/LUAC"
	begin
		copy_object $current_dist_name luacDN

		if ( param_exist luacDN "actRestrictLoginToCnum" ) del_param luacDN "actRestrictLoginToCnum"
		if ( param_exist luacDN "appAdmActivated" ) del_param luacDN "appAdmActivated"
		if ( param_exist luacDN "readOnlyActivated" ) del_param luacDN "readOnlyActivated"
		if ( param_exist luacDN "secAdmActivated" ) del_param luacDN "secAdmActivated"
	end

if ( ( objects_count "MRBTS/LNBTS/FTM/AMGR/LUAC" ) == 0 )  
	begin
		add_object luacDN
		add_param luacDN "btsAccountLockoutDuration" "15"
		add_param luacDN "btsFailedLoginCountingPeriod" "5"	
		add_param luacDN "btsMaxFailedLoginAttempts" "5"
		add_param luacDN "btsSessionLoginDelay" "1"
		add_param luacDN "localPasswdExpiryPeriod" "0"
		add_param luacDN "localPasswdWarningPeriod" "0"
	end
#######################################################################################
#######################################################################################
#Add CERTH MO

define "certhDN" mnlentRoot JOIN "/CERTH-1" 
add_object certhDN

for_objects "MRBTS/LNBTS/FTM/IPNO"
	begin
		define "tempIp" get_param $current_dist_name "srcIpForCmpCrl"
		for_objects "MRBTS/TNLSVC/TNL/IPNO/IPIF/IPADDRESSV4"
			begin
				if tempIp == get_param $current_dist_name "localIpAddr" add_param certhDN "cmpCrlSrcIpAddressDN" $current_dist_name
			end
		
		if not param_exist certhDN "cmpCrlSrcIpAddressDN" add_param certhDN "cmpCrlSrcIpAddressDN" ""
	end
	


#######################################################################################
#######################################################################################
#Add CMP MO	

define "cmpDN" certhDN JOIN "/CMP-1"
add_object cmpDN

add_param cmpDN "caCertificateUpdateTime" "90"
add_param cmpDN "neCertificateUpdateTime" "30"

for_objects "MRBTS/LNBTS/FTM/CERTH"
	begin
		if ( param_exist $current_dist_name "caSubjectName" ) add_param cmpDN "caSubjectName" get_param $current_dist_name "caSubjectName"
		if ( param_exist $current_dist_name "cmpServerIpAddress" ) add_param cmpDN "serverHost" get_param $current_dist_name "cmpServerIpAddress"
		if ( param_exist $current_dist_name "cmpServerPort" ) add_param cmpDN "serverPort" get_param $current_dist_name "cmpServerPort"
		if ( param_exist $current_dist_name "caCertificateUpdateTime" ) add_param cmpDN "caCertificateUpdateTime" get_param $current_dist_name "caCertificateUpdateTime"
		if ( param_exist $current_dist_name "btsCertificateUpdateTime" ) add_param cmpDN "neCertificateUpdateTime" get_param $current_dist_name "btsCertificateUpdateTime"
		if ( param_exist $current_dist_name "cmpDirectory" ) add_param cmpDN "serverPath" get_param $current_dist_name "cmpDirectory"
		
		#FL17A
		if ( param_exist $current_dist_name "cmpPollingTimeout" ) add_param cmpDN "cmpPollingTimeout" get_param $current_dist_name "cmpPollingTimeout"
		#if ( param_exist $current_dist_name "cmpState" ) add_param cmpDN "state" get_param $current_dist_name "cmpState"
		if ( param_exist $current_dist_name "secCaSubjectName" ) add_param cmpDN "secondaryCaSubjectName" get_param $current_dist_name "secCaSubjectName"
		if ( param_exist $current_dist_name "secCmpDirectory" ) add_param cmpDN "secondaryServerPath" get_param $current_dist_name "secCmpDirectory"
		if ( param_exist $current_dist_name "secCmpServerIpAddress" ) add_param cmpDN "secondaryServerHost" get_param $current_dist_name "secCmpServerIpAddress"
		if ( param_exist $current_dist_name "secCmpServerPort" ) add_param cmpDN "secondaryServerPort" get_param $current_dist_name "secCmpServerPort"
	end

#######################################################################################
#######################################################################################
#Add CRLH MO

define "crlhDN" certhDN JOIN "/CRLH-1"
add_object crlhDN

add_param crlhDN "distributionPointSource" "Certificate_extension"
add_param crlhDN "updatePeriod" "24"

for_objects "MRBTS/LNBTS/FTM/CERTH"
	begin
		if ( param_exist $current_dist_name "CRLDPSource" ) add_param crlhDN "distributionPointSource" get_param $current_dist_name "CRLDPSource"
		if ( param_exist $current_dist_name "crlUpdatePeriod" ) add_param crlhDN "updatePeriod" get_param $current_dist_name "crlUpdatePeriod"
		if ( param_exist $current_dist_name "CRLUsageEnabled" ) 
			add_param crlhDN "usageEnabled" get_param $current_dist_name "CRLUsageEnabled"
 		else
 			add_param crlhDN "usageEnabled" "Enabled"
	end


#######################################################################################
#######################################################################################
#Add CRLDPCONFIG MO	

for_objects "MRBTS/LNBTS/FTM/CERTH"
	for_list $current_dist_name "CRLDistributionPoint"
		begin
			# create new MOI
			define "id" $current_index + 1
			define "crldpconfigDn" crlhDN JOIN "/CRLDPCONFIG-" JOIN id
			add_object crldpconfigDn
			# add (mandatory/optional) parameters
			if param_exist $current_dist_name "CRLDistributionPoint." JOIN $current_index JOIN ".CRLDPPrimary" add_param crldpconfigDn "primaryCRLDP" get_param $current_dist_name "CRLDistributionPoint." JOIN $current_index JOIN ".CRLDPPrimary"
			if param_exist $current_dist_name "CRLDistributionPoint." JOIN $current_index JOIN ".CRLDPSecondary" add_param crldpconfigDn "secondaryCRLDP" get_param $current_dist_name "CRLDistributionPoint." JOIN $current_index JOIN ".CRLDPSecondary"
		end

#######################################################################################
#######################################################################################
#Add DNS MO
for_objects "FTM/IPNO/IDNS"
	begin
        # from: MNL18_1711_003 serverIpAddressPrimary is mandatory for MNL/MNLENT/DNS
        # if serverIpAddressPrimary is not defined in input SCF then there is no need to add DNS at all

        if ( param_exist $current_dist_name "serverIpAddress" ) && ( ( get_param $current_dist_name "serverIpAddress" )  != "0.0.0.0" )
            begin
                define "dnsDn" mnlentRoot JOIN "/DNS-" JOIN $current_IDNS

                add_object dnsDn
				add_param dnsDn "serverIpAddressPrimary" get_param $current_dist_name "serverIpAddress"

				if ( param_exist $current_dist_name "serverIpAddress2" )
                    begin
                        if ( get_param $current_dist_name "serverIpAddress2" ) != ( get_param $current_dist_name "serverIpAddress" )
                            begin
                                add_param dnsDn "serverIpAddressSecondary" get_param $current_dist_name "serverIpAddress2"
                            end
                    end
            end
	end
	
#######################################################################################
#######################################################################################
#Add NTP MO

for_objects "MNL/MNLENT/SYNC/CLOCK"
	begin
		define "ntpDN" $current_dist_name JOIN "/NTP-1"
		add_object ntpDN
		set_operation ntpDN "create"
	
	
	for_objects "MRBTS/LNBTS/FTM/IPNO/INTP"
		begin
			if ( param_exist $current_dist_name "ntpAlarmThreshold" ) add_param ntpDN "ntpAlarmingThreshold" get_param $current_dist_name "ntpAlarmThreshold"
			if ( param_exist $current_dist_name "ntpServers" ) copy_list $current_dist_name "ntpServers" ntpDN "ntpServerIpAddrList"
		end

	end

#######################################################################################
#######################################################################################
#Add TOP MO

define "clkToPIsInClockProtocol" "false"
for_objects "MRBTS/LNBTS/FTM/SYNC/STPG"
	begin
		for_list $current_dist_name "synchroSourceList"
			begin
				if ( param_exist $current_dist_name "synchroSourceList." JOIN $current_index JOIN ".clockProtocol" )
					if ( "clkToP" == ( get_param $current_dist_name "synchroSourceList." JOIN $current_index JOIN ".clockProtocol" ) )
						define "clkToPIsInClockProtocol" "true"
			end
	end

if not ( objects_count "MRBTS/LNBTS/FTM/TOPB" ) == 0
	if ( clkToPIsInClockProtocol == "true" )
		begin
			for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK"
				begin
					define "topDN" $current_dist_name JOIN "/TOP-1"
					add_object topDN
					set_operation topDN "create"
					
					for_objects "MRBTS/LNBTS/FTM/IPNO"
						begin
							define "ipnoDN" $current_dist_name
							if ( param_exist ipnoDN "sPlaneIpAddress" )
								begin
									for_objects "MRBTS/TNLSVC/TNL/IPNO/IPIF/IPADDRESSV4"
										begin
											if ( get_param ipnoDN "sPlaneIpAddress" ) == get_param $current_dist_name "localIpAddr" add_param topDN "sPlaneIpAddressDN" $current_dist_name
										end
								end
						end

	#Add TOPF MO
				if not ( objects_count "MRBTS/LNBTS/FTM/TOPB/TOPF" ) == 0
					begin
						for_objects "MRBTS/LNBTS/FTM/TOPB/TOPF" define "oldtopfDN" $current_dist_name
						
							define "actTopFreqSynchValue" "false"
							if ( param_exist oldtopfDN "actTopFreqSynch" ) define "actTopFreqSynchValue" get_param oldtopfDN "actTopFreqSynch"
							if ( actTopFreqSynchValue == "true" )
								begin
									define "topfDN" topDN JOIN "/TOPF-1"
									add_object topfDN 
									set_operation topfDN "create"
						 
                                    if ( param_exist oldtopfDN "acceptedClockQuality" )
                                        copy_list oldtopfDN "acceptedClockQuality" topfDN "acceptedClockClass"

									define "announceRequestMode" ""
									if ( param_exist oldtopfDN "announceRequestMode" )
										begin
											define "announceRequestMode" get_param oldtopfDN "announceRequestMode"
											add_param topfDN "announceRequestMode" announceRequestMode
										end

									define "ieeeTelecomProfile" ""
									if ( param_exist oldtopfDN "ieeeTelecomProfile" )
										begin
											define "ieeeTelecomProfile" get_param oldtopfDN "ieeeTelecomProfile"
											add_param topfDN "ieeeTelecomProfile" ieeeTelecomProfile
										end
						
									if ( param_exist oldtopfDN "topMasters" )
									begin
									# PR253987: [SBTS17][RP001738][LN] MNLENT/SYNC/CLOCK/TOP MO is incomplete after conversion from FL16A
										add_list topfDN "topMasterList"
											for_list oldtopfDN "topMasters"
												begin
													add_complex_param topfDN "topMasterList." JOIN $current_index
													if ( param_exist oldtopfDN "topMasters." JOIN $current_index JOIN ".masterIpAddr" ) add_param topfDN "topMasterList." JOIN $current_index JOIN ".masterIpAddr" get_param oldtopfDN "topMasters." JOIN $current_index JOIN ".masterIpAddr"
													if ( param_exist oldtopfDN "topMasters." JOIN $current_index JOIN ".priority_1" )
														add_param topfDN "topMasterList." JOIN $current_index JOIN ".priority_1" get_param oldtopfDN "topMasters." JOIN $current_index JOIN ".priority_1"
													else
														begin
															if ( ( ieeeTelecomProfile == "IEEE1588" ) && ( announceRequestMode == "ANNOUNCE_ALL" ) )
																add_param topfDN "topMasterList." JOIN $current_index JOIN ".priority_1" 0
															else
																add_param topfDN "topMasterList." JOIN $current_index JOIN ".priority_1" 128
														end
													if ( param_exist oldtopfDN "topMasters." JOIN $current_index JOIN ".priority_2" )
														add_param topfDN "topMasterList." JOIN $current_index JOIN ".priority_2" get_param oldtopfDN "topMasters." JOIN $current_index JOIN ".priority_2"
													else
														begin
															if ( announceRequestMode == "ANNOUNCE_ALL" )
																add_param topfDN "topMasterList." JOIN $current_index JOIN ".priority_2" 0
															else
																add_param topfDN "topMasterList." JOIN $current_index JOIN ".priority_2" 128
														end
												end
									end

									if ( param_exist oldtopfDN "topDomainNumber" ) add_param topDN "topDomainNumber" get_param oldtopfDN "topDomainNumber"
						
									if ( param_exist oldtopfDN "logMeanSyncValue" )
										begin
											define "lmsValue" get_param oldtopfDN "logMeanSyncValue"
											if ( -3 == lmsValue ) add_param topfDN "syncMessageRate" "RATE_8"
											if ( -4 == lmsValue ) add_param topfDN "syncMessageRate" "RATE_16"
											if ( -5 == lmsValue ) add_param topfDN "syncMessageRate" "RATE_32"
										end

								end
					end
				end
				
				  if ( ( objects_count "MRBTS/LNBTS/FTM/TOPB/TOPP" ) > 0  && ( objects_count "MRBTS/MNL/MNLENT/SYNC/CLOCK" ) > 0 )
					begin
						for_objects "MRBTS/LNBTS/FTM/TOPB/TOPP"
                            define "oldtoppDN" $current_dist_name

						define "actTopPhaseSynchValue" "false"
						if ( param_exist oldtoppDN "actTopPhaseSynch" )
                            define "actTopPhaseSynchValue" get_param oldtoppDN "actTopPhaseSynch"

						if ( actTopPhaseSynchValue == "true" )
							begin
								define "toppDN" topDN JOIN "/TOPP-1"
								add_object toppDN
								set_operation toppDN "create"
						
                                if ( param_exist oldtoppDN "acceptedClockQuality" )
                                    copy_list oldtoppDN "acceptedClockQuality" toppDN "acceptedClockClass"

								if ( param_exist oldtoppDN "topMasters" )
									begin
										add_list toppDN "topMasterList"

	                                    for_list oldtoppDN "topMasters"
	                                        begin
	                                            add_complex_param toppDN "topMasterList." JOIN $current_index

	                                            if ( param_exist oldtoppDN "topMasters." JOIN $current_index JOIN ".masterIpAddr" )
	                                                begin
	                                                    define "masterIpAddr" get_param oldtoppDN "topMasters." JOIN $current_index JOIN ".masterIpAddr"
	                                                    add_param toppDN "topMasterList." JOIN $current_index JOIN ".masterIpAddr" masterIpAddr
	                                                end

	                                            if ( param_exist oldtoppDN "topMasters." JOIN $current_index JOIN ".phaseErrorComp" )
	                                                begin
	                                                    define "phaseErrorComp" get_param oldtoppDN "topMasters." JOIN $current_index JOIN ".phaseErrorComp"
	                                                    add_param toppDN "topMasterList." JOIN $current_index JOIN ".phaseErrorComp" phaseErrorComp
	                                                end
	                                        end
									end

	                                else if ( param_exist oldtoppDN "topMasterList" )
	                                    begin
	                                        add_list toppDN "topMasterList"

	                                        for_list oldtoppDN "topMasterList"
	                                            begin
	                                                add_complex_param toppDN "topMasterList." JOIN $current_index

	                                                if ( param_exist oldtoppDN "topMasterList." JOIN $current_index JOIN ".masterIpAddr" )
	                                                    begin
	                                                        define "masterIpAddr" get_param oldtoppDN "topMasterList." JOIN $current_index JOIN ".masterIpAddr"
	                                                        add_param toppDN "topMasterList." JOIN $current_index JOIN ".masterIpAddr" masterIpAddr
	                                                    end

	                                                if ( param_exist oldtoppDN "topMasterList." JOIN $current_index JOIN ".phaseErrorComp" )
	                                                    begin
	                                                        define "phaseErrorComp" get_param oldtoppDN "topMasterList." JOIN $current_index JOIN ".phaseErrorComp"
	                                                        add_param toppDN "topMasterList." JOIN $current_index JOIN ".phaseErrorComp" phaseErrorComp
	                                                    end
	                                            end
	                                    end

	# PR253987: [SBTS17][RP001738][LN] MNLENT/SYNC/CLOCK/TOP MO is incomplete after conversion from FL16A
                                if ( param_exist oldtoppDN "topDomainNumber" )
                                    add_param topDN "topDomainNumber" get_param oldtoppDN "topDomainNumber"
						
								if ( param_exist oldtoppDN "logMeanSyncValue" )
									begin
										define "lmsValue" get_param oldtoppDN "logMeanSyncValue"
										if ( -6 == lmsValue ) add_param toppDN "syncMessageRate" "RATE_64"
										if ( -7 == lmsValue ) add_param toppDN "syncMessageRate" "RATE_128"
									end
                                
                                if ( param_exist oldtoppDN "topComMode" )
                                    add_param toppDN "topComMode" get_param oldtoppDN "topComMode"

                                if ( param_exist oldtoppDN "topStandardProfile" )
                                    begin
                                        define "topStandardProfile" get_param oldtoppDN "topStandardProfile"

                                        if ( topStandardProfile ) == "Telecom2008" || ( topStandardProfile ) == "G.8275.2"
                                            begin
                                                add_param toppDN "topComMode" "IP Unicast"
                                            end

                                        else if ( topStandardProfile ) == "G.8275.1" || ( topStandardProfile ) == "CCSA YD/T 2375"
                                            begin
                                                add_param toppDN "topComMode" "Ethernet Multicast"
                                            end
                                    end

                                if ( param_exist toppDN "topComMode" )
                                    begin
                                        define "topComMode" get_param toppDN "topComMode"

                                        if ( topComMode ) == "Ethernet Multicast"
                                            begin
                                                if ( param_exist oldtoppDN "topEthMulticastAddress" )
                                                    begin
                                                        define "topEthMulticastAddress" get_param oldtoppDN "topEthMulticastAddress"
                                                        add_param toppDN "topEthMulticastAddress" topEthMulticastAddress
                                                    end
                                            end
                                    end
							end
					end
		end
	
#######################################################################################
#######################################################################################
#Add TAC MO

if not ( objects_count "MRBTS/LNBTS/FTM/TAC" ) == 0
	begin
		define "tacDN" mnlentRoot JOIN "/TAC-1"
		add_object tacDN
		set_operation tacDN "create"
	end

#######################################################################################
#######################################################################################
#Add LTAC MOs	

for_objects "MRBTS/LNBTS/FTM/TAC/LTAC"
	begin
		define "ltacDN" tacDN JOIN "/LTAC-" JOIN $current_LTAC
		add_object ltacDN
		set_operation ltacDN "create"
		
		if ( param_exist $current_dist_name "tacLimitGbrEmergency" ) add_param ltacDN "tacLimitGbrEmergency" get_param $current_dist_name "tacLimitGbrEmergency"
		if ( param_exist $current_dist_name "tacLimitGbrHandover" ) add_param ltacDN "tacLimitGbrHandover" get_param $current_dist_name "tacLimitGbrHandover"
		if ( param_exist $current_dist_name "tacLimitGbrNormal" )
			begin
				add_param ltacDN "tacLimitGbrNormal" get_param $current_dist_name "tacLimitGbrNormal"
				add_param ltacDN "tacOverbookingLimit" 0
			end
		if ( param_exist $current_dist_name "tacOverbookingLimit" ) add_param ltacDN "tacOverbookingLimit" get_param $current_dist_name "tacOverbookingLimit"
		if ( param_exist $current_dist_name "transportNwId" ) add_param ltacDN "transportNwId" get_param $current_dist_name "transportNwId"
	
	end

#######################################################################################
#######################################################################################
#create PMMNL object MNL/MNLENT/PMMNL

for_objects "MRBTS/LNBTS/FTM/PMTNL"
	begin
		if ( ( ( param_exist $current_dist_name "lte_TAC_Statistics_Interval" ) || ( param_exist $current_dist_name "lte_TOP_FreqSync_Stats_Interval" ) ) || ( param_exist $current_dist_name "lte_TOP_PhaseSync_Stats_Interval" ) )
			begin
				define "pmmnlDN" mnlRoot JOIN "/MNLENT-1/PMMNL-1"
				add_object pmmnlDN
				set_operation pmmnlDN "create"
				
				if ( param_exist $current_dist_name "lte_TAC_Statistics_Interval" ) add_param pmmnlDN "s1X2TacStatisticsInterval" get_param $current_dist_name "lte_TAC_Statistics_Interval"
				if ( param_exist $current_dist_name "lte_TOP_FreqSync_Stats_Interval" ) add_param pmmnlDN "topFreqSyncStatisticsInterval" get_param $current_dist_name "lte_TOP_FreqSync_Stats_Interval"
				if ( param_exist $current_dist_name "lte_TOP_PhaseSync_Stats_Interval" ) add_param pmmnlDN "topPhaseSyncStatisticsInterval" get_param $current_dist_name "lte_TOP_PhaseSync_Stats_Interval"
			end

	end
#######################################################################################
#######################################################################################
#FL17A

for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK"
	begin
        define "syncInputPrio" 0
        define "syncInputListIndex" 0
		define "CLOCK_MO" $current_dist_name
		copy_list CLOCK_MO "syncInputList" CLOCK_MO "syncInputListTmp"
		del_param CLOCK_MO "syncInputList"
		for_list CLOCK_MO "syncInputListTmp"
			begin
				define "syncInputListTmpIndex" $current_index
				if ( "TRS" != get_param CLOCK_MO "syncInputListTmp." JOIN syncInputListTmpIndex JOIN ".syncInputType" )
					begin
						define "syncInputPrio" syncInputPrio + 1
						if not param_exist CLOCK_MO "syncInputList"
                            begin
                                add_list CLOCK_MO "syncInputList"
                            end
						add_complex_param CLOCK_MO "syncInputList." JOIN syncInputListIndex
						add_param CLOCK_MO "syncInputList." JOIN syncInputListIndex JOIN ".syncInputType" get_param CLOCK_MO "syncInputListTmp." JOIN syncInputListTmpIndex JOIN ".syncInputType"
						add_param CLOCK_MO "syncInputList." JOIN syncInputListIndex JOIN ".syncInputPrio" syncInputPrio
						define "syncInputListIndex" syncInputListIndex + 1
					end
			end

		define "CLOCK_MO" $current_dist_name
		for_list CLOCK_MO "syncInputListTmp"
			begin
				define "syncInputListTmpIndex" $current_index
				if ( "TRS" == get_param CLOCK_MO "syncInputListTmp." JOIN syncInputListTmpIndex JOIN ".syncInputType" )
					begin
						for_objects "MRBTS/LNBTS/FTM/SYNC/STPG"
							begin
								define "STPG_MO" $current_dist_name
								define "synceIndex" 0
                                define "pdhIndex" 0
								for_list STPG_MO "synchroSourceList"
									begin
										define "synchroSourceListIndex" $current_index
										define "value" get_param STPG_MO "synchroSourceList." JOIN synchroSourceListIndex JOIN ".clockProtocol"
										define "newValue" ""
										if ( value == "clkToP" ) define "newValue" "TOP"
										if ( value == "clkPDH" )
                                            begin
                                                define "interfaceNumber" get_param STPG_MO "synchroSourceList." JOIN synchroSourceListIndex JOIN ".interfaceNumber"
                                                define "pdhIndex" pdhIndex + 1
                                                define "newValue" "PDH-" JOIN pdhIndex
                                                define "pdhDn" CLOCK_MO JOIN "/PDH-" JOIN pdhIndex
                                                add_object pdhDn
                                                set_operation pdhDn "create"
												set_version pdhDn version
												set_adaptation pdhDn "com.nokia.srbts.mnl"

                                                for_objects "TNLSVC/TNL/PPTT"
                                                    begin
                                                        if ( $current_PPTT == interfaceNumber )
                                                            begin
                                                                add_param pdhDn "ppttDN" $current_dist_name
                                                            end
                                                    end
                                            end
										if ( value == "clkSyncE" )
											begin
												define "synceIndex" synceIndex + 1
												define "newValue" "SYNCE-" JOIN synceIndex
												define "synceDn" CLOCK_MO JOIN "/SYNCE-" JOIN synceIndex
												add_object synceDn
												set_operation synceDn "create"
												set_version synceDn version
												set_adaptation synceDn "com.nokia.srbts.mnl"
												for_objects "TNLSVC/TNL/ETHSVC/ETHLK"
													if ( get_param STPG_MO "synchroSourceList." JOIN synchroSourceListIndex JOIN ".unitNumber" ) == "0"  || ( get_param STPG_MO "synchroSourceList." JOIN synchroSourceListIndex JOIN ".unitNumber" ) == "1"
														begin
															if ( replace get_param $current_dist_name "modDN" "TRSMOD" "" ) == ( get_param $current_dist_name "modDN" ) && ( get_param $current_dist_name "connectorLabel" ) == "EIF" JOIN get_param STPG_MO "synchroSourceList." JOIN synchroSourceListIndex JOIN ".interfaceNumber"
																add_param synceDn "ethlkDN" $current_dist_name
														end
													else
														begin
															if ( replace get_param $current_dist_name "modDN" "TRSMOD" "" ) != ( get_param $current_dist_name "modDN" ) && ( get_param $current_dist_name "connectorLabel" ) == "EIF" JOIN get_param STPG_MO "synchroSourceList." JOIN synchroSourceListIndex JOIN ".interfaceNumber"
																add_param synceDn "ethlkDN" $current_dist_name
														end

												if param_exist STPG_MO "synchroSourceList." JOIN synchroSourceListIndex JOIN ".ssmAcceptanceLevel"
													begin
														define "ssmAcceptanceLevel" get_param STPG_MO "synchroSourceList." JOIN synchroSourceListIndex JOIN ".ssmAcceptanceLevel"
														if ssmAcceptanceLevel == "ssmSSU"
															define "ssmAcceptanceLevel" "ssmSSUorST2"
														add_param synceDn "ssmAcceptanceLevel" ssmAcceptanceLevel
													end

                                                if ( param_exist STPG_MO "ssmType" )
                                                    begin
                                                        define "ssmType" get_param STPG_MO "ssmType"

                                                        if ( ssmType ) == "SSM_ITU"
                                                            add_param synceDn "ssmAcceptanceLevel" "ssmSSUorST2"

                                                        if ( ssmType ) == "SSM_ANSI"
                                                            add_param synceDn "ssmAcceptanceLevel" "ssmPRCorPRS"
                                                    end

												if param_exist STPG_MO "synchroSourceList." JOIN synchroSourceListIndex JOIN ".ssmEnabled"
													add_param synceDn "ssmEnabled" get_param STPG_MO "synchroSourceList." JOIN synchroSourceListIndex JOIN ".ssmEnabled"
												if param_exist STPG_MO "synchroSourceList." JOIN synchroSourceListIndex JOIN ".ssmTimeout"
													add_param synceDn "ssmTimeout" get_param STPG_MO "synchroSourceList." JOIN synchroSourceListIndex JOIN ".ssmTimeout"
											end
										define "btsSyncMode" ""
										for_objects "MRBTS/MNL/MNLENT/SYNC"
											define "btsSyncMode" get_param $current_dist_name "btsSyncMode"
										if ( newValue == "TOP" )
											begin
												if ( btsSyncMode == "FreqSync"  && syncInputListIndex < 5 )
													begin
														if not param_exist CLOCK_MO "syncInputList"
                                                            begin
                                                                add_list CLOCK_MO "syncInputList"
                                                            end
                                                        add_complex_param CLOCK_MO "syncInputList." JOIN syncInputListIndex
														add_param CLOCK_MO "syncInputList." JOIN syncInputListIndex JOIN ".syncInputType" "TOPF"
														add_param CLOCK_MO "syncInputList." JOIN syncInputListIndex JOIN ".syncInputPrio" ( get_param STPG_MO "synchroSourceList." JOIN synchroSourceListIndex JOIN ".priority" ) + syncInputPrio
														define "syncInputListIndex" syncInputListIndex + 1
													end
												if ( btsSyncMode == "PhaseSync"  && syncInputListIndex < 5 )
													begin
														if not param_exist CLOCK_MO "syncInputList" add_list CLOCK_MO "syncInputList"
														add_complex_param CLOCK_MO "syncInputList." JOIN syncInputListIndex
														add_param CLOCK_MO "syncInputList." JOIN syncInputListIndex JOIN ".syncInputType" "TOPP"
														add_param CLOCK_MO "syncInputList." JOIN syncInputListIndex JOIN ".syncInputPrio" ( get_param STPG_MO "synchroSourceList." JOIN synchroSourceListIndex JOIN ".priority" ) + syncInputPrio
														define "syncInputListIndex" syncInputListIndex + 1
													end
											end
										else if syncInputListIndex < 5
											begin
												if not param_exist CLOCK_MO "syncInputList" add_list CLOCK_MO "syncInputList"
												add_complex_param CLOCK_MO "syncInputList." JOIN syncInputListIndex
												add_param CLOCK_MO "syncInputList." JOIN syncInputListIndex JOIN ".syncInputType" newValue
												add_param CLOCK_MO "syncInputList." JOIN syncInputListIndex JOIN ".syncInputPrio" ( get_param STPG_MO "synchroSourceList." JOIN synchroSourceListIndex JOIN ".priority" ) + syncInputPrio
												define "syncInputListIndex" syncInputListIndex + 1
											end
									end
							end
					end
			end
		del_param CLOCK_MO "syncInputListTmp"
	end

for_objects mnlentRoot JOIN "/FEATCADM"
	begin
		define "FEATCADM_MO" $current_dist_name
		if not ( param_exist FEATCADM_MO "actHybridSynch" )
			begin
				for_objects "MRBTS/LNBTS/FTM/SYNC"
					begin
						if ( param_exist $current_dist_name "actHybridSynch" ) add_param FEATCADM_MO "actHybridSynch" get_param $current_dist_name "actHybridSynch"
					end
			end
	end

for_objects mnlentRoot JOIN "/SYNC"
	begin
		define "SYNC_MO" $current_dist_name
		if not ( param_exist SYNC_MO "actHybridSynch" )
			begin
				for_objects "MRBTS/LNBTS/FTM/SYNC"
					begin
						if ( param_exist $current_dist_name "actHybridSynch" ) add_param SYNC_MO "actHybridSynch" get_param $current_dist_name "actHybridSynch"
					end
			end
	end

# TODO: move to a new file (EQM) after NIDD integration to avoid integration issues. FL17A-related.
for_objects "MRBTS/EQM/APEQM/CABINET/SMOD"
	begin
		define "smodDN" $current_dist_name
        define "cabinetDn" "MRBTS-" JOIN $current_MRBTS JOIN "/EQM-" JOIN $current_EQM JOIN "/APEQM-" JOIN $current_APEQM JOIN "/CABINET-" JOIN $current_CABINET

		for_objects "MRBTS/LNBTS/FTM/UNIT"
			begin
				define "oldunitDN" $current_dist_name

                if ( ( objects_count "TRMOD" ) == 0 )
                    begin
                        if ( param_exist oldunitDN "unitTypeExpected" ) && ( "472311A" == get_param oldunitDN "unitTypeExpected" )
                            begin
                                # finally in EQM18_1711_005 TRMOD is just under CABINET
                                define "trmodDN" cabinetDn JOIN "/TRMOD-1"

                                add_object trmodDN
                                add_param trmodDN "prodCodePlanned" get_param oldunitDN "unitTypeExpected"
                                set_adaptation trmodDN "com.nokia.srbts.eqm"
                            end
                    end

				if ( param_exist oldunitDN "enableRP301Interface" )
					begin
						if not ( param_exist smodDN "portMode" )
							begin
								if ( get_param oldunitDN "enableRP301Interface" ) == "true" add_param smodDN "portMode" "RF"
									else add_param smodDN "portMode" "Ethernet"
							end
					end	
			end

	end


#######################################################################################
#######################################################################################
for_branch mnlRoot set_version $current_dist_name version
