Skip to content

Class definition

Line

Bases: PviObject

class representing a PVI Line

Typical usage example:

pviConnection = Connection()
line = Line( pviConnection.root, 'LNANSL', CD='LNANSL')
device = Device( line, 'TCP', CD='/IF=TcpIp' )
Source code in pvi\Line.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class Line(PviObject):
    '''class representing a PVI Line

        Typical usage example:
        ```
        pviConnection = Connection()
        line = Line( pviConnection.root, 'LNANSL', CD='LNANSL')
        device = Device( line, 'TCP', CD='/IF=TcpIp' )
        ```
    '''
    def __init__( self, parent : PviObject, name : str, **objectDescriptor: Union[str,int, float]):
        '''
        Args: 
            parent : PVI connection's root object
            name : name of the line in PVI hierarchy, e.g. 'LNANSL'
            objectDescriptor: 
                ANSL : CD='LNANSL'  
                INA2000 : CD='LNINA2'  
                SNMP : CD='LNSNMP'

        '''
        if parent.type != T_POBJ_TYPE.POBJ_PVI:
            raise PviError(12009, self)         
        super().__init__( parent, T_POBJ_TYPE.POBJ_LINE, name, **objectDescriptor)

    def __repr__(self):
        return f"Line( name={self._name}, linkID={self._linkID} )"

descriptor: dict property

object descriptor example:

temperature = Variable( task1, 'gHeating.status.actTemp' )
...
print( "descriptor=", temperature.name)

results in:

descriptor= {'CD': 'gHeating.status.actTemp', 'RF': 0}

errorChanged: Callable property writable

callback for 'error changed'

It is advisable to always check the error status '0' before accessing an object.

Args:
    cb: callback( PviObject, int ) or callback( int )

typical example:

cpu = Cpu( device, 'myArsim', CD='/IP=127.0.0.1' )
...
def cpuErrorChanged( error : int ):
    if error != 0:
        raise PviError(error)

cpu.errorChanged = cpuErrorChanged

evmask: str property writable

event mask in link descriptor

"e": Change in error state "d": Data changes "f": Change to the data format "c": Change to the connection description "p": Progress information about active requests "s": Status changes "u": Change in the user tag string

externalObjects property

PviObject.externalObjects : list of dict get a list of external objects retrieved by POBJ_ACC_LIST_EXTERN

only available with ANSL, not with INA2000

example:

cpu = Cpu( device, 'myArsim', CD='/IP=127.0.0.1' )
...
print("external objects", cpu.externalObjects )

results in:

external objects [{'name': '$$sysconf', 'type': 'Module'}, {'name': '$arlogsys', 'type': 'Module'}
            ...... name': 'visvc', 'type': 'Module'}]

name: str property

hierarchical PVI object name

example:

name= @Pvi/LNANSL/TCP/myArsim/mainlogic/gHeating.status.actTemp

objectName: str property

object name

example:

temperature = Variable( task1, 'gHeating.status.actTemp' )
...
print( "oname=", temperature.name)

results in:

oname= gHeating.status.actTemp

status: dict property writable

PviObject.status read the object's status

example:

cpu = Cpu( device, 'myArsim', CD='/IP=127.0.0.1' )
task1 = Task( cpu, 'mainlogic')
temperature = Variable( task1, 'gHeating.status.actTemp' )
...
print("status=", cpu.status )

results in:

cpu.status= {'ST': 'WarmStart', 'RunState': 'RUN'}
task1.status {'ST': 'Running'}
temperature.status= {'ST': 'Var', 'SC': 'g'}

type: T_POBJ_TYPE property

object type

example:

temperature = Variable( task1, 'gHeating.status.actTemp' )
...
print( "type=", temperature.type)

results in:

type= T_POBJ_TYPE.POBJ_PVAR

userName: str property

user defined object name defaults to .objectName

userTag: str property writable

user tag

Typical usage example:

temperature = Variable( task1, name='gHeating.status.actTemp', UT="actual water temperature" )        

version: str property

PviObject.version read the object's version

__init__(parent, name, **objectDescriptor)

Parameters:

Name Type Description Default
parent

PVI connection's root object

required
name

name of the line in PVI hierarchy, e.g. 'LNANSL'

required
objectDescriptor Union[str, int, float]

ANSL : CD='LNANSL'
INA2000 : CD='LNINA2'
SNMP : CD='LNSNMP'

{}
Source code in pvi\Line.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def __init__( self, parent : PviObject, name : str, **objectDescriptor: Union[str,int, float]):
    '''
    Args: 
        parent : PVI connection's root object
        name : name of the line in PVI hierarchy, e.g. 'LNANSL'
        objectDescriptor: 
            ANSL : CD='LNANSL'  
            INA2000 : CD='LNINA2'  
            SNMP : CD='LNSNMP'

    '''
    if parent.type != T_POBJ_TYPE.POBJ_PVI:
        raise PviError(12009, self)         
    super().__init__( parent, T_POBJ_TYPE.POBJ_LINE, name, **objectDescriptor)

kill()

PviObject.kill: kills this object this should be called when object is not beeing used anymore to save PVI resources

Source code in pvi\Object.py
468
469
470
471
472
473
474
475
476
477
478
479
480
481
def kill(self):
    '''
    PviObject.kill: kills this object
    this should be called when object is not beeing used anymore
    to save PVI resources
    '''
    if self._linkID != 0 and self._connection != None:

        self._connection._linkIDs.pop(self._linkID) # remove from linkIDs
        self._connection._pviObjects.remove(self) # remove from PviObjects
        self._result = PviXUnlink(self._hPvi, self._linkID)
        self._linkID = 0
        if self._result != 0 and self._result != 12045:
            raise PviError(self._result, self)