Page 9 of 9 FirstFirst ... 56789
Results 81 to 90 of 90
  1. #81
    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,

    What I mean is, I do not think the code achieves the following specs/requirements:

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

    I want the LED to achieve the above. The script that you gave me, as far as I can see, does not achieve this. I used IOCPConsole to test. I think the problem lies within where it says Precip = 3, shouldn't it be Precip >= 3. Also, it says Precip = 1, shouldn't this be 1 OR 2? REF = 0 if Precip = 0 is correct.

    Jack

  2. #82
    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

    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
            }
            ELSE
            {
              &REF = 1
            }
          }
          ELSE
          {
            IF &precip >= 3
            {
              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
      }
    }
    
    Var 9003, name REF, Link IOCARD_OUT, Output 93

  3. #83
    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,

    For the most parthat script works the only problem is the LED won't stop blinking if it is transition from 3/4/5 -> 0/1. No Worries, I have made some very small edits and I have finalised 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
      if &Blinking = 1
      {
               &Blinking = 0
               &BlinkLed = 0
      }
     }
      ELSE
       {
        IF &precip > 0
        {
    IF &precip < 3
         {
          &REF = 1
    if &Blinking = 1
          {
               &Blinking = 0
               &BlinkLed = 1
          }
         }
        ELSE
           {
            IF &precip >= 3
            {
              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
      }
    }
    
    Var 9003, name REF, Link IOCARD_OUT, Output 93
    Is there anything that needs improving (lining of brackets maybe)?

  4. #84
    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

    yes, in the IF &precip = 0 part, change

    Code:
               &BlinkLed = 0
    into
    Code:
               &BlinkLed = 1
    and indent each line properly, but I leave that part to you ......
    Nico

  5. #85
    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 have purposely edited the &BlinkLED part. If Precip = 0, LED should be 0, not 1. If I edit it the script does work work properly how I'd like it to. In its currently state, all is good.

  6. #86
    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

    ??
    The Led part is ok, my comment was about the blinking part in that piece of your script.

    If you write this:
    Code:
      if &Blinking = 1
      {
               &Blinking = 0
               &BlinkLed = 0
      }
    You write it because you want to STOP the blinking ..
    But if you want to stop the blinking you should write:
    Code:
      if &Blinking = 1
      {
               &Blinking = 0
               &BlinkLed = 1
      }
    But this error will only occur if precip goes from 3 (blinking) to 0... I assume you have not tested that ...

    So "NOT all is good..".

    Note: You cannot test the absence of errors, only the presence of errors....
    That's why a good design is so important. Deering was leading you on that path ...

    I now quit withy this topic.
    Nico

  7. #87
    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,

    As I previously said, I did test all circumstances. If I switch from 3 to 0, the LED does exactly as I want it to (stop blinking, and REF = 0). This is my IOCPConsole Log:



    Regardless of any "errors" the script does as I want it too. I tried changing it to this like you said:

    Code:
    if &Blinking = 1
      {
               &Blinking = 0
               &BlinkLed = 1
      }
    And the LED wrongfully goes to = 1, not 0 as I want.

    Iunderstand what you are saying, what I posted is non-standard stop-code for blinking. However, if I change it to the above, like I said it does not work.

  8. #88
    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,
    The Led does not "wrongfully" goes to 1, but "by design".... The BlinkLed Var was designed to stop blinking with value 1. That was because of the requirement that going from 3 to 2 it had to stop blinking but still be on. However, now another requirement pops up that it should be possible to go from 3 to 0 and the blinking has to stop with the led off.... These requirements are contradictive. Thats why you had to invent a "trick", so to speak

    Programming with "tricks" is not a good idea, because if you look at your program one month or more later you have forgotton why you programmed it like that.

    I have given this programming task some more thought over the weekend and I have come up with a completely new design. It's completely different from the previous one. I start a timer and let it run contineously...! (no need to stop it). In the variable controlled by the timer I check the precip value. Very robust and easy to understand:
    Code:
    Var 0 Value 0
    {
      &LedControl = 500000          // long enough ...
      &LedControl = TIMER 0 -1 40
    }
    
    Var 9001 name &precip FSUIPC_IN Offset $C28D Length 1 
    
    Var 9002 name LedControl
    {
      IF &precip = 0
      {
        &REF = 0
      }
      ELSE
      {
        C0 = &precip = 1
        C1 = &precip = 2  
        IF C0 OR C1
        {
          &REF = 1
        }
        ELSE
        {
          &REF = MOD &LedControl 2
        }
      }
    }
    
    Var 9003 name &REF Link Output Number 93
    Nico
    Last edited by kiek; 08-29-2010 at 05:58 PM.

  9. Thanks Boeing 747 Flyer thanked for this post
  10. #89
    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

    _________________________

  11. #90
    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

    Thanks very much Nico, I will try that code very soon. I have studied it and I can understand the new design, definitely worth a try.

Page 9 of 9 FirstFirst ... 56789

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