Beremiz_service.py
changeset 263 0bc32427a459
parent 262 141a7145c099
child 269 d29c5f71574f
equal deleted inserted replaced
262:141a7145c099 263:0bc32427a459
   175         self.ip = ip
   175         self.ip = ip
   176         self.port = port
   176         self.port = port
   177         self.workdir = workdir
   177         self.workdir = workdir
   178         self.args = args
   178         self.args = args
   179         self.plcobj = None
   179         self.plcobj = None
   180         self.servicepublisher = ServicePublisher.ServicePublisher()
   180         self.servicepublisher = None
   181 
   181 
   182     def Loop(self):
   182     def Loop(self):
   183         while self.continueloop:
   183         while self.continueloop:
   184             self.Start()
   184             self.Start()
   185         
   185         
   201         print "The working directory :",self.workdir
   201         print "The working directory :",self.workdir
   202         
   202         
   203         # Configure and publish service
   203         # Configure and publish service
   204         # Not publish service if localhost in address params
   204         # Not publish service if localhost in address params
   205         if self.ip != "localhost" and self.ip != "127.0.0.1":    
   205         if self.ip != "localhost" and self.ip != "127.0.0.1":    
   206             print "Publish service on local network"            
   206             print "Publish service on local network"
       
   207             self.servicepublisher = ServicePublisher.ServicePublisher()            
   207             self.servicepublisher.RegisterService(self.name, self.ip, self.port)
   208             self.servicepublisher.RegisterService(self.name, self.ip, self.port)
   208         
   209         
   209         sys.stdout.flush()
   210         sys.stdout.flush()
   210         
   211         
   211         self.daemon.requestLoop()
   212         self.daemon.requestLoop()
   212     
   213     
   213     def Stop(self):
   214     def Stop(self):
   214         self.servicepublisher.UnRegisterService()
   215         if self.servicepublisher is not None:
       
   216             self.servicepublisher.UnRegisterService()
       
   217             del self.servicepublisher
   215         self.daemon.shutdown(True)
   218         self.daemon.shutdown(True)
   216 
   219 
   217 class ParamsEntryDialog(wx.TextEntryDialog):
   220 class ParamsEntryDialog(wx.TextEntryDialog):
   218     if wx.VERSION < (2, 6, 0):
   221     if wx.VERSION < (2, 6, 0):
   219         def Bind(self, event, function, id = None):
   222         def Bind(self, event, function, id = None):
   333             pyroserver.Restart()
   336             pyroserver.Restart()
   334 
   337 
   335     def OnTaskBarQuit(self,evt):
   338     def OnTaskBarQuit(self,evt):
   336         pyroserver.Quit()
   339         pyroserver.Quit()
   337         self.RemoveIcon()
   340         self.RemoveIcon()
       
   341         wx.GetApp().ExitMainLoop()
   338         
   342         
   339 pyroserver = Server(name, ip, port, WorkingDir, args)
   343 pyroserver = Server(name, ip, port, WorkingDir, args)
   340 
   344 
   341 if havewx:
   345 if havewx:
   342     app=wx.App(redirect=False)
   346     app=wx.App(redirect=False)