equal
deleted
inserted
replaced
7 # Copyright (C) 2017: Andrey Skvortsov |
7 # Copyright (C) 2017: Andrey Skvortsov |
8 # Copyright (C) 2018: Edouard TISSERANT |
8 # Copyright (C) 2018: Edouard TISSERANT |
9 |
9 |
10 # See COPYING file for copyrights details. |
10 # See COPYING file for copyrights details. |
11 |
11 |
|
12 from __future__ import absolute_import |
|
13 from __future__ import print_function |
12 import sys |
14 import sys |
13 |
15 |
14 import Pyro |
16 import Pyro |
15 import Pyro.core as pyro |
17 import Pyro.core as pyro |
16 import runtime |
18 import runtime |
17 from runtime.ServicePublisher import ServicePublisher |
19 from runtime.ServicePublisher import ServicePublisher |
|
20 |
18 |
21 |
19 class Server(object): |
22 class Server(object): |
20 def __init__(self, servicename, ip_addr, port): |
23 def __init__(self, servicename, ip_addr, port): |
21 self.continueloop = True |
24 self.continueloop = True |
22 self.daemon = None |
25 self.daemon = None |
47 |
50 |
48 # pyro never frees memory after connection close if no timeout set |
51 # pyro never frees memory after connection close if no timeout set |
49 # taking too small timeout value may cause |
52 # taking too small timeout value may cause |
50 # unwanted diconnection when IDE is kept busy for long periods |
53 # unwanted diconnection when IDE is kept busy for long periods |
51 self.daemon.setTimeout(60) |
54 self.daemon.setTimeout(60) |
52 |
55 |
53 pyro_obj=Pyro.core.ObjBase() |
56 pyro_obj = Pyro.core.ObjBase() |
54 pyro_obj.delegateTo(runtime.GetPLCObjectSingleton()) |
57 pyro_obj.delegateTo(runtime.GetPLCObjectSingleton()) |
55 |
58 |
56 self.daemon.connect(pyro_obj, "PLCObject") |
59 self.daemon.connect(pyro_obj, "PLCObject") |
57 |
60 |
58 if self._to_be_published(): |
61 if self._to_be_published(): |
73 def _stop(self): |
76 def _stop(self): |
74 if self.servicepublisher is not None: |
77 if self.servicepublisher is not None: |
75 self.servicepublisher.UnRegisterService() |
78 self.servicepublisher.UnRegisterService() |
76 self.servicepublisher = None |
79 self.servicepublisher = None |
77 self.daemon.shutdown(True) |
80 self.daemon.shutdown(True) |
78 |
|
79 |
|
80 |
|