Sign in to follow this  
Guest bartels

xml difficult(?) string questions

Recommended Posts

Hallo,1. Does anyone of you knows a "string", which gives the heading, bearing to a NAV-station?2. And is it possible to use this value, eg 312, in a SET command?Something like:1. ((A:NAV1 Radians, degrees))%!3d! or bearing etc.2. (A:.......) if{ (A:NAV1 Radians, degrees) >K:Heading Set } ?????????I am curious!Janhttp://community.webshots.com/sym/image4/2...75aouncN_ph.jpg

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

1.<String>%((A:NAV1 Radial, degrees) 180 + 360 % )%!.0f!</String>2.(>K:HEADING_BUG_SET)Arne Bartels

Share this post


Link to post
Share on other sites

Thanks Arne,To my surprise the next one will steer the plane to the facility.(A:NAV1 HAS NAV,bool) 1 == if{ (A:NAV1 radial, degrees) 180 + (>K:HEADING_BUG_SET) }Now looking for a way to automatically select the next frequency's after station passing, using my database with xml-navaids.Something with TOFROM etc.???????????(I try to make an XML-FMC)More questions will follow........Janhttp://community.webshots.com/sym/image4/2...75aouncN_ph.jpg

Share this post


Link to post
Share on other sites

To-From has nothing to do with flying to and from a navaid, that is it is if you have also tuned the radial you are heading, and only for VORs, for ILSs it's useless. It might be possible somehow with calculating the distance and checking, if you approach or depart from a NAVAID or come near enough, DME is not sufficient for this purpose. Arne Bartels

Share this post


Link to post
Share on other sites

Need advice.This works! (L:test, bool) 1 == (A:HSI TF flags, enum) 1 == (A:NAV1 HAS NAV,bool) 1 == && && if{ (A:NAV1 radial, degrees) 180 + (>K:HEADING_BUG_SET) (A:NAV1 radial, degrees) 180 + (>K:VOR1_SET) }(L:test, bool) 1 == (A:HSI TF flags, enum) 2 == && if{ (>K:HEADING_BUG_SET) }(L:test, bool) 1 == (A:HSI TF flags, enum) 2 == && if{ 112.10 100 * 10000 % int d 10 % r 10 / int d 10 % r 10 / int d 10 % r 10 / int 16 * + 16 * + 16 * + (>K:NAV1_RADIO_SET) }(L:test, bool) 1 == (A:HSI TF flags, enum) 2 == && if{ 114.20 100 * 10000 % int d 10 % r 10 / int d 10 % r 10 / int d 10 % r 10 / int 16 * + 16 * + 16 * + (>K:NAV1_RADIO_SET) }etc etcIn other words: enroute, after station passage, frequency and obs change automatically and the plane heads to the next vor (112.10) or holds the last heading.Have been experimenting with more vor's but always the last frequency is chosen, in this case 114.20.Any ideas how to solve that problem, so there can be more stations in a row?Janhttp://community.webshots.com/sym/image4/2...75aouncN_ph.jpg

Share this post


Link to post
Share on other sites

Of course last frequency is chosen. You can't distinguish with the toggling TF flag over which VOR you have flown. With your logic both frequencies are set to NAV1 at the same time, or better first 112.10, then almost immediately after theat 114.20, so 114.20 persists. You can different things, check also the ident to identify the sations, or place the frequencies in a row, use an index that increases and select per "case" in the value line.Something like <Value>... if{ (L:waypoint index,number) ++ (>L:waypoint index,number) 112.10 114.20 2 (L:waypoint index,number) case .... (>K:NAV1_RADIO_SET}...</Value>Arne Bartels

Share this post


Link to post
Share on other sites

Arne, you mean something like this:(A:HSI TF flags, enum) 2 == if{ (L:NAV,number) ++ (>L:NAV,number) 112.10 100 * 10000 % int d 10 % r 10 / int d 10 % r 10 / int d 10 % r 10 / int 16 * + 16 * + 16 * + 114.20 100 * 10000 % int d 10 % r 10 / int d 10 % r 10 / int d 10 % r 10 / int 16 * + 16 * + 16 * + 113.20 100 * 10000 % int d 10 % r 10 / int d 10 % r 10 / int d 10 % r 10 / int 16 * + 16 * + 16 * + 109.90 100 * 10000 % int d 10 % r 10 / int d 10 % r 10 / int d 10 % r 10 / int 16 * + 16 * + 16 * + etc. etc.117.80 100 * 10000 % int d 10 % r 10 / int d 10 % r 10 / int d 10 % r 10 / int 16 * + 16 * + 16 * + 5 (L:NAV,number) case (>K:NAV1_RADIO_SET) }Doesn't work so properly.What is the first chosen frequency, the last in this stock i presume?Janhttp://community.webshots.com/sym/image4/2...75aouncN_ph.jpg

