def parseSwcNvBlockNeeds(self,xmlRoot,rootProject=None):
    name=parseTextNode(xmlRoot.find('SHORT-NAME'))
    numberOfDataSets=parseIntNode(xmlRoot.find('N-DATA-SETS'))
    readonly=parseBooleanNode(xmlRoot.find('READONLY'))
    reliability=parseTextNode(xmlRoot.find('RELIABILITY'))
    resistantToChangedSW=parseBooleanNode(xmlRoot.find('RESISTANT-TO-CHANGED-SW'))
    restoreAtStart=parseBooleanNode(xmlRoot.find('RESTORE-AT-START'))
    writeOnlyOnce=parseBooleanNode(xmlRoot.find('WRITE-ONLY-ONCE'))
    writingFrequency=parseIntNode(xmlRoot.find('WRITING-FREQUENCY'))
    defaultBlockRef=parseTextNode(xmlRoot.find('DEFAULT-BLOCK-REF'))
    mirrorBlockref=parseTextNode(xmlRoot.find('MIRROR-BLOCK-REF'))      
    serviceCallPorts=self.parseServiceCallPorts(xmlRoot.find('SERVICE-CALL-PORTS'),rootProject)
    assert(len(serviceCallPorts)>0)
    swcNvBlockNeeds=SwcNvBlockNeeds(name,numberOfDataSets,readonly,reliability,resistantToChangedSW,restoreAtStart,
                                    writeOnlyOnce,writingFrequency,defaultBlockRef,mirrorBlockref)
    swcNvBlockNeeds.serviceCallPorts=serviceCallPorts
    return swcNvBlockNeeds
Example #2
0
 def parseSwcNvBlockNeeds(self,xmlRoot):
     name=parseTextNode(xmlRoot.find('SHORT-NAME'))
     numberOfDataSets=parseIntNode(xmlRoot.find('N-DATA-SETS'))
     readOnly=parseBooleanNode(xmlRoot.find('READONLY'))
     reliability=parseTextNode(xmlRoot.find('RELIABILITY'))
     resistantToChangedSW=parseBooleanNode(xmlRoot.find('RESISTANT-TO-CHANGED-SW'))
     restoreAtStart=parseBooleanNode(xmlRoot.find('RESTORE-AT-START'))
     writeOnlyOnce=parseBooleanNode(xmlRoot.find('WRITE-ONLY-ONCE'))
     writingFrequency=parseIntNode(xmlRoot.find('WRITING-FREQUENCY'))
     writingPriority=parseTextNode(xmlRoot.find('WRITING-PRIORITY'))
     defaultBlockRef=parseTextNode(xmlRoot.find('DEFAULT-BLOCK-REF'))
     mirrorBlockRef=parseTextNode(xmlRoot.find('MIRROR-BLOCK-REF'))
     serviceCallPorts=self.parseServiceCallPorts(xmlRoot.find('SERVICE-CALL-PORTS'))
     assert(len(serviceCallPorts)>0)
     swcNvBlockNeeds=SwcNvBlockNeeds(name,numberOfDataSets,readOnly,reliability,resistantToChangedSW,restoreAtStart,
                                     writeOnlyOnce,writingFrequency,writingPriority,defaultBlockRef,mirrorBlockRef)
     swcNvBlockNeeds.serviceCallPorts=serviceCallPorts
     return swcNvBlockNeeds
Example #3
0
 def parseSWCInternalBehavior(self, xmlRoot, parent):
    """AUTOSAR 4 internal behavior"""
    assert(xmlRoot.tag == 'SWC-INTERNAL-BEHAVIOR')
    name = parseTextNode(xmlRoot.find('SHORT-NAME'))
    multipleInstance = False
    xmlSupportMultipleInst = xmlRoot.find('SUPPORTS-MULTIPLE-INSTANTIATION')
    if xmlSupportMultipleInst is not None:
       multipleInstance = self.parseBooleanNode(xmlSupportMultipleInst)
       assert(multipleInstance is not None)
    ws = parent.rootWS()
    assert(ws is not None)
    if (name is not None):
       handledXML = ['SHORT-NAME', 'SUPPORTS-MULTIPLE-INSTANTIATION']
       internalBehavior = SwcInternalBehavior(name, parent.ref, multipleInstance, parent)
       for xmlElem in xmlRoot.findall('./*'):
          if xmlElem.tag in handledXML:
             pass
          elif xmlElem.tag == 'DATA-TYPE-MAPPING-REFS':
             for xmlChild in xmlElem.findall('./*'):
                if xmlChild.tag == 'DATA-TYPE-MAPPING-REF':
                   tmp = self.parseTextNode(xmlChild)
                   assert(tmp is not None)
                   internalBehavior.dataTypeMappingRefs.append(tmp)
          elif xmlElem.tag == 'EVENTS':
                for xmlEvent in xmlElem.findall('./*'):
                   event = None
                   if xmlEvent.tag == 'INIT-EVENT':
                      event = self.parseInitEvent(xmlEvent,internalBehavior)
                   elif xmlEvent.tag == 'SWC-MODE-SWITCH-EVENT':
                      event = self.parseModeSwitchEvent(xmlEvent,internalBehavior)
                   elif xmlEvent.tag == 'TIMING-EVENT':
                      event = self.parseTimingEvent(xmlEvent,internalBehavior)
                   elif xmlEvent.tag == 'DATA-RECEIVED-EVENT':
                      event = self.parseDataReceivedEvent(xmlEvent,internalBehavior)
                   elif xmlEvent.tag == 'OPERATION-INVOKED-EVENT':
                      event = self.parseOperationInvokedEvent(xmlEvent,internalBehavior)
                   else:
                      raise NotImplementedError(xmlEvent.tag)
                   if event is not None:
                      internalBehavior.events.append(event)
                   else:
                      raise NotImplementedError(xmlEvent.tag)
          elif xmlElem.tag == 'PORT-API-OPTIONS':
             for xmlOption in xmlElem.findall('./PORT-API-OPTION'):
                portAPIOption = PortAPIOption(parseTextNode(xmlOption.find('PORT-REF')),parseBooleanNode(xmlOption.find('ENABLE-TAKE-ADDRESS')),parseBooleanNode(xmlOption.find('INDIRECT-API')))
                if portAPIOption is not None: internalBehavior.portAPIOptions.append(portAPIOption)
          elif xmlElem.tag == 'RUNNABLES':
             for xmRunnable in xmlElem.findall('./RUNNABLE-ENTITY'):
                runnableEntity = self.parseRunnableEntity(xmRunnable, internalBehavior)
                if runnableEntity is not None:
                   internalBehavior.runnables.append(runnableEntity)
          elif xmlElem.tag == 'AR-TYPED-PER-INSTANCE-MEMORYS':
             for xmlChild in xmlElem.findall('./*'):
                if xmlChild.tag == 'VARIABLE-DATA-PROTOTYPE':
                   dataElement = self.parseVariableDataPrototype(xmlChild, internalBehavior)
                   internalBehavior.perInstanceMemories.append(dataElement)
                else:
                   raise NotImplementedError(xmlChild.tag)
          elif xmlElem.tag == 'SERVICE-DEPENDENCYS':
             for xmlChildElem in xmlElem.findall('./*'):
                if xmlChildElem.tag == 'SWC-SERVICE-DEPENDENCY':
                   swcServiceDependency = self.parseSwcServiceDependency(xmlChildElem, internalBehavior)
                   internalBehavior.serviceDependencies.append(swcServiceDependency)
                else:
                   raise NotImplementedError(childElem.tag)
          elif xmlElem.tag == 'SHARED-PARAMETERS':
             for xmlChildElem in xmlElem.findall('./*'):
                if xmlChildElem.tag == 'PARAMETER-DATA-PROTOTYPE':
                   tmp = self.parseParameterDataPrototype(xmlChildElem, internalBehavior)
                   if tmp is not None:
                      internalBehavior.parameterDataPrototype.append(tmp)                     
                else:
                   raise NotImplementedError(childElem.tag)
          elif xmlElem.tag == 'EXCLUSIVE-AREAS':
             for xmlChild in xmlElem.findall('./*'):
                if xmlChild.tag=='EXCLUSIVE-AREA':
                   exclusiveArea=ExclusiveArea(parseTextNode(xmlChild.find('SHORT-NAME')), internalBehavior)
                   internalBehavior.exclusiveAreas.append(exclusiveArea)
                else:
                   raise NotImplementedError(xmlChild.tag)
          else:
             raise NotImplementedError(xmlElem.tag)
       return internalBehavior
