Oscilloscope addon: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(11 intermediate revisions by 2 users not shown)
Line 19: Line 19:
I thought I'd toss this out there in case someone thought it was worth while enough to tackle.<ref>{{cite web |url=http://www.mail-archive.com/flightgear-devel@flightgear.org/msg03651.html |title=idea ... (?)|author=Curtis Olson |date=Fri, 08 Mar 2002 07:43:35 -0800}}</ref>|Curtis Olson}}
I thought I'd toss this out there in case someone thought it was worth while enough to tackle.<ref>{{cite web |url=http://www.mail-archive.com/flightgear-devel@flightgear.org/msg03651.html |title=idea ... (?)|author=Curtis Olson |date=Fri, 08 Mar 2002 07:43:35 -0800}}</ref>|Curtis Olson}}


= Instalation =
= How to install =
{{note |    This is the latest version (Jan 30, 2018)<br />
{{note |    This is the latest version (Jan 30, 2018)<br />
}}
}}
Line 26: Line 26:
:::<pre style="color: darkgreen"> fgfs <usual args> --addon=/path/to/fgaddon/Oscilloscope</pre>{{note |    From version 2017.4.0, the FG launcher accepts the ''--addon'' option in his ''Settings/Additional Settings'' tab.<br />
:::<pre style="color: darkgreen"> fgfs <usual args> --addon=/path/to/fgaddon/Oscilloscope</pre>{{note |    From version 2017.4.0, the FG launcher accepts the ''--addon'' option in his ''Settings/Additional Settings'' tab.<br />
}}Otherwise, you can install it as a submodule. Contact the author for further instructions.
}}Otherwise, you can install it as a submodule. Contact the author for further instructions.
= How to use =
== Manual mode ==
Just pressing the {{key press|o}} key the oscilloscope window appears:
[[File:Oscilloscope (default skin).png|center]] Clicking the {{key press|  ?  }} button you'll have a basic help about ''clickable areas'' and ''readings''. (click {{key press|  ?  }} again to close help)
=== Connecting Channel Sources ===
[[File:Source dialog.png|right|Channel Source input dialog.]]
Click any BNC connector (Channel 1 or Channel 2) to open the input dialog.<br />
Enter a valid source as:
* <u>a Numeric or boolean Property address</u>
::  eg.: ''/position/altitude-agl-ft''
* <u>a Numeric Nasal expression</u>
::  eg.: ''getprop("/engines/engine/rpm") /100 ;'' (do not forget the {{key press|;}})
::  eg.: ''0 ;'' (only useful to adjust Offset)
::  eg.: ''5+4*math.sin(D2R*int(100*systime())) ;''
Since the oscilloscope's time is the simulated one, simulation must not be paused in order to see the resulted plottings.<br />
The reading window above the connector will display the current source value.
=== Adjusting Channel Gain and Offset ===
Clicking the Gain knobs (upper/lower half) will increase/decrease the Channel's Gain.<br />
The reading window below the knob will display the current gain (units/div).<br />
The Offset knobs respond in a similar way.
=== Adjusting Timebase ===
Proceed in the same way with the Timebase knob. The reading window below the knob will display the current sweep speed (secs/div).
=== One Shot store ===
Clicking this button will erase the screen and prepare Channel 2 to act as trigger.<br />
Channel 2 must be an Integer or Boolean property. Once its value changes, a single sweep is triggered and the screen freezes.<br />
Click this button again in order to return to the default continuous sweeps.
== Script mode ==
Instead of launching the oscilloscope with the {{key press|o}} key and clicking buttons and knobs, it is possible to instantiate the instrument from a Nasal script.<br />
Open the Nasal Console (or the REPL interpreter if you prefer) and execute these lines:
<syntaxhighlight lang="nasal">var Osc = oscilloscope.show.new();
var myFunc = func {return 10+4*math.sin(D2R*int(100*systime()));};
Osc.setTimeBase(0.2);
Osc.setChannelInput(2,'/controls/engines/engine/magnetos');
Osc.setChannelInput(1, myFunc);
Osc.setGain(channel:1, gain:2);
Osc.setGain(channel:2, gain:2);
</syntaxhighlight>
Please note that buttons and knobs are still reacting to manual clickings.<br />
You can explore other nasal instructions like:
<syntaxhighlight lang="nasal">
Osc.setChannelInput(2, func {return 5.5;});
Osc.setChannelInput(1, 'var alt = getprop("/position/altitude-ft"); return alt/10;');
</syntaxhighlight>
= Behind the scene =
= Related =
{{Appendix}}

