• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

How to use "dummy" VC switch to trigger XML gauge variables?

rotorhub

Resource contributor
Messages
122
Country
norway
How can I trigger variables in a hidden xml gauge by using this VC "dummy" switch code?
Adding code in the callback section in the modeldef works fine, but triggering the xml gauge not so much.
Either the switch moves on/off/on/off (flooding?), or nothing at all. As an audiable test I tried to set fuelpump on/off, with no luck. Are there any examples?

Example only:

Code:
    <PartInfo>
    <Name>UHF_Power_Sw1</Name>
    <AnimLength>50</AnimLength>
    <Animation>
      <Parameter>
        <Code>(L:UHF_Power_Sw1, number) 50 *</Code>
        <Lag>200</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>hand</Cursor>
      <TooltipText>UHF Power Switch = %((L:UHF_Power_Sw1, number) 0 ==)%{if}Off%{else}On%{end}</TooltipText>
      <MouseFlags>LeftSingle+RightSingle</MouseFlags>
      <CallbackCode>(L:UHF_Power_Sw1, number) ! (>L:UHF_Power_Sw1, number)</CallbackCode>
    </MouseRect>
  </PartInfo>

Non working gauge code
Code:
<!-- Just a test so I can hear the sound of the pump) -->
<Element>
  <Select>
    <Value>(A:GENERAL ENG FUEL PUMP SWITCH:1, bool) 0 != if{ 1 (L:UHF_Power_Sw1,bool) } els{ 0 (>L:UHF_Power_Sw1,bool) }</Value>
  </Select>
</Element>
 
Messages
258
Country
ireland
I think Tapen is saying that the code should read:

if{ 1 (>L:UHF_Power_Sw1,bool) } els{ 0 (>L:UHF_Power_Sw1,bool) }
 

rotorhub

Resource contributor
Messages
122
Country
norway
I think Tapen is saying that the code should read:

if{ 1 (>L:UHF_Power_Sw1,bool) } els{ 0 (>L:UHF_Power_Sw1,bool) }
Yes, I tried it and it did not produce any result either, so I got a bit unsure. I will investigate further. Thank you for helping out!
 
Messages
258
Country
ireland
In one of the instances above at the start, you have (L:UHF_Power_Sw1,number) and in the other you have (L:UHF_Power_Sw1,bool). Bool seems to be the correct option. Might be the cause of your problem.
 

rotorhub

Resource contributor
Messages
122
Country
norway
In one of the instances above at the start, you have (L:UHF_Power_Sw1,number) and in the other you have (L:UHF_Power_Sw1,bool). Bool seems to be the correct option. Might be the cause of your problem.
I have tried all combinations above, and none will trigger the fuelpump. The only thing that I got to work is to "toggle fuel pump" from a joystick. Then the VC switch follows. But no action when the VC switch is flipped.
So I probably got it backwards somehow, and the error is 40 cm from the screen :) I will leave it for now and just add code to the modeldef, where needed. Thank you again!
 
Messages
440
Country
us-wisconsin
Ahh, finally get what you're trying to do, perhaps? ( 2d gauge )
XML:
<!-- Just a test so I can hear the sound of the pump) -->
<!-- you should be able to get by using bool, the only true bool value is zero (false), anything else is a (true) -->
<!-- the code " 1 min " ensures that only a zero or a one are produced -->

<!-- if switch is on & pump is off, toggle the pump -->
<!-- if switch is off & pump is on, toggle the pump -->
<Element>
  <Select>
    <Value>(L:UHF_Power_Sw1, number) 1 min (A:GENERAL ENG FUEL PUMP SWITCH:1, bool) != if{ (>K:TOGGLE_ELECT_FUEL_PUMP1) }</Value>
  </Select>
</Element>
 
Last edited:

rotorhub

Resource contributor
Messages
122
Country
norway
Ahh, finally get what you're trying to do, perhaps? ( 2d gauge )
XML:
<!-- Just a test so I can hear the sound of the pump) -->
<!-- you should be able to get by using bool, the only true bool value is zero (false), anything else is a (true) -->
<!-- the code " 1 min " ensures that only a zero or a one are produced -->

