Simulink RT Instrument – How to set maximum amount of data received with getBufferedData() and how to stream each signal?
I use Instrument with buffer mode and simulating random model with Simulink RT.
Here is the code for initializing instrument:
tg = slrealtime(‘TargetPC1’);
removeAllInstruments(tg);
hInst = slrealtime.Instrument(‘test.mldatx’);
hInst.addSignal({‘test/constant_block’}, 1);
hInst.addSignal({‘test/demux_block’}, 1);
hInst.addSignal({‘test/gain_block’}, 1);
hInst.addSignal({‘test/from_block’}, 1);
hInst.BufferData = true;
addInstrument(tg, hInst)
and getting datas while RT simulation is running with:
buffer_map = getBufferedData(hInst);
buffer_values = buffer_map.values
1 – Since the buffer only clears when I use getBufferedData(), If I don’t use this function for a while, it tooks many seconds to get all the data from buffer, but I only need latest data. Therefore, can I only get latest data and shorten the time or can I decrease the buffer size to shorten the time?
2 – I am adding 4 signals above code, outputs of constant, demux, gain and from blocks, but I can only get gain block’s output signal data and I can validate these 3 signals are not added to target instrument by using validate(hInst, ‘test’) and I can see warnings when I try to add them. I think they are optimized because these blocks is just for a connection, not for a mathematical operation. Is there a way to stream all the signals I have added?
I use Python-MATLAB bridge, so I can’t use callback method too.
Thank you for your time,
KaanI use Instrument with buffer mode and simulating random model with Simulink RT.
Here is the code for initializing instrument:
tg = slrealtime(‘TargetPC1’);
removeAllInstruments(tg);
hInst = slrealtime.Instrument(‘test.mldatx’);
hInst.addSignal({‘test/constant_block’}, 1);
hInst.addSignal({‘test/demux_block’}, 1);
hInst.addSignal({‘test/gain_block’}, 1);
hInst.addSignal({‘test/from_block’}, 1);
hInst.BufferData = true;
addInstrument(tg, hInst)
and getting datas while RT simulation is running with:
buffer_map = getBufferedData(hInst);
buffer_values = buffer_map.values
1 – Since the buffer only clears when I use getBufferedData(), If I don’t use this function for a while, it tooks many seconds to get all the data from buffer, but I only need latest data. Therefore, can I only get latest data and shorten the time or can I decrease the buffer size to shorten the time?
2 – I am adding 4 signals above code, outputs of constant, demux, gain and from blocks, but I can only get gain block’s output signal data and I can validate these 3 signals are not added to target instrument by using validate(hInst, ‘test’) and I can see warnings when I try to add them. I think they are optimized because these blocks is just for a connection, not for a mathematical operation. Is there a way to stream all the signals I have added?
I use Python-MATLAB bridge, so I can’t use callback method too.
Thank you for your time,
Kaan I use Instrument with buffer mode and simulating random model with Simulink RT.
Here is the code for initializing instrument:
tg = slrealtime(‘TargetPC1’);
removeAllInstruments(tg);
hInst = slrealtime.Instrument(‘test.mldatx’);
hInst.addSignal({‘test/constant_block’}, 1);
hInst.addSignal({‘test/demux_block’}, 1);
hInst.addSignal({‘test/gain_block’}, 1);
hInst.addSignal({‘test/from_block’}, 1);
hInst.BufferData = true;
addInstrument(tg, hInst)
and getting datas while RT simulation is running with:
buffer_map = getBufferedData(hInst);
buffer_values = buffer_map.values
1 – Since the buffer only clears when I use getBufferedData(), If I don’t use this function for a while, it tooks many seconds to get all the data from buffer, but I only need latest data. Therefore, can I only get latest data and shorten the time or can I decrease the buffer size to shorten the time?
2 – I am adding 4 signals above code, outputs of constant, demux, gain and from blocks, but I can only get gain block’s output signal data and I can validate these 3 signals are not added to target instrument by using validate(hInst, ‘test’) and I can see warnings when I try to add them. I think they are optimized because these blocks is just for a connection, not for a mathematical operation. Is there a way to stream all the signals I have added?
I use Python-MATLAB bridge, so I can’t use callback method too.
Thank you for your time,
Kaan simulink rt, instrument, hil, logging, streaming MATLAB Answers — New Questions