Questions about named indexed vars (Electrical modular 2.0, Pneumatic_EX1, Hydraulics_EX1, etc)

@Boris @FlyingRaccoon,

I am now using these new wonderful systems in full for very detailed simulations, something I have come across that is not clear in the SDK documentation is how to use the indexed variables of these in different scenarios.

It is clear how to properly use the index names in RPN, for example given a circuit defined as:

circuit.1 = Type:CIRCUIT_PFD #    ConsumerCfg:ConsumerPFD    #Name:PFD

You would use it in RPN like this:

<ANIM_CODE>(A:CIRCUIT ON:'PFD'_n, percent)</ANIM_CODE>

however I cannot find how I am suppose to use it for:

Panel.xml for avionics:

Every panel.xml I have seen, is still using in the logic elements the old format:

<Simvar name="CIRCUIT ON:1" unit="boolean"/>

However the documentation state, we should be using the circuit name instead of a number for the index since the merge of aircraft parts could change the index number, so my question is, do the panel.xml logic elements support this? if so, how you use it then? an example would be useful for developers.

This apply obviously for hydraulics, pneumatics, new fuel system, etc.

WASM:

Same question, the examples I seen for the new VARS API is still using i as an index number:

FsUnitId unitId = fsVarsGetUnitId("DEGREES");
FsSimVarId simvarId = fsVarsGetAircraftVarId("ATTITUDE INDICATOR PITCH DEGREES");
FsVarParamArray param = FsCreateParamArray("i", 0);
double result = 0;
if (fsVarsAircraftVarGet(simvarId, unitId, param, &result) == FS_VAR_ERROR_NONE)
{
    // valid
}
else
{
    // error
}

So can we use a named circuit, hydraulic valve component, etc.? if so how?

I am worried that, although I can use the named index in RPN, I would be unable to do the same on panel.xml and custom WASM systems I have, so any advice on this, would be appreciated.

Regards,
Raul

Panel.xml at least supports it, I converted my plane to use the named circuits awhile back

<PlaneHTMLConfig>
	<Instrument>
		<Name>EICAS_ID</Name>
		<Electric>
			<And>
				<Simvar name="CIRCUIT ON:'EICAS display'_n" unit="Boolean"/>
			</And>
		</Electric>
	</Instrument>
.... more instruments here....
</PlaneHTMLConfig>

Where my system.cfg has a line

circuit.33 = Name:EICAS display#Type:CIRCUIT_XML#Voltage:28#Wattage:80

1 Like

Weekly bump, how we use this with WASM guys?

R.

Another bump.. please, pretty please, how I use this in WASM? I am writing thousands of lines of code, so far I can only do this with a fixed circuit index numbers, fixed fuel members index numbers and fixed hyd member numbers in my c++ modules, I don’t want to go too far to then have to come back to edit it all..

Best,
Raul

Hello @SimbolFSReborn

I haven’t seen any example of this in WASM yet but I would assume you simply need to pass a string instead of an int?
FsCreateParamArray("s","PFD")

@Arzop FYI

Regards,
Sylvain

I tried this and failed.. in hence why I came here asking hehe.

R.

Hello @SimbolFSReborn

FsCreateParamArray(“s”,“PFD”) should work. I’ve tested by modifing the Standalone WASM Module Sample with DA62’s vars.

My code looks like this :

// Decleration
FsSimVarId fuelSystemValveSwitch = 0;
FsSimVarId electricalMasterBattery = 0;
FsUnitId booleanUnitId = 0;
FsVarParamArray fuelSystemValveSwitchParam{ 0 };
FsVarParamArray mainBatteryParam{ 0 };

// Init
booleanUnitId = fsVarsGetUnitId("Boolean");
fuelSystemValveSwitch = fsVarsGetAircraftVarId("FUELSYSTEM VALVE SWITCH");
electricalMasterBattery = fsVarsGetAircraftVarId("ELECTRICAL MASTER BATTERY");
fuelSystemValveSwitchParam = FsCreateParamArray("s", "LeftEngValve");
mainBatteryParam = FsCreateParamArray("s", "Main_Battery");

// Update (every 1sec)
double leftEngValve = 0;
double masterBattery = 0;
fsVarsAircraftVarGet(fuelSystemValveSwitch, booleanUnitId, fuelSystemValveSwitchParam, &leftEngValve);
fsVarsAircraftVarGet(electricalMasterBattery, booleanUnitId, fuelSystemValveSwitchParam, &masterBattery);
printf("(A:FUELSYSTEM VALVE SWITCH:'LeftEngValve'_n, Boolean) : %f", leftEngValve);
printf("(A:ELECTRICAL MASTER BATTERY:'Main_Battery'_n, Boolean) : %f", masterBattery);

// Destroy
FsDestroyParamArray(&fuelSystemValveSwitchParam);
FsDestroyParamArray(&mainBatteryParam);

And when launching a flight with the DA62, vars are updated with my action on the plane


What does your code look like when you tried in WASM ?

Regards,
Edalyn

Hi @esoriaAsobo,

Thanks for following this up, I was trying to “set” variables not reading their values, so perhaps is where the problem relies? in setting it, not reading it?

Another difference, I was initializing the ParamArray like this: FsVarParamArray param = FsCreateParamArray("s", "name"); as per examples I found in the WASM libraries itself.

