1
0
Fork 0

set elapsed time to start-stop with the CTL button

This commit is contained in:
sydadams 2009-03-19 04:08:44 +00:00
parent fc9b2dd2a5
commit 77d976ef40
5 changed files with 299 additions and 157 deletions

View file

@ -2,57 +2,128 @@ var m877 = {
new : func(prop1){
m = { parents : [m877]};
m.MODE =0;
m.digit_to_set=0;
m.digit=[];
m.set_mode=0;
m.et_start_time=0;
m.et_countdown=0;
m.et_running=0;
m.et_elapsed=0;
m.ft_start_time=0;
m.modetext =["GMT","LT","FT","ET"];
m.M877 = props.globals.getNode(prop1,1);
m.set_hour=m.M877.getNode("set-hour",1);
m.set_hour.setBoolValue(0);
m.set_min=m.M877.getNode("set-min",1);
m.set_min.setBoolValue(0);
m.mode=m.M877.getNode("mode",1);
m.mode.setIntValue(m.MODE);
m.tenths=m.M877.getNode("display-tenths",1);
m.tenths.setBoolValue(0);
m.modestring=m.M877.getNode("mode-string",1);
m.modestring.setValue(m.modetext[m.MODE]);
m.HR=m.M877.getNode("indicated-hour",1);
m.HR.setIntValue(0);
m.MN=m.M877.getNode("indicated-min",1);
m.MN.setIntValue(0);
m.ET_HR=m.M877.getNode("ET-hr",1);
m.ET_HR.setIntValue(0);
m.ET_MN=m.M877.getNode("ET-min",1);
m.ET_MN.setIntValue(0);
m.ET_string=m.M877.getNode("ET-string",1);
m.ET_string.setValue("00:00");
m.M877 = props.globals.initNode(prop1);
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");
m.FT_alarm_time=m.M877.initNode("ft-alarm-time",0,"BOOL");
append(m.digit,m.M877.initNode("digit[0]",1,"BOOL"));
append(m.digit,m.M877.initNode("digit[1]",1,"BOOL"));
append(m.digit,m.M877.initNode("digit[2]",1,"BOOL"));
append(m.digit,m.M877.initNode("digit[3]",1,"BOOL"));
m.modestring=m.M877.initNode("mode-string",m.modetext[m.MODE],"STRING");
m.power=m.M877.initNode("power",1,"BOOL");
m.HR=m.M877.initNode("indicated-hour",0,"INT");
m.MN=m.M877.initNode("indicated-min",0,"INT");
m.ET_HR=m.M877.initNode("ET-hr",0,"INT");
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");
return m;
},
#### next mode ####
set_clock : func(){
var cmode = me.mode.getValue();
cmode +=1;
if(cmode>3)cmode -=4;
me.mode.setValue(cmode);
#### displayed mode ####
select_display : func(){
if(me.set_mode==0){
me.MODE +=1;
if(me.MODE>3)me.MODE -=4;
me.modestring.setValue(me.modetext[me.MODE]);
}else{
me.digit[me.digit_to_set].setValue(1);
me.digit_to_set+=1;
if(me.digit_to_set>3){
me.digit_to_set=0;
me.set_mode=0;
}
}
},
#### set displayed mode ####
set_time : func(){
me.set_mode=1-me.set_mode;
},
#### CTL button action ####
control_action : func(){
if(me.set_mode==0){
if(me.MODE==3){
if(me.et_running==0){
me.et_start_time=getprop("/sim/time/elapsed-sec");
me.et_running=1;
}else{
me.et_start_time=getprop("/sim/time/elapsed-sec");
me.et_elapsed=0;
me.et_running=0;
}
}
}else{
if(me.MODE==0){
me.set_gmt();
}elsif(meMODE==1){
me.set_lt();
}elsif(meMODE==2){
me.set_ft();
}elsif(meMODE==3){
me.set_et();
}
}
},
#### set GMT ####
set_gmt : func(){
},
#### set LT ####
set_lt : func(){
},
#### set FT ####
set_ft : func(){
},
#### set ET ####
set_et : func(){
},
#### elapsed time ####
update_ET : func(){
var fmeter = getprop("/instrumentation/clock/m877/ET-sec");
var fhour = fmeter/3600;
var inthour =int(fhour);
me.ET_HR.setValue(inthour);
var fmin = (fhour - inthour);
if(me.tenths.getBoolValue()){
fmin *=100;
}else{
fmin *=60;
if(me.et_running!=0){
me.et_elapsed=getprop("/sim/time/elapsed-sec") - me.et_start_time;
}
var ethour = me.et_elapsed/3600;
var hr= int(ethour);
var etmin=(ethour-hr) * 60;
var min = int(etmin);
var etsec= (etmin- min) *60;
if(ethour <1){
me.ET_HR.setValue(min);
me.ET_MN.setValue(etsec);
}else{
me.ET_HR.setValue(hr);
me.ET_MN.setValue(min);
}
me.ET_MN.setValue(fmin);
var str = sprintf("%02.0f:%02.0f",inthour,fmin);
me.ET_string.setValue(str);
},
#### update clock ####
update_clock : func{
var pwr=me.power.getValue();
if(me.set_mode==0){
pwr=1-pwr;
}else{
pwr=1;
}
me.power.setValue(pwr);
me.update_ET();
var cm = me.mode.getValue();
var cm = me.MODE;
if(cm ==0){
me.HR.setValue(getprop("/instrumentation/clock/indicated-hour"));
me.MN.setValue(getprop("/instrumentation/clock/indicated-min"));
@ -72,30 +143,27 @@ var m877 = {
me.MN.setValue(me.ET_MN.getValue());
}
}
if(me.set_mode==1){
var flsh=me.digit[me.digit_to_set].getValue();
flsh=1-flsh;
me.digit[me.digit_to_set].setValue(flsh);
}else{
me.digit[me.digit_to_set].setValue(1);
}
},
};
#####################################
var davtron=m877.new("instrumentation/clock/m877");
var ETmeter = aircraft.timer.new("/instrumentation/clock/m877/ET-sec", 10);
##################################
setlistener("/sim/signals/fdm-initialized", func {
ETmeter.reset();
settimer(update,2);
print("Chronometer ... Check");
});
setlistener("/gear/gear[1]/wow", func(gr){
if(gr.getBoolValue()){
ETmeter.stop();
}else{
ETmeter.start();
}
},0,0);
var update = func{
davtron.update_clock();
settimer(update,1);
settimer(update,0.5);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View file

@ -4,16 +4,19 @@ MATERIAL "glow2" rgb 0.829458 0.829458 0.829458 amb 0.5 0.5 0.5 emis 0.6 0.6 0.6
MATERIAL "glow" rgb 1 1 1 amb 0.5 0.5 0.5 emis 1 1 1 spec 0 0 0 shi 32 trans 0
MATERIAL "glosswhite" rgb 0.8 0.8 0.8 amb 0 0 0 emis 0 0 0 spec 1 1 1 shi 64 trans 0
OBJECT world
kids 13
OBJECT group
name "CTL.btn"
kids 2
kids 15
OBJECT poly
name "CTL.btn_0"
data 4
Cube
name "CTL.btn"
data 8
Cube.001
texture "M877.png"
texrep 1 1
crease 30.000000
numvert 8
numvert 12
0.004398 -0.012743 -0.016302
0.004398 -0.018403 -0.016302
0.004398 -0.018403 -0.005646
0.004398 -0.012743 -0.005646
0.002006 -0.012743 -0.016302
0.002006 -0.018403 -0.016302
0.002006 -0.018403 -0.005646
@ -22,56 +25,42 @@ numvert 8
0.004398 -0.018403 -0.016302
0.004398 -0.018403 -0.005646
0.004398 -0.012743 -0.005646
numsurf 4
numsurf 5
SURF 0x00
mat 1
refs 4
0 0.751193165779 0.486213296652
4 0.751193165779 0.486213296652
5 0.751193165779 0.402652829885
1 0.751193165779 0.402652829885
SURF 0x00
mat 1
refs 4
1 0.751193165779 0.402652829885
5 0.751193165779 0.402652829885
6 0.664250850677 0.402652829885
2 0.664250850677 0.402652829885
SURF 0x00
mat 1
refs 4
2 0.664250850677 0.402652829885
6 0.664250850677 0.402652829885
7 0.664250850677 0.486213296652
3 0.664250850677 0.486213296652
2 0.664250850677 0.402652829885
1 0.751193165779 0.402652829885
SURF 0x00
mat 1
refs 4
4 0.751193165779 0.486213296652
0 0.751193165779 0.486213296652
3 0.664250850677 0.486213296652
7 0.664250850677 0.486213296652
kids 0
OBJECT poly
name "CTL.btn_1"
data 4
Cube
texture "M877.png"
texrep 1 1
crease 30.000000
numvert 4
0.004398 -0.012743 -0.016302
0.004398 -0.018403 -0.016302
0.004398 -0.018403 -0.005646
0.004398 -0.012743 -0.005646
numsurf 1
8 0.751193165779 0.486213296652
9 0.751193165779 0.402652829885
5 0.751193165779 0.402652829885
SURF 0x00
mat 1
refs 4
0 0.751193165779 0.486213296652
3 0.664250850677 0.486213296652
2 0.664250850677 0.402652829885
1 0.751193165779 0.402652829885
5 0.751193165779 0.402652829885
9 0.751193165779 0.402652829885
10 0.664250850677 0.402652829885
6 0.664250850677 0.402652829885
SURF 0x00
mat 1
refs 4
6 0.664250850677 0.402652829885
10 0.664250850677 0.402652829885
11 0.664250850677 0.486213296652
7 0.664250850677 0.486213296652
SURF 0x00
mat 1
refs 4
8 0.751193165779 0.486213296652
4 0.751193165779 0.486213296652
7 0.664250850677 0.486213296652
11 0.664250850677 0.486213296652
kids 0
OBJECT poly
name "HR.001"
@ -949,36 +938,46 @@ refs 4
15 0.553054749966 0.963210463524
kids 0
OBJECT poly
name "M877.colon"
data 5
Plane
texture "M877.png"
texrep 1 1
crease 30.000000
numvert 4
0.000961 0.010318 0.000855
0.000961 0.000885 0.000855
0.000961 0.000885 -0.001969
0.000961 0.010318 -0.001969
numsurf 1
SURF 0x00
mat 2
refs 4
3 0.957149386406 0.984786868095
0 0.924547255039 0.984786868095
1 0.924547195435 0.693980753422
2 0.957149386406 0.693980753422
kids 0
OBJECT poly
name "M877.display"
data 9
Plane.469
texture "M877.png"
texrep 1 1
crease 30.000000
numvert 8
0.000961 0.010318 -0.001969
0.000961 0.000885 -0.001969
0.000961 0.000885 0.000855
0.000961 0.010318 0.000855
numvert 4
0.000579 0.0142 -0.022098
0.000579 -0.004183 -0.022098
0.000579 -0.004183 0.022112
0.000579 0.0142 0.022112
numsurf 2
numsurf 1
SURF 0x00
mat 2
refs 4
0 0.957149386406 0.984786868095
3 0.924547255039 0.984786868095
2 0.924547195435 0.693980753422
1 0.957149386406 0.693980753422
SURF 0x00
mat 2
refs 4
4 0.976998031139 0.596293568611
7 0.902328789234 0.596293568611
6 0.902328789234 0.480971485376
5 0.976998031139 0.480971485376
0 0.976998031139 0.596293568611
3 0.902328789234 0.596293568611
2 0.902328789234 0.480971485376
1 0.976998031139 0.480971485376
kids 0
OBJECT poly
name "MN.001"
@ -1022,15 +1021,18 @@ refs 4
2 0.0181855931878 0.00866907835007
1 0.0918634906411 0.00866907835007
kids 0
OBJECT group
name "SEL.btn"
kids 2
OBJECT poly
name "SEL.btn_0"
name "SEL.btn"
data 8
Cube.001
Cube.002
texture "M877.png"
texrep 1 1
crease 30.000000
numvert 8
numvert 12
0.004398 -0.012743 0.006863
0.004398 -0.018403 0.006863
0.004398 -0.018403 0.01752
0.004398 -0.012743 0.01752
0.002006 -0.012743 0.006863
0.002006 -0.018403 0.006863
0.002006 -0.018403 0.01752
@ -1039,56 +1041,63 @@ numvert 8
0.004398 -0.018403 0.006863
0.004398 -0.018403 0.01752
0.004398 -0.012743 0.01752
numsurf 4
numsurf 5
SURF 0x00
mat 1
refs 4
0 0.75237852335 0.796478271484
4 0.75237852335 0.796478271484
5 0.75237852335 0.708643317223
3 0.66299623251 0.796478271484
2 0.66299623251 0.708643317223
1 0.75237852335 0.708643317223
SURF 0x00
mat 1
refs 4
1 0.75237852335 0.708643317223
5 0.75237852335 0.708643317223
6 0.66299623251 0.708643317223
2 0.66299623251 0.708643317223
4 0.750929892063 0.795054674149
8 0.750929892063 0.795054674149
9 0.750929892063 0.710066914558
5 0.750929892063 0.710066914558
SURF 0x00
mat 1
refs 4
2 0.66299623251 0.708643317223
6 0.66299623251 0.708643317223
7 0.66299623251 0.796478271484
3 0.66299623251 0.796478271484
5 0.750929892063 0.710066914558
9 0.750929892063 0.710066914558
10 0.664444863796 0.710066914558
6 0.664444863796 0.710066914558
SURF 0x00
mat 1
refs 4
4 0.75237852335 0.796478271484
0 0.75237852335 0.796478271484
3 0.66299623251 0.796478271484
7 0.66299623251 0.796478271484
6 0.664444863796 0.710066914558
10 0.664444863796 0.710066914558
11 0.664444863796 0.795054674149
7 0.664444863796 0.795054674149
SURF 0x00
mat 1
refs 4
8 0.750929892063 0.795054674149
4 0.750929892063 0.795054674149
7 0.664444863796 0.795054674149
11 0.664444863796 0.795054674149
kids 0
OBJECT poly
name "SEL.btn_1"
name "SET.btn"
data 8
Cube.001
Cube.004
texture "M877.png"
texrep 1 1
crease 30.000000
numvert 4
0.004398 -0.012743 0.006863
0.004398 -0.018403 0.006863
0.004398 -0.018403 0.01752
0.004398 -0.012743 0.01752
0.0019 -0.012311 0.005884
0.0019 -0.019511 0.005884
0.0019 -0.019511 -0.004815
0.0019 -0.012311 -0.004815
numsurf 1
SURF 0x00
mat 1
mat 3
refs 4
0 0.75237852335 0.796478271484
3 0.66299623251 0.796478271484
2 0.66299623251 0.708643317223
1 0.75237852335 0.708643317223
3 0.838916540146 0.523605704308
0 0.791258811951 0.523605704308
1 0.791258811951 0.466369539499
2 0.838916540146 0.466369539499
kids 0
OBJECT poly
name "et"

View file

@ -3,13 +3,21 @@
<path>m877.ac</path>
<animation>
<type>select</type>
<object-name>M877.colon</object-name>
<condition>
<property>instrumentation/clock/m877/power</property>
</condition>
</animation>
<animation>
<type>select</type>
<object-name>gmt</object-name>
<condition>
<equals>
<property>instrumentation/clock/m877/mode</property>
<value>0</value>
<property>instrumentation/clock/m877/mode-string</property>
<value>GMT</value>
</equals>
</condition>
</animation>
@ -19,8 +27,8 @@
<object-name>lt</object-name>
<condition>
<equals>
<property>instrumentation/clock/m877/mode</property>
<value>1</value>
<property>instrumentation/clock/m877/mode-string</property>
<value>LT</value>
</equals>
</condition>
</animation>
@ -30,8 +38,8 @@
<object-name>ft</object-name>
<condition>
<equals>
<property>instrumentation/clock/m877/mode</property>
<value>2</value>
<property>instrumentation/clock/m877/mode-string</property>
<value>FT</value>
</equals>
</condition>
</animation>
@ -41,12 +49,44 @@
<object-name>et</object-name>
<condition>
<equals>
<property>instrumentation/clock/m877/mode</property>
<value>3</value>
<property>instrumentation/clock/m877/mode-string</property>
<value>ET</value>
</equals>
</condition>
</animation>
<animation>
<type>select</type>
<object-name>HR.001</object-name>
<condition>
<property>instrumentation/clock/m877/digit[3]</property>
</condition>
</animation>
<animation>
<type>select</type>
<object-name>HR.002</object-name>
<condition>
<property>instrumentation/clock/m877/digit[2]</property>
</condition>
</animation>
<animation>
<type>select</type>
<object-name>MN.001</object-name>
<condition>
<property>instrumentation/clock/m877/digit[1]</property>
</condition>
</animation>
<animation>
<type>select</type>
<object-name>MN.002</object-name>
<condition>
<property>instrumentation/clock/m877/digit[0]</property>
</condition>
</animation>
<animation>
<type>textranslate</type>
<object-name>HR.001</object-name>
@ -101,6 +141,19 @@
<!-- -hotspots -->
<animation>
<type>pick</type>
<object-name>SEL.btn</object-name>
<action>
<button>0</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>m877.davtron.select_display();</script>
</binding>
</action>
</animation>
<animation>
<type>pick</type>
<object-name>CTL.btn</object-name>
@ -109,10 +162,22 @@
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>m877.davtron.set_clock();</script>
<script>m877.davtron.control_action();</script>
</binding>
</action>
</animation>
<animation>
<type>pick</type>
<object-name>SET.btn</object-name>
<action>
<button>1</button>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>m877.davtron.set_time();</script>
</binding>
</action>
</animation>
</PropertyList>