415 self.servicepublisher = None |
415 self.servicepublisher = None |
416 self.statuschange = statuschange |
416 self.statuschange = statuschange |
417 self.evaluator = evaluator |
417 self.evaluator = evaluator |
418 self.pyruntimevars = pyruntimevars |
418 self.pyruntimevars = pyruntimevars |
419 |
419 |
|
420 def _to_be_published(self): |
|
421 return self.servicename is not None and \ |
|
422 self.ip_addr is not None and \ |
|
423 self.ip_addr != "localhost" and \ |
|
424 self.ip_addr != "127.0.0.1" |
|
425 |
|
426 def PrintServerInfo(self): |
|
427 print(_("Pyro port :"), self.port) |
|
428 |
|
429 # Beremiz IDE detects LOCAL:// runtime is ready by looking |
|
430 # for self.workdir in the daemon's stdout. |
|
431 print(_("Current working directory :"), self.workdir) |
|
432 |
|
433 if self._to_be_published(): |
|
434 print(_("Publishing service on local network")) |
|
435 |
|
436 sys.stdout.flush() |
|
437 |
|
438 |
420 def PyroLoop(self): |
439 def PyroLoop(self): |
421 while self.continueloop: |
440 while self.continueloop: |
422 pyro.initServer() |
441 pyro.initServer() |
423 self.daemon = pyro.Daemon(host=self.ip_addr, port=self.port) |
442 self.daemon = pyro.Daemon(host=self.ip_addr, port=self.port) |
|
443 |
424 # pyro never frees memory after connection close if no timeout set |
444 # pyro never frees memory after connection close if no timeout set |
425 # taking too small timeout value may cause |
445 # taking too small timeout value may cause |
426 # unwanted diconnection when IDE is kept busy for long periods |
446 # unwanted diconnection when IDE is kept busy for long periods |
427 self.daemon.setTimeout(60) |
447 self.daemon.setTimeout(60) |
428 |
448 |
429 uri = self.daemon.connect(self.plcobj, "PLCObject") |
449 uri = self.daemon.connect(self.plcobj, "PLCObject") |
430 |
450 |
431 print(_("Pyro port :"), self.port) |
451 if self._to_be_published(): |
432 print(_("Pyro object's uri :"), uri) |
|
433 |
|
434 # Beremiz IDE detects daemon start by looking |
|
435 # for self.workdir in the daemon's stdout. |
|
436 # Therefore don't delete the following line |
|
437 print(_("Current working directory :"), self.workdir) |
|
438 |
|
439 # Configure and publish service |
|
440 # Not publish service if localhost in address params |
|
441 if self.servicename is not None and \ |
|
442 self.ip_addr is not None and \ |
|
443 self.ip_addr != "localhost" and \ |
|
444 self.ip_addr != "127.0.0.1": |
|
445 print(_("Publishing service on local network")) |
|
446 self.servicepublisher = ServicePublisher.ServicePublisher() |
452 self.servicepublisher = ServicePublisher.ServicePublisher() |
447 self.servicepublisher.RegisterService(self.servicename, self.ip_addr, self.port) |
453 self.servicepublisher.RegisterService(self.servicename, self.ip_addr, self.port) |
448 |
454 |
449 self.daemon.requestLoop() |
455 self.daemon.requestLoop() |
450 self.daemon.sock.close() |
456 self.daemon.sock.close() |