Skip to content

Class definition

Connection

class representing a connection to PVI manager

Typical usage example:

    pviConnection = Connection() # start a Pvi connection (to local PVI manager)

    # in case of a PVI remote connection:
    # pviConnection = Connection( timeout=15, IP='172.20.43.59', PN=20000 ) # start a remote Pvi connection

    line = Line( pviConnection.root, 'LNANSL', CD='LNANSL')  


Source code in pvi\Connection.py
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
class Connection():
    '''
    class representing a connection to PVI manager

    Typical usage example:

    ```
        pviConnection = Connection() # start a Pvi connection (to local PVI manager)

        # in case of a PVI remote connection:
        # pviConnection = Connection( timeout=15, IP='172.20.43.59', PN=20000 ) # start a remote Pvi connection

        line = Line( pviConnection.root, 'LNANSL', CD='LNANSL')  


    ```
    '''
    # ----------------------------------------------------------------------------------
    def __init__(self, **kwargs : Union[str,int, float] ):
        """Initializes the connection to PVI manager

        Args:
            kwargs:
                timeout : timeout in [s] to PVI manager instance

                IP : ip address or host name for remote connection

                PN : port number for remote connection

                COMT : communication timeout
        """
        timeout = int(kwargs.get('timeout', 5 ))
        self._eventLoopIsRunning = False
        self._startTime = datetime.datetime.now()
        self._objectsArranged = False
        self._pviObjects = []
        self._rootObject = PviObject(None, T_POBJ_TYPE.POBJ_PVI, '@Pvi')

        self._linkIDs = {}
        self._hPvi = wintypes.DWORD(0)
        self._connected = None

        initParameter = ""
        if 'IP' in kwargs:
            initParameter = initParameter + 'IP=' + str(kwargs['IP']) + ' '
        if 'PN' in kwargs:
            initParameter = initParameter + 'PN=' + str(kwargs['PN']) + ' '
        if 'COMT' in kwargs:
            initParameter = initParameter + 'COMT=' + str(kwargs['COMT']) + ' '

        self._result = PviXInitialize( byref(self._hPvi), timeout, 0, initParameter, None )
        debuglog(f'PviXInitialize( {timeout}, 0, "{initParameter}", NULL)')

        if self._result == 0:
            self._rootObject._connection = self
            self._rootObject._hPvi = self._hPvi
            self.link(self._rootObject)
            # set global events
            for m in (POBJ_EVENT_PVI_CONNECT, POBJ_EVENT_PVI_DISCONN, POBJ_EVENT_PVI_ARRANGE):
                self._result = PviXSetGlobEventMsg( self._hPvi, m, PVI_HMSG_NIL, SET_PVIFUNCTION, 0 )
                if self._result != 0:
                    raise PviError(self._result)
        else:
            raise PviError(self._result)

    # ----------------------------------------------------------------------------------
    def __repr__(self):
        return f"Connection()"

    # ----------------------------------------------------------------------------------
    def __del__(self):
        PviXDeinitialize(self._hPvi)

    # ----------------------------------------------------------------------------------
    @property
    def hPvi(self) ->wintypes.DWORD:
        """
        Returns:
            wintypes.DWORD: handle for PviX.. functions
        """
        return self._hPvi

    # ----------------------------------------------------------------------------------
    @property
    def root(self) ->PviObject:
        """
        Returns:
           PviObject: the base object 'Pvi'
        """
        return self._rootObject

    @property
    def license(self) -> tuple:
        """read PVI license information

        Returns:
            A tuple( state, hardware, license, dongle, license-name )

        where    
        state is 'undefined' or 'trial' or 'runtime' or 'developer' or 'locked',  
        hardware is = 'B&R IPC' or 'PC',  
        license is 'B&R License' or '',  
        dongle is 'Pvi Dongle' or '',  
        license-name is a string  

        result may be ```('undefined', '', '', '', '', '')``` if PVI root object is not yet linked.

        """
        li = T_PVI_INFO_LICENCE()
        if self.root._linkID == 0: # root object not yet valid
            return ('undefined', '', '', '', '', '' )

        self._result = PviXRead( self._hPvi, self.root._linkID, POBJ_ACC_INFO_LICENCE  , None, 0, byref(li), sizeof(li) )
        if self._result == 0:
            try: 
                state = ('undefined', 'trial', 'runtime', 'developer', 'locked')[li.PviWorkState0]
                hardware = 'B&R IPC' if li.PviWorkState1 and 0x01 else 'PC'
                burlicence = 'B&R License' if li.PviWorkState1 and 0x02 else ''
                dongle = 'Pvi Dongle' if li.PviWorkState1 and 0x04 else ''
                return state, hardware, burlicence, dongle, str(li.LcName)
            except IndexError:
                pass
        else:
            raise PviError(self._result, self )
        return ('undefined', '', '', '', '', '' )

    # ----------------------------------------------------------------------------------
    def link(self, *args ):
        """
        registers new PviObject(s)

        *args : PviObject of list of PviObjects
        """
        for o in args:
            if isinstance(o, PviObject):
                self._pviObjects.append(o)
                if self._objectsArranged:
                    o._createAndLink(self)
            elif isinstance(o, list ):
                for oo in o:
                    self.link(oo)
            else:
                raise ValueError("only PviObject or list of PviObjects allowed !")
    # ----------------------------------------------------------------------------------

    def findObjectByName(self, name : str) ->PviObject :
        for o in self._pviObjects:
            if o.name == name:
                return o
        raise KeyError('PviObject not found by name')

    # ----------------------------------------------------------------------------------

    def findObjectByLinkID(self, linkID : wintypes.DWORD) ->PviObject :
        for o in self._pviObjects:
            if o._linkID == linkID:
                return o
        raise KeyError('PviObject not found by LinkID')      

    @property
    def connectionChanged(self) -> Optional[Callable]:
        """
        callback for 'connected to PVI-Manger'

            Args:
                cb: callback(status : bool) 

                where status is 'True' if connected, 'False' if disconnected

        typical example:

        ```
        pviConnection = Connection(IP="192.168.182.128") # start a remote Pvi connection

        pviConnection.connectionChanged = lambda s : print("connected" if s else "disconnected")
        ```
        """
        return self._connected


    @connectionChanged.setter
    def connectionChanged(self, cb : Callable):
        """
        set callback for 'connected to PVI-Manger'
        """
        if callable(cb):
            self._connected = cb
        else:
            raise TypeError("only callable allowed for Connection.connected")


    # ----------------------------------------------------------------------------------

    def _eventPviConnect( self, wParam, responseInfo ):
        """
        handle PVI connect event
        """
        debuglog("POBJ_EVENT_PVI_CONNECT")
        self._result = PviXReadResponse( self._hPvi, wParam, None, 0 )
        if self._connected:
            self._connected(True)

    # ----------------------------------------------------------------------------------
    def _eventPviDisconnect( self, wParam, responseInfo ):
        """
        handle PVI disconnect event
        """      
        self._result = PviXReadResponse( self._hPvi, wParam, None, 0 )
        self._pviObjects.clear()
        self._linkIDs.clear()
        self._objectsArranged = False
        if self._connected:
            self._connected(False)

    # ----------------------------------------------------------------------------------
    def _eventPviArrange( self, wParam, responseInfo ): 
        """
        handle pvi arrange event
        """
        self._pviTrialTimeCheck = None

        self._result = PviXReadResponse( self._hPvi, wParam, None, 0 )                
        debuglog("POBJ_EVENT_PVI_ARRANGE")

        # create and link objects
        for po in self._pviObjects:
            po._createAndLink(self)
        self._objectsArranged = True

    # ----------------------------------------------------------------------------------
    def _eventOther( self, wParam, responseInfo ):
        """
        handle other events
        """
        self._result = PviXReadResponse( self._hPvi, wParam, None, 0 )

    # ----------------------------------------------------------------------------------
    def doEvents(self):
        """         
        event loop - must be cyclically called

        typical usage example:

        ```
        pviConnection = Connection()
            ....
        while run:  
            pviConnection.doEvents()  
        ```
        """     
        wParam = WPARAM()
        lParam = LPARAM()
        hMsg = HANDLE()
        dataLen = wintypes.DWORD()      
        self._result = PviXGetNextResponse( self._hPvi, byref(wParam), byref(lParam), byref(hMsg), None )

        if wParam.value != 0:
            responseInfo = T_RESPONSE_INFO()
            self._result = PviXGetResponseInfo( self._hPvi, wParam, None, byref(dataLen), byref(responseInfo), sizeof(responseInfo) )

            # if responseInfo.ErrCode != 0:
            #     po = self.findObjectByLinkID(responseInfo.LinkID)
            #     print(f'{po.name} : nMode = {responseInfo.nMode}, nType = {responseInfo.nType}, ErrCode = {responseInfo.ErrCode}')

            if responseInfo.nType == POBJ_EVENT_PVI_CONNECT:
                self._eventPviConnect( wParam, responseInfo )
            elif responseInfo.nType == POBJ_EVENT_PVI_DISCONN:
                self._eventPviDisconnect( wParam, responseInfo )
            elif responseInfo.nType == POBJ_EVENT_PVI_ARRANGE:
                self._eventPviArrange( wParam, responseInfo )
            elif responseInfo.nType == POBJ_ACC_TYPE:
                po = self._linkIDs.get(responseInfo.LinkID, None )
                if po:
                    po._eventDataType( wParam, responseInfo )
                else:
                    raise ValueError("linkID not found !")
            elif responseInfo.nType == POBJ_EVENT_DATA:
                po = self._linkIDs.get(responseInfo.LinkID, None )
                if po:
                    po._eventData( wParam, responseInfo )
                else:
                    raise ValueError("linkID not found !")                    
            elif responseInfo.nType == POBJ_ACC_UPLOAD_STM:
                po = self._linkIDs.get(responseInfo.LinkID, None )
                if po:
                    po._eventUploadStream( wParam, responseInfo, dataLen.value ) 
                else:
                    raise ValueError("linkID not found !")
            elif responseInfo.nType == POBJ_ACC_DOWNLOAD_STM:
                po = self._linkIDs.get(responseInfo.LinkID, None )
                if po:
                    po._eventDownloadStream( wParam, responseInfo ) 
                else:
                    raise ValueError("linkID not found !") 
            elif responseInfo.nType == POBJ_EVENT_STATUS or responseInfo.nType == POBJ_ACC_STATUS:
                po = self._linkIDs.get(responseInfo.LinkID, None )
                if po:
                    po._eventStatus( wParam, responseInfo )
                else:
                    raise ValueError("linkID not found !")                   
            elif responseInfo.nType == POBJ_EVENT_PROCEEDING:
                po = self._linkIDs.get(responseInfo.LinkID, None )
                if po:
                    po._eventProceeding( wParam, responseInfo ) 
                else:
                    raise ValueError("linkID not found !")   
            elif responseInfo.nType == POBJ_ACC_LN_XML_LOGM_DATA:
                po = self._linkIDs.get(responseInfo.LinkID, None )
                if po:
                    po._eventUploadLogData( wParam, responseInfo, dataLen.value ) 
                else:
                    raise ValueError("linkID not found !") 
            elif responseInfo.nType == POBJ_ACC_MOD_DATA:
                po = self._linkIDs.get(responseInfo.LinkID, None )
                if po:
                    po._eventUploadModData( wParam, responseInfo, dataLen.value ) 
                else:
                    raise ValueError("linkID not found !")                                                                    
            elif responseInfo.nType == POBJ_EVENT_ERROR:
                po = self._linkIDs.get(responseInfo.LinkID, None )
                if po:
                    debuglog( f'{repr(po)}: error {responseInfo.ErrCode}')
                    po._eventError( wParam, responseInfo )
                else:
                    raise ValueError("linkID not found !")
            else:
                self._eventOther( wParam, responseInfo )
                # po = self.findObjectByLinkID(responseInfo.LinkID)
                # print(f'{po.name} : nMode = {responseInfo.nMode}, nType = {responseInfo.nType}, ErrCode = {responseInfo.ErrCode}')                


   # ----------------------------------------------------------------------------------
    def start(self, callback : Union[Callable,None] = None ):
        """         
        start event loop

        Args:
            callback :  function that will be cyclically called in event loop or 'None'.
                        callback is called with one boolean argument which signals the
                        first call with 'True' all subsequent calls will be done with
                        argument 'False'

        typical usage example:

        ```
        pviConnection = Connection()

        def runtimeMonitor( init : bool ):
            if datetime.datetime.now() - startTime > datetime.timedelta(seconds = 10):
                print("done !")
                pviConnection.stop() # exit

        pviConnection.start( runtimeMonitor )
        ```
        """
        self._eventLoopIsRunning = True
        if( callback ) : callback(True)
        while( self._eventLoopIsRunning ):
            sleep(0.05)
            if( callback ) : callback(False)
            self.doEvents()

    # ----------------------------------------------------------------------------------
    def stop(self):
        """
        stop event loop
        typical usage example:

        ```
        pviConnection = Connection()
          ....
        pviConnection.stop()  
        ```
        """
        self._eventLoopIsRunning = False
   # ----------------------------------------------------------------------------------
    def sleep( self, millis : int ):
        """
        helper function for waiting actions
        typical usage example:

        Args:
            millis: sleep time in milliseconds
        ```
        pviConnection = Connection()
            ....
        pviConnection.sleep(2000) # pause code for 2 seconds  
        ```   
        """
        t1 = datetime.datetime.now()
        while True:
            self.doEvents()
            if (datetime.datetime.now() - t1) >= datetime.timedelta( microseconds= millis*1000):
                break