Example #4
0
 def parseInternalBehavior(self,xmlRoot,parent):
    """AUTOSAR 3 Internal Behavior"""
    assert(xmlRoot.tag == 'INTERNAL-BEHAVIOR')
    name = parseTextNode(xmlRoot.find('SHORT-NAME'))
    componentRef = parseTextNode(xmlRoot.find('COMPONENT-REF'))
    multipleInstance = False
    xmlSupportMultipleInst = xmlRoot.find('SUPPORTS-MULTIPLE-INSTANTIATION')
    if (xmlSupportMultipleInst is not None) and (xmlSupportMultipleInst.text == 'true'):
       multipleInstance = True
    ws = parent.rootWS()
    assert(ws is not None)
    if (name is not None) and (componentRef is not None):
       internalBehavior = InternalBehavior(name, componentRef, multipleInstance, parent)
       swc = ws.find(componentRef)
       if swc is not None:
          swc.behavior=internalBehavior
       for xmlNode in xmlRoot.findall('./*'):
          if (xmlNode.tag == 'SHORT-NAME') or (xmlNode.tag == 'COMPONENT-REF') or (xmlNode.tag == 'SUPPORTS-MULTIPLE-INSTANTIATION'):
             continue
          if xmlNode.tag == 'EVENTS':
             for xmlEvent in xmlNode.findall('./*'):
                event = None
                if xmlEvent.tag == 'MODE-SWITCH-EVENT':
                   event = self.parseModeSwitchEvent(xmlEvent,internalBehavior)
                elif xmlEvent.tag == 'TIMING-EVENT':
                   event = self.parseTimingEvent(xmlEvent,internalBehavior)
                elif xmlEvent.tag == 'DATA-RECEIVED-EVENT':
                   event = self.parseDataReceivedEvent(xmlEvent,internalBehavior)
                elif xmlEvent.tag == 'OPERATION-INVOKED-EVENT':
                   event = self.parseOperationInvokedEvent(xmlEvent,internalBehavior)
                else:
                   raise NotImplementedError(xmlEvent.tag)
                if event is not None:
                   internalBehavior.events.append(event)
                else:
                   raise ValueError('event')
          elif xmlNode.tag == 'PORT-API-OPTIONS':
             for xmlOption in xmlNode.findall('./PORT-API-OPTION'):
                portAPIOption = PortAPIOption(parseTextNode(xmlOption.find('PORT-REF')),parseBooleanNode(xmlOption.find('ENABLE-TAKE-ADDRESS')),parseBooleanNode(xmlOption.find('INDIRECT-API')))
                if portAPIOption is not None: internalBehavior.portAPIOptions.append(portAPIOption)
          elif xmlNode.tag == 'RUNNABLES':
             for xmRunnable in xmlNode.findall('./RUNNABLE-ENTITY'):
                runnableEntity = self.parseRunnableEntity(xmRunnable, internalBehavior)
                if runnableEntity is not None:
                   internalBehavior.runnables.append(runnableEntity)
          elif xmlNode.tag == 'PER-INSTANCE-MEMORYS':
             for xmlElem in xmlNode.findall('./PER-INSTANCE-MEMORY'):
               perInstanceMemory = PerInstanceMemory(parseTextNode(xmlElem.find('SHORT-NAME')),parseTextNode(xmlElem.find('TYPE-DEFINITION')), internalBehavior)
               if perInstanceMemory is not None: internalBehavior.perInstanceMemories.append(perInstanceMemory)
          elif xmlNode.tag == 'SERVICE-NEEDSS':
             for xmlElem in xmlNode.findall('./*'):
                if xmlElem.tag=='SWC-NV-BLOCK-NEEDS':
                   swcNvBlockNeeds=self.parseSwcNvBlockNeeds(xmlElem)
                   if swcNvBlockNeeds is not None: internalBehavior.swcNvBlockNeeds.append(swcNvBlockNeeds)
                else:
                   raise NotImplementedError(xmlElem.tag)
          elif xmlNode.tag == 'SHARED-CALPRMS':
             for xmlElem in xmlNode.findall('./*'):
                if xmlElem.tag=='CALPRM-ELEMENT-PROTOTYPE':
                   calPrmElemPrototype=self.parseCalPrmElemPrototype(xmlElem, internalBehavior)
                   assert(calPrmElemPrototype is not None)
                   internalBehavior.sharedCalParams.append(calPrmElemPrototype)
                else:
                   raise NotImplementedError(xmlElem.tag)
          elif xmlNode.tag == 'EXCLUSIVE-AREAS':
             for xmlElem in xmlNode.findall('./*'):
                if xmlElem.tag=='EXCLUSIVE-AREA':
                   exclusiveArea=ExclusiveArea(parseTextNode(xmlElem.find('SHORT-NAME')), internalBehavior)
                   internalBehavior.exclusiveAreas.append(exclusiveArea)
                else:
                   raise NotImplementedError(xmlElem.tag)
          else:
             raise NotImplementedError(xmlNode.tag)
       return internalBehavior
