1
0
Fork 0

added flight timer ...

This commit is contained in:
sydadams 2009-03-19 06:54:21 +00:00
parent 77d976ef40
commit 46e7fcffe6
2 changed files with 207 additions and 176 deletions

View file

@ -2,9 +2,11 @@
new : func(prop1){ new : func(prop1){
m = { parents : [m877]}; m = { parents : [m877]};
m.MODE =0; m.MODE =0;
m.flip =0;
m.digit_to_set=0; m.digit_to_set=0;
m.digit=[]; m.digit=[];
m.set_mode=0; m.set_mode=0;
m.ctl_timer=0;
m.et_start_time=0; m.et_start_time=0;
m.et_countdown=0; m.et_countdown=0;
m.et_running=0; m.et_running=0;
@ -12,6 +14,8 @@
m.ft_start_time=0; m.ft_start_time=0;
m.modetext =["GMT","LT","FT","ET"]; m.modetext =["GMT","LT","FT","ET"];
m.M877 = props.globals.initNode(prop1); m.M877 = props.globals.initNode(prop1);
m.fmeter_sec=m.M877.initNode("flight-meter-sec",0,"DOUBLE");
m.fmeter=aircraft.timer.new(m.fmeter_sec,1,1);
m.tenths=m.M877.initNode("tenths",0,"BOOL"); m.tenths=m.M877.initNode("tenths",0,"BOOL");
m.ET_alarm=m.M877.initNode("et-alarm",0,"BOOL"); m.ET_alarm=m.M877.initNode("et-alarm",0,"BOOL");
m.FT_alarm=m.M877.initNode("ft-alert",0,"BOOL"); m.FT_alarm=m.M877.initNode("ft-alert",0,"BOOL");
@ -28,8 +32,17 @@
m.ET_MN=m.M877.initNode("ET-min",0,"INT"); m.ET_MN=m.M877.initNode("ET-min",0,"INT");
m.FT_HR=m.M877.initNode("FT-hr",0,"INT"); m.FT_HR=m.M877.initNode("FT-hr",0,"INT");
m.FT_MN=m.M877.initNode("FT-min",0,"INT"); m.FT_MN=m.M877.initNode("FT-min",0,"INT");
m.FTlistener=setlistener("gear/gear/wow",func m.fmeter_control(),0);
return m; return m;
}, },
#### flightmeter ####
fmeter_control : func(){
if(!getprop("gear/gear/wow")){
me.fmeter.start();
}else{
me.fmeter.stop();
}
},
#### displayed mode #### #### displayed mode ####
select_display : func(){ select_display : func(){
if(me.set_mode==0){ if(me.set_mode==0){
@ -50,9 +63,13 @@
me.set_mode=1-me.set_mode; me.set_mode=1-me.set_mode;
}, },
#### CTL button action #### #### CTL button action ####
control_action : func(){ control_action : func(tmr){
if(me.set_mode==0){ if(me.set_mode==0){
if(me.MODE==3){ if(me.MODE==2){
me.ctl_timer+=getprop("/sim/time/delta-realtime-sec");
me.ctl_timer *=tmr;
if(me.ctl_timer>1.5)me.fmeter.reset();
}elsif(me.MODE==3){
if(me.et_running==0){ if(me.et_running==0){
me.et_start_time=getprop("/sim/time/elapsed-sec"); me.et_start_time=getprop("/sim/time/elapsed-sec");
me.et_running=1; me.et_running=1;
@ -113,6 +130,17 @@
me.ET_MN.setValue(min); me.ET_MN.setValue(min);
} }
}, },
#### flight time ####
update_FT : func(){
var fthour = me.fmeter_sec.getValue()/3600;
var hr= int(fthour);
var ftmin=(fthour-hr) * 60;
var min = int(ftmin);
var ftsec= (ftmin- min) *60;
me.FT_HR.setValue(hr);
me.FT_MN.setValue(min);
},
#### update clock #### #### update clock ####
update_clock : func{ update_clock : func{
var pwr=me.power.getValue(); var pwr=me.power.getValue();
@ -122,26 +150,23 @@
pwr=1; pwr=1;
} }
me.power.setValue(pwr); me.power.setValue(pwr);
me.update_ET(); if(me.flip==0){
var cm = me.MODE; me.update_ET();
if(cm ==0){ }else{
me.update_FT();
}
if(me.MODE ==0){
me.HR.setValue(getprop("/instrumentation/clock/indicated-hour")); me.HR.setValue(getprop("/instrumentation/clock/indicated-hour"));
me.MN.setValue(getprop("/instrumentation/clock/indicated-min")); me.MN.setValue(getprop("/instrumentation/clock/indicated-min"));
}elsif(cm == 1) { }elsif(me.MODE == 1) {
me.HR.setValue(getprop("/instrumentation/clock/local-hour")); me.HR.setValue(getprop("/instrumentation/clock/local-hour"));
me.MN.setValue(getprop("/instrumentation/clock/indicated-min")); me.MN.setValue(getprop("/instrumentation/clock/indicated-min"));
}elsif(cm == 2) { }elsif(me.MODE == 2) {
var FTH = getprop("instrumentation/clock/flight-meter-sec"); me.HR.setValue(me.FT_HR.getValue());
if(FTH != nil){ me.MN.setValue(me.FT_MN.getValue());
me.HR.setValue(getprop("instrumentation/clock/flight-meter-hour")); }elsif(me.MODE == 3) {
me.MN.setValue(getprop("instrumentation/clock/flight-meter-min")); me.HR.setValue(me.ET_HR.getValue());
} me.MN.setValue(me.ET_MN.getValue());
}elsif(cm == 3) {
var ETH = me.ET_HR.getValue();
if(ETH != nil){
me.HR.setValue(me.ET_HR.getValue());
me.MN.setValue(me.ET_MN.getValue());
}
} }
if(me.set_mode==1){ if(me.set_mode==1){
var flsh=me.digit[me.digit_to_set].getValue(); var flsh=me.digit[me.digit_to_set].getValue();
@ -150,12 +175,12 @@
}else{ }else{
me.digit[me.digit_to_set].setValue(1); me.digit[me.digit_to_set].setValue(1);
} }
me.flip=1-me.flip;
}, },
}; };
##################################### #####################################
var davtron=m877.new("instrumentation/clock/m877"); var davtron=m877.new("instrumentation/clock/m877");
var ETmeter = aircraft.timer.new("/instrumentation/clock/m877/ET-sec", 10);
setlistener("/sim/signals/fdm-initialized", func { setlistener("/sim/signals/fdm-initialized", func {

View file

@ -3,181 +3,187 @@
<path>m877.ac</path> <path>m877.ac</path>
<animation> <animation>
<type>select</type> <type>select</type>
<object-name>M877.colon</object-name> <object-name>M877.colon</object-name>
<condition> <condition>
<property>instrumentation/clock/m877/power</property> <property>instrumentation/clock/m877/power</property>
</condition> </condition>
</animation> </animation>
<animation> <animation>
<type>select</type> <type>select</type>
<object-name>gmt</object-name> <object-name>gmt</object-name>
<condition> <condition>
<equals> <equals>
<property>instrumentation/clock/m877/mode-string</property> <property>instrumentation/clock/m877/mode-string</property>
<value>GMT</value> <value>GMT</value>
</equals> </equals>
</condition> </condition>
</animation> </animation>
<animation> <animation>
<type>select</type> <type>select</type>
<object-name>lt</object-name> <object-name>lt</object-name>
<condition> <condition>
<equals> <equals>
<property>instrumentation/clock/m877/mode-string</property> <property>instrumentation/clock/m877/mode-string</property>
<value>LT</value> <value>LT</value>
</equals> </equals>
</condition> </condition>
</animation> </animation>
<animation> <animation>
<type>select</type> <type>select</type>
<object-name>ft</object-name> <object-name>ft</object-name>
<condition> <condition>
<equals> <equals>
<property>instrumentation/clock/m877/mode-string</property> <property>instrumentation/clock/m877/mode-string</property>
<value>FT</value> <value>FT</value>
</equals> </equals>
</condition> </condition>
</animation> </animation>
<animation> <animation>
<type>select</type> <type>select</type>
<object-name>et</object-name> <object-name>et</object-name>
<condition> <condition>
<equals> <equals>
<property>instrumentation/clock/m877/mode-string</property> <property>instrumentation/clock/m877/mode-string</property>
<value>ET</value> <value>ET</value>
</equals> </equals>
</condition> </condition>
</animation> </animation>
<animation> <animation>
<type>select</type> <type>select</type>
<object-name>HR.001</object-name> <object-name>HR.001</object-name>
<condition> <condition>
<property>instrumentation/clock/m877/digit[3]</property> <property>instrumentation/clock/m877/digit[3]</property>
</condition> </condition>
</animation> </animation>
<animation> <animation>
<type>select</type> <type>select</type>
<object-name>HR.002</object-name> <object-name>HR.002</object-name>
<condition> <condition>
<property>instrumentation/clock/m877/digit[2]</property> <property>instrumentation/clock/m877/digit[2]</property>
</condition> </condition>
</animation> </animation>
<animation> <animation>
<type>select</type> <type>select</type>
<object-name>MN.001</object-name> <object-name>MN.001</object-name>
<condition> <condition>
<property>instrumentation/clock/m877/digit[1]</property> <property>instrumentation/clock/m877/digit[1]</property>
</condition> </condition>
</animation> </animation>
<animation> <animation>
<type>select</type> <type>select</type>
<object-name>MN.002</object-name> <object-name>MN.002</object-name>
<condition> <condition>
<property>instrumentation/clock/m877/digit[0]</property> <property>instrumentation/clock/m877/digit[0]</property>
</condition> </condition>
</animation> </animation>
<animation> <animation>
<type>textranslate</type> <type>textranslate</type>
<object-name>HR.001</object-name> <object-name>HR.001</object-name>
<property>instrumentation/clock/m877/indicated-hour</property> <property>instrumentation/clock/m877/indicated-hour</property>
<factor>0.01</factor> <factor>0.01</factor>
<step>10</step> <step>10</step>
<axis> <axis>
<x>1</x> <x>1</x>
<y>0</y> <y>0</y>
<z>0</z> <z>0</z>
</axis> </axis>
</animation> </animation>
<animation> <animation>
<type>textranslate</type> <type>textranslate</type>
<object-name>HR.002</object-name> <object-name>HR.002</object-name>
<property>instrumentation/clock/m877/indicated-hour</property> <property>instrumentation/clock/m877/indicated-hour</property>
<factor>0.1</factor> <factor>0.1</factor>
<step>1</step> <step>1</step>
<axis> <axis>
<x>1</x> <x>1</x>
<y>0</y> <y>0</y>
<z>0</z> <z>0</z>
</axis> </axis>
</animation> </animation>
<animation> <animation>
<type>textranslate</type> <type>textranslate</type>
<object-name>MN.001</object-name> <object-name>MN.001</object-name>
<property>instrumentation/clock/m877/indicated-min</property> <property>instrumentation/clock/m877/indicated-min</property>
<factor>0.01</factor> <factor>0.01</factor>
<step>10</step> <step>10</step>
<axis> <axis>
<x>1</x> <x>1</x>
<y>0</y> <y>0</y>
<z>0</z> <z>0</z>
</axis> </axis>
</animation> </animation>
<animation> <animation>
<type>textranslate</type> <type>textranslate</type>
<object-name>MN.002</object-name> <object-name>MN.002</object-name>
<property>instrumentation/clock/m877/indicated-min</property> <property>instrumentation/clock/m877/indicated-min</property>
<factor>0.1</factor> <factor>0.1</factor>
<step>1</step> <step>1</step>
<axis> <axis>
<x>1</x> <x>1</x>
<y>0</y> <y>0</y>
<z>0</z> <z>0</z>
</axis> </axis>
</animation> </animation>
<!-- -hotspots --> <!-- -hotspots -->
<animation> <animation>
<type>pick</type> <type>pick</type>
<object-name>SEL.btn</object-name> <object-name>SEL.btn</object-name>
<action> <action>
<button>0</button> <button>0</button>
<repeatable>false</repeatable> <repeatable>false</repeatable>
<binding> <binding>
<command>nasal</command> <command>nasal</command>
<script>m877.davtron.select_display();</script> <script>m877.davtron.select_display();</script>
</binding> </binding>
</action> </action>
</animation> </animation>
<animation> <animation>
<type>pick</type> <type>pick</type>
<object-name>CTL.btn</object-name> <object-name>CTL.btn</object-name>
<action> <action>
<button>0</button> <button>0</button>
<repeatable>false</repeatable> <repeatable>true</repeatable>
<binding> <binding>
<command>nasal</command> <command>nasal</command>
<script>m877.davtron.control_action();</script> <script>m877.davtron.control_action(1);</script>
</binding> </binding>
</action> <mod-up>
</animation> <binding>
<command>nasal</command>
<script>m877.davtron.control_action(0);</script>
</binding>
</mod-up>
</action>
</animation>
<animation> <animation>
<type>pick</type> <type>pick</type>
<object-name>SET.btn</object-name> <object-name>SET.btn</object-name>
<action> <action>
<button>1</button> <button>1</button>
<repeatable>false</repeatable> <repeatable>false</repeatable>
<binding> <binding>
<command>nasal</command> <command>nasal</command>
<script>m877.davtron.set_time();</script> <script>m877.davtron.set_time();</script>
</binding> </binding>
</action> </action>
</animation> </animation>
</PropertyList> </PropertyList>