diff -r 89549813a6c1 -r 0b3ac94f494c connectors/WAMP/__init__.py --- a/connectors/WAMP/__init__.py Sat Nov 25 00:18:05 2023 +0100 +++ b/connectors/WAMP/__init__.py Thu Dec 07 22:41:32 2023 +0100 @@ -35,7 +35,6 @@ from autobahn.wamp.exception import TransportLost from autobahn.wamp.serializer import MsgPackSerializer -from runtime import PlcStatus _WampSession = None _WampConnection = None @@ -56,14 +55,6 @@ print('WAMP session left') -PLCObjDefaults = { - "StartPLC": False, - "GetTraceVariables": ("Broken", None), - "GetPLCstatus": (PlcStatus.Broken, None), - "RemoteExec": (-1, "RemoteExec script failed!") -} - - def _WAMP_connector_factory(cls, uri, confnodesroot): """ WAMP://127.0.0.1:12345/path#realm#ID @@ -107,26 +98,6 @@ AddToDoBeforeQuit(reactor.stop) reactor.run(installSignalHandlers=False) - def WampSessionProcMapper(funcname): - wampfuncname = str('.'.join((ID, funcname))) - - def catcher_func(*args, **kwargs): - if _WampSession is not None: - try: - return threads.blockingCallFromThread( - reactor, _WampSession.call, wampfuncname, - *args, **kwargs) - except TransportLost: - confnodesroot.logger.write_error(_("Connection lost!\n")) - confnodesroot._SetConnector(None) - except Exception: - errmess = traceback.format_exc() - confnodesroot.logger.write_error(errmess+"\n") - print(errmess) - # confnodesroot._SetConnector(None) - return PLCObjDefaults.get(funcname) - return catcher_func - class WampPLCObjectProxy(object): def __init__(self): global _WampConnection @@ -144,10 +115,30 @@ # # reactor.stop() + def WampSessionProcMapper(self, funcname): + wampfuncname = str('.'.join((ID, funcname))) + + def catcher_func(*args, **kwargs): + if _WampSession is not None: + try: + return threads.blockingCallFromThread( + reactor, _WampSession.call, wampfuncname, + *args, **kwargs) + except TransportLost: + confnodesroot.logger.write_error(_("Connection lost!\n")) + confnodesroot._SetConnector(None) + except Exception: + errmess = traceback.format_exc() + confnodesroot.logger.write_error(errmess+"\n") + print(errmess) + # confnodesroot._SetConnector(None) + return self.PLCObjDefaults.get(funcname) + return catcher_func + def __getattr__(self, attrName): member = self.__dict__.get(attrName, None) if member is None: - member = WampSessionProcMapper(attrName) + member = self.WampSessionProcMapper(attrName) self.__dict__[attrName] = member return member