|
From: <fli...@li...> - 2017-10-28 14:24:08
|
Revision: 3067
http://sourceforge.net/p/flightgear/fgaddon/3067
Author: rleibner
Date: 2017-10-28 14:24:06 +0000 (Sat, 28 Oct 2017)
Log Message:
-----------
setters validation
Modified Paths:
--------------
trunk/Addons/SpokenGCA/control.nas
trunk/Addons/SpokenGCA/gca_class.nas
trunk/Addons/SpokenGCA/parscreen_class.nas
Modified: trunk/Addons/SpokenGCA/control.nas
===================================================================
--- trunk/Addons/SpokenGCA/control.nas 2017-10-27 19:39:57 UTC (rev 3066)
+++ trunk/Addons/SpokenGCA/control.nas 2017-10-28 14:24:06 UTC (rev 3067)
@@ -61,6 +61,7 @@
var delta = demo.destination.rwy_object.heading - demo.rwyCrse;
# autoZoom:
if(dist<7 and abs(dist*math.sin(delta*D2R))<1.3 and Par.zoom >7) Par.setZoom(7,3000);
+ if((dist>=7 or abs(dist*math.sin(delta*D2R))>=1.3) and Par.zoom !=15) Par.setZoom(15,4000);
if (Par!=nil) Par.appendTrack(dist, delta,elev*M2FT);
if(demo.phrase=="oncourse"
Modified: trunk/Addons/SpokenGCA/gca_class.nas
===================================================================
--- trunk/Addons/SpokenGCA/gca_class.nas 2017-10-27 19:39:57 UTC (rev 3066)
+++ trunk/Addons/SpokenGCA/gca_class.nas 2017-10-28 14:24:06 UTC (rev 3067)
@@ -65,19 +65,16 @@
}, # del()
##### Setters:
-#~ TODO: validate setters arguments
-
-
setPosition: func(root) {
+if(props.getNode(root) == nil)
+ me.pError("setPosition",root);
me.root = root;
# AI/MP models have their own callsign node:
var callsign_node = props.getNode(root).getNode("callsign");
-
-# the main aircraft's callsign is stored under /sim/multiplay/callsign
-if (callsign_node == nil) {
-print("Using multiplayer callsign");
-callsign_node = props.getNode("/sim/multiplay/callsign");
-}
+if (callsign_node == nil) { # if not, get callsign under /sim/multiplay/callsign
+ print("Using multiplayer callsign");
+ callsign_node = props.getNode("/sim/multiplay/callsign");
+ }
else {
print("Using AI/MP callsign");
}
@@ -87,6 +84,8 @@
}, # setPosition()
setTransmissionInterval: func(secs) {
+if(secs < 0)
+ me.pError("setTransmissionInterval",secs);
me.phrase = 'prolog';
me.maxsecs = '5';
me.notifyReceivers(join("this"));
@@ -94,6 +93,9 @@
},
setAirport: func(airport) {
+var match = airportinfo(airport);
+if (match == nil or typeof(match) != 'ghost')
+ me.pError("setAirport",airport);
me.destination.airport = airport;
setprop("/gca/apt-name", airportinfo(airport).name);
me.destination.elevation = airportinfo(airport).elevation; # (m)
@@ -101,6 +103,9 @@
},
setRunway: func(rwy) {
+var match = airportinfo(me.destination.airport).runways;
+if (typeof(match)!="hash" or !size(keys(match)) or match[rwy] == nil)
+ me.pError("setRunway",rwy);
me.destination.runway = rwy;
me.destination.rwy_object = airportinfo(me.destination.airport).runways[rwy];
setprop("/gca/rwy-in-use", spell(rwy, 0));
@@ -112,11 +117,15 @@
},
setFinalApproach: func(final) {
+if(final < 3 or final > 20)
+ me.pError("setFinalApproach",final);
me.destination.final = final;
if(myDbg) printf("setFinalApproach(%i nm)", final);
},
setGlidepath: func(slope) {
+if(slope < 1 or slope > 180)
+ me.pError("setGlidepath",slope);
me.destination.glidepath = slope;
var gateAlt = me.destination.elevation*M2FT+ me.destination.final *math.tan( me.destination.glidepath*D2R)*NM2M *M2FT;
me.geoGate = geo.Coord.new().set_latlon(me.destination.rwy_object.lat
@@ -129,30 +138,42 @@
},
setSafetySlope: func(slope) {
-#~ me.destination.safety_slope = slope;
+# not used;
},
setTerrainResolution: func(nm) {
+if(nm < 0 or nm > 10)
+ me.pError("setTerrainResolution",nm);
me.TerrainResolution = nm;
},
setDecisionHeight: func(height) {
+if(height < 0 )
+ me.pError("setDecisionHeight",height);
me.destination.decision_height = height;
},
setTouchdownOffset: func(offset) {
+if(offset < 0 )
+ me.pError("setTouchdownOffset",offset);
me.destination.offset = offset;
},
setTransmissionChannel: func(node) {
+if (getprop(node) == nil)
+ me.pError("setTransmissionChannel",node);
me.TransmissionChannel = node;
},
setVertGrid: func(ft) {
+if(ft < 100 or ft > 4000)
+ me.pError("setVertGrid",ft);
me.VertGrid = ft;
},
setHzGrid: func(nm) {
+if(nm < 0.1 or nm > 10)
+ me.pError("setHzGrid",nm);
me.HzGrid = nm;
},
@@ -305,7 +326,7 @@
}
},
-openDialog:func() {
+openDialog: func() {
fgcommand("pause");
var min = minSlope(me.touch, me.destination.rwy_object.heading+180, me.destination.final *NM2M);
if(myDbg) printf("SafeSlop(%.2f)",min);
@@ -316,5 +337,9 @@
configureGCA(demo, defValues, mask);
#~ configureGCA(demo, defValues);
},
+
+pError: func(caller, value) {
+printf("Wrong arg value in %s(%s) !", caller,value);
+}
}; # end of GCAController class
Modified: trunk/Addons/SpokenGCA/parscreen_class.nas
===================================================================
--- trunk/Addons/SpokenGCA/parscreen_class.nas 2017-10-27 19:39:57 UTC (rev 3066)
+++ trunk/Addons/SpokenGCA/parscreen_class.nas 2017-10-28 14:24:06 UTC (rev 3067)
@@ -149,13 +149,10 @@
var y = int(me.y0-dist*math.sin(delta*D2R)*me.XYscale);
var z = int(me.z0 - (getprop("/position/altitude-ft") - rwyAlt) * me.Zscale);
if(myDbg) printf("x=%i ,y=%i, z=%i px ",x,y,z);
-#~ debug.dump(me.Track1.getNumCoords());
-
+print("numCoords=",me.Track1.getNumCoords());
if(me.Track1.getNumCoords() == 0) {
me.Track1.moveTo(x, z);
me.Track2.moveTo(x, y);
- #~ me.prev = [x,y,z];
- #~ print(111);
} else {
me.Track1.lineTo(x, z);
if(y>me.size.height*0.4) {
|