def _genInitValues(self, ws, ports):
      ports = sorted(ports, key=lambda port: port.name)
      code = C.sequence()
      for port in ports:
         for comspec in port.comspec:
            if isinstance(comspec, autosar.port.DataElementComSpec):
               if comspec.initValueRef is not None:
                  initValue = ws.find(comspec.initValueRef)
                  if isinstance(initValue, autosar.constant.Constant):
                     #in case the ref is pointing to a Constant (the parent), grab the child instance using .value
                     initValue=initValue.value
                  if initValue is not None:
                     dataType = ws.find(initValue.typeRef)
                     if dataType is not None:
                        prefix = 'Rte_InitValue_%s_%s'%(port.name, comspec.name)
                        code.extend(self._getInitValue(ws, prefix, initValue, dataType))
      return code