Event IDs Indexing

Hi there,
I am developing interface between hardware and simulator using simconnect and c#. To control most of the switches in sim I use Event IDs (Event IDs).
Some of them has something like index. For example Alternator:

Key: ALTERNATOR_SET
Parameter: alternator index
Description: Sets the indexed alternator. The alternator index is the N index of the alternator.N definition.

How do I specify N?

To “subscribe” to event I use

SimConnect.MapClientEventToSimEvent(Enum EventID, string EventName)
SimConnect.AddClientEventToNotificationGroup(Enum GroupID, Enum EventID, [MarshalAs(UnmanagedType.U1)] bool bMaskable)
SimConnect.SetInputGroupPriority(Enum GroupID, uint uPriority)

And to call the event:

SimConnect.TransmitClientEvent(uint ObjectID, Enum EventID, uint dwData, Enum GroupID, SIMCONNECT_EVENT_FLAG Flags)

Should I specify it in string EventName but if so, how?

Sorry, apparently this is not possible at the moment with SimConnect. :frowning: The Events which require two parameters cannot be activated this way. I’ve seen mention that this feature is planned for some near future (in forums, probably here somewhere), but nothing definitive.

There is a bit more detail about it if you scroll down on the electrical events page to Misc. section (eg. for ELECTRICAL_BUS_TO_BUS_CONNECTION_TOGGLE).

In the particular case with ALTERNATOR_SET, you can just pass it one parameter, 0 or 1 for off/on, in TransmitClientEvent()'s dwData, which will trigger both (or all) alternators at once, in case that helps. But there’s no way to isolate one.

I’m very close to releasing an open-source, multi-purpose, WASM-based Server & C++/C# Client API solution which will make this (and more) possible, maybe even as a simpler alternative to using SimConnect directly. Yes, I know, YAWM (yet another…), but this should be different… :wink:

Cheers,
-Max

This doesn’t work, at least for me right now… SimConnect reports error in the name parameter. Have you tried it?

I think you may have meant to use SetNotificationGroupPriority(). Input groups are different from Events.

BTW, just in case because it’s not clear in the docs and I’ve seen others do this also… to just send an Event, one does not need to subscribe to it, so neither AddClientEventToNotificationGroup() nor SetNotificationGroupPriority() are required. Just the Map and then the Transmit. When you subscribe, you also get notified about when you triggered (Transmitted) the event… which always seemed redundant to me (but of course may have its use cases).

-Max

1 Like

I didn’t know this. I am using this SimConnect.SetInputGroupPriority(Enum GroupID, uint uPriority) because this is how it was in some c++ sample from p3d. Unfortunately SimVarWatcher in msfs samples doesn’t provide example how to deal with events properly.
Thats a big problem with SimConnect that you don’t have really clear documentation with samples. I am new to this technology because I have started developing solutions based on simconnect about 3 years ago and this technology has about 20 years so…
I am using all that stuff because I thought it is proper way of doing this - it was in some c++ sample…
Thanks for drawing my attention to this issue.

Did you mean this page:
Reverse Polish Notation ?
It is about Simulation Variables. I am aware that I can specify index of simulation variable - I am using them to synchronise “toggle” events.

Feel free to post github link in this topic when you are ready. I was thinking about doing something like this. Does wasm enables more features which SimConnect can’t handle with data interfacing?
I am using similar approach to interface with xplane. I have plugin that hosts tcp server and I can read and set datarefs.

Thats first time I hear about YAWM. Could you link me some resources?
Cheers,
Lucas

Not only is it often lacking, but sometimes it is also just plain wrong. For example the number +/-16363 is often mentioned as numeric limits for some settings, while actually (from my experimentation) it’s +/-16384.

Well I meant for you to find that link, yes… :slight_smile: Below the SimVar section in RPN docs there’s a bit about Keys. “Keys” are another name for the SimConnect “events” because under the hood SimConnect is actually triggering what’s known as key events. Sorry for the confusion.

Yes, at least some. Basically most of the GaugeAPI functions are available to a WASM module which allows access to things like local variables but also to use calculator strings to execute or read events/data. SimConnect is still used in the module and on a client for network communication.

Sorry, I just mean Yet Another WASM Module. :slight_smile:

Ah cool, I was wondering how things could work with X. I maintain a plugin for a touch controller software which works with SimConnect in general, but some people have been asking about XPlane and I don’t know much about it.

BTW that plugin is in C# and you may, or may not :), find useful things in the SimConnectService class. I use a bit of a trick to call all SimConnect functions centrally (through a dispatch method) which helps with request tracking, but otherwise it’s pretty straight-forward.

Cheers,
-Max

1 Like

PS.

It also uses polling to get variables (SimConnect_RequestDataOnSimObjectType()) instead of SimConnect_RequestDataOnSimObject() which doesn’t need any polling (it “pushes” changes as they happen) and is way more efficient for most uses that need regular data updates whenever the values change. That plugin I linked earlier originally used that polling method from the example, but it’s all much simpler and faster now w/out polling (commit which changed this).

If your client doesn’t have a GUI (Window handle), you may also like how the WaitHandle is used with SimConnect() c’tor and in the ReceiveMessages() message dispatch thread loop to wait for new messages. Again, I’ve seen this (SimConnect running from a console app) hacked in many examples instead of just using the provided wait handle method.

-Max

1 Like

I dont know if this is what you are looking for but I was looking for similar info, found this post, but then found this in the documentation:

In the documentation under Miscellaneous Events

SELECT_1
SELECT_2
SELECT_3
SELECT_4

Sets “selected” index (for other events) to 1/2/3/4. Assume that means you can select the index, then call the other event, but I havent tested this yet

To follow up on this topic for completion, since SimConnect SDK version 0.19.0 there is now TransmitClientEvent_EX1() which accepts up to 5 parameter values.

Thanks for posting. That’s not the purpose of those SELECT_n events. To be honest I’d be hard-pressed to describe exactly what they’re for (played with them once a looong time ago but didn’t seem useful IIRC). But not for sending individual event values.

Cheers,
-Max

1 Like