connectionChanged: Optional[Callable] property writable

callback for 'connected to PVI-Manger'

Args:
    cb: callback(status : bool)

    where status is 'True' if connected, 'False' if disconnected

typical example:

pviConnection = Connection(IP="192.168.182.128") # start a remote Pvi connection

pviConnection.connectionChanged = lambda s : print("connected" if s else "disconnected")

hPvi: wintypes.DWORD property

Returns:

Type Description
DWORD

wintypes.DWORD: handle for PviX.. functions

license: tuple property

read PVI license information

Returns:

Type Description
tuple

A tuple( state, hardware, license, dongle, license-name )

where
state is 'undefined' or 'trial' or 'runtime' or 'developer' or 'locked',
hardware is = 'B&R IPC' or 'PC',
license is 'B&R License' or '',
dongle is 'Pvi Dongle' or '',
license-name is a string

result may be ('undefined', '', '', '', '', '') if PVI root object is not yet linked.

root: PviObject property

Returns:

Name Type Description
PviObject PviObject

the base object 'Pvi'

__init__(**kwargs)

Initializes the connection to PVI manager

Parameters:

Name Type Description Default
kwargs Union[str, int, float]

timeout : timeout in [s] to PVI manager instance

IP : ip address or host name for remote connection

PN : port number for remote connection