Example #5
0
 def parseRunnableEntity(self, xmlRoot, parent):
    xmlDataReceivePoints=None
    xmlDataSendPoints=None
    xmlServerCallPoints=None
    xmlCanEnterExclusiveAreas=None
    adminData = None
    xmlModeAccessPoints = None
    xmlParameterAccessPoints = None
    if self.version < 4.0:
       for xmlElem in xmlRoot.findall('*'):
          if xmlElem.tag=='SHORT-NAME':
             name=parseTextNode(xmlElem)
          elif xmlElem.tag=='CAN-BE-INVOKED-CONCURRENTLY':
             canBeInvokedConcurrently=parseBooleanNode(xmlElem)
          elif xmlElem.tag=='DATA-RECEIVE-POINTS':
             xmlDataReceivePoints=xmlElem
          elif xmlElem.tag=='DATA-SEND-POINTS':
             xmlDataSendPoints=xmlElem
          elif xmlElem.tag=='SERVER-CALL-POINTS':
             xmlServerCallPoints=xmlElem
          elif xmlElem.tag=='SYMBOL':
             symbol=parseTextNode(xmlElem)
          elif xmlElem.tag=='CAN-ENTER-EXCLUSIVE-AREA-REFS':
             xmlCanEnterExclusiveAreas=xmlElem
          elif xmlElem.tag=='ADMIN-DATA':
             adminData=parseAdminDataNode(xmlElem)
          else:
             raise NotImplementedError(xmlElem.tag)
    else:
       for xmlElem in xmlRoot.findall('*'):
          if xmlElem.tag=='SHORT-NAME':
             name=parseTextNode(xmlElem)
          elif xmlElem.tag=='CAN-BE-INVOKED-CONCURRENTLY':
             canBeInvokedConcurrently=parseBooleanNode(xmlElem)
          elif xmlElem.tag == 'MODE-ACCESS-POINTS':
             xmlModeAccessPoints = xmlElem
          elif xmlElem.tag=='DATA-RECEIVE-POINT-BY-ARGUMENTS':
             xmlDataReceivePoints=xmlElem
          elif xmlElem.tag=='DATA-SEND-POINTS':
             xmlDataSendPoints=xmlElem
          elif xmlElem.tag=='SERVER-CALL-POINTS':
             xmlServerCallPoints=xmlElem
          elif xmlElem.tag=='SYMBOL':
             symbol=parseTextNode(xmlElem)
          elif xmlElem.tag=='CAN-ENTER-EXCLUSIVE-AREA-REFS':
             xmlCanEnterExclusiveAreas=xmlElem               
          elif xmlElem.tag == 'MINIMUM-START-INTERVAL':
             pass #not implemented
          elif xmlElem.tag =='ADMIN-DATA':
             adminData=parseAdminDataNode(xmlElem)
          elif xmlElem.tag == 'PARAMETER-ACCESSS':
             xmlParameterAccessPoints = xmlElem
          else:
             raise NotImplementedError(xmlElem.tag)
    runnableEntity = RunnableEntity(name, canBeInvokedConcurrently, symbol, parent)
    if xmlDataReceivePoints is not None:
       if self.version < 4.0:
          for xmlDataPoint in xmlDataReceivePoints.findall('./DATA-RECEIVE-POINT'):
             name=parseTextNode(xmlDataPoint.find('SHORT-NAME'))
             dataElementInstanceRef = self.parseDataElementInstanceRef(xmlDataPoint.find('DATA-ELEMENT-IREF'),'R-PORT-PROTOTYPE-REF')
             if dataElementInstanceRef is not None:
                dataReceivePoint=DataReceivePoint(dataElementInstanceRef.portRef,dataElementInstanceRef.dataElemRef,name)
                runnableEntity.append(dataReceivePoint)
       else:
          for xmlVariableAcess in xmlDataReceivePoints.findall('VARIABLE-ACCESS'):
             name=parseTextNode(xmlVariableAcess.find('SHORT-NAME'))
             accessedVariable = self.parseAccessedVariable(xmlVariableAcess.find('./ACCESSED-VARIABLE'))
             assert(accessedVariable is not None)
             dataReceivePoint=DataReceivePoint(accessedVariable.portPrototypeRef,accessedVariable.targetDataPrototypeRef,name)
             runnableEntity.append(dataReceivePoint)
    if xmlDataSendPoints is not None:
       if self.version < 4.0:
          for xmlDataPoint in xmlDataSendPoints.findall('./DATA-SEND-POINT'):
             name=parseTextNode(xmlDataPoint.find('SHORT-NAME'))
             dataElementInstanceRef = self.parseDataElementInstanceRef(xmlDataPoint.find('DATA-ELEMENT-IREF'),'P-PORT-PROTOTYPE-REF')
             if dataElementInstanceRef is not None:
                dataSendPoint=DataSendPoint(dataElementInstanceRef.portRef,dataElementInstanceRef.dataElemRef,name)
                runnableEntity.append(dataSendPoint)
       else:
          for xmlVariableAcess in xmlDataSendPoints.findall('VARIABLE-ACCESS'):
             name=parseTextNode(xmlVariableAcess.find('SHORT-NAME'))
             accessedVariable = self.parseAccessedVariable(xmlVariableAcess.find('./ACCESSED-VARIABLE'))
             assert(accessedVariable is not None)
             dataSendPoint=DataSendPoint(accessedVariable.portPrototypeRef,accessedVariable.targetDataPrototypeRef,name)
             runnableEntity.append(dataSendPoint)
    if xmlModeAccessPoints is not None:
       for xmlElem in xmlModeAccessPoints.findall('./*'):
          if xmlElem.tag == 'MODE-ACCESS-POINT':
             modeAccessPoint = self.parseModeAccessPoint(xmlElem)
             assert(modeAccessPoint is not None)
             runnableEntity.modeAccessPoints.append(modeAccessPoint)
          else:
             raise NotImplementedError(xmlElem.tag)
    if xmlServerCallPoints is not None:
       for xmlServerCallPoint in xmlServerCallPoints.findall('./SYNCHRONOUS-SERVER-CALL-POINT'):
          syncServerCallPoint = self.parseSyncServerCallPoint(xmlServerCallPoint)
          if syncServerCallPoint is not None: runnableEntity.serverCallPoints.append(syncServerCallPoint)
    if xmlCanEnterExclusiveAreas is not None:
       for xmlCanEnterExclusiveAreaRef in xmlCanEnterExclusiveAreas.findall('./CAN-ENTER-EXCLUSIVE-AREA-REF'):
          runnableEntity.exclusiveAreaRefs.append(parseTextNode(xmlCanEnterExclusiveAreaRef))
    if self.version >= 4.0 and xmlParameterAccessPoints is not None:
       for xmlChild in xmlParameterAccessPoints.findall('./*'):
          if xmlChild.tag == 'PARAMETER-ACCESS':
             tmp = self.parseParameterAccessPoint(xmlChild, runnableEntity)
             if tmp is not None:
                runnableEntity.parameterAccessPoints.append(tmp)
          else:
             raise NotImplementedError('xmlChild.tag')
    
    if runnableEntity is not None:
       runnableEntity.adminData = adminData
    return runnableEntity
