WN-Dotzigen Posted October 24, 2009 Report Share Posted October 24, 2009 Dear friends! I tried to get Latitude-readings with Chris Brett's VB-Programm "UIPCHello" (included in Pete Dowson's "FSUIPC_SDK.zip" ; thank you a lot, Chris and Pete! ...but I would be greatful for further help; I'm not a professional programmer... :oops: ). I supplemented Chris' program code in the "Private Sub Timer1_Timer()"-section with "FSUIPC_Read(&H560, 8, VarPtr(Latitude(1)), dwResult)", where the Variable "Latitude(i)" was either: "Dim Latitude(8) As Byte" or "Dim Latitude(8) As Integer" or "Dim Latitude(8) As Long" or "Dim Latitude(8) As Double" (For Details see below) Whereas the Clock-bytes were always correctly transmitted, the &H560 - &H568 yielded: ====================================================================== for "Ranch Texas" Latitude 29.6452214482156 [list=] -----------Byte--------- Integ---------------------Long-------------------Double 1 0 0 1317470208 1.03739986505718E-307 2 0 20103 3319350 3 135 -22986 0 0 4 78 50 0 0 5 54 0 0 0 6 166 0 0 0 7 50 0 0 0 8 0 0 0 0 ====================================================================== for "Seattle Tacoma" Latitude 47.4314848387555 ...........Byte.........Integer....................Long.....................Double 1............0...........0........................1119944704.............3.65588727537466E-307 2............0...........17089...................5271087 3............193........28207...................0........................0 4............66.........80........................0........................0 5............47..........0........................0........................0 6............110.........0........................0.......................0 7.............80.........0........................0.......................0 8..............0.........0.........................0......................0 ====================================================================== for "Canberra Austr" Latitude -35.3143320222001 .............Byte........Integer....................Long..................Double 1.............0............0.....................-1446117376........-2.82530817051241E+307 2.............0...........-22066...............-3924502.............0 3............206..........7658..................0.....................0 4............169.........-60.....................0.....................0 5............234...........0.....................0.....................0 6.............29...........0.....................0.....................0 7.............196..........0.....................0....................0 8............255...........0....................0.....................0 ====================================================================== COPY OF MODIFIED PRIVATE SUB TIMER: Private Sub Timer1_Timer() Dim dwResult As Long Dim auiTime() As Byte Dim Latitude(8) As Byte 'Dim Latitude(8) As Integer 'Dim Latitude(8) As Long 'Dim Latitude(8) As Double ReDim auiTime(3) ' As an example of retrieving data, we will get the FS clock time. ' If we wanted additional reads/writes at the same time, we could put them here If FSUIPC_Read(&H238, 3, VarPtr(auiTime(1)), dwResult) Then ' "Read" proceeded without any problems If FSUIPC_Process(dwResult) Then ' "Process" proceeded without any problems lblClock.Caption = Format(auiTime(1), "00") & ":" & _ Format(auiTime(2), "00") & ":" & _ Format(auiTime(3), "00") Else ' Unable to "Process" lblClock.Caption = "Processing: " & ResultText(dwResult) End If Else ' Unable to "Read" lblClock.Caption = "Reading: " & ResultText(dwResult) End If ' The same for Latitude: If FSUIPC_Read(&H560, 8, VarPtr(Latitude(1)), dwResult) Then ' "Read" proceeded without any problems If FSUIPC_Process(dwResult) Then ' "Process" proceeded without any problems For i = 1 To 8 txtLat(i).Text = Latitude(i) 'of course I placed 8 Text(i)-fields on the form Next i End If End If End Sub ======================================================================== I am aware that crude data from &H560 to &H568 necessitates calculation to get Latitude. "FSUIPC for Programmers.pdf" (in "FSUIPC_SDK.zip") says: "Latitude of aircraft in FS units. To convert to Degrees: If your compiler supports long long (64-bit) integers then use such a variable to simply copy this 64-bit value into a double floating point variable and multiply by 90.0/(10001750.0 * 65536.0 * 65536.0). Otherwise you will have to handle the high 32-bits and the low 32-bits separately, combining them into one double floating point value (say dHi). To do, copy the high part (the 32-bit int at 0564) to one double and the low part (the 32-bit unsigned int at 0560) to another (say dLo). Remember that the low part is only part of a bigger number, so doesn‘t have a sign of its own. Divide dLo by (65536.0 * 65536.0) to give it its proper magnitude compared to the high part, then either add it to or subtract it from dHi according to whether dHi is positive or negative. This preserves the integrity of the original positive or negative number. Finally multiply the result by 90.0/10001750.0 to get degrees. Either way, a negative result is South, positive North." But unfortunately I could not solve this SODOKU... :? Thank you for help. Werner.niederer(a°t)sunrise.ch, Switzerland Link to comment Share on other sites More sharing options...
WN-Dotzigen Posted October 24, 2009 Author Report Share Posted October 24, 2009 Dear friends!I tried to get Latitude-readings with Chris Brett's VB-Programm "UIPCHello" (included in Pete Dowson's "FSUIPC_SDK.zip" ; thank you a lot, Chris and Pete! ...but I would be greatful for further help; I'm not a professional programmer... :oops: ). I supplemented Chris' program code in the "Private Sub Timer1_Timer()"-section with "FSUIPC_Read(&H560, 8, VarPtr(Latitude(1)), dwResult)", where the Variable "Latitude(i)" was either: "Dim Latitude(8) As Byte" or "Dim Latitude(8) As Integer" or "Dim Latitude(8) As Long" or "Dim Latitude(8) As Double" (For Details see below) Whereas the Clock-bytes were always correctly transmitted, the &H560 - &H568 yielded: ====================================================================== for "Ranch Texas" Latitude 29.6452214482156 [list=] -----------Byte--------- Integ---------------------Long-------------------Double 1..........0...............0......................1317470208.......... 1.03739986505718E-307 2..........0...............20103................3319350................0 3 .........135............-22986................0........................0 4 .........78.............50.....................0........................0 5..........54.............0......................0........................0 6 .........166............0......................0........................0 7..........50.............0......................0........................0 8..........0..............0......................0........................0 ====================================================================== for "Seattle Tacoma" Latitude 47.4314848387555 Byte Integ Long Double 1 0 0 1119944704 3.65588727537466E-307 2 0 17089 5271087 3 193 28207 0 0 4 66 80 0 0 5 47 0 0 0 6 110 0 0 0 7 80 0 0 0 8 0 0 0 0 ====================================================================== for "Canberra Austr" Latitude -35.3143320222001 Byte Integ Long Double 1 0 0 -1446117376 -2.82530817051241E+307 2 0 -22066 -3924502 0 3 206 7658 0 0 4 169 -60 0 0 5 234 0 0 0 6 29 0 0 0 7 196 0 0 0 8 255 0 0 0 ====================================================================== COPY OF MODIFIED PRIVATE SUB TIMER: Private Sub Timer1_Timer() Dim dwResult As Long Dim auiTime() As Byte Dim Latitude(8) As Byte 'Dim Latitude(8) As Integer 'Dim Latitude(8) As Long 'Dim Latitude(8) As Double ReDim auiTime(3) ' As an example of retrieving data, we will get the FS clock time. ' If we wanted additional reads/writes at the same time, we could put them here If FSUIPC_Read(&H238, 3, VarPtr(auiTime(1)), dwResult) Then ' "Read" proceeded without any problems If FSUIPC_Process(dwResult) Then ' "Process" proceeded without any problems lblClock.Caption = Format(auiTime(1), "00") & ":" & _ Format(auiTime(2), "00") & ":" & _ Format(auiTime(3), "00") Else ' Unable to "Process" lblClock.Caption = "Processing: " & ResultText(dwResult) End If Else ' Unable to "Read" lblClock.Caption = "Reading: " & ResultText(dwResult) End If ' The same for Latitude: If FSUIPC_Read(&H560, 8, VarPtr(Latitude(1)), dwResult) Then ' "Read" proceeded without any problems If FSUIPC_Process(dwResult) Then ' "Process" proceeded without any problems For i = 1 To 8 txtLat(i).Text = Latitude(i) 'of course I placed 8 Text(i)-fields on the form Next i End If End If End Sub ======================================================================== I am aware that crude data from &H560 to &H568 necessitates calculation to get Latitude. "FSUIPC for Programmers.pdf" (in "FSUIPC_SDK.zip") says: "Latitude of aircraft in FS units. To convert to Degrees: If your compiler supports long long (64-bit) integers then use such a variable to simply copy this 64-bit value into a double floating point variable and multiply by 90.0/(10001750.0 * 65536.0 * 65536.0). Otherwise you will have to handle the high 32-bits and the low 32-bits separately, combining them into one double floating point value (say dHi). To do, copy the high part (the 32-bit int at 0564) to one double and the low part (the 32-bit unsigned int at 0560) to another (say dLo). Remember that the low part is only part of a bigger number, so doesn‘t have a sign of its own. Divide dLo by (65536.0 * 65536.0) to give it its proper magnitude compared to the high part, then either add it to or subtract it from dHi according to whether dHi is positive or negative. This preserves the integrity of the original positive or negative number. Finally multiply the result by 90.0/10001750.0 to get degrees. Either way, a negative result is South, positive North." But unfortunately I could not solve this SODOKU... :? Thank you for help. Werner.niederer(a°t)sunrise.ch, Switzerland Link to comment Share on other sites More sharing options...
Pete Dowson Posted October 24, 2009 Report Share Posted October 24, 2009 "FSUIPC_Read(&H560, 8, VarPtr(Latitude(1)), dwResult)", where the Variable "Latitude(i)" was either: "Dim Latitude(8) As Byte" or "Dim Latitude(8) As Integer" or "Dim Latitude(8) As Long" or "Dim Latitude(8) As Double" I'm afraid, though I don't know VB at all, I do know that the 64-bit integer value you are reading is none of those types. In C/C++ it would be either an _int64 or a "long long" according to which compiler you were using. Of course using a 64-bit compiler it would simply be an "int" (integer), but mostly folks are still compiling for 32-bits. Maybe someone who knows VB can help, or possibly you can find a book on the subject? BTW I am pretty sure that dimensioning an array of, for example, 8 doubles will reserve space for 8 x 8 = 64 bytes of data. Similarly 8 Integers will be 8 x 4 = 32 bytes. P.S. I see you quoted verbatim my own text on the offset, and there you will read a potential solution, should your VB compile not support 64-bit integers at all. Read this part again: Otherwise you will have to handle the high 32-bits and the low 32-bits separately, combining them into one doublefloating point value (say dHi). To do, copy the high part (the 32-bit int at 0564) to one double and the low part (the 32-bit unsigned int at 0560) to another (say dLo). Remember that the low part is only part of a bigger number, so doesn‘t have a sign of its own. Divide dLo by (65536.0 * 65536.0) to give it its proper magnitude compared to the high part, then either add it to or subtract it from dHi according to whether dHi is positive or negative. This preserves the integrity of the original positive or negative number. Finally multiply the result by 90.0/10001750.0 to get degrees. So, try that. Dimension an array of two integers to read the 64 bits into, and follow the documented procedure. The Hight part will be in the second element, the Low part in the first. Regards Pete Link to comment Share on other sites More sharing options...
WN-Dotzigen Posted October 24, 2009 Author Report Share Posted October 24, 2009 Dear friends!I tried to get Latitude-readings with Chris Brett's VB-Programm "UIPCHello" (included in Pete Dowson's "FSUIPC_SDK.zip" ; thank you a lot, Chris and Pete! ...but I would be greatful for further help; I'm not a professional programmer... :oops: ). I supplemented Chris' program code in the "Private Sub Timer1_Timer()"-section with "FSUIPC_Read(&H560, 8, VarPtr(Latitude(1)), dwResult)", where the Variable "Latitude(i)" was either: "Dim Latitude(8) As Byte" or "Dim Latitude(8) As Integer" or "Dim Latitude(8) As Long" or "Dim Latitude(8) As Double" (For Details see below) Whereas the Clock-bytes were always correctly transmitted, the &H560 - &H568 yielded: ====================================================================== for "Ranch Texas" Latitude 29.6452214482156 [list=] -----------Byte--------- Integ---------------Long-------------------Double 1..........0..............0..................1317470208...........1.03739986505718E-307 2..........0.............20103 .............3319350...............0 3..........135..........-22986.............0.......................0 4...........78..........50...................0......................0 5...........54...........0...................0......................0 6..........166...........0...................0......................0 7...........50...........0...................0......................0 8............0...........0...................0......................0 ====================================================================== for "Seattle Tacoma" Latitude 47.4314848387555 ...........Byte.........Integer....................Long.....................Double 1............0...........0........................1119944704.............3.65588727537466E-307 2............0...........17089...................5271087 3............193........28207...................0........................0 4............66.........80........................0........................0 5............47..........0........................0........................0 6............110.........0........................0.......................0 7.............80.........0........................0.......................0 8..............0.........0.........................0......................0 ====================================================================== for "Canberra Austr" Latitude -35.3143320222001 .............Byte........Integer....................Long..................Double 1.............0............0.....................-1446117376........-2.82530817051241E+307 2.............0...........-22066...............-3924502.............0 3............206..........7658..................0.....................0 4............169.........-60.....................0.....................0 5............234...........0.....................0.....................0 6.............29...........0.....................0.....................0 7.............196..........0.....................0....................0 8............255...........0....................0.....................0 ====================================================================== COPY OF MODIFIED PRIVATE SUB TIMER: Private Sub Timer1_Timer() Dim dwResult As Long Dim auiTime() As Byte Dim Latitude(8) As Byte 'Dim Latitude(8) As Integer 'Dim Latitude(8) As Long 'Dim Latitude(8) As Double ReDim auiTime(3) ' As an example of retrieving data, we will get the FS clock time. ' If we wanted additional reads/writes at the same time, we could put them here If FSUIPC_Read(&H238, 3, VarPtr(auiTime(1)), dwResult) Then ' "Read" proceeded without any problems If FSUIPC_Process(dwResult) Then ' "Process" proceeded without any problems lblClock.Caption = Format(auiTime(1), "00") & ":" & _ Format(auiTime(2), "00") & ":" & _ Format(auiTime(3), "00") Else ' Unable to "Process" lblClock.Caption = "Processing: " & ResultText(dwResult) End If Else ' Unable to "Read" lblClock.Caption = "Reading: " & ResultText(dwResult) End If ' The same for Latitude: If FSUIPC_Read(&H560, 8, VarPtr(Latitude(1)), dwResult) Then ' "Read" proceeded without any problems If FSUIPC_Process(dwResult) Then ' "Process" proceeded without any problems For i = 1 To 8 txtLat(i).Text = Latitude(i) 'of course I placed 8 Text(i)-fields on the form Next i End If End If End Sub ======================================================================== I am aware that crude data from &H560 to &H568 necessitates calculation to get Latitude. "FSUIPC for Programmers.pdf" (in "FSUIPC_SDK.zip") says: "Latitude of aircraft in FS units. To convert to Degrees: If your compiler supports long long (64-bit) integers then use such a variable to simply copy this 64-bit value into a double floating point variable and multiply by 90.0/(10001750.0 * 65536.0 * 65536.0). Otherwise you will have to handle the high 32-bits and the low 32-bits separately, combining them into one double floating point value (say dHi). To do, copy the high part (the 32-bit int at 0564) to one double and the low part (the 32-bit unsigned int at 0560) to another (say dLo). Remember that the low part is only part of a bigger number, so doesn‘t have a sign of its own. Divide dLo by (65536.0 * 65536.0) to give it its proper magnitude compared to the high part, then either add it to or subtract it from dHi according to whether dHi is positive or negative. This preserves the integrity of the original positive or negative number. Finally multiply the result by 90.0/10001750.0 to get degrees. Either way, a negative result is South, positive North." But unfortunately I could not solve this SODOKU... :? Thank you for help. Werner.niederer(a°t)sunrise.ch, Switzerland Link to comment Share on other sites More sharing options...
WN-Dotzigen Posted October 24, 2009 Author Report Share Posted October 24, 2009 Thank you, Pete, for quicker answer than I could debug my text... sorry that I'm not very familiar with programming. I just would like to connect my Tile-Finder to the FS. (See http://www.eumanagement.eu/FS/LOD/LOD.html#3). (unfortunatley I'm neither familiar with writing in forums: Please delete my doubled question; I did not manage to delete it myself :( ) Your text I quoted from "FSUIPC for Programmers.pdf" (in "FSUIPC_SDK.zip") ist for me too dificult to understand... Thank you anyway. Werner Link to comment Share on other sites More sharing options...
Pete Dowson Posted October 24, 2009 Report Share Posted October 24, 2009 etc etc etc Why have you sent the same message FOUR times, twice quoted? My reply has become sandwiched between your repeats!!! Pete Link to comment Share on other sites More sharing options...
Paul Henty Posted October 25, 2009 Report Share Posted October 25, 2009 Hi Werner, Looking at your code you don't seem to be doing the maths to get the Lattitude into the correct value. In the documentation is says: If your compiler supports long long (64-bit) integers then use such a variable to simply copy this 64-bit value into a double floating point variable and multiply by 90.0/(10001750.0 * 65536.0 * 65536.0). This tells you how to get the value out of that offset. You load it into a 64 bit integer (Long in VB.NET on a 32bit OS). Then you have to multiply the Long by 90.0/(10001750.0 * 65536.0 * 65536.0) to get the units right. The result of this calculation should be put into a Double. If you haven't gone too far with the old VB.NET SDK that you are using, I suggest you take a look at my FSUIPC Client DLL for .NET. It comes with extensive documentation and an example project in VB.NET. It is much easer to use than the SDK you are currently using. For example, if you use my DLL this is all the code you need to get the Lattitude and Longitude: Private latFS As Offset(Of Long) = New FSUIPC.Offset(Of Long)(&H560) Private lonFS As Offset(Of Long) = New FSUIPC.Offset(Of Long)(&H568) ' Convert Lat and Lon from FS Units into degrees (as a double). FSUIPCConnection.Process() Dim lat As Double = latFS.Value * 90D / (10001750D * 65536D * 65536D) Dim lon As Double = lonFS.Value * 360D / (65536D * 65536D * 65536D * 65536D) You can find it in the sticky at the top of this forum: http://forums.simflight.com/viewtopic.php?f=54&t=53255 Paul Link to comment Share on other sites More sharing options...
WN-Dotzigen Posted October 25, 2009 Author Report Share Posted October 25, 2009 Thank you Paul ! You are very kind. I will try your advices -- but it's well possible that my education is not sufficient. I will report my success or failure in a few days. Thanks! Werner (P.S.: I will avoid to touch the "Quote" button...) Link to comment Share on other sites More sharing options...
WN-Dotzigen Posted October 27, 2009 Author Report Share Posted October 27, 2009 Hi Paul As suspected I did not succeed. After several tryals I encountered your text: "The zip file contains the DLL, documentation and an example project in C# and Visual Basic.NET. NOTE: This dll will not work with Visual Studio 2003 or earlier as it uses 'generics' which were not invented until Visual Studio 2005." So I capitulated, since my VB is VB 6.0 from 1998. Never the less I'm still left with Chris Brett's program, which is working well for FS-time and would probably also work for FS-position (Lat;Long;altitude). In my first forum-text of this thread I tried to present data which I got for tree positions ("Ranch,Texas";"Seattle Tacoma" and "Canberra"). I also communicated, that I have read Pete Dawson's instruction to multiply the Lat-data by 90.0/(10001750.0 * 65536.0 * 65536.0)=2.095 109 149E-15 Since this is only a factor Lat-data(Ranch)/Lat-data(Seattle) should be equal to 29.6452214482156/47.4314848387555=0.625011457 But in fact all the ratios of data pairs I extracted from FS throug Chris'program do not fit to 0.625, be it "byte" or "integer" or "long" or "double". I tried to show this in my tabels; it was not easy to insert a table in the forum -- sorry that (while trying to get a table) I unintentionally touched the QUOTE-button twice. -- However: the extracted data change with the FS-position. They obviously have a relation with the FS-Position. The "SODOKU" remains. Anyway: A great THANK YOU that you tried to help an ignorant amateur. Werner Link to comment Share on other sites More sharing options...
Paul Henty Posted October 27, 2009 Report Share Posted October 27, 2009 So I capitulated, since my VB is VB 6.0 from 1998. Sorry Werner, For some reason I thought you were using VB.NET. Anyway, here is a thread that shows how to read the Longitude and Latitude using VB6. The code in the first post apparently works. The poster's problem was elsewhere. http://forums.simflight.com/viewtopic.php?f=54&t=72968&start=0&st=0&sk=t&sd=a I hope this helps. Paul Link to comment Share on other sites More sharing options...
WN-Dotzigen Posted October 28, 2009 Author Report Share Posted October 28, 2009 Hi Paul! :D A friend in need is a friend indeed! :) I would like to hug you and then, with a cup of champagne, :o three cheers for you! You are a philantrop and mastermind. I never would have had the idea to use currency-Type-variables (currency in general is something rather strange to me...). But your tip to try Emre5134's code worked perfectly. The simultaneous readings with obplacer_xml.exe prove it: Thank you! Werner in Dotzigen (near Bern), Switzerland Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now