COMT : communication timeout

{}
Source code in pvi\Connection.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
def __init__(self, **kwargs : Union[str,int, float] ):
    """Initializes the connection to PVI manager

    Args:
        kwargs:
            timeout : timeout in [s] to PVI manager instance

            IP : ip address or host name for remote connection

            PN : port number for remote connection

            COMT : communication timeout
    """
    timeout = int(kwargs.get('timeout', 5 ))
    self._eventLoopIsRunning = False
    self._startTime = datetime.datetime.now()
    self._objectsArranged = False
    self._pviObjects = []
    self._rootObject = PviObject(None, T_POBJ_TYPE.POBJ_PVI, '@Pvi')

    self._linkIDs = {}
    self._hPvi = wintypes.DWORD(0)
    self._connected = None

    initParameter = ""
    if 'IP' in kwargs:
        initParameter = initParameter + 'IP=' + str(kwargs['IP']) + ' '
    if 'PN' in kwargs:
        initParameter = initParameter + 'PN=' + str(kwargs['PN']) + ' '
    if 'COMT' in kwargs:
        initParameter = initParameter + 'COMT=' + str(kwargs['COMT']) + ' '

    self._result = PviXInitialize( byref(self._hPvi), timeout, 0, initParameter, None )
    debuglog(f'PviXInitialize( {timeout}, 0, "{initParameter}", NULL)')

    if self._result == 0:
        self._rootObject._connection = self
        self._rootObject._hPvi = self._hPvi
        self.link(self._rootObject)
        # set global events
        for m in (POBJ_EVENT_PVI_CONNECT, POBJ_EVENT_PVI_DISCONN, POBJ_EVENT_PVI_ARRANGE):
            self._result = PviXSetGlobEventMsg( self._hPvi, m, PVI_HMSG_NIL, SET_PVIFUNCTION, 0 )
            if self._result != 0:
                raise PviError(self._result)
    else:
        raise PviError(self._result)