Example #6
0
 def parseSWCInternalBehavior(self, xmlRoot, parent):
     """AUTOSAR 4 internal behavior"""
     assert(xmlRoot.tag == 'SWC-INTERNAL-BEHAVIOR')
     name = parseTextNode(xmlRoot.find('SHORT-NAME'))
     multipleInstance = False
     xmlSupportMultipleInst = xmlRoot.find('SUPPORTS-MULTIPLE-INSTANTIATION')
     if xmlSupportMultipleInst is not None:
         multipleInstance = self.parseBooleanNode(xmlSupportMultipleInst)
         assert(multipleInstance is not None)
     ws = parent.rootWS()
     assert(ws is not None)
     if (name is not None):
         handledXML = ['SHORT-NAME', 'SUPPORTS-MULTIPLE-INSTANTIATION']
         internalBehavior = SwcInternalBehavior(name, parent.ref, multipleInstance, parent)
         for xmlElem in xmlRoot.findall('./*'):
             if xmlElem.tag in handledXML:
                 pass
             elif xmlElem.tag == 'DATA-TYPE-MAPPING-REFS':
                 for xmlChild in xmlElem.findall('./*'):
                     if xmlChild.tag == 'DATA-TYPE-MAPPING-REF':
                         tmp = self.parseTextNode(xmlChild)
                         assert(tmp is not None)
                         internalBehavior.dataTypeMappingRefs.append(tmp)
             elif xmlElem.tag == 'EVENTS':
                 for xmlEvent in xmlElem.findall('./*'):
                     event = None
                     if xmlEvent.tag == 'INIT-EVENT':
                         event = self.parseInitEvent(xmlEvent,internalBehavior)
                     elif xmlEvent.tag == 'SWC-MODE-SWITCH-EVENT':
                         event = self.parseModeSwitchEvent(xmlEvent,internalBehavior)
                     elif xmlEvent.tag == 'TIMING-EVENT':
                         event = self.parseTimingEvent(xmlEvent,internalBehavior)
                     elif xmlEvent.tag == 'DATA-RECEIVED-EVENT':
                         event = self.parseDataReceivedEvent(xmlEvent,internalBehavior)
                     elif xmlEvent.tag == 'OPERATION-INVOKED-EVENT':
                         event = self.parseOperationInvokedEvent(xmlEvent,internalBehavior)
                     else:
                         raise NotImplementedError(xmlEvent.tag)
                     if event is not None:
                         internalBehavior.events.append(event)
                     else:
                         raise NotImplementedError(xmlEvent.tag)
             elif xmlElem.tag == 'PORT-API-OPTIONS':
                 for xmlOption in xmlElem.findall('./PORT-API-OPTION'):
                     portAPIOption = PortAPIOption(parseTextNode(xmlOption.find('PORT-REF')),parseBooleanNode(xmlOption.find('ENABLE-TAKE-ADDRESS')),parseBooleanNode(xmlOption.find('INDIRECT-API')))
                     if portAPIOption is not None: internalBehavior.portAPIOptions.append(portAPIOption)
             elif xmlElem.tag == 'RUNNABLES':
                 for xmRunnable in xmlElem.findall('./RUNNABLE-ENTITY'):
                     runnableEntity = self.parseRunnableEntity(xmRunnable, internalBehavior)
                     if runnableEntity is not None:
                         internalBehavior.runnables.append(runnableEntity)
             elif xmlElem.tag == 'AR-TYPED-PER-INSTANCE-MEMORYS':
                 for xmlChild in xmlElem.findall('./*'):
                     if xmlChild.tag == 'VARIABLE-DATA-PROTOTYPE':
                         dataElement = self.parseVariableDataPrototype(xmlChild, internalBehavior)
                         internalBehavior.perInstanceMemories.append(dataElement)
                     else:
                         raise NotImplementedError(xmlChild.tag)
             elif xmlElem.tag == 'SERVICE-DEPENDENCYS':
                 for xmlChildElem in xmlElem.findall('./*'):
                     if xmlChildElem.tag == 'SWC-SERVICE-DEPENDENCY':
                         swcServiceDependency = self.parseSwcServiceDependency(xmlChildElem, internalBehavior)
                         internalBehavior.serviceDependencies.append(swcServiceDependency)
                     else:
                         raise NotImplementedError(childElem.tag)
             elif xmlElem.tag == 'SHARED-PARAMETERS':
                 for xmlChildElem in xmlElem.findall('./*'):
                     if xmlChildElem.tag == 'PARAMETER-DATA-PROTOTYPE':
                         tmp = self.parseParameterDataPrototype(xmlChildElem, internalBehavior)
                         if tmp is not None:
                             internalBehavior.parameterDataPrototype.append(tmp)
                     else:
                         raise NotImplementedError(childElem.tag)
             elif xmlElem.tag == 'EXCLUSIVE-AREAS':
                 for xmlChild in xmlElem.findall('./*'):
                     if xmlChild.tag=='EXCLUSIVE-AREA':
                         exclusiveArea=ExclusiveArea(parseTextNode(xmlChild.find('SHORT-NAME')), internalBehavior)
                         internalBehavior.exclusiveAreas.append(exclusiveArea)
                     else:
                         raise NotImplementedError(xmlChild.tag)
             else:
                 raise NotImplementedError(xmlElem.tag)
         return internalBehavior
Example #7
0
 def parseInternalBehavior(self,xmlRoot,parent):
     """AUTOSAR 3 Internal Behavior"""
     assert(xmlRoot.tag == 'INTERNAL-BEHAVIOR')
     name = parseTextNode(xmlRoot.find('SHORT-NAME'))
     componentRef = parseTextNode(xmlRoot.find('COMPONENT-REF'))
     multipleInstance = False
     xmlSupportMultipleInst = xmlRoot.find('SUPPORTS-MULTIPLE-INSTANTIATION')
     if (xmlSupportMultipleInst is not None) and (xmlSupportMultipleInst.text == 'true'):
         multipleInstance = True
     ws = parent.rootWS()
     assert(ws is not None)
     if (name is not None) and (componentRef is not None):
         internalBehavior = InternalBehavior(name, componentRef, multipleInstance, parent)
         swc = ws.find(componentRef)
         if swc is not None:
             swc.behavior=internalBehavior
         for xmlNode in xmlRoot.findall('./*'):
             if (xmlNode.tag == 'SHORT-NAME') or (xmlNode.tag == 'COMPONENT-REF') or (xmlNode.tag == 'SUPPORTS-MULTIPLE-INSTANTIATION'):
                 continue
             if xmlNode.tag == 'EVENTS':
                 for xmlEvent in xmlNode.findall('./*'):
                     event = None
                     if xmlEvent.tag == 'MODE-SWITCH-EVENT':
                         event = self.parseModeSwitchEvent(xmlEvent,internalBehavior)
                     elif xmlEvent.tag == 'TIMING-EVENT':
                         event = self.parseTimingEvent(xmlEvent,internalBehavior)
                     elif xmlEvent.tag == 'DATA-RECEIVED-EVENT':
                         event = self.parseDataReceivedEvent(xmlEvent,internalBehavior)
                     elif xmlEvent.tag == 'OPERATION-INVOKED-EVENT':
                         event = self.parseOperationInvokedEvent(xmlEvent,internalBehavior)
                     else:
                         raise NotImplementedError(xmlEvent.tag)
                     if event is not None:
                         internalBehavior.events.append(event)
                     else:
                         raise ValueError('event')
             elif xmlNode.tag == 'PORT-API-OPTIONS':
                 for xmlOption in xmlNode.findall('./PORT-API-OPTION'):
                     portAPIOption = PortAPIOption(parseTextNode(xmlOption.find('PORT-REF')),parseBooleanNode(xmlOption.find('ENABLE-TAKE-ADDRESS')),parseBooleanNode(xmlOption.find('INDIRECT-API')))
                     if portAPIOption is not None: internalBehavior.portAPIOptions.append(portAPIOption)
             elif xmlNode.tag == 'RUNNABLES':
                 for xmRunnable in xmlNode.findall('./RUNNABLE-ENTITY'):
                     runnableEntity = self.parseRunnableEntity(xmRunnable, internalBehavior)
                     if runnableEntity is not None:
                         internalBehavior.runnables.append(runnableEntity)
             elif xmlNode.tag == 'PER-INSTANCE-MEMORYS':
                 for xmlElem in xmlNode.findall('./PER-INSTANCE-MEMORY'):
                     perInstanceMemory = PerInstanceMemory(parseTextNode(xmlElem.find('SHORT-NAME')),parseTextNode(xmlElem.find('TYPE-DEFINITION')), internalBehavior)
                     if perInstanceMemory is not None: internalBehavior.perInstanceMemories.append(perInstanceMemory)
             elif xmlNode.tag == 'SERVICE-NEEDSS':
                 for xmlElem in xmlNode.findall('./*'):
                     if xmlElem.tag=='SWC-NV-BLOCK-NEEDS':
                         swcNvBlockNeeds=self.parseSwcNvBlockNeeds(xmlElem)
                         if swcNvBlockNeeds is not None: internalBehavior.swcNvBlockNeeds.append(swcNvBlockNeeds)
                     else:
                         raise NotImplementedError(xmlElem.tag)
             elif xmlNode.tag == 'SHARED-CALPRMS':
                 for xmlElem in xmlNode.findall('./*'):
                     if xmlElem.tag=='CALPRM-ELEMENT-PROTOTYPE':
                         calPrmElemPrototype=self.parseCalPrmElemPrototype(xmlElem, internalBehavior)
                         assert(calPrmElemPrototype is not None)
                         internalBehavior.sharedCalParams.append(calPrmElemPrototype)
                     else:
                         raise NotImplementedError(xmlElem.tag)
             elif xmlNode.tag == 'EXCLUSIVE-AREAS':
                 for xmlElem in xmlNode.findall('./*'):
                     if xmlElem.tag=='EXCLUSIVE-AREA':
                         exclusiveArea=ExclusiveArea(parseTextNode(xmlElem.find('SHORT-NAME')), internalBehavior)
                         internalBehavior.exclusiveAreas.append(exclusiveArea)
                     else:
                         raise NotImplementedError(xmlElem.tag)
             else:
                 raise NotImplementedError(xmlNode.tag)
         return internalBehavior
