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.

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!

2 Likes

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

Hi,

with PVI (and Pvi.py) it is possible to write to the force value (‘F+’ syntax).

It is also possible to read the status of the forcing with POBJ_ACC_STATUS.

Unfortunately it is not allowed to change (e.g. to write to) the forcing status.

To my knowledge, forcing can only be enabled with Automation Studio (and by the FB Alex mentioned), but I’m happy to be corrected.

Find example attached.

linknode.txt (1.5 KB)

3 Likes

Hi Alexander,

Do you know if it’s possible to activate “ForceActivated” using the AsIO library?
If so, do you happen to have an example of how to do it?

Do you know if it’s possible to activate “ForceActivated” using the AsIO library?

if you mean how to get the status of forcing: use AsIODPStatus()

1 Like

I wanna activate the “ForceActivated” according to the picture. This is the last piece of the puzzel, the rest I have implemented / figure out.

Currently using: AsIOEnableForcing.

ForceActivated

Hi @Johan_Elfing,

as Christoph mentioned, you can query the force status by AsIODPStatus(), the FB output “.flags” contains this information:

2 Likes

to our knowledge that is exactly the way you have to follow.

Either use Automation Studio or this function block.

1 Like

Thanks alot for the help I made it work :).
@alexander.hefner @christoph.hilchenbac

2 Likes