doEvents()

event loop - must be cyclically called

typical usage example:

pviConnection = Connection()
    ....
while run:  
    pviConnection.doEvents()  
Source code in pvi\Connection.py
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
def doEvents(self):
    """         
    event loop - must be cyclically called

    typical usage example:

    ```
    pviConnection = Connection()
        ....
    while run:  
        pviConnection.doEvents()  
    ```
    """     
    wParam = WPARAM()
    lParam = LPARAM()
    hMsg = HANDLE()
    dataLen = wintypes.DWORD()      
    self._result = PviXGetNextResponse( self._hPvi, byref(wParam), byref(lParam), byref(hMsg), None )

    if wParam.value != 0:
        responseInfo = T_RESPONSE_INFO()
        self._result = PviXGetResponseInfo( self._hPvi, wParam, None, byref(dataLen), byref(responseInfo), sizeof(responseInfo) )

        # if responseInfo.ErrCode != 0:
        #     po = self.findObjectByLinkID(responseInfo.LinkID)
        #     print(f'{po.name} : nMode = {responseInfo.nMode}, nType = {responseInfo.nType}, ErrCode = {responseInfo.ErrCode}')

        if responseInfo.nType == POBJ_EVENT_PVI_CONNECT:
            self._eventPviConnect( wParam, responseInfo )
        elif responseInfo.nType == POBJ_EVENT_PVI_DISCONN:
            self._eventPviDisconnect( wParam, responseInfo )
        elif responseInfo.nType == POBJ_EVENT_PVI_ARRANGE:
            self._eventPviArrange( wParam, responseInfo )
        elif responseInfo.nType == POBJ_ACC_TYPE:
            po = self._linkIDs.get(responseInfo.LinkID, None )
            if po:
                po._eventDataType( wParam, responseInfo )
            else:
                raise ValueError("linkID not found !")
        elif responseInfo.nType == POBJ_EVENT_DATA:
            po = self._linkIDs.get(responseInfo.LinkID, None )
            if po:
                po._eventData( wParam, responseInfo )
            else:
                raise ValueError("linkID not found !")                    
        elif responseInfo.nType == POBJ_ACC_UPLOAD_STM:
            po = self._linkIDs.get(responseInfo.LinkID, None )
            if po:
                po._eventUploadStream( wParam, responseInfo, dataLen.value ) 
            else:
                raise ValueError("linkID not found !")
        elif responseInfo.nType == POBJ_ACC_DOWNLOAD_STM:
            po = self._linkIDs.get(responseInfo.LinkID, None )
            if po:
                po._eventDownloadStream( wParam, responseInfo ) 
            else:
                raise ValueError("linkID not found !") 
        elif responseInfo.nType == POBJ_EVENT_STATUS or responseInfo.nType == POBJ_ACC_STATUS:
            po = self._linkIDs.get(responseInfo.LinkID, None )
            if po:
                po._eventStatus( wParam, responseInfo )
            else:
                raise ValueError("linkID not found !")                   
        elif responseInfo.nType == POBJ_EVENT_PROCEEDING:
            po = self._linkIDs.get(responseInfo.LinkID, None )
            if po:
                po._eventProceeding( wParam, responseInfo ) 
            else:
                raise ValueError("linkID not found !")   
        elif responseInfo.nType == POBJ_ACC_LN_XML_LOGM_DATA:
            po = self._linkIDs.get(responseInfo.LinkID, None )
            if po:
                po._eventUploadLogData( wParam, responseInfo, dataLen.value ) 
            else:
                raise ValueError("linkID not found !") 
        elif responseInfo.nType == POBJ_ACC_MOD_DATA:
            po = self._linkIDs.get(responseInfo.LinkID, None )
            if po:
                po._eventUploadModData( wParam, responseInfo, dataLen.value ) 
            else:
                raise ValueError("linkID not found !")                                                                    
        elif responseInfo.nType == POBJ_EVENT_ERROR:
            po = self._linkIDs.get(responseInfo.LinkID, None )
            if po:
                debuglog( f'{repr(po)}: error {responseInfo.ErrCode}')
                po._eventError( wParam, responseInfo )
            else:
                raise ValueError("linkID not found !")
        else:
            self._eventOther( wParam, responseInfo )

