- Messages
- 26
- Country
Hi,
I'm progressing quite nicely on my project and can now create AI aircraft, give them a location, and (mostly) control the lights. Next bit are the control surfaces. Monitoring the user aircraft to get the data was not a big problem, although the "Position" type returned not a value from -16K to +16K as the SimConnect docs describe, but rather a FLOAT between -1.0 and 1.0.
Trying to set the "RUDDER POSITION" or "RUDDER PEDAL POSITION" and such got me a load of "Generic Data Error" exceptions. My Data Definition is:
When I tried to just set Flaps and Rudder with "FLAPS_SET" and "RUDDER_SET" events instead, I found out their parameters are DWORDS, so they can't take negative values.
Any hints?
Bert
I'm progressing quite nicely on my project and can now create AI aircraft, give them a location, and (mostly) control the lights. Next bit are the control surfaces. Monitoring the user aircraft to get the data was not a big problem, although the "Position" type returned not a value from -16K to +16K as the SimConnect docs describe, but rather a FLOAT between -1.0 and 1.0.
Trying to set the "RUDDER POSITION" or "RUDDER PEDAL POSITION" and such got me a load of "Generic Data Error" exceptions. My Data Definition is:
Code:
aircraftControlsData_.clear();
aircraftControlsData_.add(DATAID_CONTROL_RUDDER, "RUDDER PEDAL POSITION", "Position", SIMCONNECT_DATATYPE_FLOAT64);
aircraftControlsData_.add(DATAID_CONTROL_ELEVATOR, "ELEVATOR POSITION", "Position", SIMCONNECT_DATATYPE_FLOAT64);
aircraftControlsData_.add(DATAID_CONTROL_AILERON, "AILERON POSITION", "Position", SIMCONNECT_DATATYPE_FLOAT64);
aircraftControlsData_.add(DATAID_CONTROL_TRIM_RUDDER, "RUDDER TRIM PCT", "Percent over 100", SIMCONNECT_DATATYPE_FLOAT64);
aircraftControlsData_.add(DATAID_CONTROL_TRIM_ELEVATOR, "ELEVATOR TRIM PCT", "Percent over 100", SIMCONNECT_DATATYPE_FLOAT64);
aircraftControlsData_.add(DATAID_CONTROL_TRIM_AILERON, "AILERON TRIM PCT", "Percent over 100", SIMCONNECT_DATATYPE_FLOAT64);
aircraftControlsData_.add(DATAID_CONTROL_SPOILERS, "SPOILERS HANDLE POSITION", "Position", SIMCONNECT_DATATYPE_FLOAT64);
aircraftControlsData_.add(DATAID_CONTROL_FLAPS_HANDLE, "FLAPS HANDLE PERCENT", "Percent over 100", SIMCONNECT_DATATYPE_FLOAT64);
aircraftControlsData_.add(DATAID_CONTROL_PARKING_BRAKE, "BRAKE PARKING POSITION", "Position", SIMCONNECT_DATATYPE_FLOAT64);
aircraftControlsData_.add(DATAID_CONTROL_PRIMARY_DOOR, "EXIT OPEN:1", "Percent over 100", SIMCONNECT_DATATYPE_FLOAT64);
aircraftControlsData_.add(DATAID_CONTROL_GEARS_HANDLE, "GEAR HANDLE POSITION", "Bool", SIMCONNECT_DATATYPE_INT32);
mgr.defineData(aircraftControlsData_, [=](const void* data, const SimConnectData& dataDef) {
switch (dataDef.id) {
case DATAID_CONTROL_RUDDER: aircraftControls_.rudderPos = *static_cast<const double*>(data); break;
case DATAID_CONTROL_ELEVATOR: aircraftControls_.elevatorPos = *static_cast<const double*>(data); break;
case DATAID_CONTROL_AILERON: aircraftControls_.aileronPos = *static_cast<const double*>(data); break;
case DATAID_CONTROL_TRIM_RUDDER: aircraftControls_.rudderTrimPos = *static_cast<const double*>(data); break;
case DATAID_CONTROL_TRIM_ELEVATOR: aircraftControls_.elevatorTrimPos = *static_cast<const double*>(data); break;
case DATAID_CONTROL_TRIM_AILERON: aircraftControls_.aileronTrimPos = *static_cast<const double*>(data); break;
case DATAID_CONTROL_SPOILERS: aircraftControls_.spoilersPos = *static_cast<const double*>(data); break;
case DATAID_CONTROL_FLAPS_HANDLE: aircraftControls_.flapsPos = *static_cast<const double*>(data); break;
case DATAID_CONTROL_PARKING_BRAKE: aircraftControls_.parkingBrakePos = *static_cast<const double*>(data); break;
case DATAID_CONTROL_PRIMARY_DOOR: aircraftControls_.doorPos = *static_cast<const double*>(data); break;
case DATAID_CONTROL_GEARS_HANDLE: aircraftControls_.gearsDown = *static_cast<const int32_t*>(data); break;
default: LOG4CPLUS_ERROR(log_, "[aircraftControlsDataItemCallback](): Unknown dataId " << dataDef.id); break;
}
return true;
}, [=](int entryNr, int outOfNr, size_t size, const SimConnectDataDefinition* dataDef) {
LOG4CPLUS_TRACE(log_, "[aircraftControlsDataCompleteCallback](): Data block complete.");
api_.sendData(aircraftControls_);
return true;
});
When I tried to just set Flaps and Rudder with "FLAPS_SET" and "RUDDER_SET" events instead, I found out their parameters are DWORDS, so they can't take negative values.
Any hints?
Bert