2009-03-19 04:08:44 +00:00
|
|
|
var m877 = {
|
2009-03-18 03:37:52 +00:00
|
|
|
new : func(prop1){
|
|
|
|
m = { parents : [m877]};
|
|
|
|
m.MODE =0;
|
2009-03-19 06:54:21 +00:00
|
|
|
m.flip =0;
|
2009-03-19 04:08:44 +00:00
|
|
|
m.digit_to_set=0;
|
|
|
|
m.digit=[];
|
|
|
|
m.set_mode=0;
|
2009-03-19 06:54:21 +00:00
|
|
|
m.ctl_timer=0;
|
2009-03-19 04:08:44 +00:00
|
|
|
m.et_start_time=0;
|
|
|
|
m.et_countdown=0;
|
|
|
|
m.et_running=0;
|
|
|
|
m.et_elapsed=0;
|
|
|
|
m.ft_start_time=0;
|
2009-06-19 06:17:47 +00:00
|
|
|
m.ft_running=0;
|
2009-03-18 03:37:52 +00:00
|
|
|
m.modetext =["GMT","LT","FT","ET"];
|
2009-03-19 04:08:44 +00:00
|
|
|
m.M877 = props.globals.initNode(prop1);
|
2009-03-19 06:54:21 +00:00
|
|
|
m.fmeter_sec=m.M877.initNode("flight-meter-sec",0,"DOUBLE");
|
|
|
|
m.fmeter=aircraft.timer.new(m.fmeter_sec,1,1);
|
2009-03-19 04:08:44 +00:00
|
|
|
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");
|
2009-03-18 03:37:52 +00:00
|
|
|
return m;
|
|
|
|
},
|
2009-03-19 06:54:21 +00:00
|
|
|
#### flightmeter ####
|
|
|
|
fmeter_control : func(){
|
2009-06-19 06:17:47 +00:00
|
|
|
var ias =getprop("velocities/airspeed-kt");
|
|
|
|
if(ias>30){
|
|
|
|
if(me.ft_running==0){
|
|
|
|
me.ft_running=1;
|
|
|
|
me.fmeter.start();
|
|
|
|
}
|
|
|
|
}elsif(ias<30){
|
|
|
|
if(me.ft_running==1){
|
|
|
|
me.ft_running=0;
|
|
|
|
me.fmeter.stop();
|
|
|
|
}
|
2009-03-19 06:54:21 +00:00
|
|
|
}
|
|
|
|
},
|
2009-03-19 04:08:44 +00:00
|
|
|
#### 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 ####
|
2009-03-19 06:54:21 +00:00
|
|
|
control_action : func(tmr){
|
2009-03-19 04:08:44 +00:00
|
|
|
if(me.set_mode==0){
|
2009-03-19 06:54:21 +00:00
|
|
|
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){
|
2009-03-19 04:08:44 +00:00
|
|
|
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(){
|
|
|
|
|
2009-03-18 03:37:52 +00:00
|
|
|
},
|
2009-03-19 04:08:44 +00:00
|
|
|
|
|
|
|
#### set FT ####
|
|
|
|
set_ft : func(){
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
#### set ET ####
|
|
|
|
set_et : func(){
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2009-03-18 03:37:52 +00:00
|
|
|
#### elapsed time ####
|
|
|
|
update_ET : func(){
|
2009-03-19 04:08:44 +00:00
|
|
|
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);
|
2009-03-18 03:37:52 +00:00
|
|
|
}else{
|
2009-03-19 04:08:44 +00:00
|
|
|
me.ET_HR.setValue(hr);
|
|
|
|
me.ET_MN.setValue(min);
|
2009-03-18 03:37:52 +00:00
|
|
|
}
|
|
|
|
},
|
2009-03-19 06:54:21 +00:00
|
|
|
#### 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;
|
2009-06-19 06:17:47 +00:00
|
|
|
if(fthour <1){
|
|
|
|
me.FT_HR.setValue(min);
|
|
|
|
me.FT_MN.setValue(ftsec);
|
|
|
|
}else{
|
|
|
|
me.FT_HR.setValue(hr);
|
|
|
|
me.FT_MN.setValue(min);
|
|
|
|
}
|
2009-03-19 06:54:21 +00:00
|
|
|
},
|
|
|
|
|
2009-03-18 03:37:52 +00:00
|
|
|
#### update clock ####
|
|
|
|
update_clock : func{
|
2009-03-19 04:08:44 +00:00
|
|
|
var pwr=me.power.getValue();
|
2009-06-19 06:17:47 +00:00
|
|
|
me.fmeter_control();
|
2009-03-19 04:08:44 +00:00
|
|
|
if(me.set_mode==0){
|
|
|
|
pwr=1-pwr;
|
|
|
|
}else{
|
|
|
|
pwr=1;
|
|
|
|
}
|
|
|
|
me.power.setValue(pwr);
|
2009-06-19 06:17:47 +00:00
|
|
|
|
2009-03-19 06:54:21 +00:00
|
|
|
if(me.flip==0){
|
|
|
|
me.update_ET();
|
|
|
|
}else{
|
|
|
|
me.update_FT();
|
|
|
|
}
|
|
|
|
if(me.MODE ==0){
|
2009-03-18 03:37:52 +00:00
|
|
|
me.HR.setValue(getprop("/instrumentation/clock/indicated-hour"));
|
|
|
|
me.MN.setValue(getprop("/instrumentation/clock/indicated-min"));
|
2009-03-19 06:54:21 +00:00
|
|
|
}elsif(me.MODE == 1) {
|
2009-03-18 03:37:52 +00:00
|
|
|
me.HR.setValue(getprop("/instrumentation/clock/local-hour"));
|
|
|
|
me.MN.setValue(getprop("/instrumentation/clock/indicated-min"));
|
2009-03-19 06:54:21 +00:00
|
|
|
}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());
|
2009-03-18 03:37:52 +00:00
|
|
|
}
|
2009-03-19 04:08:44 +00:00
|
|
|
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);
|
|
|
|
}
|
2009-03-19 06:54:21 +00:00
|
|
|
me.flip=1-me.flip;
|
2009-03-18 03:37:52 +00:00
|
|
|
},
|
|
|
|
};
|
2009-03-19 04:08:44 +00:00
|
|
|
#####################################
|
2007-09-22 20:42:39 +00:00
|
|
|
|
2009-03-18 03:37:52 +00:00
|
|
|
var davtron=m877.new("instrumentation/clock/m877");
|
2007-09-22 20:42:39 +00:00
|
|
|
|
|
|
|
|
2009-03-18 03:37:52 +00:00
|
|
|
setlistener("/sim/signals/fdm-initialized", func {
|
|
|
|
settimer(update,2);
|
|
|
|
print("Chronometer ... Check");
|
|
|
|
});
|
2007-09-22 20:42:39 +00:00
|
|
|
|
2009-03-18 03:37:52 +00:00
|
|
|
var update = func{
|
|
|
|
davtron.update_clock();
|
2009-03-19 04:08:44 +00:00
|
|
|
settimer(update,0.5);
|
2007-09-22 20:42:39 +00:00
|
|
|
}
|