Revision as of 20:00, 31 January 2018

WIP.png Work in progress
This article or section will be worked on in the upcoming hours or days.
Note: Although still incomplete, the information it contains is valid and available.
See history for the latest developments.
This screenshot shows the usual c172p "magnetos checking" Channel 1 (yellow) is rpm (100 rpm / div).Channel 2 (mauve) is magnetos (1 / div).Time sweep is 200 ms / div.[1]

This oscilloscope was created as an example of the use of 3 helpers included in the addon:

*  skinnable.nas to create Canvas GUI dialogs including multiple clickable layers.
*  graph.nas to create various types of Canvas instruments.[2]
*  plot2D.nas the very basic Canvas helpers.
But apart from that, the oscilloscope itself may be an useful tool for developers and coders. Although I do not know any aircraft that has this instrument in its panel, the on-board engineer will eventually appreciate having it on hand at some point. 

Background

Cquote1.png I was just thinking today that it might be cool to have a built in grapher for simple / quick graphing needs.

With the property system it would be trivial to pick an arbitrary property from the property tree and graph it over time -- superimposed on top of everything else. Things get a bit trickier if you want to control scaling, how much time history get's graphed, multiple values, etc., but even graphing a single value (or maybe just two values) over time could be of some use.

I thought I'd toss this out there in case someone thought it was worth while enough to tackle.[3]
— Curtis Olson
Cquote2.png

How to install

Note  This is the latest version (Jan 30, 2018)

If your FGFS version accepts Addons, you can download this feature from the Addons Repository. Download all the 11 files into the directory of your choice. Launch FlightGear including --addon argument, eg.:

 fgfs <usual args> --addon=/path/to/fgaddon/Oscilloscope
Note  From version 2017.4.0, the FG launcher accepts the --addon option in his Settings/Additional Settings tab.

Otherwise, you can install it as a submodule. Contact the author for further instructions.

How to use

Manual mode

Just pressing the o key the oscilloscope window appears:

Oscilloscope (default skin).png

Clicking the ? button you'll have a basic help about clickable areas and readings. (click ? again to close help)

Connecting Channel Sources

Channel Source input dialog.

Click any BNC connector (Channel 1 or Channel 2) to open the input dialog.
Enter a valid source as:

  • a Numeric or boolean Property address
eg.: /position/altitude-agl-ft
  • a Numeric Nasal expression
eg.: getprop("/engines/engine/rpm") /100 ; (do not forget the ;)
eg.: 0 ; (only useful to adjust Offset)
eg.: 5+4*math.sin(D2R*int(100*systime())) ;

Since the oscilloscope's time is the simulated one, simulation must not be paused in order to see the resulted plottings.
The reading window above the connector will display the current source value.

Adjusting Channel Gain and Offset

Clicking the Gain knobs (upper/lower half) will increase/decrease the Channel's Gain.
The reading window below the knob will display the current gain (units/div).
The Offset knobs respond in a similar way.

Adjusting Timebase

Proceed in the same way with the Timebase knob. The reading window below the knob will display the current sweep speed (secs/div).

One Shot store

Clicking this button will erase the screen and prepare Channel 2 to act as trigger.
Channel 2 must be an Integer or Boolean property. Once its value changes, a single sweep is triggered and the screen freezes.
Click this button again in order to return to the default continuous sweeps.

Script mode

Instead of launching the oscilloscope with the o key and clicking buttons and knobs, it is possible to instantiate the instrument from a Nasal script.
Open the Nasal Console (or the REPL interpreter if you prefer) and execute these lines:

var Osc = oscilloscope.show.new();
var myFunc = func {return 10+4*math.sin(D2R*int(100*systime()));};
Osc.setTimeBase(0.2);
Osc.setChannelInput(2,'/controls/engines/engine/magnetos');
Osc.setChannelInput(1, myFunc);
Osc.setGain(channel:1, gain:2);
Osc.setGain(channel:2, gain:2);

Please note that buttons and knobs are still reacting to manual clickings.

You can explore other nasal instructions like:

Osc.setChannelInput(2, func {return 5.5;});
Osc.setChannelInput(1, 'var alt = getprop("/position/altitude-ft"); return alt/10;');

Behind the scene

Related

References
  1. rleibner  (Jan 6th, 2018).  Re: Plot2D and graph helpers .
  2. rleibner  (Dec 27th, 2017).  Re: Spoken GCA .
  3. Curtis Olson (Fri, 08 Mar 2002 07:43:35 -0800). idea ... (?).