OML Custom Block - API's
Hello techs,
I'm facing some challenges using 'OML Custom Block' and that is why I've decided to post here because maybe someone has already had the same questions. I've done a little example to illustrate this (below). /emoticons/default_smile.png' srcset='/emoticons/smile@2x.png 2x' title=':)' width='20' />
1. First of all I'd like to understand if there are differences (or maybe improvements) between somes commands of the API's like: 'vssGetInputData' / 'vssGetInPortData' and 'vssSetOutputData' / 'vssSetOutPortData'. I've done some tests and I have obtained the same results... There is no description on the help regarding these commands (API's in general) and if possible would be nice to add them.
2. Use a Initial Condition on OML Block by the Integrator: I've set a initial condition on the Integrator block and I'd like that these conditions would be read on my Oml Block in the first step. As you could see, it is not being read exactly as a initial condition, it looks like that has already integrated:
<?xml version="1.0" encoding="UTF-8"?>
I've tried to set this on Oml block Parameters as well and it did not work. If it is not clear, I just would like to use de Initial condition (first step) of the integrator as my first 'X array' (used on Oml block) and then continue to integrate. My 'U array' is being read correctly.
Thanks.
Answers
-
Hello Joao,
I could not reproduce your issue. Can you post your .scm model as well?
Thanks,
Lorenzo
0 -
Hello Joao,
To answer your first question, the APIs to be used are vssGetInputData and vssGetOutputData. The others are aliases.
For your second question, as Lorenzo proposed, would you please share the model.
Thanks
Fady
0 -
Hello everyone,
Firstly, thanks for your effort (both Lorenzo and Fady)! For sure I can share with you (attached). /emoticons/default_smile.png' srcset='/emoticons/smile@2x.png 2x' title=':)' width='20' />
There are a few calculates in the model (which I commented) but I think that I'm having problem with the first step, reading the input (I am using 'disp' the show the input vector to debug it), as you could see, the array input is not equal than my integral initial condition:
<?xml version="1.0" encoding="UTF-8"?>
Regarding the aliases, to be honest I had some doubts because on the demos with 'OML Custom Block' different types of API function are used and I was trying to understand the differences between them like 'vssSetOutPortData(block,1,med,vssGetOutputDataType(block,1))' so actually are they all aliases?
Regards.
0 -
It's necessary to add these APIs after getting the input data:
nevprt=vssGetEventCode(block); if flag == vssBlockInitializeFlag elseif flag == vssBlockReinitializeFlag elseif flag == vssBlockTerminateFlag elseif flag == vssBlockOutputUpdateFlag
And before the end of the function:
vssSetOutputData(block,1,y1,vssGetOutputDataType(block,1)); end
Kudos to Patrick Goulding who solved the problem (he is in the forum but I'm not sure about his username)!
Regards,
Roberta
0 -
Just to comment, with those API's mentioned by Roberta (which Patrick suggested us to use) the issue was solved in fact, anyway, it is not clear yet when these API's at the beginning should be used, once in some models (including in demo) just using vssGetInputData directly we can calculate it...
Thanks for you all. /emoticons/default_smile.png' srcset='/emoticons/smile@2x.png 2x' title=':)' width='20' />
0 -