Finally, with the help of the Speedgoat Support, I can change the color of the lamp depending on the signal (for V2020b) directly, without the need for a Guage as intermidiate step.
My solution lines:
app.hInst = slrealtime.Instrument(app.mdl);
app.hInst.connectScalar(app.OnTargetLamp,[app.mdl '/RIG_Control'],1, 'PropertyName', 'Color', 'Callback', @app.Lampper);
function color=Lampper (~,~,d)
if d
color=[0,1,0];
else
color=[1,0,0];
end
end
As I store the Instrumentation object on the App variables, the syntax can be slightly different than normal, but I also but the generic syntax below for future reference:
app.hInst = slrealtime.Instrument('Simulink Model');
app.hInst.connectScalar('-GUI Lamp','-Block Path','-IO number', 'PropertyName', 'Color', 'Callback', @'app.-fcnName');
function '-dummy out variable'= '-fcnName'(app,time,signal)
'algorithm to deal with the signal'
end
If you want to change more than one item, but all with the same effect. You can scale the connectScalar line to the different App Items.
If you want to have different behaviours for the same signal. Maybe use the addSignal + connectCallBack method.
Best Answer