Results 1 to 10 of 90
Thread: SIOC "IF" Question
-
08-08-2010, 05:31 PM #1
SIOC "IF" Question
Hiya everyone,
Quick SIOC Question here:
If I want to have two "IFs" in a scipt (ie only light LED 5 if switch 1 is ON AND switch 2 is ON) how would I do it?
as always, I had a little try... But it doesn't work. The problem lies obvious in line 9:
Code:Var 9888, Link FSUIPC_IN, Offset $CE8D, Length 4 // Cloud Precipitation Rate { L0 = V9888 // FSUIPC L0 = v9888 L0 = ABS L0 // L0 not signed L2 = L0 IF L0 >= 3 // First sector { &Chain1 = 1 // 1 selected { &REF = 1 } } ELSE // Is a greater value { &REF = 0 // Off } } Var 7675, name REF, Link IOCARD_OUT, Output 4 // REF LED Var 7645, name Chain1, Link IOCARD_SW, Input 23
Cheers,
Jack
-
08-09-2010, 04:39 AM #2
- Join Date
- Jul 2013
- Posts
- 917
Re: SIOC "IF" Question
Jack
But you do not have 2 IF`s in your attempt. There are two ways in SIOC to make something happen on the value of two variables
IF Variable one = 1
{
IF Variable two = 1
{
LED = 1
}
}
OR
C0 = variable 1
C1 = variable 2
IF C0 AND C1
{
LED = 1
}
David
-
08-09-2010, 05:22 AM #3
Re: SIOC "IF" Question
Hi all,
Davids first suggestion will work and is a good way to do it.
Suggestion 2 is ever better but be carefull with it , I would write it like this to be more clear
C0 = variable one = 1
C1 = variable two = 1
IF C0 AND C1
{
LED = 1
}
so when variable one equals 1 the C0 will become one, same for C1, then the AND function will see that both C0 and C1 are true (1) and if thats the case the led will turn on
Greetings PeterFS9+PM+AST+opencockpits
-
08-09-2010, 07:47 AM #4
Re: SIOC "IF" Question
Very sorry Lads, I figured this out for myself but not before I switched of the PC last night!
Thanks for your suggestions anyway, especially suggestion 2 as it looks interesting.
However! Please don't disregard this thread, I am designing a SIoc script and I'd like to ask (once complete) if it achieves what i want it to do.
Jack
-
08-09-2010, 07:48 AM #5
- Join Date
- Oct 2008
- Location
- ontario
- Posts
- 95
Re: SIOC "IF" Question
I am far from an expert on SIOC as I am just starting to use it with IOCards but shouldn't the last line not have the ampersand (ie. the & symbol) removed so that it reads
Var 7645, name Chain1, Link IOCARD_SW, Input 23
Cheers, DaveDave Kemp
FS9-BU0836X-GoFlight 166-TH2GO-WideFS-FSUIPC-Opencockpits
-
08-09-2010, 10:50 AM #6
Re: SIOC "IF" Question
Hi Dave,
that's correct, but the symbol is no logner there (it was removed when I figured out the IF ELSE constructs).
Okay, I now need you guys to do another favour for me. I have engineered my own weather radar system using SIOC and FSUIPC Offsets. The System is designed to work with an IOCard interafced "DECCA" Panel. You won't understand unless you see a photo of the panel:
Before you read the script, note the following:
- The "LI" (Lights) Switch is NOT interfaced
- The "Chain" (Rotary) Switch has numbers running from 1-5
- The "OFF/REF/OP" Switch is a three-way rotary switch, with OFF position not being wired (so just 2 terminals wired)
- REF (Orange) and OP (Green) Are two LEDs
- This has come from a real aircraft
I would like the SIOC Script to do the following:
- If Precipitation Rate is more than 3, REF Light illumnates
- If Turbulence Rate is more than 3, OP Light Illuminates
- REF Light ONLY illuminates if the above condition is met and the Knob is set to "REF" or "OP"
- OP Light ONLY illuminates if the above condition is met and the Knob is set to "OP"
- The "Chain" Knob controls the cloud level. For example, if it is turned to 2, precipitation and turbulence reports will ONLY be given for cloud level 2 (this is controlled using appropriate Offsets)
- If the Mode Knob is set to OFF, then nothing happens (nothing lights up)
Thanks for reading, and please tell me if the script will do what I want:
Code:Var 7675, name REF, Link IOCARD_OUT, Output 4 // REF LED Var 7002, name OP, Link IOCARD_OUT, Output 5 // OP LED Var 9991, name OPSW, Link IOCARD_SW, Input 29, Type I // OP SW Var 8881, name REFSW, Link IOCARD_SW, Input 28, Type I // REF SW Var 9090, name Chain5, Link IOCARD_SW, Input 20 // Chain 5 Selector Var 7890, name Chain4, Link IOCARD_SW, Input 26 // Chain 4 Selector Var 7665, name Chain3, Link IOCARD_SW, Input 25 // Chain 3 Selector Var 7605, name Chain2, Link IOCARD_SW, Input 24 // Chain 2 Selector Var 7645, name Chain1, Link IOCARD_SW, Input 23 // Chain 1 Selector Var 9888, Link FSUIPC_IN, Offset $CE8D, Length 4 // Cloud Precipitation Rate (1) { L0 = V9888 // FSUIPC L0 = v9888 IF L0 >= 3 // First sector { IF &Chain1 = 1 // 1 selected { IF &REFSW = 1 { &REF = 1 } } } ELSE // Otherwise { &REF = 0 // Off } } Var 9889, Link FSUIPC_IN, Offset $CE9D, Length 4 // Cloud Precipitation Rate (2) { L0 = V9889 // FSUIPC L0 = v9889 IF L0 >= 3 // First sector { IF &Chain2 = 1 // 1 selected { IF &REFSW = 1 { &REF = 1 } } } ELSE // Otherwise { &REF = 0 // Off } } Var 9819, Link FSUIPC_IN, Offset $CEAD, Length 4 // Cloud Precipitation Rate (3) { L0 = V9819 // FSUIPC L0 = v9819 IF L0 >= 3 // First sector { IF &Chain3 = 1 // 1 selected { IF &REFSW = 1 { &REF = 1 } } } ELSE // Otherwise { &REF = 0 // Off } } Var 9829, Link FSUIPC_IN, Offset $CEBD, Length 4 // Cloud Precipitation Rate (4) { L0 = V9829 // FSUIPC L0 = v9829 IF L0 >= 3 // First sector { IF &Chain4 = 1 // 1 selected { IF &REFSW = 1 { &REF = 1 } } } ELSE // Otherwise { &REF = 0 // Off } } Var 3829, Link FSUIPC_IN, Offset $CECD, Length 4 // Cloud Precipitation Rate (5) { L0 = V3829 // FSUIPC L0 = v3829 IF L0 >= 3 // First sector { IF &Chain5 = 1 // 1 selected { IF &REFSW = 1 { &REF = 1 } } ELSE // Otherwise { &REF = 0 // Off } } } Var 1746, Link FSUIPC_IN, Offset $CE88, Length 4 // Cloud Turbulence Rate (1) { L0 = V1746 // FSUIPC L0 = v1746 IF L0 >= 3 // First sector { IF &Chain1 = 1 // 1 selected { IF &OPSW = 1 { &OP = 1 } } ELSE // Otherwise { &OP = 0 // Off } } } Var 3889, Link FSUIPC_IN, Offset $CE98, Length 4 // Cloud Turbulence Rate (2) { L0 = v3889 // FSUIPC L0 = v3889 IF L0 >= 3 // First sector { IF &Chain2 = 1 // 2 selected { IF &OPSW = 1 { &OP = 1 } } ELSE // Otherwise { &OP = 0 // Off } } } Var 3391, Link FSUIPC_IN, Offset $CEA8, Length 4 // Cloud Turbulence Rate (3) { L0 = V3391 // FSUIPC L0 = v3391 IF L0 >= 3 // First sector { IF &Chain3 = 1 // 3 selected { IF &OPSW { &OP = 1 } } } ELSE // Otherwise { &OP = 0 // Off } } Var 9716, Link FSUIPC_IN, Offset $CEB8, Length 4 // Cloud Turbulence Rate (4) { L0 = V9716 // FSUIPC L0 = v9716 IF L0 >= 3 // First sector { IF &Chain4 = 1 // 4 selected { IF &OPSW = 1 { &OP = 1 } } } ELSE // Otherwise { &OP = 0 // Off } } Var 1019, Link FSUIPC_IN, Offset $CEC8, Length 4 // Cloud Turbulence Rate (5) { L0 = V1019 // FSUIPC L0 = v1019 IF L0 >= 3 // First sector { IF &Chain5 = 1 // 5 selected { IF &OPSW = 1 { &OP = 1 } } ELSE // Otherwise { &OP = 0 // Off } } } Var 5678, Link FSUIPC_IN, Offset $CE8D, Length 4 // Cloud Precipitation Rate (1) { L0 = V5678 // FSUIPC L0 = v5678 IF L0 >= 3 // First sector { IF &Chain1 = 1 // 1 selected { IF &OPSW = 1 { &REF = 1 } } } ELSE // Otherwise { &REF = 0 // Off } } Var 5679, Link FSUIPC_IN, Offset $CE8D, Length 4 // Cloud Precipitation Rate (2) { L0 = V5679 // FSUIPC L0 = v5679 IF L0 >= 3 // First sector { IF &Chain2 = 1 // 2 selected { IF &OPSW = 1 { &REF = 1 } } } ELSE // Otherwise { &REF = 0 // Off } } Var 5680, Link FSUIPC_IN, Offset $CE8D, Length 4 // Cloud Precipitation Rate (3) { L0 = V5680 // FSUIPC L0 = v5680 IF L0 >= 3 // First sector { IF &Chain3 = 1 // 3 selected { IF &OPSW = 1 { &REF = 1 } } } ELSE // Otherwise { &REF = 0 // Off } } Var 5681, Link FSUIPC_IN, Offset $CE8D, Length 4 // Cloud Precipitation Rate (4) { L0 = V5681 // FSUIPC L0 = v5681 IF L0 >= 3 // First sector { IF &Chain4 = 1 // 4 selected { IF &OPSW = 1 { &REF = 1 } } } ELSE // Otherwise { &REF = 0 // Off } } Var 5682, Link FSUIPC_IN, Offset $CE8D, Length 4 // Cloud Precipitation Rate (5) { L0 = V5682 // FSUIPC L0 = v5682 IF L0 >= 3 // First sector { IF &Chain5 = 1 // 5 selected { IF &OPSW = 1 { &REF = 1 } } } ELSE // Otherwise { &REF = 0 // Off } }
-
08-09-2010, 11:06 AM #7
- Join Date
- Jul 2013
- Posts
- 917
Re: SIOC "IF" Question
Jack
For a script of this size and with so many conditions you would be better advised to run it and track what happens using IOCPConsole etc. You know how you programmed it !
Regards
David
-
08-10-2010, 11:08 AM #8
Re: SIOC "IF" Question
Hi David,
If it helps I'd like to "chop up" the script a bit then. this is because I'd rather get it sorted before my Master card arrives, giving me maximum time for testing.
First question: I've put the structure:
Code:{ L0 = V9888 // FSUIPC L0 = v9888 IF L0 >= 3 // First sector { IF &Chain1 = 1 // 1 selected { IF &REFSW = 1 { &REF = 1 } } } ELSE // Otherwise { &REF = 0 // Off } }
The question is, have I created a "contradictary paradox" here? I have used the same script for &REFSW and &OPSW to control the same LED (ie EITHER switch can control the LED). However, I have put at the end of each script ELSE &REF (LED) = 0 (OFF). This is contradictary because, for example, if the switch &OPSW was on, the LED should be lit. However, the script also says that if Switch &REF is off, the LED should be off. So, in short, the LED should in theory be ON and OFF at the same time.
How do I rectify this problem?
-
08-10-2010, 11:34 AM #9
- Join Date
- Jul 2013
- Posts
- 917
Re: SIOC "IF" Question
Jack
If I understand you correctly, then if either of two switches is on then the led should be on subject to further tests - else the led should be off
If you amend the example I and pdpo gave earlier in this thread then you can test if either switch is on
C0 = variable one = 1
C1 = variable two = 1
IF C0 OR C1
{
Insert here your further tests for conditions to turn on the LED
}
ELSE
{
LED = off
}
I cannot emphasise more strongly about using IOCPConsole to troubleshoot your code. That way you can see what is happening and recode accordingly
David
-
08-10-2010, 12:54 PM #10
Re: SIOC "IF" Question
Hi David,
How does this look (basic example):
Code:Var 7675, name REF, Link IOCARD_OUT, Output 4 // REF LED Var 9991, name OPSW, Link IOCARD_SW, Input 29, Type I // OP SW Var 8881, name REFSW, Link IOCARD_SW, Input 28, Type I // REF SW Var 7645, name Chain1, Link IOCARD_SW, Input 23 // Chain 1 Selector Var 9888, Link FSUIPC_IN, Offset $CE8D, Length 4 // Cloud Precipitation Rate (1) { C0 = V9991 = 1 C1 = V8881 = 1 IF C0 OR C1 { L0 = V9888 // FSUIPC L0 = v9888 IF L0 >= 3 // First sector { IF &Chain1 = 1 // 1 selected { &REF = 1 } } } ELSE // Otherwise { &REF = 0 // Off } }
Similar Threads
-
"Inner Circle" HSI - SIOC DC Motors Card Script
By Boeing 747 Flyer in forum OpenCockpits General DiscussionReplies: 64Last Post: 04-21-2011, 10:59 AM -
Looking for "Below GS" and "Spoilers armed" annunciator light offset
By PeterH in forum PM General Q & AReplies: 17Last Post: 03-05-2008, 12:39 PM -
A question for "Bus Drivers"
By mpl330 in forum General Builder Questions All Aircraft TypesReplies: 2Last Post: 01-31-2008, 06:56 PM -
PM updates and a question for "proof of concept"
By pap in forum PM General Q & AReplies: 4Last Post: 01-27-2008, 06:22 AM