Changeset 3696

Show
Ignore:
Timestamp:
05/07/07 13:46:17 (6 years ago)
Author:
DrewCormier
Message:

copied over port connection stuff from plot tool since i am receiving data instead of sending data. changed from graph structure class instance to write to file class instance. might not work completely

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • experimental/write_to_file/trunk/write_to_file/write_to_file.py

    r3695 r3696  
    1515    #TODO:add comment explainging this class 
    1616 
    17     def __init__(self, parent):         
    18         self.parent = parent 
    19  
    20     def write(self, data, file_name): 
     17    def __init__(self, orb, gui):         
     18        self.orb = orb 
     19        self.gui = gui 
     20 
     21    def pushPacket(self, data, file_name): 
    2122        #TODO: test this method 
    2223        open_file = open(file_name, 'w')   #open the file for writing 
     
    163164             sys.exit(1) 
    164165         name = [CosNaming.NameComponent(self.component_name[0],""), 
    165          CosNaming.NameComponent(self.component_name[1],""), 
    166          CosNaming.NameComponent(self.component_name[2],"")] 
     166             CosNaming.NameComponent(self.component_name[1],""), 
     167             CosNaming.NameComponent(self.component_name[2],"")] 
    167168      
    168169         try: 
     
    173174             sys.exit(1) 
    174175      
    175          #connect to an existing port 
    176176         ResourceHandle = ResourceRef._narrow(CF.Resource) 
    177177         PortReference = ResourceHandle.getPort(self.port_name) 
    178178         if PortReference is None: 
    179179             print "Failed to get Port reference" 
    180          self.PortHandle = PortReference._narrow(standardInterfaces__POA.complexShort) 
     180         self.PortHandle = PortReference._narrow(CF.Port) 
    181181          
     182         
     183         #create the class instance of the write_to_file class  
     184         self.my_file_writer = write_to_file(self.orb, self) 
     185 
     186         obj_poa = self.orb.resolve_initial_references("RootPOA") 
     187         poaManager = obj_poa._get_the_POAManager() 
     188         poaManager.activate() 
     189         obj_poa.activate_object(self.my_file_writer) 
     190         self.PortHandle.connectPort(self.my_file_writer._this(), "thisismyconnectionid_w2file") 
     191         #orb.run() 
     192 
    182193    def OnCloseWindow(self,event): 
    183194        if hasattr(self.parent, 'removeToolFrame'): 
     
    186197        event.Skip() 
    187198 
    188  
    189  
    190  
     199    def __del__(self): 
     200        if self.CORBA_being_used: 
     201            self.PortHandle.disconnectPort("thisismyconnectionid_plot") 
     202            while (_time.time() - self.my_local_plot.end_time) < 1.5: 
     203                #print (time.time() - self.my_local_plot.end_time) 
     204                pass 
     205                #_time.sleep(1) 
     206 
     207 
     208