Пример #1
0
    def PyroLoop(self, when_ready):
        if self._to_be_published():
            self.Publish()

        while self.continueloop:
            Pyro.config.PYRO_MULTITHREADED = 0
            pyro.initServer()
            self.daemon = pyro.Daemon(host=self.ip_addr, port=self.port)

            # pyro never frees memory after connection close if no timeout set
            # taking too small timeout value may cause
            # unwanted diconnection when IDE is kept busy for long periods
            self.daemon.setTimeout(60)

            pyro_obj = Pyro.core.ObjBase()
            pyro_obj.delegateTo(runtime.GetPLCObjectSingleton())

            self.daemon.connect(pyro_obj, "PLCObject")

            when_ready()
            self.piper, self.pipew = os.pipe()
            self.daemon.requestLoop(others=[self.piper],
                                    callback=lambda x: None)
            self.piper, self.pipew = None, None
            if hasattr(self, 'sock'):
                self.daemon.sock.close()
        self.Unpublish()
Пример #2
0
    def Start(self):
        pyro.initServer()
        self.daemon = pyro.Daemon(host=self.ip_addr, port=self.port)
        self.plcobj = PLCObject(self.workdir, self.daemon, self.argv,
                                self.statuschange, self.evaluator,
                                self.pyruntimevars)
        uri = self.daemon.connect(self.plcobj, "PLCObject")

        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.servicename is not None and self.ip_addr is not None
                and self.ip_addr != "localhost"
                and self.ip_addr != "127.0.0.1"):
            print "Publishing service on local network"
            self.servicepublisher = ServicePublisher.ServicePublisher()
            self.servicepublisher.RegisterService(self.servicename,
                                                  self.ip_addr, self.port)

        if self.autostart:
            self.plcobj.AutoLoad()
            if self.plcobj.GetPLCstatus()[0] != "Empty":
                self.plcobj.StartPLC()

        sys.stdout.flush()

        self.daemon.requestLoop()
Пример #3
0
    def Start(self):
        pyro.initServer()
        self.daemon=pyro.Daemon(host=self.ip_addr, port=self.port)
        self.plcobj = PLCObject(self.workdir, self.daemon, self.argv,
                                self.statuschange, self.evaluator,
                                self.pyruntimevars)
        uri = self.daemon.connect(self.plcobj,"PLCObject")

        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.servicename is not None and
            self.ip_addr is not None and
            self.ip_addr != "localhost" and
            self.ip_addr != "127.0.0.1"):
            print "Publishing service on local network"
            self.servicepublisher = ServicePublisher.ServicePublisher()
            self.servicepublisher.RegisterService(self.servicename, self.ip_addr, self.port)

        if self.autostart :
            self.plcobj.AutoLoad()
            if self.plcobj.GetPLCstatus()[0] != "Empty":
                self.plcobj.StartPLC()

        sys.stdout.flush()

        self.daemon.requestLoop()
Пример #4
0
def _get_daemon(daemonhost, start=True):
    if not daemonhost in _DAEMONS:
        if not start:
            raise Exception('no daemon for %s' % daemonhost)
        if not _DAEMONS:
            core.initServer(banner=0)
        host, port = host_and_port(daemonhost)
        daemon = core.Daemon(host=host, port=port)
        _DAEMONS[daemonhost] = daemon
    return _DAEMONS[daemonhost]
Пример #5
0
def _get_daemon(daemonhost, start=True):
    if not daemonhost in _DAEMONS:
        if not start:
            raise Exception('no daemon for %s' % daemonhost)
        if not _DAEMONS:
            core.initServer(banner=0)
        host, port = host_and_port(daemonhost)
        daemon = core.Daemon(host=host, port=port)
        _DAEMONS[daemonhost] = daemon
    return _DAEMONS[daemonhost]
Пример #6
0
 def Loop(self):
     while self.continueloop:
         pyro.initServer()
         self.daemon = pyro.Daemon(host=self.ip_addr, port=self.port)
         # pyro never frees memory after connection close if no timeout set
         # taking too small timeout value may cause
         # unwanted diconnection when IDE is kept busy for long periods
         self.daemon.setTimeout(60)
         self.Start()
         self.daemon.requestLoop()
         self.daemon.sock.close()
Пример #7
0
def main():
    """
    server script
    """
    core.initServer()
    daemon = core.Daemon()
    ns = naming.NameServerLocator().getNS()
    daemon.useNameServer(ns)
    
    try:
        ns.unregister('manager')
    except errors.NamingError, e:
        print e
Пример #8
0
    def PyroLoop(self, when_ready):
        while self.continueloop:
            Pyro.config.PYRO_MULTITHREADED = 0
            pyro.initServer()
            self.daemon = pyro.Daemon(host=self.ip_addr, port=self.port)

            # pyro never frees memory after connection close if no timeout set
            # taking too small timeout value may cause
            # unwanted diconnection when IDE is kept busy for long periods
            self.daemon.setTimeout(60)

            self.daemon.connect(self.plcobj, "PLCObject")

            if self._to_be_published():
                self.servicepublisher = ServicePublisher.ServicePublisher()
                self.servicepublisher.RegisterService(self.servicename,
                                                      self.ip_addr, self.port)

            when_ready()
            self.daemon.requestLoop()
            self.daemon.sock.close()
Пример #9
0
    def Start(self):
        pyro.initServer()
        self.daemon = pyro.Daemon(host=self.ip_addr, port=self.port)
        self.plcobj = PLCObject(self.workdir, self.daemon, self.argv,
                                self.statuschange, self.evaluator,
                                self.pyruntimevars)
        uri = self.daemon.connect(self.plcobj, "PLCObject")

        print(_("Pyro port :"), self.port)
        print(_("Pyro object's uri :"), uri)

        # Beremiz IDE detects daemon start by looking
        # for self.workdir in the daemon's stdout.
        # Therefore don't delete the following line
        print(_("Current working directory :"), self.workdir)

        # Configure and publish service
        # Not publish service if localhost in address params
        if self.servicename is not None and \
           self.ip_addr is not None and \
           self.ip_addr != "localhost" and \
           self.ip_addr != "127.0.0.1":
            print(_("Publishing service on local network"))
            self.servicepublisher = ServicePublisher.ServicePublisher()
            self.servicepublisher.RegisterService(self.servicename,
                                                  self.ip_addr, self.port)

        self.plcobj.AutoLoad()
        if self.plcobj.GetPLCstatus()[0] != "Empty":
            if self.autostart:
                self.plcobj.StartPLC()
        self.plcobj.StatusChange()

        sys.stdout.flush()

        self.daemon.requestLoop()
        self.daemon.sock.close()