Where as you are initializing it 1st like this: FsVarParamArray Param{ 0 } and then using the FsCreateParamArray.

Anyhow when I tried this was back with SU3 1.15.2 or so.. maybes is fixed now? but can you check anyhow setting a variable rather than reading?

I will also recheck tonight if now with 1.15.16 I get it to work.

Best,
Raul

Hello,

With the following code in update, the battery switch of the DA62 goes on and off as intended

masterBattery = (masterBattery == 0) ? 1 : 0;
FsVarParamArray param = FsCreateParamArray("s", "Main_Battery");
fsVarsAircraftVarSet(electricalMasterBattery, booleanUnitId, param, masterBattery);
FsDestroyParamArray(&param);

I don’t think that the difference between the way you create the paramArray and mine changes anything

I’m not aware that something as been fixed since 1.15.2 on this, but maybe a fix had some good side effects

Regards,
Edalyn

Hi Edalyn,

Right, I was during “circuits” and “relays”, basically setting a relay by name to be powered or not. Could it be related to those?

I will re-try tonight and see.

R.

1 Like

hi @esoriaAsobo ,

So I managed it to get it working, I think I know what happened the last time I tried this, I was caught most likely by this bug: Recompiling a WASM System, doesn't reload unless I reload the plane from main menu - #12 by Boris

Which doesn’t allow you to fully compile WASM changes unless you go to the main menu, so most likely I tried string aproach, hit build, didn;t work because I was in flight on the tarmac and I got confused.

This time I compiled from main menu, and voila the results are good as yours.

Boris is already helping with the other bug anyway. Thanks for your help on this matter, your responses will help other developers to actually understand how this work, etc.

Best,
Raul

2 Likes

Will be this the same for sound.xml?

@FlyingRaccoon @Boris do you guys know?

Thanks Raul

Yes, passing names as index is also supported in sound.xml, through the Index element.
Although the documentation does not specify it.

We will have this fixed.

Regards,
Sylvain

Ahh,

Cam you post a quick example here in the meantime? We doing sounds as we speak and we want to use the new naming convention for circuits, etc..

Thanks,

R.

You will find some in the C208 Function_Exterior_Wheels attachment sound.xml:

<Sound WwiseData="true" WwiseEvent="wear_and_tear_brake" FadeOutTime="0.5" FadeOutType="2" SimVar="WEAR AND TEAR LEVEL" Index="'BRAKE'_n" Param1="'left'_n" Units="percent over 100" PositionX="1.710008" PositionY="-2.144578" PositionZ="-0.764263">
	<Range UpperBound="0.5"/>
	<WwiseRTPC SimVar="WEAR AND TEAR LEVEL" Index="'BRAKE'_n" Param1="'left'_n" Units="percent over 100" RTPCName="SIMVAR_WEAR_AND_TEAR_LEVEL"/>
	<Requires SimVar="CONTACT POINT IS ON GROUND" Index="6" Units="BOOL">
		<Range LowerBound="1"/>
	</Requires>
	<WwiseRTPC SimVar="GROUND VELOCITY" Units="meter per second" Index="0" RTPCName="SIMVAR_GROUND_VELOCITY"/>
	<WwiseRTPC SimVar="WHEEL RPM" Index="1" Units="rpm" RTPCName="SIMVAR_WHEEL_RPM"/>
	<Requires SimVar="WHEEL RPM" Index="1" Units="rpm">
		<Range LowerBound="1"/>
	</Requires>
	<WwiseRTPC SimVar="BRAKE LEFT POSITION" Index="0" Units="percent" RTPCName="SIMVAR_BRAKE_LEFT_POSITION"/>
	<WwiseRTPC SimVar="BRAKE PARKING POSITION" Index="0" Units="percent" RTPCName="SIMVAR_BRAKE_PARKING_POSITION"/>
</Sound>
1 Like

Thank you very much! :slight_smile:

R.

1 Like

Is param0 or param1 required to be written in all cases?

For example, I am currently doing the ECS/VCS sounds and need to connect them to a CIRCUIT ON A:Var. <Sound WwiseData="true" WwiseEvent="env_vcs_on" SimVar="CIRCUIT ON" NodeName="LEFT_CABINET_DRAWER_3" Units="BOOL" Index="'COMPRESSOR_DRIVE'_n" Continuous="true">

I am not too sure what to write as Param0 or Param1 in this case, or if it’s needed.

Also; whats the trick for setting string values in the simvar watcher? The INDEX key only goes to 99. This circuit on the systems cfg is 134. :stuck_out_tongue:

No, this is covered by the documentation:

Param0 is an alias for Index so you use either on but not both.
And Param1…N are required or not, depending on how many parameters the simvar expects.

I don’t think the string index is supported in SimVarWatcher yet.
The max index was likely defined before the introduction of the new core systems simvars.
I’ll have that reviewed.

Regards,
Sylvain

2 Likes

Thank you very much Sylvain, we got it working and Tyler is going to use the aircraft electrical debug to test circuits above 99, I had to give him a full project for this.

Would be good if the dev tools could be updated for this.

Thanks for your prompt help and replies.

Raul

2 Likes

The source code for the sim var watcher is included in the SDK samples so it’s an easy change to extend the index dropdown, or even make it a regular edit control rather than a drop down if you want to get it working immediately.