registers new PviObject(s)

*args : PviObject of list of PviObjects

Source code in pvi\Connection.py
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
def link(self, *args ):
    """
    registers new PviObject(s)

    *args : PviObject of list of PviObjects
    """
    for o in args:
        if isinstance(o, PviObject):
            self._pviObjects.append(o)
            if self._objectsArranged:
                o._createAndLink(self)
        elif isinstance(o, list ):
            for oo in o:
                self.link(oo)
        else:
            raise ValueError("only PviObject or list of PviObjects allowed !")

sleep(millis)

helper function for waiting actions typical usage example:

Parameters:

Name Type Description Default
millis int

sleep time in milliseconds

required
pviConnection = Connection()
    ....
pviConnection.sleep(2000) # pause code for 2 seconds  
Source code in pvi\Connection.py
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
def sleep( self, millis : int ):
    """
    helper function for waiting actions
    typical usage example:

    Args:
        millis: sleep time in milliseconds
    ```
    pviConnection = Connection()
        ....
    pviConnection.sleep(2000) # pause code for 2 seconds  
    ```   
    """
    t1 = datetime.datetime.now()
    while True:
        self.doEvents()
        if (datetime.datetime.now() - t1) >= datetime.timedelta( microseconds= millis*1000):
            break

start(callback=None)