Example #8
0
    def parseRunnableEntity(self, xmlRoot, parent):
        xmlDataReceivePoints=None
        xmlDataSendPoints=None
        xmlServerCallPoints=None
        xmlCanEnterExclusiveAreas=None
        adminData = None
        xmlModeAccessPoints = None
        xmlParameterAccessPoints = None
        if self.version < 4.0:
            for xmlElem in xmlRoot.findall('*'):
                if xmlElem.tag=='SHORT-NAME':
                    name=parseTextNode(xmlElem)
                elif xmlElem.tag=='CAN-BE-INVOKED-CONCURRENTLY':
                    canBeInvokedConcurrently=parseBooleanNode(xmlElem)
                elif xmlElem.tag=='DATA-RECEIVE-POINTS':
                    xmlDataReceivePoints=xmlElem
                elif xmlElem.tag=='DATA-SEND-POINTS':
                    xmlDataSendPoints=xmlElem
                elif xmlElem.tag=='SERVER-CALL-POINTS':
                    xmlServerCallPoints=xmlElem
                elif xmlElem.tag=='SYMBOL':
                    symbol=parseTextNode(xmlElem)
                elif xmlElem.tag=='CAN-ENTER-EXCLUSIVE-AREA-REFS':
                    xmlCanEnterExclusiveAreas=xmlElem
                elif xmlElem.tag=='ADMIN-DATA':
                    adminData=parseAdminDataNode(xmlElem)
                else:
                    raise NotImplementedError(xmlElem.tag)
        else:
            for xmlElem in xmlRoot.findall('*'):
                if xmlElem.tag=='SHORT-NAME':
                    name=parseTextNode(xmlElem)
                elif xmlElem.tag=='CAN-BE-INVOKED-CONCURRENTLY':
                    canBeInvokedConcurrently=parseBooleanNode(xmlElem)
                elif xmlElem.tag == 'MODE-ACCESS-POINTS':
                    xmlModeAccessPoints = xmlElem
                elif xmlElem.tag=='DATA-RECEIVE-POINT-BY-ARGUMENTS':
                    xmlDataReceivePoints=xmlElem
                elif xmlElem.tag=='DATA-SEND-POINTS':
                    xmlDataSendPoints=xmlElem
                elif xmlElem.tag=='SERVER-CALL-POINTS':
                    xmlServerCallPoints=xmlElem
                elif xmlElem.tag=='SYMBOL':
                    symbol=parseTextNode(xmlElem)
                elif xmlElem.tag=='CAN-ENTER-EXCLUSIVE-AREA-REFS':
                    xmlCanEnterExclusiveAreas=xmlElem
                elif xmlElem.tag == 'MINIMUM-START-INTERVAL':
                    pass #not implemented
                elif xmlElem.tag =='ADMIN-DATA':
                    adminData=parseAdminDataNode(xmlElem)
                elif xmlElem.tag == 'PARAMETER-ACCESSS':
                    xmlParameterAccessPoints = xmlElem
                else:
                    raise NotImplementedError(xmlElem.tag)
        runnableEntity = RunnableEntity(name, canBeInvokedConcurrently, symbol, parent)
        if xmlDataReceivePoints is not None:
            if self.version < 4.0:
                for xmlDataPoint in xmlDataReceivePoints.findall('./DATA-RECEIVE-POINT'):
                    name=parseTextNode(xmlDataPoint.find('SHORT-NAME'))
                    dataElementInstanceRef = self.parseDataElementInstanceRef(xmlDataPoint.find('DATA-ELEMENT-IREF'),'R-PORT-PROTOTYPE-REF')
                    if dataElementInstanceRef is not None:
                        dataReceivePoint=DataReceivePoint(dataElementInstanceRef.portRef,dataElementInstanceRef.dataElemRef,name)
                        runnableEntity.append(dataReceivePoint)
            else:
                for xmlVariableAcess in xmlDataReceivePoints.findall('VARIABLE-ACCESS'):
                    name=parseTextNode(xmlVariableAcess.find('SHORT-NAME'))
                    accessedVariable = self.parseAccessedVariable(xmlVariableAcess.find('./ACCESSED-VARIABLE'))
                    assert(accessedVariable is not None)
                    dataReceivePoint=DataReceivePoint(accessedVariable.portPrototypeRef,accessedVariable.targetDataPrototypeRef,name)
                    runnableEntity.append(dataReceivePoint)
        if xmlDataSendPoints is not None:
            if self.version < 4.0:
                for xmlDataPoint in xmlDataSendPoints.findall('./DATA-SEND-POINT'):
                    name=parseTextNode(xmlDataPoint.find('SHORT-NAME'))
                    dataElementInstanceRef = self.parseDataElementInstanceRef(xmlDataPoint.find('DATA-ELEMENT-IREF'),'P-PORT-PROTOTYPE-REF')
                    if dataElementInstanceRef is not None:
                        dataSendPoint=DataSendPoint(dataElementInstanceRef.portRef,dataElementInstanceRef.dataElemRef,name)
                        runnableEntity.append(dataSendPoint)
            else:
                for xmlVariableAcess in xmlDataSendPoints.findall('VARIABLE-ACCESS'):
                    name=parseTextNode(xmlVariableAcess.find('SHORT-NAME'))
                    accessedVariable = self.parseAccessedVariable(xmlVariableAcess.find('./ACCESSED-VARIABLE'))
                    assert(accessedVariable is not None)
                    dataSendPoint=DataSendPoint(accessedVariable.portPrototypeRef,accessedVariable.targetDataPrototypeRef,name)
                    runnableEntity.append(dataSendPoint)
        if xmlModeAccessPoints is not None:
            for xmlElem in xmlModeAccessPoints.findall('./*'):
                if xmlElem.tag == 'MODE-ACCESS-POINT':
                    modeAccessPoint = self.parseModeAccessPoint(xmlElem)
                    assert(modeAccessPoint is not None)
                    runnableEntity.modeAccessPoints.append(modeAccessPoint)
                else:
                    raise NotImplementedError(xmlElem.tag)
        if xmlServerCallPoints is not None:
            for xmlServerCallPoint in xmlServerCallPoints.findall('./SYNCHRONOUS-SERVER-CALL-POINT'):
                syncServerCallPoint = self.parseSyncServerCallPoint(xmlServerCallPoint)
                if syncServerCallPoint is not None: runnableEntity.serverCallPoints.append(syncServerCallPoint)
        if xmlCanEnterExclusiveAreas is not None:
            for xmlCanEnterExclusiveAreaRef in xmlCanEnterExclusiveAreas.findall('./CAN-ENTER-EXCLUSIVE-AREA-REF'):
                runnableEntity.exclusiveAreaRefs.append(parseTextNode(xmlCanEnterExclusiveAreaRef))
        if self.version >= 4.0 and xmlParameterAccessPoints is not None:
            for xmlChild in xmlParameterAccessPoints.findall('./*'):
                if xmlChild.tag == 'PARAMETER-ACCESS':
                    tmp = self.parseParameterAccessPoint(xmlChild, runnableEntity)
                    if tmp is not None:
                        runnableEntity.parameterAccessPoints.append(tmp)
                else:
                    raise NotImplementedError('xmlChild.tag')

        if runnableEntity is not None:
            runnableEntity.adminData = adminData
        return runnableEntity
