OML Custom Block - API's

João Marabisa
João Marabisa
Altair Employee
edited October 2020 in Community Q&A

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"?>icond.thumb.png.8a6976df049f46b4669e232dc6123854.png

 

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

  • L Moretti
    L Moretti New Altair Community Member
    edited July 2020

    Hello Joao,

     

    I could not reproduce your issue. Can you post your .scm model as well?

     

    Thanks,

     

    Lorenzo

  • Fady Nassif_21652
    Fady Nassif_21652
    Altair Employee
    edited July 2020

    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

  • João Marabisa
    João Marabisa
    Altair Employee
    edited July 2020

    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"?>image.thumb.png.e9f2f22e701502a4665d43ef9be68078.png 

     

    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.

    Unable to find an attachment - read this blog

  • robertavarela
    robertavarela New Altair Community Member
    edited July 2020

    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

  • João Marabisa
    João Marabisa
    Altair Employee
    edited July 2020

    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' />

  • robertavarela
    robertavarela New Altair Community Member
    edited July 2020