public void Compile(string componentUid, string script)
        {
            if (componentUid == null)
            {
                throw new ArgumentNullException(nameof(componentUid));
            }
            if (script == null)
            {
                throw new ArgumentNullException(nameof(script));
            }

            _scriptHost = _pythonScriptHostFactoryService.CreateScriptHost(_logger, new ComponentPythonProxy(componentUid, _componentRegistryService));
            _scriptHost.SetVariable("publish_adapter_message", (PythonDelegates.CallbackWithResultDelegate)OnMessageReceived);
            _scriptHost.AddToWirehomeWrapper("publish_adapter_message", (PythonDelegates.CallbackWithResultDelegate)OnMessageReceived);

            _scriptHost.Compile(script);
        }
示例#2
0
        public void Compile(string componentUid, string script)
        {
            if (componentUid == null)
            {
                throw new ArgumentNullException(nameof(componentUid));
            }
            if (script == null)
            {
                throw new ArgumentNullException(nameof(script));
            }

            _scriptHost = _pythonScriptHostFactoryService.CreateScriptHost(_logger, new ComponentPythonProxy(componentUid, _componentRegistryService));
            _scriptHost.SetVariable("publish_adapter_message", (PythonDelegates.CallbackWithResultDelegate)OnAdapterMessagePublished);
            _scriptHost.AddToWirehomeWrapper("publish_adapter_message", (PythonDelegates.CallbackWithResultDelegate)OnAdapterMessagePublished);

            // TODO: Consider adding debugger here and move enable/disable/getTrace to IComponentLogic and enable via HTTP API.

            _scriptHost.Compile(script);
        }