How do I write an If into a IPG variable instead of a switch in CM4SL?

I am currently developing an IPG model in Simulink to simulate the Driver Aids of a Formula Student car.
The problem I am facing is that I want to write a 0 into a variable (PT.Control.Engine.Trq_trq) given certain condition, but when that condition does not fulfill I want the variable to remain as IPG calculates it.
By using an If block, IPG gives me an error about subsystems conflict. Also I tried by writing the same variable (PT.Control.Engine.Trq_trq) in a switch into the same variable, but it did not work.
Right now I am using the structure in the figure. Does anyone know how to implement this?
Thank you,

Hi Alberto, thanks for your question.

You should be able to use both the switch approach (see below):

and the “if” block approach:

I have tested the 2 configurations in the screenshots above and they are equivalent (the Engine Torque Target calculated internally by CM is used for the first 10s and after that a 0 target torque is assigned).

The details of the implementation, i.e. which CM signals you need to read/write, depend on the powertrain configuration you are using. In the example above I used the Examples/DemoCar with a convetional powertrain. However to be able to use the PT.Control.GasInterpret.Trq_trg and PT.Control.Engine.Trq_trg signals, the Gas Interpreter option needs to be selected in the PT Control tab:

I hope this helps.