Jump to content
The simFlight Network Forums

Graham Pollitt

Members
  • Posts

    148
  • Joined

  • Last visited

Everything posted by Graham Pollitt

  1. Pete, you informed me to be efficient and do the reads/writes, then the processes instead of doing a separate process for each read/write. Im changing my code but am not too sure about how to separate the process from the reads. I will create an array to hold the data later on as it is messy having 30+ separate variables for similar things! Below is what I have started with. Running the below gives me a zerofuelweight of around 19909989090 with zero payloads :). If I run only the zerofuel weight section it runs fine and reports 1990lbs. The way I have incorrectly set the code out adds to the zerofuelweight. Any advice please on exactly how I can split them up into the sections that you recommend? Many thanks Graham Dim t1, t2, t3, t4, t5, t6, t7, t8, t9, t10 As Integer 'token Dim r1, r2, r3, r4, r5, r6, r7, r8, r9, r10 As Integer 'result Dim pay As Double 'temp holder for payload weight FSUIPC_Read(&H3BFC, 4, t1, r1) 'zero fuel weight FSUIPC_Read(&H1400, 8, t2, r2) 'payload station 0 FSUIPC_Read(&H1430, 8, t3, r3) 'payload station 1 FSUIPC_Read(&H1460, 8, t4, r4) 'payload station 2 FSUIPC_Read(&H1490, 8, t5, r5) 'payload station 3 FSUIPC_Read(&H14C0, 8, t6, r6) 'payload station 4 If FSUIPC_Process(r1) Then FSUIPC_Get(t1, ZeroFuelWT) ZeroFuelWT = ZeroFuelWT / 256 End If If FSUIPC_Process(r2) Then FSUIPC_Get(t2, pay) PayloadWT += pay End If If FSUIPC_Process(r3) Then FSUIPC_Get(t3, pay) PayloadWT += pay End If If FSUIPC_Process(r4) Then FSUIPC_Get(t4, pay) PayloadWT += pay End If If FSUIPC_Process(r5) Then FSUIPC_Get(t5, pay) PayloadWT += pay End If If FSUIPC_Process(r6) Then FSUIPC_Get(t6, pay) PayloadWT += pay End If
  2. thanks Pete, I re-arranged my formula thus f = ((RightTankCapacity * gallonslbs / 100) * RightTankLevel) + ((LeftTankCapacity * gallonslbs / 100) * LeftTankLevel) and it works ok now. I worked it out correctly on a calculator using values read from FSInterrogate and the results were correct, however when I came to coding the formula I put things in the wrong order ! (I didnt check the formula as I was sure I had it right) Should I be creating new threads for each question that I have or should I stick them on the one thread? I am currently working on a flight monitor program for the Flight1 Cessna 172R. This will give alarms based on speed, weight, flap settings etc from the manual as I want a sense of responsibility when flying. Aside from FSPassengers there is nothing I can find to monitor to check if the aircraft is being flown as it should. So on that point I will no doubt have more questions for this board soon. Best regards Graham
  3. Using default cessna, both tanks 99.9% full yields approx 314lbs. Problem is that I read 330lbs. If I set the tanks to 20lbs each I should then read 40lbs yet I read 2700lbs. I reckon its something to do with signed/unsigned numbers but I cant seem to find where its going wrong. Can anyone see the problem please? Here is my code for the fuel calculation. To call the function I use Dim FuelWT As Integer FuelWT = GetFuelWt() Function GetFuelWt() As Integer Dim dwResult As Integer Dim token As Integer Dim gallonslbs As Short Dim RightTankCapacity As Integer Dim LeftTankCapacity As Integer Dim RightTankLevel As Integer Dim LeftTankLevel As Integer Dim f As Integer 'get lbs per gallon wt If Not FSUIPC_Read(&HAF4, 2, token, dwResult) Then lblfuelwt.Text = "error - process code: " + dwResult.ToString Else If Not FSUIPC_Process(dwResult) Then lblfuelwt.Text = "process code: " + dwResult.ToString End If FSUIPC_Get(token, gallonslbs) gallonslbs = gallonslbs / 256 End If 'get capacity of right fuel tank If Not FSUIPC_Read(&HB98, 4, token, dwResult) Then lblfuelwt.Text = "error - process code: " + dwResult.ToString Else If Not FSUIPC_Process(dwResult) Then lblfuelwt.Text = "process code: " + dwResult.ToString End If FSUIPC_Get(token, RightTankCapacity) End If 'get capacity of left fuel tank If Not FSUIPC_Read(&HB80, 4, token, dwResult) Then lblfuelwt.Text = "error - process code: " + dwResult.ToString Else If Not FSUIPC_Process(dwResult) Then lblfuelwt.Text = "process code: " + dwResult.ToString End If FSUIPC_Get(token, LeftTankCapacity) End If 'get capacity % of fuel in right tank If Not FSUIPC_Read(&HB94, 4, token, dwResult) Then lblfuelwt.Text = "error - process code: " + dwResult.ToString Else If Not FSUIPC_Process(dwResult) Then lblfuelwt.Text = "process code: " + dwResult.ToString End If FSUIPC_Get(token, RightTankLevel) RightTankLevel = RightTankLevel * 100 / (128 * 65536) End If 'get capacity % of fuel in left tank If Not FSUIPC_Read(&HB7C, 4, token, dwResult) Then lblfuelwt.Text = "error - process code: " + dwResult.ToString Else If Not FSUIPC_Process(dwResult) Then lblfuelwt.Text = "process code: " + dwResult.ToString End If FSUIPC_Get(token, LeftTankLevel) LeftTankLevel = LeftTankLevel * 100 / (128 * 65536) End If 'total fuel weight f = ((RightTankCapacity * gallonslbs) * (100 / RightTankLevel)) + ((LeftTankCapacity * gallonslbs) * (100 / LeftTankLevel)) Return f End Function Many thanks Graham
  4. Using offset 1400 I can read 170lbs which when looking at the default cessna config is 1 passenger. How do I read the 2nd passenger (I assume is the 2nd station?) Ive looked in the SDK and FSInterrogate but cant locate any info to directly access the 61 stations except that they are 48bytes apart but from where? What is the starting offset of these 60 stations? thanks Graham
  5. When using default Cessna 172 and FSInterrogate the 16bit number read for fuel weight is 1536, this is then /256 to give 6lbs. Regardless of my fuel load it always reads 6lbs. Any idea why this is please? Thanks Graham [edit] Ive just found out why, that offset is for lbs/gallon weight, not total fuel weight. so 6lbs per gallon is correct, duh!
  6. well I must thank you all for your replies and advice I think I will use VB.net. I may as well since I have copies of both .net 2003 and .net 2005, may as well start using them now ! quick question, what is mtof ? thanks Graham
  7. wow, thanks for the detailed reply Pete. I will try and digest what you suggest tomorrow as it is 1am now and I am up at 6 for work. Out of interest I have found that within VB6 defining a long gives a range of -2,147,483,647 to 2,147,483,647, a Double is a 64bit number - fixed or floating. Now using FS-Interrogate and looking at offset 0578 Pitch the raw number read in the 32bit section is 4,291,248,153. Now this will not fit into the 'long' type as I get an overflow error. It also wont fit into the 'double' type as I get a type mismatch. So if anyone works with VB6 does that suggest that there are no types that can read a number that big? I will play around further tomorrow night Thanks again Graham
  8. I am playing around within VB6 to familiarise myself with the offsets and how they work etc Code I have written is as follows : Dim dwResult As Long Dim VS As Long 'vertical speed Dim Strobe As Byte 'strobes on/off 1=on 0=off Dim altitude As Long 'altitude If FSUIPC_Read(&H2C8, 4, VarPtr(VS), dwResult) Then If FSUIPC_Read(&H281, 1, VarPtr(Strobe), dwResult) Then If FSUIPC_Read(&H570, 8, VarPtr(altitude), dwResult) Then 'offset address,size(read value from FSInterrogate),variable to store result '"Read" proceeded without any problems If FSUIPC_Process(dwResult) Then ' "Process" proceeded without any problems lbltest.Caption = "Vertical speed = " & Int(VS * 60 * 3.28084 / 256) lblstrobe.Caption = "Strobe = " & Strobe lblaltitude.Caption = "altitude = " & altitude * 3.28084 / (65536 * 65536) Else ' Unable to "Process" lbltest.Caption = "Processing: " & ResultText(dwResult) End If Else ' Unable to "Read" lbltest.Caption = "Reading: " & ResultText(dwResult) End If End If End If What would be the correct data type to load an 8bit signed, 64bit fixed etc. I get a correct VS reading but the altitude when flying at 5000ft reads something like -0.0322330. Are there any VB6 samples other than what came with the SDK? Many thanks Graham
  9. Hi did you manage to find a solution to your fuel switch problem? I have the same thing with my quadrant and would like to know if you had a successful outcome please thanks Graham
  10. I will just stick to my Visual Studio 6 for now and learn C++ I also have VS 2003.net and VS2005.net is out as of today. Maybe I will upgrade to that at some point Thanks for your reply Graham
  11. I know bits of VB/c++ from my student days but to be honest I havent done any programming for a while so have forgot quite a bit! As microsoft have released several updated versions of Visual studio since then I was wondering where to start again. Is it worth learning C or C++ or sticking to VB (although I know from searching these forums that maybe VB is not the way to go!) I may as well learn the language which is the most versatile with FSUIPC. Also any good compilers/environments recommended? Or should I stick with MSVS? Thanks Graham
  12. If I build small application in VB6 how would I get the form to display in a window within FS2004, like happens with eg FSPassengers, FSNavigator etc or would it have to run externally like AVS ? Link to help would be great :) Thanks Graham
  13. Hi, This is the first time that I have been playing around with SDK and have quick question. I am trying to read Altitude using the below code but I always get an 'overflow' error. What type would the altitude variable be considering it is 8bytes long? I have currently defined it as long. If FSUIPC_Read(&H570, 8, VarPtr(altitude), dwResult) Then ' "Read" proceeded without any problems If FSUIPC_Process(dwResult) Then ' "Process" proceeded without any problems lblAltitude.Caption = Int((altitude * 3.28084) / (65536 * 65536)) Else ' Unable to "Process" lblError.Caption = "Processing: " & ResultText(dwResult) End If Else ' Unable to "Read" lblError = "Reading: " & ResultText(dwResult) End If Many thanks Graham
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.