42 _PySrv = None |
42 _PySrv = None |
43 _WampConf = None |
43 _WampConf = None |
44 _WampSecret = None |
44 _WampSecret = None |
45 |
45 |
46 ExposedCalls = [ |
46 ExposedCalls = [ |
47 "StartPLC", |
47 ("StartPLC", {}), |
48 "StopPLC", |
48 ("StopPLC", {}), |
49 "ForceReload", |
49 ("ForceReload", {}), |
50 "GetPLCstatus", |
50 ("GetPLCstatus", {}), |
51 "NewPLC", |
51 ("NewPLC", {}), |
52 "MatchMD5", |
52 ("MatchMD5", {}), |
53 "SetTraceVariablesList", |
53 ("SetTraceVariablesList", {}), |
54 "GetTraceVariables", |
54 ("GetTraceVariables", {}), |
55 "RemoteExec", |
55 ("RemoteExec", {}), |
56 "GetLogMessage", |
56 ("GetLogMessage", {}), |
57 "ResetLogCount", |
57 ("ResetLogCount", {}) |
58 ] |
58 ] |
59 |
|
60 ExposedProgressCalls = [] |
|
61 |
59 |
62 # Those two lists are meant to be filled by customized runtime |
60 # Those two lists are meant to be filled by customized runtime |
63 # or User python code. |
61 # or User python code. |
64 |
62 |
65 """ crossbar Events to register to """ |
63 """ crossbar Events to register to """ |
106 @inlineCallbacks |
104 @inlineCallbacks |
107 def onJoin(self, details): |
105 def onJoin(self, details): |
108 global _WampSession |
106 global _WampSession |
109 _WampSession = self |
107 _WampSession = self |
110 ID = self.config.extra["ID"] |
108 ID = self.config.extra["ID"] |
111 validRegisterOptions = {} |
109 |
112 |
110 for name, kwargs in ExposedCalls: |
113 registerOptions = self.config.extra.get('registerOptions', None) |
111 try: |
114 if registerOptions: |
112 registerOptions = types.RegisterOptions(**kwargs) |
115 arguments = inspect.getargspec(types.RegisterOptions.__init__).args |
113 except TypeError as e: |
116 validRegisterOptions = getValidOptins(registerOptions, arguments) |
114 registerOptions = None |
117 if validRegisterOptions: |
115 print(_("TypeError register option: {}".format(e))) |
118 registerOptions = types.RegisterOptions(**validRegisterOptions) |
116 |
119 #print(_("Added custom register options")) |
|
120 |
|
121 for name in ExposedCalls: |
|
122 yield self.register(GetCallee(name), u'.'.join((ID, name)), registerOptions) |
117 yield self.register(GetCallee(name), u'.'.join((ID, name)), registerOptions) |
123 |
|
124 if ExposedProgressCalls: |
|
125 validRegisterOptions["details_arg"] = 'details' |
|
126 registerOptions = types.RegisterOptions(**validRegisterOptions) |
|
127 # using progress, details argument must be added |
|
128 for name in ExposedProgressCalls: |
|
129 yield self.register(GetCallee(name), u'.'.join((ID, name)), registerOptions) |
|
130 |
118 |
131 for name in SubscribedEvents: |
119 for name in SubscribedEvents: |
132 yield self.subscribe(GetCallee(name), unicode(name)) |
120 yield self.subscribe(GetCallee(name), unicode(name)) |
133 |
121 |
134 for func in DoOnJoin: |
122 for func in DoOnJoin: |