Share this post


Link to post
Share on other sites

Sorry I only know that "case" works, not exactly how, I need to investigate this to be sure.I personally would shift the float BCD conversion to the end so you need it only once, e.g:<Value>(A:HSI TF flags, enum) 2 == if{ (L:NAV,number) ++ (>L:NAV,number)112.10 114.20113.20109.90117.805 (L:NAV,number) case 100 * 10000 % int d 10 % r 10 / int d 10 % r 10 / int d 10 % r 10 / int 16 * + 16 * + 16 * + (>K:NAV1_RADIO_SET) }</Value<It is shorter and less error prone, you can even copy the part to a <String> element to check the frequencies that would be selected selected. It is not implemented how the first frequency is set in the first place.Arne Bartels

Share this post


Link to post
Share on other sites

Hallo,With the no problems, but the frequency's are a mess.Sometimes the next one is chosen, mostly the last.I cannot find the proper solution and am stuck with the FMC.This is what i have:%( 115.60 117.30 112.10 116.80 112.80 109.00 114.10 7 (L:NAV,number) case)%!6.2f! (A:HSI TF flags, enum) 2 == if{ (L:NAV,number) ++ (>L:NAV,number) 115.60 117.30 112.10 116.80 112.80 109.00 114.10 7 (L:NAV,,number) case 100 * 10000 % int d 10 % r 10 / int d 10 % r 10 / int d 10 % r 10 / int 16 * + 16 * + 16 * + (>K:NAV1_RADIO_SET) 1(>K:TOGGLE_AFTERBURNER2) }Any ideas??Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

I tried a bit and it worked (mostly). One problem is that it is possible that frequencies are stepped over, since they might be FROM before the correct course is selected. As one solution (their might be others) I thought that waypoint switching should only be possible, if you aren't far from the VOR, instead of the real distance NAV1 SIGNAL is chosen.

<Element><Select><Value> (A:HSI TF flags, enum) 2 == (A:NAV1 SIGNAL,number) 40000 > && if{ (G:Var2) ++ (>G:Var2) 115.20 116.50 117.45 112.90 115.10 110.60 117.30 7 (G:Var2) case 100 * 10000 % int d 10 % r 10 / int d 10 % r 10 / int d 10 % r 10 / int 16 * + 16 * + 16 * + (>K:NAV1_RADIO_SET)  }</Value></Select></Element>

Don't forget the frequencies are run through from end to begin.BTW instead of using strings, you can also use the <Tooltip> for "debugging info", e.g.

<Tooltip>%((G:Var2))%!d! %((A:NAV1 SIGNAL,number))%!.1f!%</Tooltip>

See also the pic for a successful flown flightplan.Arne Bartels

Share this post


Link to post
Share on other sites

Arne,To my surprise the previous mentioned stuff works suddenly(?} reasonable.It seems that a good startup-situation, plane- and fmc setup is a must.Your code looks again better, so back to the drawing board.I use the string in a sort of "PROG-page" of the fmc.Next step ADF and ISECS if at all possible?????????????Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

Found out that range of the VOR and flightlevel are important factors too (of course).Don't understand what(A:NAV1 SIGNAL,number) 40000 >really does.The whole thing remains pretty unstable still.What about setting and flying to an AIRPORT (or coordinate)? Making a rudimentary xml-gps.Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

As I said, the signal strength is an indirect measure for the distance. To get the bearing to an airport (or any other waypoint), you have to calculate the distance from the coordinates.Arne Bartels

Share this post


Link to post
Share on other sites

Arne,Now it becomes a little bit confusing.Say distance from KATL to KLAS is 2000 NMThe heading should be approximately 270 degrees, but is changing constantly because of the great circle(?).How can i put that in an xml value?What is anyway the relation between a waypoint and distance to go concerning the heading to that waypoint?Can you give an example (in xml??)JanNotso"Procul Negotiis"

Share this post


Link to post
Share on other sites

My honest opinion? In XML is great circle navigation maybe a bit too far, though possible. For shorter distances (up to several hundred nm) you don't need great circle navigation and can work with "plain" trigonometry (not exactly the same as loxodromes, but if you want to implement loxodromes, you can also use great circles, it is as complicated).The distance along longitudes is dy=deltalon*60 (lat lon in degrees, distances in nm), the distance along latitudes is dx=deltalat*60/cos(latitude). Direct distance is then sqrt(dx*dx+dy*dy), the bearing is atan(dy/dx) (use atan2 here).One of the main error in calculations like this, is the confusuiion between angles in degrees and radians, so be aware of it!Arne Bartels

Share this post


Link to post
Share on other sites

