Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: Big SIOC Task

  1. #11
    500+ This must be a daytime job



    Join Date
    Jul 2013
    Posts
    917
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Big SIOC Task

    Jack

    "Is this just here so we can associate which bracket goes with which" The indentation of brackets is to easily show what code is attached to the IF function.

    Re the IF logic, reference to Nico`s site will show you that if the IF statement is met then all the code within the associated brackets will be executed. Also, you can nest IF statemnts for example
    IF x <100
    {
    do this code
    IF > 50
    {
    only do this code ie only when x > 50 but < 100
    }
    }

  2. #12
    500+ This must be a daytime job Boeing 747 Flyer's Avatar
    Join Date
    Nov 2009
    Location
    England
    Posts
    635
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Big SIOC Task

    Okay how's this:

    Code:
    Var 8666, Link FSUIPC_IN, Offset $126C, Length 4 // Fuel Weight
    {  
    L0 = V8666 // FSUIPC Offset Variable = L0
      L0 = ABS L0     // L0 not signed 
      L2 = L0    
      IF L0 <= 400     // First sector
      {
        L1 = L2 * 0.91     // (364 steps/400 values) = 0.91
      }
      ELSE     // Is a greater value
      {
        L2 = L0 - 400     //  L2 only have values for next sector
        IF L0 <= 1200    // Second sector
        {
          L1 = L2 * 0.052     // (478 steps / 800 values) = 0.5975
          L1 = L1 + 364     // Add steps of others sectors
        }
        ELSE
        {
          L2 = L0 - 1200    // L2 only have values for next sector
          IF L0 <= 1500     // 3. Sector
          {
            L1 = L2 * 0.028     // ( 141 / 300) = 0.47
            L1 = L1 + 842     // Add steps of others sectors 364 + 478 
            }
            ELSE     // Out of range
            {
              L1 = 983        // Max. position
            }
          }
           &FuelGauge = 0 + L1     // Add to minimum (0)    
          }
    }
    
    Var 0650, name FuelGauge, Link USB_SERVOS, Output 2, PosL 0, PosC 492, PosR 983, Type 2 // FuelGauge Servo
    ANY problems at all, weather they be calculations or otherwise (please tll me if so)?

  3. #13
    500+ This must be a daytime job kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    698
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Big SIOC Task

    Quote Originally Posted by Boeing 747 Flyer View Post
    Is there any importance in leaving spaces on the brackets? What I mean is, the Brackets in most people scripts are all spaced out differently... Is this just here so we can associate which bracket goes with which, or is there another importance?
    You are now referring to the subject of 'syntaxis'.

    Every programming language has production rules for producing correct sentences in that language. These rules define what a correct sentence (statement) is and what not. (The meaning of a correct statement is what is called 'semantics')

    Code:
    IF L0 > 0
    {
      L1 = L0
    }
    is a correct SIOC statement but

    Code:
    IF L0 > 0 {L1 = L0}
    is not ...

    SIOC has strict rules for where you can put for instance an opening bracket (always at a new line, and only that bracket at that line). It does not matter how many spaces or tabs there are in front of it, or after it at the same line. So

    Code:
    IF L0 > 0
                                      {
    L1 = L0
    }
    is also a correct sentence. However, in order to understand the 'flow' in the program more easily, it is good practise to indent and line up opening and closing brackets. This becomes even more important with statements that are nested.

    Nico
    Last edited by kiek; 07-21-2010 at 10:52 AM.

  4. #14
    500+ This must be a daytime job



    Join Date
    Jul 2013
    Posts
    917
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Big SIOC Task

    Jack

    Good progress. Offhand, I see only one issue - your line "&FuelGauge = 0 + L1" needs to be run every time that the fuel weight changes. Currently, you have it too high, I think that it should be just above the last bracket. I have not checked all the nested logic, however, there is a simple way for you to troubleshoot the code, as explained in an earlier thread.

    Change your variables to lower numbers ie 10 and 11
    Run SIOC using this code - assuming that there are no syntax errors
    Open the IOCPConsole (it is within the SIOC runtime window)
    You can then see your variable values on the left of the screen, also you can change their values within that screen
    Also, by using the Log function when there is a change in value of the FSUIPC variable, then you can see all the code that is actioned. This is great for testing the logic flow

    Good luck

  5. #15
    500+ This must be a daytime job Boeing 747 Flyer's Avatar
    Join Date
    Nov 2009
    Location
    England
    Posts
    635
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Big SIOC Task

    Thanks very much Nico for clarifying that. I had a feeling that the brackets were spcaed out like that for easier reading.

    Also, thanks David for your advice. When you say that it is a problem, do you mean it won't work or is it just "better" to write it another way (like you said it is "too high").

    Another thing... Do any of you guys have information on Offset $126C? I have seen it referenced a few times, but it doesn't seem to be in the FSUIPC SDK Manual, or the table listed on PM's website! Any clues? I need to know incase I've got the length wrong or it needs dividing/multiplying.

  6. #16
    500+ This must be a daytime job



    Join Date
    Jul 2013
    Posts
    917
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Big SIOC Task

    Jack

    I am not bothered about "pretty code"! You check the logic flow, but I think that the line "&FuelGauge = 0 + L1" should be last. Try it within the IOCPConsole and see

    I got the FSUIPC list from either the official site or within the fsuipc software package - I assume you have a registered copy. The info on fuel weight is in lbs and the offset has a length of 4 bytes.

    EDIT: Not certain what you are reading, but I can assure you that the offset list is within the FSUIPC SDK manual zip file available from the official site. Suggest you check again - hint try the offset status file

    David

  7. #17
    500+ This must be a daytime job Boeing 747 Flyer's Avatar
    Join Date
    Nov 2009
    Location
    England
    Posts
    635
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Big SIOC Task

    Okay, I have changed it so that FuelGauge = L1 is on the last line, only thing below it is the final closing bracket.

    I will now test with SIOC and FSX!

  8. #18
    500+ This must be a daytime job kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    698
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Big SIOC Task

    Quote Originally Posted by Boeing 747 Flyer View Post
    Another thing... Do any of you guys have information on Offset $126C? I have seen it referenced a few times, but it doesn't seem to be in the FSUIPC SDK Manual, or the table listed on PM's website! Any clues? I need to know incase I've got the length wrong or it needs dividing/multiplying.
    The offset list is in the "FSUIPC for Programmers.pdf". This file is part of the "FSUIPC SDK 29th Release" available at the official Peter Dowson page.

    By the way, Offset $126C is not in that list, so it s not a published offset by Pete Dowson. Maybe it is an extra offset by Project Magenta (PM)? If so it will only work if you are using PM.

    Nico

  9. #19
    500+ This must be a daytime job



    Join Date
    Jul 2013
    Posts
    917
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Big SIOC Task

    Nico

    As advised earlier in the thread this offset is referenced in the FSUIPC Offsets Status file within the FSUIPC SDK 29th Release on the Official Peter Dowson Site. It is new to FSX.

    David

  10. #20
    500+ This must be a daytime job kiek's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    698
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Big SIOC Task

    Hi David,
    I see, thank you for the heads up. Was not aware of that file introducing new offsets (compared to the FSUIPC for Programmers.pdf).
    Nico

Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Sioc / PM
    By mpl330 in forum OpenCockpits General Discussion
    Replies: 6
    Last Post: 02-07-2010, 01:26 PM
  2. Where can I get SIOC, please?
    By Jake 747 400 in forum General Builder Questions All Aircraft Types
    Replies: 1
    Last Post: 11-18-2009, 06:10 PM
  3. SIOC Help
    By CessnaGuy in forum I/O Interfacing and Hardware
    Replies: 5
    Last Post: 10-25-2009, 10:00 AM
  4. SIOC for MIP?
    By HondaCop in forum I/O Interfacing Hardware and Software
    Replies: 17
    Last Post: 07-21-2009, 07:48 AM
  5. N1 SET and SPD REF - SIOC
    By paoloj in forum OpenCockpits General Discussion
    Replies: 0
    Last Post: 10-28-2008, 04:23 AM