$isCodeGen flag

The $isCodeGen flag is a built-in variable that detects whether you are generating code from a diagram or if you are simply using the diagram in a simulation. In the SIL and PIL phases, the controller (either host- or target-based) receives sensor inputs from the plant diagram residing on the host. When the diagram is migrated to the HIL phase, sensor inputs may be received from the actual sensors. In this situation the $isCodeGen flag can be used to select when to use actual sensor inputs as opposed to inputs from the plant diagram residing on the host, which in turn, would allow one controller diagram to be used for SIL, PIL, and HIL.