I am definitely interested Tom, especially if this does not imply rewriting a major pat of the (existing) INS code!
I belive you will have to rewrite... but not too much!
Stay tuned.
Tom
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.
I am definitely interested Tom, especially if this does not imply rewriting a major pat of the (existing) INS code!
I'm eager to understand what you consider as "too much"too much
...
...
...(L:LDisplay:Digit1,number)
(L:LDisplay:Digit2,number)
(L:LDisplay:degreeSg1,number)
(L:LDisplay:Digit3,number)
(L:LDisplay:decimalSg1,number)
(L:LDisplay:Digit4,number)
(L:LDisplay:decimalSg2,number)
(L:LDisplay:Digit5,number)
(L:LDisplay:degreeSg2,number)
(L:LDisplay:NorthSouth,number)
(L:RDisplay:Digit1,number)
(L:RDisplay:Digit2,number)
(L:RDisplay:Digit3,number)
(L:RDisplay:degreeSg1,number)
(L:RDisplay:Digit4,number)
(L:RDisplay:decimalSg1,number)
(L:RDisplay:Digit5,number)
(L:RDisplay:decimalSg2,number)
(L:RDisplay:Digit6,number)
(L:RDisplay:degreeSg2,number)
(L:RDisplay:EastWest,number)
Digit values = 0-9 for numbers -1 Blank -2 (L)eft -3 (R)ight
Degree sign = -1 Blank 1 Visible
Decimal sign = -1 Blank 1 Visible
NorthSouth = -1 Blank 0 North 1 South
EastWest = -1 Blank 0 East 1 West
One additional question for you is about the two degree and decimal signs each data display has: In C++ I rendered them using separate ICONs, because if I used the font's corresponding character I'd have shifted digits around (even using a proportional font) while, as in the real unit, they had to stick to their position.
Question is: Is it possible to use the same technique with XML?
(L:CDU_1_Display:Digit1,number)
(L:CDU_1_LDisplay:Digit2,number)
...etc
(L:CDU_2_Display:Digit1,number)
(L:CDU_2_LDisplay:Digit2,number)
...etc
In CDU #1, use
<Macro Name="u">1</Macro>
(L:CDU_@u_Display:Digit1,number)
(L:CDU_@u_LDisplay:Digit2,number)
...etc
CDU #2 is a copy of #1, with a single replace that is
<Macro Name="u">2</Macro>
And so on
Pseudocode:
Values are [unit#1 = 8] [unit#2 = 5] [unit#3 = 12 (a flag value, for example BLANK)]
if( Unit is #1 )
{
assign (8 * 10000) to (L:RDisplay:Digit1,number) = 80000
}
else if( Unit is #2 )
{
add (5 * 100) to current (L:RDisplay:Digit1,number) value = 80500
}
else
{
add 12 to current (L:RDisplay:Digit1,number) value = 80512
}
Unit#1:
<Macro Name="DgEx">@1 10000 / int</Macro>
Unit#2:
<Macro Name="DgEx">@1 10000 / 1 % 100 * int</Macro>
Unit#3:
<Macro Name="DgEx">@1 100 / 1 % 100 * int</Macro>
And the "calling" code:
(L:RDisplay:Digit1,number) sp0
@DgEx(l0)
etc...
Well...Tom...no, I don't exactly get it, XML is still harder than hieroglyphs for meHope you get the idea
What I understand is that, in your proposed method, you would still use one LVar for each digit but with the advantage of using ("sharing") a single L:Var for 3 INS units. And this, assuming I understood, makes things even more complex for me.
At present I'm still trying to use a single LVar for each string, and I will not give up until all possible solutions (coming to my mind) will have been proven to be non working.

QUESTION: Does an XML "validator", "evaluator", "simulator" or something to test some XML code exists? Or the only chance it to let FS/P3D load it and then test/debug it using the supplied debugging facilities?
Actually this method cannot be more simple in the C++ front; with a single conversion function you solve everything.
And the XML part is easy as well, as I showed you. I know you will understand it as soon as you go deep into digesting XML scripts.
Suppose that I am, passing a 6 char string in a single, numeric LVAR is as simple as shown in my former posts. No need of BCD conversions, extra C++ functions or weird XML decodings.
Ok, then if you want a single LVAR for each string you will need 3 LVars for unit, total 9 LVars for 3 units plus another group of LVARs for decimal signs, Coordinate signs and degree signs. Am I right?
I appreciate your efforts to find the best solution dealing with a "language" (XML) that you don't dominate yet, but at the same time I feel it's a shame that you are going to invest a lot of time trying to figure out a method that perhaps you think is complex when it is really not.

a good XML text editor will help you check for missing symbols "{} (), etc"
If yes (uses shared LVars) then I must point out that, due to the way CIVA INS gauges have been implemented (and I'm not willing to touch that because it would be a major rework), it would be a nightmare for me to "share" a variable between separate INS units. That's why I am more inclined to use per-unit variables, it makes my life much simpler.
You're 150% right Sir! This perfectly matches the way CIVA handles the L/R Data and FromTo displays strings which are separate from degree/decimal "dots" and separate from the N/S/W/E icons. Connecting them together would be again quite complex on the C++ side.
//
// Left and Right Data Display Descriptor
//
typedef struct cdu_data_display_tag {
int iChangeCounterFlag; // Incremented every time data is modified
char szString [ 8 ]; // Display text (NULL terminated)
int iIconId; // N/S or E/W icons (0=None, 1=N/E, 2=S/W)
int iUpperDot1; // first upper "dot" *RIGHTMOST*
int iUpperDot2; // second upper "dot"
int iLowerDot1; // first lower "dot" *RIGHTMOST*
int iLowerDot2; // second lower "dot"
} INSDATADSP, * PINSDATADSP;
//
// FromTo Display Descriptor
//
typedef struct cdu_fromto_display_tag {
int iChangeCounterFlag; // Incremented every time data is modified
char szString [ 3 ]; // 2 chars + NULL Term.
BOOL bBlinkingOn; // FALSE=Visible TRUE=Blanked out
} INSFTDSP, * PINSFTDSP;
//
// MSU State
//
typedef struct msu_state_data_tag {
int iChangeCounterFlag; // Incremented every time data is modified
int iModeSelectorPosition; // See MODESELPOS_*
BOOL bNavReadyLight;
BOOL bBatLight;
} MSUSTATE, * PMSUSTATE;
//
// CDU State
//
typedef struct cdu_state_data_tag {
int iChangeCounterFlag; // Incremented every time data is modified
int iDataSelectorPosition; // See DATASELPOS_*
int iAutoManSelectorPosition; // See AUTOMANSELPOS_*
INSDATADSP tLeftDataDisplay;
INSDATADSP tRightDataDisplay;
INSFTDSP tFromToDisplay;
int iLightDimLevel;
int iSelectedWpDmeNum; // 0~9
BOOL bHoldLight;
BOOL bRemoteLight;
BOOL bInsertLight;
BOOL bAlertLight;
BOOL bBatLight;
BOOL bWarningLight;
BOOL bWyptChgLight;
} CDUSTATE, * PCDUSTATE;
//
// INS Data Descriptor
// One INS Descriptor is available for EACH INS Unit (so up to 3)
//
typedef struct ins_msu_cdu_state_tag {
BOOL bInstalled;
BOOL bOn;
MSUSTATE tMsu;
CDUSTATE tCdu;
BOOL bDmeUpdateActive; // NOT Valid for INS 3
BOOL bApConnected; // TRUE=Connected to Autopilot
BOOL bBatParallelState; // Valid ONLY for INS 3
BOOL bTestMode; // TRUE=Test pressed
} INUSTATE, * PINUSTATE;
Definitely Yes! Not each CDU but the bridge can easily do that!can each one of your CDU units call a single master function passing the string of data to assign to an LVAR?
I agree, this is a gray area!the order of update does count here indeed
I couldn't have either without the help from Gianfranco Corrias, real world Alitalia F/E on Classic 747s!And you don't really need to give me thanks, I could never have done my INS without the help of all your CIVA documents and examples.
And coordinate icons and dots in separate LVARs, right?. If possible the preferred solution would be one LVar per Display.Marco,
Only I need to know, would you like one LVAR per display, or one LVAR per digit?And coordinate icons and dots in separate LVARs, right?.
Sorry but I don't get it.In the example I would assume INSDATADSP * CDUnLDisp and INSDATADSP * CDUnRDisp for left and right data displays, and the same idea for the other stuctures, being n units 1 to 3. Is this ok?
#include <string>
PINUSTATE pINU;
// can be placed in a loop as well, verbosed for readingess
pINU = InsGetInuData(1)
fExportToXML(pINU,1)
pINU = InsGetInuData(2)
fExportToXML(pINU,2)
pINU = InsGetInuData(3)
fExportToXML(pINU,3)
void fExportToXML(PINUSTATE pINU, int iUnit)
{
std::string sUnit = (iUnit==1) ? "1" : (iUnit==2) ? "2" : "3";
std::string sCivaCduFromToDisplay = "CivaCduFromToDisplay:" + sUnit,
sCivaCduLeftDataDisplay = "CivaCduLeftDataDisplay:"+ sUnit,
sCivaCduRightDataDisplay = "CivaCduLeftDataDisplay:"+ sUnit;
std::string sDataToParse,
sChar,
sTemplate = "0123456789 LR";
std::size_t stFound;
double dInteger = 0;
double dFraction = 0;
// Left Data Display
// ///////////////////
sDataToParse = pINU->tCdu.tLeftDataDisplay.szString;
for (int s=0; s < 6;s++)
{
sChar = sDataToParse.substr(s,1);
stFound = sTemplate.find(sChar);
if ( stFound != std::string::npos )
{
if( s < 3 )
{
dInteger = dInteger + ( (double)stFound * (s==0) ? 10000 : (s==1) ? 100 : 1 );
}
else
{
dFraction = dFraction + ( (double)stFound * (s==3) ? 10000 : (s==4) ? 100 : 1 );
}
}
}
set_named_variable_typed_value(register_named_variable(sCivaCduLeftDataDisplay.c_str()),(dInteger + (dFraction/1000000)),get_units_enum("number"));
// RIGHT Data Display
// ///////////////////
sDataToParse = pINU->tCdu.tRightDataDisplay.szString;
dInteger = 0;
dFraction = 0;
for (s=0; s < 6;s++)
{
sChar = sDataToParse.substr(s,1);
stFound = sTemplate.find(sChar);
if ( stFound != std::string::npos )
{
if( s < 3 )
{
dInteger = dInteger + ( (double)stFound * (s==0) ? 10000 : (s==1) ? 100 : 1 );
}
else
{
dFraction = dFraction + ( (double)stFound * (s==3) ? 10000 : (s==4) ? 100 : 1 );
}
}
}
set_named_variable_typed_value(register_named_variable(sCivaCduRightDataDisplay.c_str()),(dInteger + (dFraction/1000000)),get_units_enum("number"));
// FromTo Display
// ///////////////////
sDataToParse = pINU->tCdu.tFromToDisplay.szString;
dInteger = 0;
for (s=0; s < 2;s++)
{
sChar = sDataToParse.substr(s,1);
stFound = sTemplate.find(sChar);
if ( stFound != std::string::npos )
{
dInteger = dInteger + ( (double)stFound * (s==0) ? 100 : 1 );
}
}
set_named_variable_typed_value(register_named_variable(sCivaCduFromToDisplay.c_str()),dInteger,get_units_enum("number"));
}
<Macro Name="PseudoBcdValueToChar">
(@1, number) < 10 if{ @1 0x30 + } els{
(@1, number) == 10 if{ 0x20 } els{
(@1, number) == 11 if{ 0x4c } els{ 0x3f }}}
</Macro>
if( s < 3 )
{
dInteger = dInteger + ( (double)stFound * (s==0) ? 10000 : (s==1) ? 100 : 1 );
}
else
{
dFraction = dFraction + ( (double)stFound * (s==3) ? 10000 : (s==4) ? 100 : 1 );
}
<Macro Name="u">1</Macro>
<!--
Reorder macros for different units!!!
<Macro Name="u">2</Macro>
<Macro Name="u">3</Macro>
-->
<Macro Name="StrChar">'R' 'L' ' ' '9' '8' '7' '6' '5' '4' '3' '2' '1' '0' 13 @1 case</Macro>
<Macro Name="ParseVar">
l0 10000 / int sp1 @StrChar(l1) sp1
l0 10000 / 1 % 100 * int sp2 @StrChar(l2) l1 r scat sp2
l0 100 / 1 % 100 * int sp3 @StrChar(l3) l2 r scat sp3
l0 1 % 1000000 * sp0
l0 10000 / int sp4 @StrChar(l4) l3 r scat sp4
l0 10000 / 1 % 100 * int sp5 @StrChar(l5) l4 r scat sp5
l0 100 / 1 % 100 * near sp6 @StrChar(l6) l5 r scat
</Macro>
<Update>
(L:CivaCduLeftDataDisplay:@u,number) sp0 @ParseVar sp10
(L:CivaCduRightDataDisplay:@u,number) sp0 @ParseVar sp11
(L:CivaCduFromToDisplay:@u,number) sp0 @ParseVar sp12
</Update>
<Element Name="LEFT DATA DISPLAY">
<Position X="x" Y="y"/>
<FormattedText X="x" Y="y" Font="font" FontSize="size" LineSpacing="spacing" Color="color" Bright="Yes">
<String>%(l10)%!s!</String>
</FormattedText>
</Element>
<Element Name="RIGHT DATA DISPLAY">
<Position X="x" Y="y"/>
<FormattedText X="x" Y="y" Font="font" FontSize="size" LineSpacing="spacing" Color="color" Bright="Yes">
<String>%(l11)%!s!</String>
</FormattedText>
</Element>
<Element Name="TO FROM">
<Position X="x" Y="y"/>
<FormattedText X="x" Y="y" Font="font" FontSize="size" LineSpacing="spacing" Color="color" Bright="Yes">
<String>%(l12)%!s!</String>
</FormattedText>
</Element>
C++ is easy for me while the XML side will be extremely difficult to understand (especially stack based operations) but I will try. Will report back "soon" (it will take few days I fear)!Like the C++ example, this was done on the paper only, NOT TESTED at all, but (I hope) you get the idea.