Example #9
0
 def parseInternalBehavior(self,xmlRoot,dummy,parent=None):
    xmlName = parseTextNode(xmlRoot.find('SHORT-NAME'))
    xmlComponentRef = parseTextNode(xmlRoot.find('COMPONENT-REF'))
    xmlSupportMultipleInst = xmlRoot.find('SUPPORTS-MULTIPLE-INSTANTIATION')
    ws = parent.rootWS()
    assert(ws is not None)
    if (xmlName is not None) and (xmlComponentRef is not None):
       multipleInstance = False
       if (xmlSupportMultipleInst is not None) and (xmlSupportMultipleInst.text == 'true'):
          multipleInstance = True
       internalBehavior = InternalBehavior(xmlName, xmlComponentRef, multipleInstance, parent)
       swc = ws.find(xmlComponentRef)
       if swc is not None:
          swc.behavior=internalBehavior
       for xmlNode in xmlRoot.findall('./*'):
          if (xmlNode.tag == 'SHORT-NAME') or (xmlNode.tag == 'COMPONENT-REF') or (xmlNode.tag == 'SUPPORTS-MULTIPLE-INSTANTIATION'):
             continue
          if xmlNode.tag == 'EVENTS':
             for xmlEvent in xmlNode.findall('./*'):
                event = None
                if xmlEvent.tag == 'MODE-SWITCH-EVENT':
                   event = self.parseModeSwitchEvent(xmlEvent,internalBehavior)
                elif xmlEvent.tag == 'TIMING-EVENT':
                   event = self.parseTimingEvent(xmlEvent,internalBehavior)
                elif xmlEvent.tag == 'DATA-RECEIVED-EVENT':
                   event = self.parseDataReceivedEvent(xmlEvent,internalBehavior)
                elif xmlEvent.tag == 'OPERATION-INVOKED-EVENT':
                   event = self.parseOperationInvokedEvent(xmlEvent,internalBehavior)
                else:
                   raise NotImplementedError(xmlEvent.tag)
                if event is not None:
                   internalBehavior.events.append(event)
                else:
                   raise ValueError('event')
          elif xmlNode.tag == 'PORT-API-OPTIONS':
             for xmlOption in xmlNode.findall('./PORT-API-OPTION'):                  
                portAPIOption = PortAPIOption(parseTextNode(xmlOption.find('PORT-REF')),parseBooleanNode(xmlOption.find('ENABLE-TAKE-ADDRESS')),parseBooleanNode(xmlOption.find('INDIRECT-API')))
                if portAPIOption is not None: internalBehavior.portAPIOptions.append(portAPIOption)
          elif xmlNode.tag == 'RUNNABLES':
             for xmRunnable in xmlNode.findall('./RUNNABLE-ENTITY'):
                xmlDataReceivePoints=None
                xmlDataSendPoints=None
                xmlServerCallPoints=None
                xmlCanEnterExclusiveAreas=None
                adminData = None
                for xmlElem in xmRunnable.findall('*'):
                   if xmlElem.tag=='SHORT-NAME':
                      name=parseTextNode(xmlElem)
                   elif xmlElem.tag=='CAN-BE-INVOKED-CONCURRENTLY':
                      canBeInvokedConcurrently=parseBooleanNode(xmlElem)
                   elif xmlElem.tag=='DATA-RECEIVE-POINTS':
                      xmlDataReceivePoints=xmlElem
                   elif xmlElem.tag=='DATA-SEND-POINTS':
                      xmlDataSendPoints=xmlElem
                   elif xmlElem.tag=='SERVER-CALL-POINTS':
                      xmlServerCallPoints=xmlElem
                   elif xmlElem.tag=='SYMBOL':
                      symbol=parseTextNode(xmlElem)
                   elif xmlElem.tag=='CAN-ENTER-EXCLUSIVE-AREA-REFS':
                      xmlCanEnterExclusiveAreas=xmlElem
                   elif xmlElem.tag=='ADMIN-DATA':
                      adminData=parseAdminDataNode(xmlElem)
                   else:
                      raise NotImplementedError(xmlElem.tag)
                runnableEntity = RunnableEntity(name, canBeInvokedConcurrently, symbol, parent=internalBehavior)
                if xmlDataReceivePoints is not None:
                   for xmlDataPoint in xmlDataReceivePoints.findall('./DATA-RECEIVE-POINT'):                        
                      name=parseTextNode(xmlDataPoint.find('SHORT-NAME'))
                      dataElementInstanceRef = self.parseDataElementInstanceRef(xmlDataPoint.find('DATA-ELEMENT-IREF'),'R-PORT-PROTOTYPE-REF')                        
                      if dataElementInstanceRef is not None:
                         dataReceivePoint=DataReceivePoint(dataElementInstanceRef.portRef,dataElementInstanceRef.dataElemRef,name)
                         runnableEntity.append(dataReceivePoint)
                if xmlDataSendPoints is not None:
                   for xmlDataPoint in xmlDataSendPoints.findall('./DATA-SEND-POINT'):
                      name=parseTextNode(xmlDataPoint.find('SHORT-NAME'))
                      dataElementInstanceRef = self.parseDataElementInstanceRef(xmlDataPoint.find('DATA-ELEMENT-IREF'),'P-PORT-PROTOTYPE-REF')
                      if dataElementInstanceRef is not None:
                         dataSendPoint=DataSendPoint(dataElementInstanceRef.portRef,dataElementInstanceRef.dataElemRef,name)
                         runnableEntity.append(dataSendPoint)
                if xmlServerCallPoints is not None:
                   for xmlServerCallPoint in xmlServerCallPoints.findall('./SYNCHRONOUS-SERVER-CALL-POINT'):
                      syncServerCallPoint = self.parseSyncServerCallPoint(xmlServerCallPoint)
                      if syncServerCallPoint is not None: runnableEntity.serverCallPoints.append(syncServerCallPoint)
                if xmlCanEnterExclusiveAreas is not None:
                   for xmlCanEnterExclusiveAreaRef in xmlCanEnterExclusiveAreas.findall('./CAN-ENTER-EXCLUSIVE-AREA-REF'):
                      runnableEntity.exclusiveAreaRefs.append(parseTextNode(xmlCanEnterExclusiveAreaRef))                        
                if runnableEntity is not None:
                   runnableEntity.adminData = adminData
                   internalBehavior.runnables.append(runnableEntity)
          elif xmlNode.tag == 'PER-INSTANCE-MEMORYS':               
             for xmlElem in xmlNode.findall('./PER-INSTANCE-MEMORY'):
               perInstanceMemory = PerInstanceMemory(parseTextNode(xmlElem.find('SHORT-NAME')),parseTextNode(xmlElem.find('TYPE-DEFINITION')), internalBehavior)
               if perInstanceMemory is not None: internalBehavior.perInstanceMemories.append(perInstanceMemory)
          elif xmlNode.tag == 'SERVICE-NEEDSS':
             for xmlElem in xmlNode.findall('./*'):
                if xmlElem.tag=='SWC-NV-BLOCK-NEEDS':
                   swcNvBlockNeeds=self.parseSwcNvBlockNeeds(xmlElem)
                   if swcNvBlockNeeds is not None: internalBehavior.swcNvBlockNeeds.append(swcNvBlockNeeds)
                else:
                   raise NotImplementedError(xmlElem.tag)
          elif xmlNode.tag == 'SHARED-CALPRMS':
             for xmlElem in xmlNode.findall('./*'):
                if xmlElem.tag=='CALPRM-ELEMENT-PROTOTYPE':
                   calPrmElemPrototype=self.parseCalPrmElemPrototype(xmlElem, internalBehavior)
                   assert(calPrmElemPrototype is not None)
                   internalBehavior.sharedCalParams.append(calPrmElemPrototype)
                else:
                   raise NotImplementedError(xmlElem.tag)
          elif xmlNode.tag == 'EXCLUSIVE-AREAS':
             for xmlElem in xmlNode.findall('./*'):
                if xmlElem.tag=='EXCLUSIVE-AREA':
                   exclusiveArea=ExclusiveArea(parseTextNode(xmlElem.find('SHORT-NAME')), internalBehavior)
                   internalBehavior.exclusiveAreas.append(exclusiveArea)
                else:
                   raise NotImplementedError(xmlElem.tag)
          else:
             raise NotImplementedError(xmlNode.tag)   
       return internalBehavior      
 def parseInternalBehavior(self,xmlRoot,dummy,parent=None):
    xmlName = xmlRoot.find('SHORT-NAME')
    xmlComponentRef = xmlRoot.find('COMPONENT-REF')
    xmlSupportMultipleInst = xmlRoot.find('SUPPORTS-MULTIPLE-INSTANTIATION')      
    if (xmlName is not None) and (xmlComponentRef is not None):
       multipleInstance = False
       if (xmlSupportMultipleInst is not None) and (xmlSupportMultipleInst.text == 'true'):
          multipleInstance = True
       internalBehavior = InternalBehavior(xmlName.text,xmlComponentRef.text,multipleInstance)
       for xmlNode in xmlRoot.findall('./*'):
          if (xmlNode.tag == 'SHORT-NAME') or (xmlNode.tag == 'COMPONENT-REF') or (xmlNode.tag == 'SUPPORTS-MULTIPLE-INSTANTIATION'):
             continue
          if xmlNode.tag == 'EVENTS':
             for xmlEvent in xmlNode.findall('./*'):
                event = None
                if xmlEvent.tag == 'MODE-SWITCH-EVENT':
                   event = self.parseModeSwitchEvent(xmlEvent,parent)
                elif xmlEvent.tag == 'TIMING-EVENT':
                   event = self.parseTimingEvent(xmlEvent,parent)
                elif xmlEvent.tag == 'DATA-RECEIVED-EVENT':
                   event = self.parseDataReceivedEvent(xmlEvent,parent)
                elif xmlEvent.tag == 'OPERATION-INVOKED-EVENT':
                   event = self.parseOperationInvokedEvent(xmlEvent,parent)
                else:
                   raise NotImplementedError(xmlEvent.tag)
                if event is not None:
                   internalBehavior.events.append(event)
                else:
                   raise ValueError('event')
          elif xmlNode.tag == 'PORT-API-OPTIONS':
             for xmlOption in xmlNode.findall('./PORT-API-OPTION'):                  
                portAPIOption = PortAPIOption(parseTextNode(xmlOption.find('ENABLE-TAKE-ADDRESS')),parseTextNode(xmlOption.find('INDIRECT-API')),parseTextNode(xmlOption.find('PORT-REF')))
                if portAPIOption is not None: internalBehavior.portAPIOptions.append(portAPIOption)
          elif xmlNode.tag == 'RUNNABLES':
             for xmRunnable in xmlNode.findall('./RUNNABLE-ENTITY'):
                xmlDataReceivePoints=None
                xmlDataSendPoints=None
                xmlServerCallPoints=None
                xmlCanEnterExclusiveAreas=None
                for xmlElem in xmRunnable.findall('*'):
                   if xmlElem.tag=='SHORT-NAME':
                      name=parseTextNode(xmlElem)
                   elif xmlElem.tag=='CAN-BE-INVOKED-CONCURRENTLY':
                      canBeInvokedConcurrently=parseBooleanNode(xmlElem)
                   elif xmlElem.tag=='DATA-RECEIVE-POINTS':
                      xmlDataReceivePoints=xmlElem
                   elif xmlElem.tag=='DATA-SEND-POINTS':
                      xmlDataSendPoints=xmlElem
                   elif xmlElem.tag=='SERVER-CALL-POINTS':
                      xmlServerCallPoints=xmlElem
                   elif xmlElem.tag=='SYMBOL':
                      symbol=parseTextNode(xmlElem)
                   elif xmlElem.tag=='CAN-ENTER-EXCLUSIVE-AREA-REFS':
                      xmlCanEnterExclusiveAreas=xmlElem
                   else:
                      raise NotImplementedError(xmlElem.tag)
                runnableEntity = RunnableEntity(name,canBeInvokedConcurrently,symbol)                                     
                if xmlDataReceivePoints is not None:
                   for xmlDataPoint in xmlDataReceivePoints.findall('./DATA-RECEIVE-POINT'):                        
                      name=parseTextNode(xmlDataPoint.find('SHORT-NAME'))
                      dataElementInstanceRef = self.parseDataElementInstanceRef(xmlDataPoint.find('DATA-ELEMENT-IREF'),'R-PORT-PROTOTYPE-REF')                        
                      if dataElementInstanceRef is not None:
                         dataReceivePoint=DataReceivePoint(dataElementInstanceRef.portRef,dataElementInstanceRef.dataElemRef,name)
                         runnableEntity.dataReceivePoints.append(dataReceivePoint)
                if xmlDataSendPoints is not None:
                   for xmlDataPoint in xmlDataSendPoints.findall('./DATA-SEND-POINT'):
                      #TODO: Fix this
                      dataElementInstanceRef = self.parseDataElementInstanceRef(xmlDataPoint.find('DATA-ELEMENT-IREF'),'P-PORT-PROTOTYPE-REF')
                      if dataElementInstanceRef is not None: runnableEntity.dataSendPoints.append(dataElementInstanceRef)
                if xmlServerCallPoints is not None:
                   for xmlServerCallPoint in xmlServerCallPoints.findall('./SYNCHRONOUS-SERVER-CALL-POINT'):
                      syncServerCallPoint = self.parseSyncServerCallPoint(xmlServerCallPoint,rootProject)
                      if syncServerCallPoint is not None: runnableEntity.syncServerCallPoints.append(syncServerCallPoint)
                if xmlCanEnterExclusiveAreas is not None:
                   for xmlCanEnterExclusiveAreaRef in xmlCanEnterExclusiveAreas.findall('./CAN-ENTER-EXCLUSIVE-AREA-REF'):
                      runnableEntity.canEnterExclusiveAreas.append(parseTextNode(xmlCanEnterExclusiveAreaRef))                        
                if runnableEntity is not None: internalBehavior.runnables.append(runnableEntity)
          elif xmlNode.tag == 'PER-INSTANCE-MEMORYS':               
             for xmlElem in xmlNode.findall('./PER-INSTANCE-MEMORY'):
               perInstanceMemory = PerInstanceMemory(parseTextNode(xmlElem.find('SHORT-NAME')),parseTextNode(xmlElem.find('TYPE-DEFINITION')))
               if perInstanceMemory is not None: internalBehavior.perInstanceMemories.append(perInstanceMemory)
          elif xmlNode.tag == 'SERVICE-NEEDSS':
             for xmlElem in xmlNode.findall('./*'):
                if xmlElem.tag=='SWC-NV-BLOCK-NEEDS':
                   swcNvBlockNeeds=self.parseSwcNvBlockNeeds(xmlElem,rootProject)
                   if swcNvBlockNeeds is not None: internalBehavior.swcNvBlockNeeds.append(swcNvBlockNeeds)
                else:
                   raise NotImplementedError(xmlElem.tag)
          elif xmlNode.tag == 'SHARED-CALPRMS':
             for xmlElem in xmlNode.findall('./*'):
                if xmlElem.tag=='CALPRM-ELEMENT-PROTOTYPE':
                   calPrmElemPrototype=self.parseCalPrmElemPrototype(xmlElem,rootProject)
                   assert(calPrmElemPrototype is not None)
                   internalBehavior.sharedCalPrms.append(calPrmElemPrototype)
                else:
                   raise NotImplementedError(xmlElem.tag)
          elif xmlNode.tag == 'EXCLUSIVE-AREAS':
             for xmlElem in xmlNode.findall('./*'):
                if xmlElem.tag=='EXCLUSIVE-AREA':
                   exclusiveArea=ExclusiveArea(xmlElem.find('SHORT-NAME'))                     
                   internalBehavior.exclusiveAreas.append(exclusiveArea)
                else:
                   raise NotImplementedError(xmlElem.tag)
          else:
             raise NotImplementedError(xmlNode.tag)   
       return internalBehavior      
