andrej@1511: #!/usr/bin/env python andrej@1511: # -*- coding: utf-8 -*- andrej@1511: Edouard@2270: from __future__ import absolute_import Edouard@2270: import traceback andrej@1667: Edouard@2270: from runtime.Worker import worker Edouard@2270: MainWorker = worker() andrej@1511: Edouard@2270: from runtime.PLCObject import PLCObject andrej@1667: Edouard@2270: _PLCObjectSingleton = None etisserant@49: Edouard@2270: def GetPLCObjectSingleton(): Edouard@2270: global _PLCObjectSingleton Edouard@2270: assert(_PLCObjectSingleton is not None) Edouard@2270: return _PLCObjectSingleton Edouard@2270: Edouard@2270: Edouard@2270: def LogMessageAndException(msg, exp=None): Edouard@2270: global _PLCObjectSingleton Edouard@2270: if exp is None: Edouard@2270: exp = sys.exc_info() Edouard@2270: if _PLCObjectSingleton is not None: Edouard@2270: _PLCObjectSingleton.LogMessage(0, msg + '\n'.join(traceback.format_exception(*exp))) Edouard@2307: print(msg) Edouard@2307: traceback.print_exception(*exp) Edouard@2270: Edouard@2270: def CreatePLCObjectSingleton(*args): Edouard@2270: global _PLCObjectSingleton Edouard@2270: _PLCObjectSingleton = PLCObject(*args)