Board index FlightGear Development Nasal

Nasal property flickering

Nasal is the scripting language of FlightGear.

Nasal property flickering

Postby legoboyvdlp » Thu May 18, 2017 1:49 pm

Hi there,

I have made a function in Nasal and it works, but there is a problem.
In the property browser, the property which I did setprop to flickers between 0 and the calculated number.

Code: Select all
var FMGCinit = func {
    setprop("/FMGC/internal/greendot-kts", 0);
    greendot.start();
}
var greendot = maketimer(0.1, func {
    var gwlb = getprop("fdm/jsbsim/inertia/weight-lbs");
    var factor = 0.45359237;
    var kg = (gwlb * factor);
    var alt = getprop("position/altitude-ft");
    var kg2= (kg / 1000);
    var greendot = ((kg2 * 2) + 85);
    setprop("/FMGC/internal/greendot-kts", greendot);
});


A video of the flickering can be found at:
https://files.fm/u/rhx8jemj

I have talked to Richard, and he suggested that repeated calling of FMGCinit(); could cause this problem.
In reply, this is the only place where FMGCinit is called:

Code: Select all
setlistener("/sim/signals/fdm-initialized", func {
    fmgc.FMGCinit();
});


Would anyone have any explanations as to the cause of this? Thanks,
lego
User avatar
legoboyvdlp
 
Posts: 7981
Joined: Sat Jul 26, 2014 2:28 am
Location: Northern Ireland
Callsign: G-LEGO
Version: next
OS: Windows 10 HP

Re: Nasal property flickering

Postby Necolatis » Thu May 18, 2017 2:42 pm

not sure its related to your issue.

But its not very good to have a variable called greendot and at the same time a timer function called the same.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: Nasal property flickering

Postby jam007 » Thu May 18, 2017 3:10 pm

Maybe the property /sim/signals/fdm-initialized is written to in every fdm update cycle.
See setlistener
<runtime=1> The fourth argument is optional, and defaults to 1. This means that the callback function will be executed whenever the property is written to, independent of the value.
jam007
 
Posts: 579
Joined: Sun Dec 16, 2012 11:04 am
Location: Uppsala, Sweden
Callsign: LOOP
Version: 2020.4.0
OS: Ubuntu 22.04

Re: Nasal property flickering

Postby Octal450 » Thu May 18, 2017 3:24 pm

No, it's not, or other functions would be keep running -- I know this is not happening, or the plane would keep shutting down ;)

KR,
Josh
Skillset: JSBsim Flight Dynamics, Systems, Canvas, Autoflight/Control, Instrumentation, Animations
Aircraft: A320-family, MD-11, MD-80, Contribs in a few others

Octal450's GitHub|Launcher Catalog
|Airbus Dev Discord|Octal450 Hangar Dev Discord
User avatar
Octal450
 
Posts: 5583
Joined: Tue Oct 06, 2015 1:51 pm
Location: Huntsville, AL
Callsign: WTF411
Version: next
OS: Windows 11

Re: Nasal property flickering

Postby Octal450 » Thu May 18, 2017 3:37 pm

@legoboyvdlp
Here is your problem:
http://prntscr.com/f9b4df

This keeps calling FMGCinit();

Josh
Skillset: JSBsim Flight Dynamics, Systems, Canvas, Autoflight/Control, Instrumentation, Animations
Aircraft: A320-family, MD-11, MD-80, Contribs in a few others

Octal450's GitHub|Launcher Catalog
|Airbus Dev Discord|Octal450 Hangar Dev Discord
User avatar
Octal450
 
Posts: 5583
Joined: Tue Oct 06, 2015 1:51 pm
Location: Huntsville, AL
Callsign: WTF411
Version: next
OS: Windows 11


Return to Nasal

Who is online

Users browsing this forum: No registered users and 4 guests