diff --git a/lib.nas b/lib.nas index 2974927..a094a7a 100644 --- a/lib.nas +++ b/lib.nas @@ -155,3 +155,5 @@ var math= sqrt: func(x) {return __builtin_sqrt(x); }, atan2: func(x,y){return __builtin_atan2(x,y);} }; + +var D2R=math.pi/180; \ No newline at end of file diff --git a/nasal_builtin.h b/nasal_builtin.h index 90d98e8..4f2322b 100644 --- a/nasal_builtin.h +++ b/nasal_builtin.h @@ -12,58 +12,52 @@ std::unordered_map builtin_use_str; // used to find values that builtin function uses -#define builtin_find(name) \ -(\ - local_scope\ - ->ptr.scop\ - ->get_val\ - (builtin_use_str[name])\ -) +#define builtin_find(name) (local_scope[builtin_use_str[name]]) // declaration of builtin functions // to add new builtin function,declare it here and write the definition below -nasal_val* builtin_print(nasal_val*,nasal_gc&); -nasal_val* builtin_append(nasal_val*,nasal_gc&); -nasal_val* builtin_setsize(nasal_val*,nasal_gc&); -nasal_val* builtin_system(nasal_val*,nasal_gc&); -nasal_val* builtin_input(nasal_val*,nasal_gc&); -nasal_val* builtin_sleep(nasal_val*,nasal_gc&); -nasal_val* builtin_fin(nasal_val*,nasal_gc&); -nasal_val* builtin_fout(nasal_val*,nasal_gc&); -nasal_val* builtin_split(nasal_val*,nasal_gc&); -nasal_val* builtin_rand(nasal_val*,nasal_gc&); -nasal_val* builtin_id(nasal_val*,nasal_gc&); -nasal_val* builtin_int(nasal_val*,nasal_gc&); -nasal_val* builtin_num(nasal_val*,nasal_gc&); -nasal_val* builtin_pop(nasal_val*,nasal_gc&); -nasal_val* builtin_str(nasal_val*,nasal_gc&); -nasal_val* builtin_size(nasal_val*,nasal_gc&); -nasal_val* builtin_xor(nasal_val*,nasal_gc&); -nasal_val* builtin_and(nasal_val*,nasal_gc&); -nasal_val* builtin_or(nasal_val*,nasal_gc&); -nasal_val* builtin_nand(nasal_val*,nasal_gc&); -nasal_val* builtin_not(nasal_val*,nasal_gc&); -nasal_val* builtin_sin(nasal_val*,nasal_gc&); -nasal_val* builtin_cos(nasal_val*,nasal_gc&); -nasal_val* builtin_tan(nasal_val*,nasal_gc&); -nasal_val* builtin_exp(nasal_val*,nasal_gc&); -nasal_val* builtin_ln(nasal_val*,nasal_gc&); -nasal_val* builtin_sqrt(nasal_val*,nasal_gc&); -nasal_val* builtin_atan2(nasal_val*,nasal_gc&); -nasal_val* builtin_time(nasal_val*,nasal_gc&); -nasal_val* builtin_contains(nasal_val*,nasal_gc&); -nasal_val* builtin_delete(nasal_val*,nasal_gc&); -nasal_val* builtin_getkeys(nasal_val*,nasal_gc&); -nasal_val* builtin_import(nasal_val*,nasal_gc&); -nasal_val* builtin_die(nasal_val*,nasal_gc&); -nasal_val* builtin_type(nasal_val*,nasal_gc&); -nasal_val* builtin_substr(nasal_val*,nasal_gc&); -nasal_val* builtin_streq(nasal_val*,nasal_gc&); -nasal_val* builtin_left(nasal_val*,nasal_gc&); -nasal_val* builtin_right(nasal_val*,nasal_gc&); -nasal_val* builtin_cmp(nasal_val*,nasal_gc&); -nasal_val* builtin_chr(nasal_val*,nasal_gc&); +nasal_val* builtin_print(std::unordered_map&,nasal_gc&); +nasal_val* builtin_append(std::unordered_map&,nasal_gc&); +nasal_val* builtin_setsize(std::unordered_map&,nasal_gc&); +nasal_val* builtin_system(std::unordered_map&,nasal_gc&); +nasal_val* builtin_input(std::unordered_map&,nasal_gc&); +nasal_val* builtin_sleep(std::unordered_map&,nasal_gc&); +nasal_val* builtin_fin(std::unordered_map&,nasal_gc&); +nasal_val* builtin_fout(std::unordered_map&,nasal_gc&); +nasal_val* builtin_split(std::unordered_map&,nasal_gc&); +nasal_val* builtin_rand(std::unordered_map&,nasal_gc&); +nasal_val* builtin_id(std::unordered_map&,nasal_gc&); +nasal_val* builtin_int(std::unordered_map&,nasal_gc&); +nasal_val* builtin_num(std::unordered_map&,nasal_gc&); +nasal_val* builtin_pop(std::unordered_map&,nasal_gc&); +nasal_val* builtin_str(std::unordered_map&,nasal_gc&); +nasal_val* builtin_size(std::unordered_map&,nasal_gc&); +nasal_val* builtin_xor(std::unordered_map&,nasal_gc&); +nasal_val* builtin_and(std::unordered_map&,nasal_gc&); +nasal_val* builtin_or(std::unordered_map&,nasal_gc&); +nasal_val* builtin_nand(std::unordered_map&,nasal_gc&); +nasal_val* builtin_not(std::unordered_map&,nasal_gc&); +nasal_val* builtin_sin(std::unordered_map&,nasal_gc&); +nasal_val* builtin_cos(std::unordered_map&,nasal_gc&); +nasal_val* builtin_tan(std::unordered_map&,nasal_gc&); +nasal_val* builtin_exp(std::unordered_map&,nasal_gc&); +nasal_val* builtin_ln(std::unordered_map&,nasal_gc&); +nasal_val* builtin_sqrt(std::unordered_map&,nasal_gc&); +nasal_val* builtin_atan2(std::unordered_map&,nasal_gc&); +nasal_val* builtin_time(std::unordered_map&,nasal_gc&); +nasal_val* builtin_contains(std::unordered_map&,nasal_gc&); +nasal_val* builtin_delete(std::unordered_map&,nasal_gc&); +nasal_val* builtin_getkeys(std::unordered_map&,nasal_gc&); +nasal_val* builtin_import(std::unordered_map&,nasal_gc&); +nasal_val* builtin_die(std::unordered_map&,nasal_gc&); +nasal_val* builtin_type(std::unordered_map&,nasal_gc&); +nasal_val* builtin_substr(std::unordered_map&,nasal_gc&); +nasal_val* builtin_streq(std::unordered_map&,nasal_gc&); +nasal_val* builtin_left(std::unordered_map&,nasal_gc&); +nasal_val* builtin_right(std::unordered_map&,nasal_gc&); +nasal_val* builtin_cmp(std::unordered_map&,nasal_gc&); +nasal_val* builtin_chr(std::unordered_map&,nasal_gc&); void builtin_err(std::string func_name,std::string info) { @@ -76,7 +70,7 @@ void builtin_err(std::string func_name,std::string info) struct FUNC_TABLE { std::string name; - nasal_val* (*func)(nasal_val* x,nasal_gc&); + nasal_val* (*func)(std::unordered_map&,nasal_gc&); } builtin_func[]= { {"__builtin_std_cout", builtin_print }, @@ -123,7 +117,7 @@ struct FUNC_TABLE {"", nullptr } }; -nasal_val* builtin_print(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_print(std::unordered_map& local_scope,nasal_gc& gc) { // get arguments nasal_val* vector_val_addr=builtin_find("elements"); @@ -146,7 +140,7 @@ nasal_val* builtin_print(nasal_val* local_scope,nasal_gc& gc) // generate return value return gc.nil_addr; } -nasal_val* builtin_append(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_append(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* vec_addr=builtin_find("vector"); nasal_val* elem_addr=builtin_find("elements"); @@ -162,7 +156,7 @@ nasal_val* builtin_append(nasal_val* local_scope,nasal_gc& gc) ref_vec.push_back(ref_elems[i]); return gc.nil_addr; } -nasal_val* builtin_setsize(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_setsize(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* vec_addr=builtin_find("vector"); nasal_val* size_addr=builtin_find("size"); @@ -193,7 +187,7 @@ nasal_val* builtin_setsize(nasal_val* local_scope,nasal_gc& gc) return gc.nil_addr; } -nasal_val* builtin_system(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_system(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* str_addr=builtin_find("str"); if(str_addr->type!=vm_str) @@ -205,14 +199,14 @@ nasal_val* builtin_system(nasal_val* local_scope,nasal_gc& gc) return gc.nil_addr; } -nasal_val* builtin_input(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_input(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* ret_addr=gc.gc_alloc(vm_str); std::cin>>*ret_addr->ptr.str; return ret_addr; } -nasal_val* builtin_sleep(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_sleep(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("duration"); if(val_addr->type!=vm_num) @@ -225,7 +219,7 @@ nasal_val* builtin_sleep(nasal_val* local_scope,nasal_gc& gc) return gc.nil_addr; } -nasal_val* builtin_fin(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_fin(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("filename"); if(val_addr->type!=vm_str) @@ -251,7 +245,7 @@ nasal_val* builtin_fin(nasal_val* local_scope,nasal_gc& gc) return ret_addr; } -nasal_val* builtin_fout(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_fout(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("filename"); nasal_val* str_addr=builtin_find("str"); @@ -276,7 +270,7 @@ nasal_val* builtin_fout(nasal_val* local_scope,nasal_gc& gc) return gc.nil_addr; } -nasal_val* builtin_split(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_split(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* delimeter_val_addr=builtin_find("delimeter"); nasal_val* string_val_addr=builtin_find("string"); @@ -344,7 +338,7 @@ nasal_val* builtin_split(nasal_val* local_scope,nasal_gc& gc) } return ret_addr; } -nasal_val* builtin_rand(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_rand(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("seed"); if(val_addr->type!=vm_num && val_addr->type!=vm_nil) @@ -364,7 +358,7 @@ nasal_val* builtin_rand(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=num; return ret_addr; } -nasal_val* builtin_id(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_id(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("thing"); nasal_val* ret_addr=gc.gc_alloc(vm_str); @@ -373,7 +367,7 @@ nasal_val* builtin_id(nasal_val* local_scope,nasal_gc& gc) *ret_addr->ptr.str=buf; return ret_addr; } -nasal_val* builtin_int(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_int(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("value"); if(val_addr->type!=vm_num) @@ -386,7 +380,7 @@ nasal_val* builtin_int(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=(double)number; return ret_addr; } -nasal_val* builtin_num(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_num(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("value"); if(val_addr->type!=vm_str) @@ -398,7 +392,7 @@ nasal_val* builtin_num(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=val_addr->to_number(); return ret_addr; } -nasal_val* builtin_pop(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_pop(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("vector"); if(val_addr->type!=vm_vec) @@ -414,7 +408,7 @@ nasal_val* builtin_pop(nasal_val* local_scope,nasal_gc& gc) } return gc.nil_addr; } -nasal_val* builtin_str(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_str(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("number"); if(val_addr->type!=vm_num) @@ -426,7 +420,7 @@ nasal_val* builtin_str(nasal_val* local_scope,nasal_gc& gc) *ret_addr->ptr.str=val_addr->to_string(); return ret_addr; } -nasal_val* builtin_size(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_size(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("object"); nasal_val* ret_addr=gc.gc_alloc(vm_num); @@ -435,14 +429,13 @@ nasal_val* builtin_size(nasal_val* local_scope,nasal_gc& gc) case vm_nil: ret_addr->ptr.num=0; break; case vm_num: ret_addr->ptr.num=val_addr->ptr.num; break; case vm_func: ret_addr->ptr.num=0; break; - case vm_scop: ret_addr->ptr.num=val_addr->ptr.scop->elems.size();break; case vm_str: ret_addr->ptr.num=val_addr->ptr.str->length(); break; case vm_vec: ret_addr->ptr.num=val_addr->ptr.vec->elems.size(); break; case vm_hash: ret_addr->ptr.num=val_addr->ptr.hash->elems.size();break; } return ret_addr; } -nasal_val* builtin_xor(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_xor(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* a_addr=builtin_find("a"); nasal_val* b_addr=builtin_find("b"); @@ -462,7 +455,7 @@ nasal_val* builtin_xor(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=(number_a^number_b); return ret_addr; } -nasal_val* builtin_and(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_and(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* a_addr=builtin_find("a"); nasal_val* b_addr=builtin_find("b"); @@ -482,7 +475,7 @@ nasal_val* builtin_and(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=(number_a&number_b); return ret_addr; } -nasal_val* builtin_or(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_or(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* a_addr=builtin_find("a"); nasal_val* b_addr=builtin_find("b"); @@ -502,7 +495,7 @@ nasal_val* builtin_or(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=(number_a|number_b); return ret_addr; } -nasal_val* builtin_nand(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_nand(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* a_addr=builtin_find("a"); nasal_val* b_addr=builtin_find("b"); @@ -522,7 +515,7 @@ nasal_val* builtin_nand(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=(~(number_a&number_b)); return ret_addr; } -nasal_val* builtin_not(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_not(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* a_addr=builtin_find("a"); if(a_addr->type!=vm_num) @@ -535,7 +528,7 @@ nasal_val* builtin_not(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=(~number); return ret_addr; } -nasal_val* builtin_sin(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_sin(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("x"); if(val_addr->type!=vm_num) @@ -547,7 +540,7 @@ nasal_val* builtin_sin(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=sin(val_addr->ptr.num); return ret_addr; } -nasal_val* builtin_cos(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_cos(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("x"); if(val_addr->type!=vm_num) @@ -559,7 +552,7 @@ nasal_val* builtin_cos(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=cos(val_addr->ptr.num); return ret_addr; } -nasal_val* builtin_tan(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_tan(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("x"); if(val_addr->type!=vm_num) @@ -571,7 +564,7 @@ nasal_val* builtin_tan(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=tan(val_addr->ptr.num); return ret_addr; } -nasal_val* builtin_exp(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_exp(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("x"); if(val_addr->type!=vm_num) @@ -583,7 +576,7 @@ nasal_val* builtin_exp(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=exp(val_addr->ptr.num); return ret_addr; } -nasal_val* builtin_ln(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_ln(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("x"); if(val_addr->type!=vm_num) @@ -595,7 +588,7 @@ nasal_val* builtin_ln(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=(log(val_addr->ptr.num)/log(2.7182818284590452354)); return ret_addr; } -nasal_val* builtin_sqrt(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_sqrt(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("x"); if(val_addr->type!=vm_num) @@ -607,7 +600,7 @@ nasal_val* builtin_sqrt(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=sqrt(val_addr->ptr.num); return ret_addr; } -nasal_val* builtin_atan2(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_atan2(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* x_val_addr=builtin_find("x"); nasal_val* y_val_addr=builtin_find("y"); @@ -625,7 +618,7 @@ nasal_val* builtin_atan2(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=atan2(y_val_addr->ptr.num,x_val_addr->ptr.num); return ret_addr; } -nasal_val* builtin_time(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_time(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("begin_time"); if(val_addr->type!=vm_num) @@ -638,7 +631,7 @@ nasal_val* builtin_time(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=time(&begin_time); return ret_addr; } -nasal_val* builtin_contains(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_contains(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* hash_addr=builtin_find("hash"); nasal_val* key_addr=builtin_find("key"); @@ -656,7 +649,7 @@ nasal_val* builtin_contains(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=hash_addr->ptr.hash->check_contain(*key_addr->ptr.str); return ret_addr; } -nasal_val* builtin_delete(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_delete(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* hash_addr=builtin_find("hash"); nasal_val* key_addr=builtin_find("key"); @@ -674,7 +667,7 @@ nasal_val* builtin_delete(nasal_val* local_scope,nasal_gc& gc) hash_addr->ptr.hash->elems.erase(*key_addr->ptr.str); return gc.nil_addr; } -nasal_val* builtin_getkeys(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_getkeys(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* hash_addr=builtin_find("hash"); if(hash_addr->type!=vm_hash) @@ -693,14 +686,14 @@ nasal_val* builtin_getkeys(nasal_val* local_scope,nasal_gc& gc) } return ret_addr; } -nasal_val* builtin_import(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_import(std::unordered_map& local_scope,nasal_gc& gc) { // this function is used in preprocessing. // this function will return nothing when running. builtin_err("import","cannot use import when running"); return nullptr; } -nasal_val* builtin_die(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_die(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* str_addr=builtin_find("str"); if(str_addr->type!=vm_str) @@ -708,10 +701,10 @@ nasal_val* builtin_die(nasal_val* local_scope,nasal_gc& gc) builtin_err("die","\"str\" must be string"); return nullptr; } - std::cout<<">> [vm] error: "<ptr.str<<'\n'; + std::cout<<">> [vm] error: "<<*str_addr->ptr.str<<'\n'; return nullptr; } -nasal_val* builtin_type(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_type(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* val_addr=builtin_find("object"); nasal_val* ret_addr=gc.gc_alloc(vm_str); @@ -726,7 +719,7 @@ nasal_val* builtin_type(nasal_val* local_scope,nasal_gc& gc) } return ret_addr; } -nasal_val* builtin_substr(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_substr(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* str_addr=builtin_find("str"); nasal_val* beg_addr=builtin_find("begin"); @@ -760,7 +753,7 @@ nasal_val* builtin_substr(nasal_val* local_scope,nasal_gc& gc) *ret_addr->ptr.str=str.substr(beg,len); return ret_addr; } -nasal_val* builtin_streq(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_streq(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* a_addr=builtin_find("a"); nasal_val* b_addr=builtin_find("b"); @@ -768,7 +761,7 @@ nasal_val* builtin_streq(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=(a_addr->type!=vm_str || b_addr->type!=vm_str)?0:(*a_addr->ptr.str==*b_addr->ptr.str); return ret_addr; } -nasal_val* builtin_left(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_left(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* str_addr=builtin_find("string"); nasal_val* len_addr=builtin_find("length"); @@ -790,7 +783,7 @@ nasal_val* builtin_left(nasal_val* local_scope,nasal_gc& gc) *ret_addr->ptr.str=str.substr(0, len); return ret_addr; } -nasal_val* builtin_right(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_right(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* str_addr=builtin_find("string"); nasal_val* len_addr=builtin_find("length"); @@ -815,7 +808,7 @@ nasal_val* builtin_right(nasal_val* local_scope,nasal_gc& gc) *ret_addr->ptr.str=str.substr(srclen-len, srclen); return ret_addr; } -nasal_val* builtin_cmp(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_cmp(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* a_addr=builtin_find("a"); nasal_val* b_addr=builtin_find("b"); @@ -833,7 +826,7 @@ nasal_val* builtin_cmp(nasal_val* local_scope,nasal_gc& gc) ret_addr->ptr.num=strcmp(a_addr->ptr.str->data(),b_addr->ptr.str->data()); return ret_addr; } -nasal_val* builtin_chr(nasal_val* local_scope,nasal_gc& gc) +nasal_val* builtin_chr(std::unordered_map& local_scope,nasal_gc& gc) { nasal_val* code_addr=builtin_find("code"); if(code_addr->type!=vm_num) diff --git a/nasal_codegen.h b/nasal_codegen.h index e1a31ae..c7f61fe 100644 --- a/nasal_codegen.h +++ b/nasal_codegen.h @@ -395,7 +395,7 @@ void nasal_codegen::func_gen(nasal_ast& ast) } } exec_code[newfunc_label].num=exec_code.size()+1; - int ptr=exec_code.size(); + int jmp_ptr=exec_code.size(); gen(op_jmp,0); nasal_ast& block=ast.get_children()[1]; @@ -407,7 +407,7 @@ void nasal_codegen::func_gen(nasal_ast& ast) nil_gen(); gen(op_ret,0); } - exec_code[ptr].num=exec_code.size(); + exec_code[jmp_ptr].num=exec_code.size(); return; } diff --git a/nasal_gc.h b/nasal_gc.h index d62136d..8b690d1 100644 --- a/nasal_gc.h +++ b/nasal_gc.h @@ -6,7 +6,6 @@ enum nasal_type vm_nil=0, vm_num, vm_str, - vm_scop, vm_func, vm_vec, vm_hash @@ -48,14 +47,6 @@ struct nasal_func nasal_func(); }; -struct nasal_scop -{ - std::unordered_map elems; - - nasal_val* get_val(int); - nasal_val** get_mem(int); -}; - struct nasal_val { bool mark; @@ -67,7 +58,6 @@ struct nasal_val nasal_vec* vec; nasal_hash* hash; nasal_func* func; - nasal_scop* scop; }ptr; nasal_val(); @@ -232,20 +222,6 @@ nasal_func::nasal_func() return; } -/*functions of nasal_scop*/ -nasal_val* nasal_scop::get_val(int key) -{ - if(elems.count(key)) - return elems[key]; - return nullptr; -} -nasal_val** nasal_scop::get_mem(int key) -{ - if(elems.count(key)) - return &(elems[key]); - return nullptr; -} - /*functions of nasal_val*/ nasal_val::nasal_val() { @@ -264,7 +240,6 @@ nasal_val::nasal_val(int val_type) case vm_vec: ptr.vec=new nasal_vec; break; case vm_hash: ptr.hash=new nasal_hash; break; case vm_func: ptr.func=new nasal_func; break; - case vm_scop: ptr.scop=new nasal_scop; break; } return; } @@ -276,7 +251,6 @@ nasal_val::~nasal_val() case vm_vec: delete ptr.vec; break; case vm_hash: delete ptr.hash; break; case vm_func: delete ptr.func; break; - case vm_scop: delete ptr.scop; break; } type=vm_nil; return; @@ -289,7 +263,6 @@ void nasal_val::clear() case vm_vec: delete ptr.vec; break; case vm_hash: delete ptr.hash; break; case vm_func: delete ptr.func; break; - case vm_scop: delete ptr.scop; break; } type=vm_nil; return; @@ -304,7 +277,6 @@ void nasal_val::set_type(int val_type) case vm_vec: ptr.vec=new nasal_vec; break; case vm_hash: ptr.hash=new nasal_hash; break; case vm_func: ptr.func=new nasal_func; break; - case vm_scop: ptr.scop=new nasal_scop; break; } return; } @@ -329,14 +301,14 @@ struct nasal_gc nasal_val* zero_addr; // reserved address of nasal_val,type vm_num, 0 nasal_val* one_addr; // reserved address of nasal_val,type vm_num, 1 nasal_val* nil_addr; // reserved address of nasal_val,type vm_nil - nasal_val* global; // global scope address,type vm_scop nasal_val* val_stack[STACK_MAX_DEPTH]; nasal_val** stack_top; // stack top std::vector num_addrs; // reserved address for const vm_num - std::vector local; // local scope for function block std::vector slice_stack; // slice stack for vec[val,val,val:val] std::vector memory; // gc memory std::queue free_list; // gc free list + std::unordered_map global; + std::vector > local; void mark(); void sweep(); void gc_init(std::vector&); @@ -351,14 +323,16 @@ void nasal_gc::mark() zero_addr->mark=true; one_addr->mark=true; nil_addr->mark=true; - bfs.push(global); + for(auto i=global.begin();i!=global.end();++i) + bfs.push(i->second); int size=num_addrs.size(); for(int i=0;ibegin();j!=i->end();++j) + bfs.push(j->second); size=slice_stack.size(); for(int i=0;imark) bfs.push(*i); } - else if(tmp->type==vm_scop) - { - std::unordered_map& scop=tmp->ptr.scop->elems; - for(auto i=scop.begin();i!=scop.end();++i) - if(!i->second->mark) - bfs.push(i->second); - } } return; } @@ -442,9 +409,6 @@ void nasal_gc::gc_init(std::vector& nums) *val_stack=nil_addr; // the first space will not store any values,but gc checks - global=new nasal_val(vm_scop); // init global symbol table - memory.push_back(global); - num_addrs.clear(); // init constant numbers for(int i=0;iptr.scop->elems[exec_code[pc].num]=*stack_top--; + gc.global[exec_code[pc].num]=*stack_top--; return; } void nasal_vm::opr_loadl() { - gc.local.back()->ptr.scop->elems[exec_code[pc].num]=*stack_top--; + gc.local.back()[exec_code[pc].num]=*stack_top--; return; } void nasal_vm::opr_pnum() @@ -204,7 +204,7 @@ void nasal_vm::opr_newf() nasal_val* val=gc.gc_alloc(vm_func); val->ptr.func->entry=exec_code[pc].num; if(!gc.local.empty()) - val->ptr.func->closure=gc.local.back()->ptr.scop->elems; + val->ptr.func->closure=gc.local.back(); val->ptr.func->closure[me]=gc.nil_addr; *(++stack_top)=val; return; @@ -525,12 +525,12 @@ void nasal_vm::opr_feach() } void nasal_vm::opr_callg() { - *(++stack_top)=gc.global->ptr.scop->elems[exec_code[pc].num]; + *(++stack_top)=gc.global[exec_code[pc].num]; return; } void nasal_vm::opr_calll() { - *(++stack_top)=gc.local.back()->ptr.scop->elems[exec_code[pc].num]; + *(++stack_top)=gc.local.back()[exec_code[pc].num]; return; } void nasal_vm::opr_callv() @@ -633,14 +633,12 @@ void nasal_vm::opr_callf() return; } // push new local scope - nasal_val* closure=gc.gc_alloc(vm_scop); - gc.local.push_back(closure); + gc.local.push_back(func_addr->ptr.func->closure); // load parameters nasal_func& ref_func=*func_addr->ptr.func; std::vector& ref_para=ref_func.para; std::vector& ref_default=ref_func.default_para; - std::unordered_map& ref_closure=closure->ptr.scop->elems; - ref_closure=ref_func.closure; + std::unordered_map& ref_closure=gc.local.back(); if(para_addr->type==vm_vec) { @@ -677,7 +675,8 @@ void nasal_vm::opr_callf() die("callf: special call cannot use dynamic parameter"); return; } - for(int i=0;iptr.scop->elems[exec_code[pc].num]); + addr_stack.push(&gc.global[exec_code[pc].num]); return; } void nasal_vm::opr_mcalll() { - addr_stack.push(&gc.local.back()->ptr.scop->elems[exec_code[pc].num]); + addr_stack.push(&gc.local.back()[exec_code[pc].num]); return; } void nasal_vm::opr_mcallv() diff --git a/test/lib.nas b/stl/lib.nas similarity index 99% rename from test/lib.nas rename to stl/lib.nas index 2974927..a094a7a 100644 --- a/test/lib.nas +++ b/stl/lib.nas @@ -155,3 +155,5 @@ var math= sqrt: func(x) {return __builtin_sqrt(x); }, atan2: func(x,y){return __builtin_atan2(x,y);} }; + +var D2R=math.pi/180; \ No newline at end of file diff --git a/stl/list.nas b/stl/list.nas new file mode 100644 index 0000000..98109f6 --- /dev/null +++ b/stl/list.nas @@ -0,0 +1,73 @@ +# lib list.nas +# valkmjolnir 2021/3/31 +var list=func() +{ + var _={begin:nil,end:nil}; + return + { + push_back:func(elem) + { + var tmp={elem:elem,prev:nil,next:nil}; + if(_.end!=nil) + { + _.end.next=tmp; + tmp.prev=_.end; + _.end=tmp; + } + else + { + _.begin=tmp; + _.end=tmp; + } + return; + }, + push_front:func(elem) + { + var tmp={elem:elem,prev:nil,next:nil}; + if(_.begin!=nil) + { + _.begin.prev=tmp; + tmp.next=_.begin; + _.begin=tmp; + } + else + { + _.begin=tmp; + _.end=tmp; + } + return; + }, + pop_back:func() + { + if(_.end!=nil) + _.end=_.end.prev; + if(_.end==nil) + _.begin=nil; + else + _.end.next=nil; + return; + }, + pop_front:func() + { + if(_.begin!=nil) + _.begin=_.begin.next; + if(_.begin==nil) + _.end=nil; + else + _.begin.prev=nil; + return; + }, + front:func() + { + if(_.begin!=nil) + return _.begin.elem; + return nil; + }, + back:func() + { + if(_.end!=nil) + return _.end.elem; + return nil; + }, + }; +} \ No newline at end of file diff --git a/test/queue.nas b/stl/queue.nas similarity index 100% rename from test/queue.nas rename to stl/queue.nas diff --git a/stl/sort.nas b/stl/sort.nas new file mode 100644 index 0000000..0e5c3a1 --- /dev/null +++ b/stl/sort.nas @@ -0,0 +1,27 @@ +# lib sort.nas +# valkmjolnir 2021/4/2 +var sort=func(vec,left,right,cmp=func(a,b){return a<=b;}) +{ + if(left>=right) return nil; + var L=left; + var R=right; + var tmp=vec[L]; + while(left0? x:0; - }, - diffrelu_func:func(x) - { - return x>0; - }, - leaky_relu_func:func(k,x) - { - return x>0? x:k*x; - }, - diffleaky_relu_func:func(k,x) - { - return x>0? 1:k; - } -}; - -var matrix= -{ - new:func(col,row) - { - var new_mat= - { - col:col, - row:row, - mat:[] - }; - for(var i=0;i0.5) - mat.mat[i][j]=-rand(); - else - mat.mat[i][j]=rand(); - } - return; - }, - prt_mat:func(mat) - { - var prt_s='[\n'; - foreach(var i;mat.mat) - { - prt_s~='['; - foreach(var j;i) - prt_s~=(j~','); - prt_s~='],\n'; - } - prt_s~=']\n'; - print(prt_s); - return nil; - }, - mult_mat:func(mat1,mat2) - { - if(mat1.col!=mat2.row) - { - die("[error-mult] mat1\'s col does not match mat2\'s row."); - return nil; - } - var new_mat=me.new(mat2.col,mat1.row); - for(var i=0;i0.01) - { - error=0; - for(var i=0;i<4;i+=1) - { - me.forward(i); - error+=me.backward(i); - } - print(error); - } - return; - } -}; -var main=func() -{ - bp.init(); - bp.set_learning_rate(0.1); - bp.set_training_set(); - bp.set_expect_set(); - bp.training_process(); - return nil; -} - -main(); diff --git a/test/auto_crash.nas b/test/auto_crash.nas index 597e858..e13c864 100644 --- a/test/auto_crash.nas +++ b/test/auto_crash.nas @@ -1,5 +1,8 @@ -# Road check and auto pilot(??) by ValKmjolnir - +# Road check and auto pilot by ValKmjolnir +var dt=0.01; +var intergral=0; +var derivative=0; +var previous_error=0; var position_change = func(position_val,value){ if(position_val+value>180) position_val += value-360; @@ -10,12 +13,11 @@ var position_change = func(position_val,value){ return position_val; } var road_check_func = func(){ - + var lat = props.getNode("/position/latitude-deg",1).getValue(); var lon = props.getNode("/position/longitude-deg",1).getValue(); var position_info = geodinfo(lat,lon); var position_names = position_info[1].names; - # the friction_factor of freeway runway and road is 1 if((position_names[0]=="Freeway") or (position_names[0]=="Road")) { @@ -24,14 +26,14 @@ var road_check_func = func(){ var lon_change = 0; var left_range = 0; var right_range = 0; - + for(var i=0;i>-0.00005;i-=0.000001) { car_heading = props.getNode("/orientation/heading-deg",1).getValue(); - lat_change = math.sin(math.pi*car_heading/180); - lon_change = -math.cos(math.pi*car_heading/180); - lat = props.getNode("/position/latitude-deg",1).getValue()+0.0001*math.cos(math.pi*car_heading/180); - lon = props.getNode("/position/longitude-deg",1).getValue()+0.0001*math.sin(math.pi*car_heading/180); + lat_change = math.sin(D2R*car_heading); + lon_change = -math.cos(D2R*car_heading); + lat = props.getNode("/position/latitude-deg",1).getValue()+0.0001*math.cos(D2R*car_heading); + lon = props.getNode("/position/longitude-deg",1).getValue()+0.0001*math.sin(D2R*car_heading); var other_position_info = geodinfo(position_change(lat,i*lat_change),position_change(lon,i*lon_change)); var other_names = other_position_info[1].names; if((other_names[0]=="Freeway") or (other_names[0]=="Road")) @@ -42,10 +44,10 @@ var road_check_func = func(){ for(var i=0;i<0.00005;i+=0.000001) { car_heading = props.getNode("/orientation/heading-deg",1).getValue(); - lat_change = math.sin(math.pi*car_heading/180); - lon_change = -math.cos(math.pi*car_heading/180); - lat = props.getNode("/position/latitude-deg",1).getValue()+0.0001*math.cos(math.pi*car_heading/180); - lon = props.getNode("/position/longitude-deg",1).getValue()+0.0001*math.sin(math.pi*car_heading/180); + lat_change = math.sin(D2R*car_heading); + lon_change = -math.cos(D2R*car_heading); + lat = props.getNode("/position/latitude-deg",1).getValue()+0.0001*math.cos(D2R*car_heading); + lon = props.getNode("/position/longitude-deg",1).getValue()+0.0001*math.sin(D2R*car_heading); var other_position_info = geodinfo(position_change(lat,i*lat_change),position_change(lon,i*lon_change)); var other_names = other_position_info[1].names; if((other_names[0]=="Freeway") or (other_names[0]=="Road")) @@ -53,25 +55,26 @@ var road_check_func = func(){ else break; } - #if(left_range>right_range) - #{ - # setprop("/controls/flight/rudder",-(right_range-left_range)*(right_range-left_range)/10000); - # print("right ",right_range); - #} - #else if(left_range0) + props.getNode("/", 1).setValue("/controls/flight/rudder",Kp*error*error+Ki*intergral+Kd*derivative); + else + props.getNode("/", 1).setValue("/controls/flight/rudder",0); + previous_error=error; } }; -var road_check_timer = maketimer(0.1,road_check_func); + +var road_check_timer = maketimer(0.01,road_check_func); var toggle_auto_pilot = func(){ if(!road_check_timer.isRunning) { + intergral=0; road_check_timer.start(); props.getNode("/sim/messages/copilot",1).setValue("ze dong sheng teaan see tong yee tse yung. Auto Sheng Teaan System Activated!"); } @@ -80,4 +83,4 @@ var toggle_auto_pilot = func(){ road_check_timer.stop(); props.getNode("/sim/messages/copilot",1).setValue("ze dong sheng teaan see tong yee guan bee. Auto Sheng Teaan System is off."); } -} \ No newline at end of file +} diff --git a/test/bfs.nas b/test/bfs.nas index 81499fc..450cd27 100644 --- a/test/bfs.nas +++ b/test/bfs.nas @@ -1,5 +1,5 @@ -import("lib.nas"); -import("queue.nas"); +import("stl/lib.nas"); +import("stl/queue.nas"); rand(time(0)); @@ -26,13 +26,13 @@ var prt=func() var bfs=func(begin,end) { var move=[[1,0],[0,1],[-1,0],[0,-1]]; - var queue=new_queue(); - queue_push(queue,begin); + var que=queue(); + que.push(begin); map[begin[0]][begin[1]]=3; - while(!queue_empty(queue)) + while(!que.empty()) { - var vertex=queue_front(queue); - queue_pop(queue); + var vertex=que.front(); + que.pop(); foreach(var i;move) { var x=vertex[0]+i[0]; @@ -44,7 +44,7 @@ var bfs=func(begin,end) } if(0<=x and x<10 and 0<=y and y<10 and map[x][y]==0) { - queue_push(queue,[x,y]); + que.push([x,y]); map[x][y]=3; } } diff --git a/test/bp.nas b/test/bp.nas index 81c6594..67304b9 100644 --- a/test/bp.nas +++ b/test/bp.nas @@ -137,7 +137,7 @@ while(error>0.001) } cnt+=1; show+=1; - if(show==250) + if(show==300) { show=0; print('epoch ',cnt,':',error,'\r'); diff --git a/test/class.nas b/test/class.nas index 1f5e262..542c978 100644 --- a/test/class.nas +++ b/test/class.nas @@ -17,7 +17,11 @@ var student=func(name,age) var s=student('valk',24); s.print_info(); println(s.get_age(),' ',s.get_name()); -s.set_age(18); +s.set_age(20); s.set_name('aluo'); s.print_info(); +println(s.get_age(),' ',s.get_name()); +s.set_age(20); +s.set_name('Sidi Liang'); +s.print_info(); println(s.get_age(),' ',s.get_name()); \ No newline at end of file diff --git a/test/efb.nas b/test/efb.nas deleted file mode 100644 index 01c964d..0000000 --- a/test/efb.nas +++ /dev/null @@ -1,2044 +0,0 @@ -#// Wrappers for property I/O, for conveniently switching between two methods -var setProp = func(prop, value){ - #// setprop(prop, value); - props.getNode("/").setValue(prop, value); -} -var getProp = func(prop){ - #// getprop(prop); - props.getNode("/").getValue(prop); -} - -var ChartsList = -{ - 'KATL': - { - STAR: ["STAR_CANUK1_RNAV", "STAR_ERLIN9_RNAV", "STAR_FLCON7_RNAV", "STAR_HERKO6_RNAV", "STAR_HONIE8_RNAV", "STAR_LA_GRANGE2", "STAR_PECHY7_RNAV", "STAR_ROME4", "STAR_RPTOR1_RNAV", "STAR_SINCA5", "STAR_VIKNN_3RNAV", "STAR_WHINZ1"], - STARs: 12, - IAP: ["ILS_8L_Cat II - III", "ILS_PRM_8L", "ILS_PRM_8L_CAT II - III", "ILS_PRM_8R", "ILS_PRM_9L", "ILS-LOC_8L", "ILS-LOC_8R", "ILS-LOC_9L"], - IAPs: 8, - SID: ["SID_ATL5", "SID_BRAV6_RNAV", "SID_CADIT6_RNAV", "SID_COKEM5_RNAV", "SID_DAWGS5_RNAV", "SID_DOOLY5_RNAV", "SID_GEETK6_RNAV", "SID_JCKTS6_RNAV", "SID_JOGOR4_RNAV", "SID_MUNSN5_RNAV", "SID_NOVSS4_RNAV", "SID_NUGGT5_RNAV"], - SIDs: 12, - APT: "APT_0", - APTs: 1, - LOCATION: "ATLANTA USA", - NAME: "Hartsfield-Jackson" - }, - 'KLAX': - { - STAR: "REDEYE2", - STARs: 1, - IAP: ["06L-ILS", "06R-ILS", "07L-ILS", "07R-ILS"], - IAPs: 4, - SID: "SNGO6", - SIDs: 1, - APT: "APT_0", - APTs: 1, - LOCATION: "LOS ANGELES USA", - NAME: "Intntl" - }, - 'KIAH': - { - STAR: ["RIICE3_1", "RIICE_2"], - STARs: 2, - IAP: ["09-ILS", "15R-ILS"], - IAPs: 2, - SID: "", - SIDs: 0, - APT: "APT_0", - APTs: 1, - LOCATION: "HOUSTON USA", - NAME: "G. Bush Intctl" - }, - 'VABB': - { - STAR: "", - STARs: 0, - IAP: ["09-ILS-DME", "14-ILS-DME"], - IAPs: 2, - SID: "EKPOSxA", - SIDs: 1, - APT: "APT_0", - APTs: 1, - LOCATION: "MUMBAI IN", - NAME: "Chhatrapati Shivaji" - }, - 'KMEM': - { - STAR: "BEERT4", - STARs: 1, - IAP: "09-ILS_LOC", - IAPs: 1, - SID: "", - SIDs: 0, - APT: "APT_0", - APTs: 1, - LOCATION: "MEMPHIS USA", - NAME: "International" - }, - 'LFRB': - { - STAR: "STAR", - STARs: 1, - IAP: ["IAP_25L", "IAP_25L_RNAV", "ILS_Y_25L", "ILS_YZ_07R", "ILS_Z_25L", "NDB_25L", "RADAR", "RNAV_07R", "VFR_APP01", "VFR_LNDG_01"], - IAPs: 11, - SID: ["SID_07R", "SID_25L"], - SIDs: 2, - APT: ["APT_0", "APT_1"], - APTs: 2, - LOCATION: "BREST FR", - NAME: "Guipavas" - }, - 'LFRM': - { - STAR: ["VFR_APP01", "VFR_LND01"], - STARs: 2, - IAP: "", - IAPs: 0, - SID: "", - SIDs: 0, - APT: "APT_0", - APTs: 1, - LOCATION: "LE MANS FR", - NAME: "Arnage" - }, - 'LIME': - { - STAR: ["STAR_ASTIG_ODINA_1S", "STAR_ASTIG_ODINA_1T", "STAR_DIXER_GEN_IDONA_1S", "STAR_DIXER_GEN_IDONA_1T", "STAR_DORIN_LUSIL_OSKOR_1S", "STAR_DORIN_LUSIL_OSKOR_1T", "STAR_East", "STAR_West", "STAR_VOR_DME", "VOR_Y28", "VOR_Y28_2", "VOR_Z28"], - STARs: 12, - IAP: ["ILS-PAPA-28", "ILS-PAPA-28-CAT II", "ILS-SIERRA-28", "ILS-SIERRA-28-CAT II", "ILS-TANGO-28", "ILS-TANGO-28-CAT II", "ILS-X28", "ILS-Y28", "ILS-Z28"], - IAPs: 9, - SID: ["SID_10_BEKAN_DORIN_5S", "SID_10-28_BEKAN5T_DORIN5T_ORI5QT", "SID_10-28_Alternate", "SID_28_SRN5R_TZO5R_TZO5S", "SID_InitialClimb", "SID10_InitialClimb", "SID28_InitialClimb", "SID28_InitialClimb2", "DEP_North_East", "DEP_South", "DEP_West"], - SIDs: 12, - APT: ["APT_0", "APT_0_Small", "GROUND_East_Apron", "GROUND_North_Apron", "GROUND_West_Apron"], - APTs: 6, - LOCATION: "BERGAMO IT", - NAME: "Orio al Serio" - }, - 'LOWI': - { - STAR: ["26-RTT", "STAR", "VFR_East", "VFR_West_KTI", "West-NDB_KYI"], - STARs: 5, - IAP: ["LOC_26_RNAV", "LOC_DME_East", "LOC_DME_West", "NDB_East", "RNAV_08", "RNAV_26", "SPEC_LOC_DME_East"], - IAPs: 8, - SID: ["08-RTT", "General Departure", "SID_08", "SID0_RTT1W", "SID_08_SPECPERF_KPT1Z", "SID_08_SPECPERF_RTT2Z", "SID-26", "SID_26_MOGTI1H_RTT1Y", "SID_26_RNAV"], - SIDs: 9, - APT: ["APT_0", "APT_1"], - APTs: 2, - LOCATION: "INNSBRUCK AT", - NAME: "Kranebitten" - }, - 'WSSS': - { - STAR: ["BOBAG1A", "BOBAG1B", "LAVAX1A", "LAVAX1B"], - STARs: 4, - IAP: ["02C-VOR-DME", "02L-ILS", "02L-ILS-CATII", "20C-VOR-DME", "20R-ILS"], - IAPs: 5, - SID: "BOG1", - SIDs: 1, - APT: ["APT_0", "APT_1"], - APTs: 2, - LOCATION: "SINGAPORE SG", - NAME: "Changi" - }, -}; - -# used in page -var l=[]; -var r=[]; -for(var i=0;i<21;i+=1) -{ - append(l,""); - append(r,""); -} -var KCl0_0 = ""; -var KCl0_1 = ""; -var KCl0 = ""; -var KCl1 = ""; -var KCl2 = ""; -var KCl3 = ""; -var KCl4 = ""; -var KCr1 = ""; -var KCr2 = ""; -var KCr3 = ""; -var KCr4 = ""; -var KCr5 = ""; -var KCr6 = ""; -var ChartName = ["NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL"]; -var ChartDisp = ["NULL", "NULL", "NULL"]; -var Keyboard_Helper = ""; -var Keyboard_Message = ""; -var Index_Max = 0; -var Index_Offset = 0; -var PageList = 0; - -# used in efb -var ZoomFact = 0; -var PanHFact = 0; -var PanVFact = 0; -var OriginApt = "NOT Set"; -var DestinationApt = "NOT Set"; -var ClosingFlightFlag = 0; -var lenght = 0; -var Temp_String = ""; -var Cnv_Fact = 0; -var VK_Key = ""; -var VK_Input_Mem = 0; -var VK_Output_Mem = 0; -var TMZ_Input_Lenght = 0; -var TMZ_Converted_ID = ""; -var TMZ_Converted_Name = ""; -var TMZ_Converted_OffSet = ""; -var TMZ_zulu_HH = ""; -var TMZ_Index = 0; -var TMZ_DB_Size = 0; -var Output_TMZ_Line = ""; -var TMZ_DATE = ""; -var TMZ_TIME = ""; -var Output_HH = 0; -var Output_MM = 0; -var CUT = ["NULL", "NULL", "NULL"]; -var Initial_FL = 0; -var Target_FL = 0; -var Initial_GS = 0; -var Target_GS = 0; -var DRC_String = ""; -var DRC_Input_Lenght = 0; - -# public vars -var helper = ""; -var keypress = ""; -var nochart = ""; -var AptName = "Unknown"; -var Chart_Pages = 1; -var DRC_Distance = 0; -var DRC_l3 = ""; -var DRC_r3 = ""; -var DRC_l5 = ""; -var DRC_r5 = ""; -var DRC_l7 = ""; -var DRC_r8 = ""; -var DRC_r9 = ""; -var DRC_r10 =""; - -# Chart Properties -ident = getProp("/sim/airport/closest-airport-id"); -#AptName = getProp("/instrumentation/efb/chart/icao"); - -if (ident != nil) -{ - setProp("instrumentation/efb/chart/icao", ident); - setProp("instrumentation/efb/chart/DEP_icao", getProp("/instrumentation/efb/chart/icao")); -} else setProp("/instrumentation/efb/chart/icao", ""); -setProp("/instrumentation/efb/chart/type", "APT"); -setProp("/instrumentation/efb/chart/newairport", 0); -setProp("/instrumentation/efb/FlightStatus", 0); # INACTIVE -nochart = 0; - -var page = { - update : func { - for(var i=0; i<21; i+=1) - setProp("/instrumentation/efb/display/line"~i~"-l", l[i]); - # r[0] haven't been used - for(var i=1; i<21; i+=1) - setProp("/instrumentation/efb/display/line"~i~"-r", r[i]); - setProp("/instrumentation/efb/display/input-helper", helper); - setProp("/instrumentation/efb/keypress", keypress); - return; - }, - clearpage : func { - for(var i=0; i<21; i+=1){ - l[i] = ""; - r[i] = ""; - } - helper = ""; - return; - }, - index : func { - for(var i=0; i<21; i+=1){ - l[i] = ""; - r[i] = ""; - } - return; - }, - index_TEST : func { - for(var i=0; i<21; i+=1) - l[i] = "< TEST_L"~i; - # r[0] haven't been used - for(var i=1; i<15; i+=1) - r[i] = "TEST >"; - for(var i=15; i<21; i+=1) - r[i] = "TEST_R"~i~" >"; - return; - }, - KCupdate : func { - setProp("/instrumentation/efb/display/lineAPT_NAME", KCl0); - setProp("/instrumentation/efb/display/lineAPT_LOCATION", KCl0_0); - setProp("/instrumentation/efb/display/lineAPT_PAGESHOW", KCl0_1); - setProp("/instrumentation/efb/display/lineSTAR", KCl1); - setProp("/instrumentation/efb/display/lineIAP", KCl2); - setProp("/instrumentation/efb/display/lineSID", KCl3); - setProp("/instrumentation/efb/display/lineAPT", KCl4); - - setProp("/instrumentation/efb/display/lineCHART1-r", KCr1); - setProp("/instrumentation/efb/display/lineCHART2-r", KCr2); - setProp("/instrumentation/efb/display/lineCHART3-r", KCr3); - - setProp("/instrumentation/efb/Keyboard/CHART_Input_Line", Keyboard_Helper); - setProp("/instrumentation/efb/Keyboard/CHART_Output_Line", Keyboard_Message); - }, - KCclearpage : func { - KCl0 = ""; - KCl0_0 = ""; - KCl0_1 = ""; - KCl1 = ""; - KCl2 = ""; - KCl3 = ""; - KCl4 = ""; - - KCr1 = ""; - KCr2 = ""; - KCr3 = ""; - - Keyboard_Helper = ""; - Keyboard_Message = ""; - helper = ""; - }, - DRCupdate : func { - setProp("/instrumentation/efb/display/DRC_l3", DRC_l3); - setProp("/instrumentation/efb/display/DRC_l5", DRC_l5); - setProp("/instrumentation/efb/display/DRC_r3", DRC_r3); - setProp("/instrumentation/efb/display/DRC_r5", DRC_r5); - setProp("/instrumentation/efb/display/DRC_l7", DRC_l7); - setProp("/instrumentation/efb/display/DRC_r8", DRC_r8); - setProp("/instrumentation/efb/display/DRC_r9", DRC_r9); - setProp("/instrumentation/efb/display/DRC_r10", DRC_r10); - }, - DRCclearpage : func { - DRC_l3 = ""; - DRC_l5 = ""; - DRC_r3 = ""; - DRC_r5 = ""; - DRC_l7 = ""; - DRC_r8 = ""; - DRC_r9 = ""; - DRC_r10 = ""; - }, - airportinfo : func { - var ClosestName = ""; - if (getProp("/instrumentation/gps/scratch/name") == nil) - ClosestName = ""; - else - ClosestName = getProp("/instrumentation/gps/scratch/name"); - l[2] = "Airport : " ~ getProp("/instrumentation/gps/scratch/ident") ~ " (" ~ ClosestName ~ ")"; - l[3] = "Latitude : " ~ sprintf("%3.4f", getProp("/instrumentation/gps/scratch/latitude-deg")); - l[4] = "Longitude : " ~ sprintf("%3.4f", getProp("/instrumentation/gps/scratch/longitude-deg")); - l[5] = "Elevation : " ~ sprintf("%3.4f", getProp("/instrumentation/gps/scratch/altitude-ft")) ~ " ft"; - setProp("/environment/metar[6]/station-id", getProp("/instrumentation/gps/scratch/ident")); - l[7] = "Runways : "; - l[8] = " "; - for (var n=0; n<12; n+=1) { - if (getProp("/instrumentation/gps/scratch/runways[" ~ n ~ "]/id") != nil) { - if (n <= 7) l[7] = l[7] ~ getProp("/instrumentation/gps/scratch/runways[" ~ n ~ "]/id") ~ " "; - else l[8] = l[8] ~ getProp("/instrumentation/gps/scratch/runways[" ~ n ~ "]/id") ~ " "; - } - l[10] = "Weather Source: NOAA/METAR"; - r[10] = substr(getProp("/environment/metar[6]/data"),0,16) ~ "z"; - l[11] = substr(getProp("/environment/metar[6]/data"),17,41); - if (size(getProp("/environment/metar[6]/data")) > 41) - l[12] = substr(getProp("/environment/metar[6]/data"), 58, 41); - l[13] = " Current Weather Situation"; - l[14] = "Temperature : " ~ sprintf("%3.2f", getProp("/environment/metar[6]/temperature-degc")) ~ " �C"; - r[14] = "Dewpoint : " ~ sprintf("%3.2f", getProp("/environment/metar[6]/dewpoint-degc")) ~ " �C"; - l[15] = "Wind Direction : " ~ sprintf("%3.0f", getProp("/environment/metar[6]/base-wind-dir-deg")) ~ " degs"; - r[15] = "Wind Speed : " ~ sprintf("%3.0f", getProp("/environment/metar[6]/base-wind-speed-kt")) ~ " Kt"; - l[16] = "Max Visibility : " ~ sprintf("%3.0f", getProp("/environment/metar[6]/max-visibility-m")) ~ " ft"; - r[16] = "Min Visibility : " ~ sprintf("%3.0f", getProp("/environment/metar[6]/min-visibility-m")) ~ " ft"; - l[17] = "Relative Humidity : " ~ sprintf("%3.2f", getProp("/environment/metar[6]/rel-humidity-norm")) ~ " %"; - l[18] = "Pressure : " ~ sprintf("%3.2f", getProp("/environment/metar[6]/pressure-inhg")) ~ " inHg"; - l[20] = "Weather Report subject to Station availability"; - } - }, - FlightMonitor : func { - if (getProp("/instrumentation/efb/FlightStatus") == 1) { - var FStatus = "ACTIVE"; - } else FStatus = "INACTIVE"; - if (getProp("/autopilot/route-manager/active") == 1) { - if (getProp("/autopilot/route-manager/departure/takeoff-time") != nil) { - var TOT = getProp("/autopilot/route-manager/departure/takeoff-time") ~ "z"; - } else TOT = "Unknown"; - if (getProp("/autopilot/route-manager/destination/touchdown-time") != nil) { - var TDT = getProp("/autopilot/route-manager/destination/touchdown-time") ~ "z"; - } else TDT = "Unknown"; - var OAPT = getProp("/autopilot/route-manager/departure/airport") ~ " " ~ getProp("/autopilot/route-manager/departure/runway"); - var DAPT = getProp("/autopilot/route-manager/destination/airport") ~ " " ~ getProp("/autopilot/route-manager/destination/runway"); - } else { - OAPT = "NOT Set"; - DAPT = "NOT Set"; - TOT = "Unknown"; - TDT = "Unknown"; - } - l[2] = "Aircraft: " ~ getProp("/sim/description") ~ " Seattle"; - l[3] = "Operator: " ~ substr(getProp("/sim/aircraft-operator"),0,3); - r[3] = "CallSign: " ~ substr(getProp("/sim/multiplay/callsign"), 0,6); - l[4] = "Flight No: " ~ "NOT Set"; # This will be set through CDU (To be done) - r[4] = "Flight Status: " ~ FStatus; - l[5] = "Origin APT: " ~ OAPT; - r[5] = "TO Time: " ~ TOT; - l[6] = "Destination APT: " ~ DAPT; - r[6] = "TD Time: " ~ TDT; - l[7] = "Date: " ~ substr(getProp("environment/metar/data"),0,10); - r[7] = "Time: " ~ getProp("/instrumentation/clock/indicated-short-string") ~ "z"; - l[9] = "Ind. ALT: " ~ sprintf("%3.2f", getProp("/Instrumentation/altimeter/indicated-altitude-ft")) ~ " ft"; - r[9] = "Press. ALT: " ~ sprintf("%3.2f", getProp("/Instrumentation/altimeter/pressure-alt-ft")) ~ " ft"; - l[10] = "Press. hPa: " ~ sprintf("%3.2f", getProp("/Instrumentation/altimeter/setting-hpa")); - r[10] = "Press. inHg: " ~ sprintf("%3.2f", getProp("/Instrumentation/altimeter/setting-inhg")); - l[11] = "Speed Knots: " ~ sprintf("%3.0f", getProp("/Instrumentation/airspeed/indicated-speed-kt")); - r[11] = "Speed Mach: " ~ sprintf("%3.0f", getProp("/Instrumentation/airspeed/indicated-mach")); - l[12] = "Temperature �C: " ~ sprintf("%3.2f", getProp("/environment/temperature-degc")); - r[12] = "Temperature �F: " ~ sprintf("%3.2f", getProp("/environment/temperature-degf")); - l[13] = "Wind Dir.: " ~ sprintf("%3.0f", getProp("/environment/metar/base-wind-dir-deg")) ~ " degs"; - r[13] = "Wind Speed: " ~ sprintf("%3.0f", getProp("/environment/base-wind-speed-kt")) ~ " kts"; - l[14] = "Total Fuel: " ~ sprintf("%3.2f", getProp("/consumables/fuel/total-fuel-gals")) ~ " gals"; - l[15] = "Gross Weight: " ~ sprintf("%3.2f", getProp("/yasim/gross-weight-lbs")) ~ " lbs"; - # warning: this line l[14] has been changed to l[15],be careful of bugs.But it must be at the right side - }, - gps : func { - l[1] = " GPS POSITION / SETTINGS"; - l[2] = "Latitude : " ~ sprintf("%3.2f", getProp("/instrumentation/gps/indicated-latitude-deg")) ~ " degs"; - r[2] = "Longitude : " ~ sprintf("%3.2f", getProp("/instrumentation/gps/indicated-longitude-deg")) ~ " degs"; - l[13] = "GPS Mode: " ~ getProp("/instrumentation/gps/mode"); - r[13] = "WayPoint ID: " ~ getProp("/instrumentation/gps/wp/wp[1]/ID"); - l[14] = "Leg Distance: " ~ sprintf("%3.2f", getProp("/instrumentation/gps/wp/leg-distance-nm")) ~ " Nm"; - l[15] = "Leg Magnetic Course : " ~ sprintf("%3.2f", getProp("/instrumentation/gps/wp/leg-mag-course-deg")) ~ " degs"; - l[16] = "Leg True Heading: " ~ sprintf("%3.2f", getProp("/instrumentation/gps/wp/leg-true-course-deg")) ~ " degs"; - }, - charts_keyboard : func { - setProp("/instrumentation/efb/chart/Status", "ON"); - setProp("/instrumentation/efb/chart/type", "APT"); - PageList = getProp("/instrumentation/efb/chart/PageList"); - - # Checks existence of Charts in the DB by chart's type ~ "-0"; example: "KSFO/type-0" - var Chart_Search = ""; - Chart_Search = sprintf("%s", getProp("/instrumentation/efb/chart/icao")); - - # HERE we need to launch the SEARCH into the ChartsList hash - #if (getProp("/instrumentation/efb/chartsDB/" ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ "/" ~ getProp("/instrumentation/efb/chart/type") ~ "-0") == nil ) { - # setProp("/instrumentation/efb/chart_Found", "NOT_FOUND"); - # nochart = 1; - #} else { - # setProp("/instrumentation/efb/chart_Found", "FOUND"); - # nochart = 0; - #} - - setProp("/instrumentation/efb/Keyboard/CHART_Input_Line", "Charts for " ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ ": " ~ getProp("/instrumentation/efb/chart_Found")); - if (nochart == 0) { - # gets the APT's Name & Location - setProp("/instrumentation/efb/chart/type", "NAME"); - KCl0 = getProp("/instrumentation/efb/chartsDB/" ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ "/" ~ getProp("/instrumentation/efb/chart/type")); - setProp("/instrumentation/efb/chart/type", "LOCATION"); - KCl0_0 = getProp("/instrumentation/efb/chartsDB/" ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ "/" ~ getProp("/instrumentation/efb/chart/type")); - - setProp("/instrumentation/efb/chart/type", "APT"); - # Gets the number of charts (by Type) in the Charts DB - STAR_Status = setProp("/instrumentation/efb/chart/NumSTARs", (getProp("/instrumentation/efb/chartsDB/" ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ "/" ~ "STARs"))); - IAP_Status = setProp("/instrumentation/efb/chart/NumIAPs", (getProp("/instrumentation/efb/chartsDB/" ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ "/" ~ "IAPs"))); - SID_Status = setProp("/instrumentation/efb/chart/NumSIDs", (getProp("/instrumentation/efb/chartsDB/" ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ "/" ~ "SIDs"))); - APT_Status = setProp("/instrumentation/efb/chart/NumAPTs", (getProp("/instrumentation/efb/chartsDB/" ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ "/" ~ "APTs"))); - - # Gets the Type of chart from Pilot's Selection - - if (getProp("/instrumentation/efb/VK_Chart_Type") != "") { - if (getProp("/instrumentation/efb/VK_Chart_Type") == "STAR") { - setProp("/instrumentation/efb/chart/type", "STAR"); - Keyboard_Message = getProp("/instrumentation/efb/chart/NumSTARs") ~ " " ~ getProp("/instrumentation/efb/chart/type") ~ " Charts for " ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ " Apt - Select a Chart"; - STAR_Status = 1; - } else STAR_STATUS = 0; - if (getProp("/instrumentation/efb/VK_Chart_Type") == "IAP") { - setProp("/instrumentation/efb/chart/type", "IAP"); - Keyboard_Message = getProp("/instrumentation/efb/chart/NumIAPs") ~ " " ~ getProp("/instrumentation/efb/chart/type") ~ " Charts for " ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ " Apt - Select a Chart"; - IAP_Status = 1; - } else IAP_Status = 0; - if (getProp("/instrumentation/efb/VK_Chart_Type") == "SID") { - setProp("/instrumentation/efb/chart/type", "SID"); - Keyboard_Message = getProp("/instrumentation/efb/chart/NumSIDs") ~ " " ~ getProp("/instrumentation/efb/chart/type") ~ " Charts for " ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ " Apt - Select a Chart"; - SID_Status = 1; - } else SID_Status = 0; - if (getProp("/instrumentation/efb/VK_Chart_Type") == "APT") { - setProp("/instrumentation/efb/chart/type", "APT"); - Keyboard_Message = getProp("/instrumentation/efb/chart/NumAPTs") ~ " " ~ getProp("/instrumentation/efb/chart/type") ~ " Charts for " ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ " Apt - Select a Chart"; - APT_Status = 1; - } else APT_Status = 0; - - setProp("/instrumentation/efb/VK_Chart_Type", getProp("/instrumentation/efb/chart/type")); - setProp("/instrumentation/efb/chartsDB", "ChartsDB/"); - - #setProp("/instrumentation/efb/chart/selected", getProp("/instrumentation/efb/chartsDB/" ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ "/" ~ getProp("/instrumentation/efb/chart/type") ~ "-1")); - - var lastn = getProp("/instrumentation/efb/chartsDB/" ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ "/" ~ getProp("/instrumentation/efb/chart/type") ~ "s") - 1; - if (lastn <= 0) lastn = 0; - - if ((STAR_Status == 0) and (IAP_Status == 0) and (SID_Status == 0) and (APT_Status == 0)) { - setProp("/instrumentation/efb/chart/Status", 0); - Keyboard_Message = "No Charts available for: " ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ " Apt"; - setProp("/instrumentation/efb/chart/Status", "OFF"); - } - - # Gets the available ICAO/Type charts in the Charts DB - for (var index = 0; index <= 29; index += 1) - ChartName[index] = ""; - - if (lastn > 0) { - for (var index = 0; index <= lastn; index += 1) { - setProp("/instrumentation/efb/chart/IDX", index); - setProp("/instrumentation/efb/chart/selected", (getProp("/instrumentation/efb/chartsDB/" ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ "/" ~ getProp("/instrumentation/efb/chart/type") ~ "-" ~ getProp("/instrumentation/efb/chart/IDX")))); - ChartName[index] = getProp("/instrumentation/efb/chart/selected"); - } - } else { - setProp("/instrumentation/efb/chart/selected", (getProp("/instrumentation/efb/chartsDB/" ~ sprintf("%s", getProp("/instrumentation/efb/chart/icao")) ~ "/" ~ getProp("/instrumentation/efb/chart/type") ~ "-0"))); - ChartName[0] = getProp("/instrumentation/efb/chart/selected"); - } - Keyboard_Helper = "Enter Airport ICAO"; - setProp("/instrumentation/efb/Keyboard/CHART_Input_Line", Keyboard_Helper); - setProp("/instrumentation/efb/Keyboard/CHART_Output_Line", Keyboard_Message); - - # Prints Charts values to Upper Input Display - if (getProp("/instrumentation/efb/chart/Status") == "ON") { - KCl1 = sprintf(getProp("/instrumentation/efb/chart/NumSTARs")); - KCl2 = sprintf(getProp ("/instrumentation/efb/chart/NumIAPs")); - KCl3 = sprintf(getProp ("/instrumentation/efb/chart/NumSIDs")); - KCl4 = sprintf(getProp ("/instrumentation/efb/chart/NumAPTs")); - - # Set Index Offset for proper Page Display (by 3 rows) - if (lastn <=2) Index_Max = 0; - elsif ((lastn > 2) and (lastn <= 5)) Index_Max = 3; - elsif ((lastn > 5) and (lastn <= 8)) Index_Max = 6; - elsif ((lastn > 8) and (lastn <=11)) Index_Max = 9; - elsif ((lastn > 11) and (lastn <=14)) Index_Max = 12; - elsif ((lastn > 14) and (lastn <=17)) Index_Max = 15; - elsif ((lastn > 17) and (lastn <=20)) Index_Max = 18; - elsif ((lastn > 20) and (lastn <=23)) Index_Max = 21; - elsif ((lastn > 23) and (lastn <=26)) Index_Max = 24; - elsif ((lastn > 26) and (lastn <=29)) Index_Max = 27; - - Chart_Pages = (Index_Max/3) + 1; - - # Displays Actual Chart Page/Total Pages - var Page_Show = "Page " ~ getProp("/instrumentation/efb/chart/PageList") ~ "/" ~ Chart_Pages; - setProp("instrumentation/efb/chart/PageShow", Page_Show); - KCl0_1 = getProp("/instrumentation/efb/chart/PageShow"); - - # Build 3 rows of Chart Names - for (var index = 0; index <= 2; index += 1) { - Index_Offset = ((getProp("/instrumentation/efb/chart/PageList") - 1) * 3); - Index_Offset = Index_Offset + index; - ChartDisp[index] = ChartName[Index_Offset]; - } - # Displays 3 Chart Names [MAX Lenght = 27 chars !], ready for Selection by the Pilot - setProp("instrumentation/efb/chart/Selection_0", ChartDisp[0]); - setProp("instrumentation/efb/chart/Selection_1", ChartDisp[1]); - setProp("instrumentation/efb/chart/Selection_2", ChartDisp[2]); - KCr1 = substr(getProp("instrumentation/efb/chart/Selection_0"), 0, 26); - KCr2 = substr(getProp("instrumentation/efb/chart/Selection_1"), 0, 26); - KCr3 = substr(getProp("instrumentation/efb/chart/Selection_2"), 0, 26); - } else { - KCl0 = ""; - KCl0_0 = ""; - KCl0_1 = ""; - KCl1 = ""; - KCl2 = ""; - KCl3 = ""; - KCl4 = ""; - - KCr1 = ""; - KCr2 = ""; - KCr3 = ""; - setProp("instrumentation/efb/chart/Selection_0", ""); - setProp("instrumentation/efb/chart/Selection_1", ""); - setProp("instrumentation/efb/chart/Selection_2", ""); - } - page.KCupdate(); - } - } # END of 'nochart == 0' Brace - } -}; - -var efb = { - init : func { - me.UPDATE_INTERVAL = 0.05; - me.loopid = 0; - # INITIALIZE - - setProp("/instrumentation/efb/page", "MENU"); - setProp("/sim/model/efb/page", "Displays/Main_Menu.jpg"); - - # Chart Section Stuff - - setProp("/instrumentation/efb/chart/type", "APT"); - setProp("/instrumentation/efb/chart/selected", "APT_0"); - setProp("/instrumentation/efb/VK_keypress", ""); - setProp("/instrumentation/efb/Keyboard/CHART_Input_Line", ""); - setProp("/instrumentation/efb/chart/rotation", 0); - setProp("/instrumentation/efb/diagram/rotation", 0); - - AptName = getProp("/instrumentation/efb/chart/icao"); - - # Various Stuff - - setProp("/instrumentation/efb/manual-page", 0); - - setProp("/instrumentation/efb/vnav_autogen/first", 0); - setProp("/instrumentation/efb/vnav_autogen/gen", 0); - TMZ_DB_Size = getProp("/instrumentation/efb/TimeZonesDB/TMZ_DB_Size") - 1; - setProp("/instrumentation/efb/chart/PageList", 1); - me.reset(); - }, - searchairport : func(query) { - setProp("/instrumentation/gps/scratch/query", query); - setProp("/instrumentation/gps/scratch/type", "airport"); - setProp("/instrumentation/gps/command", "search"); - setProp("/instrumentation/efb/selected-rwy/id", ""); - }, - searchcomms : func(query) { - setProp("/sim/gui/dialogs/scratch/airports/selected-airport/id", query); - #setProp("/sim/gui/dialogs/airports/scratch/type", "airport"); - setProp("/sim/gui/dialogs/scratch/airports/mode", "search"); - #setProp("/instrumentation/efb/selected-rwy/id", ""); - }, - searchcharts : func(chart) {setProp("/sim/model/efb/chart", "Charts/" ~ chart ~ ".jpg");}, - efbTimer : nil, - update : func { - var keypress = getProp("/instrumentation/efb/keypress"); - var currentPage = getProp("/instrumentation/efb/page"); - if (currentPage == "MENU") { - # Make sure we know the APT's ICAO - setProp("/instrumentation/gps/scratch/ident", getProp("/sim/airport/closest-airport-id")); - - if (getProp("/instrumentation/gps/scratch/ident") != nil) setProp("/instrumentation/efb/chart/icao", sprintf("%s", getProp("/instrumentation/gps/scratch/ident"))); - else setProp("/instrumentation/efb/chart/icao", ""); - - AptName = sprintf("%s", getProp("/instrumentation/efb/chart/icao")); - page.clearpage(); - page.index(); - - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/Main_Menu.jpg"); - keypress = ""; - } - elsif (keypress == "l1") { - setProp("/instrumentation/efb/page", "CHARTS"); - setProp("/instrumentation/efb/chart/chartmenu", 0); - setProp("/instrumentation/efb/chart/zoom-in", 0); - ZoomFact = 0; - PanHFact = 0; - PanVFact = 0; - keypress = ""; - } - elsif (keypress == "r1") { - setProp("/sim/model/efb/page", "Displays/Video_1.jpg"); - setProp("/instrumentation/efb/page", "VIDEO"); - keypress = ""; - } - elsif (keypress == "l2") { - setProp("/sim/model/efb/page", "Displays/Performance_1.jpg"); - setProp("/instrumentation/efb/page", "PERFORMANCE"); - keypress = ""; - } - elsif (keypress == "r2") { - setProp("/sim/model/efb/page", "Displays/Documents_1.jpg"); - setProp("/instrumentation/efb/page", "DOCUMENTS"); - keypress = ""; - } - elsif (keypress == "l4") { - setProp("/sim/model/efb/page", "Displays/Airport_Info.jpg"); - setProp("/instrumentation/efb/page", "APT INFO"); - keypress = ""; - } - elsif (keypress == "l5") { - setProp("/instrumentation/efb/page", "Airport Charts"); - keypress = ""; - } - elsif (keypress == "l7") { - setProp("/sim/model/efb/page", "Displays/IDENT_1.jpg"); - setProp("/instrumentation/efb/page", "IDENT"); - keypress = ""; - } - elsif (keypress == "l8") { - setProp("/sim/model/efb/page", "Displays/System_1.jpg"); - setProp("/instrumentation/efb/page", "SYSTEMS"); - keypress = ""; - } - elsif (keypress == "r4") { - #//setProp("/instrumentation/efb/page", "Airport Diagram"); - keypress = ""; - } - elsif (keypress == "r5") { - setProp("/sim/model/efb/page", "Displays/PU_1.jpg"); - setProp("/instrumentation/efb/page", "UTILITIES"); - keypress = ""; - } - elsif (keypress == "r6") { - #//setProp("/instrumentation/efb/page", "Flight Fuel Planner"); - keypress = ""; - } - elsif (keypress == "r7") { - setProp("/sim/model/efb/page", "Displays/Monitor.jpg"); - setProp("/instrumentation/efb/page", "MONITOR"); - keypress = ""; - } - elsif (keypress == "r8") { - setProp("/instrumentation/efb/page", "INITIALIZE"); - keypress = ""; - } - #__________________________________________________________________________________________ - # CHART SECTION Parser --------------------------------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "CHARTS") { - page.clearpage(); - #setProp("/sim/model/efb/chart", "Displays/Help_1.jpg"); - setProp("/instrumentation/efb/diagram/rotation", 0); - setProp("/instrumentation/efb/diagram/chartmenu", 0); - setProp("/instrumentation/efb/chartsDB", "Charts/"); - #helper = ""; - # NOTE: this gives the Airport's name to be used on the bottom line of the Chart Display) has still to be checked: if RouteManager is not selected from the upper MENU, the property is not active... - AptName = getProp("/instrumentation/efb/chart/icao"); - - #_____________________________ - # Chart Selection at Airport | - #_____________________________| - - # Checks existence of Charts in the DB - - if(ChartsList[AptName] == nil){ - setProp("/instrumentation/efb/chart_Found", "NOT_FOUND"); - nochart = 1; - }else{ - setProp("/instrumentation/efb/chart_Found", "FOUND"); - nochart = 0; - } - if (nochart == 0){ - page.update(); - if (getProp("/instrumentation/efb/chart/type") == "APT"){ - l[0] = "AIRPORT MAP"; - } - else l[0] = ""; - - l[20] = AptName; - efb.searchcharts(AptName ~ "/" ~ getProp("/instrumentation/efb/chart/type") ~ "/" ~ getProp("/instrumentation/efb/chart/selected")); - #efb.searchcharts(AptName ~ "/" ~ getProp("/instrumentation/efb/chart/type") ~ "/" ~ getProp("instrumentation/efb/chart/selection2"); - setProp("/sim/model/efb/chart", getProp("/sim/model/efb/chart")); - setProp("/sim/model/efb/chart_BKUP", getProp("/sim/model/efb/chart")); - setProp("/sim/model/efb/Chart_2", getProp("/sim/model/efb/chart_BKUP")); - setProp("/sim/model/efb/Chart_4", getProp("/sim/model/efb/chart_BKUP")); - setProp("/sim/model/efb/Ovlay_1", "Displays/drawing.png"); - - if (getProp("/instrumentation/efb/chart/chartmenu") == 0) setProp("/sim/model/efb/Ovlay_1", "Displays/drawing.png"); - if (getProp("/instrumentation/efb/chart/chartmenu") == 1) setProp("/sim/model/efb/Ovlay_1", "Displays/drawing2.png"); - - } else { - setProp("/sim/model/efb/chart", "Displays/NoCharts.jpg"); - setProp("/sim/model/efb/Ovlay_1", "Displays/drawingNULL.png"); - helper = "Airport: " ~ AptName; - } - # Handles the Zoom-In and Zoom-Out EFB buttons on Charts Display; available ZoomFact is 2x and 4x only. - if ((ZoomFact >= 0) and (ZoomFact <= 4)) { - if ((keypress == "Zin") and (nochart == 0)) { - ZoomFact = ZoomFact + 2; - setProp("/instrumentation/efb/chart/zoom-in", ZoomFact); - keypress = ""; - } - elsif ((keypress == "Zout") and (nochart == 0) and (ZoomFact > 0)) { - ZoomFact = ZoomFact - 2; - setProp("/instrumentation/efb/chart/zoom-in", ZoomFact); - keypress = ""; - } - } - if (ZoomFact == 0) setProp("/instrumentation/efb/chart/zoom-in", 0); - # Handles the Pan-Right, Pan_Left, ScrollUP and ScrollDN EFB buttons on Charts Display; Pan Horizontal Factor is 100; Pan Vertical Factor is 100. - if ((ZoomFact == 2) or (ZoomFact == 4)) { - if ((keypress == "Move_R") and (nochart == 0)) { - PanHFact = PanHFact + 100; - setProp("/instrumentation/efb/chart/panH", PanHFact); - keypress = ""; - } - elsif ((keypress == "Move_L") and (nochart == 0)) { - PanHFact = PanHFact - 100; - setProp("/instrumentation/efb/chart/panH", PanHFact); - keypress = ""; - } - elsif ((keypress == "ScrollUP") and (nochart == 0)) { - PanVFact = PanVFact + 100; - setProp("/instrumentation/efb/chart/panV", PanVFact); - keypress = ""; - } - elsif ((keypress == "ScrollDN") and (nochart == 0)) { - PanVFact = PanVFact - 100; - setProp("/instrumentation/efb/chart/panV", PanVFact); - keypress = ""; - } - } elsif (ZoomFact == 0) { - setProp("/instrumentation/efb/chart/panH", -PanHFact); - setProp("/instrumentation/efb/chart/panV", -PanVFact); - } - # Handles Chart Rotation counter-clockwise - if ((keypress == "l2") and (nochart == 0) and (getProp("/instrumentation/efb/chart/chartmenu")) == 0) toggle("/instrumentation/efb/chart/rotation"); - # Toggles Overlay Menu On/OFF - if ((keypress == "r8") and (nochart == 0)) toggle("/instrumentation/efb/chart/chartmenu"); - # Calls Virtual Keyboard for Chart DB Selection by the Pilot - if (keypress == "l5") { - setProp("/instrumentation/efb/page", "CHARTS_KEYBOARD"); - setProp("/instrumentation/efb/chart/zoom-in", 0); - setProp("/instrumentation/efb/VKDRC_keypress", ""); - setProp("/instrumentation/efb/VK_Keyboard/Input_String", ""); - setProp("/instrumentation/efb/chart/Searchable", 0); - } - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/Main_Menu.jpg"); - setProp("/instrumentation/efb/chart/zoom-in", 0); - ZoomFact = 0; - PanHFact = -PanHFact; - PanVFact = -PanVFact; - setProp("/instrumentation/efb/page", "MENU"); - keypress = ""; - } - #__________________________________________________________________________________________ - # AIRPORT INFO SECTION Parser -------------------------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "APT INFO") { - - page.clearpage(); - efb.searchairport(getProp("/sim/airport/closest-airport-id")); - efb.searchcomms(getProp("/sim/airport/closest-airport-id")); - page.airportinfo(); - page.update(); - - # if (keypress == "r6") { - # setProp("/instrumentation/efb/page", "Runway Information"); - # keypress = ""; - # } - if (keypress == "r8") { - setProp("/instrumentation/efb/page", "CHARTS"); - keypress = ""; - } - elsif (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/Main_Menu.jpg"); - setProp("/instrumentation/efb/page", "MENU"); - keypress = ""; - } - #__________________________________________________________________________________________ - # MONITOR SECTION Parser ------------------------------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "MONITOR") { - page.clearpage(); - page.FlightMonitor(); - page.update(); - - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/Main_Menu.jpg"); - setProp("/instrumentation/efb/page", "MENU"); - keypress = ""; - } - #__________________________________________________________________________________________ - # VIDEO SECTION Parser --------------------------------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "VIDEO") { - page.clearpage(); - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/Main_Menu.jpg"); - setProp("/instrumentation/efb/page", "MENU"); - keypress = ""; - } - #__________________________________________________________________________________________ - # DOCUMENTS SECTION Parser ----------------------------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "DOCUMENTS") { - page.clearpage(); - - if (keypress == "l3") { - setProp("/instrumentation/efb/page", "NORM PROC MANUAL"); - keypress = ""; - } - elsif (keypress == "r2") { - setProp("/sim/model/efb/page", "Displays/Checklists_1.jpg"); - setProp("/instrumentation/efb/page", "CHECKLISTS"); - keypress = ""; - } - elsif (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/Main_Menu.jpg"); - setProp("/instrumentation/efb/page", "MENU"); - keypress = ""; - } - #__________________________________________________________________________________________ - # PERFORMANCE SECTION Parser --------------------------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "PERFORMANCE") { - page.clearpage(); - - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/Main_Menu.jpg"); - setProp("/instrumentation/efb/page", "MENU"); - keypress = ""; - } - #__________________________________________________________________________________________ - # CHECKLISTS SECTION Parser ---------------------------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "CHECKLISTS") { - page.clearpage(); - - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/Main_Menu.jpg"); - setProp("/instrumentation/efb/page", "MENU"); - keypress = ""; - } - if (keypress == "l2") { - setProp("/sim/model/efb/page", "Displays/Checklists_1_1.jpg"); - setProp("/instrumentation/efb/page", "CHECKLISTS"); - keypress = ""; - } - if (keypress == "r2") { - setProp("/sim/model/efb/page", "Displays/Checklists_1_2.jpg"); - setProp("/instrumentation/efb/page", "CHECKLISTS"); - keypress = ""; - } - #__________________________________________________________________________________________ - # IDENT SECTION Parser -------------------------------------------------------------------| - #_________________________________________________________________________________________| - } elsif (currentPage == "IDENT") { - page.clearpage(); - - IDENTl3 = getProp("/sim/description"); - IDENTl4 = substr(getProp("/sim/aircraft-operator"),0,3) ~ " / " ~ substr(getProp("/sim/multiplay/callsign"), 0,6); # this is to ensure that too long 'operator' and 'callsign' data can fit into the EFB display - IDENTr4 = "VMEFB001"; # this is the EFb Seattle version's ID - IDENTl5 = substr(getProp("environment/metar/data"),0,10); - IDENTr5 = getProp("/instrumentation/clock/indicated-short-string") ~ "z"; - IDENTl8 = "AIRPORT MAP DATABASE Seattle Data APR1214-JUN3014"; # this is the DB version, which we will periodically update with better and new Charts - - setProp("/instrumentation/efb/display/IDENTline3-l", IDENTl3); - setProp("/instrumentation/efb/display/IDENTline4-l", IDENTl4); - setProp("/instrumentation/efb/display/IDENTline4-r", IDENTr4); - setProp("/instrumentation/efb/display/IDENTline5-l", IDENTl5); - setProp("/instrumentation/efb/display/IDENTline5-r", IDENTr5); - setProp("/instrumentation/efb/display/IDENTline8-l", IDENTl8); - - setProp("/instrumentation/efb/display/input-helper", helper); - setProp("/instrumentation/efb/keypress", keypress); - - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/Main_Menu.jpg"); - setProp("/instrumentation/efb/page", "MENU"); - - IDENTl3 = ""; - IDENTl4 = ""; - IDENTr4 = ""; - IDENTl5 = ""; - IDENTr5 = ""; - IDENTl8 = ""; - setProp("/instrumentation/efb/display/IDENTline3-l", IDENTl3); - setProp("/instrumentation/efb/display/IDENTline4-l", IDENTl4); - setProp("/instrumentation/efb/display/IDENTline4-r", IDENTr4); - setProp("/instrumentation/efb/display/IDENTline5-l", IDENTl5); - setProp("/instrumentation/efb/display/IDENTline5-r", IDENTr5); - setProp("/instrumentation/efb/display/IDENTline8-l", IDENTl8); - - keypress = ""; - } - #__________________________________________________________________________________________ - # SYSTEM SECTION Parser ------------------------------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "SYSTEMS") { - page.clearpage(); - - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/Main_Menu.jpg"); - setProp("/instrumentation/efb/page", "MENU"); - keypress = ""; - } - #__________________________________________________________________________________________ - # CHART SECTION Parser -------------------------------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "CHARTS_KEYBOARD") { - page.clearpage(); - page.update(); - page.charts_keyboard(); - - if (getProp("/instrumentation/efb/chart/Searchable") == 0) { - setProp("/instrumentation/efb/Keyboard/CHART_Input_Line", "Enter ICAO"); - } - - # Get the ICAO to be searched for; "Virtual Keyboard" Keys Parser (see EFB_Chart_Keyboard.xml) - - if ((getProp("/instrumentation/efb/VKDRC_keypress") != "") and (getProp("/instrumentation/efb/VKDRC_keypress") != "SYMB") and (getProp("/instrumentation/efb/VKDRC_keypress") != "SHIFT")) { - setProp("/instrumentation/efb/VK_Keyboard/Input_String", getProp("/instrumentation/efb/VK_Keyboard/Input_String") ~ getProp("/instrumentation/efb/VKDRC_keypress")); # Build the Input String - - if (getProp("/instrumentation/efb/VKDRC_keypress") == "CLEAR") { - - setProp("/instrumentation/efb/VK_Keyboard/Input_String", ""); # CLEARs the whole Input Field and other stuff - } - if (getProp("/instrumentation/efb/VKDRC_keypress") == "BKSP") { - Temp_String = getProp("/instrumentation/efb/VK_Keyboard/Input_String"); # BACKSPACEs the Input Field - lenght = size(Temp_String) - 1; - setProp("/instrumentation/efb/VK_Keyboard/Input_String", substr(Temp_String, 0, lenght)); - setProp("/instrumentation/efb/VKDRC_keypress", ""); - } - } - - setProp("/instrumentation/efb/VKDRC_keypress", ""); - - TMZ_String = getProp("/instrumentation/efb/VK_Keyboard/Input_String"); - TMZ_Input_Lenght = size(TMZ_String); - - if (TMZ_Input_Lenght <= 3) { - setProp("/instrumentation/efb/Keyboard/CHART_Input_Line", getProp("/instrumentation/efb/VK_Keyboard/Input_String")); # Print it to the Keyboard Input Field - - } else { - setProp("/instrumentation/efb/chart/Searchable", 1); - setProp("/instrumentation/efb/Keyboard/CHART_Input_Line", "Press [Search IDENT] to search for: " ~ getProp("/instrumentation/efb/VK_Keyboard/Input_String")); - } - if ((getProp("/instrumentation/efb/chart/Searchable") == 1) and (keypress == "l3")) { # do SEARCH CHART - setProp("/instrumentation/efb/chart/icao", getProp("/instrumentation/efb/VK_Keyboard/Input_String")); - page.charts_keyboard(); - setProp("/instrumentation/efb/VKDRC_keypress", ""); - setProp("/instrumentation/efb/chart/Searchable", 0); - setProp("/instrumentation/efb/VK_Keyboard/Input_String", ""); - } - - if ((keypress == "PGDN") and (getProp("/instrumentation/efb/chart/PageList") < Chart_Pages)) { - setProp("/instrumentation/efb/chart/SetPage", "INCREASE"); - setProp("/instrumentation/efb/chart/PageList", getProp("/instrumentation/efb/chart/PageList") + 1); - } - if ((keypress == "PGUP") and (getProp("/instrumentation/efb/chart/PageList") > 1)) { - setProp("/instrumentation/efb/chart/SetPage", "INCREASE"); - setProp("/instrumentation/efb/chart/PageList", getProp("/instrumentation/efb/chart/PageList") + 1); - } - - # Chart Selection - redirection to CHARTS...___________________________________________________________________________________ - - if (keypress == "r1") { - setProp("/instrumentation/efb/chart/selected", getProp("/instrumentation/efb/chart/Selection_0")); - keypress = "MENU"; - } - if (keypress == "r2") { - setProp("/instrumentation/efb/chart/selected", getProp("/instrumentation/efb/chart/Selection_1")); - keypress = "MENU"; - } - if (keypress == "r3") { - setProp("/instrumentation/efb/chart/selected", getProp("/instrumentation/efb/chart/Selection_2")); - keypress = "MENU"; - } - # _____________________________________________________________________________________________________________________________ - - if (keypress == "MENU") { - # setProp("/sim/model/efb/page", "Displays/Blank_Test.jpg"); - setProp("/instrumentation/efb/chart/Status", "OFF"); - setProp("/instrumentation/efb/VK_Chart_Type", "APT"); # This starts and re-starts the Chart_Keyboard with active ICAO/APT Chart displayed ! (see B777 EFB Manual) - setProp("/instrumentation/efb/VK_Keyboard/Input_String", ""); - setProp("/instrumentation/efb/page", "CHARTS"); - page.KCclearpage(); - page.KCupdate(); - keypress = ""; - } - - #__________________________________________________________________________________________ - # INITIALIZE SECTION Parser --------------------------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "INITIALIZE") { - page.clearpage(); - if (getProp("/instrumentation/efb/FlightStatus") == 0) { - if (getProp("/autopilot/route-manager/departure/airport") != "") - OriginApt = getProp("/autopilot/route-manager/departure/airport"); - else - OriginApt = "NOT Set"; - if (getProp("/autopilot/route-manager/destination/airport") != "") - DestinationApt = getProp("/autopilot/route-manager/destination/airport"); - else - DestinationApt = "NOT Set"; - if ((OriginApt != "NOT Set") and (DestinationApt != "NOT Set")) { - OriginApt = getProp("/autopilot/route-manager/departure/airport"); - DestinationApt = getProp("/autopilot/route-manager/destination/airport"); - setProp("/sim/model/efb/page", "Displays/Initialize_1.jpg"); - ClosingFlightFlag = 1; # Flight INITIABLE - } else { - setProp("/sim/model/efb/page", "Displays/Initialize_2.jpg"); - setProp("/instrumentation/efb/FlightStatus", 0); - ClosingFlightFlag = 0; # Flight NOT INITIABLE - } - } elsif ((getProp("/instrumentation/efb/FlightStatus") == 1) and (ClosingFlightFlag == 2)) { - setProp("/instrumentation/efb/FlightStatus", 1); # Flight ACTIVE and CLOSABLE - FlightStatus = 1; - setProp("/sim/model/efb/page", "Displays/Initialize_3.jpg"); - } - - INITl4 = OriginApt; - INITl5 = DestinationApt; - setProp("/instrumentation/efb/display/INITline4-l", INITl4); - setProp("/instrumentation/efb/display/INITline5-l", INITl5); - - if ((keypress == "r8") and (ClosingFlightFlag == 1)) { - setProp("/instrumentation/efb/FlightStatus", 1); # Flight INITIATED - ClosingFlightFlag = 2; # Flight CLOSABLE - keypress = ""; - } - if ((keypress == "r8") and (FlightStatus == 1)) { - setProp("/instrumentation/efb/FlightStatus", 0); # Flight NOT ACTIVE - setProp("/sim/model/efb/page", "Displays/Initialize_5.jpg"); - FlightStatus = 0; - ClosingFlightFlag = 0; # Flight CLOSED - keypress = ""; - } - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/Main_Menu.jpg"); - setProp("/instrumentation/efb/page", "MENU"); - keypress = ""; - INITl4 = ""; - INITl5 = ""; - setProp("/instrumentation/efb/display/INITline4-l", INITl4); - setProp("/instrumentation/efb/display/INITline5-l", INITl5); - keypress = ""; - } - - #__________________________________________________________________________________________ - # PILOT UTILITIES SECTION Parser ----------------------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "UTILITIES") { - page.clearpage(); - setProp("/instrumentation/efb/Keyboard/Input_String", ""); - setProp("/instrumentation/efb/Keyboard/Input_Line", ""); - setProp("/instrumentation/efb/Keyboard/Input_Line2", ""); - setProp("/instrumentation/efb/Keyboard/Input_Line3", ""); - setProp("/instrumentation/efb/VK_keypress", ""); - - if (keypress == "l3") { - setProp("/instrumentation/efb/page", "UTILITIES_DESC_RATE"); - setProp("/sim/model/efb/page", "Displays/PU_DRC.jpg"); - setProp("/instrumentation/efb/Keyboard/Input_String", ""); - setProp("/instrumentation/efb/VK_keypress", ""); - setProp("/instrumentation/efb/Input_Unit", "NO_INPUT"); - setProp("/instrumentation/efb/DRC_Initial_FL", "300"); - setProp("/instrumentation/efb/DRC_Target_FL", "30"); - setProp("/instrumentation/efb/DRC_Initial_GS", "250"); - setProp("/instrumentation/efb/DRC_Target_GS", "200"); - setProp("/instrumentation/efb/DRC_Distance", "50"); - setProp("/instrumentation/efb/DRC_Initial_FL_MEM", getProp("/instrumentation/efb/DRC_Initial_FL")); - setProp("/instrumentation/efb/DRC_Target_FL_MEM", getProp("/instrumentation/efb/DRC_Target_FL")); - setProp("/instrumentation/efb/DRC_Initial_GS_MEM", getProp("/instrumentation/efb/DRC_Initial_GS")); - setProp("/instrumentation/efb/DRC_Target_GS_MEM", getProp("/instrumentation/efb/DRC_Target_GS")); - setProp("/instrumentation/efb/DRC_Distance_MEM", getProp("/instrumentation/efb/DRC_Distance")); - VK_Key = ""; - #setProp("/instrumentation/efb/VK_DRC_MarkerL", 1); - Initial_FL = 300; - Target_FL = 30; - Initial_GS = 250; - Target_GS = 200; - DRC_Distance = 50; - keypress = ""; - } - if (keypress == "l4") { - setProp("/instrumentation/efb/page", "GPS POSITION"); - } - if (keypress == "r1") { - setProp("/instrumentation/efb/page", "UTILITIES_CNV_SPD"); - setProp("/sim/model/efb/page", "Displays/PU_Cnv_Spd.jpg"); - setProp("/instrumentation/efb/VK_keypress", ""); - setProp("/instrumentation/efb/VK_IN_Marker", 1); - setProp("/instrumentation/efb/VK_OUT_Marker", 1); - VK_Input_Mem = 0; - VK_Output_Mem = 0; - } - if (keypress == "r2") { - setProp("/instrumentation/efb/page", "UTILITIES_CNV_LNG"); - setProp("/sim/model/efb/page", "Displays/PU_Cnv_Lng.jpg"); - setProp("/instrumentation/efb/VK_keypress", ""); - setProp("/instrumentation/efb/VK_IN_Marker", 1); - setProp("/instrumentation/efb/VK_OUT_Marker", 1); - VK_Input_Mem = 0; - VK_Output_Mem = 0; - } - if (keypress == "r3") { - setProp("/instrumentation/efb/page", "UTILITIES_CNV_WGT"); - setProp("/sim/model/efb/page", "Displays/PU_Cnv_Wgt.jpg"); - setProp("/instrumentation/efb/VK_keypress", ""); - setProp("/instrumentation/efb/VK_IN_Marker", 1); - setProp("/instrumentation/efb/VK_OUT_Marker", 1); - VK_Input_Mem = 0; - VK_Output_Mem = 0; - } - if (keypress == "r4") { - setProp("/instrumentation/efb/page", "UTILITIES_CNV_TMP"); - setProp("/sim/model/efb/page", "Displays/PU_Cnv_Tmp.jpg"); - setProp("/instrumentation/efb/VK_keypress", ""); - setProp("/instrumentation/efb/VK_IN_Marker", 1); - setProp("/instrumentation/efb/VK_OUT_Marker", 1); - VK_Input_Mem = 0; - VK_Output_Mem = 0; - } - if (keypress == "r5") { - setProp("/instrumentation/efb/page", "UTILITIES_CNV_VLM"); - setProp("/sim/model/efb/page", "Displays/PU_Cnv_Vlm.jpg"); - setProp("/instrumentation/efb/VK_keypress", ""); - setProp("/instrumentation/efb/VK_IN_Marker", 1); - setProp("/instrumentation/efb/VK_OUT_Marker", 1); - VK_Input_Mem = 0; - VK_Output_Mem = 0; - } - if (keypress == "r6") { - setProp("/instrumentation/efb/page", "UTILITIES_CNV_TMZ"); - setProp("/sim/model/efb/page", "Displays/PU_Cnv_Tmz.jpg"); - setProp("/instrumentation/efb/VK_keypress", ""); - setProp("/instrumentation/efb/VK_IN_Marker", 1); - setProp("/instrumentation/efb/VK_OUT_Marker", 1); - setProp("/instrumentation/efb/Keyboard/Input_String",""); - setProp("/instrumentation/efb/Keyboard/Input_HH", "--"); - setProp("/instrumentation/efb/Keyboard/Input_MM", "--"); - setProp("/instrumentation/efb/Keyboard/Output_HH", ""); - setProp("/instrumentation/efb/Keyboard/Output_MM", ""); - setProp("/instrumentation/efb/page/Cnv_Fact", "0"); - TMZ_String = ""; - TMZ_Index = 0; - - #Parsing for Month's names - - TMZ_DATE = substr(getProp("environment/metar/data"), 5, 5); - - if (substr(TMZ_DATE, 0, 2) == "01") TMZ_DATE = "JAN" ~ substr(TMZ_DATE, 2, 3); - if (substr(TMZ_DATE, 0, 2) == "02") TMZ_DATE = "FEB" ~ substr(TMZ_DATE, 2, 3); - if (substr(TMZ_DATE, 0, 2) == "03") TMZ_DATE = "MAR" ~ substr(TMZ_DATE, 2, 3); - if (substr(TMZ_DATE, 0, 2) == "04") TMZ_DATE = "APR" ~ substr(TMZ_DATE, 2, 3); - if (substr(TMZ_DATE, 0, 2) == "05") TMZ_DATE = "MAY" ~ substr(TMZ_DATE, 2, 3); - if (substr(TMZ_DATE, 0, 2) == "06") TMZ_DATE = "JUN" ~ substr(TMZ_DATE, 2, 3); - if (substr(TMZ_DATE, 0, 2) == "07") TMZ_DATE = "JUL" ~ substr(TMZ_DATE, 2, 3); - if (substr(TMZ_DATE, 0, 2) == "08") TMZ_DATE = "AUG" ~ substr(TMZ_DATE, 2, 3); - if (substr(TMZ_DATE, 0, 2) == "09") TMZ_DATE = "SEP" ~ substr(TMZ_DATE, 2, 3); - if (substr(TMZ_DATE, 0, 2) == "10") TMZ_DATE = "OCT" ~ substr(TMZ_DATE, 2, 3); - if (substr(TMZ_DATE, 0, 2) == "11") TMZ_DATE = "NOV" ~ substr(TMZ_DATE, 2, 3); - if (substr(TMZ_DATE, 0, 2) == "12") TMZ_DATE = "DEC" ~ substr(TMZ_DATE, 2, 3); - } - - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/Main_Menu.jpg"); - setProp("/instrumentation/efb/page", "MENU"); - keypress = ""; - } - - #__________________________________________________________________________________________ - # PILOT UTILITIES - GPS POSITION ----------------------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "GPS POSITION") { - page.clearpage(); - page.gps(); - - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/PU_1.jpg"); - setProp("/instrumentation/efb/page", "UTILITIES"); - keypress = ""; - } - - #__________________________________________________________________________________________ - # PILOT UTILITIES - SPEED CONVERSION Parser -----------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "UTILITIES_CNV_SPD") { - Input_Unit = getProp("/instrumentation/efb/VK_IN_Marker"); - Output_Unit = getProp("/instrumentation/efb/VK_OUT_Marker"); - - # Input keys Check - - if (getProp("/instrumentation/efb/VK_keypress") != "" or (Input_Unit != VK_Input_Mem) or (Output_Unit != VK_Output_Mem)) { - # Input Field Parser - if (getProp("/instrumentation/efb/VK_keypress") == "CLEAR") { - setProp("/instrumentation/efb/Keyboard/Input_String", ""); # CLEARs the whole Input Field - setProp("/instrumentation/efb/VK_keypress", ""); - } - if (getProp("/instrumentation/efb/VK_keypress") == "BKSP") { - Temp_String = getProp("/instrumentation/efb/Keyboard/Input_String"); # BACKSPACEs the Input Field - lenght = size(Temp_String) - 1; - setProp("/instrumentation/efb/Keyboard/Input_String", substr(Temp_String, 0, lenght)); - setProp("/instrumentation/efb/VK_keypress", ""); - } - if (getProp("/instrumentation/efb/VK_keypress") == "CHNGS") { - Temp_String = getProp("/instrumentation/efb/Keyboard/Input_String"); # CHANGEs SIGN to the Input Field - if (substr(Temp_String, 0, 1) == "-") { - lenght = size(Temp_String) - 1; - Temp_String = substr(Temp_String, 1, lenght); - } else { - Temp_String = "-" ~ Temp_String; - } - setProp("/instrumentation/efb/Keyboard/Input_String", Temp_String); - setProp("/instrumentation/efb/VK_keypress", ""); - } - - # Input Field Display - - setProp("/instrumentation/efb/Keyboard/Input_String", getProp("/instrumentation/efb/Keyboard/Input_String") ~ getProp("/instrumentation/efb/VK_keypress")); # Build the Input String - setProp("/instrumentation/efb/Keyboard/Input_Line", getProp("/instrumentation/efb/Keyboard/Input_String")); # Print it to the Keyboard Input Field - - # ---------------> Conversion Table Selection - # ---------------> Input Unit 1 () FT/M ---> Output Unit: FT/M, KM/H, KT, MTS, MPH - if (Input_Unit == 1) { - if (Output_Unit == 1) Cnv_Fact = 1; - elsif (Output_Unit == 2) Cnv_Fact = 0.018288; - elsif (Output_Unit == 3) Cnv_Fact = 0.0098747; - elsif (Output_Unit == 4) Cnv_Fact = 0.0050800; - elsif (Output_Unit == 5) { - if (getProp("/instrumentation/efb/VK_keypress") == "CLEAR") { - setProp("/instrumentation/efb/Keyboard/Input_String", ""); # CLEARs the whole Input Field - setProp("/instrumentation/efb/VK_keypress", ""); - } - elsif (getProp("/instrumentation/efb/VK_keypress") == "BKSP") { - Temp_String = getProp("/instrumentation/efb/Keyboard/Input_String"); # BACKSPACEs the Input Field - lenght = size(Temp_String) - 1; - setProp("/instrumentation/efb/Keyboard/Input_String", substr(Temp_String, 0, lenght)); - setProp("/instrumentation/efb/VK_keypress", ""); - } - elsif (getProp("/instrumentation/efb/VK_keypress") == "CHNGS") { - Temp_String = getProp("/instrumentation/efb/Keyboard/Input_String"); # CHANGEs SIGN to the Input Field - if (substr(Temp_String, 0, 1) == "-") { - lenght = size(Temp_String) - 1; - Temp_String = substr(Temp_String, 1, lenght); - } else { - Temp_String = "-" ~ Temp_String; - } - setProp("/instrumentation/efb/Keyboard/Input_String", Temp_String); - setProp("/instrumentation/efb/VK_keypress", ""); - } - Cnv_Fact = 0.011364; - } - } - # ---------------> Input Unit 2 () KM/H ---> Output Unit: FT/M, KM/H, KT, MTS, MPH - elsif (Input_Unit == 2) { - if (Output_Unit == 1) Cnv_Fact = 54.68066; - elsif (Output_Unit == 2) Cnv_Fact = 1; - elsif (Output_Unit == 3) Cnv_Fact = 0.5399568; - elsif (Output_Unit == 4) Cnv_Fact = 0.2777778; - elsif (Output_Unit == 5) Cnv_Fact = 0.6213712; - } - # ---------------> Input Unit 3 () KT ---> Output Unit: FT/M, KM/H, KT, MTS, MPH - elsif (Input_Unit == 3) { - if (Output_Unit == 1) Cnv_Fact = 101.2686; - elsif (Output_Unit == 2) Cnv_Fact = 1.852000; - elsif (Output_Unit == 3) Cnv_Fact = 1; - elsif (Output_Unit == 4) Cnv_Fact = 0.5144444; - elsif (Output_Unit == 5) Cnv_Fact = 1.150779; - } - # ---------------> Input Unit 4 () MTS ---> Output Unit: FT/M, KM/H, KT, MTS, MPH - elsif (Input_Unit == 4) { - if (Output_Unit == 1) Cnv_Fact = 196.85; - elsif (Output_Unit == 2) Cnv_Fact = 3.6000; - elsif (Output_Unit == 3) Cnv_Fact = 1.9438; - elsif (Output_Unit == 4) Cnv_Fact = 1; - elsif (Output_Unit == 5) Cnv_Fact = 2.2369; - } - # ---------------> Input Unit 5 () MPH ---> Output Unit: FT/M, KM/H, KT, MTS, MPH - elsif (Input_Unit == 5) { - if (Output_Unit == 1) Cnv_Fact = 88.0002; - elsif (Output_Unit == 2) Cnv_Fact = 1.609344; - elsif (Output_Unit == 3) Cnv_Fact = 0.8689762; - elsif (Output_Unit == 4) Cnv_Fact = 0.4470400; - elsif (Output_Unit == 5) Cnv_Fact = 1; - } - VK_Input_Mem = Input_Unit; - VK_Output_Mem = Output_Unit; - - # Output Field Display - - if ((getProp("/instrumentation/efb/Keyboard/Input_Line") == "") or (getProp("/instrumentation/efb/Keyboard/Input_Line") == ".") or (getProp("/instrumentation/efb/Keyboard/Input_Line") == "-")) { - setProp("/instrumentation/efb/Keyboard/Output_Line", ""); - } else { - Output_Line = getProp("/instrumentation/efb/Keyboard/Input_Line"); - Output_Line = Output_Line * Cnv_Fact; # Build the Input String - setProp("/instrumentation/efb/Keyboard/Output_Line", Output_Line); # Print it to the Keyboard Output Field - } - setProp("/instrumentation/efb/VK_keypress", ""); - } - - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/PU_1.jpg"); - setProp("/instrumentation/efb/page", "UTILITIES"); - setProp("/instrumentation/efb/Keyboard/Input_Line", ""); - setProp("/instrumentation/efb/Keyboard/Output_Line", ""); - keypress = ""; - } - - #__________________________________________________________________________________________ - # PILOT UTILITIES - LENGHT CONVERSION Parser ----------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "UTILITIES_CNV_LNG") { - - Input_Unit = getProp("/instrumentation/efb/VK_IN_Marker"); - Output_Unit = getProp("/instrumentation/efb/VK_OUT_Marker"); - - # Input keys Check - - if (getProp("/instrumentation/efb/VK_keypress") != "" or (Input_Unit != VK_Input_Mem) or (Output_Unit != VK_Output_Mem)) { - # Input Field Parser - - if (getProp("/instrumentation/efb/VK_keypress") == "CLEAR") { - setProp("/instrumentation/efb/Keyboard/Input_String", ""); # CLEARs the whole Input Field - setProp("/instrumentation/efb/VK_keypress", ""); - } - elsif (getProp("/instrumentation/efb/VK_keypress") == "BKSP") { - Temp_String = getProp("/instrumentation/efb/Keyboard/Input_String"); # BACKSPACEs the Input Field - lenght = size(Temp_String) - 1; - setProp("/instrumentation/efb/Keyboard/Input_String", substr(Temp_String, 0, lenght)); - setProp("/instrumentation/efb/VK_keypress", ""); - } - elsif (getProp("/instrumentation/efb/VK_keypress") == "CHNGS") { - Temp_String = getProp("/instrumentation/efb/Keyboard/Input_String"); # CHANGEs SIGN to the Input Field - if (substr(Temp_String, 0, 1) == "-") { - lenght = size(Temp_String) - 1; - Temp_String = substr(Temp_String, 1, lenght); - } else { - Temp_String = "-" ~ Temp_String; - } - setProp("/instrumentation/efb/Keyboard/Input_String", Temp_String); - setProp("/instrumentation/efb/VK_keypress", ""); - } - - # Input Field Display - - setProp("/instrumentation/efb/Keyboard/Input_String", getProp("/instrumentation/efb/Keyboard/Input_String") ~ getProp("/instrumentation/efb/VK_keypress")); # Build the Input String - setProp("/instrumentation/efb/Keyboard/Input_Line", getProp("/instrumentation/efb/Keyboard/Input_String")); # Print it to the Keyboard Input Field - - # ---------------> Conversion Table Selection - - # ---------------> Input Unit 1 () FEET ---> Output Unit: FEET, KILOMETERS, METERS, NAUTICAL MILES, STATUTE MILES - if (Input_Unit == 1) { - if (Output_Unit == 1) Cnv_Fact = 1; - elsif (Output_Unit == 2) Cnv_Fact = 0.0003048; - elsif (Output_Unit == 3) Cnv_Fact = 0.30480; - elsif (Output_Unit == 4) Cnv_Fact = 0.000164579; # International and US Nautical Miles, NOT UK Nautical Miles !! - elsif (Output_Unit == 5) Cnv_Fact = 0.000189394; # International Statute Miles - } - # ---------------> Input Unit 2 () KILOMETERS ---> Output Unit: FEET, KILOMETERS, METERS, NAUTICAL MILES, STATUTE MILES - elsif (Input_Unit == 2) { - if (Output_Unit == 1) Cnv_Fact = 3280.83989501; - elsif (Output_Unit == 2) Cnv_Fact = 1; - elsif (Output_Unit == 3) Cnv_Fact = 1000; - elsif (Output_Unit == 4) Cnv_Fact = 0.539956803456; # International and US Nautical Miles, NOT UK Nautical Miles !! - elsif (Output_Unit == 5) Cnv_Fact = 0.621371192237; # International Statute Miles - } - # ---------------> Input Unit 3 () METERS ---> Output Unit: FEET, KILOMETERS, METERS, NAUTICAL MILES, STATUTE MILES - elsif (Input_Unit == 3) { - if (Output_Unit == 1) Cnv_Fact = 3.28083989501; - elsif (Output_Unit == 2) Cnv_Fact = 0.001; - elsif (Output_Unit == 3) Cnv_Fact = 1; - elsif (Output_Unit == 4) Cnv_Fact = 0.000539956803456; # International and US Nautical Miles, NOT UK Nautical Miles !! - elsif (Output_Unit == 5) Cnv_Fact = 0.000621371192237; # International Statute Miles - } - # ---------------> Input Unit 4 () NAUTICAL MILES (INTERNATIONAL!) ---> Output Unit: FEET, KILOMETERS, METERS, NAUTICAL MILES, STATUTE MILES - elsif (Input_Unit == 4) { - if (Output_Unit == 1) Cnv_Fact = 6076.11548556; - elsif (Output_Unit == 2) Cnv_Fact = 1.852; - elsif (Output_Unit == 3) Cnv_Fact = 1852; - elsif (Output_Unit == 4) Cnv_Fact = 1; - elsif (Output_Unit == 5) Cnv_Fact = 1.15077944802; # International Statute Miles - } - # ---------------> Input Unit 5 () STATUTE MILES ---> Output Unit: FEET, KILOMETERS, METERS, NAUTICAL MILES, STATUTE MILES - elsif (Input_Unit == 5) { - if (Output_Unit == 1) Cnv_Fact = 5280; - elsif (Output_Unit == 2) Cnv_Fact = 1.609344; - elsif (Output_Unit == 3) Cnv_Fact = 1609.344; - elsif (Output_Unit == 4) Cnv_Fact = 0.868976241901; # International and US Nautical Miles, NOT UK Nautical Miles !! - elsif (Output_Unit == 5) Cnv_Fact = 1; - } - VK_Input_Mem = Input_Unit; - VK_Output_Mem = Output_Unit; - - # Output Field Display - if ((getProp("/instrumentation/efb/Keyboard/Input_Line") == "") or (getProp("/instrumentation/efb/Keyboard/Input_Line") == ".") or (getProp("/instrumentation/efb/Keyboard/Input_Line") == "-")) { - setProp("/instrumentation/efb/Keyboard/Output_Line", ""); - } else { - Output_Line = getProp("/instrumentation/efb/Keyboard/Input_Line"); - Output_Line = Output_Line * Cnv_Fact; # Build the Input String - setProp("/instrumentation/efb/Keyboard/Output_Line", Output_Line); # Print it to the Keyboard Output Field - } - setProp("/instrumentation/efb/VK_keypress", ""); - } - - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/PU_1.jpg"); - setProp("/instrumentation/efb/page", "UTILITIES"); - setProp("/instrumentation/efb/Keyboard/Input_Line", ""); - setProp("/instrumentation/efb/Keyboard/Output_Line", ""); - keypress = ""; - } - - #__________________________________________________________________________________________ - # PILOT UTILITIES - WEIGHT CONVERSION Parser ----------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "UTILITIES_CNV_WGT") { - Input_Unit = getProp("/instrumentation/efb/VK_IN_Marker"); - Output_Unit = getProp("/instrumentation/efb/VK_OUT_Marker"); - - # Input keys Check - if (getProp("/instrumentation/efb/VK_keypress") != "" or (Input_Unit != VK_Input_Mem) or (Output_Unit != VK_Output_Mem)) { - # Input Field Parser - if (getProp("/instrumentation/efb/VK_keypress") == "CLEAR") { - setProp("/instrumentation/efb/Keyboard/Input_String", ""); # CLEARs the whole Input Field - setProp("/instrumentation/efb/VK_keypress", ""); - } - elsif (getProp("/instrumentation/efb/VK_keypress") == "BKSP") { - Temp_String = getProp("/instrumentation/efb/Keyboard/Input_String"); # BACKSPACEs the Input Field - lenght = size(Temp_String) - 1; - setProp("/instrumentation/efb/Keyboard/Input_String", substr(Temp_String, 0, lenght)); - setProp("/instrumentation/efb/VK_keypress", ""); - } - elsif (getProp("/instrumentation/efb/VK_keypress") == "CHNGS") { - Temp_String = getProp("/instrumentation/efb/Keyboard/Input_String"); # CHANGEs SIGN to the Input Field - if (substr(Temp_String, 0, 1) == "-") { - lenght = size(Temp_String) - 1; - Temp_String = substr(Temp_String, 1, lenght); - } else { - Temp_String = "-" ~ Temp_String; - } - setProp("/instrumentation/efb/Keyboard/Input_String", Temp_String); - setProp("/instrumentation/efb/VK_keypress", ""); - } - - # Input Field Display - setProp("/instrumentation/efb/Keyboard/Input_String", getProp("/instrumentation/efb/Keyboard/Input_String") ~ getProp("/instrumentation/efb/VK_keypress")); # Build the Input String - setProp("/instrumentation/efb/Keyboard/Input_Line2", getProp("/instrumentation/efb/Keyboard/Input_String")); # Print it to the Keyboard Input Field - - # ---------------> Conversion Table Selection - # ---------------> Input Unit 1 () KILOGRAMS ---> Output Unit: KILOGRAMS, POUNDS - if (Input_Unit == 1) { - if (Output_Unit == 1) Cnv_Fact = 1; - elsif (Output_Unit == 2) Cnv_Fact = 2.20462262185; - } - # ---------------> Input Unit 2 () POUNDS ---> Output Unit: KILOGRAMS, POUNDS - elsif (Input_Unit == 2) { - if (Output_Unit == 1) Cnv_Fact = 0.45359237; - elsif (Output_Unit == 2) Cnv_Fact = 1; - } - VK_Input_Mem = Input_Unit; - VK_Output_Mem = Output_Unit; - - # Output Field Display - if ((getProp("/instrumentation/efb/Keyboard/Input_Line2") == "") or (getProp("/instrumentation/efb/Keyboard/Input_Line2") == ".") or (getProp("/instrumentation/efb/Keyboard/Input_Line2") == "-")) { - setProp("/instrumentation/efb/Keyboard/Output_Line2", ""); - } else { - Output_Line2 = getProp("/instrumentation/efb/Keyboard/Input_Line2"); - Output_Line2 = Output_Line2 * Cnv_Fact; # Build the Input String - setProp("/instrumentation/efb/Keyboard/Output_Line2", Output_Line2); # Print it to the Keyboard Output Field - } - setProp("/instrumentation/efb/VK_keypress", ""); - } - - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/PU_1.jpg"); - setProp("/instrumentation/efb/page", "UTILITIES"); - setProp("/instrumentation/efb/Keyboard/Input_Line2", ""); - setProp("/instrumentation/efb/Keyboard/Output_Line2", ""); - keypress = ""; - } - - #__________________________________________________________________________________________ - # PILOT UTILITIES - TEMPERATURE CONVERSION Parser -----------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "UTILITIES_CNV_TMP") { - - Input_Unit = getProp("/instrumentation/efb/VK_IN_Marker"); - Output_Unit = getProp("/instrumentation/efb/VK_OUT_Marker"); - - # Input keys Check - if (getProp("/instrumentation/efb/VK_keypress") != "" or (Input_Unit != VK_Input_Mem) or (Output_Unit != VK_Output_Mem)) { - # Input Field Parser - if (getProp("/instrumentation/efb/VK_keypress") == "CLEAR") { - setProp("/instrumentation/efb/Keyboard/Input_String", ""); # CLEARs the whole Input Field - setProp("/instrumentation/efb/VK_keypress", ""); - } - elsif (getProp("/instrumentation/efb/VK_keypress") == "BKSP") { - Temp_String = getProp("/instrumentation/efb/Keyboard/Input_String"); # BACKSPACEs the Input Field - lenght = size(Temp_String) - 1; - setProp("/instrumentation/efb/Keyboard/Input_String", substr(Temp_String, 0, lenght)); - setProp("/instrumentation/efb/VK_keypress", ""); - } - elsif (getProp("/instrumentation/efb/VK_keypress") == "CHNGS") { - Temp_String = getProp("/instrumentation/efb/Keyboard/Input_String"); # CHANGEs SIGN to the Input Field - if (substr(Temp_String, 0, 1) == "-") { - lenght = size(Temp_String) - 1; - Temp_String = substr(Temp_String, 1, lenght); - } else { - Temp_String = "-" ~ Temp_String; - } - setProp("/instrumentation/efb/Keyboard/Input_String", Temp_String); - setProp("/instrumentation/efb/VK_keypress", ""); - } - # Input Field Display - setProp("/instrumentation/efb/Keyboard/Input_String", getProp("/instrumentation/efb/Keyboard/Input_String") ~ getProp("/instrumentation/efb/VK_keypress")); # Build the Input String - setProp("/instrumentation/efb/Keyboard/Input_Line2", getProp("/instrumentation/efb/Keyboard/Input_String")); # Print it to the Keyboard Input Field - - # Output Field Display - if ((getProp("/instrumentation/efb/Keyboard/Input_Line2") == "") or (getProp("/instrumentation/efb/Keyboard/Input_Line2") == ".") or (getProp("/instrumentation/efb/Keyboard/Input_Line2") == "-")) { - setProp("/instrumentation/efb/Keyboard/Output_Line2", ""); - } else { - Output_Line2 = getProp("/instrumentation/efb/Keyboard/Input_Line2"); - # ---------------> Conversion Table Selection - # ---------------> Input Unit 1 () CELSIUS (�C) ---> Output Unit: CELSIUS (�C), FAHRENHEIT (�F) - if (Input_Unit == 1) { - if (Output_Unit == 1) Cnv_Fact = Output_Line2; - elsif (Output_Unit == 2) Cnv_Fact = (Output_Line2*1.8) + 32; - } - # ---------------> Input Unit 2 () FAHRENHEIT (�F) ---> Output Unit: CELSIUS (�C), FAHRENHEIT (�F) - elsif (Input_Unit == 2) { - if (Output_Unit == 1) Cnv_Fact = (Output_Line2 - 32)/1.8; - elsif (Output_Unit == 2) Cnv_Fact = Output_Line2; - } - VK_Input_Mem = Input_Unit; - VK_Output_Mem = Output_Unit; - - Output_Line2 = Cnv_Fact; # Build the Input String - setProp("/instrumentation/efb/Keyboard/Output_Line2", Output_Line2); # Print it to the Keyboard Output Field - } - setProp("/instrumentation/efb/VK_keypress", ""); - } - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/PU_1.jpg"); - setProp("/instrumentation/efb/page", "UTILITIES"); - setProp("/instrumentation/efb/Keyboard/Input_Line2", ""); - setProp("/instrumentation/efb/Keyboard/Output_Line2", ""); - keypress = ""; - } - #__________________________________________________________________________________________ - # PILOT UTILITIES - VOLUME CONVERSION Parser ----------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "UTILITIES_CNV_VLM") { - - Input_Unit = getProp("/instrumentation/efb/VK_IN_Marker"); - Output_Unit = getProp("/instrumentation/efb/VK_OUT_Marker"); - Output_TMZ_Line = ""; - # Input keys Check - if (getProp("/instrumentation/efb/VK_keypress") != "" or (Input_Unit != VK_Input_Mem) or (Output_Unit != VK_Output_Mem)) { - # Input Field Parser - if (getProp("/instrumentation/efb/VK_keypress") == "CLEAR") { - setProp("/instrumentation/efb/Keyboard/Input_String", ""); # CLEARs the whole Input Field - setProp("/instrumentation/efb/VK_keypress", ""); - } - elsif (getProp("/instrumentation/efb/VK_keypress") == "BKSP") { - Temp_String = getProp("/instrumentation/efb/Keyboard/Input_String"); # BACKSPACEs the Input Field - lenght = size(Temp_String) - 1; - setProp("/instrumentation/efb/Keyboard/Input_String", substr(Temp_String, 0, lenght)); - setProp("/instrumentation/efb/VK_keypress", ""); - } - elsif (getProp("/instrumentation/efb/VK_keypress") == "CHNGS") { - Temp_String = getProp("/instrumentation/efb/Keyboard/Input_String"); # CHANGEs SIGN to the Input Field - if (substr(Temp_String, 0, 1) == "-") { - lenght = size(Temp_String) - 1; - Temp_String = substr(Temp_String, 1, lenght); - } else { - Temp_String = "-" ~ Temp_String; - } - setProp("/instrumentation/efb/Keyboard/Input_String", Temp_String); - setProp("/instrumentation/efb/VK_keypress", ""); - } - # Input Field Display - setProp("/instrumentation/efb/Keyboard/Input_String", getProp("/instrumentation/efb/Keyboard/Input_String") ~ getProp("/instrumentation/efb/VK_keypress")); # Build the Input String - setProp("/instrumentation/efb/Keyboard/Input_Line3", getProp("/instrumentation/efb/Keyboard/Input_String")); # Print it to the Keyboard Input Field - - # ---------------> Conversion Table Selection - # ---------------> Input Unit 1 () IMPERIAL GALLONS ---> Output Unit: IMPERIAL GALLONS, US GALLONS, LITERS - if (Input_Unit == 1) { - if (Output_Unit == 1) Cnv_Fact = 1; - elsif (Output_Unit == 2) Cnv_Fact = 1.20095; - elsif (Output_Unit == 3) Cnv_Fact = 4.54609; - } - # ---------------> Input Unit 2 () US GALLONS ---> Output Unit: IMPERIAL GALLONS, US GALLONS, LITERS - elsif (Input_Unit == 2) { - if (Output_Unit == 1) Cnv_Fact = 0.832674; - elsif (Output_Unit == 2) Cnv_Fact = 1; - elsif (Output_Unit == 3) Cnv_Fact = 3.78541; - } - # ---------------> Input Unit 3 () LITERS ---> Output Unit: IMPERIAL GALLONS, US GALLONS, LITERS - elsif (Input_Unit == 3) { - if (Output_Unit == 1) Cnv_Fact = 0.219969; - elsif (Output_Unit == 2) Cnv_Fact = 0.264172; - elsif (Output_Unit == 3) Cnv_Fact = 1; - } - VK_Input_Mem = Input_Unit; - VK_Output_Mem = Output_Unit; - # Output Field Display - if ((getProp("/instrumentation/efb/Keyboard/Input_Line3") == "") or (getProp("/instrumentation/efb/Keyboard/Input_Line3") == ".") or (getProp("/instrumentation/efb/Keyboard/Input_Line3") == "-")) { - setProp("/instrumentation/efb/Keyboard/Output_Line3", ""); - } else { - Output_Line2 = getProp("/instrumentation/efb/Keyboard/Input_Line3"); - Output_Line2 = Output_Line2 * Cnv_Fact; # Build the Input String - setProp("/instrumentation/efb/Keyboard/Output_Line3", Output_Line2); # Print it to the Keyboard Output Field - } - setProp("/instrumentation/efb/VK_keypress", ""); - } - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/PU_1.jpg"); - setProp("/instrumentation/efb/page", "UTILITIES"); - setProp("/instrumentation/efb/Keyboard/Input_Line3", ""); - setProp("/instrumentation/efb/Keyboard/Output_Line3", ""); - keypress = ""; - } - - #__________________________________________________________________________________________ - # PILOT UTILITIES - TIME ZONE CONVERSION Parser -------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "UTILITIES_CNV_TMZ") { - - TMZ_TIME = getProp("/instrumentation/clock/indicated-short-string") ~ "z"; - setProp("/instrumentation/efb/Keyboard/Current_DT_Line", TMZ_DATE ~ " " ~ TMZ_TIME); # Print Current Date & Time - setProp("/instrumentation/efb/Keyboard/Converted_Name_Line", "Use Keyboard to Input Time (HHMM)"); - # Input keys Check - - if (getProp("/instrumentation/efb/VK_keypress") != "") { - # Input Field Parser - if (getProp("/instrumentation/efb/VK_keypress") == "CLEAR") { - setProp("/instrumentation/efb/Keyboard/Input_String", ""); # CLEARs the whole Input Field and other stuff - setProp("/instrumentation/efb/Keyboard/Input_HH_Line", "--"); - setProp("/instrumentation/efb/Keyboard/Input_MM_Line", "--"); - setProp("/instrumentation/efb/Keyboard/Input_Zulu_Line", "--:--"); - setProp("/instrumentation/efb/Keyboard/Output_HH", ""); - setProp("/instrumentation/efb/Keyboard/Output_MM", ""); - setProp("/instrumentation/efb/Keyboard/Converted_ID_Line", ""); - setProp("/instrumentation/efb/Keyboard/Converted_Name_Line", "Use Keyboard to Input Time (HHMM)"); - setProp("/instrumentation/efb/Keyboard/Output_TMZ_Line", "--:--"); - setProp("/instrumentation/efb/Keyboard/Cnv_Fact", ""); - TMZ_index = 0; - Output_TMz_Line = "--:--"; - setProp("/instrumentation/efb/VK_keypress", ""); - } - elsif (getProp("/instrumentation/efb/VK_keypress") == "BKSP") { - Temp_String = getProp("/instrumentation/efb/Keyboard/Input_String"); # BACKSPACEs the Input Field - lenght = size(Temp_String) - 1; - setProp("/instrumentation/efb/Keyboard/Input_String", substr(Temp_String, 0, lenght)); - setProp("/instrumentation/efb/VK_keypress", ""); - } - elsif (getProp("/instrumentation/efb/VK_keypress") == "CHNGS") { - setProp("/instrumentation/efb/Keyboard/Input_String", getProp("/instrumentation/efb/Keyboard/Input_String")); # Bypasses CHANGEs SIGN - setProp("/instrumentation/efb/VK_keypress", ""); - } - - # Input Field Display - TMZ_String = getProp("/instrumentation/efb/Keyboard/Input_String"); - TMZ_Input_Lenght = size(TMZ_String); - - if (TMZ_Input_Lenght <= 3) { - setProp("/instrumentation/efb/Keyboard/Input_String", getProp("/instrumentation/efb/Keyboard/Input_String") ~ getProp("/instrumentation/efb/VK_keypress")); # Build the Input String - - if (TMZ_Input_Lenght > 1) { - setProp("/instrumentation/efb/Keyboard/Input_HH_Line", substr(getProp("/instrumentation/efb/Keyboard/Input_String"), 0, 2)); # IF 3rd digit, Print HH to the Keyboard Input Field - setProp("/instrumentation/efb/Keyboard/Output_HH", substr(getProp("/instrumentation/efb/Keyboard/Input_String"), 0, 2)); # Copy HH to Output_HH - setProp("/instrumentation/efb/Keyboard/Input_MM_Line", substr(getProp("/instrumentation/efb/Keyboard/Input_String"), 2, TMZ_Input_Lenght)); # IF 3rd digit, Print MM to the Keyboard Input Field - setProp("/instrumentation/efb/Keyboard/Output_MM", substr(getProp("/instrumentation/efb/Keyboard/Input_String"), 2, TMZ_Input_Lenght)); # Copy MM to Output_MM - setProp("/instrumentation/efb/Keyboard/Input_Zulu_Line", (getProp("/instrumentation/efb/Keyboard/Input_HH_Line") ~ ":" ~ getProp("/instrumentation/efb/Keyboard/Input_MM_Line"))); # IF 3rd digit, Print "zulu Time" to the Keyboard Output "zulu to be converted" Field (see EFB Manual) - } else { - setProp("/instrumentation/efb/Keyboard/Input_HH_Line", getProp("/instrumentation/efb/Keyboard/Input_String")); # Print Blank HH to the Keyboard Input Field - setProp("/instrumentation/efb/Keyboard/Input_MM_Line", "--"); # Print Blank HH to the Keyboard Input Field - setProp("/instrumentation/efb/Keyboard/Input_Zulu_Line", getProp("/instrumentation/efb/Keyboard/Input_HH_Line") ~ ":" ~ getProp("/instrumentation/efb/Keyboard/Input_MM_Line")); # Print Blank "zulu Time" to the Keyboard Output "zulu to be converted" Field (see EFB Manual) # Print "" MM to the Keyboard Input Field - setProp("/instrumentation/efb/Keyboard/Output_HH", ""); - setProp("/instrumentation/efb/Keyboard/Output_MM", ""); - } - - } # an 'else' clause should be set here, giving the Pilot an audible 'WARNING Beep', because we cannot accept more than 4 chars for Time Input! - } - setProp("/instrumentation/efb/VK_keypress", ""); # reset the VK keys to "" - - # ---------------> Output Unit: Input Time Conversion --> TIME ZONES Time - - if (TMZ_Input_Lenght > 1) { - # TMZ_Index = TMZ_Index; - if ((keypress == "r3") and (TMZ_Index > 0)) { - TMZ_Index = TMZ_Index - 1; - keypress = ""; - } # an 'else' clause should be set here, giving the Pilot an audible 'WARNING Beep', because he reached Bottom End of DB File! - if ((keypress == "r4") and (TMZ_Index < TMZ_DB_Size)) { - TMZ_Index = TMZ_Index + 1; - keypress = ""; - } # an 'else' clause should be set here, giving the Pilot an audible 'WARNING Beep', because he reached Top End of DB File! - #setProp("/instrumentation/efb/Keyboard/Output_HH", "12"); - #setProp("/instrumentation/efb/Keyboard/Output_MM", "54"); - if (keypress == "r5") { setProp("/instrumentation/efb/Keyboard/Cnv_Fact", "0"); # RESET ALL - setProp("/instrumentation/efb/Keyboard/Input_String", ""); - TMZ_String = ""; - TMZ_Index = 0; - TMZ_Input_Lenght = 0; - setProp("/instrumentation/efb/Keyboard/Current_DT_Line", ""); - setProp("/instrumentation/efb/Keyboard/Input_HH_Line", ""); - setProp("/instrumentation/efb/Keyboard/Input_MM_Line", ""); - setProp("/instrumentation/efb/Keyboard/Input_Zulu_Line", ""); - setProp("/instrumentation/efb/Keyboard/Output_HH", "0"); - setProp("/instrumentation/efb/Keyboard/Output_MM", "0"); - setProp("/instrumentation/efb/Keyboard/Converted_ID_Line", ""); - setProp("/instrumentation/efb/Keyboard/Converted_Name_Line", "Use Keyboard to Input Time (HHMM)"); - setProp("/instrumentation/efb/Keyboard/Output_TMZ_Line", ""); - setProp("/instrumentation/efb/Keyboard/Cnv_Fact", "0"); - TMZ_index = 0; - Output_TMz_Line = "--:--"; - } - if (getProp("/instrumentation/efb/Keyboard/Output_HH") != "0") { - TMZ_Converted_ID = getProp("/instrumentation/efb/TimeZonesDB/IDX[" ~ TMZ_Index ~ "]/ID"); - TMZ_Converted_Name = getProp("/instrumentation/efb/TimeZonesDB/IDX[" ~ TMZ_Index ~ "]/Name"); - TMZ_zulu_HH = getProp("/instrumentation/efb/Keyboard/Output_HH"); - TMZ_Converted_OffSet = getProp("/instrumentation/efb/TimeZonesDB/IDX[" ~ TMZ_Index ~ "]/OffSet"); - setProp("/instrumentation/efb/Keyboard/Converted_ID_Line", TMZ_Converted_ID); # Print Time Zone ID to the Keyboard Converted Time Field - setProp("/instrumentation/efb/Keyboard/Converted_Name_Line", TMZ_Converted_Name); # Print Time Zone Name to the Keyboard Converted Time Field - setProp("/instrumentation/efb/Keyboard/Cnv_Fact", (TMZ_zulu_HH + TMZ_Converted_OffSet)); - } else { - setProp("/instrumentation/efb/Keyboard/Cnv_Fact", 0); - } - # HH Corrections for Time Zone's Conversion Factors - if (getProp("/instrumentation/efb/Keyboard/Cnv_Fact") > 9) { - setProp("/instrumentation/efb/Keyboard/Cnv_Fact", getProp("/instrumentation/efb/Keyboard/Cnv_Fact")); # Print HH Converted Time to the Keyboard Converted Time Field - } elsif (((getProp("/instrumentation/efb/Keyboard/Cnv_Fact") >= 0) and (getProp("/instrumentation/efb/Keyboard/Cnv_Fact") <= 9))) { - setProp("/instrumentation/efb/Keyboard/Cnv_Fact", "0" ~ getProp("/instrumentation/efb/Keyboard/Cnv_Fact")); # Print H Converted Time to the Keyboard Converted Time Field - } elsif (getProp("/instrumentation/efb/Keyboard/Cnv_Fact") < 0) { - setProp("/instrumentation/efb/Keyboard/Cnv_Fact", (24 + getProp("/instrumentation/efb/Keyboard/Cnv_Fact"))); # Print (24 - HH) Converted Time to the Keyboard Converted Time Field - } - } else { - setProp("/instrumentation/efb/Keyboard/Cnv_Fact", "--"); - } - # Output Converted Time Field Display - if ((getProp("/instrumentation/efb/Keyboard/Input_HH_Line") == "") or (getProp("/instrumentation/efb/Keyboard/Input_HH_Line") == ".") or (getProp("/instrumentation/efb/Keyboard/Input_HH_Line") == "--")) { - setProp("/instrumentation/efb/Keyboard/Output_TMZ_Line", ""); - Output_TMz_Line = "--:--"; - } else { - Output_TMZ_Line = getProp("/instrumentation/efb/Keyboard/Cnv_Fact"); - Output_TMZ_Line = substr(Output_TMZ_Line, 0, 2) ~ ":" ~ getProp("/instrumentation/efb/Keyboard/Output_MM");# Build the Output String - } - setProp("/instrumentation/efb/Keyboard/Output_TMZ_Line", Output_TMZ_Line); # Print it to the Keyboard Output Converted Time Field - - if (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/PU_1.jpg"); - setProp("/instrumentation/efb/page", "UTILITIES"); - setProp("/instrumentation/efb/Keyboard/Current_DT_Line", ""); - setProp("/instrumentation/efb/Keyboard/Input_HH_Line", ""); - setProp("/instrumentation/efb/Keyboard/Input_MM_Line", ""); - setProp("/instrumentation/efb/Keyboard/Input_Zulu_Line", ""); - setProp("/instrumentation/efb/Keyboard/Cnv_Fact", ""); - setProp("/instrumentation/efb/Keyboard/Output_HH", ""); - setProp("/instrumentation/efb/Keyboard/Output_MM", ""); - setProp("/instrumentation/efb/Keyboard/Converted_ID_Line", ""); - setProp("/instrumentation/efb/Keyboard/Converted_Name_Line", ""); - setProp("/instrumentation/efb/Keyboard/Output_TMZ_Line", ""); - setProp("/instrumentation/efb/Keyboard/Input_String", ""); - - keypress = ""; - } - - #__________________________________________________________________________________________ - # PILOT UTILITIES - DESCENT RATE Calculator ----------------------------------------------| - #_________________________________________________________________________________________| - } elsif (currentPage == "UTILITIES_DESC_RATE") { - - page.clearpage(); - # Input keys Check - if (keypress == "l2") { - setProp("/instrumentation/efb/Input_Unit", "Initial_FL"); - setProp("/instrumentation/efb/Keyboard/Input_String",""); - setProp("/instrumentation/efb/DRC_Initial_FL_MEM", getProp("/instrumentation/efb/DRC_Initial_FL")); - setProp("/instrumentation/efb/VK_DRC_MarkerL", 1); - setProp("/instrumentation/efb/VK_DRC_MarkerR", 0); - } - elsif (keypress == "r2") { - setProp("/instrumentation/efb/Input_Unit", "Target_FL"); - setProp("/instrumentation/efb/Keyboard/Input_String",""); - setProp("/instrumentation/efb/DRC_Target_FL_MEM", getProp("/instrumentation/efb/DRC_Target_FL")); - setProp("/instrumentation/efb/VK_DRC_MarkerR", 1); - setProp("/instrumentation/efb/VK_DRC_MarkerL", 0); - } - elsif (keypress == "l3") { - setProp("/instrumentation/efb/Input_Unit", "Initial_GS"); - setProp("/instrumentation/efb/Keyboard/Input_String",""); - setProp("/instrumentation/efb/DRC_Initial_GS_MEM", getProp("/instrumentation/efb/DRC_Initial_GS")); - setProp("/instrumentation/efb/VK_DRC_MarkerL", 2); - setProp("/instrumentation/efb/VK_DRC_MarkerR", 0); - } - elsif (keypress == "r3") { - setProp("/instrumentation/efb/Input_Unit", "Target_GS"); - setProp("/instrumentation/efb/Keyboard/Input_String",""); - setProp("/instrumentation/efb/DRC_Target_GS_MEM", getProp("/instrumentation/efb/DRC_Target_GS")); - setProp("/instrumentation/efb/VK_DRC_MarkerR", 2); - setProp("/instrumentation/efb/VK_DRC_MarkerL", 0); - } - elsif (keypress == "l4") { - setProp("/instrumentation/efb/Input_Unit", "Distance"); - setProp("/instrumentation/efb/Keyboard/Input_String",""); - setProp("/instrumentation/efb/DRC_Distance_MEM", getProp("/instrumentation/efb/DRC_Distance")); - setProp("/instrumentation/efb/VK_DRC_MarkerL", 3); - setProp("/instrumentation/efb/VK_DRC_MarkerR", 0); - } - - # Input keys Parser - if ((getProp("/instrumentation/efb/VK_keypress") != "") and (getProp("/instrumentation/efb/VK_keypress") != ".") and (getProp("/instrumentation/efb/VK_keypress") != "CHNGS") and (getProp("/instrumentation/efb/Input_Unit") != "NO_INPUT")) { - if (getProp("/instrumentation/efb/VK_keypress") == "CLEAR") { - setProp("/instrumentation/efb/Keyboard/Input_String", ""); # CLEARs the whole Input Field - VK_Key = "VOID"; - setProp("/instrumentation/efb/VK_keypress", ""); - } - elsif (getProp("/instrumentation/efb/VK_keypress") == "BKSP") { - Temp_String = getProp("/instrumentation/efb/Keyboard/Input_String"); # BACKSPACEs the Input Field - lenght = size(Temp_String) - 1; - if (lenght >= 1) { - setProp("/instrumentation/efb/Keyboard/Input_String", substr(Temp_String, 0, lenght)); - setProp("/instrumentation/efb/VK_keypress", ""); - } elsif (lenght <= 0) { - setProp("/instrumentation/efb/Keyboard/Input_String", ""); # CLEARs the whole Input Field - VK_Key = "VOID"; - } - } - DRC_String = getProp("/instrumentation/efb/Keyboard/Input_String"); - DRC_Input_Lenght = size(DRC_String); - - if (DRC_Input_Lenght < 3) { - if (VK_Key != "VOID") { - setProp("/instrumentation/efb/Keyboard/Input_String", getProp("/instrumentation/efb/Keyboard/Input_String") ~ getProp("/instrumentation/efb/VK_keypress")); # Build the Input String... - } - if ((getProp("/instrumentation/efb/Input_Unit") == "Initial_FL") and (VK_Key != "VOID")) { - setProp("/instrumentation/efb/DRC_Initial_FL", getProp("/instrumentation/efb/Keyboard/Input_String")); # ...For Initial FL - } elsif ((getProp("/instrumentation/efb/Input_Unit") == "Initial_FL") and (VK_Key == "VOID")) { - setProp("/instrumentation/efb/display/DRC_l3", "CLEAR"); - setProp("/instrumentation/efb/DRC_Initial_FL", getProp("/instrumentation/efb/DRC_Initial_FL_MEM")); - } - if ((getProp("/instrumentation/efb/Input_Unit") == "Target_FL") and (VK_Key != "VOID")) { - setProp("/instrumentation/efb/DRC_Target_FL", getProp("/instrumentation/efb/Keyboard/Input_String")); # ...For Target FL - } elsif ((getProp("/instrumentation/efb/Input_Unit") == "Target_FL") and (VK_Key == "VOID")) { - setProp("/instrumentation/efb/display/DRC_r3", "CLEAR"); - setProp("/instrumentation/efb/DRC_Target_FL", getProp("/instrumentation/efb/DRC_Target_FL_MEM")); - } - if ((getProp("/instrumentation/efb/Input_Unit") == "Initial_GS") and (VK_Key != "VOID")) { - setProp("/instrumentation/efb/DRC_Initial_GS", getProp("/instrumentation/efb/Keyboard/Input_String")); # ...For Initial GS - } elsif ((getProp("/instrumentation/efb/Input_Unit") == "Initial_GS") and (VK_Key == "VOID")) { - setProp("/instrumentation/efb/display/DRC_l5", "CLEAR"); - setProp("/instrumentation/efb/DRC_Initial_GS", getProp("/instrumentation/efb/DRC_Initial_GS_MEM")); - } - if ((getProp("/instrumentation/efb/Input_Unit") == "Target_GS") and (VK_Key != "VOID")) { - setProp("/instrumentation/efb/DRC_Target_GS", getProp("/instrumentation/efb/Keyboard/Input_String")); # ...For Target GS - } elsif ((getProp("/instrumentation/efb/Input_Unit") == "Target_GS") and (VK_Key == "VOID")) { - setProp("/instrumentation/efb/display/DRC_r5", "CLEAR"); - setProp("/instrumentation/efb/DRC_Target_GS", getProp("/instrumentation/efb/DRC_Target_GS_MEM")); - } - if ((getProp("/instrumentation/efb/Input_Unit") == "Distance") and (VK_Key != "VOID")) { - setProp("/instrumentation/efb/DRC_Distance", getProp("/instrumentation/efb/Keyboard/Input_String")); # ...For Distance - } elsif ((getProp("/instrumentation/efb/Input_Unit") == "Distance") and (VK_Key == "VOID")) { - setProp("/instrumentation/efb/display/DRC_l7", "CLEAR"); - setProp("/instrumentation/efb/DRC_Distance", getProp("/instrumentation/efb/DRC_Distance_MEM")); - } - } - } - setProp("/instrumentation/efb/VK_keypress", ""); # reset the VK keys to "" - VK_Key = ""; - - # Transfers Values to DRC variables as numbers - Initial_FL = num(getProp("/instrumentation/efb/DRC_Initial_FL")); - Target_FL = num(getProp("/instrumentation/efb/DRC_Target_FL")); - Initial_GS = num(getProp("/instrumentation/efb/DRC_Initial_GS")); - Target_GS = num(getProp("/instrumentation/efb/DRC_Target_GS")); - DRC_Distance = num(getProp("/instrumentation/efb/DRC_Distance")); - - # Calculates Formulas - # Formula: [Angle of Descent (ft/NM) = ALT Gradient/Distance] |||| [SPD Factor (ft/min) = SPD Gradient/60] |||| [Target Descent Rate (Fpm) = Angle of Descent * SPD Factor] - - var DRC_Angle = (Target_FL - Initial_FL)/DRC_Distance; - var DRC_AvgSpeed = (Initial_GS + Target_GS)/2; - var DRC_Fact = DRC_AvgSpeed/60; - var DRC_Output = DRC_Angle * DRC_Fact*100; - var DRC_Time = (Target_FL - Initial_FL)/(DRC_Output/100); - - # Prepares Output Strings - DRC_l3 = substr(getProp("/instrumentation/efb/DRC_Initial_FL"), 0, 3); - CUT = split(".", DRC_l3); - DRC_l3 = CUT[0]; - - DRC_r3 = substr(getProp("/instrumentation/efb/DRC_Target_FL"), 0, 3); - CUT = split(".", DRC_r3); - DRC_r3 = CUT[0]; - - DRC_l5 = substr(getProp("/instrumentation/efb/DRC_Initial_GS"), 0, 3); - CUT = split(".", DRC_l5); - DRC_l5 = CUT[0]; - - DRC_r5 = substr(getProp("/instrumentation/efb/DRC_Target_GS"), 0, 3); - CUT = split(".", DRC_r5); - DRC_r5 = CUT[0]; - - DRC_l7 = substr(getProp("/instrumentation/efb/DRC_Distance"), 0, 3); - CUT = split(".", DRC_l7); - DRC_l7 = CUT[0]; - - setProp("/instrumentation/efb/DRC_Output", "100"); - setProp("/instrumentation/efb/DRC_Output", DRC_Output); - DRC_r8 = substr(getProp("/instrumentation/efb/DRC_Output"), 0, 8); - CUT = split(".", DRC_r8); - DRC_r8 = CUT[0]; - - setProp("/instrumentation/efb/DRC_Angle", "100"); - setProp("/instrumentation/efb/DRC_Angle", DRC_Angle); - DRC_r9 = substr(getProp("/instrumentation/efb/DRC_Angle"), 0, 5); - # CUT = split(".", DRC_r9); - # DRC_r9 = CUT[0]; - - setProp("/instrumentation/efb/DRC_Time", "100"); - setProp("/instrumentation/efb/DRC_Time", DRC_Time); - DRC_r10 = substr(getProp("/instrumentation/efb/DRC_Time"), 0, 5); - #CUT = split(".", DRC_r10); - #DRC_r10 = CUT[0]; - - - page.DRCupdate(); # Displays Output - - if (keypress == "MENU") { - page.DRCclearpage(); - page.DRCupdate(); - setProp("/sim/model/efb/page", "Displays/PU_1.jpg"); - setProp("/instrumentation/efb/VK_DRC_MarkerR", 0); - setProp("/instrumentation/efb/VK_DRC_MarkerL", 0); - setProp("/instrumentation/efb/page", "UTILITIES"); - keypress = ""; - } - #__________________________________________________________________________________________ - # PILOT UTILITIES - NORMAL PROCEDURES MANUAL ----------------------------------------------| - #__________________________________________________________________________________________| - } elsif (currentPage == "NORM PROC MANUAL") { - page.clearpage(); - - if (keypress == "PGUP") { - setProp("/instrumentation/efb/manual-page", getProp("/instrumentation/efb/manual-page") - 0.20); - keypress = ""; - } - elsif (keypress == "ScrollUP") { - setProp("/instrumentation/efb/manual-page", getProp("/instrumentation/efb/manual-page") - 0.02); - keypress = ""; - } - elsif (keypress == "ScrollDN") { - setProp("/instrumentation/efb/manual-page", getProp("/instrumentation/efb/manual-page") + 0.02); - keypress = ""; - } - elsif (keypress == "PGDN") { - setProp("/instrumentation/efb/manual-page", getProp("/instrumentation/efb/manual-page") + 0.20); - keypress = ""; - } - elsif (keypress == "MENU") { - setProp("/sim/model/efb/page", "Displays/Documents_1.jpg"); - setProp("/instrumentation/efb/page", "DOCUMENTS"); - keypress = ""; - } - } - #___________________________________________________________________________________________ - #_______________________________END of Parsers & SubParsers_________________________________| - page.update(); - if ((getProp("/instrumentation/efb/page") == "Airport Charts") or (getProp("/instrumentation/efb/page") == "Airport Diagram") or (getProp("/instrumentation/efb/page") == "NORM PROC MANUAL")) setProp("/instrumentation/efb/text-color", 0); - else setProp("/instrumentation/efb/text-color", 1); - }, - reset : func { - if(!me.efbTimer) - me.efbTimer = maketimer(me.UPDATE_INTERVAL, func me.update()); - else - me.efbTimer.stop(); - me.loopid += 1; - #//me._loop_(me.loopid); - me.efbTimer.start(); - }, - #//_loop_ : func() { - #// id == me.loopid or return; - #// me.update(); - #//} -}; - -var toggle = func(property) { - if (getProp(property) == 1) - setProp(property, 0); - else - setProp(property, 1); -} -setlistener("sim/signals/fdm-initialized", func {efb.init();}); diff --git a/test/fib.nas b/test/fib.nas index 51e36b0..d06371a 100644 --- a/test/fib.nas +++ b/test/fib.nas @@ -5,15 +5,4 @@ var fib=func(x) return fib(x-1)+fib(x-2); } for(var i=0;i<31;i+=1) - print(fib(i),'\n'); - -var m=[0,1,1,2,3,5,8]; -setsize(m,32); -var fib=func(n) -{ - if(m[n]!=nil) return m[n]; - var t=fib(n-1)+fib(n-2); - m[n]=t; - return t; -} -print(fib(31),'\n'); \ No newline at end of file + print(fib(i),'\n'); \ No newline at end of file diff --git a/test/fmz.nas b/test/fmz.nas deleted file mode 100644 index 9b9b32e..0000000 --- a/test/fmz.nas +++ /dev/null @@ -1,7564 +0,0 @@ -# ================================================================== -# BD700 FMZ by IceGuye. -# ================================================================== - -setprop("/instrumentation/fmz/fmz-key-A-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-B-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-C-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-D-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-E-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-F-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-G-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-H-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-I-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-J-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-K-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-L-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-M-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-N-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-O-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-P-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-Q-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-R-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-S-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-T-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-U-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-V-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-W-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-X-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-Y-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-Z-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-DEL-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-CLR-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-1-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-2-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-3-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-4-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-5-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-6-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-7-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-8-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-9-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-0-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-DOT-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-DASH-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-SLASH-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-L1-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-L2-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-L3-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-L4-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-R1-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-R2-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-R3-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-R4-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-PREV-press", 0.0); -setprop("/instrumentation/fmz/fmz-key-NEXT-press", 0.0); -setprop("/instrumentation/fmz/waypoints-num", 0.0); - -var waypoints = std.Vector.new(); - -var fmzCanvas = func { - - var font_mapper = func(family,weight) { - if (family == "'DejaVu Sans Mono'" and weight == "normal") { - return "DejaVuSansMono.ttf"; - } - }; - - var my_canvas = canvas.new({ - "name": "fmz", - "size": [1024, 1024], - "view": [1024, 1024], - "mipmapping": 1 - }); - - var fmz = my_canvas.createGroup(); - - canvas.parsesvg( - fmz, - "Aircraft/bd700/Models/fmz/fmz.svg", - {'font-mapper': font_mapper} - ); - - var numericMonth = { - "JAN":1, - "FEB":2, - "MAR":3, - "APR":4, - "MAY":5, - "JUN":6, - "JUL":7, - "AUG":8, - "SEP":9, - "OCT":10, - "NOV":11, - "DEC":12, - }; - - var createWaypoint = { - orgn_id:"江泽民", - id:"董建华", - type:"Normal", - lat:1989.0604, - lon:-1989.0604, - lat_nd:1989.0604, - lon_nd:-1989.0604, - speed:0, - altitude:-19890604.0, - altitudeCons:0, - altitudeRestriction:"at", - hdg_crs:0, - hdg_crs_value:-1989.0604, - distance:0, - flytype:"Fly-by", - bankLimit:25, - radialtoIntercept:-1989.0604, - DMEtoIntercept:-1989.0604, - sp_turn:"Auto", - hld_rad_or_inbd:"Inbd", - hld_rad_vlue:-1989.0604, - hld_turn:"Right", - hld_time_dist:"Time", - hld_td_value:0, - procedure:"not in proc", - - new: func(orgn_id, lat=0.0, lon=0.0) { - var p = {parents:[createWaypoint]}; - p.orgn_id = orgn_id; - p.id = orgn_id; - p.lat = lat; - p.lon = lon; - p.lat_nd = lat; - p.lon_nd = lon; - return p; - }, - }; - - var pageTitle = fmz.getElementById("pageTitle"); - var pageTitleRight = fmz.getElementById("pageTitleRight"); - var scratchPad = fmz.getElementById("scratchPad"); - var line1Left = fmz.getElementById("line1Left"); - var line2Left = fmz.getElementById("line2Left"); - var line3Left = fmz.getElementById("line3Left"); - var line4Left = fmz.getElementById("line4Left"); - var line5Left = fmz.getElementById("line5Left"); - var line6Left = fmz.getElementById("line6Left"); - var line7Left = fmz.getElementById("line7Left"); - var line1Right = fmz.getElementById("line1Right"); - var line2Right = fmz.getElementById("line2Right"); - var line3Right = fmz.getElementById("line3Right"); - var line4Right = fmz.getElementById("line4Right"); - var line5Right = fmz.getElementById("line5Right"); - var line6Right = fmz.getElementById("line6Right"); - var line7Right = fmz.getElementById("line7Right"); - var line1Mid = fmz.getElementById("line1Mid"); - var line2Mid = fmz.getElementById("line2Mid"); - var line3Mid = fmz.getElementById("line3Mid"); - var line4Mid = fmz.getElementById("line4Mid"); - var line5Mid = fmz.getElementById("line5Mid"); - var line6Mid = fmz.getElementById("line6Mid"); - var line7Mid = fmz.getElementById("line7Mid"); - var l7rRectangle = fmz.getElementById("l7rRectangle"); - var currentPage = fmz.getElementById("currentPage"); - var totalPage = fmz.getElementById("totalPage"); - var save_current_page = 0; - var current_page_prop = 1; - var total_page_prop = 1; - var total_page_rte = 1; - var total_page_miss = 1; - var total_page_altn = 1; - var page_prop_tmp = -9999; - var scratch_pad_text = ""; - var scratch_pad_message = ""; - var scratch_pad_display = " "; - var press_orgn = { - "A": getprop("/instrumentation/fmz/fmz-key-A-press"), - "B": getprop("/instrumentation/fmz/fmz-key-B-press"), - "C": getprop("/instrumentation/fmz/fmz-key-C-press"), - "D": getprop("/instrumentation/fmz/fmz-key-D-press"), - "E": getprop("/instrumentation/fmz/fmz-key-E-press"), - "F": getprop("/instrumentation/fmz/fmz-key-F-press"), - "G": getprop("/instrumentation/fmz/fmz-key-G-press"), - "H": getprop("/instrumentation/fmz/fmz-key-H-press"), - "I": getprop("/instrumentation/fmz/fmz-key-I-press"), - "J": getprop("/instrumentation/fmz/fmz-key-J-press"), - "K": getprop("/instrumentation/fmz/fmz-key-K-press"), - "L": getprop("/instrumentation/fmz/fmz-key-L-press"), - "M": getprop("/instrumentation/fmz/fmz-key-M-press"), - "N": getprop("/instrumentation/fmz/fmz-key-N-press"), - "O": getprop("/instrumentation/fmz/fmz-key-O-press"), - "P": getprop("/instrumentation/fmz/fmz-key-P-press"), - "Q": getprop("/instrumentation/fmz/fmz-key-Q-press"), - "R": getprop("/instrumentation/fmz/fmz-key-R-press"), - "S": getprop("/instrumentation/fmz/fmz-key-S-press"), - "T": getprop("/instrumentation/fmz/fmz-key-T-press"), - "U": getprop("/instrumentation/fmz/fmz-key-U-press"), - "V": getprop("/instrumentation/fmz/fmz-key-V-press"), - "W": getprop("/instrumentation/fmz/fmz-key-W-press"), - "X": getprop("/instrumentation/fmz/fmz-key-X-press"), - "Y": getprop("/instrumentation/fmz/fmz-key-Y-press"), - "Z": getprop("/instrumentation/fmz/fmz-key-Z-press"), - "1": getprop("/instrumentation/fmz/fmz-key-1-press"), - "2": getprop("/instrumentation/fmz/fmz-key-2-press"), - "3": getprop("/instrumentation/fmz/fmz-key-3-press"), - "4": getprop("/instrumentation/fmz/fmz-key-4-press"), - "5": getprop("/instrumentation/fmz/fmz-key-5-press"), - "6": getprop("/instrumentation/fmz/fmz-key-6-press"), - "7": getprop("/instrumentation/fmz/fmz-key-7-press"), - "8": getprop("/instrumentation/fmz/fmz-key-8-press"), - "9": getprop("/instrumentation/fmz/fmz-key-9-press"), - "0": getprop("/instrumentation/fmz/fmz-key-0-press"), - "CLR": getprop("/instrumentation/fmz/fmz-key-CLR-press"), - "DEL": getprop("/instrumentation/fmz/fmz-key-DEL-press"), - ".": getprop("/instrumentation/fmz/fmz-key-DOT-press"), - "/": getprop("/instrumentation/fmz/fmz-key-SLASH-press"), - "-": getprop("/instrumentation/fmz/fmz-key-DASH-press"), - "PREV": getprop("/instrumentation/fmz/fmz-key-PREV-press"), - "NEXT": getprop("/instrumentation/fmz/fmz-key-NEXT-press"), - "L1": getprop("/instrumentation/fmz/fmz-key-L1-press"), - "L2": getprop("/instrumentation/fmz/fmz-key-L2-press"), - "L3": getprop("/instrumentation/fmz/fmz-key-L3-press"), - "L4": getprop("/instrumentation/fmz/fmz-key-L4-press"), - "R1": getprop("/instrumentation/fmz/fmz-key-R1-press"), - "R2": getprop("/instrumentation/fmz/fmz-key-R2-press"), - "R3": getprop("/instrumentation/fmz/fmz-key-R3-press"), - "R4": getprop("/instrumentation/fmz/fmz-key-R4-press"), - }; - var A_press_orig = getprop("/instrumentation/fmz/fmz-key-A-press"); - var B_press_orig = getprop("/instrumentation/fmz/fmz-key-B-press"); - var C_press_orig = getprop("/instrumentation/fmz/fmz-key-C-press"); - var D_press_orig = getprop("/instrumentation/fmz/fmz-key-D-press"); - var E_press_orig = getprop("/instrumentation/fmz/fmz-key-E-press"); - var F_press_orig = getprop("/instrumentation/fmz/fmz-key-F-press"); - var G_press_orig = getprop("/instrumentation/fmz/fmz-key-G-press"); - var H_press_orig = getprop("/instrumentation/fmz/fmz-key-H-press"); - var I_press_orig = getprop("/instrumentation/fmz/fmz-key-I-press"); - var J_press_orig = getprop("/instrumentation/fmz/fmz-key-J-press"); - var K_press_orig = getprop("/instrumentation/fmz/fmz-key-K-press"); - var L_press_orig = getprop("/instrumentation/fmz/fmz-key-L-press"); - var M_press_orig = getprop("/instrumentation/fmz/fmz-key-M-press"); - var N_press_orig = getprop("/instrumentation/fmz/fmz-key-N-press"); - var O_press_orig = getprop("/instrumentation/fmz/fmz-key-O-press"); - var P_press_orig = getprop("/instrumentation/fmz/fmz-key-P-press"); - var Q_press_orig = getprop("/instrumentation/fmz/fmz-key-Q-press"); - var R_press_orig = getprop("/instrumentation/fmz/fmz-key-R-press"); - var S_press_orig = getprop("/instrumentation/fmz/fmz-key-S-press"); - var T_press_orig = getprop("/instrumentation/fmz/fmz-key-T-press"); - var U_press_orig = getprop("/instrumentation/fmz/fmz-key-U-press"); - var V_press_orig = getprop("/instrumentation/fmz/fmz-key-V-press"); - var W_press_orig = getprop("/instrumentation/fmz/fmz-key-W-press"); - var X_press_orig = getprop("/instrumentation/fmz/fmz-key-X-press"); - var Y_press_orig = getprop("/instrumentation/fmz/fmz-key-Y-press"); - var Z_press_orig = getprop("/instrumentation/fmz/fmz-key-Z-press"); - var DEL_press_orig = getprop("/instrumentation/fmz/fmz-key-DEL-press"); - var CLR_press_orig = getprop("/instrumentation/fmz/fmz-key-CLR-press"); - var num1_press_orig = getprop("/instrumentation/fmz/fmz-key-1-press"); - var num2_press_orig = getprop("/instrumentation/fmz/fmz-key-2-press"); - var num3_press_orig = getprop("/instrumentation/fmz/fmz-key-3-press"); - var num4_press_orig = getprop("/instrumentation/fmz/fmz-key-4-press"); - var num5_press_orig = getprop("/instrumentation/fmz/fmz-key-5-press"); - var num6_press_orig = getprop("/instrumentation/fmz/fmz-key-6-press"); - var num7_press_orig = getprop("/instrumentation/fmz/fmz-key-7-press"); - var num8_press_orig = getprop("/instrumentation/fmz/fmz-key-8-press"); - var num9_press_orig = getprop("/instrumentation/fmz/fmz-key-9-press"); - var num0_press_orig = getprop("/instrumentation/fmz/fmz-key-0-press"); - var DOT_press_orig = getprop("/instrumentation/fmz/fmz-key-DOT-press"); - var DASH_press_orig = getprop("/instrumentation/fmz/fmz-key-DASH-press"); - var SLASH_press_orig = getprop("/instrumentation/fmz/fmz-key-SLASH-press"); - var L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - var L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - var L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - var L4_press_orig = getprop("/instrumentation/fmz/fmz-key-L4-press"); - var R1_press_orig = getprop("/instrumentation/fmz/fmz-key-R1-press"); - var R2_press_orig = getprop("/instrumentation/fmz/fmz-key-R2-press"); - var R3_press_orig = getprop("/instrumentation/fmz/fmz-key-R3-press"); - var R4_press_orig = getprop("/instrumentation/fmz/fmz-key-R4-press"); - var PREV_press_orig = getprop("/instrumentation/fmz/fmz-key-PREV-press"); - var NEXT_press_orig = getprop("/instrumentation/fmz/fmz-key-NEXT-press"); - var page_title_text = "NAV IDENT"; - var set_date = "10MAR16"; - var global_set_time = "1358Z"; - var time_orig = global_set_time; - var time_counter = 0.0; - var time_text = global_set_time; - var time_1 = chr(time_orig[3]); - var time_10 = chr(time_orig[2]); - var time_100 = chr(time_orig[1]); - var time_1000 = chr(time_orig[0]); - var pos_init_loaded = ""; - var origin_airport_hash = createWaypoint.new(airportinfo().id, airportinfo().lat, airportinfo().lon); - origin_airport_hash.altitude = airportinfo().elevation; - waypoints.insert(0, origin_airport_hash); - var origin_airport_id = waypoints.vector[0].id; - var sld_rwy = nil; - var wpt_sel_vec = []; - var wpt_sel_isr = 65532; - var wpt_num = waypoints.size(); - var custom_wpt_prop = []; - var dest_airport = ""; - var altn_airport = ""; - var awy_wpt_list = []; - var awy_wpt_list_lat = []; - var awy_wpt_list_lon = []; - var is_active = 0; - var sel_sid = "I am angry."; - var sel_sid_blk = ""; - var sel_sid_tran = ""; - var spd_rule = ""; - var perf_mode = "FULL PERF"; - var acft_tail_num = ""; - var clb_ias = 300; - var clb_mach = 0.80; - var crs_perf_type = "LRC"; - var crs_ias = 300; - var crs_mach = 0.80; - var des_ias = 300; - var des_mach = 0.80; - var des_path_deg = 3.0; - var step_incm = 0; - var fuel_rsv_mode = "NBAA"; - var fuel_rsv_lb = 0; - var fuel_rsv_min = 0; - var to_fuel = 400; - var ldg_fuel = 200; - var ttl_fuel_prd = 0.0; - var dest_fuel_prd = 0.0; - var altn_fuel_prd = 0.0; - var fuel_no_rsv = 0.0; - var req_rsv = 0.0; - var ete_to_dest = 0.0; - var ete_to_altn = 0.0; - var dep_spd_lmt = 200; - var dep_agl_lmt = 2500; - var dep_nm_lmt = 4.0; - var app_init_dst = 15; - var app_1st_wpt = "YES"; - var cln_app_lmt = 200; - var flp6_app_lmt = 180; - var flp16_app_lmt = 160; - var flp30_app_lmt = 140; - var cln_ga_lmt = 200; - var flp6_ga_lmt = 180; - var flp16_ga_lmt = 160; - var flp30_ga_lmt = 135; - var cln_vso = 200 / 1.3; - var flp6_vso = 180 / 1.3; - var flp16_vso = 160 / 1.3; - var flp30_vso = 140 / 1.3; - var cln_vref = 200; - var flp6_vref = 180; - var flp16_vref = 160; - var flp30_vref = 140; - var miss_wpt_vec = []; - var altn_wpt_vec = []; - var trans_alt = 18000; - var spd_alt_lim_s = 250; - var spd_alt_lim_a = 10000; - var init_crz_alt_mod = "OPTIMUM"; - var init_crz_alt = -9999; - var crn_crz_alt = init_crz_alt; - var opm_init_alt = 0; - var ceil_alt = -9999; - var isa_dev_c = 0; - var crz_wind_d = 360; - var crz_wind_s = 0; - var crz_wind_at_alt = 40000; - var bsc_oprt_wght = 45000; - var fuel_qnt_snsr = 1; - var total_fuel_lbs_inp = getprop("/consumables/fuel/total-fuel-lbs") or -9999; - var plan_fuel_ground = total_fuel_lbs_inp; - var cargo_weight = -9999; - var pax_number = 99999; - var weight_per_pax = -9999; - var perf_page_read = [0,0,0,0,0]; - var fuel_prd_fom_dest = 0.2; - var fuel_prd_fom_altn = 0.2; - - var key_prs = func(key, key_func){ - var press_crnt = getprop("/instrumentation/fmz/fmz-key-" ~ key ~ "-press"); - if (press_orgn[key] == 0 and press_crnt == 1){ - key_func(); - } - press_orgn[key] = press_crnt; - } - - var fmz_setlistener = func(fnc_name) { - setlistener("sim/signals/fdm-initialized", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-A-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-B-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-C-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-D-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-E-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-F-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-G-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-H-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-I-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-J-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-K-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-L-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-M-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-N-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-O-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-P-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-Q-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-R-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-S-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-T-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-U-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-V-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-W-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-X-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-Y-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-Z-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-DEL-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-CLR-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-1-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-2-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-3-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-4-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-5-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-6-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-7-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-8-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-9-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-0-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-DOT-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-DASH-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-SLASH-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-L1-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-L2-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-L3-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-L4-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-R1-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-R2-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-R3-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-R4-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-NEXT-press", fnc_name); - setlistener("/instrumentation/fmz/fmz-key-PREV-press", fnc_name); - } - - var eachPageInit = func () { - pageTitle.setText(""); - pageTitle.setColor(255,255,255,255); - pageTitle.setFontSize(48,1); - pageTitleRight.setText(""); - pageTitleRight.setColor(255,255,255,255); - pageTitleRight.setFontSize(48,1); - currentPage.setText(""); - currentPage.setColor(255,255,255,255); - currentPage.setFontSize(36,1); - totalPage.setText(""); - totalPage.setColor(255,255,255,255); - totalPage.setFontSize(36,1); - line1Left.setText(""); - line1Left.setColor(255,255,255,255); - line1Left.setFontSize(36,1); - line1Mid.setText(""); - line1Mid.setColor(255,255,255,255); - line1Mid.setFontSize(36,1); - line1Right.setText(""); - line1Right.setColor(255,255,255,255); - line1Right.setFontSize(36,1); - line2Left.setText(""); - line2Left.setColor(255,255,255,255); - line2Left.setFontSize(48,1); - line2Mid.setText(""); - line2Mid.setColor(255,255,255,255); - line2Mid.setFontSize(36,1); - line2Right.setText(""); - line2Right.setColor(255,255,255,255); - line2Right.setFontSize(48,1); - line3Left.setText(""); - line3Left.setColor(255,255,255,255); - line3Left.setFontSize(36,1); - line3Mid.setText(""); - line3Mid.setColor(255,255,255,255); - line3Mid.setFontSize(36,1); - line3Right.setText(""); - line3Right.setColor(255,255,255,255); - line3Right.setFontSize(36,1); - line4Left.setText(""); - line4Left.setColor(255,255,255,255); - line4Left.setFontSize(48,1); - line4Mid.setText(""); - line4Mid.setColor(255,255,255,255); - line4Mid.setFontSize(36,1); - line4Right.setText(""); - line4Right.setColor(255,255,255,255); - line4Right.setFontSize(48,1); - line5Left.setText(""); - line5Left.setColor(255,255,255,255); - line5Left.setFontSize(36,1); - line5Mid.setText(""); - line5Mid.setColor(255,255,255,255); - line5Mid.setFontSize(36,1); - line5Right.setText(""); - line5Right.setColor(255,255,255,255); - line5Right.setFontSize(36,1); - line6Left.setText(""); - line6Left.setColor(255,255,255,255); - line6Left.setFontSize(48,1); - line6Mid.setText(""); - line6Mid.setColor(255,255,255,255); - line6Mid.setFontSize(36,1); - line6Right.setText(""); - line6Right.setColor(255,255,255,255); - line6Right.setFontSize(48,1); - line7Left.setText(""); - line7Left.setColor(255,255,255,255); - line7Left.setFontSize(36,1); - line7Mid.setText(""); - line7Mid.setColor(255,255,255,255); - line7Right.setText(""); - line7Right.setColor(255,255,255,255); - line7Right.setFontSize(36,1); - l7rRectangle.setVisible(0); - } - - var bsc_oprt_wght1 = bsc_oprt_wght; - var cargo_weight1 = cargo_weight; - var pax_number1 = pax_number; - var weight_per_pax1 = weight_per_pax; - var init_crz_alt_mod1 = init_crz_alt_mod; - var init_crz_alt1 = init_crz_alt; - var zfw = bsc_oprt_wght1 + (weight_per_pax1 * pax_number1) + cargo_weight1; - - var checkPerfInit = func () { - var can_confirm = "incompleted"; - var check_mark = []; - var whl_cnt = 0; - while (whl_cnt <= 5) { - append(check_mark, 0); - whl_cnt = whl_cnt + 1; - } - - var have_all_read = 0; - var whl_cnt = 0; - while (whl_cnt 0) { - check_mark[1] = 1; - } - - if (cargo_weight >= 0) { - check_mark[2] = 1; - } - - if (pax_number >= 0 and pax_number <= 30) { - check_mark[3] = 1; - } - - if (weight_per_pax >= 0) { - check_mark[4] = 1; - } - - if (init_crz_alt_mod != "MANUAL" or init_crz_alt > 0) { - check_mark[5] = 1; - } - - if (bsc_oprt_wght1 != bsc_oprt_wght or cargo_weight1 != cargo_weight or pax_number1 != pax_number or weight_per_pax1 != weight_per_pax or init_crz_alt_mod1 != init_crz_alt_mod or init_crz_alt1 != init_crz_alt) { - var any_perf_changed = 1; - } else { - var any_perf_changed = 0; - } - - - var whl_cnt = 0; - while (whl_cnt < size(check_mark)) { - if (check_mark[whl_cnt] == 1 and any_perf_changed == 1) { - can_confirm = "can confirm"; - whl_cnt = whl_cnt + 1; - } else if (check_mark[whl_cnt] == 1 and any_perf_changed == 0) { - can_confirm = "don't need"; - whl_cnt = whl_cnt + 1; - } else { - can_confirm = "incompleted"; - whl_cnt = 65532; - } - } - - return (can_confirm); - } - - var totalFuelByFlow = func () { - var engine0_flow_pph = getprop("/engines/engine[0]/fuel-flow_pph") or 0; - var engine1_flow_pph = getprop("/engines/engine[1]/fuel-flow_pph") or 0; - var total_flow_pph = engine0_flow_pph + engine1_flow_pph; - var total_flow_pps = total_flow_pph / 3600; - total_fuel_lbs_inp = total_fuel_lbs_inp - total_flow_pps; - } - var totalFuelByFlow_timer = maketimer(1, totalFuelByFlow); - totalFuelByFlow_timer.start(); - - var frozen_fuel_on_ground = func () { - var on_ground = getprop("/fdm/jsbsim/gear/wow") or 1; - if (on_ground == 1) { - plan_fuel_ground = total_fuel_lbs_inp; - } - } - var frozen_fuel_on_ground_timer = maketimer(1, frozen_fuel_on_ground); - frozen_fuel_on_ground_timer.start(); - - var milthrust_grid = [ - [1.2600, 1.0000, 0.7400, 0.5340, 0.3720, 0.2410, 0.1490, 0.0000], - [1.0680, 0.8518, 0.6357, 0.4615, 0.3238, 0.2107, 0.1304, 0.0000], - [0.9476, 0.7589, 0.5702, 0.4169, 0.2942, 0.1920, 0.1195, 0.0000], - [0.8692, 0.6999, 0.5307, 0.3916, 0.2782, 0.1825, 0.1133, 0.0000], - [0.8152, 0.6610, 0.5067, 0.3771, 0.2702, 0.1782, 0.1102, 0.0000], - [0.7666, 0.6272, 0.4878, 0.3646, 0.2660, 0.1764, 0.1092, 0.0000], - ]; - - var milthrust_inp = func (mach, alt) { - var x = 0; - var y = 0; - var dif_x = 0.2; - var dif_mach = 0; - var dif_y = 10000; - var dif_alt = 0; - var thrust_cfn = 1; - - if (mach < 0.2) { - x = 0; - dif_mach = mach; - } else if (mach >= 0.2 and mach < 0.4) { - x = 1; - dif_mach = mach - 0.2; - } else if (mach >= 0.4 and mach < 0.6) { - x = 2; - dif_mach = mach - 0.4; - } else if (mach >= 0.6 and mach < 0.8) { - x = 3; - dif_mach = mach - 0.6; - } else if (mach >= 0.8 and mach < 1.0) { - x = 4; - dif_mach = mach - 0.8; - } else { - x = 4; - dif_mach = 0.0; - } - - if (alt < 0) { - y = 0; - dif_alt = alt; - } else if (alt >= 0 and alt < 10000) { - y = 1; - dif_alt = alt; - } else if (alt >= 10000 and alt < 20000) { - y = 2; - dif_alt = alt - 10000; - } else if (alt >= 20000 and alt < 30000) { - y = 3; - dif_alt = alt - 20000; - } else if (alt >= 30000 and alt < 40000) { - y = 4; - dif_alt = alt - 30000; - } else if (alt >= 40000 and alt < 50000) { - y = 5; - dif_alt = alt - 40000; - } else if (alt >= 50000 and alt < 60000) { - y = 6; - dif_alt = alt - 50000; - } else { - y = 6; - dif_alt = 0; - } - - var dif_mach_y = milthrust_grid[x + 1][y] - milthrust_grid[x][y]; - var dif_mach_y1 = milthrust_grid[x + 1][y + 1] - milthrust_grid[x][y + 1]; - var avg = milthrust_grid[x][y] + dif_mach_y / dif_x * dif_mach; - var avg1 = milthrust_grid[x][y + 1] + dif_mach_y1 / dif_x * dif_mach; - var thrust_rsl = avg + (avg1 - avg) / dif_y * dif_alt; - return(thrust_rsl); - } - - var dist_to_dest = func() { - var wpt_num = rte_wpt_counter(); - var clc_rlt = 0; - var whl_cnt = 1; - while (whl_cnt < wpt_num) { - var each_dst = grtCircDist(whl_cnt); - clc_rlt = clc_rlt + each_dst; - whl_cnt = whl_cnt + 1; - } - return(clc_rlt); - } - - var ttl_rte_dst = func() { - var clc_rlt = 0; - var wpt_num = waypoints.size(); - for (i=1; i 500) { - - for (i=0; i<32; i=i+1){ - theta = (273 + crn_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var clb_tas = 250 + 250 * (crn_dns_alt/600/100 + (crn_temp - 15)/5/100); - mach_conv = clb_tas / snd_spd_temp; - var thrust = 14750 * 2 * milthrust_inp(mach_conv, crn_dns_alt); - var cl_for_clb = (-(thrust/grs_wgt_to) + math.sqrt(math.pow(thrust/grs_wgt_to,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_clb < 0 ) { - cl_for_clb = (-(thrust/grs_wgt_to) - math.sqrt(math.pow(thrust/grs_wgt_to,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - var cd_for_clb = cd0 + ind_drag_K * math.pow(cl_for_clb, 2); - var sin_ang_clb = thrust/grs_wgt_to - cd_for_clb/cl_for_clb; - var vrt_spd_grd = clb_tas * sin_ang_clb * 101.2685; - - fd_temp = crn_temp - ((10000 - crn_dns_alt) / 1000 * 1.98); - std_temp = 15 - 1.98 * (10000/1000); - theta = (273 + fd_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var clb_tas = 250 + 250 * (10000/600/100 + (fd_temp - std_temp)/5/100); - mach_conv = clb_tas / snd_spd_temp; - if (mach_conv > clb_mach) { - mach_conv = clb_mach; - } - thrust = 14750 * 2 * milthrust_inp(mach_conv, 10000); - cl_for_clb = (-(thrust/grs_wgt_10K) + math.sqrt(math.pow(thrust/grs_wgt_10K,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_clb < 0 ) { - cl_for_clb = (-(thrust/grs_wgt_10K) - math.sqrt(math.pow(thrust/grs_wgt_10K,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - cd_for_clb = cd0 + ind_drag_K * math.pow(cl_for_clb, 2); - sin_ang_clb = thrust/grs_wgt_10K - cd_for_clb/cl_for_clb; - var vrt_spd_10K = clb_tas * sin_ang_clb * 101.2685; - var abs_alt_lmt = (crn_dns_alt * vrt_spd_10K - 10000 * vrt_spd_grd) / (vrt_spd_10K - vrt_spd_grd); - var clb_time_10K = (abs_alt_lmt / vrt_spd_grd) * math.ln((abs_alt_lmt - crn_dns_alt) / (abs_alt_lmt - 10000)); - clb_time_10K = clb_time_10K / 60; - var fuel_burned_10K = clb_time_10K * thrust * 0.623; - grs_wgt_10K = grs_wgt_to - fuel_burned_10K; - } - rte_gone = clb_tas * clb_time_10K; - ete_gone = clb_time_10K; - - for (i=0; i<32; i=i+1) { - fd_temp = crn_temp - ((test_alt - crn_dns_alt) / 1000 * 1.98); - std_temp = 15 - 1.98 * (test_alt/1000); - theta = (273 + fd_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var clb_tas = clb_ias + clb_ias * (test_alt/600/100 + (fd_temp - std_temp)/5/100); - mach_conv = clb_tas / snd_spd_temp; - if (mach_conv > clb_mach) { - mach_conv = clb_mach; - } - thrust = 14750 * 2 * milthrust_inp(mach_conv, test_alt); - cl_for_clb = (-(thrust/grs_wgt_toc) + math.sqrt(math.pow(thrust/grs_wgt_toc,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_clb < 0 ) { - cl_for_clb = (-(thrust/grs_wgt_toc) - math.sqrt(math.pow(thrust/grs_wgt_toc,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - cd_for_clb = cd0 + ind_drag_K * math.pow(cl_for_clb, 2); - sin_ang_clb = thrust/grs_wgt_toc - cd_for_clb/cl_for_clb; - if (mach_conv < clb_mach) { - vrt_spd_toc = clb_tas * sin_ang_clb * 101.2685; - } else { - var clb_tas = mach_conv * snd_spd_temp; - vrt_spd_toc = clb_tas * sin_ang_clb * 101.2685; - } - var clb_time_toc = 0; - if ((abs_alt_lmt - 10000) / (abs_alt_lmt - test_alt) != 1) { - abs_alt_lmt = (10000 * vrt_spd_toc - test_alt * vrt_spd_10K) / (vrt_spd_toc - vrt_spd_10K); - clb_time_toc = (abs_alt_lmt / vrt_spd_10K) * math.ln((abs_alt_lmt - 10000) / (abs_alt_lmt - test_alt)); - } - clb_time_toc = clb_time_toc / 60; - var fuel_burned_toc = clb_time_toc * thrust * 0.623; - grs_wgt_toc = grs_wgt_10K - fuel_burned_toc; - } - test_alt = test_alt + 1000; - } - opm_init_alt = test_alt - 1000 - 2000; - ceil_alt = test_alt - 1000; - var opm_alt = test_alt - 1000 - 2000; - - for (i=0; i<32; i=i+1) { - fd_temp = crn_temp - ((opm_alt - crn_dns_alt) / 1000 * 1.98); - std_temp = 15 - 1.98 * (opm_alt/1000); - theta = (273 + fd_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var clb_tas = clb_ias + clb_ias * (opm_alt/600/100 + (fd_temp - std_temp)/5/100); - mach_conv = clb_tas / snd_spd_temp; - if (mach_conv > clb_mach) { - mach_conv = clb_mach; - } - thrust = 14750 * 2 * milthrust_inp(mach_conv, opm_alt); - cl_for_clb = (-(thrust/grs_wgt_toc) + math.sqrt(math.pow(thrust/grs_wgt_toc,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_clb < 0 ) { - cl_for_clb = (-(thrust/grs_wgt_toc) - math.sqrt(math.pow(thrust/grs_wgt_toc,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - cd_for_clb = cd0 + ind_drag_K * math.pow(cl_for_clb, 2); - sin_ang_clb = thrust/grs_wgt_toc - cd_for_clb/cl_for_clb; - if (mach_conv < clb_mach) { - vrt_spd_toc = clb_tas * sin_ang_clb * 101.2685; - } else { - var clb_tas = mach_conv * snd_spd_temp; - vrt_spd_toc = clb_tas * sin_ang_clb * 101.2685; - } - var clb_time_toc = 0; - if ((abs_alt_lmt - 10000) / (abs_alt_lmt - opm_alt) != 1) { - abs_alt_lmt = (10000 * vrt_spd_toc - opm_alt * vrt_spd_10K) / (vrt_spd_toc - vrt_spd_10K); - clb_time_toc = (abs_alt_lmt / vrt_spd_10K) * math.ln((abs_alt_lmt - 10000) / (abs_alt_lmt - opm_alt)); - } - clb_time_toc = clb_time_toc / 60; - var fuel_burned_toc = clb_time_toc * thrust * 0.623; - grs_wgt_toc = grs_wgt_10K - fuel_burned_toc; - } - rte_gone = rte_gone + (clb_time_toc * clb_tas); - ete_gone = ete_gone + clb_time_toc; - - var opm_fd_temp = crn_temp - ((opm_alt - crn_dns_alt) / 1000 * 1.98); - var opm_std_temp = 15 - 1.98 * (opm_alt/1000); - var opm_alt_prs = opm_alt - (100 * (opm_fd_temp - opm_std_temp)); - opm_alt_prs = math.round(opm_alt / 1000) * 1000; - - var grs_wgt_crs = grs_wgt_toc; - - while(rte_gone < rte_rng) { - vrt_spd_toc = -99999; - var crs_min_count = 0; - while(vrt_spd_toc < 500 and rte_gone < rte_rng) { - - var opm_alt_std_temp = 15 - 1.98 * (opm_alt / 1000); - theta = (273 + opm_alt_std_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var crs_tas = crs_ias * (1 + (opm_alt/600/100)); - mach_conv = crs_tas / snd_spd_temp; - - if (mach_conv > crs_mach) { - mach_conv = crs_mach; - } - - var crs_thr = 14750 * 2 * milthrust_inp(mach_conv, opm_alt); - var sin_ang_crs = 99999; - while(sin_ang_crs>0.008){ - crs_thr = crs_thr - 100; - cl_for_crs = (-(crs_thr/grs_wgt_crs) + math.sqrt(math.pow(crs_thr/grs_wgt_crs,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_crs < 0 ) { - cl_for_crs = (-(crs_thr/grs_wgt_crs) - math.sqrt(math.pow(crs_thr/grs_wgt_crs,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - cd_for_crs = cd0 + ind_drag_K * math.pow(cl_for_crs, 2); - sin_ang_crs = crs_thr/grs_wgt_crs - cd_for_crs/cl_for_crs; - } - var crs_fuel_rate = (crs_thr * 0.623); - var crs_fuel_brn_min = crs_fuel_rate / 60; - grs_wgt_crs = grs_wgt_crs - crs_fuel_brn_min; - - var next_opm_alt = opm_alt + (step_incm * 1000) + 2000; - - var next_std_temp = 15 - 1.98 * (next_opm_alt / 1000); - theta = (273 + next_std_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var clb_tas = clb_ias + clb_ias * (next_opm_alt/600/100); - mach_conv = clb_tas / snd_spd_temp; - if (mach_conv > clb_mach) { - mach_conv = clb_mach; - } - thrust = 14750 * 2 * milthrust_inp(mach_conv, next_opm_alt); - cl_for_clb = (-(thrust/grs_wgt_crs) + math.sqrt(math.pow(thrust/grs_wgt_crs,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_clb < 0 ) { - cl_for_clb = (-(thrust/grs_wgt_crs) - math.sqrt(math.pow(thrust/grs_wgt_crs,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - cd_for_clb = cd0 + ind_drag_K * math.pow(cl_for_clb, 2); - sin_ang_clb = thrust/grs_wgt_crs - cd_for_clb/cl_for_clb; - if (mach_conv < clb_mach) { - vrt_spd_toc = clb_tas * sin_ang_clb * 101.2685; - } else { - var clb_tas = mach_conv * snd_spd_temp; - vrt_spd_toc = clb_tas * sin_ang_clb * 101.2685; - } - crs_min_count = crs_min_count + 1; - rte_gone = rte_gone + (1/60 * crs_tas); - ete_gone = ete_gone + (1/60); - } - - if (vrt_spd_toc > 500) { - var last_opm_alt = opm_alt; - opm_alt = next_opm_alt - 2000; - - var vrt_spd_next_step = -999999; - var grs_wgt_next_step = grs_wgt_crs; - - for (i=0; i<8; i=i+1) { - std_temp = 15 - 1.98 * (opm_alt/1000); - theta = (273 + std_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var clb_tas = clb_ias + clb_ias * (opm_alt/600/100); - mach_conv = clb_tas / snd_spd_temp; - if (mach_conv > clb_mach) { - mach_conv = clb_mach; - } - thrust = 14750 * 2 * milthrust_inp(mach_conv, opm_alt); - cl_for_clb = (-(thrust/grs_wgt_next_step) + math.sqrt(math.pow(thrust/grs_wgt_next_step,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_clb < 0 ) { - cl_for_clb = (-(thrust/grs_wgt_next_step) - math.sqrt(math.pow(thrust/grs_wgt_next_step,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - cd_for_clb = cd0 + ind_drag_K * math.pow(cl_for_clb, 2); - sin_ang_clb = thrust/grs_wgt_next_step - cd_for_clb/cl_for_clb; - if (mach_conv < clb_mach) { - vrt_spd_next_step = clb_tas * sin_ang_clb * 101.2685; - } else { - var clb_tas = mach_conv * snd_spd_temp; - vrt_spd_next_step = clb_tas * sin_ang_clb * 101.2685; - } - var clb_time_toc = 0; - if ((abs_alt_lmt - last_opm_alt) / (abs_alt_lmt - opm_alt) != 1) { - abs_alt_lmt = (last_opm_alt * vrt_spd_next_step - opm_alt * vrt_spd_toc) / (vrt_spd_next_step - vrt_spd_toc); - clb_time_toc = (abs_alt_lmt / vrt_spd_toc) * math.ln((abs_alt_lmt - last_opm_alt) / (abs_alt_lmt - opm_alt)); - } - clb_time_toc = clb_time_toc / 60; - var fuel_burned_toc = clb_time_toc * thrust * 0.623; - grs_wgt_next_step = grs_wgt_crs - fuel_burned_toc; - } - rte_gone = rte_gone + (clb_time_toc * clb_tas); - ete_gone = ete_gone + clb_time_toc; - grs_wgt_crs = grs_wgt_next_step; - } - } - - if (fuel_rsv_mode == "NBAA") { - - var grs_wgt_ga_5K = grs_wgt_crs; - - for (i=0; i<8; i=i+1){ - theta = (273 + std_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var clb_tas = 200 + 200 * (crn_dns_alt/600/100); - mach_conv = clb_tas / snd_spd_temp; - var thrust = 14750 * 2 * milthrust_inp(mach_conv, crn_dns_alt); - var cl_for_clb = (-(thrust/grs_wgt_crs) + math.sqrt(math.pow(thrust/grs_wgt_crs,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_clb < 0 ) { - cl_for_clb = (-(thrust/grs_wgt_crs) - math.sqrt(math.pow(thrust/grs_wgt_crs,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - var cd_for_clb = cd0 + ind_drag_K * math.pow(cl_for_clb, 2); - var sin_ang_clb = thrust/grs_wgt_crs - cd_for_clb/cl_for_clb; - var vrt_spd_grd = clb_tas * sin_ang_clb * 101.2685; - - std_temp = 15 - 1.98 * (5000/1000); - theta = (273 + std_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var clb_tas = 250 + 250 * (5000/600/100); - mach_conv = clb_tas / snd_spd_temp; - if (mach_conv > clb_mach) { - mach_conv = clb_mach; - } - thrust = 14750 * 2 * milthrust_inp(mach_conv, 5000); - cl_for_clb = (-(thrust/grs_wgt_ga_5K) + math.sqrt(math.pow(thrust/grs_wgt_ga_5K,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_clb < 0 ) { - cl_for_clb = (-(thrust/grs_wgt_ga_5K) - math.sqrt(math.pow(thrust/grs_wgt_ga_5K,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - cd_for_clb = cd0 + ind_drag_K * math.pow(cl_for_clb, 2); - sin_ang_clb = thrust/grs_wgt_ga_5K - cd_for_clb/cl_for_clb; - var vrt_spd_5K = clb_tas * sin_ang_clb * 101.2685; - var abs_alt_lmt = (crn_dns_alt * vrt_spd_5K - 5000 * vrt_spd_grd) / (vrt_spd_5K - vrt_spd_grd); - var clb_time_5K = (abs_alt_lmt / vrt_spd_grd) * math.ln((abs_alt_lmt - crn_dns_alt) / (abs_alt_lmt - 5000)); - clb_time_5K = clb_time_5K / 60; - var fuel_burned_5K = clb_time_10K * thrust * 0.623; - grs_wgt_ga_5K = grs_wgt_crs - fuel_burned_5K; - } - - var nbaa_atn_gone = 0; - ete_gone = ete_gone + clb_time_5K; - var grs_wgt_atn = grs_wgt_ga_5K; - - while(nbaa_atn_gone <= 200) { - - var opm_alt_std_temp = 15 - 1.98 * (opm_alt / 1000); - theta = (273 + opm_alt_std_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var crs_tas = crs_ias * (1 + (opm_alt/600/100)); - mach_conv = crs_tas / snd_spd_temp; - - if (mach_conv > crs_mach) { - mach_conv = crs_mach; - } - - var crs_thr = 14750 * 2 * milthrust_inp(mach_conv, opm_alt); - var sin_ang_crs = 99999; - while(sin_ang_crs>0.008){ - crs_thr = crs_thr - 100; - cl_for_crs = (-(crs_thr/grs_wgt_atn) + math.sqrt(math.pow(crs_thr/grs_wgt_atn,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_crs < 0 ) { - cl_for_crs = (-(crs_thr/grs_wgt_atn) - math.sqrt(math.pow(crs_thr/grs_wgt_atn,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - cd_for_crs = cd0 + ind_drag_K * math.pow(cl_for_crs, 2); - sin_ang_crs = crs_thr/grs_wgt_atn - cd_for_crs/cl_for_crs; - } - - var atn_fuel_rate = (crs_thr * 0.623); - var atn_fuel_brn_min = atn_fuel_rate / 60; - grs_wgt_atn = grs_wgt_atn - atn_fuel_brn_min; - nbaa_atn_gone = nbaa_atn_gone + (crs_tas * (1/60)); - ete_gone = ete_gone + (1/60); - } - - var grs_wgt_hold = grs_wgt_atn; - - for (hold_min=0; hold_min<=35; hold_min=hold_min+1) { - var hold_std_temp = 15 - 1.98 * (5000 / 1000); - var hold_tas = 200 * (1 + (5000/600/100)); - var hold_thr = 14750 * 2 * milthrust_inp(mach_conv, 5000); - var sin_ang_hold = 99999; - while(sin_ang_hold>0.008){ - hold_thr = hold_thr - 100; - hold_cl = (-(hold_thr/grs_wgt_hold) + math.sqrt(math.pow(hold_thr/grs_wgt_hold,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (hold_cl < 0 ) { - hold_cl = (-(hold_thr/grs_wgt_hold) - math.sqrt(math.pow(hold_thr/grs_wgt_hold,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - hold_cd = cd0 + ind_drag_K * math.pow(hold_cl, 2); - sin_ang_hold = hold_thr/grs_wgt_hold - hold_cd/hold_cl; - } - var hold_fuel_rate = (hold_thr * 0.623); - var hold_fuel_brn_min = hold_fuel_rate / 60; - grs_wgt_hold = grs_wgt_hold - hold_fuel_brn_min; - } - ete_gone = ete_gone + (35/60); - - var grs_wgt_ld = grs_wgt_hold; - ttl_fuel_prd = grs_wgt_to - grs_wgt_ld + to_fuel + ldg_fuel; - - } else if (fuel_rsv_lb != 0) { - ttl_fuel_prd = grs_wgt_to - grs_wgt_crs + fuel_rsv_lb + to_fuel + ldg_fuel; - } - fuel_no_rsv = grs_wgt_to - grs_wgt_crs + to_fuel + ldg_fuel; - req_rsv = ttl_fuel_prd - fuel_no_rsv; - grs_wgt_to = zfw + ttl_fuel_prd; - if (grs_wgt_to > 98000) { - grs_wgt_to = 98000; - } - } - dest_fuel_prd = ttl_fuel_prd; - ete_to_dest = ete_gone; - } - - var fuel_opm_alt_altn = func() { - var grs_wgt_to = 98000; - - for (j=0; j<32; j=j+1) { - var test_alt = 11000; - var rte_rng = ttl_rte_dst(); - var rte_gone = 0; - var ete_gone = 0; - var grd_dns_air = getprop("/environment/density-slugft3"); - var dns_air = getprop("/environment/density-slugft3"); - var crn_dns_alt = getprop("/fdm/jsbsim/atmosphere/density-altitude"); - var crn_temp = getprop("/environment/temperature-degc"); - var fd_temp = crn_temp - ((test_alt - crn_dns_alt) / 1000 * 1.98); - var std_temp = 15 - 1.98 * (test_alt/1000); - var theta = (273 + fd_temp) / (273 + 15); - var snd_spd_temp = 661 * math.sqrt(theta); - var oswald_efc = 0.755877483; - var ind_drag_K = 1 / (oswald_efc * math.pi * 8.654260529); - var cd0 = 0.013; - var mach_conv = 0; - var vrt_spd_toc = 99999; - var pilot_l_wgt = getprop("/fdm/jsbsim/inertia/pointmass-weight-lbs[0]"); - var pilot_r_wgt = getprop("/fdm/jsbsim/inertia/pointmass-weight-lbs[1]"); - var cabin_pyld = getprop("/fdm/jsbsim/inertia/pointmass-weight-lbs[2]"); - zfw = bsc_oprt_wght1 + (weight_per_pax1 * pax_number1) + cargo_weight1; - var grs_wgt_10K = grs_wgt_to; - var grs_wgt_toc = grs_wgt_to; - - while (test_alt <= 51000 and vrt_spd_toc > 500) { - - for (i=0; i<32; i=i+1){ - theta = (273 + crn_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var clb_tas = 250 + 250 * (crn_dns_alt/600/100 + (crn_temp - 15)/5/100); - mach_conv = clb_tas / snd_spd_temp; - var thrust = 14750 * 2 * milthrust_inp(mach_conv, crn_dns_alt); - var cl_for_clb = (-(thrust/grs_wgt_to) + math.sqrt(math.pow(thrust/grs_wgt_to,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_clb < 0 ) { - cl_for_clb = (-(thrust/grs_wgt_to) - math.sqrt(math.pow(thrust/grs_wgt_to,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - var cd_for_clb = cd0 + ind_drag_K * math.pow(cl_for_clb, 2); - var sin_ang_clb = thrust/grs_wgt_to - cd_for_clb/cl_for_clb; - var vrt_spd_grd = clb_tas * sin_ang_clb * 101.2685; - - fd_temp = crn_temp - ((10000 - crn_dns_alt) / 1000 * 1.98); - std_temp = 15 - 1.98 * (10000/1000); - theta = (273 + fd_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var clb_tas = 250 + 250 * (10000/600/100 + (fd_temp - std_temp)/5/100); - mach_conv = clb_tas / snd_spd_temp; - if (mach_conv > clb_mach) { - mach_conv = clb_mach; - } - thrust = 14750 * 2 * milthrust_inp(mach_conv, 10000); - cl_for_clb = (-(thrust/grs_wgt_10K) + math.sqrt(math.pow(thrust/grs_wgt_10K,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_clb < 0 ) { - cl_for_clb = (-(thrust/grs_wgt_10K) - math.sqrt(math.pow(thrust/grs_wgt_10K,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - cd_for_clb = cd0 + ind_drag_K * math.pow(cl_for_clb, 2); - sin_ang_clb = thrust/grs_wgt_10K - cd_for_clb/cl_for_clb; - var vrt_spd_10K = clb_tas * sin_ang_clb * 101.2685; - var abs_alt_lmt = (crn_dns_alt * vrt_spd_10K - 10000 * vrt_spd_grd) / (vrt_spd_10K - vrt_spd_grd); - var clb_time_10K = (abs_alt_lmt / vrt_spd_grd) * math.ln((abs_alt_lmt - crn_dns_alt) / (abs_alt_lmt - 10000)); - clb_time_10K = clb_time_10K / 60; - var fuel_burned_10K = clb_time_10K * thrust * 0.623; - grs_wgt_10K = grs_wgt_to - fuel_burned_10K; - } - rte_gone = clb_tas * clb_time_10K; - ete_gone = clb_time_10K; - - for (i=0; i<32; i=i+1) { - fd_temp = crn_temp - ((test_alt - crn_dns_alt) / 1000 * 1.98); - std_temp = 15 - 1.98 * (test_alt/1000); - theta = (273 + fd_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var clb_tas = clb_ias + clb_ias * (test_alt/600/100 + (fd_temp - std_temp)/5/100); - mach_conv = clb_tas / snd_spd_temp; - if (mach_conv > clb_mach) { - mach_conv = clb_mach; - } - thrust = 14750 * 2 * milthrust_inp(mach_conv, test_alt); - cl_for_clb = (-(thrust/grs_wgt_toc) + math.sqrt(math.pow(thrust/grs_wgt_toc,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_clb < 0 ) { - cl_for_clb = (-(thrust/grs_wgt_toc) - math.sqrt(math.pow(thrust/grs_wgt_toc,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - cd_for_clb = cd0 + ind_drag_K * math.pow(cl_for_clb, 2); - sin_ang_clb = thrust/grs_wgt_toc - cd_for_clb/cl_for_clb; - if (mach_conv < clb_mach) { - vrt_spd_toc = clb_tas * sin_ang_clb * 101.2685; - } else { - var clb_tas = mach_conv * snd_spd_temp; - vrt_spd_toc = clb_tas * sin_ang_clb * 101.2685; - } - var clb_time_toc = 0; - if ((abs_alt_lmt - 10000) / (abs_alt_lmt - test_alt) != 1) { - abs_alt_lmt = (10000 * vrt_spd_toc - test_alt * vrt_spd_10K) / (vrt_spd_toc - vrt_spd_10K); - clb_time_toc = (abs_alt_lmt / vrt_spd_10K) * math.ln((abs_alt_lmt - 10000) / (abs_alt_lmt - test_alt)); - } - clb_time_toc = clb_time_toc / 60; - var fuel_burned_toc = clb_time_toc * thrust * 0.623; - grs_wgt_toc = grs_wgt_10K - fuel_burned_toc; - } - test_alt = test_alt + 1000; - } - opm_init_alt = test_alt - 1000 - 2000; - ceil_alt = test_alt - 1000; - var opm_alt = test_alt - 1000 - 2000; - - for (i=0; i<32; i=i+1) { - fd_temp = crn_temp - ((opm_alt - crn_dns_alt) / 1000 * 1.98); - std_temp = 15 - 1.98 * (opm_alt/1000); - theta = (273 + fd_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var clb_tas = clb_ias + clb_ias * (opm_alt/600/100 + (fd_temp - std_temp)/5/100); - mach_conv = clb_tas / snd_spd_temp; - if (mach_conv > clb_mach) { - mach_conv = clb_mach; - } - thrust = 14750 * 2 * milthrust_inp(mach_conv, opm_alt); - cl_for_clb = (-(thrust/grs_wgt_toc) + math.sqrt(math.pow(thrust/grs_wgt_toc,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_clb < 0 ) { - cl_for_clb = (-(thrust/grs_wgt_toc) - math.sqrt(math.pow(thrust/grs_wgt_toc,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - cd_for_clb = cd0 + ind_drag_K * math.pow(cl_for_clb, 2); - sin_ang_clb = thrust/grs_wgt_toc - cd_for_clb/cl_for_clb; - if (mach_conv < clb_mach) { - vrt_spd_toc = clb_tas * sin_ang_clb * 101.2685; - } else { - var clb_tas = mach_conv * snd_spd_temp; - vrt_spd_toc = clb_tas * sin_ang_clb * 101.2685; - } - var clb_time_toc = 0; - if ((abs_alt_lmt - 10000) / (abs_alt_lmt - opm_alt) != 1) { - abs_alt_lmt = (10000 * vrt_spd_toc - opm_alt * vrt_spd_10K) / (vrt_spd_toc - vrt_spd_10K); - clb_time_toc = (abs_alt_lmt / vrt_spd_10K) * math.ln((abs_alt_lmt - 10000) / (abs_alt_lmt - opm_alt)); - } - clb_time_toc = clb_time_toc / 60; - var fuel_burned_toc = clb_time_toc * thrust * 0.623; - grs_wgt_toc = grs_wgt_10K - fuel_burned_toc; - } - rte_gone = rte_gone + (clb_time_toc * clb_tas); - ete_gone = ete_gone + clb_time_toc; - - var opm_fd_temp = crn_temp - ((opm_alt - crn_dns_alt) / 1000 * 1.98); - var opm_std_temp = 15 - 1.98 * (opm_alt/1000); - var opm_alt_prs = opm_alt - (100 * (opm_fd_temp - opm_std_temp)); - opm_alt_prs = math.round(opm_alt / 1000) * 1000; - - var grs_wgt_crs = grs_wgt_toc; - - while(rte_gone < rte_rng) { - vrt_spd_toc = -99999; - var crs_min_count = 0; - while(vrt_spd_toc < 500 and rte_gone < rte_rng) { - - var opm_alt_std_temp = 15 - 1.98 * (opm_alt / 1000); - theta = (273 + opm_alt_std_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var crs_tas = crs_ias * (1 + (opm_alt/600/100)); - mach_conv = crs_tas / snd_spd_temp; - - if (mach_conv > crs_mach) { - mach_conv = crs_mach; - } - - var crs_thr = 14750 * 2 * milthrust_inp(mach_conv, opm_alt); - var sin_ang_crs = 99999; - while(sin_ang_crs>0.008){ - crs_thr = crs_thr - 100; - cl_for_crs = (-(crs_thr/grs_wgt_crs) + math.sqrt(math.pow(crs_thr/grs_wgt_crs,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_crs < 0 ) { - cl_for_crs = (-(crs_thr/grs_wgt_crs) - math.sqrt(math.pow(crs_thr/grs_wgt_crs,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - cd_for_crs = cd0 + ind_drag_K * math.pow(cl_for_crs, 2); - sin_ang_crs = crs_thr/grs_wgt_crs - cd_for_crs/cl_for_crs; - } - var crs_fuel_rate = (crs_thr * 0.623); - var crs_fuel_brn_min = crs_fuel_rate / 60; - grs_wgt_crs = grs_wgt_crs - crs_fuel_brn_min; - - var next_opm_alt = opm_alt + (step_incm * 1000) + 2000; - - var next_std_temp = 15 - 1.98 * (next_opm_alt / 1000); - theta = (273 + next_std_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var clb_tas = clb_ias + clb_ias * (next_opm_alt/600/100); - mach_conv = clb_tas / snd_spd_temp; - if (mach_conv > clb_mach) { - mach_conv = clb_mach; - } - thrust = 14750 * 2 * milthrust_inp(mach_conv, next_opm_alt); - cl_for_clb = (-(thrust/grs_wgt_crs) + math.sqrt(math.pow(thrust/grs_wgt_crs,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_clb < 0 ) { - cl_for_clb = (-(thrust/grs_wgt_crs) - math.sqrt(math.pow(thrust/grs_wgt_crs,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - cd_for_clb = cd0 + ind_drag_K * math.pow(cl_for_clb, 2); - sin_ang_clb = thrust/grs_wgt_crs - cd_for_clb/cl_for_clb; - if (mach_conv < clb_mach) { - vrt_spd_toc = clb_tas * sin_ang_clb * 101.2685; - } else { - var clb_tas = mach_conv * snd_spd_temp; - vrt_spd_toc = clb_tas * sin_ang_clb * 101.2685; - } - crs_min_count = crs_min_count + 1; - rte_gone = rte_gone + (1/60 * crs_tas); - ete_gone = ete_gone + (1/60); - } - - if (vrt_spd_toc > 500) { - var last_opm_alt = opm_alt; - opm_alt = next_opm_alt - 2000; - - var vrt_spd_next_step = -999999; - var grs_wgt_next_step = grs_wgt_crs; - - for (i=0; i<8; i=i+1) { - std_temp = 15 - 1.98 * (opm_alt/1000); - theta = (273 + std_temp) / (273 + 15); - snd_spd_temp = 661 * math.sqrt(theta); - var clb_tas = clb_ias + clb_ias * (opm_alt/600/100); - mach_conv = clb_tas / snd_spd_temp; - if (mach_conv > clb_mach) { - mach_conv = clb_mach; - } - thrust = 14750 * 2 * milthrust_inp(mach_conv, opm_alt); - cl_for_clb = (-(thrust/grs_wgt_next_step) + math.sqrt(math.pow(thrust/grs_wgt_next_step,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_clb < 0 ) { - cl_for_clb = (-(thrust/grs_wgt_next_step) - math.sqrt(math.pow(thrust/grs_wgt_next_step,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - cd_for_clb = cd0 + ind_drag_K * math.pow(cl_for_clb, 2); - sin_ang_clb = thrust/grs_wgt_next_step - cd_for_clb/cl_for_clb; - if (mach_conv < clb_mach) { - vrt_spd_next_step = clb_tas * sin_ang_clb * 101.2685; - } else { - var clb_tas = mach_conv * snd_spd_temp; - vrt_spd_next_step = clb_tas * sin_ang_clb * 101.2685; - } - var clb_time_toc = 0; - if ((abs_alt_lmt - last_opm_alt) / (abs_alt_lmt - opm_alt) != 1) { - abs_alt_lmt = (last_opm_alt * vrt_spd_next_step - opm_alt * vrt_spd_toc) / (vrt_spd_next_step - vrt_spd_toc); - clb_time_toc = (abs_alt_lmt / vrt_spd_toc) * math.ln((abs_alt_lmt - last_opm_alt) / (abs_alt_lmt - opm_alt)); - } - clb_time_toc = clb_time_toc / 60; - var fuel_burned_toc = clb_time_toc * thrust * 0.623; - grs_wgt_next_step = grs_wgt_crs - fuel_burned_toc; - } - rte_gone = rte_gone + (clb_time_toc * clb_tas); - ete_gone = ete_gone + clb_time_toc; - grs_wgt_crs = grs_wgt_next_step; - } - } - - var grs_wgt_hold = grs_wgt_crs; - - for (hold_min=0; hold_min<=35; hold_min=hold_min+1) { - var hold_std_temp = 15 - 1.98 * (5000 / 1000); - var hold_tas = 200 * (1 + (5000/600/100)); - var hold_thr = 14750 * 2 * milthrust_inp(mach_conv, 5000); - var sin_ang_hold = 99999; - while(sin_ang_hold>0.008){ - hold_thr = hold_thr - 100; - hold_cl = (-(hold_thr/grs_wgt_hold) + math.sqrt(math.pow(hold_thr/grs_wgt_hold,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (hold_cl < 0 ) { - hold_cl = (-(hold_thr/grs_wgt_hold) - math.sqrt(math.pow(hold_thr/grs_wgt_hold,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - hold_cd = cd0 + ind_drag_K * math.pow(hold_cl, 2); - sin_ang_hold = hold_thr/grs_wgt_hold - hold_cd/hold_cl; - } - var hold_fuel_rate = (hold_thr * 0.623); - var hold_fuel_brn_min = hold_fuel_rate / 60; - grs_wgt_hold = grs_wgt_hold - hold_fuel_brn_min; - } - ete_gone = ete_gone + (35/60); - - var grs_wgt_ld = grs_wgt_hold; - ttl_fuel_prd = grs_wgt_to - grs_wgt_ld + to_fuel + ldg_fuel; - grs_wgt_to = zfw + ttl_fuel_prd; - if (grs_wgt_to > 98000) { - grs_wgt_to = 98000; - } - } - altn_fuel_prd = ttl_fuel_prd; - ete_to_altn = ete_gone; - } - - var fuel_opm_alt_prd = func() { - fuel_opm_alt_dest(); - fuel_opm_alt_altn(); - } - - var vy_finder = func(test_alt, grs_wgt){ - var crn_dns_alt = getprop("/fdm/jsbsim/atmosphere/density-altitude"); - var crn_dns_air = getprop("/environment/density-slugft3"); - var crn_temp = getprop("/environment/temperature-degc"); - var std_temp = 15 - 1.98 * (test_alt/1000); - var fd_temp = crn_temp - ((test_alt - crn_dns_alt) / 1000 * 1.98); - var theta = (273 + fd_temp) / (273 + 15); - var snd_spd_temp = 661 * math.sqrt(theta); - var oswald_efc = 0.755877483; - var ind_drag_K = 1 / (oswald_efc * math.pi * 8.654260529); - var cd0 = 0.013; - if (test_alt < 36089) { - dns_air = crn_dns_air - (0.000000046 * (test_alt - crn_dns_alt)); - } else { - dns_air = crn_dns_air - (0.000000046 * (36089 - crn_dns_alt)) - (0.000000018 * (test_alt - 36089)); - } - - var vy_mach = 0.0; - var vy_tas = 0.0; - for (i=0; i<32; i=i+1) { - var thrust = 14750 * 2 * milthrust_inp(vy_mach, test_alt); - var cl_for_vy = (-(thrust/grs_wgt) + math.sqrt(math.pow(thrust/grs_wgt,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - if (cl_for_vy < 0 ) { - cl_for_vy = (-(thrust/grs_wgt) - math.sqrt(math.pow(thrust/grs_wgt,2) + 12 * cd0 * ind_drag_K)) / (2 * ind_drag_K); - } - var cd_for_vy = cd0 + ind_drag_K * math.pow(cl_for_vy, 2); - var vy = math.sqrt(grs_wgt / (0.5 * dns_air * 1021 * cl_for_vy)); - vy_tas = vy * 0.592; - var vy_ias = vy_tas / (1 + (test_alt/600/100 + (fd_temp - std_temp)/5/100)); - vy_mach = vy_tas / snd_spd_temp; - } - return(vy_ias); - } - - var vspeed_calc = func() { - var dns_air = getprop("/environment/density-slugft3") * 515.378819; - var g_accl = getprop("/environment/gravitational-acceleration-mps2"); - var grs_wgt = getprop("/fdm/jsbsim/inertia/weight-lbs") / 2.20462262185; - var wing_area = getprop("/fdm/jsbsim/metrics/Sw-sqft") * 0.092903; - var slat_clad = getprop("/fdm/jsbsim/aero/alpha-deg") * 0.00303; - var cln_clmax = 1.617; - var flp6_clmax = 1.617 + 0.065 + 0.054 + 0.051 - 0.063 + slat_clad; - var flp16_clmax = 1.617 + 0.171 + 0.142 + 0.134 - 0.063 + slat_clad; - var flp30_clmax = 1.617 + 0.296 + 0.248 + 0.233 - 0.063 + slat_clad; - cln_vso = math.sqrt((2*grs_wgt*g_accl)/(dns_air*wing_area*cln_clmax))/0.514444444444; - flp6_vso = math.sqrt((2*grs_wgt*g_accl)/(dns_air*wing_area*flp6_clmax))/0.514444444444; - flp16_vso = math.sqrt((2*grs_wgt*g_accl)/(dns_air*wing_area*flp16_clmax))/0.514444444444; - flp30_vso = math.sqrt((2*grs_wgt*g_accl)/(dns_air*wing_area*flp30_clmax))/0.514444444444; - cln_vref = cln_vso * 1.3; - flp6_vref = flp6_vso * 1.3; - flp16_vref = flp16_vso * 1.3; - flp30_vref = flp30_vso * 1.3; - } - var vspeed_calc_timer = maketimer(3, vspeed_calc); - vspeed_calc_timer.start(); - - var dff_bearings = func(a, b) { - var dist = math.fmod(a - b + 360, 360); - if (dist > 180) { - dist = 360 - dist; - } - return dist; - } - - var read_crt_wpt = func(wpt_name, isr_num) { - var navaid_dat_path = getprop("/sim/fg-aircraft") ~ "/bd700/Navaids/WPNAVAID.txt"; - var fix_dat_path = getprop("/sim/fg-aircraft") ~ "/bd700/Navaids/WPNAVFIX.txt"; - if (io.stat(navaid_dat_path) == nil) { - var navaid_dat = " "; - } else { - var navaid_dat = io.readfile(navaid_dat_path); - } - if (io.stat(fix_dat_path) == nil) { - var fix_dat = " "; - } else { - var fix_dat = io.readfile(fix_dat_path); - } - var navaid_dat_rmn = navaid_dat; - var fix_dat_rmn = fix_dat; - var wpt_name_len = size(wpt_name); - var wpt_pos = 65532; - var wpt_vec = []; - var wpt_found_name = []; - var wpt_found_lat = []; - var wpt_found_lon = []; - var wpt_found_dst = []; - while (wpt_pos != -1) { - wpt_pos = find(wpt_name, navaid_dat_rmn); - var real_wpt_name = ""; - var w_c = 0; - while(substr(navaid_dat_rmn, wpt_pos + w_c, 1) != " "){ - real_wpt_name = real_wpt_name ~ substr(navaid_dat_rmn, wpt_pos + w_c, 1); - w_c = w_c + 1; - } - var lat_text = substr(navaid_dat_rmn, wpt_pos+9, 10); - if (substr(lat_text, 0, 2) == " "){ - var lat_num = num(substr(lat_text, 2, 8)); - } else if (substr(lat_text, 0, 1) == " ") { - var lat_num = num(substr(lat_text, 1, 9)); - } else { - var lat_num = num(lat_text); - } - var lon_text = substr(navaid_dat_rmn, wpt_pos+19, 11); - if (substr(lon_text, 0, 3) == " ") { - var lon_num = num(substr(lon_text, 3, 8)); - } else if (substr(lon_text, 0, 2) == " ") { - var lon_num = num(substr(lon_text, 2, 9)); - } else if (substr(lon_text, 0, 1) == " ") { - var lon_num = num(substr(lon_text, 1, 10)); - } else { - var lon_num = num(lon_text); - } - if (lat_num != nil and lon_num != nil and real_wpt_name == wpt_name) { - append(wpt_found_name, wpt_name); - append(wpt_found_lat, lat_num); - append(wpt_found_lon, lon_num); - } - navaid_dat_rmn = substr(navaid_dat_rmn, wpt_pos + wpt_name_len); - } - if (size(wpt_found_name) == 0) { - wpt_pos = 65532; - } - while (wpt_pos != -1) { - wpt_pos = find(wpt_name, fix_dat_rmn); - var real_wpt_name = ""; - var w_c = 0; - while(substr(fix_dat_rmn, wpt_pos + w_c, 1) != " "){ - real_wpt_name = real_wpt_name ~ substr(fix_dat_rmn, wpt_pos + w_c, 1); - w_c = w_c + 1; - } - var lat_text = substr(fix_dat_rmn, wpt_pos+29, 10); - if (substr(lat_text, 0, 2) == " ") { - var lat_num = num(substr(lat_text, 2, 8)); - } else if (substr(lat_text, 0, 1) == " ") { - var lat_num = num(substr(lat_text, 1, 9)); - } else { - var lat_num = num(lat_text); - } - var lon_text = substr(fix_dat_rmn, wpt_pos+39, 11); - if (substr(lon_text, 0, 3) == " ") { - var lon_num = num(substr(lon_text, 3, 8)); - } else if (substr(lon_text, 0, 2) == " ") { - var lon_num = num(substr(lon_text, 2, 9)); - } else if (substr(lon_text, 0, 1) == " ") { - var lon_num = num(substr(lon_text, 1, 10)); - } else { - var lon_num = num(lon_text); - } - if (lat_num != nil and lon_num != nil and real_wpt_name == wpt_name) { - append(wpt_found_name, wpt_name); - append(wpt_found_lat, lat_num); - append(wpt_found_lon, lon_num); - } - fix_dat_rmn = substr(fix_dat_rmn, wpt_pos + wpt_name_len); - } - if (size(wpt_found_name) == 0 and ((find("N", wpt_name) != -1 and find("E", wpt_name) != -1) or (find("N", wpt_name) != -1 and find("W", wpt_name) != -1) or (find("S", wpt_name) != -1 and find("E", wpt_name) != -1) or (find("S", wpt_name) != -1 and find("W", wpt_name) != -1))) { - wc = 0; - while((substr(wpt_name, 0, 1) == "N" or substr(wpt_name, 0, 1) == "S") and substr(wpt_name, wc, 1) != "E" and substr(wpt_name, wc, 1) != "W") { - wc = wc + 1; - } - if (wc <= 1) { - var inp_lat_deg = 9999; - var inp_lat_min = 0.0; - } else if (wc == 2) { - var inp_lat_deg = num(substr(wpt_name, 1, 1)) or 9999; - var inp_lat_min = 0.0; - } else if (wc == 3) { - var inp_lat_deg = num(substr(wpt_name, 1, 2)) or 9999; - var inp_lat_min = 0.0; - } else if (wc == 4) { - var inp_lat_deg = num(substr(wpt_name, 1, 2)) or 9999; - var inp_lat_min = (num(substr(wpt_name, 3, 1)) or 0) * 10; - } else if (wc >= 5) { - var inp_lat_deg = num(substr(wpt_name, 1, 2)) or 9999; - var inp_lat_min = num(substr(wpt_name, 3, wc - 3)) or 0; - } - if (size(substr(wpt_name, wc)) <=1) { - var inp_lon_deg = 9999; - var inp_lon_min = 0.0; - } else if (size(substr(wpt_name, wc)) == 2) { - var inp_lon_deg = num(substr(wpt_name, wc + 1, 1)) or 9999; - var inp_lon_min = 0; - } else if (size(substr(wpt_name, wc)) == 3) { - var inp_lon_deg = num(substr(wpt_name, wc + 1, 2)) or 9999; - var inp_lon_min = 0; - } else if (size(substr(wpt_name, wc)) == 4) { - var inp_lon_deg = num(substr(wpt_name, wc + 1, 3)) or 9999; - var inp_lon_min = 0; - } else if (size(substr(wpt_name, wc)) == 5) { - var inp_lon_deg = num(substr(wpt_name, wc + 1, 3)) or 9999; - var inp_lon_min = (num(substr(wpt_name, wc + 4, 1)) or 0) * 10; - } else if (size(substr(wpt_name, wc)) >= 6) { - var inp_lon_deg = num(substr(wpt_name, wc + 1, 3)) or 9999; - var inp_lon_min = num(substr(wpt_name, wc + 4)) or 0; - } - - if (inp_lat_deg == 90 and inp_lat_min != 0) { - scratch_pad_message = "INVALID INPUT"; - } else if (inp_lon_deg == 180 and inp_lon_min != 0) { - scratch_pad_message = "INVALID INPUT"; - } else if (inp_lat_deg <= 90 and inp_lon_deg <= 180 and inp_lat_min < 60 and inp_lon_min < 60) { - var cdn_dsp = ""; - cdn_dsp = cdn_dsp ~ substr(wpt_name, 0, 1) ~ sprintf("%02d", inp_lat_deg); - cdn_dsp = cdn_dsp ~ substr(wpt_name, wc, 1) ~ sprintf("%03d", inp_lon_deg); - if (substr(wpt_name, 0, 1) == "S") { - var inp_lat = -(inp_lat_deg + (inp_lat_min / 60)); - } else { - var inp_lat = inp_lat_deg + (inp_lat_min / 60); - } - if (substr(wpt_name, wc, 1) == "W") { - var inp_lon = -(inp_lon_deg + (inp_lon_min / 60)); - } else { - var inp_lon = inp_lon_deg + (inp_lon_min / 60); - } - var wp = createWaypoint.new(cdn_dsp, inp_lat, inp_lon); - waypoints.insert(isr_num, wp); - wpt_num = waypoints.size(); - rte_wpt_num = rte_wpt_counter(); - var wc = 0; - while(waypoints.vector[wc].lat != inp_lat or (waypoints.vector[wc].lon != inp_lon) and wc <= wpt_num) { - wc = wc + 1; - } - if (wc < isr_num){ - for (i=wc; i<(isr_num); i=i+1){ - waypoints.pop(wc); - } - } - total_page_rte = math.ceil(rte_wpt_num / 3); - total_page_prop = total_page_rte + total_page_miss + total_page_altn; - if (current_page_prop >= total_page_prop) { - current_page_prop = total_page_prop; - } - } else { - scratch_pad_message = "NOT IN DATABASE"; - } - } else if (size(wpt_found_name) == 0){ - scratch_pad_message = "NOT IN DATABASE"; - } else { - var pre_num = isr_num - 1; - var pre_lat = waypoints.vector[pre_num].lat; - var pre_lon = waypoints.vector[pre_num].lon; - var ert_R = 6371000; - var pre_lat_rad = pre_lat * D2R; - var pre_lon_rad = pre_lon * D2R; - for (i=0; i= total_page_prop) { - current_page_prop = total_page_prop; - } - } else { - save_current_page = current_page_prop; - current_page_prop = 1; - page_title_text = "WAYPOINT SELECT"; - } - } - } - - var awy_parser = func(via_to) { - var awy_dat = getprop("/sim/fg-aircraft") ~ "/bd700/Navaids/WPNAVRTE.txt"; - if (io.stat(awy_dat) == nil) { - var awy_dat_content ="I am angry!"; - } else { - var awy_dat_content = io.readfile(awy_dat); - } - var awy_dat_remain = awy_dat_content; - var awy_dat_size = size(awy_dat_content); - awy_wpt_list = []; - awy_wpt_list_lat = []; - awy_wpt_list_lon = []; - var tmp_list = []; - var tmp_list_lat = []; - var tmp_list_lon = []; - var to_id = substr(via_to, (find(".",via_to)+1)); - var awy_id_len = find(".", via_to); - var awy_id = substr(via_to, 0, awy_id_len); - wpt_num = waypoints.size(); - var from_id = waypoints.vector[(wpt_num-1)].id; - var awy_cursor = find(awy_id, awy_dat_remain); - while (awy_cursor != -1) { - var real_awy_id = ""; - if (substr(awy_dat_remain, awy_cursor - 1, 1) == chr(13) or awy_cursor == 0) { - while(substr(awy_dat_remain, awy_cursor, 1) != " "){ - real_awy_id = real_awy_id ~ substr(awy_dat_remain, awy_cursor, 1); - awy_cursor = awy_cursor + 1; - } - } - if (awy_id == real_awy_id) { - awy_cursor = awy_cursor + 5; - var tmp_wpt_id = ""; - while(substr(awy_dat_remain, awy_cursor, 1) != " ") { - tmp_wpt_id = tmp_wpt_id ~ substr(awy_dat_remain, awy_cursor, 1); - awy_cursor = awy_cursor + 1; - } - awy_cursor = awy_cursor + 1; - - var tmp_wpt_lat = ""; - while(substr(awy_dat_remain, awy_cursor, 1) != " ") { - tmp_wpt_lat = tmp_wpt_lat ~ substr(awy_dat_remain, awy_cursor, 1); - awy_cursor = awy_cursor + 1; - } - - tmp_wpt_lat = num(tmp_wpt_lat); - - awy_cursor = awy_cursor + 1; - var tmp_wpt_lon = ""; - while(substr(awy_dat_remain, awy_cursor, 1) != chr(13)) { - tmp_wpt_lon = tmp_wpt_lon ~ substr(awy_dat_remain, awy_cursor, 1); - awy_cursor = awy_cursor + 1; - } - tmp_wpt_lon = num(tmp_wpt_lon); - - append(tmp_list, tmp_wpt_id); - append(tmp_list_lat, tmp_wpt_lat); - append(tmp_list_lon, tmp_wpt_lon); - } - awy_dat_remain = substr(awy_dat_remain, awy_cursor); - awy_cursor = find(awy_id, awy_dat_remain); - } - - if (size(tmp_list) == 0) { - return 0; - } - - var from_idx = 0; - while(from_idx < size(tmp_list) and from_id != tmp_list[from_idx]) { - from_idx = from_idx + 1; - } - var to_idx = 0; - while(to_idx < size(tmp_list) and to_id != tmp_list[to_idx]){ - to_idx = to_idx + 1; - } - var awy_len = abs(from_idx - to_idx) + 1; - - if (from_id == tmp_list[from_idx] and to_id == tmp_list[to_idx] and from_idx != to_idx) { - var wc = from_idx; - while(wc <= to_idx) { - append(awy_wpt_list, tmp_list[wc]); - append(awy_wpt_list_lat, tmp_list_lat[wc]); - append(awy_wpt_list_lon, tmp_list_lon[wc]); - wc = wc + 1; - } - var wc = from_idx; - while(wc >= to_idx) { - append(awy_wpt_list, tmp_list[wc]); - append(awy_wpt_list_lat, tmp_list_lat[wc]); - append(awy_wpt_list_lon, tmp_list_lon[wc]); - wc = wc - 1; - } - - return 1; - } else { - return 0; - } - } - - var grtCircHdg = func (wpt_idx) { - var pre_lat = waypoints.vector[(wpt_idx - 1)].lat_nd * D2R; - var pre_lon = waypoints.vector[(wpt_idx - 1)].lon_nd * D2R; - var crt_lat = waypoints.vector[wpt_idx].lat_nd * D2R; - var crt_lon = waypoints.vector[wpt_idx].lon_nd * D2R; - var y_par = math.sin(crt_lon - pre_lon) * math.cos(crt_lat); - var x_par = math.cos(pre_lat) * math.sin(crt_lat) - - math.sin(pre_lat) * math.cos(crt_lat) * - math.cos(crt_lon - pre_lon); - var brng = math.atan2(y_par, x_par) * R2D; - brng = math.fmod((brng + 360), 360); - return (brng); - } - - var grtCircDist = func (wpt_idx) { - var ert_r = 6371000; - var pre_lat = waypoints.vector[(wpt_idx - 1)].lat_nd * D2R; - var pre_lon = waypoints.vector[(wpt_idx - 1)].lon_nd * D2R; - var crt_lat = waypoints.vector[wpt_idx].lat_nd * D2R; - var crt_lon = waypoints.vector[wpt_idx].lon_nd * D2R; - var delta_lat = crt_lat - pre_lat; - var delta_lon = crt_lon - pre_lon; - var a_par = math.sin(delta_lat / 2) * math.sin(delta_lat / 2) + - math.cos(pre_lat) * math.cos(crt_lat) * - math.sin(delta_lon / 2) * math.sin(delta_lon / 2); - var c_par = 2 * math.atan2(math.sqrt(a_par), math.sqrt(1 - a_par)); - var dist = ert_r * c_par / 1000 * 0.54; - return (dist); - } - - var hdg_frm_acr = func (wpt_idx) { - var pre_lat = getprop("/position/latitude-deg") or 0; - var pre_lon = getprop("/position/longitude-deg") or 0; - pre_lat = pre_lat * D2R; - pre_lon = pre_lon * D2R; - var crt_lat = waypoints.vector[wpt_idx].lat_nd * D2R; - var crt_lon = waypoints.vector[wpt_idx].lon_nd * D2R; - var y_par = math.sin(crt_lon - pre_lon) * math.cos(crt_lat); - var x_par = math.cos(pre_lat) * math.sin(crt_lat) - - math.sin(pre_lat) * math.cos(crt_lat) * - math.cos(crt_lon - pre_lon); - var brng = math.atan2(y_par, x_par) * R2D; - brng = math.fmod((brng + 360), 360); - return (brng); - } - - var dst_frm_acr = func (wpt_idx) { - var ert_r = 6371000; - var pre_lat = getprop("/position/latitude-deg") or 0; - var pre_lon = getprop("/position/longitude-deg") or 0; - pre_lat = pre_lat * D2R; - pre_lon = pre_lon * D2R; - var crt_lat = waypoints.vector[wpt_idx].lat_nd * D2R; - var crt_lon = waypoints.vector[wpt_idx].lon_nd * D2R; - var delta_lat = crt_lat - pre_lat; - var delta_lon = crt_lon - pre_lon; - var a_par = math.sin(delta_lat / 2) * math.sin(delta_lat / 2) + - math.cos(pre_lat) * math.cos(crt_lat) * - math.sin(delta_lon / 2) * math.sin(delta_lon / 2); - var c_par = 2 * math.atan2(math.sqrt(a_par), math.sqrt(1 - a_par)); - var dist = ert_r * c_par / 1000 * 0.54; - return (dist); - } - - var listSids = func(origin, rwy) { - var rwy_sid_list = []; - var sids_file = getprop("/sim/fg-aircraft") ~ "/bd700/Navaids/" ~ origin ~ ".xml"; - if (io.stat(sids_file) == nil) { - var sids_cnt = "Too young to simple, sometime naive!"; - } else { - var sids_cnt = io.readfile(sids_file); - } - var sids_cnt_rmn = sids_cnt; - var sid_name_pos = 0; - while (sid_name_pos != -1) { - sid_name_pos = find('', sid_blk); - var sid_blk_end = find("", sid_blk); - var sid_blk_size = sid_blk_end - sid_blk_bgn; - sid_blk = substr(sid_blk, sid_blk_bgn, sid_blk_size); - wpt_num = waypoints.size(); - var have_sid = 0; - for (i=(wpt_num - 1); i>=0; i=i-1) { - var proc_type = waypoints.vector[i].procedure; - if (proc_type == "sid") { - waypoints.pop(i); - } - } - - var find_cnt = 0; - for (i=(sid_blk_size-size('", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - var alt = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - alt = num(alt); - var alt_rtt = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - var spd = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - spd = num(spd); - var wpt_lat = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - wpt_lat = num(wpt_lat); - var wpt_lon = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - var wpt_lon = num(wpt_lon); - var wpt_type = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - var fly_type = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - var alt_con = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - var hdg_crs = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - var hdg_crs_value = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - var bank_limit = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - var sp_turn = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - var radl_to_intc = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - var hld_rad_or_inbd = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - var hld_rad_vlue = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - var hld_turn = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - var hld_time_dist = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - var hld_td_value = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - - var dme_to_intercept = substr(sid_wpt_blk, (find("", sid_wpt_blk)+size("")), (find("", sid_wpt_blk) - (find("", sid_wpt_blk)+size("")))); - - if (waypoints.size() >= 2) { - var first_wpt = waypoints.vector[1].id; - } else { - var first_wpt = ""; - } - - if (find_cnt == 0 and first_wpt == name) { - waypoints.pop(1); - } - var sid_wp = createWaypoint.new(name, wpt_lat, wpt_lon); - sid_wp.type = wpt_type; - sid_wp.speed = spd; - sid_wp.altitude = alt; - sid_wp.altitudeCons = alt_con; - sid_wp.altitudeRestriction = alt_rtt; - sid_wp.hdg_crs = hdg_crs; - sid_wp.hdg_crs_value = hdg_crs_value; - sid_wp.flytype = fly_type; - sid_wp.bankLimit = bank_limit; - sid_wp.radialtoIntercept = radl_to_intc; - sid_wp.DMEtoIntercept = dme_to_intercept; - sid_wp.sp_turn = sp_turn; - sid_wp.hld_rad_or_inbd = hld_rad_or_inbd; - sid_wp.hld_rad_vlue = hld_rad_vlue; - sid_wp.hld_turn = hld_turn; - sid_wp.hld_time_dist = hld_time_dist; - sid_wp.hld_td_value = hld_td_value; - sid_wp.procedure = "sid"; - waypoints.insert(1, sid_wp); - - find_cnt = find_cnt + 1; - } - } - sel_sid = sid_name; - var find_sid_bgn = '", sid_rst); - sid_end = sid_end + size(""); - var sid_blk = substr(sid_rst, 0, sid_end); - sel_sid_blk = sid_blk; - } - - var listSidTran = func () { - var sid_trn_list = []; - var sid_blk_rmn = sel_sid_blk; - while (size(sid_blk_rmn) > 0) { - sid_trn_bgn = find('', sid_blk_rmn); - var trn_nam = substr(sid_blk_rmn, 0, trn_nam_siz); - append(sid_trn_list, trn_nam); - } - } - return(sid_trn_list); - } - - var isrSidTran = func (tran_name) { - var fnd_trn_nam = ''; - var sid_trn_bgn = find(fnd_trn_nam, sel_sid_blk); - var sid_trn_rst = substr(sel_sid_blk, sid_trn_bgn); - var sid_trn_end = find("", sid_trn_rst); - sid_trn_end = sid_trn_end + size(""); - var sid_trn_blk = substr(sid_trn_rst, 0, sid_trn_end); - var trn_blk_rmn = sid_trn_blk; - var wpt_siz = waypoints.size(); - - for (i=(wpt_siz - 1); i>=0; i=i-1) { - var proc_type = waypoints.vector[i].procedure; - if (proc_type == "sidtran") { - waypoints.pop(i); - } - } - - var wpt_siz = waypoints.size(); - var found_last_sid = 0; - var last_sid = (wpt_siz - 1); - while (found_last_sid == 0 and last_sid >= 0) { - var proc_type = waypoints.vector[last_sid].procedure; - if (proc_type == "sid") { - found_last_sid = 1; - } else { - last_sid = last_sid - 1; - } - } - var while_find_counter = 0; - while (size(trn_blk_rmn) > 0) { - if (find('", trn_blk_rmn); - wpt_nam_bgn = wpt_nam_bgn + size(""); - var wpt_nam_end = find("", trn_blk_rmn); - var wpt_nam_len = wpt_nam_end - wpt_nam_bgn; - var wpt_nam = substr(trn_blk_rmn, wpt_nam_bgn, wpt_nam_len); - - var wpt_typ_bgn = find("", trn_blk_rmn); - wpt_typ_bgn = wpt_typ_bgn + size(""); - var wpt_typ_end = find("", trn_blk_rmn); - var wpt_typ_len = wpt_typ_end - wpt_typ_bgn; - var wpt_typ = substr(trn_blk_rmn, wpt_typ_bgn, wpt_typ_len); - - var wpt_lat_bgn = find("", trn_blk_rmn); - wpt_lat_bgn = wpt_lat_bgn + size(""); - var wpt_lat_end = find("", trn_blk_rmn); - var wpt_lat_len = wpt_lat_end - wpt_lat_bgn; - var wpt_lat = substr(trn_blk_rmn, wpt_lat_bgn, wpt_lat_len); - wpt_lat = num(wpt_lat); - - var wpt_lon_bgn = find("", trn_blk_rmn); - wpt_lon_bgn = wpt_lon_bgn + size(""); - var wpt_lon_end = find("", trn_blk_rmn); - var wpt_lon_len = wpt_lon_end - wpt_lon_bgn; - var wpt_lon = substr(trn_blk_rmn, wpt_lon_bgn, wpt_lon_len); - wpt_lon = num(wpt_lon); - - var wpt_spd_bgn = find("", trn_blk_rmn); - wpt_spd_bgn = wpt_spd_bgn + size(""); - var wpt_spd_end = find("", trn_blk_rmn); - var wpt_spd_len = wpt_spd_end - wpt_spd_bgn; - var wpt_spd = substr(trn_blk_rmn, wpt_spd_bgn, wpt_spd_len); - wpt_spd = num(wpt_spd); - - var wpt_alt_bgn = find("", trn_blk_rmn); - wpt_alt_bgn = wpt_alt_bgn + size(""); - var wpt_alt_end = find("", trn_blk_rmn); - var wpt_alt_len = wpt_alt_end - wpt_alt_bgn; - var wpt_alt = substr(trn_blk_rmn, wpt_alt_bgn, wpt_alt_len); - wpt_alt = num(wpt_alt); - - var wpt_altcon_bgn = find("", trn_blk_rmn); - wpt_altcon_bgn = wpt_altcon_bgn + size(""); - var wpt_altcon_end = find("", trn_blk_rmn); - var wpt_altcon_len = wpt_altcon_end - wpt_altcon_bgn; - var wpt_altcon = substr(trn_blk_rmn, wpt_altcon_bgn, wpt_altcon_len); - wpt_altcon = num(wpt_altcon); - - var wpt_altrsn_bgn = find("", trn_blk_rmn); - wpt_altrsn_bgn = wpt_altrsn_bgn + size(""); - var wpt_altrsn_end = find("", trn_blk_rmn); - var wpt_altrsn_len = wpt_altrsn_end - wpt_altrsn_bgn; - var wpt_altrsn = substr(trn_blk_rmn, wpt_altrsn_bgn, wpt_altrsn_len); - wpt_altrsn = num(wpt_altrsn); - - var wpt_flytype_bgn = find("", trn_blk_rmn); - wpt_flytype_bgn = wpt_flytype_bgn + size(""); - var wpt_flytype_end = find("", trn_blk_rmn); - var wpt_flytype_len = wpt_flytype_end - wpt_flytype_bgn; - var wpt_flytype = substr(trn_blk_rmn, wpt_flytype_bgn, wpt_flytype_len); - - var wpt_bnklmt_bgn = find("", trn_blk_rmn); - wpt_bnklmt_bgn = wpt_bnklmt_bgn + size(""); - var wpt_bnklmt_end = find("", trn_blk_rmn); - var wpt_bnklmt_len = wpt_bnklmt_end - wpt_bnklmt_bgn; - var wpt_bnklmt = substr(trn_blk_rmn, wpt_bnklmt_bgn, wpt_bnklmt_len); - wpt_bnklmt = num(wpt_bnklmt); - - var wpt_spturn_bgn = find("", trn_blk_rmn); - wpt_spturn_bgn = wpt_spturn_bgn + size(""); - var wpt_spturn_end = find("", trn_blk_rmn); - var wpt_spturn_len = wpt_spturn_end - wpt_spturn_bgn; - var wpt_spturn = substr(trn_blk_rmn, wpt_spturn_bgn, wpt_spturn_len); - - if (while_find_counter == 1) { - var wp_siz = waypoints.size(); - var last_wp_id = waypoints.vector[(wp_siz - 1)].id; - if (last_wp_id == wpt_nam) { - waypoints.pop(wp_siz - 1); - } - } - - var trn_wp_hsh = createWaypoint.new(wpt_nam, wpt_lat, wpt_lon); - trn_wp_hsh.type = wpt_typ; - trn_wp_hsh.speed = wpt_spd; - trn_wp_hsh.altitude = wpt_alt; - trn_wp_hsh.altitudeCons = wpt_altcon; - trn_wp_hsh.altitudeRestriction = wpt_altrsn; - trn_wp_hsh.flytype = wpt_flytype; - trn_wp_hsh.bankLimit = wpt_bnklmt; - trn_wp_hsh.sp_turn = wpt_spturn; - trn_wp_hsh.procedure = "sidtran"; - - var trn_wp_ins = last_sid + while_find_counter; - waypoints.insert(trn_wp_ins, trn_wp_hsh); - sel_sid_tran = tran_name; - } - } - } - - var fmzInput = func { - key_prs("A", func(){ - scratch_pad_text = scratch_pad_text ~ "A"; - }); - if (B_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-B-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "B"; - } - } - B_press_orig = getprop("/instrumentation/fmz/fmz-key-B-press"); - - if (C_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-C-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "C"; - } - } - C_press_orig = getprop("/instrumentation/fmz/fmz-key-C-press"); - - if (D_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-D-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "D"; - } - } - D_press_orig = getprop("/instrumentation/fmz/fmz-key-D-press"); - - if (E_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-E-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "E"; - } - } - E_press_orig = getprop("/instrumentation/fmz/fmz-key-E-press"); - - if (F_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-F-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "F"; - } - } - F_press_orig = getprop("/instrumentation/fmz/fmz-key-F-press"); - - if (G_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-G-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "G"; - } - } - G_press_orig = getprop("/instrumentation/fmz/fmz-key-G-press"); - - if (H_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-H-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "H"; - } - } - H_press_orig = getprop("/instrumentation/fmz/fmz-key-H-press"); - - if (I_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-I-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "I"; - } - } - I_press_orig = getprop("/instrumentation/fmz/fmz-key-I-press"); - - if (J_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-J-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "J"; - } - } - J_press_orig = getprop("/instrumentation/fmz/fmz-key-J-press"); - - if (K_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-K-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "K"; - } - } - K_press_orig = getprop("/instrumentation/fmz/fmz-key-K-press"); - - if (L_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-L-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "L"; - } - } - L_press_orig = getprop("/instrumentation/fmz/fmz-key-L-press"); - - if (M_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-M-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "M"; - } - } - M_press_orig = getprop("/instrumentation/fmz/fmz-key-M-press"); - - if (N_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-N-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "N"; - } - } - N_press_orig = getprop("/instrumentation/fmz/fmz-key-N-press"); - - if (O_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-O-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "O"; - } - } - O_press_orig = getprop("/instrumentation/fmz/fmz-key-O-press"); - - if (P_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-P-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "P"; - } - } - P_press_orig = getprop("/instrumentation/fmz/fmz-key-P-press"); - - if (Q_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-Q-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "Q"; - } - } - Q_press_orig = getprop("/instrumentation/fmz/fmz-key-Q-press"); - - if (R_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-R-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "R"; - } - } - R_press_orig = getprop("/instrumentation/fmz/fmz-key-R-press"); - - if (S_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-S-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "S"; - } - } - S_press_orig = getprop("/instrumentation/fmz/fmz-key-S-press"); - - if (T_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-T-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "T"; - } - } - T_press_orig = getprop("/instrumentation/fmz/fmz-key-T-press"); - - if (U_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-U-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "U"; - } - } - U_press_orig = getprop("/instrumentation/fmz/fmz-key-U-press"); - - if (V_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-V-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "V"; - } - } - V_press_orig = getprop("/instrumentation/fmz/fmz-key-V-press"); - - if (W_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-W-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "W"; - } - } - W_press_orig = getprop("/instrumentation/fmz/fmz-key-W-press"); - - if (X_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-X-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "X"; - } - } - X_press_orig = getprop("/instrumentation/fmz/fmz-key-X-press"); - - if (Y_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-Y-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "Y"; - } - } - Y_press_orig = getprop("/instrumentation/fmz/fmz-key-Y-press"); - - if (Z_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-Z-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "Z"; - } - } - Z_press_orig = getprop("/instrumentation/fmz/fmz-key-Z-press"); - - if (DEL_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-DEL-press"); - if (press == 1 and scratch_pad_message == "") { - scratch_pad_message = "DELETE"; - } - } - DEL_press_orig = getprop("/instrumentation/fmz/fmz-key-DEL-press"); - - if (CLR_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-CLR-press"); - if (press == 1) { - scratch_pad_message = ""; - scratch_pad_text = substr(scratch_pad_text,0,size(scratch_pad_text)-1); - } - } - CLR_press_orig = getprop("/instrumentation/fmz/fmz-key-CLR-press"); - var CLR_timer = maketimer(1, func(){ - if (CLR_press_orig == 1) { - scratch_pad_text = ""; - } - }); - CLR_timer.singleShot = 1; - CLR_timer.start(); - - if (num1_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-1-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "1"; - } - } - num1_press_orig = getprop("/instrumentation/fmz/fmz-key-1-press"); - - if (num2_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-2-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "2"; - } - } - num2_press_orig = getprop("/instrumentation/fmz/fmz-key-2-press"); - - if (num3_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-3-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "3"; - } - } - num3_press_orig = getprop("/instrumentation/fmz/fmz-key-3-press"); - - if (num4_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-4-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "4"; - } - } - num4_press_orig = getprop("/instrumentation/fmz/fmz-key-4-press"); - - if (num5_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-5-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "5"; - } - } - num5_press_orig = getprop("/instrumentation/fmz/fmz-key-5-press"); - - if (num6_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-6-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "6"; - } - } - num6_press_orig = getprop("/instrumentation/fmz/fmz-key-6-press"); - - if (num7_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-7-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "7"; - } - } - num7_press_orig = getprop("/instrumentation/fmz/fmz-key-7-press"); - - if (num8_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-8-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "8"; - } - } - num8_press_orig = getprop("/instrumentation/fmz/fmz-key-8-press"); - - if (num9_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-9-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "9"; - } - } - num9_press_orig = getprop("/instrumentation/fmz/fmz-key-9-press"); - - if (num0_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-0-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "0"; - } - } - num0_press_orig = getprop("/instrumentation/fmz/fmz-key-0-press"); - - if (DOT_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-DOT-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "."; - } - } - DOT_press_orig = getprop("/instrumentation/fmz/fmz-key-DOT-press"); - - if (DASH_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-DASH-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "-"; - } - } - DASH_press_orig = getprop("/instrumentation/fmz/fmz-key-DASH-press"); - - if (SLASH_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-SLASH-press"); - if (press == 1) { - scratch_pad_text = scratch_pad_text ~ "/"; - } - } - SLASH_press_orig = getprop("/instrumentation/fmz/fmz-key-SLASH-press"); - - if (PREV_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-PREV-press"); - if (press == 1) { - current_page_prop = current_page_prop - 1; - if (current_page_prop <= 1){ - current_page_prop = 1; - } - } - } - PREV_press_orig = getprop("/instrumentation/fmz/fmz-key-PREV-press"); - - if (NEXT_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-NEXT-press"); - if (press == 1) { - current_page_prop = current_page_prop + 1; - if (current_page_prop >= total_page_prop){ - current_page_prop = total_page_prop; - } - } - } - NEXT_press_orig = getprop("/instrumentation/fmz/fmz-key-NEXT-press"); - - if (scratch_pad_message != ""){ - scratch_pad_text = ""; - scratch_pad_display = scratch_pad_message; - } else if (scratch_pad_text != "") { - scratch_pad_display = "[ " ~ scratch_pad_text ~ " ]"; - } else { - scratch_pad_display = ""; - } - scratchPad.setText(sprintf("%s", scratch_pad_display)); - } - fmz_setlistener(fmzInput); - - var fmzClock = maketimer(1, func() { - var time_set = global_set_time; - if (time_set != time_orig) { - time_counter = 0.0; - time_1 = chr(time_set[3]); - time_10 = chr(time_set[2]); - time_100 = chr(time_set[1]); - time_1000 = chr(time_set[0]); - } else { - time_counter = time_counter + 1; - } - - if (time_counter != 0 and math.fmod(time_counter,60) == 0){ - time_1 = time_1 + 1; - } - if (time_1 >= 10) { - time_10 = time_10 + 1; - time_1 = 0; - } - if (time_10 >= 6) { - time_100 = time_100 + 1; - time_10 = 0; - } - if (time_100 >= 10) { - time_1000 = time_1000 + 1; - time_100 = 0; - } - if (time_1000 >= 2 and time_100 >= 4) { - time_1000 = 0; - time_100 = 0; - } - time_text = time_1000 ~ time_100 ~ time_10 ~ time_1 ~ "Z"; - - - time_orig = global_set_time; - - }); - fmzClock.start(); - - var to_waypoint = 0; - var from_waypoint = to_waypoint - 1; - var to_wp_dst = [0,0]; - var to_wp_dst_switch = -1; - var to_waypoint_check = maketimer(3, func() { - if (to_wp_dst_switch == -1) { - to_wp_dst[0] = dst_frm_acr(to_waypoint); - } else if (to_wp_dst_switch == 1) { - to_wp_dst[1] = dst_frm_acr(to_waypoint); - } - - if (to_wp_dst[1] > to_wp_dst[0]) { - to_waypoint = to_waypoint + 1; - from_waypoint = to_waypoint - 1; - } - - if (to_waypoint >= waypoints.size()) { - to_waypoint = waypoints.size() - 1; - } - - to_wp_dst_switch = to_wp_dst_switch * (-1); - }); - to_waypoint_check.start(); - - var fmzReadLastPos = func() { - var filename = getprop("/sim/fg-home") ~ "/Export/bd700-last-pos.xml"; - if (io.stat(filename) == nil) { - var lat_deg = getprop("/position/latitude-deg"); - var lon_deg = getprop("/position/longitude-deg"); - var file = io.open(filename, "w"); - var xml = ' - - ' ~ lat_deg ~ ' - ' ~ lon_deg ~ ' -'; - io.write(file, xml); - io.close(file); - } - var file_content = io.readfile(filename); - var last_pos_begin = find("", file_content) + 9; - var last_pos_end = find("", file_content); - var last_pos_len = last_pos_end - last_pos_begin; - var last_pos_content = substr(file_content, last_pos_begin, last_pos_len); - var last_lat_begin = find("", last_pos_content) + 5; - var last_lat_end = find("", last_pos_content); - var last_lat_len = last_lat_end - last_lat_begin; - var last_lat_deg = num(substr(last_pos_content, last_lat_begin, last_lat_len)); - var last_lon_begin = find("", last_pos_content) + 5; - var last_lon_end = find("", last_pos_content); - var last_lon_len = last_lon_end - last_lon_begin; - var last_lon_deg = num(substr(last_pos_content, last_lon_begin, last_lon_len)); - if (last_lat_deg >= 0){ - var last_north_south = "N"; - } else { - var last_north_south = "S"; - } - if (last_lon_deg >=0) { - var last_east_west = "E"; - } else { - var last_east_west = "W"; - } - var last_lat_deg_int = math.floor(abs(last_lat_deg)); - var last_lon_deg_int = math.floor(abs(last_lon_deg)); - var last_lat_min = (abs(last_lat_deg) - last_lat_deg_int) * 60; - var last_lon_min = (abs(last_lon_deg) - last_lon_deg_int) * 60; - var last_lat_deg_str = sprintf("%03d", last_lat_deg_int); - var last_lon_deg_str = sprintf("%03d", last_lon_deg_int); - var last_lat_min_str = sprintf("%2.1f", last_lat_min); - var last_lon_min_str = sprintf("%2.1f", last_lon_min); - var last_pos_str = last_north_south ~ last_lat_deg_str ~ "° " ~ last_lat_min_str ~ " " ~ last_east_west ~ last_lon_deg_str ~ "° " ~ last_lon_min_str; - return last_pos_str; - } - var last_pos_str = fmzReadLastPos(); - - var pageNavIdent = func { - if (page_title_text == "NAV IDENT") { - eachPageInit(); - pageTitle.setText(sprintf("%s", "NAV IDENT")); - pageTitleRight.setText(sprintf("%s", "")); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setColor(255,255,255,255); - totalPage.setText(sprintf("%s", "1")); - currentPage.setText(sprintf("%s", "1")); - totalPage.setColor(255,255,255,255); - currentPage.setColor(255,255,255,255); - line1Left.setText(sprintf("%s", "DATE")); - line1Left.setColor(255,255,255,255); - line1Left.setFontSize(36, 1); - line2Left.setText(sprintf("%s", set_date)); - line2Left.setColor(0,174,255,255); - line2Left.setFontSize(48, 1); - line3Left.setText(sprintf("%s", "UTC")); - line3Left.setColor(255,255,255,255); - line3Left.setFontSize(36, 1); - line4Left.setText(sprintf("%s", time_text)); - line4Left.setColor(0,174,255,255); - line4Left.setFontSize(48, 1); - line5Left.setText(sprintf("%s", "SW")); - line5Left.setColor(255,255,255,255); - line5Left.setFontSize(36, 1); - line6Left.setText(sprintf("%s", "NZ6.125")); - line6Left.setColor(0,255,0,255); - line6Left.setFontSize(48, 1); - line7Left.setText(sprintf("%s", "◀ MAINTENANCE")); - line7Left.setColor(255,255,255,255); - line7Left.setFontSize(36, 1); - line1Right.setText(sprintf("%s", "ACTIVE NDB")); - line1Right.setColor(255,255,255,255); - line1Right.setFontSize(36, 1); - line2Right.setText(sprintf("%s", "Data Cycle 2013.10")); - line2Right.setColor(0,255,0,255); - line2Right.setFontSize(48, 1); - line3Right.setText(sprintf("%s", " ")); - line4Right.setText(sprintf("%s", "Data Cycle 2013.10 ▶")); - line4Right.setColor(255,255,0,255); - line4Right.setFontSize(48, 1); - line5Right.setText(sprintf("%s", "NDB V2 . 0 4M")); - line5Right.setColor(0,255,0,255); - line5Right.setFontSize(36, 1); - line6Right.setText(sprintf("%s", "WORLD 2 − 04")); - line6Right.setColor(0,255,0,255); - line6Right.setFontSize(48, 1); - line7Right.setText(sprintf("%s", "POS INIT ▶")); - line7Right.setColor(255,255,255,255); - line7Right.setFontSize(36, 1); - line1Mid.setText(sprintf("%s", "")); - line2Mid.setText(sprintf("%s", "")); - line3Mid.setText(sprintf("%s", "")); - line4Mid.setText(sprintf("%s", "")); - line5Mid.setText(sprintf("%s", "")); - line6Mid.setText(sprintf("%s", "")); - line7Mid.setText(sprintf("%s", "")); - - if (L1_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (press) { - var day = 0; - var month = 0; - var year = 0; - var day_checked = 0; - var month_checked = 0; - var year_checked = -1; - if (size(scratch_pad_text) == 7 or size(scratch_pad_text) == 9) { - day = num(substr(scratch_pad_text,0,2)) or 0; - month = numericMonth[substr(scratch_pad_text,2,3)] or 0; - year = num(substr(scratch_pad_text,5,2)) or -1; - if (size(scratch_pad_text) == 9) - year = num(substr(scratch_pad_text,5,4)) or -1; - day_checked = day >= 1 and day <= 31; - month_checked = month >= 1 and month <= 12; - year_checked = year >=0 and year <= 9999; - } - if (day_checked and month_checked and year_checked) { - set_date = scratch_pad_text; - scratch_pad_text = ""; - } else { - scratch_pad_message = "INVALID INPUT"; - } - } - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - - if (L2_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (press) { - var min_checked = 0; - var hour_checked = 0; - var zulu = 0; - if (size(scratch_pad_text) == 5) { - var hour = num(substr(scratch_pad_text,0,2)) or -1; - var min = num(substr(scratch_pad_text,2,2)) or -1; - zulu = (chr(scratch_pad_text[4]) == "Z"); - hour_checked = hour >= 0 and hour < 24; - min_checked = min >= 0 and min < 60; - } - if (zulu and hour_checked and min_checked) { - global_set_time = scratch_pad_text; - scratch_pad_text = ""; - } else { - scratch_pad_message = "INVALID INPUT"; - } - } - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - if (R4_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-R4-press"); - if (press) { - page_title_text = "POSITION INIT"; - } - } - R4_press_orig = getprop("/instrumentation/fmz/fmz-key-R4-press"); - } - } - fmz_setlistener(pageNavIdent); - var pageNavIdent_timer = maketimer(1, pageNavIdent); - pageNavIdent_timer.start(); - - var pagePositionInit = func { - if (page_title_text == "POSITION INIT") { - eachPageInit(); - pageTitle.setText(sprintf("%s", "POSITION INIT")); - pageTitleRight.setText(sprintf("%s", "")); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setColor(255,255,255,255); - totalPage.setText(sprintf("%s", "1")); - currentPage.setText(sprintf("%s", "1")); - totalPage.setColor(255,255,255,255); - currentPage.setColor(255,255,255,255); - var lat_deg = getprop("/position/latitude-deg"); - var lon_deg = getprop("/position/longitude-deg"); - if (lat_deg >= 0){ - var north_south = "N"; - } else { - var north_south = "S"; - } - if (lon_deg >=0) { - var east_west = "E"; - } else { - var east_west = "W"; - } - if (airportinfo().lat >= 0){ - var apt_north_south = "N"; - } else { - var apt_north_south = "S"; - } - if (airportinfo().lon >=0) { - var apt_east_west = "E"; - } else { - var apt_east_west = "W"; - } - var lat_deg_int = math.floor(abs(lat_deg)); - var lon_deg_int = math.floor(abs(lon_deg)); - var apt_lat_deg_int = math.floor(abs(airportinfo().lat)); - var apt_lon_deg_int = math.floor(abs(airportinfo().lon)); - var lat_min = (abs(lat_deg) - lat_deg_int) * 60; - var lon_min = (abs(lon_deg) - lon_deg_int) * 60; - var apt_lat_min = (abs(airportinfo().lat) - apt_lat_deg_int) * 60; - var apt_lon_min = (abs(airportinfo().lon) - apt_lon_deg_int) * 60; - var lat_deg_str = sprintf("%03d", lat_deg_int); - var lon_deg_str = sprintf("%03d", lon_deg_int); - var lat_min_str = sprintf("%2.1f", lat_min); - var lon_min_str = sprintf("%2.1f", lon_min); - var apt_lat_deg_str = sprintf("%03d", apt_lat_deg_int); - var apt_lon_deg_str = sprintf("%03d", apt_lon_deg_int); - var apt_lat_min_str = sprintf("%2.1f", apt_lat_min); - var apt_lon_min_str = sprintf("%2.1f", apt_lon_min); - var pos_str = north_south ~ lat_deg_str ~ "° " ~ lat_min_str ~ " " ~ east_west ~ lon_deg_str ~ "° " ~ lon_min_str; - var apt_pos_str = apt_north_south ~ apt_lat_deg_str ~ "° " ~ apt_lat_min_str ~ " " ~ apt_east_west ~ apt_lon_deg_str ~ "° " ~ apt_lon_min_str; - line1Left.setText(sprintf("%s", "LAST POS")); - line2Left.setText(sprintf("%s", last_pos_str)); - line3Left.setText(sprintf("%s", airportinfo().id)); - line4Left.setText(sprintf("%s", apt_pos_str)); - line5Left.setText(sprintf("%s", "GPS 1 POS")); - line6Left.setText(sprintf("%s", pos_str)); - line7Left.setText(sprintf("%s", "◀ POS SENSORS")); - line1Left.setColor(255,255,255,255); - line2Left.setColor(0,255,0,255); - line3Left.setColor(0,255,0,255); - line4Left.setColor(0,255,0,255); - line5Left.setColor(255,255,255,255); - line6Left.setColor(0,255,0,255); - - if (pos_init_loaded == "LAST POS") { - line1Right.setText(sprintf("%s", "(LOADED) ")); - } else { - line1Right.setText(sprintf("%s", " ")); - } - - line2Right.setText(sprintf("%s", "LOAD▶")); - - if (pos_init_loaded == "REF WPT") { - line3Right.setText(sprintf("%s", "(LOADED) ")); - } else { - line3Right.setText(sprintf("%s", " ")); - } - - line4Right.setText(sprintf("%s", "LOAD▶")); - - if (pos_init_loaded == "GPS POS") { - line5Right.setText(sprintf("%s", "(LOADED) ")); - } else { - line5Right.setText(sprintf("%s", " ")); - } - - line6Right.setText(sprintf("%s", "LOAD▶")); - if (pos_init_loaded != "") { - line7Right.setText(sprintf("%s", "FLT PLAN ▶")); - } else { - line7Right.setText(sprintf("%s", "")); - } - line2Right.setColor(255,255,255,255); - line4Right.setColor(255,255,255,255); - line5Right.setColor(255,255,255,255); - line6Right.setColor(255,255,255,255); - line7Right.setColor(255,255,255,255); - line1Mid.setText(sprintf("%s", " ")); - line2Mid.setText(sprintf("%s", " ")); - line3Mid.setText(sprintf("%s", "REF WPT ")); - line4Mid.setText(sprintf("%s", " ")); - line5Mid.setText(sprintf("%s", " ")); - line6Mid.setText(sprintf("%s", " ")); - line7Mid.setText(sprintf("%s", " ")); - line3Mid.setColor(255,255,255,255); - - if (R1_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-R1-press"); - if (press) { - pos_init_loaded = "LAST POS"; - } - } - R1_press_orig = getprop("/instrumentation/fmz/fmz-key-R1-press"); - - if (R2_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-R2-press"); - if (press) { - pos_init_loaded = "REF WPT"; - } - } - R2_press_orig = getprop("/instrumentation/fmz/fmz-key-R2-press"); - - if (R3_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-R3-press"); - if (press) { - pos_init_loaded = "GPS POS"; - } - } - R3_press_orig = getprop("/instrumentation/fmz/fmz-key-R3-press"); - - if (R4_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-R4-press"); - if (press) { - if (pos_init_loaded !="") { - page_title_text = "ACTIVE FLT PLAN"; - } else { - scratch_pad_message = "NO INITIAL POSITION LOADED"; - } - } - } - R4_press_orig = getprop("/instrumentation/fmz/fmz-key-R4-press"); - } - } - fmz_setlistener(pagePositionInit); - var pagePositionInit_timer = maketimer(3, pagePositionInit); - pagePositionInit_timer.start(); - - var rte_wpt_counter = func () { - var rte_wpt_num = 0; - wpt_num = waypoints.size(); - for (i=0; i= 1) { - total_page_rte = math.floor((rte_wpt_num + 3) / 3); - } - total_page_prop = total_page_rte + total_page_miss + total_page_altn; - if (current_page_prop >= total_page_prop){ - current_page_prop = total_page_prop; - } - totalPage.setText(sprintf("%s", total_page_prop)); - currentPage.setText(sprintf("%s", current_page_prop)); - - if (current_page_prop <= total_page_rte) { - if (dest_airport == "") { - pageTitle.setText(sprintf("%s", "ACTIVE FLT PLAN")); - pageTitleRight.setText(sprintf("%s", "")); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setColor(255,255,255,255); - line4Right.setText(sprintf("%s", "-----")); - line4Right.setColor(0,174,255,255); - } else { - pageTitle.setText(sprintf("%s", origin_airport ~ "-" ~ dest_airport)); - pageTitleRight.setText(sprintf("%s", "FPL ")); - pageTitle.setColor(255,255,0,255); - pageTitleRight.setColor(255,255,255,255); - } - } - - if (is_active) { - line7Left.setText(sprintf("%s", "◀ DEPARTURE")); - line7Left.setColor(255,255,255,255); - line7Right.setText(sprintf("%s", "PERF INIT ▶")); - line7Right.setColor(255,255,255,255); - } else { - line7Left.setText(sprintf("%s", "◀ FPL LIST")); - line7Left.setColor(255,255,255,255); - line7Right.setText(sprintf("%s", "FPL SEL ▶")); - line7Right.setColor(255,255,255,255); - } - line7Mid.setText(sprintf("%s", "")); - line7Mid.setColor(255,255,255,255); - - if (current_page_prop == 1 and rte_wpt_num <= 1) { - - line1Left.setText(sprintf("%s", "ORIGIN")); - line1Left.setColor(255,255,255,255); - line1Mid.setText(sprintf("%s", "DIST/ETE")); - line1Mid.setColor(255,255,255,255); - line1Right.setText(sprintf("%s", spd_rule)); - line1Right.setColor(255,255,255,255); - line2Left.setText(sprintf("%s", origin_airport)); - line2Left.setColor(255,255,0,255); - line2Mid.setText(sprintf("%s", "")); - line2Mid.setColor(255,255,255,255); - line2Right.setText(sprintf("%s", "")); - line2Right.setColor(255,255,255,255); - - if (waypoints.vector[(waypoints.size()-1)].id == dest_airport) { - line3Left.setText(sprintf("%s", "")); - line3Left.setColor(255,255,255,255); - line4Left.setText(sprintf("%s", "")); - line4Left.setColor(0,174,255,255); - } else { - line3Left.setText(sprintf("%s", "VIA TO")); - line3Left.setColor(255,255,255,255); - line4Left.setText(sprintf("%s", "-----")); - line4Left.setColor(0,174,255,255); - } - - line3Mid.setText(sprintf("%s", "")); - line3Mid.setColor(255,255,255,255); - line3Right.setText(sprintf("%s", "DEST")); - line3Right.setColor(255,255,255,255); - line4Mid.setText(sprintf("%s", "")); - line4Mid.setColor(255,255,255,255); - if (dest_airport == ""){ - line4Right.setText(sprintf("%s", "-----")); - line4Right.setColor(0,174,255,255); - } else { - line4Right.setText(sprintf("%s", dest_airport)); - line4Right.setColor(0,255,0,255); - } - line5Left.setText(sprintf("%s", "")); - line5Mid.setText(sprintf("%s", "RECALL OR CREATE")); - line5Mid.setColor(255,255,255,255); - line5Right.setText(sprintf("%s", "")); - line5Right.setColor(255,255,255,255); - line6Left.setText(sprintf("%s", "")); - line6Mid.setText(sprintf("%s", "FPL NAMED")); - line6Mid.setColor(255,255,255,255); - line6Right.setText(sprintf("%s", "-------")); - line6Right.setColor(255,255,0,255); - - if (R2_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-R2-press"); - if (press == 1) { - var dest_airport_tmp = scratch_pad_text; - var chck_dest = findAirportsByICAO(dest_airport_tmp); - if (size(chck_dest) != 1) { - scratch_pad_message = "NOT IN DATABASE"; - dest_airport_tmp = ""; - } else if (chck_dest[0].id != dest_airport_tmp) { - scratch_pad_message = "NOT IN DATABASE"; - dest_airport_tmp = ""; - } else { - dest_airport = dest_airport_tmp; - } - scratch_pad_text = ""; - } - } - R2_press_orig = getprop("/instrumentation/fmz/fmz-key-R2-press"); - - if (L2_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (press == 1) { - if (dest_airport != ""){ - if (scratch_pad_text == dest_airport) { - var dest_apt_hash = createWaypoint.new(dest_airport, airportinfo(dest_airport).lat, airportinfo(dest_airport).lon); - dest_apt_hash.altitude = airportinfo(dest_airport).elevation; - waypoints.insert(rte_wpt_counter(),dest_apt_hash); - } else { - read_crt_wpt(scratch_pad_text, 1); - } - } else { - scratch_pad_message = "INVALID INPUT"; - } - - scratch_pad_text = ""; - } - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - } - - if (current_page_prop == 1 and rte_wpt_num == 2){ - - line1Left.setText(sprintf("%s", "ORIGIN")); - line1Left.setColor(255,255,255,255); - line1Mid.setText(sprintf("%s", "DIST/ETE")); - line1Mid.setColor(255,255,255,255); - line1Right.setText(sprintf("%s", spd_rule)); - line1Right.setColor(255,255,255,255); - line2Left.setText(sprintf("%s", origin_airport)); - line2Left.setColor(255,255,0,255); - line2Mid.setText(sprintf("%s", "")); - line2Mid.setColor(255,255,255,255); - line2Right.setText(sprintf("%s", "")); - line2Right.setColor(255,255,255,255); - var hdg = grtCircHdg(1); - line3Left.setText(sprintf("%03.0f", hdg) ~ "°"); - line3Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(1); - line3Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line3Mid.setColor(0,255,0,255); - line3Right.setText(sprintf("%s", "")); - line3Right.setColor(255,255,255,255); - line4Left.setText(sprintf("%s", waypoints.vector[1].id)); - line4Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line4Mid.setText(sprintf("%s", ete_str)); - line4Mid.setColor(0,255,0,255); - line4Right.setText(sprintf("%s", "-----")); - line4Right.setColor(0,174,255,255); - - if (waypoints.vector[(waypoints.size()-1)].id == dest_airport) { - line5Left.setText(sprintf("%s", "")); - line5Left.setColor(255,255,255,255); - line6Left.setText(sprintf("%s", "")); - line6Left.setColor(0,174,255,255); - } else { - line5Left.setText(sprintf("%s", "VIA TO")); - line5Left.setColor(255,255,255,255); - line6Left.setText(sprintf("%s", "-----")); - line6Left.setColor(0,174,255,255); - } - - line5Right.setText(sprintf("%s", "DEST")); - line5Right.setColor(255,255,255,255); - line5Mid.setText(sprintf("%s", "")); - line5Mid.setColor(255,255,255,255); - line6Mid.setText(sprintf("%s", "")); - line6Mid.setColor(255,255,255,255); - line6Right.setText(sprintf("%s", dest_airport)); - line6Right.setColor(0,255,0,255); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1 and scratch_pad_text != "") { - - read_crt_wpt(scratch_pad_text, 1); - scratch_pad_text = ""; - - } else if (L2_press_orig == 0 and press == 1 and scratch_pad_message == "DELETE") { - waypoints.pop(1); - scratch_pad_message = ""; - } else if (L2_press_orig == 0 and press == 1){ - scratch_pad_message = "INVALID INPUT"; - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (R3_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-R3-press"); - if (press == 1) { - var dest_airport_tmp = scratch_pad_text; - var chck_dest = findAirportsByICAO(dest_airport_tmp); - if (size(chck_dest) != 1) { - scratch_pad_message = "NOT IN DATABASE"; - dest_airport_tmp = ""; - } else if (chck_dest[0].id != dest_airport_tmp) { - scratch_pad_message = "NOT IN DATABASE"; - dest_airport_tmp = ""; - } else { - dest_airport = dest_airport_tmp; - } - scratch_pad_text = ""; - } - } - R3_press_orig = getprop("/instrumentation/fmz/fmz-key-R3-press"); - - if (L3_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (press == 1) { - var has_dot = find(".", scratch_pad_text)!=-1; - var long_enough = size(scratch_pad_text) >=5; - if (has_dot and long_enough) { - var is_awy = awy_parser(scratch_pad_text); - } else { - var is_awy = 0; - } - if (rte_wpt_num == 2 and is_awy == 1) { - for (i=size(awy_wpt_list)-1;i>0;i=i-1) { - var awy_wpt = createWaypoint.new(awy_wpt_list[i], awy_wpt_list_lat[i], awy_wpt_list_lon[i]); - waypoints.insert(2, awy_wpt); - } - scratch_pad_text = ""; - } else if (rte_wpt_num == 2 and is_awy ==0) { - if (scratch_pad_text == dest_airport) { - var dest_apt_hash = createWaypoint.new(dest_airport, airportinfo(dest_airport).lat, airportinfo(dest_airport).lon); - dest_apt_hash.altitude = airportinfo(dest_airport).elevation; - waypoints.insert(rte_wpt_counter(), dest_apt_hash); - } else { - read_crt_wpt(scratch_pad_text, 2); - } - scratch_pad_text = ""; - } else { - scratch_pad_message = "INVALID INPUT"; - } - } - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - } - if (current_page_prop == 1 and rte_wpt_num >= 3){ - - line1Left.setText(sprintf("%s", "ORIGIN")); - line1Left.setColor(255,255,255,255); - line1Mid.setText(sprintf("%s", "DIST/ETE")); - line1Mid.setColor(255,255,255,255); - line1Right.setText(sprintf("%s", spd_rule)); - line1Right.setColor(255,255,255,255); - line2Left.setText(sprintf("%s", origin_airport)); - line2Left.setColor(255,255,0,255); - line2Mid.setText(sprintf("%s", "")); - line2Mid.setColor(255,255,255,255); - line2Right.setText(sprintf("%s", "")); - line2Right.setColor(255,255,255,255); - var hdg = grtCircHdg(1); - line3Left.setText(sprintf("%03.0f", hdg) ~ "°"); - line3Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(1); - line3Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line3Mid.setColor(0,255,0,255); - line3Right.setText(sprintf("%s", "")); - line3Right.setColor(255,255,255,255); - line4Left.setText(sprintf("%s", waypoints.vector[1].id)); - line4Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line4Mid.setText(sprintf("%s", ete_str)); - line4Mid.setColor(0,255,0,255); - line4Right.setText(sprintf("%s", "")); - line4Right.setColor(255,255,255,255); - var hdg = grtCircHdg(2); - line5Left.setText(sprintf("%03.0f", hdg) ~ "°"); - line5Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(2); - line5Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line5Mid.setColor(0,255,0,255); - line5Right.setText(sprintf("%s", "")); - line5Right.setColor(255,255,255,255); - line6Left.setText(sprintf("%s", waypoints.vector[2].id)); - line6Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line6Mid.setText(sprintf("%s", ete_str)); - line6Mid.setColor(0,255,0,255); - line6Right.setText(sprintf("%s", "-----")); - line6Right.setColor(0,174,255,255); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1 and scratch_pad_text != "") { - - read_crt_wpt(scratch_pad_text, 1); - scratch_pad_text = ""; - - } else if (L2_press_orig == 0 and press == 1 and scratch_pad_message == "DELETE") { - waypoints.pop(1); - scratch_pad_message = ""; - } else if (L2_press_orig == 0 and press == 1) { - scratch_pad_message = "INVALID INPUT"; - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1 and scratch_pad_text != "") { - - read_crt_wpt(scratch_pad_text, 2); - scratch_pad_text = ""; - - } else if (L3_press_orig == 0 and press == 1 and scratch_pad_message == "DELETE") { - waypoints.pop(2); - scratch_pad_message = ""; - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - } - - if (current_page_prop >= 2 and current_page_prop == total_page_rte and math.fmod(rte_wpt_num,3) == 0){ - - if (waypoints.vector[(waypoints.size()-1)].id == dest_airport) { - line1Left.setText(sprintf("%s", "")); - line1Left.setColor(255,255,255,255); - line2Left.setText(sprintf("%s", "")); - line2Left.setColor(0,174,255,255); - } else { - line1Left.setText(sprintf("%s", "VIA TO")); - line1Left.setColor(255,255,255,255); - line2Left.setText(sprintf("%s", "-----")); - line2Left.setColor(0,174,255,255); - } - line1Mid.setText(sprintf("%s", "")); - line1Mid.setColor(255,255,255,255); - line1Right.setText(sprintf("%s", "DEST")); - line1Right.setColor(255,255,255,255); - line2Mid.setText(sprintf("%s", "")); - line2Mid.setColor(255,255,255,255); - line2Right.setText(sprintf("%s", dest_airport)); - line2Right.setColor(0,255,0,255); - line3Left.setText(sprintf("%s", "")); - line3Left.setColor(255,255,255,255); - line3Mid.setText(sprintf("%s", "")); - line3Mid.setColor(255,255,255,255); - line3Right.setText(sprintf("%s", "")); - line3Right.setColor(255,255,255,255); - line4Left.setText(sprintf("%s", "")); - line4Left.setColor(255,255,255,255); - line4Mid.setText(sprintf("%s", "")); - line4Mid.setColor(255,255,255,255); - line4Right.setText(sprintf("%s", "")); - line4Right.setColor(255,255,255,255); - line5Left.setText(sprintf("%s", "")); - line5Left.setColor(255,255,255,255); - line5Mid.setText(sprintf("%s", "")); - line5Mid.setColor(255,255,255,255); - line5Right.setText(sprintf("%s", "")); - line5Right.setColor(255,255,255,255); - line6Left.setText(sprintf("%s", "")); - line6Left.setColor(255,255,255,255); - line6Mid.setText(sprintf("%s", "")); - line6Mid.setColor(255,255,255,255); - line6Right.setText(sprintf("%s", "")); - line6Right.setColor(255,255,255,255); - - if (L1_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (press == 1) { - if (dest_airport != ""){ - var has_dot = find(".", scratch_pad_text)!=-1; - var long_enough = size(scratch_pad_text) >=5; - if (has_dot and long_enough) { - var is_awy = awy_parser(scratch_pad_text); - } else { - var is_awy = 0; - } - if (is_awy == 1) { - for (i=size(awy_wpt_list)-1;i>0;i=i-1) { - var awy_wpt = createWaypoint.new(awy_wpt_list[i], awy_wpt_list_lat[i], awy_wpt_list_lon[i]); - waypoints.insert((current_page_prop*3-3), awy_wpt); - } - scratch_pad_text = ""; - } else { - if (scratch_pad_text == dest_airport) { - var dest_apt_hash = createWaypoint.new(dest_airport,airportinfo(dest_airport).lat, airportinfo(dest_airport).lon); - dest_apt_hash.altitude = airportinfo(dest_airport).elevation; - waypoints.insert(rte_wpt_counter(), dest_apt_hash); - } else { - read_crt_wpt(scratch_pad_text, (current_page_prop*3-3)); - } - } - } else { - scratch_pad_message = "INVALID INPUT"; - } - - scratch_pad_text = ""; - } - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - } - - if (current_page_prop >= 2 and current_page_prop == total_page_rte and math.fmod(rte_wpt_num,3) == 1){ - - var hdg = grtCircHdg(current_page_prop*3-3); - line1Left.setText(sprintf("%03.0f", hdg) ~ "°"); - line1Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(current_page_prop*3-3); - line1Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line1Mid.setColor(0,255,0,255); - line1Right.setText(sprintf("%s", "")); - line1Right.setColor(255,255,255,255); - var wpt_id = waypoints.vector[(current_page_prop*3-3)].id; - line2Left.setText(sprintf("%s", wpt_id)); - line2Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line2Mid.setText(sprintf("%s", ete_str)); - line2Mid.setColor(0,255,0,255); - line2Right.setText(sprintf("%s","")); - line2Right.setColor(255,255,255,255); - - if (waypoints.vector[(waypoints.size()-1)].id == dest_airport) { - line3Left.setText(sprintf("%s", "")); - line3Left.setColor(255,255,255,255); - line4Left.setText(sprintf("%s", "")); - line4Left.setColor(0,174,255,255); - } else { - line3Left.setText(sprintf("%s", "VIA TO")); - line3Left.setColor(255,255,255,255); - line4Left.setText(sprintf("%s", "-----")); - line4Left.setColor(0,174,255,255); - } - line3Mid.setText(sprintf("%s", "")); - line3Mid.setColor(255,255,255,255); - line3Right.setText(sprintf("%s", "DEST")); - line3Right.setColor(255,255,255,255); - line4Mid.setText(sprintf("%s", "")); - line4Mid.setColor(255,255,255,255); - line4Right.setText(sprintf("%s", dest_airport)); - line4Right.setColor(0,255,0,255); - line5Left.setText(sprintf("%s", "")); - line5Left.setColor(255,255,255,255); - line5Mid.setText(sprintf("%s", "")); - line5Mid.setColor(255,255,255,255); - line5Right.setText(sprintf("%s", "")); - line5Right.setColor(255,255,255,255); - line6Left.setText(sprintf("%s", "")); - line6Left.setColor(255,255,255,255); - line6Mid.setText(sprintf("%s", "")); - line6Mid.setColor(255,255,255,255); - line6Right.setText(sprintf("%s", "")); - line6Right.setColor(255,255,255,255); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1 and scratch_pad_text != ""){ - read_crt_wpt(scratch_pad_text, (current_page_prop*3-3)); - scratch_pad_text = ""; - } else if (L1_press_orig == 0 and press == 1 and scratch_pad_message == "DELETE") { - waypoints.pop((current_page_prop*3-3)); - scratch_pad_message = ""; - } else if (L1_press_orig == 0 and press == 1) { - scratch_pad_message = "INVALID INPUT"; - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L2_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (press == 1) { - if (dest_airport != ""){ - var has_dot = find(".", scratch_pad_text)!=-1; - var long_enough = size(scratch_pad_text) >=5; - if (has_dot and long_enough) { - var is_awy = awy_parser(scratch_pad_text); - } else { - var is_awy = 0; - } - if (is_awy == 1) { - for (i=size(awy_wpt_list)-1;i>0;i=i-1) { - var awy_wpt = createWaypoint.new(awy_wpt_list[i], awy_wpt_list_lat[i], awy_wpt_list_lon[i]); - waypoints.insert((current_page_prop*3-2), awy_wpt); - } - scratch_pad_text = ""; - } else { - if (scratch_pad_text == dest_airport) { - var dest_apt_hash = createWaypoint.new(dest_airport, airportinfo(dest_airport).lat, airportinfo(dest_airport).lon); - dest_apt_hash.altitude = airportinfo(dest_airport).elevation; - waypoints.insert(rte_wpt_counter(), dest_apt_hash); - } else { - read_crt_wpt(scratch_pad_text, (current_page_prop*3-2)); - } - scratch_pad_text = ""; - } - } else { - scratch_pad_message = "INVALID INPUT"; - } - - scratch_pad_text = ""; - } - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - } - - if (current_page_prop >= 2 and current_page_prop == total_page_rte and math.fmod(rte_wpt_num,3) == 2){ - - var hdg = grtCircHdg(current_page_prop*3-3); - line1Left.setText(sprintf("%03.0f", hdg) ~ "°"); - line1Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(current_page_prop*3-3); - line1Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line1Mid.setColor(0,255,0,255); - line1Right.setText(sprintf("%s", "")); - line1Right.setColor(255,255,255,255); - var wpt_id = waypoints.vector[(current_page_prop*3-3)].id; - line2Left.setText(sprintf("%s", wpt_id)); - line2Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line2Mid.setText(sprintf("%s", ete_str)); - line2Mid.setColor(0,255,0,255); - line2Right.setText(sprintf("%s","")); - line2Right.setColor(255,255,255,255); - var hdg = grtCircHdg(current_page_prop*3-2); - line3Left.setText(sprintf("%03.0f", hdg) ~ "°"); - line3Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(current_page_prop*3-2); - line3Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line3Mid.setColor(0,255,0,255); - line3Right.setText(sprintf("%s", "")); - line3Right.setColor(255,255,255,255); - var wpt_id = waypoints.vector[(current_page_prop*3-2)].id; - line4Left.setText(sprintf("%s", wpt_id)); - line4Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line4Mid.setText(sprintf("%s", ete_str)); - line4Mid.setColor(0,255,0,255); - line4Right.setText(sprintf("%s", "")); - line4Right.setColor(255,255,255,255); - - if (waypoints.vector[(waypoints.size()-1)].id == dest_airport) { - line5Left.setText(sprintf("%s", "")); - line5Left.setColor(255,255,255,255); - line6Left.setText(sprintf("%s", "")); - line6Left.setColor(0,174,255,255); - } else { - line5Left.setText(sprintf("%s", "VIA TO")); - line5Left.setColor(255,255,255,255); - line6Left.setText(sprintf("%s", "-----")); - line6Left.setColor(0,174,255,255); - } - line5Mid.setText(sprintf("%s", "")); - line5Mid.setColor(255,255,255,255); - line5Right.setText(sprintf("%s", "DEST")); - line5Right.setColor(255,255,255,255); - line6Mid.setText(sprintf("%s", "")); - line6Mid.setColor(255,255,255,255); - line6Right.setText(sprintf("%s", dest_airport)); - line6Right.setColor(0,255,0,255); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1 and scratch_pad_text != ""){ - read_crt_wpt(scratch_pad_text, (current_page_prop*3-3)); - scratch_pad_text = ""; - } else if (L1_press_orig == 0 and press == 1 and scratch_pad_message == "DELETE") { - waypoints.pop(current_page_prop*3-3); - scratch_pad_message = ""; - } else if (L1_press_orig == 0 and press == 1) { - scratch_pad_message = "INVALID INPUT"; - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1 and scratch_pad_text != "") { - read_crt_wpt(scratch_pad_text, (current_page_prop*3-2)); - scratch_pad_text = ""; - - } else if (L2_press_orig == 0 and press == 1 and scratch_pad_message == "DELETE") { - waypoints.pop(current_page_prop*3-2); - scratch_pad_message = ""; - } else if (L2_press_orig == 0 and press == 1) { - scratch_pad_message = "INVALID INPUT"; - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L3_press_orig == 0) { - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (press == 1) { - if (dest_airport != ""){ - var has_dot = find(".", scratch_pad_text)!=-1; - var long_enough = size(scratch_pad_text) >=5; - if (has_dot and long_enough) { - var is_awy = awy_parser(scratch_pad_text); - } else { - var is_awy = 0; - } - if (is_awy == 1) { - for (i=size(awy_wpt_list)-1;i>0;i=i-1) { - var awy_wpt = createWaypoint.new(awy_wpt_list[i], awy_wpt_list_lat[i], awy_wpt_list_lon[i]); - waypoints.insert((current_page_prop*3-1), awy_wpt); - } - scratch_pad_text = ""; - } else { - if (scratch_pad_text == dest_airport) { - var dest_apt_hash = createWaypoint.new(dest_airport, airportinfo(dest_airport).lat, airportinfo(dest_airport).lon); - dest_apt_hash.altitude = airportinfo(dest_airport).elevation; - waypoints.insert(rte_wpt_counter(), dest_apt_hash); - } else { - read_crt_wpt(scratch_pad_text, (current_page_prop*3-1)); - } - scratch_pad_text = ""; - } - } else { - scratch_pad_message = "INVALID INPUT"; - } - - scratch_pad_text = ""; - } - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - } - - if (current_page_prop >= 2 and current_page_prop < total_page_rte){ - - var hdg = grtCircHdg(current_page_prop*3-3); - line1Left.setText(sprintf("%03.0f", hdg) ~ "°"); - line1Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(current_page_prop*3-3); - line1Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line1Mid.setColor(0,255,0,255); - line1Right.setText(sprintf("%s", "")); - line1Right.setColor(255,255,255,255); - var wpt_id = waypoints.vector[(current_page_prop*3-3)].id; - line2Left.setText(sprintf("%s", wpt_id)); - line2Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line2Mid.setText(sprintf("%s", ete_str)); - line2Mid.setColor(0,255,0,255); - line2Right.setText(sprintf("%s","")); - line2Right.setColor(255,255,255,255); - var hdg = grtCircHdg(current_page_prop*3-2); - line3Left.setText(sprintf("%03.0f", hdg) ~ "°"); - line3Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(current_page_prop*3-2); - line3Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line3Mid.setColor(0,255,0,255); - line3Right.setText(sprintf("%s", "")); - line3Right.setColor(255,255,255,255); - var wpt_id = waypoints.vector[(current_page_prop*3-2)].id; - line4Left.setText(sprintf("%s", wpt_id)); - line4Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line4Mid.setText(sprintf("%s", ete_str)); - line4Mid.setColor(0,255,0,255); - line4Right.setText(sprintf("%s", "")); - line4Right.setColor(255,255,255,255); - var hdg = grtCircHdg(current_page_prop*3-1); - line5Left.setText(sprintf("%03.0f", hdg) ~ "°"); - line5Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(current_page_prop*3-1); - line5Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line5Mid.setColor(0,255,0,255); - line5Right.setText(sprintf("%s", "")); - line5Right.setColor(255,255,255,255); - var wpt_id = waypoints.vector[(current_page_prop*3-1)].id; - line6Left.setText(sprintf("%s", wpt_id)); - line6Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line6Mid.setText(sprintf("%s", ete_str)); - line6Mid.setColor(0,255,0,255); - line6Right.setText(sprintf("%s", "-----")); - line6Right.setColor(0,174,255,255); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1 and scratch_pad_text != ""){ - read_crt_wpt(scratch_pad_text, (current_page_prop*3-3)); - scratch_pad_text = ""; - } else if (L1_press_orig == 0 and press == 1 and scratch_pad_message == "DELETE") { - waypoints.pop(current_page_prop*3-3); - scratch_pad_message = ""; - } else if (L1_press_orig == 0 and press == 1) { - scratch_pad_message = "INVALID INPUT"; - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1 and scratch_pad_text != "") { - read_crt_wpt(scratch_pad_text, (current_page_prop*3-2)); - scratch_pad_text = ""; - - } else if (L2_press_orig == 0 and press == 1 and scratch_pad_message == "DELETE") { - waypoints.pop(current_page_prop*3-2); - scratch_pad_message = ""; - } else if (L2_press_orig == 0 and press == 1) { - scratch_pad_message = "INVALID INPUT"; - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1 and scratch_pad_text != "") { - read_crt_wpt(scratch_pad_text, (current_page_prop*3-1)); - scratch_pad_text = ""; - - } else if (L3_press_orig == 0 and press == 1 and scratch_pad_message == "DELETE") { - waypoints.pop(current_page_prop*3-1); - scratch_pad_message = ""; - } else if (L3_press_orig == 0 and press == 1) { - scratch_pad_message = "INVALID INPUT"; - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - } - - if (current_page_prop > total_page_rte and current_page_prop <= (total_page_rte + total_page_miss)) { - pageTitle.setText("MISSED APPROACH"); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setText(""); - line1Left.setText(""); - line1Mid.setText(""); - line1Right.setText(""); - line2Left.setText(""); - line2Mid.setText(""); - line2Right.setText(""); - line3Left.setText(""); - line3Mid.setText(""); - line3Right.setText(""); - line4Left.setText(""); - line4Mid.setText(""); - line4Right.setText(""); - line5Left.setText(""); - line5Mid.setText(""); - line5Right.setText(""); - line6Left.setText(""); - line6Mid.setText(""); - line6Right.setText(""); - line7Left.setText(""); - line7Mid.setText(""); - line7Right.setText(""); - } - - if (current_page_prop > (total_page_rte + total_page_miss) and current_page_prop <= total_page_prop) { - - pageTitle.setText("ALTERNATE FPL"); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setText(""); - var altn_wpt_num = altn_wpt_counter(); - var non_altn_num = rte_wpt_counter() + miss_wpt_counter(); - total_page_altn = math.floor((altn_wpt_num - 2) / 3) + 2; - var current_page_altn = current_page_prop - total_page_rte - total_page_miss; - - if (altn_wpt_num == 0) { - line1Left.setText(""); - line1Mid.setText(""); - line1Right.setText(""); - line2Mid.setText(""); - line2Right.setText(""); - line3Mid.setText(""); - line4Mid.setText(""); - if (altn_airport == "") { - line2Left.setText(""); - line3Left.setText(""); - line3Right.setText("ALTERNATE "); - line3Right.setColor(255,255,255,255); - line4Left.setText(""); - line4Right.setText("-----"); - line4Right.setColor(0,174,255,255); - } else { - line2Left.setText(dest_airport); - line2Left.setColor(0,255,0,255); - line3Left.setText("VIA.TO"); - line3Left.setColor(255,255,255,255); - line3Right.setText("ALTN "); - line3Right.setColor(255,255,255,255); - line4Left.setText("-----"); - line4Left.setColor(0,174,255,255); - line4Right.setText(altn_airport); - line4Right.setColor(0,255,0,255); - } - line5Left.setText(""); - line5Mid.setText(""); - line5Right.setText(""); - line6Left.setText(""); - line6Mid.setText(""); - line6Right.setText(""); - - var press = getprop("/instrumentation/fmz/fmz-key-R2-press"); - if (R2_press_orig == 0 and press == 1) { - var altn_airport_tmp = scratch_pad_text; - var chck_altn = findAirportsByICAO(altn_airport_tmp); - if (size(chck_altn) != 1) { - scratch_pad_message = "NOT IN DATABASE"; - altn_airport_tmp = ""; - } else if (chck_altn[0].id != altn_airport_tmp) { - scratch_pad_message = "NOT IN DATABASE"; - altn_airport_tmp = ""; - } else { - altn_airport = altn_airport_tmp; - } - scratch_pad_text = ""; - } - R2_press_orig = getprop("/instrumentation/fmz/fmz-key-R2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - var has_dot = find(".", scratch_pad_text)!=-1; - var long_enough = size(scratch_pad_text) >=5; - if (has_dot and long_enough) { - var is_awy = awy_parser(scratch_pad_text); - } else { - var is_awy = 0; - } - if (is_awy == 1) { - var insert_point = non_altn_num + 0; - for (i=size(awy_wpt_list)-1;i>0;i=i-1) { - var awy_wp = createWaypoint.new(awy_wpt_list[i], awy_wpt_list_lat[i], awy_wpt_list_lon[i]); - awy_ap.procedure = "altn"; - waypoints.insert(insert_point, awy_wp); - } - scratch_pad_text = ""; - } else { - if (scratch_pad_text == altn_airport) { - var altn_apt_hash = createWaypoint.new(altn_airport, airportinfo(altn_airport).lat, airportinfo(altn_airport).lon); - altn_apt_hash.altitude = airportinfo(altn_airport).elevation; - altn_apt_hash.procedure = "altn"; - waypoints.append(altn_apt_hash); - } else { - var old_wpt_num = waypoints.size(); - var insert_point = non_altn_num + 0; - read_crt_wpt(scratch_pad_text, insert_point); - var new_wpt_num = waypoints.size(); - if (new_wpt_num > old_wpt_num) { - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - } - scratch_pad_text = ""; - } - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - } - - if (altn_wpt_num == 1) { - line1Left.setText(""); - line1Mid.setText(""); - line1Right.setText(""); - line2Left.setText(dest_airport); - line2Left.setColor(0,255,0,255); - line2Mid.setText(""); - line2Right.setText(""); - var hdg = grtCircHdg(altn_wpt_vec[0]); - line3Left.setText(sprintf("%03d", hdg) ~ "°"); - line3Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(altn_wpt_vec[0]); - line3Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line3Mid.setColor(0,255,0,255); - line3Right.setText(""); - var wpt_id = waypoints.vector[altn_wpt_vec[0]].id; - line4Left.setText(wpt_id); - line4Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line4Mid.setText(ete_str); - line4Mid.setColor(0,255,0,255); - line4Right.setText(""); - line5Left.setText("VIA.TO"); - line5Left.setColor(255,255,255,255); - line5Mid.setText(""); - line5Right.setText("ALTN"); - line5Right.setColor(255,255,255,255); - line6Left.setText("------"); - line6Left.setColor(0,174,255,255); - line6Mid.setText(""); - line6Right.setText(altn_airport); - line6Right.setColor(0,255,0,255); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - if (scratch_pad_message == "DELETE"){ - var pop_point = non_altn_num + 0; - waypoints.pop(pop_point); - scratch_pad_message = ""; - } else { - var old_wpt_num = waypoints.size(); - var insert_point = non_altn_num + 0; - read_crt_wpt(scratch_pad_text, insert_point); - var new_wpt_num = waypoints.size(); - if (new_wpt_num > old_wpt_num) { - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - scratch_pad_text = ""; - } - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - var old_wpt_num = waypoints.size(); - var has_dot = find(".", scratch_pad_text)!=-1; - var long_enough = size(scratch_pad_text) >=5; - if (has_dot and long_enough) { - var is_awy = awy_parser(scratch_pad_text); - } else { - var is_awy = 0; - } - if (is_awy == 1) { - var insert_point = non_altn_num + 1; - for (i=size(awy_wpt_list)-1;i>0;i=i-1) { - var awy_wp = createWaypoint.new(awy_wpt_list[i], awy_wpt_list_lat[i], awy_wpt_list_lon[i]); - awy_wp.procedure = "altn"; - waypoints.insert(insert_point, awy_wp); - } - scratch_pad_text = ""; - } else { - if (scratch_pad_text == altn_airport) { - var altn_apt_hash = createWaypoint.new(altn_airport, airportinfo(altn_airport).lat, airportinfo(altn_airport).lon); - altn_apt_hash.altitude = airportinfo(altn_airport).elevation; - altn_apt_hash.procedure = "altn"; - waypoints.append(altn_apt_hash); - } else { - var old_wpt_num = waypoints.size(); - var insert_point = non_altn_num + 1; - read_crt_wpt(scratch_pad_text, insert_point); - var new_wpt_num = waypoints.size(); - if (new_wpt_num > old_wpt_num) { - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - } - scratch_pad_text = ""; - } - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - } - - if (altn_wpt_num >= 2 and current_page_prop == (total_page_rte + total_page_miss + 1)) { - line1Left.setText(""); - line1Mid.setText(""); - line1Right.setText(""); - line2Left.setText(dest_airport); - line2Left.setColor(0,255,0,255); - line2Mid.setText(""); - line2Right.setText(""); - var hdg = grtCircHdg(altn_wpt_vec[0]); - line3Left.setText(sprintf("%03d", hdg) ~ "°"); - line3Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(altn_wpt_vec[0]); - line3Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line3Mid.setColor(0,255,0,255); - line3Right.setText(""); - var wpt_id = waypoints.vector[altn_wpt_vec[0]].id; - line4Left.setText(wpt_id); - line4Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line4Mid.setText(ete_str); - line4Mid.setColor(0,255,0,255); - line4Right.setText(""); - var hdg = grtCircHdg(altn_wpt_vec[1]); - line5Left.setText(sprintf("%03d", hdg) ~ "°"); - line5Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(altn_wpt_vec[1]); - line5Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line5Mid.setColor(0,255,0,255); - line5Right.setText(""); - var wpt_id = waypoints.vector[altn_wpt_vec[1]].id; - line6Left.setText(wpt_id); - line6Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line6Mid.setText(ete_str); - line6Right.setText(""); - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - if (L2_press_orig == 0 and press == 1) { - if (scratch_pad_message == "DELETE"){ - var pop_point = non_altn_num + 0; - waypoints.pop(pop_point); - scratch_pad_message = ""; - } else { - var old_wpt_num = waypoints.size(); - var insert_point = non_altn_num + 0; - read_crt_wpt(scratch_pad_text, insert_point); - var new_wpt_num = waypoints.size(); - if (new_wpt_num > old_wpt_num) { - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - scratch_pad_text = ""; - } - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - if (scratch_pad_message == "DELETE"){ - var pop_point = non_altn_num + 1; - waypoints.pop(pop_point); - scratch_pad_message = ""; - } else { - var old_wpt_num = waypoints.size(); - var insert_point = non_altn_num + 1; - read_crt_wpt(scratch_pad_text, insert_point); - var new_wpt_num = waypoints.size(); - if (new_wpt_num > old_wpt_num) { - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - scratch_pad_text = ""; - } - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - } - - if (altn_wpt_num >= 5 and current_page_prop == (total_page_rte + total_page_miss + 1)) { - line1Left.setText(""); - line1Mid.setText(""); - line1Right.setText(""); - line2Left.setText(dest_airport); - line2Left.setColor(0,255,0,255); - line2Mid.setText(""); - line2Right.setText(""); - var hdg = grtCircHdg(altn_wpt_vec[current_page_altn * 3 - 3]); - line3Left.setText(sprintf("%03d", hdg) ~ "°"); - line3Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(altn_wpt_vec[current_page_altn * 3 - 3]); - line3Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line3Mid.setColor(0,255,0,255); - line3Right.setText(""); - var wpt_id = waypoints.vector[altn_wpt_vec[current_page_altn * 3 - 3]].id; - line4Left.setText(wpt_id); - line4Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line4Mid.setText(ete_str); - line4Mid.setColor(0,255,0,255); - line4Right.setText(""); - var hdg = grtCircHdg(altn_wpt_vec[current_page_altn * 3 - 2]); - line5Left.setText(sprintf("%03d", hdg) ~ "°"); - line5Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(altn_wpt_vec[current_page_altn * 3 - 2]); - line5Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line5Mid.setColor(0,255,0,255); - line5Right.setText(""); - var wpt_id = waypoints.vector[altn_wpt_vec[current_page_altn * 3 - 2]].id; - line6Left.setText(wpt_id); - line6Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line6Mid.setText(ete_str); - line6Mid.setColor(0,255,0,255); - line6Right.setText(""); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - if (scratch_pad_message == "DELETE"){ - var pop_point = non_altn_num + (current_page_altn * 3 - 3); - waypoints.pop(pop_point); - scratch_pad_message = ""; - } else { - var old_wpt_num = waypoints.size(); - var insert_point = non_altn_num + (current_page_altn * 3 - 3); - read_crt_wpt(scratch_pad_text, insert_point); - var new_wpt_num = waypoints.size(); - if (new_wpt_num > old_wpt_num) { - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - scratch_pad_text = ""; - } - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - if (scratch_pad_message == "DELETE"){ - var pop_point = non_altn_num + (current_page_altn * 3 - 2); - waypoints.pop(pop_point); - scratch_pad_message = ""; - } else { - var old_wpt_num = waypoints.size(); - var insert_point = non_altn_num + (current_page_altn * 3 - 2); - read_crt_wpt(scratch_pad_text, insert_point); - var new_wpt_num = waypoints.size(); - if (new_wpt_num > old_wpt_num) { - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - scratch_pad_text = ""; - } - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - } else if (altn_wpt_num >= 5 and current_page_prop < total_page_prop) { - var hdg = grtCircHdg(altn_wpt_vec[current_page_altn * 3 - 4]); - line1Left.setText(sprintf("%03d", hdg) ~ "°"); - line1Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(altn_wpt_vec[current_page_altn * 3 - 4]); - line1Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line1Mid.setColor(0,255,0,255); - line1Right.setText(""); - var wpt_id = waypoints.vector[altn_wpt_vec[current_page_altn * 3 - 4]].id; - line2Left.setText(wpt_id); - line2Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line2Mid.setText(ete_str); - line2Mid.setColor(0,255,0,255); - line2Right.setText(""); - var hdg = grtCircHdg(altn_wpt_vec[current_page_altn * 3 - 3]); - line3Left.setText(sprintf("%03d", hdg) ~ "°"); - line3Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(altn_wpt_vec[current_page_altn * 3 - 3]); - line3Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line3Mid.setColor(0,255,0,255); - line3Right.setText(""); - var wpt_id = waypoints.vector[altn_wpt_vec[current_page_altn * 3 - 3]].id; - line4Left.setText(wpt_id); - line4Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line4Mid.setText(ete_str); - line4Mid.setColor(0,255,0,255); - line4Right.setText(""); - var hdg = grtCircHdg(altn_wpt_vec[current_page_altn * 3 - 2]); - line5Left.setText(sprintf("%03d", hdg) ~ "°"); - line5Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(altn_wpt_vec[current_page_altn * 3 - 2]); - line5Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line5Mid.setColor(0,255,0,255); - line5Right.setText(""); - var wpt_id = waypoints.vector[altn_wpt_vec[current_page_altn * 3 - 2]].id; - line6Left.setText(wpt_id); - line6Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line6Mid.setText(ete_str); - line6Mid.setColor(0,255,0,255); - line6Right.setText(""); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - if (scratch_pad_message == "DELETE"){ - var pop_point = non_altn_num + (current_page_altn * 3 - 4); - waypoints.pop(pop_point); - scratch_pad_message = ""; - } else { - var old_wpt_num = waypoints.size(); - var insert_point = non_altn_num + (current_page_altn * 3 - 4); - read_crt_wpt(scratch_pad_text, insert_point); - var new_wpt_num = waypoints.size(); - if (new_wpt_num > old_wpt_num) { - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - scratch_pad_text = ""; - } - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - if (scratch_pad_message == "DELETE"){ - var pop_point = non_altn_num + (current_page_altn * 3 - 3); - waypoints.pop(pop_point); - scratch_pad_message = ""; - } else { - var old_wpt_num = waypoints.size(); - var insert_point = non_altn_num + (current_page_altn * 3 - 3); - read_crt_wpt(scratch_pad_text, insert_point); - var new_wpt_num = waypoints.size(); - if (new_wpt_num > old_wpt_num) { - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - scratch_pad_text = ""; - } - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - if (scratch_pad_message == "DELETE"){ - var pop_point = non_altn_num + (current_page_altn * 3 - 2); - waypoints.pop(pop_point); - scratch_pad_message = ""; - } else { - var old_wpt_num = waypoints.size(); - var insert_point = non_altn_num + (current_page_altn * 3 - 2); - read_crt_wpt(scratch_pad_text, insert_point); - var new_wpt_num = waypoints.size(); - if (new_wpt_num > old_wpt_num) { - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - scratch_pad_text = ""; - } - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - } - - if (altn_wpt_num >= 2 and current_page_prop == total_page_prop and math.fmod(altn_wpt_num, 3) == 2) { - line1Left.setText("VIA.TO"); - line1Left.setColor(255,255,255,255); - line1Mid.setText(""); - line1Right.setText("ALTN"); - line1Right.setColor(255,255,255,255); - line2Left.setText("-----"); - line2Left.setColor(0,174,255,255); - line2Mid.setText(""); - line2Right.setText(altn_airport); - line2Right.setColor(0,255,0,255); - line3Left.setText(""); - line3Mid.setText(""); - line3Right.setText(""); - line4Left.setText(""); - line4Mid.setText(""); - line4Right.setText(""); - line5Left.setText(""); - line5Mid.setText(""); - line5Right.setText(""); - line6Left.setText(""); - line6Mid.setText(""); - line6Right.setText(""); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - var has_dot = find(".", scratch_pad_text)!=-1; - var long_enough = size(scratch_pad_text) >=5; - if (has_dot and long_enough) { - var is_awy = awy_parser(scratch_pad_text); - } else { - var is_awy = 0; - } - if (is_awy == 1) { - var insert_point = non_altn_num + (current_page_altn * 3 - 4); - for (i=size(awy_wpt_list)-1;i>0;i=i-1) { - var awy_wp = createWaypoint.new(awy_wpt_list[i], awy_wpt_list_lat[i], awy_wpt_list_lon[i]); - awy_ap.procedure = "altn"; - waypoints.insert(insert_point, awy_wp); - } - scratch_pad_text = ""; - } else { - if (scratch_pad_text == altn_airport) { - var altn_apt_hash = createWaypoint.new(altn_airport, airportinfo(altn_airport).lat, airportinfo(altn_airport).lon); - altn_apt_hash.altitude = airportinfo(altn_airport).elevation; - altn_apt_hash.procedure = "altn"; - waypoints.append(altn_apt_hash); - } else { - var old_wpt_num = waypoints.size(); - var insert_point = non_altn_num + (current_page_altn * 3 - 4); - read_crt_wpt(scratch_pad_text, insert_point); - var new_wpt_num = waypoints.size(); - if (new_wpt_num > old_wpt_num) { - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - } - scratch_pad_text = ""; - } - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - } - - if (altn_wpt_num >= 2 and current_page_prop == total_page_prop and math.fmod(altn_wpt_num, 3) == 0) { - var hdg = grtCircHdg(altn_wpt_vec[current_page_altn * 3 - 4]); - line1Left.setText(sprintf("%03d", hdg) ~ "°"); - line1Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(altn_wpt_vec[current_page_altn * 3 - 4]); - line1Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line1Mid.setColor(0,255,0,255); - line1Right.setText(""); - var wpt_id = waypoints.vector[altn_wpt_vec[current_page_altn * 3 - 4]].id; - line2Left.setText(wpt_id); - line2Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line2Mid.setText(ete_str); - line2Mid.setColor(0,255,0,255); - line2Right.setText(""); - line3Left.setText("VIA.TO"); - line3Left.setColor(255,255,255,255); - line3Mid.setText(""); - line3Right.setText("ALTN"); - line3Right.setColor(255,255,255,255); - line4Left.setText("-----"); - line4Left.setColor(0,174,255,255); - line4Mid.setText(""); - line4Right.setText(altn_airport); - line4Right.setColor(0,255,0,255); - line5Left.setText(""); - line5Mid.setText(""); - line5Right.setText(""); - line6Left.setText(""); - line6Mid.setText(""); - line6Right.setText(""); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - if (scratch_pad_message == "DELETE"){ - var pop_point = non_altn_num + (current_page_altn * 3 - 4); - waypoints.pop(pop_point); - scratch_pad_message = ""; - } else { - var old_wpt_num = waypoints.size(); - var insert_point = non_altn_num + (current_page_altn * 3 - 4); - read_crt_wpt(scratch_pad_text, insert_point); - var new_wpt_num = waypoints.size(); - if (new_wpt_num > old_wpt_num) { - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - scratch_pad_text = ""; - } - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - var has_dot = find(".", scratch_pad_text)!=-1; - var long_enough = size(scratch_pad_text) >=5; - if (has_dot and long_enough) { - var is_awy = awy_parser(scratch_pad_text); - } else { - var is_awy = 0; - } - if (is_awy == 1) { - var insert_point = non_altn_num + (current_page_altn * 3 - 3); - for (i=size(awy_wpt_list)-1;i>0;i=i-1) { - var awy_wp = createWaypoint.new(awy_wpt_list[i], awy_wpt_list_lat[i], awy_wpt_list_lon[i]); - awy_ap.procedure = "altn"; - waypoints.insert(insert_point, awy_wp); - } - scratch_pad_text = ""; - } else { - if (scratch_pad_text == altn_airport) { - var altn_apt_hash = createWaypoint.new(altn_airport, airportinfo(altn_airport).lat, airportinfo(altn_airport).lon); - altn_apt_hash.altitude = airportinfo(altn_airport).elevation; - altn_apt_hash.procedure = "altn"; - waypoints.append(altn_apt_hash); - } else { - var old_wpt_num = waypoints.size(); - var insert_point = non_altn_num + (current_page_altn * 3 - 3); - read_crt_wpt(scratch_pad_text, insert_point); - var new_wpt_num = waypoints.size(); - if (new_wpt_num > old_wpt_num) { - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - } - scratch_pad_text = ""; - } - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - } - - if (altn_wpt_num >= 2 and current_page_prop == total_page_prop and math.fmod(altn_wpt_num, 3) == 1) { - var hdg = grtCircHdg(altn_wpt_vec[current_page_altn * 3 - 4]); - line1Left.setText(sprintf("%03d", hdg) ~ "°"); - line1Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(altn_wpt_vec[current_page_altn * 3 - 4]); - line1Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line1Mid.setColor(0,255,0,255); - line1Right.setText(""); - var wpt_id = waypoints.vector[altn_wpt_vec[current_page_altn * 3 - 4]].id; - line2Left.setText(wpt_id); - line2Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line2Mid.setText(ete_str); - line2Mid.setColor(0,255,0,255); - line2Right.setText(""); - var hdg = grtCircHdg(altn_wpt_vec[current_page_altn * 3 - 3]); - line3Left.setText(sprintf("%03d", hdg) ~ "°"); - line3Left.setColor(0,255,0,255); - var leg_dist = grtCircDist(altn_wpt_vec[current_page_altn * 3 - 3]); - line3Mid.setText(sprintf("%4.0f", leg_dist) ~ "NM"); - line3Mid.setColor(0,255,0,255); - line3Right.setText(""); - var wpt_id = waypoints.vector[altn_wpt_vec[current_page_altn * 3 - 3]].id; - line4Left.setText(wpt_id); - line4Left.setColor(0,255,0,255); - if (ground_spd < 80){ - var ete_f = leg_dist / 440; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } else { - var ete_f = leg_dist / ground_spd; - var ete_h = sprintf("%02d", ete_f); - var ete_m = sprintf("%02d", (ete_f-math.floor(ete_f))*60); - var ete_str = ete_h ~ " + " ~ ete_m; - } - line4Mid.setText(ete_str); - line4Mid.setColor(0,255,0,255); - line4Right.setText(""); - line5Left.setText("VIA.TO"); - line5Left.setColor(255,255,255,255); - line5Mid.setText(""); - line5Right.setText("ALTN"); - line5Right.setColor(255,255,255,255); - line6Left.setText("-----"); - line6Left.setColor(0,174,255,255); - line6Mid.setText(""); - line6Right.setText(altn_airport); - line6Right.setColor(0,255,0,255); - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - if (scratch_pad_message == "DELETE"){ - var pop_point = non_altn_num + (current_page_altn * 3 - 4); - waypoints.pop(pop_point); - scratch_pad_message = ""; - } else { - var old_wpt_num = waypoints.size(); - var insert_point = non_altn_num + (current_page_altn * 3 - 4); - read_crt_wpt(scratch_pad_text, insert_point); - var new_wpt_num = waypoints.size(); - if (new_wpt_num > old_wpt_num) { - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - scratch_pad_text = ""; - } - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - if (scratch_pad_message == "DELETE"){ - var pop_point = non_altn_num + (current_page_altn * 3 - 3); - waypoints.pop(pop_point); - scratch_pad_message = ""; - } else { - var old_wpt_num = waypoints.size(); - var insert_point = non_altn_num + (current_page_altn * 3 - 3); - read_crt_wpt(scratch_pad_text, insert_point); - var new_wpt_num = waypoints.size(); - if (new_wpt_num > old_wpt_num) { - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - scratch_pad_text = ""; - } - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - var has_dot = find(".", scratch_pad_text)!=-1; - var long_enough = size(scratch_pad_text) >=5; - if (has_dot and long_enough) { - var is_awy = awy_parser(scratch_pad_text); - } else { - var is_awy = 0; - } - if (is_awy == 1) { - var insert_point = non_altn_num + (current_page_altn * 3 - 2); - for (i=size(awy_wpt_list)-1;i>0;i=i-1) { - var awy_wp = createWaypoint.new(awy_wpt_list[i], awy_wpt_list_lat[i], awy_wpt_list_lon[i]); - awy_ap.procedure = "altn"; - waypoints.insert(insert_point, awy_wp); - } - scratch_pad_text = ""; - } else { - if (scratch_pad_text == altn_airport) { - var altn_apt_hash = createWaypoint.new(altn_airport, airportinfo(altn_airport).lat, airportinfo(altn_airport).lon); - altn_apt_hash.altitude = airportinfo(altn_airport).elevation; - altn_apt_hash.procedure = "altn"; - waypoints.append(altn_apt_hash); - } else { - var old_wpt_num = waypoints.size(); - var insert_point = non_altn_num + (current_page_altn * 3 - 2); - read_crt_wpt(scratch_pad_text, insert_point); - var new_wpt_num = waypoints.size(); - if (new_wpt_num > old_wpt_num) { - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - } - scratch_pad_text = ""; - } - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - } - } - } - } - fmz_setlistener(pageActiveFltPlan); - var pageActiveFltPlan_timer = maketimer(1, pageActiveFltPlan); - pageActiveFltPlan_timer.start(); - - var pageWayPointSelect = func { - if (page_title_text == "WAYPOINT SELECT") { - eachPageInit(); - total_page_prop = math.ceil(size(wpt_sel_vec) / 3); - pageTitle.setText(sprintf("%s", "WAYPOINT SELECT")); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setText(""); - currentPage.setText(sprintf("%d", current_page_prop)); - currentPage.setColor(255,255,255,255); - totalPage.setText(sprintf("%d", total_page_prop)); - totalPage.setColor(255,255,255,255); - line1Left.setText(wpt_sel_vec[current_page_prop*3-3][0]); - line1Left.setColor(255,255,255,255); - line1Mid.setText(sprintf("%.0f", wpt_sel_vec[current_page_prop*3-3][3]) ~ "NM"); - line1Mid.setColor(255,255,255,255); - line1Right.setText("RETURN ▶"); - - var wpt_pos = ""; - if (wpt_sel_vec[current_page_prop*3-3][1]<0) { - wpt_pos = wpt_pos ~ "◀ S"; - } else { - wpt_pos = wpt_pos ~ "◀ N"; - } - var lat_deg = math.floor(abs(wpt_sel_vec[current_page_prop*3-3][1])); - var lat_min = (abs(wpt_sel_vec[current_page_prop*3-3][1])-lat_deg)*60; - lat_deg = sprintf("%02d", lat_deg); - lat_min = sprintf("%05.2f", lat_min); - wpt_pos = wpt_pos ~ lat_deg ~ "° " ~ lat_min; - if (wpt_sel_vec[current_page_prop*3-3][2]<0) { - wpt_pos = wpt_pos ~ " W"; - } else { - wpt_pos = wpt_pos ~ " E"; - } - var lon_deg = math.floor(abs(wpt_sel_vec[current_page_prop*3-3][2])); - var lon_min = (abs(wpt_sel_vec[current_page_prop*3-3][2])-lon_deg) * 60; - lon_deg = sprintf("%03d", lon_deg); - lon_min = sprintf("%05.2f", lon_min); - wpt_pos = wpt_pos ~ lon_deg ~ "° " ~ lon_min; - - line2Left.setText(wpt_pos); - line2Left.setColor(0,255,0,255); - line2Mid.setText(""); - line2Right.setText(""); - - if (math.fmod(size(wpt_sel_vec),3)==2 or math.fmod(size(wpt_sel_vec),3)==0 or current_page_prop < total_page_prop) { - line3Left.setText(wpt_sel_vec[current_page_prop*3-2][0]); - line3Left.setColor(255,255,255,255); - line3Mid.setText(sprintf("%.0f", wpt_sel_vec[current_page_prop*3-2][3]) ~ "NM"); - line3Mid.setColor(255,255,255,255); - line3Right.setText(""); - - var wpt_pos = ""; - if (wpt_sel_vec[current_page_prop*3-2][1]<0) { - wpt_pos = wpt_pos ~ "◀ S"; - } else { - wpt_pos = wpt_pos ~ "◀ N"; - } - var lat_deg = math.floor(abs(wpt_sel_vec[current_page_prop*3-2][1])); - var lat_min = (abs(wpt_sel_vec[current_page_prop*3-2][1])-lat_deg)*60; - lat_deg = sprintf("%02d", lat_deg); - lat_min = sprintf("%04.2f", lat_min); - wpt_pos = wpt_pos ~ lat_deg ~ "° " ~ lat_min; - if (wpt_sel_vec[current_page_prop*3-2][2]<0) { - wpt_pos = wpt_pos ~ " W"; - } else { - wpt_pos = wpt_pos ~ " E"; - } - var lon_deg = math.floor(abs(wpt_sel_vec[current_page_prop*3-2][2])); - var lon_min = (abs(wpt_sel_vec[current_page_prop*3-2][2])-lon_deg) * 60; - lon_deg = sprintf("%03d", lon_deg); - lon_min = sprintf("%05.2f", lon_min); - wpt_pos = wpt_pos ~ lon_deg ~ "° " ~ lon_min; - - line4Left.setText(wpt_pos); - line4Left.setColor(0,255,0,255); - line4Mid.setText(""); - line4Right.setText(""); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - var isr_name = wpt_sel_vec[current_page_prop*3-2][0]; - var isr_lat = wpt_sel_vec[current_page_prop*3-2][1]; - var isr_lon = wpt_sel_vec[current_page_prop*3-2][2]; - var wp = createWaypoint.new(isr_name, isr_lat, isr_lon); - waypoints.insert(wpt_sel_isr, wp); - wpt_num = waypoints.size(); - var wc = 0; - while((abs(waypoints.vector[wc].lat - isr_lat) > 0.0001 or abs(waypoints.vector[wc].lon - isr_lon) > 0.0001) and wc <= wpt_num) { - wc = wc + 1; - } - if (wc < wpt_sel_isr){ - for (i=wc; i<(wpt_sel_isr); i=i+1){ - waypoints.pop(wc); - } - } - if (save_current_page > (total_page_rte + total_page_miss)){ - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - page_title_text = "ACTIVE FLT PLAN"; - current_page_prop = save_current_page; - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - } else { - line3Left.setText(""); - line3Mid.setText(""); - line3Right.setText(""); - line4Left.setText(""); - line4Mid.setText(""); - line4Right.setText(""); - } - - if (math.fmod(size(wpt_sel_vec),3)==3 or current_page_prop < total_page_prop) { - line5Left.setText(wpt_sel_vec[current_page_prop*3-1][0]); - line5Left.setColor(255,255,255,255); - line5Mid.setText(sprintf("%.0f", wpt_sel_vec[current_page_prop*3-1][3]) ~ "NM"); - line5Mid.setColor(255,255,255,255); - line3Mid.setColor(255,255,255,255); - line3Right.setText(""); - - var wpt_pos = ""; - if (wpt_sel_vec[current_page_prop*3-1][1]<0) { - wpt_pos = wpt_pos ~ "◀ S"; - } else { - wpt_pos = wpt_pos ~ "◀ N"; - } - var lat_deg = math.floor(abs(wpt_sel_vec[current_page_prop*3-1][1])); - var lat_min = (abs(wpt_sel_vec[current_page_prop*3-1][1])-lat_deg)*60; - lat_deg = sprintf("%02d", lat_deg); - lat_min = sprintf("%05.2f", lat_min); - wpt_pos = wpt_pos ~ lat_deg ~ "° " ~ lat_min; - if (wpt_sel_vec[current_page_prop*3-1][2]<0) { - wpt_pos = wpt_pos ~ " W"; - } else { - wpt_pos = wpt_pos ~ " E"; - } - var lon_deg = math.floor(abs(wpt_sel_vec[current_page_prop*3-1][2])); - var lon_min = (abs(wpt_sel_vec[current_page_prop*3-1][2])-lon_deg) * 60; - lon_deg = sprintf("%03d", lon_deg); - lon_min = sprintf("%05.2f", lon_min); - wpt_pos = wpt_pos ~ lon_deg ~ "° " ~ lon_min; - - line6Left.setText(wpt_pos); - line6Left.setColor(0,255,0,255); - line6Mid.setText(""); - line6Right.setText(""); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - var isr_name = wpt_sel_vec[current_page_prop*3-1][0]; - var isr_lat = wpt_sel_vec[current_page_prop*3-1][1]; - var isr_lon = wpt_sel_vec[current_page_prop*3-1][2]; - var wp = createWaypoint.new(isr_name, isr_lat, isr_lon); - waypoints.insert(wpt_sel_isr, wp); - wpt_num = waypoints.size(); - var wc = 0; - while((abs(waypoints.vector[wc].lat - isr_lat) > 0.0001 or abs(waypoints.vector[wc].lon - isr_lon) > 0.0001) and wc <= wpt_num) { - wc = wc + 1; - } - if (wc < wpt_sel_isr){ - for (i=wc; i<(wpt_sel_isr); i=i+1){ - waypoints.pop(wc); - } - } - if (save_current_page > (total_page_rte + total_page_miss)){ - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - page_title_text = "ACTIVE FLT PLAN"; - current_page_prop = save_current_page; - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - - } else { - line5Left.setText(""); - line5Mid.setText(""); - line5Right.setText(""); - line6Left.setText(""); - line6Mid.setText(""); - line6Right.setText(""); - } - line7Left.setText(""); - line7Mid.setText(""); - line7Right.setText(""); - - var press = getprop("/instrumentation/fmz/fmz-key-R1-press"); - if (R1_press_orig == 0 and press == 1) { - page_title_text = "ACTIVE FLT PLAN"; - current_page_prop = save_current_page; - } - R1_press_orig = getprop("/instrumentation/fmz/fmz-key-R1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - var isr_name = wpt_sel_vec[current_page_prop*3-3][0]; - var isr_lat = wpt_sel_vec[current_page_prop*3-3][1]; - var isr_lon = wpt_sel_vec[current_page_prop*3-3][2]; - var wp = createWaypoint.new(isr_name, isr_lat, isr_lon); - waypoints.insert(wpt_sel_isr, wp); - wpt_num = waypoints.size(); - var wc = 0; - while((abs(waypoints.vector[wc].lat - isr_lat) > 0.0001 or abs(waypoints.vector[wc].lon - isr_lon) > 0.0001) and wc <= wpt_num) { - wc = wc + 1; - } - if (wc < wpt_sel_isr){ - for (i=wc; i<(wpt_sel_isr); i=i+1){ - waypoints.pop(wc); - } - } - if (save_current_page > (total_page_rte + total_page_miss)){ - waypoints.vector[wpt_sel_isr].procedure = "altn"; - } - page_title_text = "ACTIVE FLT PLAN"; - current_page_prop = save_current_page; - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - } - } - fmz_setlistener(pageWayPointSelect); - - var pageFplPlanSelect = func { - - if (page_title_text == "FPL PLAN SELECT"){ - eachPageInit(); - var press = getprop("/instrumentation/fmz/fmz-key-R1-press"); - if (R1_press_orig == 0 and press == 1) { - is_active = 1; - page_title_text = "ACTIVE FLT PLAN"; - } - R1_press_orig = getprop("/instrumentation/fmz/fmz-key-R1-press"); - - var origin_airport = origin_airport_id; - pageTitle.setText(sprintf("%s", "FPL PLAN SELECT")); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setText(sprintf("%s", "")); - pageTitleRight.setColor(255,255,255,255); - currentPage.setText(sprintf("%d", 1)); - currentPage.setColor(255,255,255,255); - totalPage.setText(sprintf("%d", 1)); - totalPage.setColor(255,255,255,255); - line1Left.setText(sprintf("%s", "FLT PLAN")); - line1Left.setColor(255,255,255,255); - line2Left.setText(sprintf("%s",origin_airport ~ " - " ~ dest_airport)); - line2Left.setColor(255,255,0,255); - line3Left.setText(sprintf("%s", "")); - line3Left.setColor(255,255,255,255); - line4Left.setText(sprintf("%s", "")); - line4Left.setColor(255,255,255,255); - line5Left.setText(sprintf("%s", "")); - line5Left.setColor(255,255,255,255); - line6Left.setText(sprintf("%s", "")); - line6Left.setColor(255,255,255,255); - line7Left.setText(sprintf("%s", "◀ FPL LIST")); - line7Left.setColor(255,255,255,255); - line1Mid.setText(sprintf("%s", "")); - line1Mid.setColor(255,255,255,255); - line2Mid.setText(sprintf("%s", "")); - line2Mid.setColor(255,255,255,255); - line3Mid.setText(sprintf("%s", "")); - line3Mid.setColor(255,255,255,255); - line4Mid.setText(sprintf("%s", "")); - line4Mid.setColor(255,255,255,255); - line5Mid.setText(sprintf("%s", "")); - line5Mid.setColor(255,255,255,255); - line6Mid.setText(sprintf("%s", "")); - line6Mid.setColor(255,255,255,255); - line7Mid.setText(sprintf("%s", "")); - line7Mid.setColor(255,255,255,255); - line1Right.setText(sprintf("%s", "")); - line1Right.setColor(255,255,255,255); - line2Right.setText(sprintf("%s", "ACTIVATE ▶")); - line2Right.setColor(255,255,255,255); - line3Right.setText(sprintf("%s", "")); - line3Right.setColor(255,255,255,255); - line4Right.setText(sprintf("%s", "INVERT/ACTIVATE ▶")); - line4Right.setColor(255,255,255,255); - line5Right.setText(sprintf("%s", "")); - line5Right.setColor(255,255,255,255); - line6Right.setText(sprintf("%s", "STORED FPL PREF ▶")); - line6Right.setColor(255,255,255,255); - line7Right.setText(sprintf("%s", "")); - line7Right.setColor(255,255,255,255); - } - } - fmz_setlistener(pageFplPlanSelect); - - var pageDepartureRunways = func { - if (page_title_text == "DEPARTURE RUNWAYS") { - eachPageInit(); - var origin_airport = origin_airport_id; - var runways = airportinfo(origin_airport).runways; - var runways_vector = []; - foreach(var rwy; keys(runways)){ - append(runways_vector, rwy); - } - total_page_prop = math.ceil(size(runways)/4); - var runway_sel = sld_rwy; - - pageTitle.setText(sprintf("%s", "DEPARTURE RUNWAYS")); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setText(sprintf("%s", "")); - pageTitleRight.setColor(255,255,255,255); - currentPage.setText(sprintf("%d", current_page_prop)); - currentPage.setColor(255,255,255,255); - totalPage.setText(sprintf("%d",total_page_prop)); - totalPage.setColor(255,255,255,255); - line1Left.setText(sprintf("%s", "")); - line1Left.setColor(255,255,255,255); - line2Left.setText(sprintf("%s", origin_airport)); - line2Left.setColor(0,255,0,255); - line3Left.setText(sprintf("%s", "")); - line3Left.setColor(255,255,255,255); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - var rwy_num = runways_vector[current_page_prop*4-4]; - sld_rwy = rwy_num; - - var orgn_apt_rwy_hash = createWaypoint.new((origin_airport ~ " -- " ~ rwy_num), airportinfo(origin_airport).runways[rwy_num].lat, airportinfo(origin_airport).runways[rwy_num].lon); - orgn_apt_rwy_hash.altitude = airportinfo(origin_airport).elevation; - waypoints.pop(0); - waypoints.insert(0, orgn_apt_rwy_hash); - - var rwy_sids = listSids(origin_airport, rwy_num); - if (size(rwy_sids)>0){ - page_title_text = "SIDs"; - current_page_prop = 1; - } - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R2-press"); - if (R2_press_orig == 0 and press == 1) { - var rwy_num = runways_vector[current_page_prop*4-3]; - sld_rwy = rwy_num; - - var orgn_apt_rwy_hash = createWaypoint.new((origin_airport ~ " -- " ~ rwy_num), airportinfo(origin_airport).runways[rwy_num].lat, airportinfo(origin_airport).runways[rwy_num].lon); - orgn_apt_rwy_hash.altitude = airportinfo(origin_airport).elevation; - waypoints.pop(0); - waypoints.insert(0, orgn_apt_rwy_hash); - - var rwy_sids = listSids(origin_airport, rwy_num); - if (size(rwy_sids)>0){ - page_title_text = "SIDs"; - current_page_prop = 1; - } - } - R2_press_orig = getprop("/instrumentation/fmz/fmz-key-R2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1 and (math.fmod(size(runways_vector),4) == 0 or current_page_prop < total_page_prop)) { - var rwy_num = runways_vector[current_page_prop*4-2]; - sld_rwy = rwy_num; - - var orgn_apt_rwy_hash = createWaypoint.new((origin_airport ~ " -- " ~ rwy_num), airportinfo(origin_airport).runways[rwy_num].lat, airportinfo(origin_airport).runways[rwy_num].lon); - orgn_apt_rwy_hash.altitude = airportinfo(origin_airport).elevation; - waypoints.pop(0); - waypoints.insert(0, orgn_apt_rwy_hash); - - var rwy_sids = listSids(origin_airport, rwy_num); - if (size(rwy_sids)>0){ - page_title_text = "SIDs"; - current_page_prop = 1; - } - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R3-press"); - if (R3_press_orig == 0 and press == 1 and (math.fmod(size(runways_vector),4) == 0 or current_page_prop < total_page_prop)) { - var rwy_num = runways_vector[current_page_prop*4-1]; - sld_rwy = rwy_num; - - var orgn_apt_rwy_hash = createWaypoint.new((origin_airport ~ " -- " ~ rwy_num), airportinfo(origin_airport).runways[rwy_num].lat, airportinfo(origin_airport).runways[rwy_num].lon); - orgn_apt_rwy_hash.altitude = airportinfo(origin_airport).elevation; - waypoints.pop(0); - waypoints.insert(0, orgn_apt_rwy_hash); - - var rwy_sids = listSids(origin_airport, rwy_num); - if (size(rwy_sids)>0){ - page_title_text = "SIDs"; - current_page_prop = 1; - } - } - R3_press_orig = getprop("/instrumentation/fmz/fmz-key-R3-press"); - - if (runways_vector[current_page_prop*4-4] == runway_sel){ - line4Left.setText(sprintf("%s", runways_vector[current_page_prop*4-4] ~ " [SEL]")); - } else { - line4Left.setText(sprintf("%s", runways_vector[current_page_prop*4-4])); - } - line4Left.setColor(0,255,0,255); - line5Left.setText(sprintf("%s", "")); - line5Left.setColor(255,255,255,255); - if (runways_vector[current_page_prop*4-3] == runway_sel){ - line4Right.setText(sprintf("%s", runways_vector[current_page_prop*4-3] ~ " [SEL]")); - } else { - line4Right.setText(sprintf("%s", runways_vector[current_page_prop*4-3])); - } - line6Left.setColor(0,255,0,255); - line7Left.setText(sprintf("%s", "")); - line7Left.setColor(255,255,255,255); - line1Mid.setText(sprintf("%s", "")); - line1Mid.setColor(255,255,255,255); - line2Mid.setText(sprintf("%s", "")); - line2Mid.setColor(255,255,255,255); - line3Mid.setText(sprintf("%s", "")); - line3Mid.setColor(255,255,255,255); - line4Mid.setText(sprintf("%s", "")); - line4Mid.setColor(255,255,255,255); - line5Mid.setText(sprintf("%s", "")); - line5Mid.setColor(255,255,255,255); - line6Mid.setText(sprintf("%s", "")); - line6Mid.setColor(255,255,255,255); - line7Mid.setText(sprintf("%s", "")); - line7Mid.setColor(255,255,255,255); - line1Right.setText(sprintf("%s", "")); - line1Right.setColor(255,255,255,255); - line2Right.setText(sprintf("%s", "")); - line2Right.setColor(255,255,255,255); - line3Right.setText(sprintf("%s", "")); - line3Right.setColor(255,255,255,255); - if (current_page_prop < total_page_prop){ - if(runways_vector[current_page_prop*4-2] == runway_sel){ - line6Left.setText(sprintf("%s", "[SEL] " ~ runways_vector[current_page_prop*4-2])); - } else { - line6Left.setText(sprintf("%s", runways_vector[current_page_prop*4-2])); - } - if(runways_vector[current_page_prop*4-1] == runway_sel){ - line6Right.setText(sprintf("%s", "[SEL] " ~ runways_vector[current_page_prop*4-1])); - } else { - line6Right.setText(sprintf("%s", runways_vector[current_page_prop*4-1])); - } - } else if (math.fmod(size(runways),4)==0){ - if(runways_vector[current_page_prop*4-2] == runway_sel){ - line6Left.setText(sprintf("%s", "[SEL] " ~ runways_vector[current_page_prop*4-2])); - } else { - line6Left.setText(sprintf("%s", runways_vector[current_page_prop*4-2])); - } - if(runways_vector[current_page_prop*4-1] == runway_sel){ - line6Right.setText(sprintf("%s", "[SEL] " ~ runways_vector[current_page_prop*4-1])); - } else { - line6Right.setText(sprintf("%s", runways_vector[current_page_prop*4-1])); - } - } else { - line6Left.setText(sprintf("%s", "")); - line6Right.setText(sprintf("%s", "")); - } - line4Right.setColor(0,255,0,255); - line5Right.setText(sprintf("%s", "")); - line5Right.setColor(255,255,255,255); - - line6Right.setColor(0,255,0,255); - line7Right.setText(sprintf("%s", "TAKEOFF ▶")); - line7Right.setColor(255,255,255,255); - } - - } - fmz_setlistener(pageDepartureRunways); - - var pageSids = func { - - if (page_title_text == "SIDs"){ - eachPageInit(); - var origin_airport = origin_airport_id; - var rwy_num = sld_rwy; - var rwy_sids = listSids(origin_airport, rwy_num); - total_page_prop = math.ceil(size(rwy_sids)/4); - - var press = getprop("/instrumentation/fmz/fmz-key-R4-press"); - if (R4_press_orig == 0 and press == 1) { - is_active = 1; - page_title_text = "ACTIVE FLT PLAN"; - current_page_prop = 1; - } - R4_press_orig = getprop("/instrumentation/fmz/fmz-key-R4-press"); - - pageTitle.setText(sprintf("%s", "SIDs")); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setText(sprintf("%s", "")); - pageTitleRight.setColor(255,255,255,255); - currentPage.setText(sprintf("%d", current_page_prop)); - currentPage.setColor(255,255,255,255); - totalPage.setText(sprintf("%d",total_page_prop)); - line1Left.setText(sprintf("%s", "")); - line1Left.setColor(255,255,255,255); - line2Left.setText(sprintf("%s", origin_airport ~ " " ~ rwy_num)); - line2Left.setColor(0,255,0,255); - line3Left.setText(sprintf("%s", "")); - line3Left.setColor(255,255,255,255); - if (sel_sid != rwy_sids[current_page_prop*4-4]) { - line4Left.setText(sprintf("%s", rwy_sids[current_page_prop*4-4])); - } else { - line4Left.setText(sprintf("%s", rwy_sids[current_page_prop*4-4] ~ " [SEL]")); - } - line4Left.setColor(0,255,0,255); - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - isrSids(origin_airport, rwy_sids[current_page_prop*4-4]); - if (size(listSidTran()) > 0) { - page_title_text = "SID TRANSITIONS"; - current_page_prop = 1; - } - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - line5Left.setText(sprintf("%s", "")); - line5Left.setColor(255,255,255,255); - if (math.fmod(size(rwy_sids),4) == 2 or math.fmod(size(rwy_sids),4) == 3 or math.fmod(size(rwy_sids),4) == 0 or current_page_prop < total_page_prop) { - if (sel_sid != rwy_sids[current_page_prop*4-3]) { - line4Right.setText(sprintf("%s", rwy_sids[current_page_prop*4-3])); - } else { - line4Right.setText(sprintf("%s", rwy_sids[current_page_prop*4-3] ~ " [SEL]")); - } - var press = getprop("/instrumentation/fmz/fmz-key-R2-press"); - if (R2_press_orig == 0 and press == 1) { - isrSids(origin_airport, rwy_sids[current_page_prop*4-3]); - if (size(listSidTran()) > 0) { - page_title_text = "SID TRANSITIONS"; - current_page_prop = 1; - } - } - R2_press_orig = getprop("/instrumentation/fmz/fmz-key-R2-press"); - } else { - line4Right.setText(sprintf("%s", "")); - } - line6Left.setColor(0,255,0,255); - line7Left.setText(sprintf("%s", "")); - line7Left.setColor(255,255,255,255); - line1Mid.setText(sprintf("%s", "")); - line1Mid.setColor(255,255,255,255); - line2Mid.setText(sprintf("%s", "")); - line2Mid.setColor(255,255,255,255); - line3Mid.setText(sprintf("%s", "")); - line3Mid.setColor(255,255,255,255); - line4Mid.setText(sprintf("%s", "")); - line4Mid.setColor(255,255,255,255); - line5Mid.setText(sprintf("%s", "")); - line5Mid.setColor(255,255,255,255); - line6Mid.setText(sprintf("%s", "")); - line6Mid.setColor(255,255,255,255); - line7Mid.setText(sprintf("%s", "")); - line7Mid.setColor(255,255,255,255); - line1Right.setText(sprintf("%s", "")); - line1Right.setColor(255,255,255,255); - line2Right.setText(sprintf("%s", "")); - line2Right.setColor(255,255,255,255); - line3Right.setText(sprintf("%s", "")); - line3Right.setColor(255,255,255,255); - if (math.fmod(size(rwy_sids),4) == 3 or math.fmod(size(rwy_sids),4) == 0 or current_page_prop < total_page_prop) { - if (sel_sid != rwy_sids[current_page_prop*4-2]) { - line6Left.setText(sprintf("%s", rwy_sids[current_page_prop*4-2])); - } else { - line6Left.setText(sprintf("%s", "[SEL] " ~ rwy_sids[current_page_prop*4-2])); - } - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - isrSids(origin_airport, rwy_sids[current_page_prop*4-2]); - if (size(listSidTran()) > 0) { - page_title_text = "SID TRANSITIONS"; - current_page_prop = 1; - } - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - } else { - line6Left.setText(sprintf("%s", "")); - } - line4Right.setColor(0,255,0,255); - line5Right.setText(sprintf("%s", "")); - line5Right.setColor(255,255,255,255); - if (math.fmod(size(rwy_sids),4) == 0 or current_page_prop < total_page_prop) { - if (sel_sid != rwy_sids[current_page_prop*4-1]) { - line6Right.setText(sprintf("%s", rwy_sids[current_page_prop*4-1])); - } else { - line6Right.setText(sprintf("%s", "[SEL] " ~ rwy_sids[current_page_prop*4-1])); - } - var press = getprop("/instrumentation/fmz/fmz-key-R3-press"); - if (R3_press_orig == 0 and press == 1) { - isrSids(origin_airport, rwy_sids[current_page_prop*4-1]); - if (size(listSidTran()) > 0) { - page_title_text = "SID TRANSITIONS"; - current_page_prop = 1; - } - } - R3_press_orig = getprop("/instrumentation/fmz/fmz-key-R3-press"); - - } else { - line6Right.setText(sprintf("%s", "")); - } - line6Right.setColor(0,255,0,255); - line7Right.setText(sprintf("%s", "ACTIVATE ▶")); - line7Right.setColor(255,255,255,255); - } - } - fmz_setlistener(pageSids); - - var pageSidTran = func () { - if (page_title_text == "SID TRANSITIONS") { - eachPageInit(); - var sid_tran_size = size(listSidTran()); - var sid_tran_list = listSidTran(); - total_page_prop = math.ceil(sid_tran_size / 4); - - var press = getprop("/instrumentation/fmz/fmz-key-R4-press"); - if (R4_press_orig == 0 and press == 1) { - is_active = 1; - page_title_text = "ACTIVE FLT PLAN"; - current_page_prop = 1; - } - R4_press_orig = getprop("/instrumentation/fmz/fmz-key-R4-press"); - - currentPage.setText(sprintf("%d", current_page_prop)); - currentPage.setColor(255,255,255,255); - totalPage.setText(sprintf("%d",total_page_prop)); - totalPage.setColor(255,255,255,255); - pageTitle.setText("SID TRANSITIONS"); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setText(""); - line1Left.setText(""); - line2Left.setText(sprintf("%s", sel_sid)); - line2Left.setColor(0,255,0,255); - - if (current_page_prop == total_page_prop and math.fmod(sid_tran_size, 4) == 1) { - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - isrSidTran(sid_tran_list[current_page_prop * 4 - 4]); - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - if (sel_sid_tran == sid_tran_list[current_page_prop * 4 - 4]) { - line4Left.setText(sid_tran_list[current_page_prop * 4 - 4] ~ " [SEL]"); - } else { - line4Left.setText(sid_tran_list[current_page_prop * 4 - 4]); - } - line4Left.setColor(0,255,0,255); - line6Left.setText(""); - line4Right.setText(""); - line6Right.setText(""); - } - - if (current_page_prop == total_page_prop and math.fmod(sid_tran_size, 4) == 2) { - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - isrSidTran(sid_tran_list[current_page_prop * 4 - 4]); - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R2-press"); - if (R2_press_orig == 0 and press == 1) { - isrSidTran(sid_tran_list[current_page_prop * 4 - 3]); - } - R2_press_orig = getprop("/instrumentation/fmz/fmz-key-R2-press"); - - if (sel_sid_tran == sid_tran_list[current_page_prop * 4 - 4]) { - line4Left.setText(sid_tran_list[current_page_prop * 4 - 4] ~ " [SEL]"); - } else { - line4Left.setText(sid_tran_list[current_page_prop * 4 - 4]); - } - line4Left.setColor(0,255,0,255); - - if (sel_sid_tran == sid_tran_list[current_page_prop * 4 - 3]){ - line4Right.setText("[SEL] " ~ sid_tran_list[current_page_prop * 4 - 3]); - } else { - line4Right.setText(sid_tran_list[current_page_prop * 4 - 3]); - } - line4Right.setColor(0,255,0,255); - line4Left.setText(""); - line6Right.setText(""); - } - - if (current_page_prop == total_page_prop and math.fmod(sid_tran_size, 4) == 3) { - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - isrSidTran(sid_tran_list[current_page_prop * 4 - 4]); - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R2-press"); - if (R2_press_orig == 0 and press == 1) { - isrSidTran(sid_tran_list[current_page_prop * 4 - 3]); - } - R2_press_orig = getprop("/instrumentation/fmz/fmz-key-R2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - isrSidTran(sid_tran_list[current_page_prop * 4 - 2]); - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (sel_sid_tran == sid_tran_list[current_page_prop * 4 - 4]) { - line4Left.setText(sid_tran_list[current_page_prop * 4 - 4] ~ " [SEL]"); - } else { - line4Left.setText(sid_tran_list[current_page_prop * 4 - 4]); - } - line4Left.setColor(0,255,0,255); - if (sel_sid_tran == sid_tran_list[current_page_prop * 4 - 2]) { - line6Left.setText(sid_tran_list[current_page_prop * 4 - 2] ~ " [SEL]"); - } else { - line6Left.setText(sid_tran_list[current_page_prop * 4 - 2]); - } - line6Left.setColor(0,255,0,255); - if (sel_sid_tran == sid_tran_list[current_page_prop * 4 - 3]){ - line4Right.setText("[SEL] " ~ sid_tran_list[current_page_prop * 4 - 3]); - } else { - line4Right.setText(sid_tran_list[current_page_prop * 4 - 3]); - } - line4Right.setColor(0,255,0,255); - line6Right.setText(""); - } - - if (current_page_prop == total_page_prop and math.fmod(sid_tran_size, 4) == 0) { - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - isrSidTran(sid_tran_list[current_page_prop * 4 - 4]); - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R2-press"); - if (R2_press_orig == 0 and press == 1) { - isrSidTran(sid_tran_list[current_page_prop * 4 - 3]); - } - R2_press_orig = getprop("/instrumentation/fmz/fmz-key-R2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - isrSidTran(sid_tran_list[current_page_prop * 4 - 2]); - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R3-press"); - if (R3_press_orig == 0 and press == 1) { - isrSidTran(sid_tran_list[current_page_prop * 4 - 1]); - } - R3_press_orig = getprop("/instrumentation/fmz/fmz-key-R3-press"); - - if (sel_sid_tran == sid_tran_list[current_page_prop * 4 - 4]) { - line4Left.setText(sid_tran_list[current_page_prop * 4 - 4] ~ " [SEL]"); - } else { - line4Left.setText(sid_tran_list[current_page_prop * 4 - 4]); - } - line4Left.setColor(0,255,0,255); - if (sel_sid_tran == sid_tran_list[current_page_prop * 4 - 2]) { - line6Left.setText(sid_tran_list[current_page_prop * 4 - 2] ~ " [SEL]"); - } else { - line6Left.setText(sid_tran_list[current_page_prop * 4 - 2]); - } - line6Left.setColor(0,255,0,255); - if (sel_sid_tran == sid_tran_list[current_page_prop * 4 - 3]){ - line4Right.setText("[SEL] " ~ sid_tran_list[current_page_prop * 4 - 3]); - } else { - line4Right.setText(sid_tran_list[current_page_prop * 4 - 3]); - } - line4Right.setColor(0,255,0,255); - if (sel_sid_tran == sid_tran_list[current_page_prop * 4 - 1]) { - line6Right.setText("[SEL] " ~ sid_tran_list[current_page_prop * 4 - 1]); - } else { - line6Right.setText(sid_tran_list[current_page_prop * 4 - 1]); - } - line6Right.setColor(0,255,0,255); - } - - if (current_page_prop < total_page_prop) { - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - isrSidTran(sid_tran_list[current_page_prop * 4 - 4]); - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R2-press"); - if (R2_press_orig == 0 and press == 1) { - isrSidTran(sid_tran_list[current_page_prop * 4 - 3]); - } - R2_press_orig = getprop("/instrumentation/fmz/fmz-key-R2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - isrSidTran(sid_tran_list[current_page_prop * 4 - 2]); - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R3-press"); - if (R3_press_orig == 0 and press == 1) { - isrSidTran(sid_tran_list[current_page_prop * 4 - 1]); - } - R3_press_orig = getprop("/instrumentation/fmz/fmz-key-R3-press"); - if (sel_sid_tran == sid_tran_list[current_page_prop * 4 - 4]) { - line4Left.setText(sid_tran_list[current_page_prop * 4 - 4] ~ " [SEL]"); - } else { - line4Left.setText(sid_tran_list[current_page_prop * 4 - 4]); - } - line4Left.setColor(0,255,0,255); - if (sel_sid_tran == sid_tran_list[current_page_prop * 4 - 2]) { - line6Left.setText(sid_tran_list[current_page_prop * 4 - 2] ~ " [SEL]"); - } else { - line6Left.setText(sid_tran_list[current_page_prop * 4 - 2]); - } - line6Left.setColor(0,255,0,255); - if (sel_sid_tran == sid_tran_list[current_page_prop * 4 - 3]){ - line4Right.setText("[SEL] " ~ sid_tran_list[current_page_prop * 4 - 3]); - } else { - line4Right.setText(sid_tran_list[current_page_prop * 4 - 3]); - } - line4Right.setColor(0,255,0,255); - if (sel_sid_tran == sid_tran_list[current_page_prop * 4 - 1]) { - line6Right.setText("[SEL] " ~ sid_tran_list[current_page_prop * 4 - 1]); - } else { - line6Right.setText(sid_tran_list[current_page_prop * 4 - 1]); - } - line6Right.setColor(0,255,0,255); - } - - line3Left.setText(""); - line5Left.setText(""); - line7Left.setText(""); - line1Mid.setText(""); - line2Mid.setText(""); - line3Mid.setText(""); - line4Mid.setText(""); - line5Mid.setText(""); - line6Mid.setText(""); - line7Mid.setText(""); - line1Right.setText(""); - line2Right.setText(""); - line3Right.setText(""); - line5Right.setText(""); - line7Right.setText("ACTIVATE ▶"); - line7Right.setColor(255,255,255,255); - } - } - fmz_setlistener(pageSidTran); - - var pagePerformanceInit = func (){ - if (page_title_text == "PERFORMANCE INIT") { - if (current_page_prop == 1) { - eachPageInit(); - perf_page_read[0] = 1; - total_page_prop = 5; - currentPage.setText(sprintf("%d", current_page_prop)); - currentPage.setColor(255,255,255,255); - totalPage.setText(sprintf("%d",total_page_prop)); - totalPage.setColor(255,255,255,255); - pageTitle.setText(sprintf("%s", "PERFORMANCE INIT")); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setText(sprintf("%s", "")); - var press = getprop("/instrumentation/fmz/fmz-key-R1-press"); - if (R1_press_orig == 0 and press == 1 and scratch_pad_text != "") { - acft_tail_num = scratch_pad_text; - scratch_pad_text = ""; - } else if (R1_press_orig == 0 and press == 1 and scratch_pad_message == "DELETE") { - acft_tail_num = ""; - scratch_pad_message = ""; - } else if (R1_press_orig == 0 and press == 1) { - scratch_pad_message = "INVALID INPUT"; - } - R1_press_orig = getprop("/instrumentation/fmz/fmz-key-R1-press"); - - line1Left.setText(sprintf("%s", "ACFT TYPE")); - line1Left.setColor(255,255,255,255); - line2Left.setText("BD-700"); - line2Left.setColor(0,255,0,255); - line3Left.setText(sprintf("%s", "PERF MODE")); - line3Left.setColor(255,255,255,255); - line4Left.setText(sprintf("%s", perf_mode)); - line4Left.setColor(0,255,0,255); - line5Left.setText(sprintf("%s", "")); - line6Left.setText(sprintf("%s", "")); - line7Left.setText(sprintf("%s", "")); - line1Mid.setText(sprintf("%s", "")); - line2Mid.setText(sprintf("%s", "")); - line3Mid.setText(sprintf("%s", "")); - line4Mid.setText(sprintf("%s", "")); - line5Mid.setText(sprintf("%s", "")); - line6Mid.setText(sprintf("%s", "")); - line7Mid.setText(sprintf("%s", "")); - line1Right.setText(sprintf("%s", "TAIL #")); - line1Right.setColor(255,255,255,255); - if (acft_tail_num == "") { - line2Right.setText(sprintf("%s", "------")); - line2Right.setColor(0,174,255,255); - } else { - line2Right.setText(sprintf("%s", acft_tail_num)); - line2Right.setColor(0,174,255,255); - } - line3Right.setText(sprintf("%s", "")); - line4Right.setText(sprintf("%s", "OR ▶")); - line4Right.setColor(255,255,255,255); - line5Right.setText(sprintf("%s", "")); - line6Right.setText(sprintf("%s", "")); - line7Right.setText(sprintf("%s", "")); - } - if (current_page_prop == 2) { - eachPageInit(); - perf_page_read[1] = 1; - total_page_prop = 5; - currentPage.setText(sprintf("%d", current_page_prop)); - currentPage.setColor(255,255,255,255); - totalPage.setText(sprintf("%d",total_page_prop)); - totalPage.setColor(255,255,255,255); - pageTitle.setText(sprintf("%s", "PERFORMANCE INIT")); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setText(sprintf("%s", "")); - - var clb_spd_text = sprintf("%3d", clb_ias) ~ "/." ~ sprintf("%2d", (clb_mach*100)) ~ "M"; - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1 and scratch_pad_message == "DELETE") { - clb_ias = 300; - clb_mach = 0.80; - scratch_pad_message = ""; - } else if (L1_press_orig == 0 and press == 1) { - scratch_pad_message = "INVALID INPUT"; - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1 and scratch_pad_message == "DELETE") { - crs_perf_type = "LRC"; - scratch_pad_message = ""; - } else if (L2_press_orig == 0 and press == 1) { - scratch_pad_message = "INVALID INPUT"; - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1 and scratch_pad_message == "DELETE") { - des_ias = 300; - des_mach = 0.80; - des_path_deg = 3.0; - scratch_pad_message = ""; - } else if (L3_press_orig == 0 and press == 1) { - scratch_pad_message = "INVALID INPUT"; - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L4-press"); - if (L4_press_orig == 0 and press == 1) { - page_title_text = "DEP/APP SPD"; - current_page_prop = 1; - } - L4_press_orig = getprop("/instrumentation/fmz/fmz-key-L4-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R1-press"); - if (R1_press_orig == 0 and press == 1) { - page_title_text = "CLIMB MODES"; - current_page_prop = 1; - } - R1_press_orig = getprop("/instrumentation/fmz/fmz-key-R1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R2-press"); - if (R2_press_orig == 0 and press == 1) { - page_title_text = "CRUISE MODES"; - current_page_prop = 1; - } - R2_press_orig = getprop("/instrumentation/fmz/fmz-key-R2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R3-press"); - if (R3_press_orig == 0 and press == 1) { - page_title_text = "DESCENT MODES"; - current_page_prop = 1; - } - R3_press_orig = getprop("/instrumentation/fmz/fmz-key-R3-press"); - - line1Left.setText(sprintf("%s", "CLIMB")); - line1Left.setColor(255,255,255,255); - line2Left.setText(sprintf("%3d", clb_ias) ~ "/." ~ sprintf("%2d", (clb_mach*100)) ~ "ᴍ"); - line2Left.setColor(0,174,255,255); - line3Left.setText(sprintf("%s", "CRUISE")); - line3Left.setColor(255,255,255,255); - if (crs_perf_type == "MANUAL") { - line4Left.setText(sprintf("%3d", crs_ias) ~ "/." ~ sprintf("%2d", (crs_mach*100)) ~ "ᴍ"); - } else { - line4Left.setText(sprintf("%s", crs_perf_type)); - } - line4Left.setColor(0,174,255,255); - line5Left.setText(sprintf("%s", "DESCENT")); - line5Left.setColor(255,255,255,255); - if (des_ias == 340 and des_mach == 0.86 and des_path_deg == 4.0) { - line6Left.setText(sprintf("%s", "VMO/MMO/4.0°")); - } else { - line6Left.setText(sprintf("%3d", des_ias) ~ "/." ~ sprintf("%2d", (des_mach*100)) ~ "ᴍ/" ~ sprintf("%1.1f", des_path_deg) ~ "°"); - } - line6Left.setColor(0,174,255,255); - line7Left.setText(sprintf("%s", "◀ DEP/APP SPD")); - line7Left.setColor(255,255,255,255); - line1Mid.setText(sprintf("%s", "")); - line2Mid.setText(sprintf("%s", "")); - line3Mid.setText(sprintf("%s", "")); - line4Mid.setText(sprintf("%s", "")); - line5Mid.setText(sprintf("%s", "")); - line6Mid.setText(sprintf("%s", "")); - line7Mid.setText(sprintf("%s", "")); - line1Right.setText(sprintf("%s", "")); - line2Right.setText(sprintf("%s", "OR ▶")); - line2Right.setColor(255,255,255,255); - line3Right.setText(sprintf("%s", "")); - line4Right.setText(sprintf("%s", "OR ▶")); - line4Right.setColor(255,255,255,255); - line5Right.setText(sprintf("%s", "")); - line6Right.setText(sprintf("%s", "OR ▶")); - line6Right.setColor(255,255,255,255); - line7Right.setText(sprintf("%s", "")); - } - - if (current_page_prop == 3) { - eachPageInit(); - perf_page_read[2] = 1; - total_page_prop = 5; - currentPage.setText(sprintf("%d", current_page_prop)); - currentPage.setColor(255,255,255,255); - totalPage.setText(sprintf("%d",total_page_prop)); - totalPage.setColor(255,255,255,255); - pageTitle.setText("PERFORMANCE INIT-LB"); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setText(""); - line1Left.setText("STEP INCREMENT"); - line1Left.setColor(255,255,255,255); - line1Mid.setText(""); - line1Right.setText(""); - line2Left.setText(sprintf("%d", step_incm)); - line2Left.setColor(0,174,255,255); - line2Mid.setText(""); - line2Right.setText(""); - line3Left.setText("FUEL RESERVE"); - line3Left.setColor(255,255,255,255); - line3Mid.setText(""); - line3Right.setText(""); - line4Left.setText(sprintf("%s", fuel_rsv_mode)); - line4Left.setColor(0,174,255,255); - line4Mid.setText(""); - line4Right.setText("OR ▶"); - line4Right.setColor(255,255,255,255); - line5Left.setText("TO/LDG FUEL"); - line5Left.setColor(255,255,255,255); - line5Mid.setText(""); - line5Right.setText(""); - var to_ldg_fuel_text = sprintf("%03d", to_fuel) ~ "/" ~ sprintf("%03d", ldg_fuel) ~ " ʟʙ"; - line6Left.setText(to_ldg_fuel_text); - line6Left.setColor(0,174,255,255); - line6Mid.setText(""); - line6Right.setText(""); - line7Left.setText(""); - line7Mid.setText(""); - line7Right.setText(""); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - if(num(scratch_pad_text) != nil){ - if (num(scratch_pad_text) >= 0 and num(scratch_pad_text) <= 20) { - step_incm = num(scratch_pad_text); - scratch_pad_text = ""; - } - } else { - scratch_pad_message = "INVALID INPUT"; - } - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R2-press"); - if (R2_press_orig == 0 and press == 1) { - page_title_text = "FUEL RESERVE"; - current_page_prop = 1; - } - R2_press_orig = getprop("/instrumentation/fmz/fmz-key-R2-press"); - } - - if (current_page_prop == 4) { - eachPageInit(); - perf_page_read[3] = 1; - total_page_prop = 5; - currentPage.setText(sprintf("%d", current_page_prop)); - currentPage.setColor(255,255,255,255); - totalPage.setText(sprintf("%d",total_page_prop)); - totalPage.setColor(255,255,255,255); - pageTitle.setText("PERFORMANCE INIT"); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setText(""); - line1Left.setText("TRANS ALT"); - line1Left.setColor(255,255,255,255); - line1Mid.setText(""); - line1Right.setText("SPD/ALT LIM"); - line1Right.setColor(255,255,255,255); - line2Left.setText(sprintf("%d", trans_alt)); - line2Left.setColor(0,174,255,255); - line2Mid.setText(""); - line2Right.setText(sprintf("%d", spd_alt_lim_s) ~ "/" ~ sprintf("%d", spd_alt_lim_a)); - line2Right.setColor(0,174,255,255); - line3Left.setText("INIT CRZ ALT"); - line3Left.setColor(255,255,255,255); - line3Mid.setText(""); - line3Right.setText("ISA DEV"); - line3Right.setColor(255,255,255,255); - - if (init_crz_alt_mod == "OPTIMUM") { - if (init_crz_alt < 0) { - line4Left.setText("OPTIMUM"); - line4Left.setFontSize(48, 1); - } else { - var init_fl = init_crz_alt / 100; - line4Left.setText("FL" ~ sprintf("%03d", init_fl) ~ " (OPTIMUM)"); - line4Left.setFontSize(36, 1); - } - } else if (init_crz_alt_mod == "MANUAL") { - var init_fl = init_crz_alt / 100; - line4Left.setText("FL" ~ sprintf("%03d", init_fl)); - line4Left.setFontSize(48, 1); - } else { - line4Left.setText(init_crz_alt_mod); - } - - line4Left.setColor(0,174,255,255); - line4Mid.setText(""); - if (isa_dev_c < 0) { - line4Right.setText(sprintf("%d", isa_dev_c) ~ "°C"); - } else { - line4Right.setText("+" ~ sprintf("%d", isa_dev_c) ~ "°C"); - } - - line4Right.setColor(0,174,255,255); - line5Left.setText("CRZ WINDS"); - line5Left.setColor(255,255,255,255); - line5Mid.setText(""); - line5Right.setText("AT ALTITUDE"); - line5Right.setColor(255,255,255,255); - line6Left.setText(sprintf("%d", crz_wind_d) ~ "ᴛ" ~ "/" ~ sprintf("%d", crz_wind_s)); - line6Left.setColor(0,174,255,255); - line6Mid.setText(""); - if (init_crz_alt > 0) { - crz_wind_at_alt = init_crz_alt; - } else { - crz_wind_at_alt = 40000; - } - var crz_wind_at_fl = crz_wind_at_alt / 100; - line6Right.setText("FL" ~ sprintf("%03d", crz_wind_at_fl)); - line6Right.setColor(0,174,255,255); - line7Left.setText("◀ PERF PLAN"); - line7Left.setColor(255,255,255,255); - line7Mid.setText(""); - line7Right.setText(""); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - var trans_alt_inp = num(scratch_pad_text) or -9999; - if (trans_alt_inp >= 0 and trans_alt_inp < 99999) { - trans_alt = trans_alt_inp; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - var press = getprop("/instrumentation/fmz/fmz-key-R1-press"); - if (R1_press_orig == 0 and press == 1) { - var sal_inp = scratch_pad_text; - var sal_slash_pos = find("/", sal_inp); - var grab_spd_lim = substr(sal_inp, 0, sal_slash_pos); - grab_spd_lim = num(grab_spd_lim); - var grab_lim_alt = substr(sal_inp, (sal_slash_pos + 1)); - grab_lim_alt = num(grab_lim_alt); - if (sal_slash_pos == 3 and grab_lim_alt != nil and grab_spd_lim != nil) { - spd_alt_lim_s = grab_spd_lim; - spd_alt_lim_a = grab_lim_alt; - } else if (sal_slash_pos == 0 and grab_lim_alt != nil) { - spd_alt_lim_a = grab_lim_alt; - } else if (sal_slash_pos == 3 and size(sal_inp) == 4 and grab_spd_lim != nil) { - spd_alt_lim_s = grab_spd_lim; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - R1_press_orig = getprop("/instrumentation/fmz/fmz-key-R1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - var init_alt_inp = scratch_pad_text; - var grab_fl_mark = substr(init_alt_inp, 0, 2); - var num_init_alt = num(init_alt_inp) or -9999; - if (grab_fl_mark == "FL") { - var grab_fl = substr(init_alt_inp, 2, 3); - grab_fl = num(grab_fl); - init_crz_alt = grab_fl * 100; - init_crz_alt_mod = "MANUAL"; - } else if (num_init_alt >= 0) { - init_crz_alt = init_alt_inp; - init_crz_alt_mod = "MANUAL"; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R2-press"); - if (R2_press_orig == 0 and press == 1) { - var isa_dev_inp = num(scratch_pad_text) or -9999; - if (abs(isa_dev_inp) < 100) { - isa_dev_c = isa_dev_inp; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - R2_press_orig = getprop("/instrumentation/fmz/fmz-key-R2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - var crz_wind_inp = scratch_pad_text; - var wind_dir_inp = substr(crz_wind_inp, 0, 3); - wind_dir_inp = num(wind_dir_inp) or -9999; - var dir_inp_vld = (wind_dir_inp >=0 and wind_dir_inp <= 359); - var wind_slh_pos = find("/", crz_wind_inp); - var wind_spd_inp = substr(crz_wind_inp, wind_slh_pos + 1); - wind_spd_inp = num(wind_spd_inp) or -9999; - var spd_inp_vld = (wind_spd_inp >=0); - var tur_pos = find("T", crz_wind_inp); - var mag_pos = find("M", crz_wind_inp); - if (wind_slh_pos == 4 and tur_pos == 3) { - wind_slh_pos = 3; - } else if (wind_slh_pos == 4 and mag_pos == 3) { - var mag_var = getprop("/environment/magnetic-variation-deg") or 0; - wind_slh_pos = 3; - wind_dir_inp = wind_dir_inp + mag_var; - } - wind_dir_inp = math.fmod(wind_dir_inp, 360); - if (wind_dir_inp < 0) { - wind_dir_inp = wind_dir_inp + 360; - } - if (wind_slh_pos == 3 and dir_inp_vld and spd_inp_vld) { - crz_wind_d = wind_dir_inp; - crz_wind_s = wind_spd_inp; - } else if (wind_slh_pos == 3 and dir_inp_vld) { - crz_wind_d = wind_dir_inp; - } else if (wind_slh_pos == 0 and spd_inp_vld) { - crz_wind_s = wind_spd_inp; - - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R3-press"); - if (R3_press_orig == 0 and press == 1) { - var wind_at_alt_inp = scratch_pad_text; - var grab_fl_mark = substr(wind_at_alt_inp, 0, 2); - var num_wind_at_alt = num(wind_at_alt_inp) or -9999; - if (grab_fl_mark == "FL") { - var grab_fl = substr(wind_at_alt_inp, 2, 3); - grab_fl = num(grab_fl); - crz_wind_at_alt = grab_fl * 100; - } else if (num_init_alt >= 0) { - crz_wind_at_alt = init_alt_inp; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - R3_press_orig = getprop("/instrumentation/fmz/fmz-key-R3-press"); - } - - if (current_page_prop == 5) { - eachPageInit(); - perf_page_read[4] = 1; - total_page_prop = 5; - currentPage.setText(sprintf("%d", current_page_prop)); - currentPage.setColor(255,255,255,255); - totalPage.setText(sprintf("%d",total_page_prop)); - totalPage.setColor(255,255,255,255); - pageTitle.setText("PERFORMANCE INIT-LB"); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setText(""); - line1Left.setText("BOW"); - line1Mid.setText(""); - line1Right.setText("PASS/@ LB"); - line2Left.setText(sprintf("%d", bsc_oprt_wght)); - line2Left.setColor(0,174,255,255); - line2Mid.setText(""); - if (pax_number <= 30 and weight_per_pax >= 0) { - line2Right.setText(sprintf("%d", pax_number) ~ "/" ~ sprintf("%d", weight_per_pax)); - } else { - line2Right.setText("--" ~ "/" ~ "---"); - } - line2Right.setColor(0,174,255,255); - line3Left.setText(" FUEL (GAUGE)"); - line3Mid.setText(""); - line3Right.setText("PASS WT"); - var gauge_fuel_lbs = getprop("/consumables/fuel/total-fuel-lbs"); - line4Left.setText(sprintf("%d", total_fuel_lbs_inp) ~ " (" ~ sprintf("%d", gauge_fuel_lbs) ~ ")"); - - if (fuel_qnt_snsr == 1) { - line4Left.setFontSize(36, 1); - } else { - line4Left.setFontSize(48, 1); - } - - line4Left.setColor(0,174,255,255); - line4Mid.setText(""); - - var ttl_pax_wght = pax_number * weight_per_pax; - if (ttl_pax_wght >= 0) { - line4Right.setText(sprintf("%d", ttl_pax_wght)); - } else { - line4Right.setText("-----"); - } - - line4Right.setColor(0,174,255,255); - line5Left.setText("CARGO"); - line5Mid.setText(""); - line5Right.setText("GROSS WT"); - - if (cargo_weight < 0) { - line6Left.setText("---"); - } else { - line6Left.setText(sprintf("%d", cargo_weight)); - } - - line6Left.setColor(0,174,255,255); - line6Mid.setText(""); - - if (bsc_oprt_wght >= 0 and cargo_weight >= 0 and ttl_pax_wght >= 0 and total_fuel_lbs_inp >= 0) { - var gross_weight = bsc_oprt_wght + cargo_weight + ttl_pax_wght + total_fuel_lbs_inp; - } else { - var gross_weight = -99999; - } - if (gross_weight > 0) { - line6Right.setText(sprintf("%d", gross_weight)); - } else { - line6Right.setText("-----"); - } - line6Right.setColor(0,174,255,255); - line7Left.setText(""); - line7Mid.setText(""); - if (checkPerfInit() == "can confirm"){ - line7Right.setText("CONFIRM INIT ▶"); - l7rRectangle.setVisible(1); - } else { - line7Right.setText(""); - l7rRectangle.setVisible(0); - } - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - var bow_inp = num(scratch_pad_text) or -9999; - if (bow_inp >= 0 and bow_inp < 98250) { - bsc_oprt_wght = bow_inp; - } else if (scratch_pad_message == "DELETE") { - bsc_oprt_wght = 45000; - scratch_pad_message = ""; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - var fuel_wght_pad = num(scratch_pad_text) or -9999; - if (fuel_wght_pad >= 0 and fuel_wght_pad <= 46586) { - fuel_qnt_snsr = 0; - total_fuel_lbs_inp = fuel_wght_pad; - } else if (scratch_pad_message == "DELETE") { - fuel_qnt_snsr = 1; - total_fuel_lbs_inp = getprop("/consumables/fuel/total-fuel-lbs"); - scratch_pad_message = ""; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - var cargo_wght_pad = num(scratch_pad_text) or -9999; - if (cargo_wght_pad >= 0) { - cargo_weight = cargo_wght_pad; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R1-press"); - if (R1_press_orig == 0 and press == 1) { - var pax_data_pad = scratch_pad_text; - var pax_slsh_pos = find("/", pax_data_pad); - var pax_data_size = size(pax_data_pad); - if (pax_slsh_pos == 0) { - var sub_wght_per_pax = substr(pax_data_pad, (pax_slsh_pos + 1)); - sub_wght_per_pax = num(sub_wght_per_pax) or -9999; - if (sub_wght_per_pax >= 0) { - weight_per_pax = sub_wght_per_pax; - } else { - scratch_pad_message = "INVALID INPUT"; - } - } else if (pax_slsh_pos > 0 and pax_slsh_pos == (pax_data_size - 1)) { - var sub_pax_num = substr(pax_data_pad, 0, pax_slsh_pos); - sub_pax_num = num(sub_pax_num) or -9999; - if (sub_pax_num >= 0 and sub_pax_num <= 30) { - pax_number = sub_pax_num; - } else { - scratch_pad_message = "INVALID INPUT"; - } - } else if (pax_slsh_pos > 0) { - var sub_pax_num = substr(pax_data_pad, 0, pax_slsh_pos); - sub_pax_num = num(sub_pax_num) or -9999; - var sub_wght_per_pax = substr(pax_data_pad, (pax_slsh_pos + 1)); - sub_wght_per_pax = num(sub_wght_per_pax) or -9999; - if (sub_wght_per_pax >= 0 and sub_pax_num >= 0 and sub_pax_num <= 30) { - pax_number = sub_pax_num; - weight_per_pax = sub_wght_per_pax; - } else { - scratch_pad_message = "INVALID INPUT"; - } - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - R1_press_orig = getprop("/instrumentation/fmz/fmz-key-R1-press"); - var press = getprop("/instrumentation/fmz/fmz-key-R4-press"); - if (R4_press_orig == 0 and press == 1) { - if (init_crz_alt_mod == "OPTIMUM" and checkPerfInit() == "can confirm") { - bsc_oprt_wght1 = bsc_oprt_wght; - cargo_weight1 = cargo_weight; - pax_number1 = pax_number; - weight_per_pax1 = weight_per_pax; - init_crz_alt_mod1 = init_crz_alt_mod; - fuel_opm_alt_prd(); - init_crz_alt = opm_init_alt; - init_crz_alt1 = init_crz_alt; - crn_crz_alt = init_crz_alt; - page_title_text = "PERF DATA"; - current_page_prop = 1; - } else if (checkPerfInit() == "can confirm") { - bsc_oprt_wght1 = bsc_oprt_wght; - cargo_weight1 = cargo_weight; - pax_number1 = pax_number; - weight_per_pax1 = weight_per_pax; - init_crz_alt_mod1 = init_crz_alt_mod; - init_crz_alt1 = init_crz_alt; - fuel_opm_alt_prd(); - crn_crz_alt = init_crz_alt; - page_title_text = "PERF DATA"; - current_page_prop = 1; - } else if (checkPerfInit() == "incompleted") { - scratch_pad_message = "INCOMPLETED INPUT"; - } else if (checkPerfInit() == "don't need") { - page_title_text = "PERF DATA"; - current_page_prop = 1; - } - } - R4_press_orig = getprop("/instrumentation/fmz/fmz-key-R4-press"); - } - } - } - fmz_setlistener(pagePerformanceInit); - - var pageClimbModes = func(){ - if (page_title_text == "CLIMB MODES") { - eachPageInit(); - total_page_prop = 1; - pageTitle.setText(sprintf("%s", "CLIMB MODES")); - pageTitleRight.setText(sprintf("%s", "")); - currentPage.setText(sprintf("%d", current_page_prop)); - totalPage.setText(sprintf("%d", total_page_prop)); - line1Left.setText(sprintf("%s", "MANUAL")); - line1Left.setColor(255,255,255,255); - if (clb_ias == 300 and clb_mach == 0.80) { - line2Left.setText(sprintf("%3d", clb_ias) ~ "/." ~ sprintf("%2d", (clb_mach*100)) ~ "M"); - line2Left.setFontSize(36, 1); - } else { - line2Left.setText(sprintf("%3d", clb_ias) ~ "/." ~ sprintf("%2d", (clb_mach*100)) ~ "ᴍ" ~ " [ACT]"); - line2Left.setFontSize(48, 1); - } - line2Left.setColor(0,174,255,255); - line3Left.setText(sprintf("%s", "")); - if (clb_ias == 300 and clb_mach == 0.80) { - line4Left.setText(sprintf("%s", "◀ 300/.80ᴍ [ACT]")); - line4Left.setFontSize(48, 1); - } else { - line4Left.setText(sprintf("%s", "◀ 300/.80M")); - line4Left.setFontSize(36, 1); - } - line4Left.setColor(0,174,255,255); - line5Left.setText(sprintf("%s", "")); - line6Left.setText(sprintf("%s", "")); - line7Left.setText(sprintf("%s", "")); - line1Mid.setText(sprintf("%s", "")); - line2Mid.setText(sprintf("%s", "")); - line3Mid.setText(sprintf("%s", "")); - line4Mid.setText(sprintf("%s", "")); - line5Mid.setText(sprintf("%s", "")); - line6Mid.setText(sprintf("%s", "")); - line7Mid.setText(sprintf("%s", "")); - line1Right.setText(sprintf("%s", "RETURN ▶")); - line1Right.setColor(255,255,255,255); - line2Right.setText(sprintf("%s", "")); - line3Right.setText(sprintf("%s", "")); - line4Right.setText(sprintf("%s", "")); - line5Right.setText(sprintf("%s", "")); - line6Right.setText(sprintf("%s", "")); - line7Right.setText(sprintf("%s", "")); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - var slash_pos = find("/", scratch_pad_text); - if (slash_pos == -1) { - scratch_pad_message = "INVALID INPUT"; - } else if (num(substr(scratch_pad_text, 0, slash_pos))==nil){ - if (num(substr(scratch_pad_text, slash_pos+1))==nil) { - scratch_pad_message = "INVALID INPUT"; - } - } else if (num(substr(scratch_pad_text, 0, slash_pos))!=nil){ - if (num(substr(scratch_pad_text, 0, slash_pos))>340) { - scratch_pad_message = "INVALID INPUT"; - } - } else if (num(substr(scratch_pad_text, slash_pos+1))!=nil) { - if (num(substr(scratch_pad_text, slash_pos+1))>=0.90) { - scratch_pad_message = "INVALID INPUT"; - } - } - if (scratch_pad_message != "INVALID INPUT") { - if (num(substr(scratch_pad_text, 0, slash_pos))!=nil) { - clb_ias = num(substr(scratch_pad_text, 0, slash_pos)); - } - if (num(substr(scratch_pad_text, slash_pos+1))!=nil) { - clb_mach = num(substr(scratch_pad_text, slash_pos+1)); - } - line2Left.setFontSize(48, 1); - line4Left.setFontSize(48, 1); - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 2; - scratch_pad_text = ""; - } - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - clb_ias = 300; - clb_mach = 0.8; - line2Left.setFontSize(48, 1); - line4Left.setFontSize(48, 1); - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 2; - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R1-press"); - if (R1_press_orig == 0 and press == 1) { - line2Left.setFontSize(48, 1); - line4Left.setFontSize(48, 1); - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 2; - } - R1_press_orig = getprop("/instrumentation/fmz/fmz-key-R1-press"); - } - } - fmz_setlistener(pageClimbModes); - - var pageCruiseModes = func() { - if (page_title_text == "CRUISE MODES") { - eachPageInit(); - total_page_prop = 1; - pageTitle.setText(sprintf("%s", "CRUISE MODES")); - pageTitleRight.setText(""); - currentPage.setText(sprintf("%d", current_page_prop)); - totalPage.setText(sprintf("%d", total_page_prop)); - line1Left.setText("MANUAL"); - line1Left.setColor(255,255,255,255); - line1Mid.setText(""); - line1Right.setText("RETURN ▶"); - line1Right.setColor(255,255,255,255); - if (crs_perf_type == "MANUAL") { - line2Left.setText(sprintf("%3d", crs_ias) ~ "/." ~ sprintf("%2d", (crs_mach*100)) ~ "ᴍ" ~ " [ACT]"); - line2Left.setFontSize(48, 1); - } else { - line2Left.setText(sprintf("%3d", crs_ias) ~ "/." ~ sprintf("%2d", (crs_mach*100)) ~ "M"); - line2Left.setFontSize(36, 1); - } - line2Left.setColor(0,174,255,255); - line2Mid.setText(""); - line2Right.setText(""); - line3Left.setText(""); - line3Mid.setText(""); - line3Right.setText(""); - if (crs_perf_type == "LRC") { - line4Left.setText("◀ LRC [ACT]"); - line4Left.setFontSize(48,1); - } else { - line4Left.setText("◀ LRC"); - line4Left.setFontSize(36,1); - } - line4Left.setColor(0,174,255,255); - line4Mid.setText(""); - if (crs_perf_type == "MAX END") { - line4Right.setText("[ACT] MAX END ▶"); - line4Right.setFontSize(48,1); - } else { - line4Right.setText("MAX END ▶"); - line4Right.setFontSize(36,1); - } - line4Right.setColor(0,174,255,255); - line5Left.setText(""); - line5Mid.setText(""); - line5Right.setText(""); - if (crs_perf_type == "MAX SPD") { - line6Left.setText("◀ MAX SPD [ACT]"); - line6Left.setFontSize(48,1); - } else { - line6Left.setText("◀ MAX SPD"); - line6Left.setFontSize(36,1); - } - line6Left.setColor(0,174,255,255); - line6Mid.setText(""); - line6Right.setText(""); - line7Left.setText(""); - line7Mid.setText(""); - line7Right.setText(""); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - var slash_pos = find("/", scratch_pad_text); - if (slash_pos == -1) { - scratch_pad_message = "INVALID INPUT"; - } else if (num(substr(scratch_pad_text, 0, slash_pos))==nil){ - if (num(substr(scratch_pad_text, slash_pos+1))==nil) { - scratch_pad_message = "INVALID INPUT"; - } - } else if (num(substr(scratch_pad_text, 0, slash_pos))!=nil){ - if (num(substr(scratch_pad_text, 0, slash_pos))>340) { - scratch_pad_message = "INVALID INPUT"; - } - } else if (num(substr(scratch_pad_text, slash_pos+1))!=nil) { - if (num(substr(scratch_pad_text, slash_pos+1))>=0.90) { - scratch_pad_message = "INVALID INPUT"; - } - } - if (scratch_pad_message != "INVALID INPUT") { - if (num(substr(scratch_pad_text, 0, slash_pos))!=nil) { - crs_ias = num(substr(scratch_pad_text, 0, slash_pos)); - } - if (num(substr(scratch_pad_text, slash_pos+1))!=nil) { - crs_mach = num(substr(scratch_pad_text, slash_pos+1)); - } - crs_perf_type = "MANUAL"; - line2Left.setFontSize(48, 1); - line4Left.setFontSize(48, 1); - line4Right.setFontSize(48, 1); - line6Left.setFontSize(48,1); - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 2; - scratch_pad_text = ""; - } - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - crs_perf_type = "LRC"; - crs_ias = 300; - crs_mach = 0.8; - line2Left.setFontSize(48, 1); - line4Left.setFontSize(48, 1); - line4Right.setFontSize(48, 1); - line6Left.setFontSize(48,1); - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 2; - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - crs_perf_type = "MAX SPD"; - crs_ias = 340; - crs_mach = 0.86; - line2Left.setFontSize(48, 1); - line4Left.setFontSize(48, 1); - line4Right.setFontSize(48, 1); - line6Left.setFontSize(48,1); - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 2; - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R2-press"); - if (R2_press_orig == 0 and press == 1) { - crs_perf_type = "MAX END"; - crs_ias = 230; - crs_mach = 0.62; - line2Left.setFontSize(48, 1); - line4Left.setFontSize(48, 1); - line4Right.setFontSize(48, 1); - line6Left.setFontSize(48,1); - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 2; - } - R2_press_orig = getprop("/instrumentation/fmz/fmz-key-R2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R1-press"); - if (R1_press_orig == 0 and press == 1) { - line2Left.setFontSize(48, 1); - line4Left.setFontSize(48, 1); - line4Right.setFontSize(48, 1); - line6Left.setFontSize(48,1); - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 2; - } - R1_press_orig = getprop("/instrumentation/fmz/fmz-key-R1-press"); - } - } - fmz_setlistener(pageCruiseModes); - - var pageDescentModes = func() { - if (page_title_text == "DESCENT MODES") { - eachPageInit(); - total_page_prop = 1; - pageTitle.setText(sprintf("%s", "DESCENT MODES")); - pageTitleRight.setText(""); - currentPage.setText(sprintf("%d", current_page_prop)); - totalPage.setText(sprintf("%d", total_page_prop)); - line1Left.setText("MANUAL"); - line1Left.setColor(255,255,255,255); - line1Mid.setText(""); - line1Right.setText("RETURN ▶"); - line1Right.setColor(255,255,255,255); - line2Left.setColor(0,174,255,255); - line2Mid.setText(""); - line2Right.setText(""); - line3Left.setText(""); - line3Mid.setText(""); - line3Right.setText(""); - if (des_ias == 300 and des_mach == 0.8 and des_path_deg == 3.0) { - line4Left.setText("◀ 300/.80ᴍ/3.0° [ACT]"); - line4Left.setFontSize(48,1); - - line2Left.setText(sprintf("%3d", des_ias) ~ "/." ~ sprintf("%2d", (des_mach*100)) ~ "M" ~ "/" ~ sprintf("%3.1f", des_path_deg) ~"°"); - line2Left.setFontSize(36, 1); - line6Left.setText("◀ VMO/MMO/4.0°"); - line6Left.setFontSize(36,1); - } else if (des_ias == 340 and des_mach == 0.86 and des_path_deg == 4.0) { - line6Left.setText("◀ VMO/MMO/4.0° [ACT]"); - line6Left.setFontSize(48,1); - - line4Left.setText("◀ 300/.80M/3.0°"); - line4Left.setFontSize(36,1); - line2Left.setText(sprintf("%3d", des_ias) ~ "/." ~ sprintf("%2d", (des_mach*100)) ~ "M" ~ "/" ~ sprintf("%3.1f", des_path_deg) ~"°"); - line2Left.setFontSize(36, 1); - } else { - line2Left.setText(sprintf("%3d", des_ias) ~ "/." ~ sprintf("%2d", (des_mach*100)) ~ "ᴍ" ~ "/" ~ sprintf("%3.1f", des_path_deg) ~"°" ~ " [ACT]"); - line2Left.setFontSize(48, 1); - - line4Left.setText("◀ 300/.80M/3.0°"); - line4Left.setFontSize(36,1); - line6Left.setText("◀ VMO/MMO/4.0°"); - line6Left.setFontSize(36,1); - } - line4Left.setColor(0,174,255,255); - line4Mid.setText(""); - line4Right.setText(""); - line5Left.setText(""); - line5Mid.setText(""); - line5Right.setText(""); - line6Left.setColor(0,174,255,255); - line6Mid.setText(""); - line6Right.setText(""); - line7Left.setText(""); - line7Mid.setText(""); - line7Right.setText(""); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - var des_ias_inp = num(substr(scratch_pad_text, 0, 3)) or 9999; - var slash_1 = find("/", scratch_pad_text); - var rmn_pad_text = substr(scratch_pad_text, slash_1 + 1); - var slash_2 = find("/", rmn_pad_text); - if (slash_2 == -1) { - slash_2 = 9999; - } - var des_mach_inp = num(substr(rmn_pad_text, 0, slash_2)) or 9999; - var des_deg_inp = num(substr(rmn_pad_text, slash_2 + 1)) or 9999; - var des_inp_vld = 0; - - if (des_ias_inp >= 108 and des_ias_inp <= 340) { - des_ias = des_ias_inp; - des_inp_vld = 1; - } - if (des_mach_inp >= 0.6 and des_mach_inp <= 0.90) { - des_mach = des_mach_inp; - des_inp_vld = 1; - } - if (des_deg_inp > 0 and des_deg_inp < 10.0){ - des_path_deg = des_deg_inp; - des_inp_vld = 1; - } - - if (des_inp_vld == 0) { - scratch_pad_message = "INVALID INPUT"; - } - - if (scratch_pad_message != "INVALID INPUT") { - scratch_pad_text = ""; - line2Left.setFontSize(48, 1); - line4Left.setFontSize(48, 1); - line4Right.setFontSize(48, 1); - line6Left.setFontSize(48,1); - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 2; - } - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - des_ias = 300; - des_mach = 0.8; - des_path_deg = 3.0; - line2Left.setFontSize(48, 1); - line4Left.setFontSize(48, 1); - line4Right.setFontSize(48, 1); - line6Left.setFontSize(48,1); - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 2; - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - des_ias = 340; - des_mach = 0.86; - des_path_deg = 4.0; - line2Left.setFontSize(48, 1); - line4Left.setFontSize(48, 1); - line4Right.setFontSize(48, 1); - line6Left.setFontSize(48,1); - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 2; - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R1-press"); - if (R1_press_orig == 0 and press == 1) { - line2Left.setFontSize(48, 1); - line4Left.setFontSize(48, 1); - line4Right.setFontSize(48, 1); - line6Left.setFontSize(48,1); - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 2; - } - R1_press_orig = getprop("/instrumentation/fmz/fmz-key-R1-press"); - } - } - fmz_setlistener(pageDescentModes); - - var pageDepAppSpd = func() { - if (page_title_text == "DEP/APP SPD") { - eachPageInit(); - total_page_prop = 4; - pageTitleRight.setText(""); - totalPage.setText(sprintf("%d", total_page_prop)); - currentPage.setText(sprintf("%d", current_page_prop)); - if (page_title_text == "DEP/APP SPD" and current_page_prop == 1) { - eachPageInit(); - pageTitle.setText("DEPARTURE SPEED"); - pageTitle.setColor(255,255,255,255); - line1Left.setText("SPEED LIMIT"); - line1Left.setColor(255,255,255,255); - line1Mid.setText(""); - line1Right.setText("RETURN ▶"); - line2Left.setText(sprintf("%d", dep_spd_lmt)); - line2Left.setColor(0,174,255,255); - line2Mid.setText(""); - line2Right.setText(""); - line3Left.setText(""); - line3Mid.setText(" AGL <------------------ LIMIT ------------------> NM"); - line3Mid.setColor(255,255,255,255); - line3Right.setText(""); - line4Left.setText(sprintf("%d", dep_agl_lmt)); - line4Left.setColor(0,174,255,255); - line4Mid.setText(""); - line4Right.setText(sprintf("%.1f", dep_nm_lmt)); - line4Right.setColor(0,174,255,255); - line5Left.setText(""); - line5Mid.setText(""); - line5Right.setText(""); - line6Left.setText(""); - line6Mid.setText(""); - line6Right.setText(""); - line7Left.setText(""); - line7Mid.setText(""); - line7Right.setText(""); - - var press = getprop("/instrumentation/fmz/fmz-key-R1-press"); - if (R1_press_orig == 0 and press == 1) { - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 2; - } - R1_press_orig = getprop("/instrumentation/fmz/fmz-key-R1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - var dep_spd_lmt_inp = num(scratch_pad_text) or 9999; - if (dep_spd_lmt_inp <= (cln_vref / 1.3) or dep_spd_lmt_inp > 340) { - scratch_pad_message = "INVALID INPUT"; - } else { - dep_spd_lmt = dep_spd_lmt_inp; - } - scratch_pad_text = ""; - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - var dep_agl_lmt_inp = num(scratch_pad_text) or -9999; - if (dep_agl_lmt_inp >= 0 and dep_agl_lmt_inp < 10000) { - dep_agl_lmt = dep_agl_lmt_inp; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R2-press"); - if (R2_press_orig == 0 and press == 1) { - var dep_nm_lmt_inp = num(scratch_pad_text) or -9999; - if (dep_nm_lmt_inp >= 0 and dep_nm_lmt_inp < 999) { - dep_nm_lmt = dep_nm_lmt_inp; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - R2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - } - - if (page_title_text == "DEP/APP SPD" and current_page_prop == 2) { - eachPageInit(); - page_prop_tmp = current_page_prop; - pageTitle.setText("APPROACH SPEED"); - pageTitle.setColor(255,255,255,255); - line1Left.setText("CLEAN"); - line1Left.setColor(255,255,255,255); - line1Mid.setText(""); - line1Right.setText("RETURN ▶"); - line1Right.setColor(255,255,255,255); - line2Left.setText(sprintf("%d", cln_app_lmt)); - line2Left.setColor(0,174,255,255); - line2Mid.setText(""); - line2Right.setText(""); - line3Left.setText("DIST TO DESTINATION"); - line3Left.setColor(255,255,255,255); - line3Mid.setText(""); - line3Right.setText(""); - line4Left.setText(sprintf("%.1f", app_init_dst) ~ "NM"); - line4Left.setColor(0,174,255,255); - line4Mid.setText(""); - line4Right.setText(""); - line5Left.setText(" FIRST APP WPT"); - line5Left.setColor(255,255,255,255); - line5Mid.setText(""); - line5Right.setText(""); - line6Left.setText(" " ~ app_1st_wpt); - line6Left.setColor(0,255,0,255); - line6Mid.setText(" OR"); - line6Mid.setColor(255,255,255,255); - line6Mid.setFontSize(48,1); - if (app_1st_wpt == "YES") { - line6Right.setText("NO ▶"); - } else { - line6Right.setText("YES ▶"); - } - line6Right.setColor(255,255,255,255); - line6Right.setFontSize(36,1); - line7Left.setText(""); - line7Mid.setText(""); - line7Right.setText(""); - - var press = getprop("/instrumentation/fmz/fmz-key-R1-press"); - if (R1_press_orig == 0 and press == 1) { - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 2; - line6Mid.setFontSize(36,1); - line6Right.setFontSize(48,1); - } - R1_press_orig = getprop("/instrumentation/fmz/fmz-key-R1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R3-press"); - if (R3_press_orig == 0 and press == 1) { - if (app_1st_wpt == "YES") { - app_1st_wpt = "NO"; - } else { - app_1st_wpt = "YES"; - } - } - R3_press_orig = getprop("/instrumentation/fmz/fmz-key-R3-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - var cln_app_lmt_inp = num(scratch_pad_text) or 9999; - if (cln_app_lmt_inp > cln_vso and cln_app_lmt_inp < 340) { - cln_app_lmt = cln_app_lmt_inp; - scratch_pad_text = ""; - } else { - scratch_pad_message = "INVALID INPUT"; - } - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - var app_init_dst_inp = num(scratch_pad_text) or -9999; - if (app_init_dst_inp > 0) { - app_init_dst = app_init_dst_inp; - scratch_pad_text = ""; - } else { - scratch_pad_message = "INVALID INPUT"; - } - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - } - if (page_prop_tmp == 2 and current_page_prop != 2) { - line6Mid.setFontSize(36,1); - line6Right.setFontSize(48,1); - } - - if (page_title_text == "DEP/APP SPD" and current_page_prop == 3) { - eachPageInit(); - pageTitle.setText("APPROACH SPEED"); - pageTitle.setColor(255,255,255,255); - line1Left.setText("FLAPS 6"); - line1Left.setColor(255,255,255,255); - line1Mid.setText(""); - line1Right.setText("RETURN ▶"); - line1Right.setColor(255,255,255,255); - - if (flp6_app_lmt <= 74) { - line2Left.setText(sprintf("%d", flp6_vref + flp6_app_lmt)); - } else { - line2Left.setText(sprintf("%d", flp6_app_lmt)); - } - line2Left.setColor(0,174,255,255); - line2Mid.setText(""); - line2Right.setText(""); - line3Left.setText("FLAPS 16"); - line3Left.setColor(255,255,255,255); - line3Mid.setText(""); - line3Right.setText(""); - if (flp16_app_lmt <= 74) { - line4Left.setText(sprintf("%d", flp16_vref + flp16_app_lmt)); - } else { - line4Left.setText(sprintf("%d", flp16_app_lmt)); - } - line4Left.setColor(0,174,255,255); - line4Mid.setText(""); - line4Right.setText(""); - line5Left.setText("FLAPS 30"); - line5Left.setColor(255,255,255,255); - line5Mid.setText(""); - line5Right.setText(""); - if (flp30_app_lmt <=74) { - line6Left.setText(sprintf("%d", flp30_vref + flp30_app_lmt)); - } else { - line6Left.setText(sprintf("%d", flp30_app_lmt)); - } - line6Left.setColor(0,174,255,255); - line6Mid.setText(""); - line6Right.setText(""); - - var press = getprop("/instrumentation/fmz/fmz-key-R1-press"); - if (R1_press_orig == 0 and press == 1) { - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 2; - } - R1_press_orig = getprop("/instrumentation/fmz/fmz-key-R1-press"); - - var flp6_app_use_vref = 0; - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - var flp6_app_inp = num(scratch_pad_text) or -9999; - if ((flp6_app_inp >= 5 and flp6_app_inp <=74) or flp6_app_inp > flp6_vso) { - flp6_app_lmt = flp6_app_inp; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - var flp16_app_inp = num(scratch_pad_text) or -9999; - if ((flp16_app_inp >= 5 and flp16_app_inp <=74) or flp16_app_inp > flp16_vso) { - flp16_app_lmt = flp16_app_inp; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - var flp30_app_inp = num(scratch_pad_text) or -9999; - if ((flp30_app_inp >= 5 and flp30_app_inp <=74) or flp30_app_inp > flp30_vso) { - flp30_app_lmt = flp30_app_inp; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - } - if (page_title_text == "DEP/APP SPD" and current_page_prop == 4) { - eachPageInit(); - pageTitle.setText("GO-AROUND SPEEDS"); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setText(""); - line1Left.setText("CLEAN"); - line1Left.setColor(255,255,255,255); - line1Mid.setText(""); - line1Right.setText("RETURN ▶"); - line1Right.setColor(255,255,255,255); - line2Left.setText(sprintf("%d", cln_ga_lmt)); - line2Left.setColor(0,174,255,255); - line2Mid.setText(""); - line2Right.setText(""); - line3Left.setText("FLAPS 6"); - line3Left.setColor(255,255,255,255); - line3Mid.setText(""); - line3Right.setText("FLAPS 30"); - line3Right.setColor(255,255,255,255); - if (flp6_ga_lmt >= 5 and flp6_ga_lmt <= 74){ - line4Left.setText(sprintf("%d", flp6_vref + flp6_ga_lmt)); - } else { - line4Left.setText(sprintf("%d", flp6_ga_lmt)); - } - line4Left.setColor(0,174,255,255); - line4Mid.setText(""); - if (flp30_ga_lmt >= 5 and flp30_ga_lmt <= 74) { - line4Right.setText(sprintf("%d", flp30_vref + flp30_ga_lmt)); - } else { - line4Right.setText(sprintf("%d", flp30_ga_lmt)); - } - line4Right.setColor(0,174,255,255); - line5Left.setText("FLAPS 16"); - line5Left.setColor(255,255,255,255); - line5Mid.setText(""); - line5Right.setText(""); - if (flp16_ga_lmt >= 5 and flp16_ga_lmt <= 74) { - line6Left.setText(sprintf("%d", flp16_vref + flp16_ga_lmt)); - } else { - line6Left.setText(sprintf("%d", flp16_ga_lmt)); - } - line6Left.setColor(0,174,255,255); - line6Mid.setText(""); - line6Right.setText(""); - line7Left.setText(""); - line7Mid.setText(""); - line7Right.setText(""); - - var press = getprop("/instrumentation/fmz/fmz-key-R1-press"); - if (R1_press_orig == 0 and press == 1) { - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 2; - } - R1_press_orig = getprop("/instrumentation/fmz/fmz-key-R1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - var ga_lmt_inp = num(scratch_pad_text) or -9999; - if (ga_lmt_inp > cln_vso) { - cln_ga_lmt = ga_lmt_inp; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - var ga_lmt_inp = num(scratch_pad_text) or -9999; - if ((ga_lmt_inp >= 5 and ga_lmt_inp <= 74) or (ga_lmt_inp > flp6_vso)) { - flp6_ga_lmt = ga_lmt_inp; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - var ga_lmt_inp = num(scratch_pad_text) or -9999; - if ((ga_lmt_inp >= 5 and ga_lmt_inp <= 74) or (ga_lmt_inp > flp16_vso)) { - flp16_ga_lmt = ga_lmt_inp; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R2-press"); - if (R2_press_orig == 0 and press == 1) { - var ga_lmt_inp = num(scratch_pad_text) or -9999; - if ((ga_lmt_inp >= 5 and ga_lmt_inp <= 74) or (ga_lmt_inp > flp30_vso)) { - flp30_ga_lmt = ga_lmt_inp; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - } - R2_press_orig = getprop("/instrumentation/fmz/fmz-key-R2-press"); - } - } - } - fmz_setlistener(pageDepAppSpd); - var pageDepAppSpd_timer = maketimer(3, pageDepAppSpd); - pageDepAppSpd_timer.start(); - - var pageFuelReserve = func { - if (page_title_text == "FUEL RESERVE") { - eachPageInit(); - total_page_prop = 1; - pageTitle.setText("FUEL RESERVE"); - pageTitle.setColor(255,255,255,255); - pageTitleRight.setText(""); - currentPage.setText(sprintf("%d", current_page_prop)); - totalPage.setText(sprintf("%d", total_page_prop)); - line1Left.setText(""); - line1Left.setColor(255,255,255,255); - line1Mid.setText(""); - line1Right.setText("RETURN ▶"); - line1Right.setColor(255,255,255,255); - - if (fuel_rsv_mode == "NBAA") { - line2Left.setText("◀ NBAA [ACT]"); - } else { - line2Left.setText("◀ NBAA"); - } - line2Left.setColor(0,174,255,255); - line2Mid.setText(""); - line2Right.setText(""); - line3Left.setText(""); - line3Mid.setText(""); - line3Right.setText(""); - - if (fuel_rsv_lb == 0) { - line4Left.setText("----- ʟʙ"); - } else if (fuel_rsv_lb > 0) { - line4Left.setText(sprintf("%d", fuel_rsv_lb) ~ " ʟʙ"); - } - line4Left.setColor(0,174,255,255); - - line4Mid.setText(""); - line4Right.setText("AT DEST"); - line4Right.setColor(255,255,255,255); - line4Right.setFontSize(36); - line5Left.setText(""); - line5Mid.setText(""); - line5Right.setText("OR ALTN IF"); - line5Right.setColor(255,255,255,255); - - if (fuel_rsv_min == 0) { - line6Left.setText("--- ᴍɪɴ"); - } else if (fuel_rsv_min > 0) { - line6Left.setText(sprintf("%d", fuel_rsv_min) ~ " ᴍɪɴ"); - } - line6Left.setColor(0,174,255,255); - - line6Mid.setText(""); - line6Right.setText("ENTERED"); - line6Right.setColor(255,255,255,255); - line6Right.setFontSize(36); - - var press = getprop("/instrumentation/fmz/fmz-key-R1-press"); - if (R1_press_orig == 0 and press == 1) { - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 3; - line4Right.setFontSize(48); - line6Right.setFontSize(48); - } - R1_press_orig = getprop("/instrumentation/fmz/fmz-key-R1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - fuel_rsv_mode = "NBAA"; - fuel_rsv_lb = 0; - fuel_rsv_min = 0; - - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 3; - line4Right.setFontSize(48); - line6Right.setFontSize(48); - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L2-press"); - if (L2_press_orig == 0 and press == 1) { - if (num(scratch_pad_text) != nil) { - if (altn_airport == "") { - fuel_rsv_mode = dest_airport; - } else { - fuel_rsv_mode = altn_airport; - } - fuel_rsv_lb = num(scratch_pad_text); - fuel_rsv_min = 0; - - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 3; - line4Right.setFontSize(48); - line6Right.setFontSize(48); - - scratch_pad_text = ""; - } else { - scratch_pad_message = "INVALID INPUT"; - } - } - L2_press_orig = getprop("/instrumentation/fmz/fmz-key-L2-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-L3-press"); - if (L3_press_orig == 0 and press == 1) { - if (num(scratch_pad_text) != nil) { - if (altn_airport == "") { - fuel_rsv_mode = dest_airport; - } else { - fuel_rsv_mode = altn_airport; - } - fuel_rsv_lb = 0; - fuel_rsv_min = num(scratch_pad_text); - - page_title_text = "PERFORMANCE INIT"; - current_page_prop = 3; - line4Right.setFontSize(48); - line6Right.setFontSize(48); - - scratch_pad_text = ""; - } else { - scratch_pad_message = "INVALID INPUT"; - } - } - L3_press_orig = getprop("/instrumentation/fmz/fmz-key-L3-press"); - } - } - fmz_setlistener(pageFuelReserve); - - var pagePerformanceData = func () { - if (page_title_text == "PERF DATA") { - eachPageInit(); - total_page_prop = 4; - if (current_page_prop == 1){ - eachPageInit(); - pageTitle.setText(page_title_text); - pageTitle.setColor(255,255,255,255); - currentPage.setText(sprintf("%d", current_page_prop)); - totalPage.setText(sprintf("%d", total_page_prop)); - line1Left.setText("CRZ/CEIL ALT"); - - var alt_preselector = getprop("autopilot/settings/target-altitude-ft"); - if (alt_preselector > crn_crz_alt) { - crn_crz_alt = alt_preselector; - } - var crn_crz_fl = "FL" ~ sprintf("%03d", crn_crz_alt / 100); - var ceil_alt_fl = "FL" ~ sprintf("%03d", ceil_alt / 100); - line2Left.setText(crn_crz_fl ~ "/" ~ ceil_alt_fl); - line2Left.setColor(0,174,255,255); - line1Right.setText("STEP INC"); - line2Right.setText(sprintf("%d", step_incm)); - line2Right.setColor(0,174,255,255); - line3Left.setText("DEST"); - line3Right.setText("ALTN"); - line4Mid.setText("<-------- ETE ------->"); - var ete_dest_hrs = math.floor(ete_to_dest); - var ete_dest_min = (ete_to_dest - ete_dest_hrs) * 60; - line4Left.setText(sprintf("%02d", ete_dest_hrs) ~ "+" ~ sprintf("%02d", ete_dest_min)); - line4Left.setColor(0,174,255,255); - line4Left.setFontSize(36,1); - var ete_altn_hrs = math.floor(ete_to_altn); - var ete_altn_min = (ete_to_altn - ete_altn_hrs) * 60; - line4Right.setText(sprintf("%02d", ete_altn_hrs) ~ "+" ~ sprintf("%02d", ete_altn_min)); - line4Right.setColor(0,174,255,255); - line4Right.setFontSize(36,1); - line5Mid.setText("<----- FUEL REQ ----->"); - line5Left.setText(sprintf("%0.1f", (dest_fuel_prd / 1000))); - line5Left.setColor(0,174,255,255); - line5Left.setFontSize(36,1); - line5Right.setText(sprintf("%0.1f", (altn_fuel_prd / 1000))); - line5Right.setColor(0,174,255,255); - line5Right.setFontSize(36,1); - line6Mid.setText("<----- FUEL FOM ----->"); - line6Left.setText(sprintf("%0.1f", fuel_prd_fom_dest)); - line6Left.setColor(0,174,255,255); - line6Left.setFontSize(36,1); - line6Right.setText(sprintf("%0.1f", fuel_prd_fom_altn)); - line6Right.setColor(0,174,255,255); - line6Right.setFontSize(36,1); - line7Left.setText("◀ PERF INIT"); - line7Right.setText("DEPARTURE ▶"); - - var press = getprop("/instrumentation/fmz/fmz-key-L1-press"); - if (L1_press_orig == 0 and press == 1) { - var inp_num = num(scratch_pad_text) or -65532; - if (inp_num > ceil_alt) { - inp_num = ceil_alt; - } else if (inp_num > 0) { - crn_crz_alt = inp_num; - } else { - var fl_pos = find("FL", scratch_pad_text); - var fl_size = size(scratch_pad_text); - if (fl_pos == 0 and fl_size == 5) { - var fl_num = substr(scratch_pad_text, 2); - fl_num = num(fl_num) or -65532; - if (fl_num > 0) { - crn_crz_alt = fl_num * 100; - } else { - scratch_pad_message = "INVALID INPUT"; - } - } - } - scratch_pad_text = ""; - } - L1_press_orig = getprop("/instrumentation/fmz/fmz-key-L1-press"); - - key_prs("R1", func() { - var inp_num = num(scratch_pad_text) or -65532.12; - var int_part = int(inp_num); - - if ((int_part - inp_num) == 0) { - var check_int = 1; - } else { - var check_int = 0; - } - if (inp_num >= 0 and check_int == 1) { - step_incm = inp_num; - } else { - scratch_pad_message = "INVALID INPUT"; - } - scratch_pad_text = ""; - }); - } - - if (current_page_prop == 2) { - eachPageInit(); - pageTitle.setText(page_title_text); - pageTitle.setColor(255,255,255,255); - currentPage.setText(sprintf("%d", current_page_prop)); - totalPage.setText(sprintf("%d", total_page_prop)); - line1Left.setText("DEST"); - line1Left.setFontSize(36,1); - line1Right.setText("ALTN"); - line1Right.setFontSize(36,1); - var dist_dest = dist_to_dest(); - if (dist_dest >= 1000) { - line2Left.setText(sprintf("%4d", dist_dest)); - } else { - line2Left.setText(sprintf("%3.1f", dist_dest)); - } - line2Left.setColor(0,255,0,255); - line2Left.setFontSize(36,1); - line2Mid.setText("<------- DIST ------->"); - var dist_altn = ttl_rte_dst(); - if (dist_altn >= 1000) { - line2Right.setText(sprintf("%4d", dist_altn)); - } else { - line2Right.setText(sprintf("%3.1f", dist_altn)); - } - line2Right.setColor(0,255,0,255); - line2Right.setFontSize(36,1); - var on_ground = getprop("/fdm/jsbsim/gear/wow") or 1; - var eta_dest_dst = 0; - var wpt_num = rte_wpt_counter(); - var whl_cnt = to_waypoint + 1; - while (whl_cnt < wpt_num) { - var leg_dst = grtCircDist(whl_cnt); - eta_dest_dst = eta_dest_dst + leg_dst; - whl_cnt = whl_cnt + 1; - } - - eta_dest_dst = eta_dest_dst + dst_frm_acr(to_waypoint); - var grd_spd = getprop("/velocities/groundspeed-kt") or 0; - var ete_dest = eta_dest_dst / grd_spd; - var now_hr = num(substr(time_text, 0, 2)); - var now_min = num(substr(time_text, 2, 2)); - now_min = now_min / 60; - var now_dcm = now_hr + now_min; - var eta_dest = now_dcm + ete_dest; - var eta_dest_hr = math.fmod(math.floor(eta_dest), 24); - var eta_dest_min = eta_dest - math.floor(eta_dest); - eta_dest_min = eta_dest_min * 60; - var eta_dest_text = sprintf("%02d", eta_dest_hr); - eta_dest_text = eta_dest_text ~ sprintf("%02d", eta_dest_min); - eta_dest_text = eta_dest_text ~ "Z"; - if (on_ground == 1) { - line3Left.setText(""); - } else { - line3Left.setText(eta_dest_text); - } - line3Left.setColor(0,174,255,255); - line3Left.setFontSize(36,1); - line3Mid.setText("<-------- ETA ------->"); - var eta_altn_dst = 0; - var wpt_num = waypoints.size(); - var whl_cnt = to_waypoint + 1; - while (whl_cnt < wpt_num) { - var leg_dst = grtCircDist(whl_cnt); - eta_altn_dst = eta_altn_dst + leg_dst; - whl_cnt = whl_cnt + 1; - } - - eta_altn_dst = eta_altn_dst + dst_frm_acr(to_waypoint); - var grd_spd = getprop("/velocities/groundspeed-kt") or 0; - var ete_altn = eta_altn_dst / grd_spd; - var now_hr = num(substr(time_text, 0, 2)); - var now_min = num(substr(time_text, 2, 2)); - now_min = now_min / 60; - var now_dcm = now_hr + now_min; - var eta_altn = now_dcm + ete_altn; - var eta_altn_hr = math.fmod(math.floor(eta_altn), 24); - var eta_altn_min = eta_altn - math.floor(eta_altn); - eta_altn_min = eta_altn_min * 60; - var eta_altn_text = sprintf("%02d", eta_altn_hr); - eta_altn_text = eta_altn_text ~ sprintf("%02d", eta_altn_min); - eta_altn_text = eta_altn_text ~ "Z"; - if (on_ground == 1) { - line3Right.setText(""); - } else { - line3Right.setText(eta_altn_text); - } - line3Right.setColor(0,174,255,255); - line3Right.setFontSize(36,1); - line4Mid.setText("<----- FUEL REM ----->"); - var engine0_flow_pph = getprop("/engines/engine[0]/fuel-flow_pph") or 0; - var engine1_flow_pph = getprop("/engines/engine[1]/fuel-flow_pph") or 0; - var total_flow_pph = engine0_flow_pph + engine1_flow_pph; - var fuel_rmn_dtn = total_fuel_lbs_inp - (total_flow_pph * ete_dest); - var fuel_rmn_dtn_grd = total_fuel_lbs_inp - dest_fuel_prd; - if (on_ground == 1) { - var frdgk = fuel_rmn_dtn_grd / 1000; - line4Left.setText(sprintf("%0.1f", frdgk)); - } else { - var frdk = fuel_rmn_dtn / 1000; - line4Left.setText(sprintf("%0.1f", frdk)); - } - line4Left.setColor(0,174,255,255); - line4Left.setFontSize(36, 1); - var fuel_rmn_atn = total_fuel_lbs_inp - (total_flow_pph * ete_altn); - var fuel_rmn_atn_grd = total_fuel_lbs_inp - altn_fuel_prd; - if (on_ground == 1) { - var fragk = fuel_rmn_atn_grd / 1000; - line4Right.setText(sprintf("%0.1f", fragk)); - } else { - var frak = fuel_rmn_atn / 1000; - line4Right.setText(sprintf("%0.1f", frak)); - } - line4Right.setColor(0,174,255,255); - line4Right.setFontSize(36, 1); - line5Mid.setText("<----- GROSS WT ----->"); - var grs_wgh_dtn_grd = zfw + fuel_rmn_dtn_grd; - var grs_wgh_dtn = zfw + fuel_rmn_dtn; - var grs_wgh_atn_grd = zfw + fuel_rmn_atn_grd; - var grs_wgh_atn = zfw + fuel_rmn_atn; - if (on_ground == 1) { - var gwdgk = grs_wgh_dtn_grd / 1000; - line5Left.setText(sprintf("%0.1f", gwdgk)); - } else { - var gwdk = grs_wgh_dtn / 1000; - line5Left.setText(sprintf("%0.1f", gwdk)); - } - line5Left.setColor(0,174,255,255); - line5Left.setFontSize(36, 1); - if (on_ground == 1) { - var gwagk = grs_wgh_atn_grd / 1000; - line5Right.setText(sprintf("%0.1f", gwagk)); - } else { - var gwak = grs_wgh_atn / 1000; - line5Right.setText(sprintf("%0.1f", gwak)); - } - line5Right.setColor(0,174,255,255); - line5Right.setFontSize(36, 1); - line7Left.setText("◀ PERF INIT"); - line7Right.setText("DEPARTURE ▶"); - } - - if (current_page_prop == 3) { - eachPageInit(); - pageTitle.setText(page_title_text); - pageTitle.setColor(255,255,255,255); - currentPage.setText(sprintf("%d", current_page_prop)); - totalPage.setText(sprintf("%d", total_page_prop)); - line1Left.setText("CRZ"); - line1Left.setFontSize(36, 1); - line1Right.setText("TW"); - line1Right.setFontSize(36, 1); - line1Mid.setText("<----- AVG WIND ----->"); - line3Left.setText(" DEST FUEL REMAINING"); - line3Left.setFontSize(36, 1); - line4Left.setText("PREFLIGHT PLAN"); - line4Left.setFontSize(36, 1); - var eta_dest_dst = 0; - var wpt_num = rte_wpt_counter(); - var whl_cnt = to_waypoint + 1; - while (whl_cnt < wpt_num) { - var leg_dst = grtCircDist(whl_cnt); - eta_dest_dst = eta_dest_dst + leg_dst; - whl_cnt = whl_cnt + 1; - } - eta_dest_dst = eta_dest_dst + dst_frm_acr(to_waypoint); - var grd_spd = getprop("/velocities/groundspeed-kt") or 0; - var ete_dest = eta_dest_dst / grd_spd; - var engine0_flow_pph = getprop("/engines/engine[0]/fuel-flow_pph") or 0; - var engine1_flow_pph = getprop("/engines/engine[1]/fuel-flow_pph") or 0; - var total_flow_pph = engine0_flow_pph + engine1_flow_pph; - var fuel_rmn_dtn = total_fuel_lbs_inp - (total_flow_pph * ete_dest); - var fuel_rmn_dtn_grd = plan_fuel_ground - fuel_no_rsv; - var on_ground = getprop("/fdm/jsbsim/gear/wow") or 1; - var frz_fuel_rmn_k = fuel_rmn_dtn_grd / 1000; - line4Right.setText(sprintf("%0.1f", frz_fuel_rmn_k)); - line4Right.setColor(0,174,255,255); - line4Right.setFontSize(36, 1); - line5Left.setText("UPDATED PLAN"); - line5Left.setFontSize(36, 1); - if (on_ground == 1) { - line5Right.setText(""); - line5Right.setFontSize(36, 1); - } else { - fuel_rmn_dtn_k = fuel_rmn_dtn / 1000; - line5Right.setText(sprintf("%0.1f", fuel_rmn_dtn_k)); - line5Right.setFontSize(36, 1); - } - line5Right.setColor(0,174,255,255); - line6Left.setText("DIFFERENCE"); - line6Left.setFontSize(36, 1); - if (on_ground == 1) { - line6Right.setText(""); - } else { - var pln_upd_dfr = frz_fuel_rmn_k - fuel_rmn_dtn_k; - line6Right.setText(sprintf("%0.1f", pln_upd_dfr)); - } - line6Right.setColor(0,174,255,255); - line7Left.setText("◀ PERF INIT"); - line7Right.setText("DEPARTURE ▶"); - } - - if (current_page_prop == 4) { - eachPageInit(); - pageTitle.setText(page_title_text); - pageTitle.setColor(255,255,255,255); - currentPage.setText(sprintf("%d", current_page_prop)); - totalPage.setText(sprintf("%d", total_page_prop)); - if (fuel_rsv_mode == "NBAA") { - line1Mid.setText("NBAA FUEL RESERVE"); - line2Left.setText(" AT DEST"); - line2Left.setFontSize(36, 1); - line2Right.setText("200NM + "); - line2Right.setFontSize(36, 1); - line3Mid.setFontSize(36, 1); - line3Mid.setText("30 MIN @ 5000 @ 200"); - } else if (fuel_rsv_lb != 0) { - line1Mid.setText("LBS FUEL RESERVE"); - if (altn_airport == "") { - line2Left.setText(" AT DEST"); - line2Left.setFontSize(36, 1); - lb_str = sprintf("%d", fuel_rsv_lb) ~ " LBS"; - line2Right.setText("lb_str "); - line2Right.setFontSize(36, 1); - line3Mid.setText(""); - } else { - line2Left.setText(" AT ALTN"); - line2Left.setFontSize(36, 1); - lb_str = sprintf("%d", fuel_rsv_lb) ~ " LBS"; - line2Right.setText("lb_str "); - line2Right.setFontSize(36, 1); - line3Mid.setText(""); - } - } else if (fuel_rsv_min != 0) { - line1Mid.setText("MIN FUEL RESERVE"); - if (altn_airport == "") { - line2Left.setText(" AT DEST"); - line2Left.setFontSize(36, 1); - min_str = sprintf("%d", fuel_rsv_min) ~ " MIN"; - line2Right.setText("min_str "); - line2Right.setFontSize(36, 1); - line3Mid.setText(""); - } else { - line2Left.setText(" AT ALTN"); - line2Left.setFontSize(36, 1); - min_str = sprintf("%d", fuel_rsv_min) ~ " MIN"; - line2Right.setText("min_str "); - line2Right.setFontSize(36, 1); - line3Mid.setText(""); - } - } - - var eta_dest_dst = 0; - var wpt_num = rte_wpt_counter(); - var whl_cnt = to_waypoint + 1; - while (whl_cnt < wpt_num) { - var leg_dst = grtCircDist(whl_cnt); - eta_dest_dst = eta_dest_dst + leg_dst; - whl_cnt = whl_cnt + 1; - } - eta_dest_dst = eta_dest_dst + dst_frm_acr(to_waypoint); - var grd_spd = getprop("/velocities/groundspeed-kt") or 0; - var ete_dest = eta_dest_dst / grd_spd; - var engine0_flow_pph = getprop("/engines/engine[0]/fuel-flow_pph") or 0; - var engine1_flow_pph = getprop("/engines/engine[1]/fuel-flow_pph") or 0; - var total_flow_pph = engine0_flow_pph + engine1_flow_pph; - var fuel_rmn_dtn = total_fuel_lbs_inp - (total_flow_pph * ete_dest); - var fuel_rmn_dtn_grd = plan_fuel_ground - fuel_no_rsv; - var on_ground = getprop("/fdm/jsbsim/gear/wow") or 1; - var frz_fuel_rmn_k = fuel_rmn_dtn_grd / 1000; - var req_rsv_k = req_rsv / 1000; - line4Left.setText("REQ/PLAN"); - line4Left.setFontSize(36, 1); - req_plan_txt = sprintf("%0.1f", req_rsv_k); - req_plan_txt = req_plan_txt ~ "/"; - req_plan_txt = req_plan_txt ~ sprintf("%0.1f", frz_fuel_rmn_k); - line4Right.setText(); - line4Right.setFontSize(36, 1); - line4Right.setColor(0,174,255,255); - - line5Left.setText("UPDATED PLAN"); - line5Left.setFontSize(36, 1); - if (on_ground == 1) { - line5Right.setText(""); - line5Right.setFontSize(36, 1); - } else { - fuel_rmn_dtn_k = fuel_rmn_dtn / 1000; - line5Right.setText(sprintf("%0.1f", fuel_rmn_dtn_k)); - line5Right.setFontSize(36, 1); - line5Right.setColor(0,174,255,255); - } - - line6Left.setText("DIFFERENCE"); - line6Left.setFontSize(36, 1); - if (on_ground == 1) { - line6Right.setText(""); - } else { - var pln_upd_dfr = frz_fuel_rmn_k - fuel_rmn_dtn_k; - line6Right.setText(sprintf("%0.1f", pln_upd_dfr)); - line6Right.setColor(0,174,255,255); - } - - line7Left.setText("◀ PERF INIT"); - line7Right.setText("DEPARTURE ▶"); - } - - var press = getprop("/instrumentation/fmz/fmz-key-L4-press"); - if (L4_press_orig == 0 and press == 1) { - page_title_text = "PERFORMANCE INIT"; - } - L4_press_orig = getprop("/instrumentation/fmz/fmz-key-L4-press"); - - var press = getprop("/instrumentation/fmz/fmz-key-R4-press"); - if (R4_press_orig == 0 and press == 1) { - page_title_text = "DEPARTURE RUNWAYS"; - } - R4_press_orig = getprop("/instrumentation/fmz/fmz-key-R4-press"); - } - } - fmz_setlistener(pagePerformanceData); - var page_perf_data_timer = maketimer(1.0, pagePerformanceData); - page_perf_data_timer.start(); - - var saveLastPosition = maketimer(60, func() { - var lat_deg = getprop("/position/latitude-deg"); - var lon_deg = getprop("/position/longitude-deg"); - var path = string.normpath(getprop("/sim/fg-home") ~ '/Export/bd700-last-pos.xml'); - var file = io.open(path, "w"); - var xml = ' - - ' ~ lat_deg ~ ' - ' ~ lon_deg ~ ' -'; - io.write(file, xml); - io.close(file); - - }); - saveLastPosition.start(); - - var waypointsCoodCalc = func { - var R = 6371000; - var wpt_num = waypoints.size(); - var mag_var_deg = getprop("/environment/magnetic-variation-deg") or 0; - - for (i=0; i 100 and vs > 1000) { - var ct_hr = (alt_delta / vs) / 60; - var dist = ct_hr * gs; - } else { - var dist = (alt_delta / 2000 / 60) * 200; - } - dist = dist * 1852; - var new_lat = math.asin(math.sin(acft_lat) * math.cos(dist/R) + math.cos(acft_lat) * math.sin(dist/R) * math.cos(hdg)); - var new_lon = acft_lon + math.atan2(math.sin(hdg) * math.sin(dist/R) * math.cos(acft_lat), math.cos(dist/R) - math.sin(acft_lat) * math.sin(new_lat)); - new_lat = new_lat * R2D; - new_lon = new_lon * R2D; - new_lon = math.fmod((new_lon + 540), 360) - 180; - waypoints.vector[i].lat_nd = new_lat; - waypoints.vector[i].lon_nd = new_lon; - - } else if (type == "VorRadialIntc") { - var lat1 = waypoints.vector[i-1].lat_nd; - var lon1 = waypoints.vector[i-1].lon_nd; - var theta13 = waypoints.vector[i].hdg_crs_value + mag_var_deg; - lat1 = lat1 * D2R; - lon1 = lon1 * D2R; - theta13 = theta13 * D2R; - var lat2 = waypoints.vector[i].lat; - var lon2 = waypoints.vector[i].lon; - var theta23 = waypoints.vector[i].radialtoIntercept + mag_var_deg; - lat2 = lat2 * D2R; - lon2 = lon2 * D2R; - theta23 = theta23 * D2R; - var delta_lat = lat2 - lat1; - var delta_lon = lon2 - lon1; - var delta12 = 2 * math.asin(math.sqrt(math.pow(math.sin(delta_lat / 2), 2) + math.cos(lat1) * math.cos(lat2) * math.pow(math.sin(delta_lon / 2), 2))); - var theta_a = math.acos((math.sin(lat2) - math.sin(lat1) * math.cos(delta12)) / (math.sin(delta12) * math.cos(lat1))); - var theta_b = math.acos((math.sin(lat1) - math.sin(lat2) * math.cos(delta12)) / (math.sin(delta12) * math.cos(lat2))); - if (math.sin(lon2 - lon1) > 0) { - var theta12 = theta_a; - var theta21 = 2 * math.pi - theta_b; - } else { - var theta12 = 2 * math.pi - theta_a; - var theta21 = theta_b; - } - var alpha1 = math.fmod((theta13 - theta12 + math.pi), (2 * math.pi)) - math.pi; - var alpha2 = math.fmod((theta21 - theta23 + math.pi), (2 * math.pi)) - math.pi; - var alpha3 = math.acos(-math.cos(alpha1) * math.cos(alpha2) + math.sin(alpha1) * math.sin(alpha2) * math.cos(delta12)); - var delta13 = math.atan2(math.sin(delta12) * math.sin(alpha1) * math.sin(alpha2), math.cos(alpha2) + math.cos(alpha1) * math.cos(alpha3)); - var lat3 = math.asin(math.sin(lat1) * math.cos(delta13) + math.cos(lat1) * math.sin(delta13) * math.cos(theta13)); - var delta_lon13 = math.atan2(math.sin(theta13) * math.sin(delta13) * math.cos(lat1), math.cos(delta13) - math.sin(lat1) * math.sin(lat3)); - var lon3 = lon1 + delta_lon13; - lat3 = lat3 * R2D; - lon3 = lon3 * R2D; - lon3 = math.fmod(lon3 + 540, 360) - 180; - var old_name = waypoints.vector[i].orgn_id; - var vor_radial = waypoints.vector[i].radialtoIntercept; - new_name = old_name ~ "-R" ~ sprintf("%03d", vor_radial); - waypoints.vector[i].id = new_name; - waypoints.vector[i].lat_nd = lat3; - waypoints.vector[i].lon_nd = lon3; - - } else if (type == "DmeIntc") { - var dst_fr_prv = 0; - var delta_dst = 9999; - while (dst_fr_prv < 600 and delta_dst >= 0.1) { - # Calculates a gussing point. - var phi1 = waypoints.vector[i-1].lat_nd * D2R; - var lambda1 = waypoints.vector[i-1].lon_nd * D2R; - var brng = (waypoints.vector[i].hdg_crs_value + mag_var_deg) * D2R; - var d_delta = dst_fr_prv * 1852; - var phi2 = math.asin(math.sin(phi1) * math.cos(d_delta / R) + math.cos(phi1) * math.sin(d_delta/R) * math.cos(brng)); - var lambda2 = lambda1 + math.atan2(math.sin(brng) * math.sin(d_delta / R) * math.cos(phi1), math.cos(d_delta / R) - math.sin(phi1) * math.sin(phi2)); - # Calculates the distance from the gussing point to the VOR/DME. - phi1 = phi2; - lambda1 = lambda2; - phi2 = waypoints.vector[i].lat * D2R; - lambda2 = waypoints.vector[i].lon * D2R; - var delta_phi = phi2 - phi1; - var delta_lambda = lambda2 - lambda1; - var a_alpha = math.pow(math.sin(delta_phi / 2), 2) + math.cos(phi1) * math.cos(phi2) * math.pow(math.sin(delta_lambda / 2), 2); - var c_charlie = 2 * math.atan2(math.sqrt(a_alpha), math.sqrt(1 - a_alpha)); - var crt_dst_to_dme = R * c_charlie; - crt_dst_to_dme = crt_dst_to_dme / 1852; - var rqr_dst_to_dme = waypoints.vector[i].DMEtoIntercept; - - delta_dst = math.abs(rqr_dst_to_dme - crt_dst_to_dme); - dst_fr_prv = dst_fr_prv + 0.1; - } - var new_lat = phi1 * R2D; - var new_lon = lambda1 * R2D; - new_lon = math.fmod(new_lon + 540, 360) - 180; - waypoints.vector[i].lat_nd = new_lat; - waypoints.vector[i].lon_nd = new_lon; - var old_id = waypoints.vector[i].orgn_id; - var vor_dme = waypoints.vector[i].DMEtoIntercept; - vor_dme = sprintf("%d", vor_dme); - var new_id = old_id ~ "-D" ~ vor_dme; - waypoints.vector[i].id = new_id; - - - } else if (type == "Intc") { - var lat1 = waypoints.vector[i-1].lat_nd; - var lon1 = waypoints.vector[i-1].lon_nd; - var theta13 = waypoints.vector[i].hdg_crs_value + mag_var_deg; - lat1 = lat1 * D2R; - lon1 = lon1 * D2R; - theta13 = theta13 * D2R; - var lat2 = waypoints.vector[i].lat; - var lon2 = waypoints.vector[i].lon; - var theta23 = waypoints.vector[i].radialtoIntercept + mag_var_deg; - lat2 = lat2 * D2R; - lon2 = lon2 * D2R; - theta23 = theta23 * D2R; - var delta_lat = lat2 - lat1; - var delta_lon = lon2 - lon1; - var delta12 = 2 * math.asin(math.sqrt(math.pow(math.sin(delta_lat / 2), 2) + math.cos(lat1) * math.cos(lat2) * math.pow(math.sin(delta_lon / 2), 2))); - var theta_a = math.acos((math.sin(lat2) - math.sin(lat1) * math.cos(delta12)) / (math.sin(delta12) * math.cos(lat1))); - var theta_b = math.acos((math.sin(lat1) - math.sin(lat2) * math.cos(delta12)) / (math.sin(delta12) * math.cos(lat2))); - if (math.sin(lon2 - lon1) > 0) { - var theta12 = theta_a; - var theta21 = 2 * math.pi - theta_b; - } else { - var theta12 = 2 * math.pi - theta_a; - var theta21 = theta_b; - } - var alpha1 = math.fmod((theta13 - theta12 + math.pi), (2 * math.pi)) - math.pi; - var alpha2 = math.fmod((theta21 - theta23 + math.pi), (2 * math.pi)) - math.pi; - var alpha3 = math.acos(-math.cos(alpha1) * math.cos(alpha2) + math.sin(alpha1) * math.sin(alpha2) * math.cos(delta12)); - var delta13 = math.atan2(math.sin(delta12) * math.sin(alpha1) * math.sin(alpha2), math.cos(alpha2) + math.cos(alpha1) * math.cos(alpha3)); - var lat3 = math.asin(math.sin(lat1) * math.cos(delta13) + math.cos(lat1) * math.sin(delta13) * math.cos(theta13)); - var delta_lon13 = math.atan2(math.sin(theta13) * math.sin(delta13) * math.cos(lat1), math.cos(delta13) - math.sin(lat1) * math.sin(lat3)); - var lon3 = lon1 + delta_lon13; - lat3 = lat3 * R2D; - lon3 = lon3 * R2D; - lon3 = math.fmod(lon3 + 540, 360) - 180; - waypoints.vector[i].lat_nd = lat3; - waypoints.vector[i].lon_nd = lon3; - } else if (type == "Vectors") { - var hdg = (waypoints.vector[i].hdg_crs_value + mag_var_deg) * D2R; - var acft_lat = getprop("/position/latitude-deg") * D2R or 0; - var acft_lon = getprop("/position/longitude-deg") * D2R or 0; - var dist = 9999 * 1852; - var new_lat = math.asin(math.sin(acft_lat) * math.cos(dist/R) + math.cos(acft_lat) * math.sin(dist/R) * math.cos(hdg)); - var new_lon = acft_lon + math.atan2(math.sin(hdg) * math.sin(dist/R) * math.cos(acft_lat), math.cos(dist/R) - math.sin(acft_lat) * math.sin(new_lat)); - new_lat = new_lat * R2D; - new_lon = new_lon * R2D; - new_lon = math.fmod((new_lon + 540), 360) - 180; - waypoints.vector[i].lat_nd = new_lat; - waypoints.vector[i].lon_nd = new_lon; - } - } - } - fmz_setlistener(waypointsCoodCalc); - var waypointsCoodCalc_timer = maketimer(0.382, waypointsCoodCalc); - waypointsCoodCalc_timer.start(); - - var prep_wp_num = waypoints.size(); - setprop("/instrumentation/fmz/waypoints-num", waypoints.size()); - var wpSizePropGen = func { - var new_wp_num = waypoints.size(); - if (new_wp_num != prep_wp_num) { - setprop("/instrumentation/fmz/waypoints-num", waypoints.size()); - prep_wp_num = new_wp_num; - } - } - fmz_setlistener(wpSizePropGen); - var wpSizePropGen_timer = maketimer(0.382, wpSizePropGen); - wpSizePropGen_timer.start(); - - my_canvas.addPlacement({"node": "fmz-screen"}); - -} - -setlistener("sim/signals/fdm-initialized", fmzCanvas); diff --git a/test/multiplayer.nas b/test/multiplayer.nas deleted file mode 100644 index 4d71d3a..0000000 --- a/test/multiplayer.nas +++ /dev/null @@ -1,643 +0,0 @@ -############################################################################### -## -## Nasal module for dual control over the multiplayer network. -## -## Copyright (C) 2007 - 2010 Anders Gidenstam (anders(at)gidenstam.org) -## This file is licensed under the GPL license version 2 or later. -## -############################################################################### -## MP properties -var lat_mpp = "position/latitude-deg"; -var lon_mpp = "position/longitude-deg"; -var alt_mpp = "position/altitude-ft"; -var heading_mpp = "orientation/true-heading-deg"; -var pitch_mpp = "orientation/pitch-deg"; -var roll_mpp = "orientation/roll-deg"; - -# Import components from the mp_broadcast module. -var Binary = mp_broadcast.Binary; -var MessageChannel = mp_broadcast.MessageChannel; - -############################################################################### -# Utility classes - -############################################################ -# Translate a property into another. -# Factor and offsets are only used for numeric values. -# src - source : property node -# dest - destination : property node -# factor - : double -# offset - : double -var Translator = {}; -Translator.new = func (src = nil, dest = nil, factor = 1, offset = 0) { - var obj = { parents : [Translator], - src : src, - dest : dest, - factor : factor, - offset : offset }; - if (obj.src == nil or obj.dest == nil) { - print("Translator["); - print(" ", debug.string(obj.src)); - print(" ", debug.string(obj.dest)); - print("]"); - fail(); - } - - return obj; -} -Translator.update = func () { - var v = me.src.getValue(); - if (is_num(v)) { - me.dest.setValue(me.factor * v + me.offset); - } else { - if (typeof(v) == "scalar") - me.dest.setValue(v); - } -} - -############################################################ -# Detects flanks on two insignals encoded in a property. -# - positive signal up/down flank -# - negative signal up/down flank -# n - source : property node -# on_positive_flank - action : func (v) -# on_negative_flank - action : func (v) -var EdgeTrigger = {}; -EdgeTrigger.new = func (n, on_positive_flank, on_negative_flank) { - var obj = { parents : [EdgeTrigger], - old : 0, - node : n, - pos_flank : on_positive_flank, - neg_flank : on_negative_flank }; - if (obj.node == nil) { - print("EdgeTrigger["); - print(" ", debug.string(obj.node)); - print("]"); - fail(); - } - return obj; -} -EdgeTrigger.update = func { - # NOTE: float MP properties get interpolated. - # This detector relies on that steady state is reached between - # flanks. - var val = me.node.getValue(); - if (!is_num(val)) return; - if (me.old == 1) { - if (val < me.old) { - me.pos_flank(0); - } - } elsif (me.old == 0) { - if (val > me.old) { - me.pos_flank(1); - } elsif (val < me.old) { - me.neg_flank(1); - } - } elsif (me.old == -1) { - if (val > me.old) { - me.neg_flank(0); - } - } - me.old = val; -} - -############################################################ -# StableTrigger: Triggers an action when a MPP property -# becomes stable (i.e. doesn't change for -# MIN_STABLE seconds). -# src - MP prop : property node -# action - action to take when the value becomes stable : [func(v)] -# An action is triggered when value has stabilized. -var StableTrigger = {}; -StableTrigger.new = func (src, action) { - var obj = { parents : [StableTrigger], - src : src, - action : action, - old : 0, - stable_since : 0, - wait : 0, - MIN_STABLE : 0.01 }; - # Error checking. - var bad = (obj.src == nil) or (action = nil); - - if (bad) { - print("StableTrigger["); - print(" ", debug.string(obj.src)); - print(" ", debug.string(obj.action)); - print("]"); - fail(); - } - - return obj; -} -StableTrigger.update = func () { - var v = me.src.getValue(); - if (!is_num(v)) return; - var t = getprop("/sim/time/elapsed-sec"); # NOTE: simulated time. - - if ((me.old == v) and - ((t - me.stable_since) > me.MIN_STABLE) and (me.wait == 1)) { - # Trigger action. - me.action(v); - - me.wait = 0; - } elsif (me.old == v) { - # Wait. This is either before the signal is stable or after the action. - } else { - me.stable_since = t; - me.wait = 1; - me.old = me.src.getValue(); - } -} - -############################################################ -# Selects the most recent value of two properties. -# src1 - : property node -# src2 - : property node -# dest - : property node -# threshold - : double -var MostRecentSelector = {}; -MostRecentSelector.new = func (src1, src2, dest, threshold) { - var obj = { parents : [MostRecentSelector], - old1 : 0, - old2 : 0, - src1 : src1, - src2 : src2, - dest : dest, - thres : threshold }; - if (obj.src1 == nil or obj.src2 == nil or obj.dest == nil) { - print("MostRecentSelector["); - print(" ", debug.string(obj.src1)); - print(" ", debug.string(obj.src2)); - print(" ", debug.string(obj.dest)); - print("]"); - } - - return obj; -} -MostRecentSelector.update = func { - var v1 = me.src1.getValue(); - var v2 = me.src2.getValue(); - if (!is_num(v1) and !is_num(v2)) return; - elsif (!is_num(v1)) me.dest.setValue(v2); - elsif (!is_num(v2)) me.dest.setValue(v1); - else { - if (abs (v2 - me.old2) > me.thres) { - me.old2 = v2; - me.dest.setValue(me.old2); - } - if (abs (v1 - me.old1) > me.thres) { - me.old1 = v1; - me.dest.setValue(me.old1); - } - } -} - -############################################################ -# Adds two input properties. -# src1 - : property node -# src2 - : property node -# dest - : property node -var Adder = {}; -Adder.new = func (src1, src2, dest) { - var obj = { parents : [DeltaAccumulator], - src1 : src1, - src2 : src2, - dest : dest }; - if (obj.src1 == nil or obj.src2 == nil or obj.dest == nil) { - print("Adder["); - print(" ", debug.string(obj.src1)); - print(" ", debug.string(obj.src2)); - print(" ", debug.string(obj.dest)); - print("]"); - fail(); - } - - return obj; -} -Adder.update = func () { - var v1 = me.src1.getValue(); - var v2 = me.src2.getValue(); - if (!is_num(v1) or !is_num(v2)) return; - me.dest.setValue(v1 + v2); -} - -############################################################ -# Adds the delta of src to dest. -# src - : property node -# dest - : property node -var DeltaAdder = {}; -DeltaAdder.new = func (src, dest) { - var obj = { parents : [DeltaAdder], - old : 0, - src : src, - dest : dest }; - if (obj.src == nil or obj.dest == nil) { - print("DeltaAdder[", debug.string(obj.src), ", ", - debug.string(obj.dest), "]"); - fail(); - } - - return obj; -} -DeltaAdder.update = func () { - var v = me.src.getValue(); - if (!is_num(v)) return; - me.dest.setValue((v - me.old) + me.dest.getValue()); - me.old = v; -} - -############################################################ -# Switch encoder: Encodes upto 32 boolean properties in one -# int property. -# inputs - list of property nodes -# dest - where the bitmask is stored : property node -var SwitchEncoder = {}; -SwitchEncoder.new = func (inputs, dest) { - var obj = { parents : [SwitchEncoder], - inputs : inputs, - dest : dest }; - # Error checking. - var bad = (obj.dest == nil); - foreach (var i; inputs) { - if (i == nil) { bad = 1; } - } - - if (bad) { - print("SwitchEncoder["); - foreach (var i; inputs) { - print(" ", debug.string(i)); - } - print(" ", debug.string(obj.dest)); - print("]"); - fail(); - } - - return obj; -} -SwitchEncoder.update = func () { - var v = 0; - var b = 1; - forindex (var i; me.inputs) { - if (me.inputs[i].getBoolValue()) { - v = v + b; - } - b *= 2; - } - me.dest.setIntValue(v); -} - -############################################################ -# Switch decoder: Decodes a bitmask in an int property. -# src - : property node -# actions - list of actions : [func(b)] -# Actions are triggered when their input bit change. -# Due to interpolation the decoder needs to wait for a -# stable input value. -var SwitchDecoder = {}; -SwitchDecoder.new = func (src, actions) { - var obj = { parents : [SwitchDecoder], - wait : 0, - old : 0, - old_stable : 0, - stable_since : 0, - reset : 1, - src : src, - actions : actions, - MIN_STABLE : 0.1 }; - # Error checking. - var bad = (obj.src == nil); - foreach (var a; obj.actions) { - if (a == nil) { bad = 1; } - } - - if (bad) { - print("SwitchDecoder["); - print(" ", debug.string(obj.src)); - foreach (var a; obj.actions) { - print(" ", debug.string(a)); - } - print("]"); - fail(); - } - - return obj; -} -SwitchDecoder.update = func () { - var t = getprop("/sim/time/elapsed-sec"); # NOTE: simulated time. - var v = me.src.getValue(); - if (!is_num(v)) return; - - if ((me.old == v) and ((t - me.stable_since) > me.MIN_STABLE) and - (me.wait == 1)) { - var ov = me.old_stable; -# Use this to improve. -# here's the boring version: var bittest = func(u, b) { while (b) { u = int(u / 2); b -= 1; } u != int(u / 2) * 2; } - forindex (var i; me.actions) { - var m = math.mod(v, 2); - var om = math.mod(ov, 2); - if ((m != om or me.reset)) { me.actions[i](m?1:0); } - v = (v - m)/2; - ov = (ov - om)/2; - } - me.old_stable = me.src.getValue(); - me.wait = 0; - me.reset = 0; - } elsif (me.old == v) { - # Wait. This is either before the bitmask is stable or after - # it has been processed. - } else { - me.stable_since = t; - me.wait = 1; - me.old = me.src.getValue(); - } -} - -############################################################ -# Time division multiplexing encoder: Transmits a list of -# properties over a MP enabled string property. -# inputs - input properties : [property node] -# dest - MP string prop : property node -# Note: TDM can have high latency so it is best used for -# non-time critical properties. -var TDMEncoder = {}; -TDMEncoder.new = func (inputs, dest) { - var obj = { parents : [TDMEncoder], - inputs : inputs, - channel : MessageChannel.new(dest, - func (msg) { - print("This should not happen!"); - }), - MIN_INT : 0.25, - last_time : 0, - next_item : 0, - old : [] }; - # Error checking. - var bad = (dest == nil) or (obj.channel == nil); - foreach (var i; inputs) { - if (i == nil) { bad = 1; } - } - - if (bad) { - print("TDMEncoder["); - foreach (var i; inputs) { - print(" ", debug.string(i)); - } - print(" ", debug.string(dest)); - print("]"); - } - - setsize(obj.old, size(obj.inputs)); - - return obj; -} -TDMEncoder.update = func () { - var t = getprop("/sim/time/elapsed-sec"); # NOTE: simulated time. - if (t > me.last_time + me.MIN_INT) { - var n = size(me.inputs); - while (1) { - var v = me.inputs[me.next_item].getValue(); - - if ((n <= 0) or (me.old[me.next_item] != v)) { - # Set the MP properties to send the next item. - me.channel.send(Binary.encodeByte(me.next_item) ~ - Binary.encodeDouble(v)); - - me.old[me.next_item] = v; - - me.last_time = t; - me.next_item += 1; - if (me.next_item >= size(me.inputs)) { me.next_item = 0; } - return; - } else { - # Search for changed property. - n -= 1; - me.next_item += 1; - if (me.next_item >= size(me.inputs)) { me.next_item = 0; } - } - } - } -} - -############################################################ -# Time division multiplexing decoder: Receives a list of -# properties over a MP enabled string property. -# src - MP string prop : property node -# actions - list of actions : [func(v)] -# An action is triggered when its value is received. -# Note: TDM can have high latency so it is best used for -# non-time critical properties. -var TDMDecoder = {}; -TDMDecoder.new = func (src, actions) { - var obj = { parents : [TDMDecoder], - actions : actions }; - obj.channel = MessageChannel.new(src, - func (msg) { - obj.process(msg); - }); - - # Error checking. - var bad = (src == nil) or (obj.channel == nil); - foreach (var a; actions) { - if (a == nil) { bad = 1; } - } - - if (bad) { - print("TDMDecoder["); - print(" ", debug.string(src)); - foreach (var a; actions) { - print(" ", debug.string(a)); - } - print("]"); - fail(); - } - - return obj; -} -TDMDecoder.process = func (msg) { - var v1 = Binary.decodeByte(msg); - var v2 = Binary.decodeDouble(substr(msg, 1)); - # Trigger action. - me.actions[v1](v2); -} -TDMDecoder.update = func { - me.channel.update(); -} - -############################################################################### -# Internal utility functions - -var is_num = func (v) { - return num(v) != nil; -} - -# fail causes a Nasal runtime error so we get a backtrace. -var fail = func { - error_detected_in_calling_context(); -} - -############################################################################### - -############################################################################### -# Copilot selection dialog. -# -# Usage: dual_control_tools.copilot_dialog.show(); -# -var COPILOT_DLG = 0; -var copilot_dialog = {}; -############################################################ -copilot_dialog.init = func (copilot_type, x = nil, y = nil) { - me.x = x; - me.y = y; - me.bg = [0, 0, 0, 0.3]; # background color - me.fg = [[1.0, 1.0, 1.0, 1.0]]; - # - # "private" - if (contains(aircraft_dual_control, "copilot_view")) { - me.title = "Pilot selection"; - } else { - me.title = "Copilot selection"; - } - me.basenode = props.globals.getNode("sim/remote", 1); - me.dialog = nil; - me.namenode = props.Node.new({"dialog-name" : me.title }); - me.listeners = []; - me.copilot_type = copilot_type; -} -############################################################ -copilot_dialog.create = func { - if (me.dialog != nil) - me.close(); - - me.dialog = gui.Widget.new(); - me.dialog.set("name", me.title); - if (me.x != nil) - me.dialog.set("x", me.x); - if (me.y != nil) - me.dialog.set("y", me.y); - - me.dialog.set("layout", "vbox"); - me.dialog.set("default-padding", 0); - var titlebar = me.dialog.addChild("group"); - titlebar.set("layout", "hbox"); - titlebar.addChild("empty").set("stretch", 1); - if (contains(aircraft_dual_control, "copilot_view")) { - titlebar.addChild("text").set("label", "Book your flight"); - } else { - titlebar.addChild("text").set("label", "Passengers online"); - } - var w = titlebar.addChild("button"); - w.set("pref-width", 16); - w.set("pref-height", 16); - w.set("legend", ""); - w.set("default", 0); - w.set("key", "esc"); - w.setBinding("nasal", "dual_control_tools.copilot_dialog.destroy(); "); - w.setBinding("dialog-close"); - me.dialog.addChild("hrule"); - - var content = me.dialog.addChild("group"); - content.set("layout", "vbox"); - content.set("halign", "center"); - content.set("default-padding", 5); - - # Generate the dialog contents. - me.players = me.find_copilot_players(); - var i = 0; - var tmpbase = me.basenode.getNode("dialog", 1); - var selected = me.basenode.getNode("pilot-callsign").getValue(); - foreach (var p; me.players) { - var tmp = tmpbase.getNode("b[" ~ i ~ "]", 1); - tmp.setBoolValue(streq(selected, p)); - var w = content.addChild("checkbox"); - w.node.setValues({"label" : p, - "halign" : "left", - "property" : tmp.getPath()}); - w.setBinding - ("nasal", - "dual_control_tools.copilot_dialog.select_action(" ~ i ~ ");"); - i = i + 1; - } - me.dialog.addChild("hrule"); - - # Display the dialog. - fgcommand("dialog-new", me.dialog.prop()); - fgcommand("dialog-show", me.namenode); -} -############################################################ -copilot_dialog.close = func { - fgcommand("dialog-close", me.namenode); -} -############################################################ -copilot_dialog.destroy = func { - COPILOT_DLG = 0; - me.close(); - foreach(var l; me.listeners) - removelistener(l); - delete(gui.dialog, "\"" ~ me.title ~ "\""); -} -############################################################ -copilot_dialog.show = func (copilot_type) { -# print("Showing MPCopilots dialog!"); - if (!COPILOT_DLG) { - COPILOT_DLG = int(getprop("/sim/time/elapsed-sec")); - me.init(copilot_type); - me.create(); - me._update_(COPILOT_DLG); - } -} -############################################################ -copilot_dialog._redraw_ = func { - if (me.dialog != nil) { - me.close(); - me.create(); - } -} -############################################################ -copilot_dialog._update_ = func (id) { - if (COPILOT_DLG != id) return; - me._redraw_(); - settimer(func { me._update_(id); }, 4.1); -} -############################################################ -copilot_dialog.select_action = func (n) { - var selected = me.basenode.getNode("pilot-callsign").getValue(); - var bs = me.basenode.getNode("dialog").getChildren(); - # Assumption: There are two true b:s or none. The one not matching selected - # is the new selection. - var i = 0; - me.basenode.getNode("pilot-callsign").setValue(""); - foreach (var b; bs) { - if (!b.getValue() and (i == n)) { - b.setValue(1); - me.basenode.getNode("pilot-callsign").setValue(me.players[i]); - } else { - b.setValue(0); - } - i = i + 1; - } - dual_control.main.reset(); - me._redraw_(); -} -############################################################ -# Return a list containing all nearby copilot players of the right type. -copilot_dialog.find_copilot_players = func { - var mpplayers = - props.globals.getNode("ai/models").getChildren("multiplayer"); - - var res = []; - foreach (var pilot; mpplayers) { - if ((pilot.getNode("valid") != nil) and - (pilot.getNode("valid").getValue()) and - (pilot.getNode("sim/model/path") != nil)) { - var type = pilot.getNode("sim/model/path").getValue(); - - if (type == me.copilot_type) { - append(res, pilot.getNode("callsign").getValue()); - } - } - } -# debug.dump(res); - return res; -} -############################################################################### diff --git a/test/neo4j.nas b/test/neo4j.nas deleted file mode 100644 index da44c4a..0000000 --- a/test/neo4j.nas +++ /dev/null @@ -1,162 +0,0 @@ -import("lib.nas"); - -rand(time(0)); -var chartable='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; -var node=func(type) -{ - var s=""; - for(var i=0;i<10;i+=1) - s~=chr(chartable[rand()*62]); - return {name:s,type:type,next:[]}; -} -var film_node=[]; -for(var i=0;i<1000;i+=1) - append(film_node,node("film")); -var director_node=[]; -for(var i=0;i<200;i+=1) - append(director_node,node("direct")); -var actor_node=[]; -for(var i=0;i<400;i+=1) - append(actor_node,node("actor")); -var writer_node=[]; -for(var i=0;i<100;i+=1) - append(writer_node,node("writer")); -var type_node=[]; -for(var i=0;i<40;i+=1) - append(type_node,node("type")); -var lang_node=[]; -for(var i=0;i<120;i+=1) - append(lang_node,node("lang")); -var country_node=[]; -for(var i=0;i<120;i+=1) - append(country_node,node("country")); - -func() -{ - var director_size=size(director_node); - var actor_size=size(actor_node); - var writer_size=size(writer_node); - var type_size=size(type_node); - var lang_size=size(lang_node); - var country_size=size(country_node); - - foreach(var film;film_node) - { - var director_link=int(1+rand()*2); - var actor_link=int(1+rand()*20); - var writer_link=int(1+rand()*2); - var type_link=int(1+rand()*5); - var lang_link=int(1+rand()*4); - var country_link=int(1+rand()*4); - for(var i=0;i10?10:list_size; - for(var i=1;i=list_size) - die("choose a correct index"); - get_next(num(choose)); -} - -foreach(var film;film_node) - setsize(film.next,0); diff --git a/test/smartscreen.nas b/test/smartscreen.nas deleted file mode 100644 index ac5d13c..0000000 --- a/test/smartscreen.nas +++ /dev/null @@ -1,210 +0,0 @@ -var smartScreen = canvas.new({ - "name": "smartScreen", # The name is optional but allow for easier identification - "size": [2048, 2048], # Size of the underlying texture (should be a power of 2, required) [Resolution] - "view": [768, 768], # Virtual resolution (Defines the coordinate system of the canvas [Dimensions] - # which will be stretched the size of the texture, required) - "mipmapping": 1 # Enable mipmapping (optional) -}); - -smartScreen.addPlacement({"node": "screen", "texture": "screen.jpeg"}); -var group = smartScreen.createGroup(); - -# Create a text element and set some values -var text = group.createChild("text", "optional-id-for element") - .setTranslation(10, 20) # The origin is in the top left corner - .setAlignment("left-center") # All values from osgText are supported (see $FG_ROOT/Docs/README.osgtext) - .setFont("LiberationFonts/LiberationSans-Regular.ttf") # Fonts are loaded either from $AIRCRAFT_DIR/Fonts or $FG_ROOT/Fonts - .setFontSize(14, 1.2) # Set fontsize and optionally character aspect ratio - .setColor(1,0,0) # Text color - .setText("This is a text element"); -text.hide(); -text.setText("SELF TEST NORMAL").show(); - - - -var ui_root = smartScreen.createGroup(); -var vbox = canvas.VBoxLayout.new(); -smartScreen.setLayout(vbox); - - -var button_onl = canvas.gui.widgets.Button.new(ui_root, canvas.style, {}).setText("Online OSM").listen("clicked", func showOnlineMap()); -var button_offl = canvas.gui.widgets.Button.new(ui_root, canvas.style, {}).setText("Offline OSM").listen("clicked", func showOfflineMap()); -button_onl.setSizeHint([32, 128]); -button_offl.setSizeHint([32, 128]); - -var label = canvas.gui.widgets.Label.new(ui_root, canvas.style, {}); - -var button_box = canvas.HBoxLayout.new(); -button_box.addItem(button_onl); -button_box.addItem(button_offl); -button_box.addItem(label); -button_box.addStretch(1); - -vbox.addItem(button_box); -vbox.addStretch(1); - - -var showOnlineMap = func(){ - TestMap.show(); - g.hide(); - label.setText("Online Mode"); -} - - -var showOfflineMap = func(){ - TestMap.hide(); - g.show(); - label.setText("Offline Mode"); -} - - -# Online Map using MapStructure -var TestMap = smartScreen.createGroup().createChild("map"); -TestMap.setTranslation(smartScreen.get("view[0]")/2,smartScreen.get("view[1]")/2); - - -var ctrl_ns = canvas.Map.Controller.get("Aircraft position"); -var source = ctrl_ns.SOURCES["map-dialog"]; -if (source == nil) { - # TODO: amend - var source = ctrl_ns.SOURCES["map-dialog"] = { - getPosition: func subvec(geo.aircraft_position().latlon(), 0, 2),# ? ? ? - getAltitude: func getprop('/position/altitude-ft'), - getHeading: func { - if (me.aircraft_heading) - getprop('/orientation/heading-deg'); - else - 0; - }, - aircraft_heading: 1, - }; -} -setlistener("/sim/gui/dialogs/map-canvas/aircraft-heading-up", func(n){source.aircraft_heading = n.getBoolValue();}, 1); -TestMap.setController("Aircraft position", "map-dialog"); -TestMap.setRange(1); - -var r = func(name,vis=1,zindex=nil){return caller(0)[0];}; -# TODO: we'll need some z-indexing here, right now it's just random - -foreach(var type; [r('APS')] ){ - TestMap.addLayer(factory: canvas.SymbolLayer, type_arg: type.name, visible: type.vis, priority: 2); -} - -foreach(var type; [ r('OSM')]) { - TestMap.addLayer(factory: canvas.OverlayLayer, - type_arg: type.name, - visible: type.vis, - priority: 1); -} - - -TestMap.hide(); - -# Offline map - -var g = smartScreen.createGroup(); -var zoom = 15; -var type = "intl"; -var tile_size = 256; - - -var changeZoom = func(d) -{ - zoom = math.max(2, math.min(19, zoom + d)); - updateTiles(); -} - -# http://polymaps.org/docs/ -# https://github.com/simplegeo/polymaps -# https://github.com/Leaflet/Leaflet - -var maps_base = getprop("/sim/fg-home") ~ '/cache/maps'; - -var makePath = -string.compileTemplate(maps_base ~ '/osm-{type}/{z}/{x}/{y}.jpg'); -var num_tiles = [4, 4]; - -var center_tile_offset = [(num_tiles[0]-1)/2, (num_tiles[1]-1)/ 2]; - -# simple aircraft icon at current position/center of the map -g.createChild("path") - .moveTo( tile_size*center_tile_offset[0]-10, tile_size*center_tile_offset[1]) - .horiz(20) - .move(-10,-10) - .vert(20) - .set("stroke", "red") - .set("stroke-width", 2) - .set("z-index", 1); - -# initialize the map by setting up -# a grid of raster images - -var tiles = setsize([], num_tiles[0]); -for(var x=0; x