DEFINITION CPT_780042403 1501
DEFINITION CSCF_CDR_780042403 0x00
DEFINITION s_CSCF_RECORD_780042403 0x00
DEFINITION INCREMENT_780042403 1
REGISTRE ENTIER erreur_780042403
REGISTRE ENTIER recordType_780042403
REGISTRE ENTIER roleOfNode_780042403
REGISTRE ENTIER Y_780042403
REGISTRE ENTIER X_780042403
REGISTRE ENTIER Z_780042403
REGISTRE ENTIER date_780042403
################################################################################
#
#                               Treatement Pcode Tims_CSCF.src of IMS CDR
#
# history :
# 		Creation le 07/07/09
#
# PKH 07/07/09 G3R2 offre MIPC lot2
# 14/01/11 - BEA - G3R1 lot4 Verification/Correction des variables (constantes, entiers, pointeurs)
################################################################################



erreur_780042403 = 0
recordType_780042403 = -1
roleOfNode_780042403 = -1
Y_780042403 = -1
X_780042403 = -1
Z_780042403 = -1
date_780042403 = -1 



trace(" ======================================")
trace("| [Tims Trait] Treatement module       |")
trace(" ======================================")
#-----------------------------------------
# IF CDR Source != CSCF and != AS
#  Then CDR is erroneous
#-----------------------------------------

#Test controle unitaire sur les champs

#champ source
SI( ! i_valid_field_n(g_iartin, $Tims_CSCF::source) )

#si champ source absent creer le champ avec la valeur 0
# le test source == 0 n'est plus necessaire

ALORS
     erreur_780042403 = i_ajout_tlv(g_iartin,"T3_source", "")
     erreur_780042403 = i_resize_tlv(g_iartin,"T3_source","source", 1)
     erreur_780042403 = i_set_art_field(g_iartin,$Tims_CSCF::source,CSCF_CDR_780042403)  
FINSI

#champ recordtype
recordType_780042403 = i_get_art_field(g_iartin,$Tims_CSCF::recordType)
SI(recordType_780042403 != s_CSCF_RECORD_780042403)
ALORS
      trace("[Tims Trait] Erroneous CSCF CDR, recordType must be s-CSCF")
      SAUT ERRONEOUS_CDR
FINSI

#champ roleOfNode
roleOfNode_780042403 = i_get_art_field(g_iartin,$Tims_CSCF::roleOfNode)
SI (roleOfNode_780042403 !=0 && roleOfNode_780042403 !=1)
ALORS
      trace ("[Tims Trait] Erroneous CSCF CDR, recordType ")
	 SAUT ERRONEOUS_CDR
FINSI 

#controle presence du champ callStartTime

SI(!i_valid_field_n(g_iartin, $Tims_CSCF::callStartTime))
ALORS
	 trace ("[Tims Trait] Erroneous CSCF CDR, absence du champ callStartTime ")
	 SAUT ERRONEOUS_CDR
FINSI
	

	###############################
	# increment du compteur
	###############################

Y_780042403 = g_ieec
SI (roleOfNode_780042403 == 0)
ALORS
		X_780042403 = 0xB1
SINON
	SI (roleOfNode_780042403 == 1)
	ALORS
		X_780042403 = 0xB2
	FINSI
FINSI	

Z_780042403=0
date_780042403 = i_DHgetLocalTime(4, 7, i_date_audit())
erreur_780042403 = i_incr_cpt(CPT_780042403,X_780042403,Y_780042403,Z_780042403,date_780042403,INCREMENT_780042403)


trace("[Tims Trait] CDR stored OK")
erreur_780042403 = i_stocke_art(g_iartin, 0, PT_OK, 0)
RETOUR TRAIT_OK


POINT ERRONEOUS_CDR
erreur_780042403 = i_stocke_art(g_iartin, 0, PT_ERRONE, 0)
trace("[Tims Trait] ERRONEOUS IMS CDR , end of treatement")
RETOUR -1
#---------------------- Fin Tims_CSCF.src ----------------------------------------------
