Closed OlHall closed 8 years ago
Like everything else in DCS-BIOS, the aircraft name is updated whenever it changes. Assigning it to address 0x0000 was a deliberate decision -- that makes sure that it is transmitted first, so when you receive the data for the new aircraft you already know what to look for. The "autosync" mechanism will resend a bit of unchanged data with each update, so the aircraft name will also be retransmitted from time to time, but a properly implemented StringBuffer should not set the dirty flag in this case.
Dynamically creating the controls should work. However, you may want to watch _ACFT_NAME with a specially modified StringBuffer class that calls its callback immediately after a new value has been received to ensure that the rest of the initial update when entering the new aircraft is correctly interpreted.
If dynamically creating the new buffer classes turns out to be too slow, you could also instantiate everything at once and just switch the PollingInput::firstPollingInput
and ExportStreamListener::firstExportStreamListener
pointers around (assuming there is enough memory to hold everything at once).
I did not consider multi-aircraft panels when designing DCS-BIOS. It is a use case where something like the Helios EOS protocol is clearly superior, because it puts all the configuration on the much more powerful PC.
The rationale behind the DCS-BIOS design is to put all panel-specific information into the panel's firmware.
For a multi-function panel, I would consider using some sort of middleware on the host PC that sits between DCS-BIOS and the panels. You could even talk the DCS-BIOS protocol to the panels, but assign addresses to specific outputs (and have inputs send generic commands, such as "PNL1_S1") and make the middleware translate between the two based on a configuration file and the currently active aircraft.
Think about it -- when a new aircraft module comes out, you don't want to have to re-flash all your panels.
The addresses and input identifiers on the "panel-side" DCS-BIOS protocol don't even have to be generic -- you could build your pit for a specific aircraft and then have the middleware adapt it to different ones.
This may be a job for Helios at some point in the future.
My motivation for this was because I'm not hardcore enough to want a specific aircraft simpit, but I do like the flexibility of physical switches etc. so my plan was to enable me to remap various encoders, switches, etc. to the most useful functions on each of the aircraft I like to fly (basically only helicopters!). I tend to switch about a bit too, so re-flashing the Arduino each time I do would become a chore.
Even though it's not "authentic" I'd still like to be able to control the radios of the Huey and the Ka-50 from the same set of controls (some redundant in one or the other modes).
I went for DCS-BIOS because it seems to offer that in a very simple package, without the need to any further middleware. I wasn't trying to make DCS-BIOS something it wasn't intended to be, so apologies if that's how it came across.
Don't worry, I will probably build some kind of multi-function panel myself at some point.
DCS-BIOS is still the way to go in terms of interfacing with DCS, but I think using additional middleware on the host PC to handle multi-aircraft panels makes more sense.
I've been wondering about whether it's possible (assuming a suitably sized Arduino) to support multiple aircraft types efficiently in a single Sketch. I realise we could just define all controls for each aircraft, and let the addressing sort itself out, but that will also create a long linked list of controls in the Parser's ExportStreamListener which may not be ideal as it's iterated over in each DcsBiosWrite and again at the end of the frame.
Two questions: Will the aircraft name be updated every frame, or just once at the beginning of the sim session? If it's the former, we'd need to protect against re-initialising the aircraft on every frame...
Secondly, would dynamically creating the controls work?
Something like this...