Changeset 3529

Show
Ignore:
Timestamp:
04/30/07 13:09:21 (6 years ago)
Author:
DrewCormier
Message:

stuff for generating port declaration stuff in init method. not tested yet

Location:
WaveDev/trunk/WaveDev/wavedev/generate/templates/py_comp
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • WaveDev/trunk/WaveDev/wavedev/generate/templates/py_comp/_sampleComp.py

    r3528 r3529  
    2121        self.naming_service_name = label 
    2222        self.poa = poa 
    23          
    24         self.inPort0_servant = dataIn_complexShort_i(self, "data_in_cs") 
    25         self.inPort0_var = self.inPort0_servant._this() 
    26          
    27         self.outPort0_servant = dataOut_complexShort_i(self, "data_out_cs") 
    28         self.outPort0_var = self.outPort0_servant._this() 
    29         self.outPort0_active = False 
    30         self.outPort1_servant = dataOut_timingStatus_i(self, "send_timing_report") 
    31         self.outPort1_var = self.outPort1_servant._this() 
    32         self.outPort1_active = False 
    33          
     23 
     24         __PORT_DECL__ 
     25 
    3426        self.propertySet = [] 
    3527        self.work_mod = None 
  • WaveDev/trunk/WaveDev/wavedev/generate/templates/py_comp/genStructure.py

    r3526 r3529  
    110110         l_out = line.replace('__CLASS_NAME__',comp.name) 
    111111         output.write(l_out) 
    112           
     112 
     113         if l_out.find("__PORT_DECL__") != -1: 
     114              self.writePortDecl(output,comp) 
     115              continue 
     116 
    113117 
    114118      input_tmpl.close() 
     
    136140      output_wm.close() 
    137141 
     142       
     143 
     144 
     145 
     146 
     147 
     148  def writePortDecl(output,comp): 
     149    """ This function writes the corba declarations of the ports to the init method""" 
     150 
     151    #TODO: test this method 
     152    inCount = 0 
     153    for p in c.ports: 
     154        if p.type == "Provides": 
     155            ts = " "*8 + "self.inPort" + inCount + '_servant = dataIn_complexShort_i(self, "' + p.name + '")\n' 
     156            ts = ts + " "*8 + 'self.inPort' + inCount + '_var = self.inPort' + inCount + '_servant._this()\n\n'   
     157            output.write(ts) 
     158            inCount += 1 
     159 
     160    outCount = 0 
     161    for p in c.ports: 
     162        if p.type == "Uses": 
     163            ts = " "*8 + 'self.outPort' + outCount + '_servant = dataOut_' + p.interface + '_i(self, "' + p.name + '")\n' 
     164            ts = ts + " "*8 + 'self.outPort' + outCount + '_var = self.outPort' + outCount + '_servant._this()\n' 
     165            ts = ts + " "*8 + 'self.outPort' + outCount + '_active = False\n\n' 
     166            output.write(ts) 
     167            outCount += 1 
     168     
     169 
    138170 
    139171 
    140172      '''         
    141         for line in inputH.readlines(): 
    142           l_out = line.replace("__CLASS_DEF__",comp.name.upper()+"_IMPL_H") 
    143           l_out = l_out.replace("__Class_name__",comp.name+"_i") 
    144           if l_out.find("__PORT_DECL__") != -1: 
    145               self.writePortDecl(outputH,comp) 
    146               continue 
    147           if l_out.find("__ACE_INCLUDES__") != -1: 
    148               if comp.ace == True: 
    149                   l_out = '#include "ace/Task.h"\n' 
    150               else: 
    151                   continue 
    152           if l_out.find("__ACE_INHERIT__") != -1: 
    153               if comp.ace == True: 
    154                   l_out = l_out.replace("__ACE_INHERIT__",", public ACE_Task<ACE_MT_SYNCH>") 
    155               else: 
    156                   l_out = l_out.replace("__ACE_INHERIT__","") 
    157           if l_out.find("__ACE_SVC_DECL__") != -1: 
    158               if comp.ace == True: 
    159                   l_out = l_out.replace("__ACE_SVC_DECL__",'int svc(void);\n        size_t queue_size;') 
    160               else: 
    161                   continue    
    162           if l_out.find("__FRIEND_DECL__") != -1: 
    163               l_out = l_out.replace("__FRIEND_DECL__","") 
    164               self.writeFriendDecl(outputH,comp) 
    165               continue 
    166                     
    167           outputH.write(l_out) 
    168            
    169         inputH.close() 
    170         outputH.close() 
    171          
     173                 
    172174        # generate the .cpp files for each component 
    173         inputCPP = open('generate/templates/custom_ports/sampleComp.cpp','r') 
    174         outputCPP = open(self.path + comp.name + "/" + comp.name + ".cpp",'w') 
    175         self.addGPL(outputCPP,comp.name) 
    176175        for line in inputCPP.readlines(): 
    177           l_out = line.replace("__IncludeFile__",comp.name) 
    178           l_out = l_out.replace("__Class_name__",comp.name+"_i") 
    179           #l_out = l_out.replace("__NS_name__","ossie" + comp.name+"Resource") 
    180176          if l_out.find("__PORT_INST__") != -1: 
    181177              self.writePortInst(outputCPP,comp) 
     
    187183              self.writeDelPort(outputCPP,comp) 
    188184              continue 
    189           if l_out.find("__ACE_SVC_PORTS__") != -1: 
    190               self.writeACESvcPorts(outputCPP,comp) 
    191               continue 
    192           if l_out.find("__ACE_SVC_DEF__") != -1: 
    193               if comp.ace == True: 
    194                   self.writeACESvcDef(outputCPP,comp,'component',comp.timing, comp) 
    195               continue               
    196           outputCPP.write(l_out) 
    197            
    198         inputCPP.close() 
    199         outputCPP.close() 
    200          
    201         # generate the main.cpp files for each component 
    202         inputMain = open('generate/templates/custom_ports/sampleMain.cpp','r') 
    203         outputMain = open(self.path + comp.name + "/main.cpp",'w') 
    204         self.addGPL(outputMain,comp.name) 
    205          
    206         for line in inputMain.readlines(): 
    207           l_out = line.replace("__IncludeFile__",comp.name) 
    208           l_out = l_out.replace("__Class_name__",comp.name+"_i") 
    209           l_out = l_out.replace("__CLASS_VAR__",comp.name.lower()) 
    210           if l_out.find("__CLASS_VAR_ACE__") != -1: 
    211               if comp.ace == True: 
    212                   l_out = l_out.replace("__CLASS_VAR_ACE__",comp.name.lower()) 
    213               else: 
    214                   continue           
    215           if l_out.find("__NAME_SPACE__") != -1: 
    216               ns_list = [] 
    217               for p in comp.ports: 
    218                   if p.interface.nameSpace not in ns_list: 
    219                       ns_list.append(p.interface.nameSpace) 
    220               l_out = '' 
    221               for tmpns in ns_list: 
    222                   l_out += 'using namespace ' + tmpns + ';\n' 
    223  
    224           outputMain.write(l_out) 
    225            
    226         inputMain.close() 
    227         outputMain.close() 
     185         
    228186         
    229187        # generate the port_impl.h file