From 8ba026397863570c2cc8c62532edc1ed09cad499 Mon Sep 17 00:00:00 2001 From: vezza Date: Sun, 14 Feb 2021 00:29:20 +0100 Subject: [PATCH] Chrono on ND (both sides) --- Models/FlightDeck/a320.flightdeck.xml | 34 +++++++++++ Models/Instruments/ND/canvas/style.nas | 2 +- Nasal/Panels/clock.nas | 83 +++++++++++++++++++++++++- 3 files changed, 116 insertions(+), 3 deletions(-) diff --git a/Models/FlightDeck/a320.flightdeck.xml b/Models/FlightDeck/a320.flightdeck.xml index cbdbc318..ecd70ab5 100644 --- a/Models/FlightDeck/a320.flightdeck.xml +++ b/Models/FlightDeck/a320.flightdeck.xml @@ -8742,6 +8742,40 @@ + + + pick + chrono_cpt + + + false + + property-cycle + /instrumentation/efis/inputs/CHRONO + 0 + 1 + 2 + + + + + + + pick + chrono_fo + + + false + + property-cycle + /instrumentation/efis[1]/inputs/CHRONO + 0 + 1 + 2 + + + + diff --git a/Models/Instruments/ND/canvas/style.nas b/Models/Instruments/ND/canvas/style.nas index 30c89234..3e6147f2 100644 --- a/Models/Instruments/ND/canvas/style.nas +++ b/Models/Instruments/ND/canvas/style.nas @@ -72,7 +72,7 @@ canvas.NDStyles["Airbus"] = { level_off_alt: "/autopilot/route-manager/vnav/level-off-alt", athr: "/it-autoflight/output/athr", app_mode: "/instrumentation/nd/app-mode", - chrono_node: "/instrumentation/chrono", + chrono_node: "/instrumentation/ndchrono", fpln_offset: "/autopilot/route-manager/offset", active_route_color: [0.0509,0.7529,0.2941], inactive_route_color: [0.95,0.95,0.21] diff --git a/Nasal/Panels/clock.nas b/Nasal/Panels/clock.nas index 558cac2c..30985b60 100644 --- a/Nasal/Panels/clock.nas +++ b/Nasal/Panels/clock.nas @@ -1,8 +1,10 @@ # -# Chrono - Clock - ET +# Chrono - Clock - ET # var chr = aircraft.timer.new("instrumentation/chrono[0]/elapsetime-sec",1); var clk = aircraft.timer.new("instrumentation/clock/elapsetime-sec",1); +var chrono_cpt = aircraft.timer.new("instrumentation/ndchrono[0]/elapsetime-sec",1); +var chrono_fo = aircraft.timer.new("instrumentation/ndchrono[1]/elapsetime-sec",1); var chr_min = nil; var chr_sec = nil; @@ -49,6 +51,22 @@ var chrono = { started: props.globals.getNode("/instrumentation/chrono[0]/started"), }; +#Cpt chrono +var cpt_chrono = { + etHh_cpt: props.globals.initNode("/instrumentation/ndchrono[0]/etHh_cpt", 0, "INT"), + etMin_cpt: props.globals.initNode("/instrumentation/ndchrono[0]/etMin_cpt", 0, "INT"), + etSec_cpt: props.globals.initNode("/instrumentation/ndchrono[0]/etSec_cpt", 0, "INT"), + text: props.globals.initNode("/instrumentation/ndchrono[0]/text", "0' 00''", "STRING"), +}; + +#Fo chrono +var fo_chrono = { + etHh_fo: props.globals.initNode("/instrumentation/ndchrono[1]/etHh_fo", 0, "INT"), + etMin_fo: props.globals.initNode("/instrumentation/ndchrono[1]/etMin_fo", 0, "INT"), + etSec_fo: props.globals.initNode("/instrumentation/ndchrono[1]/etSec_fo", 0, "INT"), + text: props.globals.initNode("/instrumentation/ndchrono[1]/text", "0' 00''", "STRING"), +}; + var rudderTrim = { rudderTrimDisplay: props.globals.initNode("/controls/flight/rudder-trim-display", 0, "STRING"), rudderTrimDisplayLetter: props.globals.initNode("/controls/flight/rudder-trim-letter-display", "", "STRING"), @@ -59,6 +77,8 @@ setlistener("sim/signals/fdm-initialized", func { chr.reset(); clk.stop(); clk.reset(); + chrono_cpt.reset(); + chrono_fo.reset(); rudderTrim.rudderTrimDisplay.setValue(sprintf("%2.1f", pts.Fdm.JSBsim.Hydraulics.Rudder.trimDeg.getValue())); start_loop.start(); }); @@ -120,6 +140,31 @@ setlistener("/instrumentation/chrono[0]/chrono-reset", func(et){ }; }, 0, 0); +#Chrono +setlistener("instrumentation/efis[0]/inputs/CHRONO", func(et){ + chrono0 = et.getValue(); + if (chrono0 == 1){ + chrono_cpt.start(); + } elsif (chrono0 == 2) { + chrono_cpt.stop(); + } elsif (chrono0 == 0) { + chrono_cpt.reset(); + setprop("instrumentation/ndchrono[0]/elapsetime-sec", 0); + } +}, 0, 0); + +setlistener("instrumentation/efis[1]/inputs/CHRONO", func(et){ + chrono1 = et.getValue(); + if (chrono1 == 1){ + chrono_fo.start(); + } elsif (chrono1 == 2) { + chrono_fo.stop(); + } elsif (chrono1 == 0) { + chrono_fo.reset(); + setprop("instrumentation/ndchrono[1]/elapsetime-sec", 0); + } +}, 0, 0); + setlistener("instrumentation/clock/et-selector", func(et){ tmp1 = et.getValue(); if (tmp1 == 2){ @@ -225,6 +270,40 @@ var start_loop = maketimer(0.1, func { item.update(nil); } } + + #Cpt Chrono + chr0_tmp = getprop("instrumentation/ndchrono[0]/elapsetime-sec"); + if (chr0_tmp >= 360000) { + setprop("instrumentation/ndchrono[0]/elapsetime-sec", getprop("instrumentation/ndchrono[0]/elapsetime-sec") - 360000); + }; + chr0_hh = int(chr0_tmp * 0.000277777777778); + chr0_min = int((chr0_tmp * 0.0166666666667) - (chr0_hh * 60)); + chr0_sec = int(chr0_tmp - (chr0_min * 60) - (chr0_hh * 3600)); + setprop("instrumentation/ndchrono[0]/etHh_cpt", chr0_hh); + setprop("instrumentation/ndchrono[0]/etMin_cpt", chr0_min); + setprop("instrumentation/ndchrono[0]/etSec_cpt", chr0_sec); + if (chr0_tmp >= 3600) { + setprop("instrumentation/ndchrono[0]/text", sprintf("%02d H %02d'", chr0_hh, chr0_min)); + } else { + setprop("instrumentation/ndchrono[0]/text", sprintf("%02d' %02d''", chr0_min, chr0_sec)); + } + + #Fo Chrono + chr1_tmp = getprop("instrumentation/ndchrono[1]/elapsetime-sec"); + if (chr1_tmp >= 360000) { + setprop("instrumentation/ndchrono[1]/elapsetime-sec", getprop("instrumentation/ndchrono[1]/elapsetime-sec") - 360000); + }; + chr1_hh = int(chr1_tmp * 0.000277777777778); + chr1_min = int(chr1_tmp * 0.0166666666667); + chr1_sec = int(chr1_tmp - (chr1_min * 60) - (chr1_hh * 3600)); + setprop("instrumentation/ndchrono[1]/etHh_fo", chr1_hh); + setprop("instrumentation/ndchrono[1]/etMin_fo", chr1_min); + setprop("instrumentation/ndchrono[1]/etSec_fo", chr1_sec); + if (chr1_tmp >= 3600) { + setprop("instrumentation/ndchrono[1]/text", sprintf("%02d H %02d'", chr1_hh, chr1_min)); + } else { + setprop("instrumentation/ndchrono[1]/text", sprintf("%02d' %02d''", chr1_min, chr1_sec)); + } }); var updateRudderTrim = func() { @@ -255,4 +334,4 @@ var update_items = [ ), ]; -setlistener("/controls/switches/annun-test", updateRudderTrim, 0, 0); \ No newline at end of file +setlistener("/controls/switches/annun-test", updateRudderTrim, 0, 0);