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){
m = { parents : [m877]};
m.MODE =0;
m.flip =0;
m.digit_to_set=0;
m.digit=[];
m.set_mode=0;
m.ctl_timer=0;
m.et_start_time=0;
m.et_countdown=0;
m.et_running=0;
@ -12,6 +14,8 @@
m.ft_start_time=0;
m.modetext =["GMT","LT","FT","ET"];
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.ET_alarm=m.M877.initNode("et-alarm",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.FT_HR=m.M877.initNode("FT-hr",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;
},
#### flightmeter ####
fmeter_control : func(){
if(!getprop("gear/gear/wow")){
me.fmeter.start();
}else{
me.fmeter.stop();
}
},
#### displayed mode ####
select_display : func(){
if(me.set_mode==0){
@ -50,9 +63,13 @@
me.set_mode=1-me.set_mode;
},
#### CTL button action ####
control_action : func(){
control_action : func(tmr){
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){
me.et_start_time=getprop("/sim/time/elapsed-sec");
me.et_running=1;
@ -113,6 +130,17 @@
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 : func{
var pwr=me.power.getValue();
@ -122,27 +150,24 @@
pwr=1;
}
me.power.setValue(pwr);
if(me.flip==0){
me.update_ET();
var cm = me.MODE;
if(cm ==0){
}else{
me.update_FT();
}
if(me.MODE ==0){
me.HR.setValue(getprop("/instrumentation/clock/indicated-hour"));
me.MN.setValue(getprop("/instrumentation/clock/indicated-min"));
}elsif(cm == 1) {
}elsif(me.MODE == 1) {
me.HR.setValue(getprop("/instrumentation/clock/local-hour"));
me.MN.setValue(getprop("/instrumentation/clock/indicated-min"));
}elsif(cm == 2) {
var FTH = getprop("instrumentation/clock/flight-meter-sec");
if(FTH != nil){
me.HR.setValue(getprop("instrumentation/clock/flight-meter-hour"));
me.MN.setValue(getprop("instrumentation/clock/flight-meter-min"));
}
}elsif(cm == 3) {
var ETH = me.ET_HR.getValue();
if(ETH != nil){
}elsif(me.MODE == 2) {
me.HR.setValue(me.FT_HR.getValue());
me.MN.setValue(me.FT_MN.getValue());
}elsif(me.MODE == 3) {
me.HR.setValue(me.ET_HR.getValue());
me.MN.setValue(me.ET_MN.getValue());
}
}
if(me.set_mode==1){
var flsh=me.digit[me.digit_to_set].getValue();
flsh=1-flsh;
@ -150,12 +175,12 @@
}else{
me.digit[me.digit_to_set].setValue(1);
}
me.flip=1-me.flip;
},
};
#####################################
var davtron=m877.new("instrumentation/clock/m877");
var ETmeter = aircraft.timer.new("/instrumentation/clock/m877/ET-sec", 10);
setlistener("/sim/signals/fdm-initialized", func {

View file

@ -3,15 +3,15 @@
<path>m877.ac</path>
<animation>
<animation>
<type>select</type>
<object-name>M877.colon</object-name>
<condition>
<property>instrumentation/clock/m877/power</property>
</condition>
</animation>
</animation>
<animation>
<animation>
<type>select</type>
<object-name>gmt</object-name>
<condition>
@ -20,9 +20,9 @@
<value>GMT</value>
</equals>
</condition>
</animation>
</animation>
<animation>
<animation>
<type>select</type>
<object-name>lt</object-name>
<condition>
@ -31,9 +31,9 @@
<value>LT</value>
</equals>
</condition>
</animation>
</animation>
<animation>
<animation>
<type>select</type>
<object-name>ft</object-name>
<condition>
@ -42,9 +42,9 @@
<value>FT</value>
</equals>
</condition>
</animation>
</animation>
<animation>
<animation>
<type>select</type>
<object-name>et</object-name>
<condition>
@ -53,41 +53,41 @@
<value>ET</value>
</equals>
</condition>
</animation>
</animation>
<animation>
<animation>
<type>select</type>
<object-name>HR.001</object-name>
<condition>
<property>instrumentation/clock/m877/digit[3]</property>
</condition>
</animation>
</animation>
<animation>
<animation>
<type>select</type>
<object-name>HR.002</object-name>
<condition>
<property>instrumentation/clock/m877/digit[2]</property>
</condition>
</animation>
</animation>
<animation>
<animation>
<type>select</type>
<object-name>MN.001</object-name>
<condition>
<property>instrumentation/clock/m877/digit[1]</property>
</condition>
</animation>
</animation>
<animation>
<animation>
<type>select</type>
<object-name>MN.002</object-name>
<condition>
<property>instrumentation/clock/m877/digit[0]</property>
</condition>
</animation>
</animation>
<animation>
<animation>
<type>textranslate</type>
<object-name>HR.001</object-name>
<property>instrumentation/clock/m877/indicated-hour</property>
@ -98,9 +98,9 @@
<y>0</y>
<z>0</z>
</axis>
</animation>
</animation>
<animation>
<animation>
<type>textranslate</type>
<object-name>HR.002</object-name>
<property>instrumentation/clock/m877/indicated-hour</property>
@ -111,9 +111,9 @@
<y>0</y>
<z>0</z>
</axis>
</animation>
</animation>
<animation>
<animation>
<type>textranslate</type>
<object-name>MN.001</object-name>
<property>instrumentation/clock/m877/indicated-min</property>
@ -124,9 +124,9 @@
<y>0</y>
<z>0</z>
</axis>
</animation>
</animation>
<animation>
<animation>
<type>textranslate</type>
<object-name>MN.002</object-name>
<property>instrumentation/clock/m877/indicated-min</property>
@ -137,11 +137,11 @@
<y>0</y>
<z>0</z>
</axis>
</animation>
</animation>
<!-- -hotspots -->
<animation>
<animation>
<type>pick</type>
<object-name>SEL.btn</object-name>
<action>
@ -152,22 +152,28 @@
<script>m877.davtron.select_display();</script>
</binding>
</action>
</animation>
</animation>
<animation>
<animation>
<type>pick</type>
<object-name>CTL.btn</object-name>
<action>
<button>0</button>
<repeatable>false</repeatable>
<repeatable>true</repeatable>
<binding>
<command>nasal</command>
<script>m877.davtron.control_action();</script>
<script>m877.davtron.control_action(1);</script>
</binding>
<mod-up>
<binding>
<command>nasal</command>
<script>m877.davtron.control_action(0);</script>
</binding>
</mod-up>
</action>
</animation>
</animation>
<animation>
<animation>
<type>pick</type>
<object-name>SET.btn</object-name>
<action>
@ -178,6 +184,6 @@
<script>m877.davtron.set_time();</script>
</binding>
</action>
</animation>
</animation>
</PropertyList>