Board index FlightGear Development Aircraft

Changing properties?

Questions and discussion about creating aircraft. Flight dynamics, 3d models, cockpits, systems, animation, textures.

Changing properties?

Postby StuartC » Wed Mar 22, 2017 4:49 pm

I am looking for a simple way to change the value of a property depending on the value of another property, so when one changes the other will switch with it.
There is no switch, button knob or 3d object involved. its simple if property A= true then property B needs to change to true.
StuartC
 
Posts: 2763
Joined: Fri Jun 18, 2010 8:18 pm
Location: Arse end of the Universe
Callsign: WF01
Version: 2019.1
OS: W10 64 bit

Re: Changing properties?

Postby Bomber » Wed Mar 22, 2017 5:03 pm

You're spoilt for choice.... but I'd use a table...

0 0
1 1

Simon
"If anyone ever tells you anything about an aeroplane which is so bloody complicated you can't understand it, take it from me - it's all balls" - R J Mitchel
Bomber
 
Posts: 1934
Joined: Fri Dec 14, 2007 7:06 pm
OS: Windows XP and 10

Re: Changing properties?

Postby sanhozay » Wed Mar 22, 2017 5:10 pm

Indeed, and here are the choices if you aren't using JSBSim ...

If it updates a lot, i.e. near frame rate, you can set up a property rule and use a simple gain filter with a gain of 1.0.

http://wiki.flightgear.org/Autopilot_co ... figuration
http://wiki.flightgear.org/Autopilot_co ... .3Cgain.3E

Code: Select all
<filter>
  <type>gain</type>
  <gain>1.0</gain>
  <input>master-property</input>
  <output>slave-property</output>
</filter>

You might also be able to use a "logic" rule if the property is a boolean, e.g.
Code: Select all
<logic>
  <input>master-property</input>
  <output>slave-property</output>
</logic>

(These normally have conditions in them but I think that would work. I haven't tested it).

If it changes less frequently, you can set up a listener in Nasal and set the slave property whenever the master changes, e.g.

Code: Select all
setlistener("master-property", func(node) {
    setprop("slave-property", node.getValue());
}, startup = 1, runtime = 0);

You could also use property aliases in some cases. That might be the simplest, depending on what you are doing, e.g. in -set.xml.

Code: Select all
<engines>
  <engine n="0">
    <carb-temp-degc alias="/fdm/jsbsim/systems/carburettor/carb-temp-degC"/>
    <cht-degc alias="/fdm/jsbsim/propulsion/engine/cht-degC"/>
    <oil-temperature-degc alias="/fdm/jsbsim/propulsion/engine/oil-temperature-degC"/>
  </engine>
</engines>
sanhozay
 
Posts: 1207
Joined: Thu Dec 26, 2013 11:57 am
Location: EGNM
Callsign: G-SHOZ
Version: Git
OS: Ubuntu 16.04

Re: Changing properties?

Postby StuartC » Wed Mar 22, 2017 7:06 pm

its not engine related.

The logic code, does that go in the model.xml?
StuartC
 
Posts: 2763
Joined: Fri Jun 18, 2010 8:18 pm
Location: Arse end of the Universe
Callsign: WF01
Version: 2019.1
OS: W10 64 bit

Re: Changing properties?

Postby sanhozay » Wed Mar 22, 2017 8:43 pm

No, it goes in a separate XML file and it is referenced in the -set.xml file:
http://wiki.flightgear.org/Autopilot_co ... figuration

For example:
https://sourceforge.net/p/flightgear/fg ... ilters.xml

Make sure you assign a number > 100. There are system property rules with low numbers and you don't want to disable them.
sanhozay
 
Posts: 1207
Joined: Thu Dec 26, 2013 11:57 am
Location: EGNM
Callsign: G-SHOZ
Version: Git
OS: Ubuntu 16.04

Re: Changing properties?

Postby StuartC » Wed Mar 22, 2017 9:36 pm

ah, that wont work, its nothing to do with engines or flight control
StuartC
 
Posts: 2763
Joined: Fri Jun 18, 2010 8:18 pm
Location: Arse end of the Universe
Callsign: WF01
Version: 2019.1
OS: W10 64 bit

Re: Changing properties?

Postby Johan G » Fri Mar 24, 2017 7:49 am

That would not be a problem. You can use property rules (updates at frame rate) or autopilot (updates at FDM rate) for anything.* :wink: You need to include them from the aircraft-set.xml file though, see the wiki article Autopilot configuration reference#Adding a configuration to an aircraft (perm).

* Trivia: IIRC the reason that property rules/autopilot should have a index attribute above 100 is that the advanced weather uses a lot of property rules (though probably not the full 100).
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 5546
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 3.0.0
OS: Windows 7, 32 bit

Re: Changing properties?

Postby sanhozay » Fri Mar 24, 2017 8:08 am

Johan G wrote in Fri Mar 24, 2017 7:49 am:* Trivia: IIRC the reason that property rules/autopilot should have a index attribute above 100 is that the advanced weather uses a lot of property rules (though probably not the full 100).

There are four sets, visible in the property tree at sim/systems/property-rule. If the first is overwritten (because you forgot to assign a number), live weather stops working.
sanhozay
 
Posts: 1207
Joined: Thu Dec 26, 2013 11:57 am
Location: EGNM
Callsign: G-SHOZ
Version: Git
OS: Ubuntu 16.04

Re: Changing properties?

Postby Thorsten » Fri Mar 24, 2017 8:46 am

What solution precisely you'd use for best effect depends on the use case, so maybe you just tell us...
Thorsten
 
Posts: 11378
Joined: Mon Nov 02, 2009 8:33 am

Re: Changing properties?

Postby StuartC » Fri Mar 24, 2017 9:01 am

Im trying to manipulate visual settings depending on view. Its a bit of an experiment.
StuartC
 
Posts: 2763
Joined: Fri Jun 18, 2010 8:18 pm
Location: Arse end of the Universe
Callsign: WF01
Version: 2019.1
OS: W10 64 bit

Re: Changing properties?

Postby Thorsten » Fri Mar 24, 2017 10:05 am

And if there's a 1:1 mapping between the original and the derived property - why can't you just use the original property?
Thorsten
 
Posts: 11378
Joined: Mon Nov 02, 2009 8:33 am

Re: Changing properties?

Postby StuartC » Fri Mar 24, 2017 11:25 am

If I select View number X, I want to change visual properties as in filter settings automatically to save going into the rendering options and manually changing things
StuartC
 
Posts: 2763
Joined: Fri Jun 18, 2010 8:18 pm
Location: Arse end of the Universe
Callsign: WF01
Version: 2019.1
OS: W10 64 bit

Re: Changing properties?

Postby Thorsten » Fri Mar 24, 2017 11:29 am

Ah, you want something like IR view automatically on whenever the view number is, say, 7?

I'd use a listener to the view number setting the rendering properties accordingly. Changing view number is rare, that's best handled by a listener rather than by per-frame polling.
Thorsten
 
Posts: 11378
Joined: Mon Nov 02, 2009 8:33 am

Re: Changing properties?

Postby StuartC » Fri Mar 24, 2017 11:33 am

so that would be like this from earlier:-

setlistener("master-property", func(node) {
setprop("slave-property", node.getValue());
}, startup = 1, runtime = 0);

Best in a nasal file or the nasal section of the model xml ?
StuartC
 
Posts: 2763
Joined: Fri Jun 18, 2010 8:18 pm
Location: Arse end of the Universe
Callsign: WF01
Version: 2019.1
OS: W10 64 bit


Return to Aircraft

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], lomar and 4 guests