Very kind of you Arne, but this requires a lot off study in my high school mathematics books and i don't have them anymore.....%((A:Forgotten,hic..))!!!.f %((A:Lost Anatomical Mathematics HUMP,bool)) 1== ((P: abs no time,days)) && && etc.Though i shall try to implement your suggestions to calculate a floating heading to my desired point of destination.Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

An example:Waypoint 1 =E004,...; N52,...Waypoint 2 =W084,...; N33,...Distance LON=84+4=88*60=5280 NMDistance LAT=52-33=19*60=1140 NM?? COSLAT=COS19=0,9987 ??Distance LAT=1140/0,9987=1153Real Distance between 1 and 2=(Pythagoras)5280*5280+1153*1153=30470400+1329409=31799809SQRT=5639,13 NMBearing=atan2 1153/5280=1,355800146In degrees: 77,68162621Considering flying from E to W i think i have to add 180, so the end of the calculation =257,6 degreesFSNAV gives 257 degrees.So i think that looks ok, but of course starting in 1 and heading 257 never brings me to 2.I must add a lot of shorter legs.But how to set above formulas in XML?Will try and let you know.Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

coslat is the cosine of the average latitude. For small distances you can use either the one from the startpoint or from the endpoint. As a said before it is only valid for small distances, more than 5000nm is much too far. The assumption for the formula is, that the earth is flat, which might be locally acceptable, but not too far out.Last point you need the signs for dx,dy for the correct course. Assuming a flight from Waypoint 1 to Waypoint 2 it would be: Distance LON=84-(-4)=88deg, Distance LAT=33-52=-19deg COSLAT=cos((52+33)/2) and so on.Arne Bartels

Share this post


Link to post
Share on other sites

Small Question Arne, I think arteriosclerosis cerebri is hitting so i could be very wrong but,Distance Lon =84-(-4)=88*60=5280 NMMeasured over say (33+52)/2=42.5 LATIsn't that 5280*sin(42.5)=3567,12 NMSo real distance between 1 and 2 becomes SQRT (12724318,67+1299600,00)=3744,85 NMWhich gives an atan2 of 1,26 = 72,28 degrees so steer 252,28The other calculation gives Dist Lon=5280 NMcos(42,5)=0,74so coslat=(33-52)*60=-1140/0,74=-1546,23 NMReal distance is the SQRT etc.=5502 NMWhich gives an atan2 1,86 = 106,32 degrees so steer 286,32Don't know anymoreLast one looks more realistic in vieuw of reality. Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

Oops. First the distance along the longitudes is of course the difference in latitudes (longitude constant). And distance along latitudes is difference in longitudes*cos(latitude) (latitudes constant). Second the distance along a latitude is dlon*cos(lat) not dlon/cos(lat) sorry. You divide to get from distances to lon diffs. From lon diffs to distance you multiplicate (the lengths of latitude circles are 360*60*cos(lat), shorter to the poles). From Point1 N52E040 to N33W84:dx=((-84)-4)*60*cos((52+33)/2)=-3893nmdy=(33-52)*60=-1140nmdist=4056crs=(atan2(dx,dy)+360)%360=(-106.3+360)%360=253.7 atan alone would give 73.7, but since you have two cancelling minus in the arguments you have to map it in the third quadrant (+180). atan2 is easier for this, it takes control of the quadrants itself, you might need to modulo the angle to positive values with ..+360)%360.. though.Again over so large distances the calculation is pretty wrong compared to great circle routines. Apart from that, great circle need just a bit more cos/sin stuff.Arne Bartls

Share this post


Link to post
Share on other sites

Arne,To bring things a step further: 1. Do i need diff. and integral calcs for the great circle?2. Taking the Plane's position at a certain moment, Lat Lon (Time), it seems possible to calculate distance and angle to a fixed waypoint.Then i could bring the results (the constant changing angle, heading, dependant of plane's pos) in the autopilot and use the distances for other calcs like flightlevel, speed etc.To construct this in XML is another matter, but i 'll try.Good Eastern! (if this is the last post, which i doubt)Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

Hallo all, Good Eastern!Again a summary of my idea:1. To make an xml-fmc.2. To let the plane, dependant of weight, weather, distance etc. fly the whole route automatically. 3. To set the heading in the autopilot by calculating course to a waypoint using the plane

Share this post


Link to post
Share on other sites

Good morningThis one seems the real problem, can't find the proper synthax, but it will set the heading to the waypoint: ((waypoint LATITUDE,number) (A: PLANE LATITUDE, number) -)(((waypoint LONGITUDE,number) (A: PLANE LONGITUDE, number) -) (((waypoint LATITUDE,number) (A: PLANE LATITUDE, number) + ) acos) * ) degrees atan2(>K:HEADING_BUG_SET)Questions:1. How to write the WAYPOINTS coordinates, numbers in XML?2. How to write the proper synthax?3. At all possible??I know it is a lot....Jan"Procul Negotiis"

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this