Emesary MFD bridge: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
Line 37: Line 37:
== Instantiating a MFD Dialog ==
== Instantiating a MFD Dialog ==
{{Main article|Howto:Creating a Canvas GUI dialog file}}
{{Main article|Howto:Creating a Canvas GUI dialog file}}
<syntaxhighlight lang="nasal">
var (width,height) = (640,480);
var title = 'Canvas MFD/Emesary Bridge';
var window = canvas.Window.new([width,height],"dialog").set('title',title);
##
# the del() function is the destructor of the Window
# which will be called upon termination (dialog closing)
# you can use this to do resource management (clean up timers, listeners or background threads)
#window.del = func()
#{
#  print("Cleaning up window:",title,"\n");
# explanation for the call() technique at: http://wiki.flightgear.org/Object_oriented_programming_in_Nasal#Making_safer_base-class_calls
#  call(canvas.Window.del, [], me);
#};
# adding a canvas to the new window and setting up background colors/transparency
var myCanvas = window.createCanvas().set("background", canvas.style.getColor("bg_color"));
# creating the top-level/root group which will contain all other elements/group
var root = myCanvas.createGroup();
</syntaxhighlight>





Revision as of 18:09, 14 October 2017

This article is a stub. You can help the wiki by expanding it.

Objective

Document ongoing talks and ideas about using the Emesary framework to provide a sane interfacing mechanism for Canvas based avionics (and lower-level MapStructure building blocks) using Richard's Canvas MFD Framework.

Background

This is an adapted version of the Garmin GPSMap 196 originally developed by F-JJTH. Here, the whole instrument is entirely set up in XML space without using any Nasal, including buttons/event handling, but also the embedded canvas region that serves as the 'screen'. The idea is to allow arbitrary MFDs to be specified in an aircraft-agnostic fashion, including displays like a PFD, NavDisplay or EFB. For details, please see Canvas Glass Cockpit Efforts.

Over time, the NavDisplay code has become a huge mess - it is far from being easily maintainable, yet it is the most widely used Canvas-based MFD in use today, mainly because it is generic and can be easily reused, which is due to it having been designed using just a standalone GUI dialog.

So there are some lessons to be learnt from the whole experience.

Nasal modules

Use Cases

Design Goals

Screenshot showing a PUI dialog with two NavDisplay instances, featuring support for customizable resolution/size of the ND as well as selectable number of NDs to be shown.

The NavDisplay code is structured to support:

  • GUI-based prototyping and design/testing of layers
  • truly indenpendent instances (an arbitrary number of them)
  • styling of ND layers/components according to aircraft specifics (think Boeing vs. Airbus ND)
  • encapsulate aircraft/system specifics (think differences between fdm, autopilot and route manager)
  • encourage a modular and reusable design of additions, so that all aircraft developers using the framework can benefit automatically

Implementation

We will be hooking up the Canvas MFD framework to a conventional Canvas GUI dialog, so that a MFD instrument can be shown in a standalone GUI dialog. The next step will involve using the Emesary framework to create custom events and actions.

Instantiating a MFD Dialog

1rightarrow.png See Howto:Creating a Canvas GUI dialog file for the main article about this subject.


var (width,height) = (640,480);
var title = 'Canvas MFD/Emesary Bridge';

var window = canvas.Window.new([width,height],"dialog").set('title',title);


##
# the del() function is the destructor of the Window
# which will be called upon termination (dialog closing)
# you can use this to do resource management (clean up timers, listeners or background threads)
#window.del = func()
#{
#  print("Cleaning up window:",title,"\n");
# explanation for the call() technique at: http://wiki.flightgear.org/Object_oriented_programming_in_Nasal#Making_safer_base-class_calls
#  call(canvas.Window.del, [], me);
#};

# adding a canvas to the new window and setting up background colors/transparency
var myCanvas = window.createCanvas().set("background", canvas.style.getColor("bg_color"));

# creating the top-level/root group which will contain all other elements/group
var root = myCanvas.createGroup();


var svgURL = "https://sourceforge.net/p/flightgear/fgaddon/HEAD/tree/trunk/Aircraft/F-15/Nasal/MPCD/MPCD_0_0.svg?format=raw";
var svgFile = http.load(svgURL);

svgFile.done( func(request) {
	debug.dump( request.response );
});

Related

References