--- a/Beremiz_service.py Wed May 18 14:46:27 2011 +0200
+++ b/Beremiz_service.py Tue May 24 00:36:08 2011 +0200
@@ -27,14 +27,14 @@
Usage of Beremiz PLC execution service :\n
-%s {[-n name] [-i ip] [-p port] [-x enabletaskbar] [-a autostart]|-h|--help} working_dir
- -n - zeroconf service name
- -i - ip of interface to bind to (x.x.x.x)
+%s {[-n servicename] [-i ip] [-p port] [-x enabletaskbar] [-a autostart]|-h|--help} working_dir + -n - zeroconf service name (default:disabled) + -i - ip of interface to bind to (default:localhost) + -p - port number default:3000 -h - print this help text and quit
- -a - autostart PLC (0:disable 1:enable)
- -x - enable/disable wxTaskbarIcon (0:disable 1:enable)
- -t - enable/disable Twisted web interface (0:disable 1:enable)
+ -a - autostart PLC (0:disable 1:enable) (default:0) + -x - enable/disable wxTaskbarIcon (0:disable 1:enable) (default:1) + -t - enable/disable Twisted web interface (0:disable 1:enable) (default:1) working_dir - directory where are stored PLC files
@@ -50,10 +50,7 @@
- }.get(sys.platform, "USER")]
@@ -71,7 +68,7 @@
# port: port that the service runs on
@@ -102,6 +99,7 @@
+ print "Wx unavailable !" @@ -431,10 +429,10 @@
return callable(*args,**kwargs)
- def __init__(self, name, ip, port, workdir, argv, autostart=False, statuschange=None, evaluator=default_evaluator, website=None):
+ def __init__(self, servicename, ip, port, workdir, argv, autostart=False, statuschange=None, evaluator=default_evaluator, website=None):
+ self.servicename = servicename @@ -463,16 +461,16 @@
self.plcobj = PLCObject(self.workdir, self.daemon, self.argv, self.statuschange, self.evaluator, self.website)
uri = self.daemon.connect(self.plcobj,"PLCObject")
- print "The daemon runs on port :",self.port
- print "The object's uri is :",uri
- print "The working directory :",self.workdir
+ print "Pyro port :",self.port + print "Pyro object's uri :",uri + print "Current working directory :",self.workdir # Configure and publish service
# Not publish service if localhost in address params
- if self.ip != "localhost" and self.ip != "127.0.0.1":
- print "Publish service on local network"
+ if self.servicename is not None and self.ip != "localhost" and self.ip != "127.0.0.1": + print "Publishing service on local network" self.servicepublisher = ServicePublisher.ServicePublisher()
- self.servicepublisher.RegisterService(self.name, self.ip, self.port)
+ self.servicepublisher.RegisterService(self.servicename, self.ip, self.port) @@ -485,11 +483,12 @@
if self.servicepublisher is not None:
self.servicepublisher.UnRegisterService()
- del self.servicepublisher
+ self.servicepublisher = None self.daemon.shutdown(True)
+ from threading import Thread, currentThread from twisted.internet import wxreactor
@@ -500,6 +499,7 @@
+ print "Twisted unavailable !" @@ -648,8 +648,8 @@
reactor.registerWxApp(app)
- site = appserver.NevowSite(res)
+ website = WebInterface() + site = appserver.NevowSite(website) @@ -659,8 +659,9 @@
+ print "Http interface port :",website_port
from threading import Semaphore
@@ -688,18 +689,25 @@
wx.CallAfter(wx_evaluator,callable,*args,**kwargs)
+ pyroserver = Server(servicename, ip, port, WorkingDir, argv, autostart, statuschange, evaluator, website) + taskbar_instance = BeremizTaskBarIcon(pyroserver) + pyroserver = Server(servicename, ip, port, WorkingDir, argv, autostart, website=website) - pyroserver = Server(name, ip, port, WorkingDir, argv, autostart, statuschange, evaluator, res)
- taskbar_instance = BeremizTaskBarIcon(pyroserver)
+if havetwisted or havewx: pyro_thread=Thread(target=pyroserver.Loop)
- pyroserver = Server(name, ip, port, WorkingDir, argv, autostart, website=res)
+ except KeyboardInterrupt,e: --- a/runtime/ServicePublisher.py Wed May 18 14:46:27 2011 +0200
+++ b/runtime/ServicePublisher.py Tue May 24 00:36:08 2011 +0200
@@ -69,7 +69,7 @@
properties = self.serviceproperties))
def gethostaddr(self, dst = '224.0.1.41'):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)