Example #11
0
 def parseSWCInternalBehavior(self, xmlRoot, parent):
    """AUTOSAR 4 internal behavior"""
    assert(xmlRoot.tag == 'SWC-INTERNAL-BEHAVIOR')
    name = parseTextNode(xmlRoot.find('SHORT-NAME'))               
    multipleInstance = False
    xmlSupportMultipleInst = xmlRoot.find('SUPPORTS-MULTIPLE-INSTANTIATION')
    if (xmlSupportMultipleInst is not None) and (xmlSupportMultipleInst.text == 'true'):
       multipleInstance = True      
    ws = parent.rootWS()
    assert(ws is not None)
    if (name is not None):
       handledXML = ['SHORT-NAME', 'SUPPORTS-MULTIPLE-INSTANTIATION'] 
       internalBehavior = InternalBehavior(name, parent.ref, multipleInstance, parent)      
       for xmlNode in xmlRoot.findall('./*'):
          if xmlNode.tag in handledXML:
             pass
          elif xmlNode.tag == 'DATA-TYPE-MAPPING-REFS':
             pass #not yet implemented
          elif xmlNode.tag == 'EVENTS':
                for xmlEvent in xmlNode.findall('./*'):
                   event = None
                   if xmlEvent.tag == 'INIT-EVENT':
                      event = self.parseInitEvent(xmlEvent,internalBehavior)
                   elif xmlEvent.tag == 'SWC-MODE-SWITCH-EVENT':
                      event = self.parseModeSwitchEvent(xmlEvent,internalBehavior)
                   elif xmlEvent.tag == 'TIMING-EVENT':
                      event = self.parseTimingEvent(xmlEvent,internalBehavior)
                   elif xmlEvent.tag == 'DATA-RECEIVED-EVENT':
                      event = self.parseDataReceivedEvent(xmlEvent,internalBehavior)
                   elif xmlEvent.tag == 'OPERATION-INVOKED-EVENT':
                      event = self.parseOperationInvokedEvent(xmlEvent,internalBehavior)
                   else:
                      raise NotImplementedError(xmlEvent.tag)
                   if event is not None:
                      internalBehavior.events.append(event)
                   else:
                      raise NotImplementedError(xmlEvent.tag)
          elif xmlNode.tag == 'PORT-API-OPTIONS':
             for xmlOption in xmlNode.findall('./PORT-API-OPTION'):                  
                portAPIOption = PortAPIOption(parseTextNode(xmlOption.find('PORT-REF')),parseBooleanNode(xmlOption.find('ENABLE-TAKE-ADDRESS')),parseBooleanNode(xmlOption.find('INDIRECT-API')))
                if portAPIOption is not None: internalBehavior.portAPIOptions.append(portAPIOption)
          elif xmlNode.tag == 'RUNNABLES':
             for xmRunnable in xmlNode.findall('./RUNNABLE-ENTITY'):
                runnableEntity = self.parseRunnableEntity(xmRunnable, parent)
                if runnableEntity is not None:
                   internalBehavior.runnables.append(runnableEntity)                     
          else:
             raise NotImplementedError(xmlNode.tag)
       return internalBehavior