Python PVI wrapper : Question Regarding PVI.py

In the modified example, “Coffee Machine” is a data structure as shown in the picture.
If I now want to access the values (e.g., write or read the values), how would I do it? I tried to write a value to the struct, but I received a message saying:

‘Writing of struct not implemented
Variable( name=@Pvi/LNANSL/TCP/myArsim/myProg/myComplexStruct, linkID=212, VT=struct )’

Do I need to implement a method myself? If so, do you maybe have any tips on how to do it and things I need to consider?

Thanks in advance!

Hi there,

first of all for everyone to understand the question: PVI.py is this linked project

That being said, the answer is both in the error message AND the source code: Writing of structures is not implemented in that wrapper: Pvi.py/pvi/Variable.py at main · hilch/Pvi.py · GitHub

So the code only allows writing to basic datatypes. You either have to implement it yourself or work around it with simple variables which you then copy in the cyclic code to the structure.

Hope that helps

BR

Edit: It seems like you can still access single member variables of a struct simply by using the full name:

myProg = Task(myCPU, 'myProg');
RefOffset = Variable(myProg, 'myComplexStruct.positionDataElements[2].EndlessPositionData[0].RefOffset');
2 Likes

Somehow i cant access the value by using the full name. Is there maybe something i am missing?

By this time it would be easier to understand or try myself if you shared the AS project (I have no clue what “the modified example” is. My CoffeeMachine does not contain “myComplexStruct”. Also please share your python file.

Thanks

This is the link to the python file, including the AS file.

Yeah, seems like an array with index range [2…2] still needs to be used like it was a zero based index:

('myComplexStruct.positionDataElements[0].EndlessPositionData[0].RefOffset', 2)

does the trick here

3 Likes