Jump to content
The simFlight Network Forums

efratomer

Members
  • Posts

    76
  • Joined

  • Last visited

Posts posted by efratomer

  1. But you don't need a module then. You have to modify the parent window of your main VB window, so it uses the FS main window as its parent and is displayed infront of FS. But this does not work very well with all VGA cards out there. So you need to be careful with this.

    Thomas

    I didn't know this option,

    how do I do it execly? or if you can tell me where I can learn about it.

    Thanks in advance,

    Omer.

  2. writing something from scratch here

    say you want a 12 byte string

    dim t as string

    dim s(12) as byte

    Call FSUIPC_Read(&H3D00, 12, VarPtr(s(1)), dwResult)

    Call FSUIPC_Process(dwResult)

    t = ""

    For j = 1 To 12

    If s(j) = 0 Then Exit For

    t = t & Chr(s(j))

    Next j

    MsgBox s

    Working! the only problem was that you needed to do msgbox t not s :) but I fixed that.

    Thanks!

    By the way, I hope, when you have these things figured out, that you are not doing "Read/Process" pairs all the time. It would be extremely inefficient, both for you program and for FS. You want to bunch all your Reads and Writes then do one Process call to send all the requests over to FSUIPC in one visit.

    So you mean for best performance of FS and my program I should make a single proccess for multiple read / write actions?

    Thanks,

    Omer.

  3. writetxt - "test"

    writetxt = Left(writetxt , 127)

    writetxt = writetxt & vbNullChar

    j = 4

    Call FSUIPC_WriteS(&H3380, Len(writetxt ), writetxt , dwResult)

    Call FSUIPC_Write(&H32FA, 2, VarPtr(j), dwResult)

    Call FSUIPC_Process(dwResult)

    Thanks!!

    Works as magic!!

    What about current aircraft name?

    I've tried the offset 3D00, but it returns me some strange numbers:

    Dim tst As String
    Call FSUIPC_Read(&H3D00, 1, VarPtr(tst), dwResult)
    Call FSUIPC_Process(dwResult)
    MsgBox tst

    What's difficult? Sending a control to FS? That only involves writing one number to offset 3110. I don't understand.

    It wasn't what I ment anyway,

    nevermind, Really thanks Pete!

    Thanks,

    Omer.

  4. Well, Thanks Pete.

    I think i'll just give in with this one.

    I'ts not that improtant for me, just didnt thought it will be that difficult.

    Anyway, I have something more important for my program:

    I would like to write text messages into the simulator using the offset 3380.

    I just doesn't get string(text) inputs work...

    I have done this code:

        Dim writetxt As String
        writetxt = "Test"
        Call FSUIPC_Write(&H3380, 1, VarPtr(writetxt), dwResult)
        Call FSUIPC_Process(dwResult)
    

    Doesn't work :?

    Thanks in advance,

    Omer.

  5. Hello again,

    Thanks! Thats all I needed!

    What i've done was that in a click of a button your are getting located in some parking space at some airport including the heading of the parking...

    Another issue I have in mind:

    After im moving the plane into a far away coordinate, it doesn't show the loading screen and it loads while in the plane so you can see the loading action infront of you, I say its kind of ugly, Is there any way of forcing the simulator of showing the loading screen?

    Pete, sorry if you get tired of me :?

    Thanks in advance,

    Omer.

  6. You are most certainly making an elementary arithmetic error then, somewhere. I have now checked this thoroughly. The formula in my documentation is accurate. The only slight inaccuracy anywhere is in the FS displays, where is seems to usually round UP to the next whole number of gallons even if the value is .000001 over! The values you can read and write via FSUIPC are more accurate than the displays.

    I got you my problem was that I set the precentage and not the gallons...

    like I wrote it I want 70% of the fuel tank. Probebly thats why it was no accurate.

    Does FSInterrogate read anything anywhere? The current version will not actually connect to FS unless FS is up and running first BEFORE you run FSInterrogate. There's a new version coming which is a lot better and will connect/disconnect as needed, automatically.

    as I told:

    Somehow, I have now checked but after I load the default 737 and opened the FSInterrogate I got all 0 in all of the fuel tanks in the plane (event though it was full on fuel on board).

    I DID opened the FS first, of course.

    They are only split up like that in FSInterrogate because that version cannot handly 64-bit integers. Please use the Programmer's guide documentation as your main source of information. It contains much more explanatory material.

    As I know, and as I read here in the forum old threads - VB Doesn't support 64-bit integers...

    All the help you should need is in the documentation NOT in FSInterrogate. Read those values into a 64 bit value and apply the formula given.

    I did looked in the documenation and found this:

    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.

    Now, if I have understood this correctly I have done the following:

    Dim dHi As Double
    Dim dLo As Double
    Call FSUIPC_Read(&H564, 4, VarPtr(dHi), dwResult)
    Call FSUIPC_Read(&H560, 4, VarPtr(dLo), dwResult)
    Call FSUIPC_Process(dwResult)
    dLo = dLo / (65536# * 65536#)
        If dHi > 0 Then
            dHi = dHi + dLo
        Else
            dHi = dHi - dLo
        End If
    dHi = dHi * (90# / 10001750#)
    

    At the end dHi was equal to: 2.32210853545386E-322

    And I really doesn't know what this number means...

    In addition, I have tried to set the dHi and the dLo as Long varients,

    the result was that at the end dHi was equal to: 47

    Which was part of my plane's coordinate: N47* 25.89' W122* 18.48'

    Why im getting 2.32210853545386E-322 instead of a decimal coordinate?

    Thanks,

    Omer.

  7. Hey Pete!

    And when you try to set 14.3 you get 15? Is that what you are saying? I really can't believe it is that much out. Let me check with FSInterrogate.

    Yes that what happend.

    Please check things using FSInterrogate. See if your figures match its figures. If not, you have got something wrong!

    Somehow, I have now checked but after I load the default 737 and opened the FSInterrogate I got all 0 in all of the fuel tanks in the plane (event though it was full on fuel on board).

    For each tank there's a CAPACITY offset, which is how many US gallons 100% represents, and a LEVEL, which is the value you read or write to tell you how full it is. The CAPACITY offset is right next to each LEVEL offset, so I'm amzed you've not noticed it.

    Having got the level and the capacity you can easily work out the number of US gallons.

    Well I just probebly didnt understood you in the last reply, I just didnt understood your talking on the Capacity of each fuel tank. This one I have seen.

    And have been thinking on using it, and after you wrote to use it. I have tried and it is now much much more accurate.

    I have done this:

    Dim setfuel As Long
    Dim maxfuel As Long
    Call FSUIPC_Read(&HB80, 4, VarPtr(maxfuel), dwResult)
    Call FSUIPC_Process(dwResult)
    setfuel = (1000 / maxfuel) * (128 * 65536)
    Call FSUIPC_Write(&HB7C, 4, VarPtr(setfuel), dwResult)
    Call FSUIPC_Process(dwResult)
    

    Now this have worked great!

    It actualy returned 1001 galons in the fuel tank.

    Tried the same code only with 1400 galons and that time it did returned 1400 galons in the fuel tank. :)

    I think the fuel situtation as been solved finally. THANKS!! :D

    Another question (really hope you still got power for me :oops:):

    What about plane coordinates?

    I have looked up for the right offsets and found the following:

    0560 Lat Lo

    0564 Lat Hi

    0568 Long Lo

    056C Long Hi

    I have tried to see what im getting for the Lat Lo (0560) by this code:

    Dim plane_latlo As Long
    Call FSUIPC_Read(&H560, 4, VarPtr(plane_latlo), dwResult)
    Call FSUIPC_Process(dwResult)
    MsgBox plane_latlo
    

    Now what that I had in the msgbox was: -1133445120

    execly as I got in the FSInterrogate....

    only problem is that I really dont know what to do with it for getting the full decimal lattitude and longtitude numbers of the plane. Some help please?

    Thanks in advance,

    Omer.

  8. Hey Pete,

    Well WOW now im confused.

    What EXACTLY do you really want to fix? Do you want to be able simply to adjust the amount of fuel in the tanks, or do you want some value in some menu in FS to exactly reflect what you want? I don't understand.

    Its kind of them both? I want to set the fuel level as execly as I wrote him.

    Like 14.3 Galons in the left tank & in the right tank.

    Meaning, I do NOT want it to round it for 15 or 13 whatever. How shell I do it?

    Why not, instead of reading percentages in FS's dialogues, read the fuel levels on the gauges? That is surely the only thing that is relevant, isn't it?

    I haven't seen in the offsets list an offset which will bring back Galons in tank... Did I missed it?

    Maybe, whoever derived the units used in those locations got them slightly wrong? This dates from way before my time, from FS98 and FS95 before that. Maybe instead of being 128 = 100% it was 127.76541 or some other number which has some special significance. I do not know. I would be extremely reluctant to change the documentation now even if it is slightly wrong, because there are so many programs using this stuff quite happily that I would not want them all to have to change.

    If all you want to achieve is to get a certain figure in the dialogue, then set that figure in that dialogue, read what is in the FSUIPC offset for that tank, and write that. This is the only way. You can read the value either in FSInterrogate or using the FSUIPC monitor (right-hand side of the Logging options page).

    Im really sorry but I didnt understand what you are saying here.

    Really thanks Pete!

    Omer.

  9. Well Pete,

    I worked on this for couple of hours now.

    I did found a close answer but still that rounding action really anoying :?

    My code:

    dim tfuel as long
    tfuel = 95 / 100 * (128 * 65536)
    Call FSUIPC_Write(&HB7C, 4, VarPtr(tfuel), dwResult)
    Call FSUIPC_Process(dwResult)
    

    I just done the opposit action as the read: CntrFuel * 100 / (128 * 65536)

    As I think you said.

    The only problem is that rounding as I said. I write 95 and it gives me 98.

    So... I tried make the variant as a double type, what happend was that tfuel was equel to 7969177.6 and then the simulator translate it to 10483% of fuel :?.

    With the long type variant tfuel equels to 7969178, and gives 98% fuel in the sim as I wrote above.

    How can I fix this?

    BTW, I hope you dont think that I ain't tring things my own, If you do, I wanna tell ya that I have succeed of making a Engine Fail with the Write function. as this:

    Dim tst As Byte
    Call FSUIPC_Write(&HB6B, 1, VarPtr(tst), dwResult)
    Call FSUIPC_Process(dwResult)

    Worked great 8)

    Thanks VERY MUCH,

    Omer.

  10. Hey Pete,

    Oh, you right.

    Probebly I just wrote that message when u just finished yours so I didnt saw it...

    To the point:

    I now tried this:

    Dim tfuel As Long 
    tfuel = 95 / (128 * 65536)
    Call FSUIPC_Write(&HB7C, 4, VarPtr(tfuel), dwResult) 
    Call FSUIPC_Process(dwResult)
    

    But somehow still getting a 0 in the fuel tank...

    And tried this also:

    Dim tfuel As Long 
    tfuel = 8388608
    Call FSUIPC_Write(&HB7C, 4, VarPtr(tfuel), dwResult) 
    Call FSUIPC_Process(dwResult)
    

    But here I get 101% (How can it be?!)

    Thanks in advance,

    Omer.

  11. Hello again Pete,

    Hey again,

    Thanks jd!

    Oh, you right, I was with a cessna :) silley me.

    More questions (Hope you ain't tired :lol:):

    First, I have 50% fuel and it gives me 49, Do you know why?

    (Same as 100% fuel and 98 ).

    Second, If I would like to set the fuel stats, what should I do?

    Edit:

    I've tried this code:

    Dim tfuel As Long
    tfuel = 95
    Call FSUIPC_Write(&HB7C, 4, VarPtr(tfuel), dwResult)
    Call FSUIPC_Process(dwResult)
    

    But somehow it sets a 0 in the left fuel tank, Why is that?

    My code for the Fuel read:

    Dim dwResult As Long
    Dim CntrFuel As Long
    Private Sub Timer1_Timer()
    If FSUIPC_Read(&HB7C, 4, VarPtr(CntrFuel), dwResult) Then
        If FSUIPC_Process(dwResult) Then
            CntrFuel = CntrFuel * 100 / (128 * 65536)
            Label1.Caption = CntrFuel
        End If
    End If
    End Sub
    

    Thanks in advance,

    Omer.

    Are you sure u saw this one?

    Thanks in advance,

    Omer.

  12. Hey Pete,

    Thanks for your replies though I did passed this stage already.

    Please read my last reply, maybe you can help.

    Beyond that,

    GndAlt = 0 
    If FSUIPC_Read(&HB4C, 2, VarPtr(GndAlt), dwResult) Then 
        If FSUIPC_Process(dwResult) Then 
            Label1.Caption = "Altitude: " & GndAlt 
        End If 
    End If 
    End Sub  
    

    GndAlt = 0 will always stay 0 because you set to 0, otherword it does nothing but stay 0.

    I'm afraid that what High-Octane wrote isn't correct. So don't get scary from VB too fast :)

    Thanks in advance,

    Omer.

  13. Hey again,

    Thanks jd!

    Oh, you right, I was with a cessna :) silley me.

    More questions (Hope you ain't tired :lol:):

    First, I have 50% fuel and it gives me 49, Do you know why?

    (Same as 100% fuel and 98 ).

    Second, If I would like to set the fuel stats, what should I do?

    Edit:

    I've tried this code:

    Dim tfuel As Long
    tfuel = 95
    Call FSUIPC_Write(&HB7C, 4, VarPtr(tfuel), dwResult)
    Call FSUIPC_Process(dwResult)
    

    But somehow it sets a 0 in the left fuel tank, Why is that?

    My code for the Fuel read:

    Dim dwResult As Long
    Dim CntrFuel As Long
    Private Sub Timer1_Timer()
    If FSUIPC_Read(&HB7C, 4, VarPtr(CntrFuel), dwResult) Then
        If FSUIPC_Process(dwResult) Then
            CntrFuel = CntrFuel * 100 / (128 * 65536)
            Label1.Caption = CntrFuel
        End If
    End If
    End Sub
    

    Thanks in advance,

    Omer.

  14. Hey,

    First of all, jD, Your code worked as a megic.

    Now, there are somethings I do not understand in your code:

    Dim x As Long 
    Dim y As Single
    

    How can I know what type of variant I need?

    and:

    If y > 32767 Then y = y - 65534 
    

    why you done that?

    And, now if I would like to get the Fuel Capacity (offset B78, 4 bits), Ive done this code:

    Dim dwResult As Long
    Dim CntrFuel As Integer
    Private Sub Timer1_Timer()
    If FSUIPC_Read(&HB78, 4, VarPtr(CntrFuel), dwResult) Then
        If FSUIPC_Process(dwResult) Then
            Label1.Caption = CntrFuel
        End If
    End If
    End Sub
    

    Plus - I tried to set CntrFuel to 0 but with no luck too...

    All I get is 0 again...

    What am I doing wrong again?

    Thanks in advance,

    Omer.

  15. hey again,

    couple of things,

    First, I set Variant type which is kind of evrything so because I didnt knew what type of variant I shell need to fix this I put Variant.

    Second, im aware of that I labeled the output as fuel because before this offset I have tried to get the fuel infromation with no luck, then changed it to ground altitude, but just didnt changed the label.

    so.. now, I have tried to name the variant as Integer and did set it to 0 first. Now all I am getting is "131" output with no connection to what is my ground altitude in the session. My code is:

    Dim dwResult As Long
    Dim GndAlt As Integer
    Private Sub Timer1_Timer()
    GndAlt = 0
    If FSUIPC_Read(&HB4C, 2, VarPtr(GndAlt), dwResult) Then
        If FSUIPC_Process(dwResult) Then
            Label1.Caption = "Altitude: " & GndAlt
        End If
    End If
    End Sub
    

    Thanks in advance & as I said enjoy yourself at the event,

    Omer

  16. Well, as your request:

    Dim dwResult As Long
    Dim auitime As Variant
    
    Private Sub Timer1_Timer()
    If FSUIPC_Read(&HB4C, 2, VarPtr(auitime), dwResult) Then
        If FSUIPC_Process(dwResult) Then
            Label1.Caption = "Fuel: " & auitime
        End If
    End If
    End Sub
    

    Isn't it need to be as simple as that?

    (Needless to say that I'm connected to the session already).

    Hope you will enjoy at the event Pete.

    Waiting for your (or someones) response.

    And thanks in advance,

    Omer

  17. Hello again,

    Pete, I thought it was needless to say that I have searched this forum and some other like it for an answer with no results.

    In addition, I have looked on the FSInterrogate as well, though, I didnt much understand from it, while I done outputs reads for things like: crash status, gear status, airborn status etc', I had problems reading the other offsets as i described in the above reply with the same way as the first ones.

    so I just dont understand what im doing wrong.

    still looking for a good example though.

    Thanks in advance,

    Omer.

×
×
  • 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.