<!-- if switch is on & pump is off, toggle the pump -->
<!-- if switch is off & pump is on, toggle the pump -->
<Element>
  <Select>
    <Value>(L:UHF_Power_Sw1, number) 1 min (A:GENERAL ENG FUEL PUMP SWITCH:1, bool) != if{ (>K:TOGGLE_ELECT_FUEL_PUMP1) }</Value>
  </Select>
</Element>
Yes, 2D gauge without graphics, to control variables. Vc switch is only on/off. What you are saying makes sense, and I can't wait to try it out in the morning. Many of the switces in the real T4 don't have any matching fs variables. So this is a way of getting the switces "workable" after compiling. Thank you!
 

rotorhub

Resource contributor
Messages
122
Country
norway
Ahh, finally get what you're trying to do, perhaps? ( 2d gauge )
XML:
<!-- Just a test so I can hear the sound of the pump) -->
<!-- you should be able to get by using bool, the only true bool value is zero (false), anything else is a (true) -->
<!-- the code " 1 min " ensures that only a zero or a one are produced -->

<!-- if switch is on & pump is off, toggle the pump -->
<!-- if switch is off & pump is on, toggle the pump -->
<Element>
  <Select>
    <Value>(L:UHF_Power_Sw1, number) 1 min (A:GENERAL ENG FUEL PUMP SWITCH:1, bool) != if{ (>K:TOGGLE_ELECT_FUEL_PUMP1) }</Value>
  </Select>
</Element>
It worked perfectly!
I am working on my XML syntax deciphering skills, and it sinks in a little at the time. Thank you for taking the time to teach, and share your knowledge.
 
Messages
258
Country
ireland
I too struggle greatly with the structures of XML, and being an ex COBOL'er I am amazed at times why some of the code works as it is so short and terse.

I fail to see how the code here works - to me there should be an "or" or an "and" before the if{

Code:
(L:UHF_Power_Sw1, number) 1 min (A:GENERAL ENG FUEL PUMP SWITCH:1, bool) != if{ (>K:TOGGLE_ELECT_FUEL_PUMP1)

There is a huge L sign on my back so forgive me if I missed an obvious XML trick here.


EDIT. I get it now, I think...
 

rotorhub

Resource contributor
Messages
122
Country
norway
I too struggle greatly with the structures of XML, and being an ex COBOL'er I am amazed at times why some of the code works as it is so short and terse.

I fail to see how the code here works - to me there should be an "or" or an "and" before the if{

Code:
(L:UHF_Power_Sw1, number) 1 min (A:GENERAL ENG FUEL PUMP SWITCH:1, bool) != if{ (>K:TOGGLE_ELECT_FUEL_PUMP1)

There is a huge L sign on my back so forgive me if I missed an obvious XML trick here.


EDIT. I get it now, I think...
It's like learning to read another language backwards, and that your sentence always should make sence. I only had HTML/CSS/Javascript skills before taking on RPN, and some PASCAL 38 years ago. So even if I start to understand, it is still a bit of trial and error.
 

rotorhub

Resource contributor
Messages
122
Country
norway
After some more testing I found that the working example code interupts the "joystick" fuel pump toggle. They do not work together, any ideas?

Code:
<Gauge Name="T4_systems_VC">
   <Update Frequency="1"/>

<!-- Just a test so I an hear the sound of the pump) -->
<Element>
  <Select>
    <Value>(L:UHF_Power_Sw1, number) 1 min (A:GENERAL ENG FUEL PUMP SWITCH:1, bool) != if{ (>K:TOGGLE_ELECT_FUEL_PUMP1) }</Value>
  </Select>
</Element>

</Gauge>
 
Messages
440
Country
us-wisconsin
After some more testing I found that the working example code interrupts the "joystick" fuel pump toggle. They do not work together, any ideas?
Woah! That's a whole new thing and if wanted to code a switch & joy command to do the same thing but yet overwrite each other would be a lot of work. (FSUIPC, Lua and or Macros etc..)
If you want the UHF switch to act like a fuel pump, why not code it that way from the start?
You can always lie a little on the tooltip to have it show as a UHF switch.
XML:
<PartInfo>
    <Name>UHF_Power_Sw1</Name>
    <AnimLength>50</AnimLength>
        <Animation>
            <Parameter>
                <Code>(A:GENERAL ENG FUEL PUMP SWITCH:1, bool) 50 *</Code>
                <Lag>200</Lag>
            </Parameter>
        </Animation>
    <MouseRect>
        <Cursor>hand</Cursor>
        <TooltipText>UHF Power Switch = %((A:GENERAL ENG FUEL PUMP SWITCH:1, bool) 0 ==)%{if}Off%{else}On%{end}</TooltipText>
        <MouseFlags>LeftSingle+RightSingle</MouseFlags>
        <CallbackCode>(>K:TOGGLE_ELECT_FUEL_PUMP1)</CallbackCode>
    </MouseRect>
</PartInfo>

fail to see how the code here works - to me there should be an "or" or an "and" before the if{
If the command for the fuel pump had discrete on/off commands then the code may be different. It doesn't, all that is available is a "toggle".
On of the best things to use is truth tables, in this case -
If switch is off & pump is off, (the 2 vars equal) do nothing
If switch is off & pump is on, (the 2 vars do not equal) toggle the pump to off --> the result will be the line directly above
If switch is on & pump is on, (the 2 vars equal) do nothing
If switch is on & pump is off, (the 2 vars do not equal) toggle the pump to
on --> the result will be the line directly above
 

rotorhub

Resource contributor
Messages
122
Country
norway
Woah! That's a whole new thing and if wanted to code a switch & joy command to do the same thing but yet overwrite each other would be a lot of work. (FSUIPC, Lua and or Macros etc..)
If you want the UHF switch to act like a fuel pump, why not code it that way from the start?
You can always lie a little on the tooltip to have it show as a UHF switch.
XML:
<PartInfo>
    <Name>UHF_Power_Sw1</Name>
    <AnimLength>50</AnimLength>
        <Animation>
            <Parameter>
                <Code>(A:GENERAL ENG FUEL PUMP SWITCH:1, bool) 50 *</Code>
                <Lag>200</Lag>
            </Parameter>
        </Animation>
    <MouseRect>
        <Cursor>hand</Cursor>
        <TooltipText>UHF Power Switch = %((A:GENERAL ENG FUEL PUMP SWITCH:1, bool) 0 ==)%{if}Off%{else}On%{end}</TooltipText>
        <MouseFlags>LeftSingle+RightSingle</MouseFlags>
        <CallbackCode>(>K:TOGGLE_ELECT_FUEL_PUMP1)</CallbackCode>
    </MouseRect>
</PartInfo>


If the command for the fuel pump had discrete on/off commands then the code may be different. It doesn't, all that is available is a "toggle".
On of the best things to use is truth tables, in this case -
If switch is off & pump is off, (the 2 vars equal) do nothing
If switch is off & pump is on, (the 2 vars do not equal) toggle the pump to off --> the result will be the line directly above
If switch is on & pump is on, (the 2 vars equal) do nothing
If switch is on & pump is off, (the 2 vars do not equal) toggle the pump to
on --> the result will be the line directly above
The fuel pump was just the most obvious test, without making a panel gauge to check status. Sorry if it was misleading, but it was very useful as an example, thanks again.

For most of the switches I will make a simple L:fake_system to mimic the behaviour of lamps and indicators.
But, since I am still working with the T4 documetation, it is easier to refactor the fake system XML as I go. And just let the VC switches do the triggering.
I can make some FSUIPC macros, if ever needed. I did this for a home cockpit many years ago. http://www.fsdreamteam.com/forum/index.php?topic=3248.0;wap2
 
Messages
258
Country
ireland
Before this thread maybe disappears into obscurity, could someone please tell me what exactly was going on.

There was a T4 mentioned, presumably an aircraft. It must have a VC installed and rotorhub wants to make something happen by using a 2D gauge with XML (but without graphics!!).

Spokes2112 understands exactly what the problem is and what is required to make it all happen, suggesting some elaborate working code and then even going to the bother of telling us all how it works (Nice one - the sign of a true mentor).

The fuel pump is however really only an example of the requirement and an easy one at that!

Or maybe I misunderstood the whole thing.

I don't even know if the original overall problem is actually solved.

Please tell me it had nothing to do with a suspected flaw in the computer logic on the Perseverance rover currently (we hope!) on its way to Mars! It seemed more complicated than that anyway.

Or, alternatively, you could just leave me in ignorance, fretting and losing sleep over something I know nothing about and could never hope to understand. :confused::banghead:
 

rotorhub

Resource contributor
Messages
122
Country
norway
Before this thread maybe disappears into obscurity, could someone please tell me what exactly was going on.

There was a T4 mentioned, presumably an aircraft. It must have a VC installed and rotorhub wants to make something happen by using a 2D gauge with XML (but without graphics!!).

Spokes2112 understands exactly what the problem is and what is required to make it all happen, suggesting some elaborate working code and then even going to the bother of telling us all how it works (Nice one - the sign of a true mentor).

The fuel pump is however really only an example of the requirement and an easy one at that!

Or maybe I misunderstood the whole thing.

I don't even know if the original overall problem is actually solved.

Please tell me it had nothing to do with a suspected flaw in the computer logic on the Perseverance rover currently (we hope!) on its way to Mars! It seemed more complicated than that anyway.

Or, alternatively, you could just leave me in ignorance, fretting and losing sleep over something I know nothing about and could never hope to understand. :confused::banghead:
I am doing a Jet Provost T4. Many of the switches in the VC are unsupported variables, like inverter selection and testing. I can add some code to the switch in the modeldef, but since I dont't know what functionality to implement yet, I just want to make use of a switch that have two states. I can then use a 2D XML gauge with no graphics to trigger it's function by the VC switch.

Her is the VC dummy switch, just a flickable switch with no FS variable trigger;
Code:
    <Animation name="UHF_Stby_Sw1" guid="4978dd8d-e742-49e7-8386-0c0c48f4cd4a" type="Sim" typeParam="AutoPlay" length="50" typeParam2="UHF_Stby_Sw1"/>

    <PartInfo>
    <Name>UHF_Stby_Sw1</Name>
    <AnimLength>50</AnimLength>
    <Animation>
      <Parameter>
        <Code>(L:UHF_Stby_Sw1, number) 50 *</Code>
        <Lag>200</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>hand</Cursor>
      <TooltipText>UHF Standby = %((L:UHF_Stby_Sw1, number) 0 ==)%{if}Standby%{else}Normal%{end}</TooltipText>
      <MouseFlags>LeftSingle+RightSingle</MouseFlags>
      <CallbackCode>(L:UHF_Stby_Sw1, number) ! (>L:UHF_Stby_Sw1, number)</CallbackCode>
    </MouseRect>
  </PartInfo>

The XML gauge trigger look like this;
Code:
<Gauge Name="T4_systems_VC">
   <Update Frequency="1"/>

<!-- Just a test so I an hear the sound of the pump) -->
<Element>
  <Select>
    <Value>(L:UHF_Power_Sw1, number) 1 min (A:GENERAL ENG FUEL PUMP SWITCH:1, bool) != if{ (>K:TOGGLE_ELECT_FUEL_PUMP1) }</Value>
  </Select>
</Element>

</Gauge>

The [Vcockpit01] section looks like this;

gauge00=Test!OxyGauge_VC, 1,1,0,0
gauge01=Test!T4_systems_VC, 1,1,0,0

The fuelpump was just an easy way of testing, because I can hear right if the switch trigger it's function. It will be replaced by something more logical, eventually, or not. UHF select top or belly antenna switch does not make any sense. So it will just be a dummy switch forever.

I am very grateful that all the XML magicans here reach out when we ordinary mortals are completely stuck. I am constantly plowing through the forum, and trying to learn as I go. Understanding units was good reading for me.

There are more advanced uses of 2D xml, Bill Leaming posted this example;
 
Top