public void OnDestroy() { try { try { if (sensationCoreInterop_ != null) { sensationCoreInterop_.uhsclRelease(sensationCoreInstancePtr_); sensationCoreInterop_ = null; SensationCore.Instance = null; sensationCoreInstancePtr_ = default(IntPtr); } } catch { ReleaseEmitter(); sensationCoreInterop_.uhsclRelease(sensationCoreInstancePtr_); sensationCoreInterop_ = null; SensationCore.Instance = null; sensationCoreInstancePtr_ = default(IntPtr); } } catch (Exception e) { UCA.Logger.LogInfo("Exception when destroying SensationCore: " + e); } }
private void ApplySearchPath(ISensationCoreInterop interop, IntPtr sclInstance, string path) { if (!setSearchPaths_.Contains(path)) { interop.uhsclAddSearchPath(sclInstance, path); setSearchPaths_.Add(path); } }
public LogStreamReader(ISensationCoreInterop sensationCoreInterop) { uhsclGetLogInfoMessageBufferSize_ = sensationCoreInterop.uhsclGetLogInfoMessageBufferSize; uhsclGetLogInfoMessageBufferAndClear_ = sensationCoreInterop.uhsclGetLogInfoMessageBufferAndClear; uhsclGetLogWarningMessageBufferSize_ = sensationCoreInterop.uhsclGetLogWarningMessageBufferSize; uhsclGetLogWarningMessageBufferAndClear_ = sensationCoreInterop.uhsclGetLogWarningMessageBufferAndClear; uhsclGetLogErrorMessageBufferSize_ = sensationCoreInterop.uhsclGetLogErrorMessageBufferSize; uhsclGetLogErrorMessageBufferAndClear_ = sensationCoreInterop.uhsclGetLogErrorMessageBufferAndClear; }
public void CreateSensationCore(ISensationCoreInterop SensationCoreInterop = null) { try { if (SensationCore.Instance == null) { if (SensationCoreInterop == null) { sensationCoreInterop_ = new SensationCoreInterop(); sensationCoreInterop_ = new LockDecorator(sensationCoreInterop_); sensationCoreInterop_ = new ThrowOnErrorDecorator(sensationCoreInterop_); sensationCoreInterop_ = new ForwardLogMessagesDecorator(sensationCoreInterop_, new LogStreamReader(sensationCoreInterop_)); } else { sensationCoreInterop_ = SensationCoreInterop; } sensationCoreInstancePtr_ = sensationCoreInterop_.uhsclCreate(); if (sensationCoreInstancePtr_ == default(IntPtr)) { throw new Exception("Failed to initialise SensationCore library"); } foreach (var method in onSensationCoreInitializeUserMethods_) { try { method.Invoke(null, null); } catch (Exception ex) { UCA.Logger.LogWarning("Failed executing OnSensationCoreInitialize Method : " + method.Name + "\n" + ex.InnerException ?? ex.Message); } } pythonSearchPaths_.ResetApplied(); pythonSearchPaths_.Apply(sensationCoreInterop_, sensationCoreInstancePtr_); pythonSearchPaths_.DisplayWarningIfNoSearchPathsAreValid(); Instance = this; if (Application.isPlaying) { UCA.Logger.LogInfo("SensationCore Successfully Created"); } } } catch (Exception e) { UCA.Logger.LogInfo("Exception creating SensationCore: " + e); } }
public void Apply(ISensationCoreInterop interop, IntPtr sclInstance) { ApplySearchPath(interop, sclInstance, DefaultSearchPath); foreach (var path in AdditionalSearchPaths) { ApplySearchPath(interop, sclInstance, path); } LoadPythonModulesInPath(interop, sclInstance, DefaultSearchPath); foreach (var path in AdditionalSearchPaths) { LoadPythonModulesInPath(interop, sclInstance, path); } }
private void LoadPythonModulesInPath(ISensationCoreInterop interop, IntPtr sclInstance, string path) { if (Directory.Exists(path)) { foreach (string file in System.IO.Directory.GetFiles(path)) { if (Path.GetExtension(file) == ".py") { var module = Path.GetFileNameWithoutExtension(file); Console.Error.Write("Loading " + module + " ... "); try { interop.uhsclImportPythonModule(sclInstance, module); Console.Error.WriteLine("success"); } catch { Console.Error.WriteLine("failed"); } } } } }
public InteropDecoratorTemplate(ISensationCoreInterop interop) { interop_ = interop; }
public ThrowOnErrorDecorator(ISensationCoreInterop interop) { interop_ = interop; }
public ForwardLogMessagesDecorator(ISensationCoreInterop interop, ILogStreamReader logStreamReader) { interop_ = interop; logStreamReader_ = logStreamReader; }
public LockDecorator(ISensationCoreInterop interop) { interop_ = interop; }