equal
deleted
inserted
replaced
101 # Event to signal when PLC is stopped. |
101 # Event to signal when PLC is stopped. |
102 self.PlcStopped = Event() |
102 self.PlcStopped = Event() |
103 self.PlcStopped.set() |
103 self.PlcStopped.set() |
104 |
104 |
105 self._init_blobs() |
105 self._init_blobs() |
|
106 |
|
107 # initialize extended calls with GetVersions call, ignoring arguments |
|
108 self.extended_calls = {"GetVersions":lambda *_args:self.GetVersions().encode()} |
106 |
109 |
107 # First task of worker -> no @RunInMain |
110 # First task of worker -> no @RunInMain |
108 def AutoLoad(self, autostart): |
111 def AutoLoad(self, autostart): |
109 # Get the last transfered PLC |
112 # Get the last transfered PLC |
110 try: |
113 try: |
816 self._suspendDebug(True) # Disable debugger |
819 self._suspendDebug(True) # Disable debugger |
817 break |
820 break |
818 |
821 |
819 self.TraceThread = None |
822 self.TraceThread = None |
820 |
823 |
821 def RemoteExec(self, script, *kwargs): |
|
822 try: |
|
823 exec(script, kwargs) |
|
824 except Exception: |
|
825 _e_type, e_value, e_traceback = sys.exc_info() |
|
826 line_no = traceback.tb_lineno(get_last_traceback(e_traceback)) |
|
827 return (-1, "RemoteExec script failed!\n\nLine %d: %s\n\t%s" % |
|
828 (line_no, e_value, script.splitlines()[line_no - 1])) |
|
829 return (0, kwargs.get("returnVal", None)) |
|
830 |
|
831 def GetVersions(self): |
824 def GetVersions(self): |
832 return platform_module.system() + " " + platform_module.release() |
825 return platform_module.system() + " " + platform_module.release() |
833 |
826 |
|
827 @RunInMain |
|
828 def ExtendedCall(self, method, argument): |
|
829 """ Dispatch argument to registered service """ |
|
830 return self.extended_calls[method](argument) |
|
831 |
|
832 def RegisterExtendedCall(method, callback): |
|
833 self.extended_calls[method] = callback |
|
834 |
|
835 def UnregisterExtendedCall(method): |
|
836 del self.extended_calls[method] |
|
837 |