Howto talk:Development of the CDU: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
No edit summary
Line 43: Line 43:
--[[User:Hooray|Hooray]] 22:31, 2 December 2010 (UTC)
--[[User:Hooray|Hooray]] 22:31, 2 December 2010 (UTC)


== Generality of the CDU ==
= Generality of the CDU =


CDUs differ from aircraft type to aircraft type. [[User:Gijs|Gijs]] started the [[CDU]] for a Boeing 747-400 based upon the documentation he had for that airplane. I personally have access to a '''B777 FMS PILOT'S GUIDE''' which I will use to guide me in my decisions.... Hopefully people can live with a "mixed up" CDU for the moment (as compared to ''no'' CDU) and interested parties can separate the internal workings later...  
CDUs differ from aircraft type to aircraft type. [[User:Gijs|Gijs]] started the [[CDU]] for a Boeing 747-400 based upon the documentation he had for that airplane. I personally have access to a '''B777 FMS PILOT'S GUIDE''' which I will use to guide me in my decisions.... Hopefully people can live with a "mixed up" CDU for the moment (as compared to ''no'' CDU) and interested parties can separate the internal workings later...  


--[[User:Hcc23|Hcc23]] 22:32, 2 December 2010 (UTC)
--[[User:Hcc23|Hcc23]] 22:32, 2 December 2010 (UTC)

Revision as of 22:33, 2 December 2010

Nasal in XML files (command bindings)

Note that Nasal scripts embedded in XML should be wrapped in <![CDATA[ ... ]]> markup:

 <![CDATA[ print("Foo");  ]]>

--Hooray 21:42, 2 December 2010 (UTC)

Thanks for that advice. But shouldn't there be a > somewhere? Could you please correct this example (in a new version below)?

<animation> 
	<type>pick</type>
	<object-name>Btn.zero</object-name>
	<action>
		<button>0</button>
		<repeatable>false</repeatable>  
		<binding>
			<command>nasal</command>
			<script><![CDATA[
                         setprop("/instrumentation/cdu/input",getprop("/instrumentation/cdu/input")~'0');
                       ]]></script>
		</binding>
	</action>
</animation>

--Hcc23 22:16, 2 December 2010 (UTC)

Implementing LSK logics

"The most cumbersome buttons are the line select keys. As their function depends on the current state of the CDU, 
 the corresponding XML requires some conditional checks."

I think, we actually talked about this previously on the forums. Instead of using lots of nested XML logics to model a CDU (or any complex instrument), it is actually better to just use the property tree for communicating "events" (e.g. button presses). This would then make it possible for a Nasal script to handle ALL logics (using a registered listener), so that a FSM (finite state machine) can be implemented in Nasal space, this is more flexible than a purely XML-based approach, and could also be more easily reused by other aircraft and developers. My personal suggestion would be to refrain from modeling advanced logics in XML space, while it is certainly possible to do so to a certain degree, the corresponding building blocks are relicts from an era where Nasal scripting was not yet available.--Hooray 22:31, 2 December 2010 (UTC)


Loading external Nasal files from XML files

There is code to do this in $FG_ROOT/Nasal/io.nas - namely the function "load_nasal(filename, namespace)". io.nas contains some comments. Basically, this allows you to reference/load and run separate Nasal modules, without having to embed all of the code directly in the XML markup. So it's a good practice and makes things easier:

 <binding>
 <command>nasal<command>
 <script><![CDATA[
    io.load_nasal("lsk.nas","lsk");
 ]]></script>
 </binding>

--Hooray 22:31, 2 December 2010 (UTC)

Generality of the CDU

CDUs differ from aircraft type to aircraft type. Gijs started the CDU for a Boeing 747-400 based upon the documentation he had for that airplane. I personally have access to a B777 FMS PILOT'S GUIDE which I will use to guide me in my decisions.... Hopefully people can live with a "mixed up" CDU for the moment (as compared to no CDU) and interested parties can separate the internal workings later...

--Hcc23 22:32, 2 December 2010 (UTC)