start event loop

Parameters:

Name Type Description Default
callback

function that will be cyclically called in event loop or 'None'. callback is called with one boolean argument which signals the first call with 'True' all subsequent calls will be done with argument 'False'

None

typical usage example:

pviConnection = Connection()

def runtimeMonitor( init : bool ):
    if datetime.datetime.now() - startTime > datetime.timedelta(seconds = 10):
        print("done !")
        pviConnection.stop() # exit

pviConnection.start( runtimeMonitor )
Source code in pvi\Connection.py
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
def start(self, callback : Union[Callable,None] = None ):
    """         
    start event loop

    Args:
        callback :  function that will be cyclically called in event loop or 'None'.
                    callback is called with one boolean argument which signals the
                    first call with 'True' all subsequent calls will be done with
                    argument 'False'

    typical usage example:

    ```
    pviConnection = Connection()

    def runtimeMonitor( init : bool ):
        if datetime.datetime.now() - startTime > datetime.timedelta(seconds = 10):
            print("done !")
            pviConnection.stop() # exit

    pviConnection.start( runtimeMonitor )
    ```
    """
    self._eventLoopIsRunning = True
    if( callback ) : callback(True)
    while( self._eventLoopIsRunning ):
        sleep(0.05)
        if( callback ) : callback(False)
        self.doEvents()

stop()

stop event loop typical usage example:

pviConnection = Connection()
  ....
pviConnection.stop()  
Source code in pvi\Connection.py
395
396
397
398
399
400
401
402
403
404
405
406
def stop(self):
    """
    stop event loop
    typical usage example:

    ```
    pviConnection = Connection()
      ....
    pviConnection.stop()  
    ```
    """
    self._eventLoopIsRunning = False