Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As I mentioned previously in #885 (comment), I'm currently working on adding the NRLMSIS2.0 atmospheric model to JSBSim which is kind of a revival of the existing
src/models/atmosphere/FGMSIS.cpp
code (which was based on the previous version 1.0 of NRLMSIS)1.In order for this feature to work, we will need to modify the atmosphere model that is currently created by default in
FGFDMExec
:jsbsim/src/FGFDMExec.cpp
Line 229 in 39e7058
Basically, the idea is to call at some point the following code:
The trick is that if no special care is taken, the properties
atmosphere/T-R
,atmosphere/P-Psf
, etc. will still be bound to the old instance ofFGStandardAtmosphere
even after the above code has been executed. With the current code,FGMSIS
would fail to bind itself to the aforementioned properties as they would already be tied toFGStandardAtmosphere
and JSBSim would complain with the infamous error messageFailed to tie property atmosphere/T-R to object methods
. Even worse, if one would try to accessatmosphere/T-R
and the likes, it would cause a SEGFAULT as the property would try to call the methodFGAtmosphere::GetTemperature()
on a deletedFGStandardAtmopshere
instance.To avoid this issue, we need to tell JSBSim to unbind
FGStandardAtmosphere
before an instance ofFGMSIS
is created. Currently there is no generic code in JSBSim that allows to unbind a singleFGModel
instance (you'd need to untie the properties one by one which is less than ideal from a maintenance standpoint).To address this issue the current PR adds a new method
FGPropertyManager::Unbind(void* instance)
to unbind the properties of a given class instance. With this new method, the code above will become something like:The new
Unbind
method also restores the read/write attributes of each properties as the newly bound instance might want to set them differently.Finally, the unit test
FGAtmosphereTest
is amended by the PR to test the new feature and checks that the properties suchatmosphere/T-R
are tied to the correct instance (see the methodtestRun()
inFGAmosphereTest
).Footnotes
For the record the code in
FGMSIS.cpp
is dead code as there is currently no means to execute this code from JSBSim. ↩