Page 8 of 9 FirstFirst ... 456789 LastLast
Results 71 to 80 of 90
  1. #71
    75+ Posting Member
    Join Date
    Apr 2009
    Location
    Toronto
    Posts
    125
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: SIOC "IF" Question

    ___________________

  2. #72
    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: SIOC "IF" Question

    Meh. I tried.

    I really boils my water when people act like you have throughout this thread. Please do not repeat this pathetic behaviour again.

    If I were a teacher, I would applaud a student's enthuasiasm. You have done the complete opposite; which, quite frankly, is disgusting.

  3. #73
    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: SIOC "IF" Question

    If anyone's interested, I finally figured out how to do it.

    Through use of a Subroutine as a "checker", at 12:15AM last night all pulled through.

    Script:

    Code:
    Var 9888, Link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
    {
      IF v9888 >= 3
     { 
    &REF = 0
       &BlinkLed = 500000 // Begin value of timer
       &BlinkLed = TIMER 0 -1 40
     }
    }
       
    Var 9891, name BlinkLed
    {
        L0 = MOD &BlinkLed 2
     IF L0 = 0
     {
         &REF = 0
     }
       ELSE
      {
         &REF = 1
      }
    }
    
    Var 7675, name REF, Link IOCARD_OUT, Output 4 // REF LED
    {
    IF &REF = 0
     {
    CALL &PRECIPTEST
     }
    }
    
    Var 9105, name PRECIPSET, Link SUBRUTINE
    {
     IF v9888 > 0
     {
     IF v9888 < 3 // YEH
      {
      &REF = 1
      }
     }
    }
    
    
    
    Var 9887, Link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
    {
      IF v9887 < 3
     { 
       &BlinkLed = 1 // equal to end value of timer (0) + 1
       &REF = 1
     }
    }
    
    Var 9886, Link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
    {
      IF v9886 = 0
     { 
    &REF = 0
     }
    }
    Nico Kaan has also suggested another method for me to use. I am currently experimenting with both to see which is the more efficient.

  4. #74
    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: SIOC "IF" Question

    Hi Jack,

    Just a few tips, to help you. In my (humble) opinion there are several things "wrong" with your script:

    * You defined three variables linked to the same FSUIPC offset, which is not efficient and can lead to "race-conditions". E.g. if the FSUIPC offset becomes 0, Var 9887 is executed and &REF will be set to 1, while "concurrently" Var 9886 is executed and that code will try to set &REF to 0 ..... It is just because you have defined Var 9887 just before Var 9886 that it this time works, but if Opencockpits changes the order of evaluation from forwards to backwards your in trouble ... So never program like this. Always put all sioc code related to a FSUIPC offset in one Variable.

    * It is also bad programming practice to attach sioc code to an output definition (Var 7675). If one writes to an output one assumes it will go to the output, not that an attached sioc statement changes the value that you just wrote .... E.g I write 0 to that output, but due to the CALL to PRECIPTEST it might be overwritten by the value 1... (UGLY )

    * If precip becomes 3 you start a timer (in Var 988 . However, if precip becomes 4 you start another timer, (same with 5, and so on). This is not efficient and the outcome becomes undefined.

    Maybe it is better to move over to my code:

    Note that it is important keep status of whether the led is already blinking because you have to take into account whether you are going up or down in precip value ...

    Code:
    Var 9000 name blinking value 0   // 0 or 1 (blinking)
    Var 9001 name precip link FSUIPC_IN offset $C28D length 1
    {
      IF &precip = 0
      {
        &REF = 0
      }
      ELSE
      {
        C0 = &precip = 1
        C1 = &precip = 2
        IF C0 OR C1
        {
          &REF = 1
        }
        ELSE
        {
          IF &precip = 3
          {
            if &blinking = 1
            {
               &blinking = 0
               &blinkLed = 1   // coming from 4, stop blinking
            }
            ELSE
            {
              &REF = 1   // coming from 2, keep led on ...
            }
          }
          ELSE
          {
            if &blinking = 0
            {
              &blinking = 1
              &blinkLed = 500000 
              &blinkLed = TIMER 0 -1 40
            }
          }
        }
      }
    }
    
    Var 9002 name blinkLed
    {
      // make sure that blinking stops with led = On,
      // end value of TIMER has to be even.
      L0 = MOD &Blinkled 2
      IF L0 = 0
      {
        &REF = 1
      }
      ELSE
      {
        &REF = 0
      }
    }
    Var 9003 name REF Link IOCARD_OUT Output 93

  5. #75
    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: SIOC "IF" Question

    Hi Nico,

    Not sure what I've done wrong, but I can't get your script to work. Basically, the LED goes ON and OFF as it should, but never BLINKS. I think this lies within Var "Blinking". The LED will only blink if this Var is =1, but I don't know how it becomes =1?

    Script:

    Code:
    Var 9003, name REF, Link IOCARD_OUT, Output 93
    Var 9000, name Blinking, Value 0 // 0 or 1 (Blinking)
    Var 9001, name precip, link FSUIPC_IN, Offset $C28D, Length 1 //  Cloud Precipitation Rate (1)
    {
      IF &Precip = 0
      {
        &REF = 0
      }
      ELSE
      {
        C0 = &Precip = 1
        C1 = &Precip = 2
        IF C0 OR C1
        {
          &REF = 1
        }
        ELSE
        {
          IF &Precip >= 3
          {
            if &Blinking = 1
            {
               &Blinking = 0
               &BlinkLed = 1   // coming from 4, stop blinking
            }
            ELSE
            {
              &REF = 1   // coming from 2, keep led on ...
            }
          }
          ELSE
          {
            if &blinking = 0
            {
              &Blinking = 1
              &BlinkLed = 500000 
              &BlinkLed = TIMER 0 -1 40
            }
          }
        }
      }
    }
    
    Var 9002, name BlinkLed
    {
      L0 = MOD &Blinkled 2
      IF L0 = 0
      {
        &REF = 1
      }
      ELSE
      {
        &REF = 0
      }
    }

  6. #76
    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: SIOC "IF" Question

    Is precip ever 4 ? I assumed it is, otherwise I have to change the script

  7. #77
    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: SIOC "IF" Question

    Quote Originally Posted by kiek View Post
    Is precip ever 4 ? I assumed it is, otherwise I have to change the script
    Hi Nico,

    Precip can be anything 0-5.

  8. #78
    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: SIOC "IF" Question

    Okaty, try this script:
    Code:
    Var 9000, name Blinking, Value 0 // 0 or 1 (Blinking)
    
    Var 9001, name precip, link FSUIPC_IN, Offset $C28D, Length 1 //  Cloud Precipitation Rate (1)
    {
      IF &precip = 0
      {
        &REF = 0
      }
      ELSE
      {
        IF &precip = 1
        {
          &REF = 1
        }
        ELSE
        {
          If &precip = 2
          {
            if &Blinking = 1
            {
               &Blinking = 0
               &BlinkLed = 1   // coming from 3, stop blinking
            }
          }
          ELSE
          {
            IF &precip = 3
            {
              IF &blinking = 0   // coming from 2
              {
                &Blinking = 1
                &BlinkLed = 500000 
                &BlinkLed = TIMER 0 -1 40
              }
            }
          }
        }
      }
    }
    
    Var 9002, name BlinkLed
    {
      L0 = MOD &Blinkled 2
      IF L0 = 0
      {
        &REF = 1
      }
      ELSE
      {
        &REF = 0
      }
    }
    
    Var 9003, name REF, Link IOCARD_OUT, Output 93
    Nico

  9. #79
    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: SIOC "IF" Question

    Hi Nico,

    I am facing similar problems. Basically, I've had a look at the Script, and I (think) there are some errors:

    - If 0, LED is OFF
    - If 1,2 LED is ON
    - If 3, 4, 5 LED BLINKS

    I think there are parts of the code which do not achieve this?

    Thanks very much,

    Jack

  10. #80
    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: SIOC "IF" Question

    Jack,
    Can you be more specific
    Quote Originally Posted by Boeing 747 Flyer View Post
    Hi Nico,

    there are some errors:

    - If 0, LED is OFF
    - If 1,2 LED is ON
    - If 3, 4, 5 LED BLINKS
    What do you mean by this: a specification? or is it what you see (which is according to my spec), so why do you speak about Errors?

    What exactly do you think is missing?
    How do you check this script?

    Nico

Page 8 of 9 FirstFirst ... 456789 LastLast

Similar Threads

  1. "Inner Circle" HSI - SIOC DC Motors Card Script
    By Boeing 747 Flyer in forum OpenCockpits General Discussion
    Replies: 64
    Last Post: 04-21-2011, 10:59 AM
  2. Replies: 17
    Last Post: 03-05-2008, 12:39 PM
  3. A question for "Bus Drivers"
    By mpl330 in forum General Builder Questions All Aircraft Types
    Replies: 2
    Last Post: 01-31-2008, 06:56 PM
  4. PM updates and a question for "proof of concept"
    By pap in forum PM General Q & A
    Replies: 4
    Last Post: 01-27-2008, 06:22 AM