def generateGroupedIeClass(grpIeDetails,grpIe): templateData['fileName'] = grpIe[0].lower()+grpIe[1:] + 'Ie' templateData['className'] = grpIe + 'Ie' templateData['classNameUC'] = templateData['fileName'].upper() fileName=templateData['fileName'] for inst in grpIeDetails['instList']: instanceInfo = {} instDetails = grpIeDetails[inst] GenerateGrpIeClass.generateGroupedIeInstanceClass(instDetails, inst) instanceInfo['className'] = inst instanceInfo['fileName'] = inst[0].lower()+inst[1:] instanceInfo['msgType'] = instDetails['msgName'] + 'MsgType' instanceInfo['instance'] = instDetails['instance'] if instanceInfo not in templateData['instList']: templateData['instList'].append(instanceInfo) templateData[fileName]=[inst for inst in templateData['instList'] if grpIe in inst['className']] outputDir = '../../src/gtpV2Codec/ieClasses' ttFileNameCpp = 'tts/grpietemplate.cpp.tt' ttFileNameH = 'tts/grpietemplate.h.tt' xlUtils.templateProcess(templateData,ttFileNameCpp,ttFileNameH,outputDir,outputDir) objectfile ='ieClasses/' + templateData['fileName'] + '.o' sourcefile = 'ieClasses/' + templateData['fileName'] + '.cpp' xlUtils.addToMakeSo('gtpV2Stack.so',objectfile,sourcefile)
def prepareIeMakeFile(self): outputDir = 'ieClasses/' xlUtils.addToMakeSo('gtpV2Stack.so', outputDir + 'dataTypeCodecUtils.o', outputDir + 'dataTypeCodecUtils.cpp') xlUtils.addToMakeSo('gtpV2Stack.so', outputDir + 'manual/gtpV2Ie.o', outputDir + 'manual/gtpV2Ie.cpp')
def generateIeFactory(self, currentType): ieinfo = {} ieinfo['className'] = currentType + 'Ie' ieinfo['ieFileName'] = currentType[0].lower() + currentType[1:] + 'Ie' if ieinfo not in ieFactoryData['ieList']: ieFactoryData['ieList'].append(ieinfo) outputDir = 'ieClasses/' self.ieFactoryTemplate(ieFactoryData) xlUtils.addToMakeSo('gtpV2Stack.so', outputDir + 'gtpV2IeFactory.o', outputDir + 'gtpV2IeFactory.cpp')
def generateMsgFactory(msgData, currentMessage): msgInfo = {} msgInfo['className'] = currentMessage + 'Msg' msgInfo['msgFileName'] = currentMessage[0].lower( ) + currentMessage[1:] + 'Msg' msgInfo['dataMember'] = currentMessage[0].lower( ) + currentMessage[1:] + 'StackData' if msgInfo not in msgFactoryData['msgList']: msgFactoryData['msgList'].append(msgInfo) outputDirCpp = 'msgClasses/' GenerateMsgClass.msgfactoryStacktemplate(msgFactoryData) xlUtils.addToMakeSo('gtpV2Stack.so', outputDirCpp + 'gtpV2MsgFactory.o', outputDirCpp + 'gtpV2MsgFactory.cpp') xlUtils.addToMakeSo('gtpV2Stack.so', 'gtpV2Stack.o', 'gtpV2Stack.cpp')
def prepareMsgMakeFile(): outputDir = 'msgClasses/manual/' xlUtils.addToMakeSo('gtpV2Stack.so', outputDir + 'gtpV2Message.o', outputDir + 'gtpV2Message.cpp')
def templateIes(msgData, currentMessage): templateData = dict() ieListTemplate = [] ieTypeTemplate = [] ieTypeDetailList = [] ieTypeList = [] templateData['fileName'] = currentMessage[0].lower( ) + currentMessage[1:] + 'Msg' templateData['msgClassName'] = currentMessage[0].upper( ) + currentMessage[1:] + 'Msg' templateData['classNameUC'] = templateData['fileName'].upper() templateData['msgCategory'] = msgData['msgDetails'][currentMessage][ 'msgCategory'] for ieDetail in msgData['ieDetails']: for key, value in ieDetail.items(): for ie in msgData['ieList']: ieInfo = {} ieTypeInfo = {} if value['ieVarName'] == ie: ieInfo['ieName'] = value['ieVarName'] ieInfo['ieVarName'] = value['ieVarName'] ieInfo['ieType'] = value['ieTypeName'] ieInfo['ieFileName'] = value['ieTypeName'][0].lower( ) + value['ieTypeName'][1:] + 'Ie' ieInfo['ieLocalVar'] = value['ieTypeName'][0].lower( ) + value['ieTypeName'][1:] ieInfo['iePresence'] = value['presence'] ieInfo['ieCardinality'] = value['cardinality'] ieInfo['instance'] = value['instance'] ieInfo['grouped'] = value['grouped'] ieInfo['grpIeInstClassName'] = value['ieGroupTypeName'] if ieInfo['grouped'] == 'Yes': ieInfo['grpIeInstClassName'] = value[ 'ieGroupTypeName'][0].upper( ) + value['ieGroupTypeName'][1:] ieInfo['grpIeInstFileName'] = value['ieGroupTypeName'] ieType = ieInfo['ieType'] ieTypeInfo['ieName'] = value['ieVarName'] ieTypeInfo['ieVarName'] = value['ieVarName'] ieTypeInfo['ieType'] = value['ieTypeName'] ieTypeInfo['ieFileName'] = value['ieTypeName'][ 0].lower() + value['ieTypeName'][1:] + 'Ie' ieTypeInfo['ieLocalVar'] = value[ 'ieTypeName'].capitalize() ieTypeInfo['iePresence'] = value['presence'] ieTypeInfo['ieCardinality'] = value['cardinality'] ieTypeInfo['instance'] = value['instance'] ieTypeInfo['grouped'] = value['grouped'] ieTypeInfo['grpIeInstClassName'] = value[ 'ieGroupTypeName'] if ieTypeInfo['grouped'] == 'Yes': ieTypeInfo['grpIeInstClassName'] = value[ 'ieGroupTypeName'][0].upper( ) + value['ieGroupTypeName'][1:] ieTypeInfo['grpIeInstFileName'] = value[ 'ieGroupTypeName'].capitalize() ieListTemplate.append(ieInfo) templateData['ieList'] = ieListTemplate if ieInfo['ieType'] not in ieTypeList: ieTypeList.append(ieInfo['ieType']) templateData['ieTypeList'] = ieTypeList ieTypeTemplate = [] ieTypeTemplate.append(ieTypeInfo) templateData['ieTypeDetails'] = {} templateData['ieTypeDetails'][ieType] = ieTypeTemplate ieTypeDetailList.append(templateData['ieTypeDetails']) templateData['ieTypeDetails'] = ieTypeDetailList outputDir = '../../src/gtpV2Codec/msgClasses' ttFileNameCpp = 'tts/msgtemplate.cpp.tt' ttFileNameH = 'tts/msgtemplate.h.tt' xlUtils.templateProcess(templateData, ttFileNameCpp, ttFileNameH, outputDir, outputDir) objectFile = 'msgClasses/' + templateData['fileName'] + '.o' sourceFile = 'msgClasses/' + templateData['fileName'] + '.cpp' xlUtils.addToMakeSo('gtpV2Stack.so', objectFile, sourceFile)
def prepareGrpIeMakeFile(): outputDirCpp = 'ieClasses/manual/' xlUtils.addToMakeSo("gtpV2Stack.so", outputDirCpp+'gtpV2GroupedIe.o',outputDirCpp+'gtpV2GroupedIe.cpp')
def generateGroupedIeInstanceClass(instDetails, inst): templateInstData = {} ieTypeList = [] ieTypeDetailsList = [] ieInfoList =[] templateInstData['fileName'] = inst[0].lower()+inst[1:] templateInstData['msgClassName'] = inst templateInstData['classNameUC'] = templateInstData['fileName'].upper() templateInstData['msgType'] = instDetails['msgName'] + 'MsgType' for ieEntry in instDetails['ieList']: ieInfo = {} ieTypeInfo = {} ies = instDetails['ieDetails'] for x in ies: ie = x.get(ieEntry) if ie != None and ieEntry == ie.get('ieVarName'): ieInfo['ieName'] = ie['ieVarName'] ieInfo['ieVarName'] = ie['ieVarName'] ieInfo['ieType'] = ie['ieTypeName'] ieInfo['ieFileName'] = ie['ieTypeName'][0].lower()+ie['ieTypeName'][1:] + 'Ie' ieInfo['ieLocalVar'] = ie['ieTypeName'][0].lower()+ie['ieTypeName'][1:] ieInfo['iePresence'] = ie['presence'] ieInfo['ieCardinality'] = ie['cardinality'] ieInfo['instance'] = ie['instance'] ieInfo['grouped'] = ie['grouped'] if ieInfo['grouped']=='Yes': ieInfo['grpIeInstClassName'] = ie['ieGroupTypeName'][0].upper()+ie['ieGroupTypeName'][1:] ieInfo['grpIeInstFileName'] = ie['ieGroupTypeName'] ieType = ieInfo['ieType'] ieTypeInfo['ieName'] = ie['ieVarName'] ieTypeInfo['ieVarName'] = ie['ieVarName'] ieTypeInfo['ieType'] = ie['ieTypeName'] ieTypeInfo['ieFileName'] = ie['ieTypeName'][0].lower()+ie['ieTypeName'][1:] + 'Ie' ieTypeInfo['ieLocalVar'] = ie['ieTypeName'][0].lower()+ie['ieTypeName'][1:] ieTypeInfo['iePresence'] = ie['presence'] ieTypeInfo['ieCardinality'] = ie['cardinality'] ieTypeInfo['instance'] = ie['instance'] ieTypeInfo['grouped'] = ie['grouped'] if ieTypeInfo['grouped']=='Yes': ieTypeInfo['grpIeInstClassName'] = ie['ieGroupTypeName'][0].upper()+ie['ieGroupTypeName'][1:] ieTypeInfo['grpIeInstFileName'] = ie['ieGroupTypeName'].capitalize() if ieInfo['ieType'] not in ieTypeList: ieTypeList.append(ieInfo['ieType']) templateInstData['ieTypeList'] = ieTypeList if ieInfo not in ieInfoList: ieInfoList.append(ieInfo) templateInstData['ieList'] = ieInfoList templateInstData['ieTypeDetails'] = {} templateInstData['ieTypeDetails'][ieType] = [] if ieTypeInfo not in templateInstData['ieTypeDetails'][ieType]: templateInstData['ieTypeDetails'][ieType].append(ieTypeInfo) ieTypeDetailsList.append(templateInstData['ieTypeDetails']) templateInstData['ieTypeDetails'] = ieTypeDetailsList GenerateGrpIeClass.templateInstanceprocess(templateInstData) outputDirCpp = 'ieClasses/' objectfile = outputDirCpp +templateInstData['fileName'] + '.o' sourcefile = outputDirCpp + templateInstData['fileName'] + '.cpp' xlUtils.addToMakeSo('gtpV2Stack.so',objectfile,sourcefile)
def templateIes(self, ieData, currentType): templateData = dict() varDetailsList = [] sequenceList = [] varDetailsList = ieData['varDetails'] templateData[ 'className'] = ieData['ieDetails'][currentType]['ieName'] + 'Ie' templateData['fileName'] = templateData['className'][0].lower( ) + templateData['className'][1:] templateData['classNameUC'] = templateData['className'].upper() templateData['ieTypeVal'] = ieData['ieDetails'][currentType][ 'ieTypeVal'] #building the dictionary obtained to a dict 'templateData' #which is the input to template process for en in ieData['encodeSeq']: mEncode = re.search('encode:(\w+):', en) mSkip = re.search('skip:(\d+):(\w+)', en) item = dict() if mSkip: bitByte = mSkip.group(2) skipValue = mSkip.group(1) item['skipType'] = 'y' item['bitByte'] = bitByte item['skipValue'] = skipValue elif mEncode: varName = mEncode.group(1) for variableDetails in varDetailsList: for key, value in variableDetails.items(): if key == varName: item['fieldName'] = varName if value['bitLength'] != 0: item['bitField'] = 'y' item['fieldSize'] = value['bitLength'] item['leafType'] = 'y' else: item['fieldSize'] = value['byteLength'] if value['decodeCondition'] != '': item['decodeConditional'] = 'y' item['decodeCondition'] = value[ 'decodeCondition'] if value['encodeCondition'] != '': item['encodeConditional'] = 'y' item['encodeCondition'] = value[ 'encodeCondition'] if value.get('presence') == 'optional': item['presence'] = 'optional' item['fieldType'] = value['varType'] mUint = re.search('^Uint(\d+)$', value['varType']) if mUint or value['varType'] == 'bool': item['leafType'] = 'y' else: if value['lengthStr'] == 'EOI' or value[ 'lengthStr'] == '': item['length'] = 'lengthLeft' else: item['length'] = value['lengthStr'] if value['validation'] != '': item['validationPresent'] = 'y' item['validationRule'] = value['validation'] mArray = re.search('Array', value['varType']) if mArray: item['arrayType'] = 'y' if value['count'] == '': item['count'] = 0 else: item['count'] = value['count'] if item != {}: sequenceList.append(item) templateData['sequence'] = sequenceList outputDir = '../../src/gtpV2Codec/ieClasses' ttFileNameCpp = 'tts/ietemplate.cpp.tt' ttFileNameH = 'tts/ietemplate.h.tt' xlUtils.templateProcess(templateData, ttFileNameCpp, ttFileNameH, outputDir, outputDir) objectFile = 'ieClasses/' + templateData['fileName'] + '.o' sourceFile = 'ieClasses/' + templateData['fileName'] + '.cpp' xlUtils.addToMakeSo('gtpV2Stack.so', objectFile, sourceFile)