# HG changeset patch # User ed # Date 1260111356 -3600 # Node ID e050ef5bd28508d92c575d36fdb38f840ec1a2c3 # Parent fd316d2babd5b5008068fffb5014a6ac75b49791 Refactoring in PLCobject, for PLC that do not use python plugin diff -r fd316d2babd5 -r e050ef5bd285 runtime/PLCObject.py --- a/runtime/PLCObject.py Sun Dec 06 15:54:22 2009 +0100 +++ b/runtime/PLCObject.py Sun Dec 06 15:55:56 2009 +0100 @@ -95,8 +95,8 @@ self._startPLC.restype = ctypes.c_int self._startPLC.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.c_char_p)] - self.DummyIteratorLock = Lock() - self.DummyIteratorLock.acquire() + self._stopPLC_real = self.PLClibraryHandle.stopPLC + self._stopPLC_real.restype = None self._PythonIterator = getattr(self.PLClibraryHandle, "PythonIterator", None) if self._PythonIterator is not None: @@ -105,24 +105,27 @@ def StopPLCLock(): self.PLClibraryLock.acquire() - self.PLClibraryHandle.stopPLC() + self._stopPLC_real() self.PLClibraryLock.release() else: - def DummyIterator(res): - self.DummyIteratorLock.acquire() - self.DummyIteratorLock.release() + # If python plugin is not enabled, we reuse _PythonIterator + # as a call that block pythonthread until StopPLC + self.PythonIteratorLock = Lock() + self.PythonIteratorLock.acquire() + def PythonIterator(res): + self.PythonIteratorLock.acquire() + self.PythonIteratorLock.release() return None - self._PythonIterator = DummyIterator + self._PythonIterator = PythonIterator def StopPLCLock(): self.PLClibraryLock.acquire() - self.PLClibraryHandle.stopPLC() - self.DummyIteratorLock.release() + self._stopPLC_real() + self.PythonIteratorLock.release() self.PLClibraryLock.release() self._stopPLC = StopPLCLock - self._stopPLC.restype = None self._ResetDebugVariables = self.PLClibraryHandle.ResetDebugVariables self._ResetDebugVariables.restype = None @@ -374,6 +377,7 @@ Return a list of variables, corresponding to the list of required idx """ if self.PLCStatus == "Started": + res=[] self.PLClibraryLock.acquire() tick = ctypes.c_uint32() size = ctypes.c_uint32()