Is it possible to activate variable forcing (ForceActivated / ForceActivated Value) programmatically via PVI?

Hello,

I am currently developing a Python-based framework for a B&R PLC application using PVI to communicate with the controller.

For the Python side I’m using the wrapper Pvi.py: GitHub - hilch/Pvi.py: Python wrapper for B&R Pvi (process visualization interface) · GitHub .

Through PVI I can successfully read and write process variables using the Python wrapper (pvi.Variable). For example:

var = Variable(task, "AF_AI[6].ModuleOk")
var.value = True

However, the variable is overwritten again during the next PLC cycle because it is updated inside a cyclic task (100 ms). In Automation Studio I can solve this manually by enabling ForceActivated and setting ForceActivated Value in the watch window.

image

What I would like to do is activate this forcing programmatically via PVI, similar to what Automation Studio does when clicking “Force”.

So my questions are:

  1. Is it possible to activate ForceActivated and set ForceActivated Value through PVI?

  2. If so, which PVI API or command should be used to do this?

Currently the Variable object in the Python wrapper exposes attributes such as:

value
status
descriptor
readable
writable

but I do not see any methods related to forcing.

If forcing cannot be controlled via PVI, what would be the recommended approach for automated testing in this situation?

Thanks in advance for any guidance.

@Hans_Jorgen_Gunnar

1 Like

Hi, and welcome to ourCommunity!

Yes it’s possible, but I’m not sure if it’s already integrated into the Python wrapper (I don’t think so).

In general, forcing of IO variables can be done with PVI DLL interface (which is also used by the Python wrapper) by accessing the so-called “link nodes” (via the ANSL variable object):

Additionally, forcing is also possible directly inside the PLC code by using the AsIO library functions:

Best regards!

Hi,

Thanks for the quick response.

I’ll investigate this further. If the Python wrapper doesn’t solve the problem, I’ll likely proceed with the alternative solution you suggested.

Best regards,
Johan

1 Like