Changeset 3607

Show
Ignore:
Timestamp:
05/02/07 15:57:52 (6 years ago)
Author:
DrewCormier
Message:

added generation of getPOrt method based on existing ports

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

    r3529 r3607  
    3434         
    3535    def getPort(self, id): 
    36         if str(id) == "data_in_cs": 
    37             return self.inPort0_var 
    38         elif str(id) == "data_out_cs": 
    39             return self.outPort0_var 
    40         elif str(id) == "send_timing_report": 
    41             return self.outPort1_var 
    42          
    43         return None 
     36        __GET_PORT__ 
     37         
     38        return None  #port not found in available ports list 
    4439         
    4540    def initialize(self): 
  • WaveDev/trunk/WaveDev/wavedev/generate/templates/py_comp/genStructure.py

    r3605 r3607  
    120120              self.writePortDecl(output,comp) 
    121121              continue 
     122         if l_out.find("__GET_PORT__") != -1: 
     123              self.writeGetPort(output,comp) 
     124              continue 
    122125 
    123126 
     
    152155 
    153156 
    154  
     157  #----------------------------------------------------------------------------------- 
    155158  def writePortDecl(output,comp): 
    156159    """ This function writes the corba declarations of the ports to the init method""" 
    157160 
     161    #TODO: test this method 
     162    inCount = 0 
     163    for p in comp.ports: 
     164        if p.type == "Provides": 
     165            ts = " "*8 + "self.inPort" + inCount + '_servant = dataIn_complexShort_i(self, "' + p.name + '")\n' 
     166            ts = ts + " "*8 + 'self.inPort' + inCount + '_var = self.inPort' + inCount + '_servant._this()\n\n'   
     167            output.write(ts) 
     168            inCount += 1 
     169 
     170    outCount = 0 
     171    for p in comp.ports: 
     172        if p.type == "Uses": 
     173            ts = " "*8 + 'self.outPort' + outCount + '_servant = dataOut_' + p.interface + '_i(self, "' + p.name + '")\n' 
     174            ts = ts + " "*8 + 'self.outPort' + outCount + '_var = self.outPort' + outCount + '_servant._this()\n' 
     175            ts = ts + " "*8 + 'self.outPort' + outCount + '_active = False\n\n' 
     176            output.write(ts) 
     177            outCount += 1 
     178  #----------------------------------------------------------------------------------------     
     179 
     180  #---------------------------------------------------------------------------------------- 
     181  def writeGetPort(output,comp): 
     182    #TODO: comment this method 
    158183    #TODO: test this method 
    159184    inCount = 0 
    160185    for p in c.ports: 
    161186        if p.type == "Provides": 
    162             ts = " "*8 + "self.inPort" + inCount + '_servant = dataIn_complexShort_i(self, "' + p.name + '")\n' 
    163             ts = ts + " "*8 + 'self.inPort' + inCount + '_var = self.inPort' + inCount + '_servant._this()\n\n'   
     187            ts = " "*8 + 'if str(id) == "' + p.name + '":\n' 
     188            ts = ts + " "*12 + 'return ' + 'self.inPort' + inCount + '_var\n' 
    164189            output.write(ts) 
    165190            inCount += 1 
     
    168193    for p in c.ports: 
    169194        if p.type == "Uses": 
    170             ts = " "*8 + 'self.outPort' + outCount + '_servant = dataOut_' + p.interface + '_i(self, "' + p.name + '")\n' 
    171             ts = ts + " "*8 + 'self.outPort' + outCount + '_var = self.outPort' + outCount + '_servant._this()\n' 
    172             ts = ts + " "*8 + 'self.outPort' + outCount + '_active = False\n\n' 
    173             output.write(ts) 
    174             outCount += 1 
    175      
    176  
    177  
     195            ts = " "*8 + 'if str(id) == "' + p.name + '":\n' 
     196            ts = ts + " "*12 + 'return ' + 'self.outPort' + outCount + '_var\n' 
     197            output.write(ts) 
     198            inCount += 1 
     199  #---------------------------------------------------------------------------------------- 
    178200 
    179201      '''