New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue with the function "getComponentsTest" of the Scripting library #7594
Comments
@felix-marsollier2, version 1.16.5 is quite obsolete now, I'd suggest you to use 1.17.0 I guess you get an error because @adrpo, I am a bit confused by these API function names. I could not find |
Hi Francesco Casella,
Thank you for the quick response. I used return in the example but i tried
with other words with the same results. I cannot capture the output.
I would like to swicht to the 1.17 but with the dynamically linked
libraries, the exe is no longer portable with is required for us. I'm
waiting for the commit be able to switch between static and dynamic.
In any case, thanks a lot for this free and powerfull software.
The number of users are continuously growing at the EDF compagny.
Sincerely
Félix marsollier
Le lun. 21 juin 2021 à 23:48, Francesco Casella ***@***.***>
a écrit :
… @felix-marsollier2 <https://github.com/felix-marsollier2>, version 1.16.5
is quite obsolete now, I'd suggest you to use 1.17.0
I guess you get an error because return is a Modelica language keword,
see Section 2.3.3
<https://specification.modelica.org/maint/3.5/lexical-structure.html#modelica-keywords>
of the language spec.
@adrpo <https://github.com/adrpo>, I am a bit confused by these API
function names. I could not find getComponents in the API guide
<https://openmodelica.org/doc/OpenModelicaUsersGuide/latest/scripting_api.html>,
and what does getComponentsTest mean? Is it a test function? Does it
retrieve test cases for components? Can you shed some light here? Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7594 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AO47M6N3GOAXLHSHCFINN6DTT6XUTANCNFSM47B76OXA>
.
|
getComponentsTest wasn't updated for the new instantiation, it seems. It hasn't been touched since it was added in 2015. getComponents is not typed API and cannot be used to assign the result to variables or do anything useful with it (unless you use ZMQ and manually parse the results). |
The problem is that the documentation does not explain what this API function does. @sjoelund do you know that? Could we add a short explanation? And why the "Test" in the name? |
I think it was only used to see if OMEdit could use it. The problem is getComponents uses the Interactive.mo API which cannot be used in OMPython or mos-scripts. |
So we have a test function which is documented and gets used by end-users 2015, while the real function cannot. Hmm. |
I think getComponentsTest was added as a test to see if we can have a typed API for getComponents. As far as I know we don't use it anywhere. @adeas31, is this the case? As for the interactive API we don't have documentation for it as it should be internal. We need to redo the entire API properly as currently is a mess. |
Note that the documentation happens automatically for all functions in the ModelicaBuiltin.mo file. Maybe we should have annotations on which ones should not show up in the documentation. |
Who do you mean by "we"? I mean, it's documented in the User's Guide, so people will use it, as @felix-marsollier2's case proves. And I guess we are not supposed to removed it point-blank at some point, lest some of our users get stuck using Stone Age versions of OMC because they found it useful but it's no longer supported :) If it works, it should be properly documented, explaining what it does. If if doesn't, it should be fixed or removed. If it only does partially, we should explain this in the documentation.
Use at your own risk :)
I agree, but I'm afraid this wont' happen anytime soon. In the meantime, I'd try to clarify the situation with this specific case, if it is not too complicated. |
That's one possibility, but we shouldn't remove the ones that have been publicly available and documented for years, unless there are compelling reasons to do so. |
By "we" I mean any of our clients: OMEdit, OMNotebook, MDT, OMShell, OMPython, OMJulia, etc. |
OK, now I get it, sorry. If it is really broken for good, and it's always been, I'm fine to remove it. Maybe it just doesn't work with the example cited by @felix-marsollier2, which is quite involved, since it uses the Multibody library. In that case, since it's been public for some time, we should rather fix it. @felix-marsollier2, have you used this function successfully in other cases? |
I have tried this function with the example from the Thermal and the Fluid libraries of the MSL and with my own library and nothing worked. |
@felix-marsollier2 you don't need to do that, I'll fix getComponentsTest as it is documented and we have at least one user. |
And I will also add a test for it this time so we don't break it again without knowing. |
Thanks! Please also add one line to the documentation briefly explaining what it does. |
- make getComponentsTest work with new instantiation and -d=nfAPI - make getComponentsTest work with old instantiation via -d=-newInst
This should now be fixed with PR #7615. Try the build from tomorrow. You need to set some command line options to make it work with the new frontend: |
Ouch, I forgot about that, will try to add it. |
Some more documentation added in #7616. |
It works fine. Thanks the team. |
Description
The function "getComponentsTest" described in the note lastest documentation note returns nothing when called in the command line interpreter of OMEdit of the version 1.16.5 of OpenModelica and under windows 10 using the MSL 3.2.3
However, when using the similar function "getComponents" in the same command line interpreter, it looks to return the right output.
Moreover, when using the function "getComponents", I can't capture the output like: output_list := getComponents(...). I get the following error and I wonder why:
return := getComponents(Modelica.Thermal.HeatTransfer.Examples.TwoMasses)
Error occurred building AST
Syntax Error
[:1:0-1:6:writable] Error: Parser error: Unexpected token near: return (RETURN)
Steps to reproduce
1 - In the Command Line Interpreter, load the Modelica Standard Library V3.2.3 if not automatically loaded
2 - write the statement: getComponentsTest(Modelica.Thermal.HeatTransfer.Examples.TwoMasses)
3 - Write the statement: getComponents(Modelica.Thermal.HeatTransfer.Examples.TwoMasses, , useQuotes = false)
4 - Write the statement: return:=getComponents(Modelica.Thermal.HeatTransfer.Examples.TwoMasses, , useQuotes = false)
Expected behavior
I only want the "sub" class of a given class and its name like getSubClasses(Modelica.Thermal.HeatTransfer.Examples.TwoMasses) => {{Modelica.SIunits.Temperature,T_final}, {Modelica.Thermal.HeatTransfer.Components.HeatCapacitor,mass1},...}. Thus I think that the getComponentsTest function is the most appropriate.
Version and OS
The text was updated successfully, but these errors were encountered: