• 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.

MSFS20 Clarification needed: What XML is "evaluated" at "compile time", what during simulation "run time"?

  • Thread starter Thread starter tml
  • Start date Start date

tml

Messages
89
Country
finland
If one compares the model XML file and all the things it includes to C or C++ source code that is compiled and run, do I understand correctly:

<UseTemplate> elements are "expanded" when the XML is read into the simulator. Let's call this "compile time". From the simulator's point if view it is completely equivalent if you replace a <UseTemplate> element with the contents of the corresponding <Template> element, with parameters replaced based on the ones you would have provided as child elements to the <UseTemplate> element, and with default and override parameters provided in the <Template> itself. All the parameter handling and expansion of #PARMETERNAME# things is done at compile time. Templates are conceptually a bit like C preprocessor macros, or C++ templates, right?

The XML logical expression trees constructed from <And>, <Or>, <Greater>, <Value> etc elements are also evaluated at compile time, right? As are RPN expression in the text of parameter name elements with the Process attribute. Such RPN then obviously can't contain references to simulation variables, but only literal numbers and strings (expanded from #PARAMETERS#), and RPN operators, conditionals, and function calls.

But <UseInputEvent> elements are not the same, right? You can't replace a <UseInputEvent> element with the contents of the corresponding <InputEvent> and get it to work, can you? Is the <InputElement> element used at run time, and it isn't enough to just have the <Presets> and <Preset> elements? But what about <Extend>?
 
Last edited:
But <UseInputEvent> elements are not the same, right? You can't replace a <UseInputEvent> element with the contents of the corresponding <InputEvent> and get it to work, can you? Is the <InputElement> element used at run time, and it isn't enough to just have the <Presets> and <Preset> elements? But what about <Extend>?

Maybe, maybe not.

This is my own custom InputEvent. I guess, in theory, you could replace the UseInputEvent call with all the stuff within <Presets> and it should work, in theory. Instead of using #PARAMETERS# you would replace them with the actual text/code/variables.

Personally, I think Asobo went mad with the InputEvents and they made a bunch of pointlessly complicated templates (as seems to be the way they do things). They all boil down to essentially what you see below. And if you didn't need to use <Bindings> the code below would be a fraction of the size.

Code:
    <InputEvent ID = "ANTSDRIFTEREVENTS">
        <Presets>
            <Preset ID="#PRESET_NAME#">
                <Tooltip>
                    <Icon>#TT_ICON#</Icon>
                    <Interaction>#TT_INTERACTION#</Interaction>
                    <InteractionLockable>#TT_INTERACTIONLOCKABLE#</InteractionLockable>
                    <TTDescription RPN="True">#TT_DESCRIPTION#</TTDescription>
                    <TTValue RPN="True">#TT_VALUE#</TTValue>
                </Tooltip>
                <Value>
                    <Units>#VAL_UNITS#</Units>
                    <Code>#VAL_CODE#</Code>
                    <Init>#VAL_INIT#</Init>
                    <WatchVars>
                        <Condition Check="VAL_LOCALVAR">
                            <True>
                                <LocalVar ID="#VAL_LOCALVAR#"/>                         
                            </True>
                        </Condition>
                        <Condition Check="VAL_LOCALVAR_2">
                            <True>
                                <LocalVar ID="#VAL_LOCALVAR_2#"/>                         
                            </True>
                        </Condition>
                        <Condition Check="VAL_SIMVAR">
                            <True>
                                <SimVar ID="#VAL_SIMVAR#"/>                         
                            </True>
                        </Condition>
                        <Condition Check="VAL_SIMVAR_2">
                            <True>
                                <SimVar ID="#VAL_SIMVAR_2#"/>                         
                            </True>
                        </Condition>
                    </WatchVars>
                </Value>
                <Inc>
                    <Code>#INC_CODE#</Code>
                    <Parameters>
                        <Param Type="Float" RPN="True">#INC_PARAM#</Param>
                    </Parameters>
                    <Bindings>
                        <Loop>
                            <Setup>
                                <Param>ID</Param>
                                <From>1</From>
                                <Inc>1</Inc>
                                <While>
                                    <Arg NotEmpty="INC_BINDING_#ID#"/>
                                </While>
                            </Setup>
                            <Do>
                                <Parameters Type="Override" Lifetime="Iteration">
                                    <INC_BINDING Process="Param">INC_BINDING_#ID#</INC_BINDING>
                                    <INC_BINDINGVALUE Process="Param">INC_BINDINGVALUE_#ID#</INC_BINDINGVALUE>
                                </Parameters>
                                <Binding EventID="#INC_BINDING#">
                                    <Param>#INC_BINDINGVALUE#</Param>
                                </Binding>                         
                            </Do>
                        </Loop>             
                    </Bindings>
                </Inc>
                <Dec>
                    <Code>#DEC_CODE#</Code>
                    <Parameters>
                        <Param Type="Float" RPN="True">#DEC_PARAM#</Param>
                    </Parameters>
                    <Bindings>
                        <Loop>
                            <Setup>
                                <Param>ID</Param>
                                <From>1</From>
                                <Inc>1</Inc>
                                <While>
                                    <Arg NotEmpty="DEC_BINDING_#ID#"/>
                                </While>
                            </Setup>
                            <Do>
                                <Parameters Type="Override" Lifetime="Iteration">
                                    <DEC_BINDING Process="Param">DEC_BINDING_#ID#</DEC_BINDING>
                                    <DEC_BINDINGVALUE Process="Param">DEC_BINDINGVALUE_#ID#</DEC_BINDINGVALUE>
                                </Parameters>
                                <Binding EventID="#DEC_BINDING#">
                                    <Param>#DEC_BINDINGVALUE#</Param>
                                </Binding>                         
                            </Do>
                        </Loop>             
                    </Bindings>
                </Dec>
                <Set>
                    <Code>#SET_CODE#</Code>
                    <Parameters>
                        <Param Type="Float" RPN="True">#SET_PARAM#</Param>
                    </Parameters>                 
                    <Bindings>
                        <Loop>
                            <Setup>
                                <Param>ID</Param>
                                <From>1</From>
                                <Inc>1</Inc>
                                <While>
                                    <Arg NotEmpty="SET_BINDING_#ID#"/>
                                </While>
                            </Setup>
                            <Do>
                                <Parameters Type="Override" Lifetime="Iteration">
                                    <SET_BINDING Process="Param">SET_BINDING_#ID#</SET_BINDING>
                                    <SET_BINDINGVALUE Process="Param">SET_BINDINGVALUE_#ID#</SET_BINDINGVALUE>
                                </Parameters>
                                <Binding EventID="#SET_BINDING#">
                                    <Param>#SET_BINDINGVALUE#</Param>
                                </Binding>                         
                            </Do>
                        </Loop>             
                    </Bindings>
                </Set>
            </Preset>
        </Presets>
    </InputEvent>
 
Back
Top