Non GSX Fuel setting
This commit is contained in:
@@ -1,306 +1,299 @@
|
||||
#include "freighter.h"
|
||||
|
||||
// ZFW Entry
|
||||
void distribute(fPayloadData_t* const targetPayload, const FuelData_t* const fuel, const double ZFWTarget, const UserData_t* const userData) {
|
||||
// Find payload, num pax and extra cargo
|
||||
double payload = ZFWTarget - targetPayload->empty - targetPayload->pilot - targetPayload->firstOfficer - targetPayload->engineer -
|
||||
targetPayload->leftAux - targetPayload->rightAux;
|
||||
unsigned int cargo = round(payload);
|
||||
void distribute(fPayloadData_t *const targetPayload, const FuelData_t *const fuel, const double ZFWTarget,
|
||||
const UserData_t *const userData) {
|
||||
// Find payload, num pax and extra cargo
|
||||
double payload = ZFWTarget - targetPayload->empty - targetPayload->pilot - targetPayload->firstOfficer -
|
||||
targetPayload->engineer - targetPayload->leftAux - targetPayload->rightAux;
|
||||
unsigned int cargo = round(payload);
|
||||
|
||||
distribute(targetPayload, fuel, cargo, userData);
|
||||
distribute(targetPayload, fuel, cargo, userData);
|
||||
}
|
||||
|
||||
// SimBrief Entry
|
||||
void distribute(fPayloadData_t* const targetPayload, const FuelData_t* const fuel, unsigned int cargo, const UserData_t* const userData) {
|
||||
// Clear
|
||||
targetPayload->stations.upper1 = targetPayload->stations.upper2 = targetPayload->stations.upper3 = targetPayload->stations.upper4 =
|
||||
targetPayload->stations.total = 0;
|
||||
targetPayload->lowerForward = targetPayload->lowerRear = 0;
|
||||
void distribute(fPayloadData_t *const targetPayload, const FuelData_t *const fuel, unsigned int cargo,
|
||||
const UserData_t *const userData) {
|
||||
// Clear
|
||||
targetPayload->stations.upper1 = targetPayload->stations.upper2 = targetPayload->stations.upper3 =
|
||||
targetPayload->stations.upper4 = targetPayload->stations.total = 0;
|
||||
targetPayload->lowerForward = targetPayload->lowerRear = 0;
|
||||
|
||||
unsigned short _cargo = 0;
|
||||
unsigned int count = MAX_UPPER_CARGO(userData->isImperial) * 4 + MAX_FRONT_CARGO(userData->isImperial) + MAX_REAR_CARGO(userData->isImperial, userData->isER);
|
||||
// Initial distributiob
|
||||
while (cargo > 0 && count > 0) {
|
||||
if (cargo >= 6) {
|
||||
if (targetPayload->stations.upper1 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper1++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper2 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper2++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper3 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper3++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper4 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper4++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->lowerForward < MAX_FRONT_CARGO(userData->isImperial)) {
|
||||
targetPayload->lowerForward++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->lowerRear < MAX_REAR_CARGO(userData->isImperial, userData->isER)) {
|
||||
targetPayload->lowerRear++;
|
||||
_cargo++;
|
||||
}
|
||||
} else if (cargo == 5) {
|
||||
if (targetPayload->stations.upper1 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper1++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper2 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper2++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper3 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper3++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper4 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper4++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->lowerForward < MAX_FRONT_CARGO(userData->isImperial)) {
|
||||
targetPayload->lowerForward++;
|
||||
_cargo++;
|
||||
}
|
||||
}
|
||||
else if (cargo == 4) {
|
||||
if (targetPayload->stations.upper1 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper1++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper2 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper2++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper3 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper3++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper4 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper4++;
|
||||
_cargo++;
|
||||
}
|
||||
}
|
||||
else if (cargo == 3) {
|
||||
if (targetPayload->stations.upper1 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper1++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper2 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper2++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper3 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper3++;
|
||||
_cargo++;
|
||||
}
|
||||
}
|
||||
else if (cargo == 2) {
|
||||
if (targetPayload->stations.upper1 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper1++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper2 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper2++;
|
||||
_cargo++;
|
||||
}
|
||||
}
|
||||
else if (cargo == 1) {
|
||||
if (targetPayload->stations.upper1 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper1++;
|
||||
_cargo++;
|
||||
}
|
||||
}
|
||||
cargo -= _cargo;
|
||||
targetPayload->stations.total += _cargo;
|
||||
|
||||
_cargo = 0;
|
||||
|
||||
count--;
|
||||
unsigned short _cargo = 0;
|
||||
unsigned int count = MAX_UPPER_CARGO(userData->isImperial) * 4 + MAX_FRONT_CARGO(userData->isImperial) +
|
||||
MAX_REAR_CARGO(userData->isImperial, userData->isER);
|
||||
// Initial distributiob
|
||||
while (cargo > 0 && count > 0) {
|
||||
if (cargo >= 6) {
|
||||
if (targetPayload->stations.upper1 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper1++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper2 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper2++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper3 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper3++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper4 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper4++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->lowerForward < MAX_FRONT_CARGO(userData->isImperial)) {
|
||||
targetPayload->lowerForward++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->lowerRear < MAX_REAR_CARGO(userData->isImperial, userData->isER)) {
|
||||
targetPayload->lowerRear++;
|
||||
_cargo++;
|
||||
}
|
||||
} else if (cargo == 5) {
|
||||
if (targetPayload->stations.upper1 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper1++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper2 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper2++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper3 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper3++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper4 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper4++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->lowerForward < MAX_FRONT_CARGO(userData->isImperial)) {
|
||||
targetPayload->lowerForward++;
|
||||
_cargo++;
|
||||
}
|
||||
} else if (cargo == 4) {
|
||||
if (targetPayload->stations.upper1 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper1++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper2 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper2++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper3 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper3++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper4 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper4++;
|
||||
_cargo++;
|
||||
}
|
||||
} else if (cargo == 3) {
|
||||
if (targetPayload->stations.upper1 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper1++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper2 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper2++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper3 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper3++;
|
||||
_cargo++;
|
||||
}
|
||||
} else if (cargo == 2) {
|
||||
if (targetPayload->stations.upper1 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper1++;
|
||||
_cargo++;
|
||||
}
|
||||
if (targetPayload->stations.upper2 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper2++;
|
||||
_cargo++;
|
||||
}
|
||||
} else if (cargo == 1) {
|
||||
if (targetPayload->stations.upper1 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper1++;
|
||||
_cargo++;
|
||||
}
|
||||
}
|
||||
// Refinement
|
||||
count = MAX_UPPER_CARGO(userData->isImperial) * 4 + MAX_FRONT_CARGO(userData->isImperial) + MAX_REAR_CARGO(userData->isImperial, userData->isER);
|
||||
while (count > 0) {
|
||||
generatePayload(targetPayload, userData->isImperial);
|
||||
calculateCGs(targetPayload, fuel, &targetPayload->ZFWCG, &targetPayload->TOCG, userData->isImperial);
|
||||
cargo -= _cargo;
|
||||
targetPayload->stations.total += _cargo;
|
||||
|
||||
// in front of target
|
||||
if (targetPayload->ZFWCG < targetPayload->CGTarget - CG_TOLERANCE) {
|
||||
if (targetPayload->stations.upper1 > 0) {
|
||||
targetPayload->stations.upper1--;
|
||||
}
|
||||
else if (targetPayload->stations.upper2 > 0) {
|
||||
targetPayload->stations.upper2--;
|
||||
}
|
||||
else if (targetPayload->stations.upper3 > 0) {
|
||||
targetPayload->stations.upper3--;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
_cargo = 0;
|
||||
|
||||
if (targetPayload->stations.upper4 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper4++;
|
||||
}
|
||||
else if (targetPayload->stations.upper3 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper3++;
|
||||
}
|
||||
else if (targetPayload->stations.upper2 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper2++;
|
||||
}
|
||||
else {
|
||||
targetPayload->stations.upper1++;
|
||||
}
|
||||
}
|
||||
// behind target
|
||||
else if (targetPayload->ZFWCG > targetPayload->CGTarget + CG_TOLERANCE) {
|
||||
if (targetPayload->stations.upper4 > 0) {
|
||||
targetPayload->stations.upper4--;
|
||||
}
|
||||
else if (targetPayload->stations.upper3 > 0) {
|
||||
targetPayload->stations.upper3--;
|
||||
}
|
||||
else if (targetPayload->stations.upper2 > 0) {
|
||||
targetPayload->stations.upper2--;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
count--;
|
||||
}
|
||||
// Refinement
|
||||
count = MAX_UPPER_CARGO(userData->isImperial) * 4 + MAX_FRONT_CARGO(userData->isImperial) +
|
||||
MAX_REAR_CARGO(userData->isImperial, userData->isER);
|
||||
while (count > 0) {
|
||||
generatePayload(targetPayload, userData->isImperial);
|
||||
calculateCGs(targetPayload, fuel, userData->isImperial);
|
||||
|
||||
if (targetPayload->stations.upper1 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper1++;
|
||||
}
|
||||
else if (targetPayload->stations.upper2 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper2++;
|
||||
}
|
||||
else if (targetPayload->stations.upper3 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper3++;
|
||||
}
|
||||
else {
|
||||
targetPayload->stations.upper4++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
// in front of target
|
||||
if (targetPayload->ZFWCG < targetPayload->CGTarget - CG_TOLERANCE) {
|
||||
if (targetPayload->stations.upper1 > 0) {
|
||||
targetPayload->stations.upper1--;
|
||||
} else if (targetPayload->stations.upper2 > 0) {
|
||||
targetPayload->stations.upper2--;
|
||||
} else if (targetPayload->stations.upper3 > 0) {
|
||||
targetPayload->stations.upper3--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
count--;
|
||||
if (targetPayload->stations.upper4 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper4++;
|
||||
} else if (targetPayload->stations.upper3 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper3++;
|
||||
} else if (targetPayload->stations.upper2 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper2++;
|
||||
} else {
|
||||
targetPayload->stations.upper1++;
|
||||
}
|
||||
}
|
||||
// Refinement cargo
|
||||
count = MAX_FRONT_CARGO(userData->isImperial) + MAX_REAR_CARGO(userData->isImperial, userData->isER);
|
||||
while (count > 0) {
|
||||
generatePayload(targetPayload, userData->isImperial);
|
||||
calculateCGs(targetPayload, fuel, &targetPayload->ZFWCG, &targetPayload->TOCG, userData->isImperial);
|
||||
// behind target
|
||||
else if (targetPayload->ZFWCG > targetPayload->CGTarget + CG_TOLERANCE) {
|
||||
if (targetPayload->stations.upper4 > 0) {
|
||||
targetPayload->stations.upper4--;
|
||||
} else if (targetPayload->stations.upper3 > 0) {
|
||||
targetPayload->stations.upper3--;
|
||||
} else if (targetPayload->stations.upper2 > 0) {
|
||||
targetPayload->stations.upper2--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
// in front of target
|
||||
if (targetPayload->ZFWCG < targetPayload->CGTarget - CG_TOLERANCE) {
|
||||
if (targetPayload->lowerForward > 0 && targetPayload->lowerRear < MAX_REAR_CARGO(userData->isImperial, userData->isER)) {
|
||||
targetPayload->lowerForward--;
|
||||
targetPayload->lowerRear++;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// behind target
|
||||
else if (targetPayload->ZFWCG > targetPayload->CGTarget + CG_TOLERANCE) {
|
||||
if (targetPayload->lowerRear > 0 && targetPayload->lowerForward < MAX_FRONT_CARGO(userData->isImperial)) {
|
||||
targetPayload->lowerRear--;
|
||||
targetPayload->lowerForward++;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
||||
count--;
|
||||
if (targetPayload->stations.upper1 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper1++;
|
||||
} else if (targetPayload->stations.upper2 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper2++;
|
||||
} else if (targetPayload->stations.upper3 < MAX_UPPER_CARGO(userData->isImperial)) {
|
||||
targetPayload->stations.upper3++;
|
||||
} else {
|
||||
targetPayload->stations.upper4++;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
count--;
|
||||
}
|
||||
// Refinement cargo
|
||||
count = MAX_FRONT_CARGO(userData->isImperial) + MAX_REAR_CARGO(userData->isImperial, userData->isER);
|
||||
while (count > 0) {
|
||||
generatePayload(targetPayload, userData->isImperial);
|
||||
calculateCGs(targetPayload, fuel, userData->isImperial);
|
||||
|
||||
// in front of target
|
||||
if (targetPayload->ZFWCG < targetPayload->CGTarget - CG_TOLERANCE) {
|
||||
if (targetPayload->lowerForward > 0 && targetPayload->lowerRear < MAX_REAR_CARGO(userData->isImperial, userData->isER)) {
|
||||
targetPayload->lowerForward--;
|
||||
targetPayload->lowerRear++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// behind target
|
||||
else if (targetPayload->ZFWCG > targetPayload->CGTarget + CG_TOLERANCE) {
|
||||
if (targetPayload->lowerRear > 0 && targetPayload->lowerForward < MAX_FRONT_CARGO(userData->isImperial)) {
|
||||
targetPayload->lowerRear--;
|
||||
targetPayload->lowerForward++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
// Updates pax stations with their respective weights
|
||||
// Used internally and used for Station Entry (pax only, cargo is set directly)
|
||||
void generatePayload(fPayloadData_t* const targetPayload, const bool isImperial) {
|
||||
targetPayload->upper1Left = targetPayload->upper1Right = (targetPayload->stations.upper1 / 2.0);
|
||||
targetPayload->upper2Left = targetPayload->upper2Right = (targetPayload->stations.upper2 / 2.0);
|
||||
targetPayload->upper3Left = targetPayload->upper3Right = (targetPayload->stations.upper3 / 2.0);
|
||||
targetPayload->upper4Left = targetPayload->upper4Right = (targetPayload->stations.upper4 / 2.0);
|
||||
targetPayload->total = targetPayload->empty + targetPayload->pilot + targetPayload->firstOfficer + targetPayload->engineer + targetPayload->upper1Left +
|
||||
targetPayload->upper1Right + targetPayload->upper2Left + targetPayload->upper2Right + targetPayload->upper3Left +
|
||||
targetPayload->upper3Right + targetPayload->upper4Left + targetPayload->upper4Right + targetPayload->lowerForward +
|
||||
targetPayload->lowerRear + targetPayload->leftAux + targetPayload->rightAux;
|
||||
void generatePayload(fPayloadData_t *const targetPayload, const bool isImperial) {
|
||||
targetPayload->upper1Left = targetPayload->upper1Right = (targetPayload->stations.upper1 / 2.0);
|
||||
targetPayload->upper2Left = targetPayload->upper2Right = (targetPayload->stations.upper2 / 2.0);
|
||||
targetPayload->upper3Left = targetPayload->upper3Right = (targetPayload->stations.upper3 / 2.0);
|
||||
targetPayload->upper4Left = targetPayload->upper4Right = (targetPayload->stations.upper4 / 2.0);
|
||||
targetPayload->total = targetPayload->empty + targetPayload->pilot + targetPayload->firstOfficer + targetPayload->engineer +
|
||||
targetPayload->upper1Left + targetPayload->upper1Right + targetPayload->upper2Left +
|
||||
targetPayload->upper2Right + targetPayload->upper3Left + targetPayload->upper3Right +
|
||||
targetPayload->upper4Left + targetPayload->upper4Right + targetPayload->lowerForward +
|
||||
targetPayload->lowerRear + targetPayload->leftAux + targetPayload->rightAux;
|
||||
}
|
||||
|
||||
// Normalise to Pounds
|
||||
// MANDATORY BEFORE SETTING WEIGHTS
|
||||
// USE ON COPY OF GLOBAL STATE ONLY
|
||||
void normalisePayload(fPayloadData_t* const targetPayload, const bool isImperial) {
|
||||
targetPayload->empty = TO_POUNDS(isImperial, targetPayload->empty);
|
||||
targetPayload->pilot = TO_POUNDS(isImperial, targetPayload->pilot);
|
||||
targetPayload->firstOfficer = TO_POUNDS(isImperial, targetPayload->firstOfficer);
|
||||
targetPayload->engineer = TO_POUNDS(isImperial, targetPayload->engineer);
|
||||
targetPayload->upper1Left = TO_POUNDS(isImperial, targetPayload->upper1Left);
|
||||
targetPayload->upper1Right = TO_POUNDS(isImperial, targetPayload->upper1Right);
|
||||
targetPayload->upper2Left = TO_POUNDS(isImperial, targetPayload->upper2Left);
|
||||
targetPayload->upper2Right = TO_POUNDS(isImperial, targetPayload->upper2Right);
|
||||
targetPayload->upper3Left = TO_POUNDS(isImperial, targetPayload->upper3Left);
|
||||
targetPayload->upper3Right = TO_POUNDS(isImperial, targetPayload->upper3Right);
|
||||
targetPayload->upper4Left = TO_POUNDS(isImperial, targetPayload->upper4Left);
|
||||
targetPayload->upper4Right = TO_POUNDS(isImperial, targetPayload->upper4Right);
|
||||
targetPayload->lowerForward = TO_POUNDS(isImperial, targetPayload->lowerForward);
|
||||
targetPayload->lowerRear = TO_POUNDS(isImperial, targetPayload->lowerRear);
|
||||
targetPayload->leftAux = TO_POUNDS(isImperial, targetPayload->leftAux);
|
||||
targetPayload->rightAux = TO_POUNDS(isImperial, targetPayload->rightAux);
|
||||
void normalisePayload(fPayloadData_t *const targetPayload, const bool isImperial) {
|
||||
targetPayload->empty = TO_POUNDS(isImperial, targetPayload->empty);
|
||||
targetPayload->pilot = TO_POUNDS(isImperial, targetPayload->pilot);
|
||||
targetPayload->firstOfficer = TO_POUNDS(isImperial, targetPayload->firstOfficer);
|
||||
targetPayload->engineer = TO_POUNDS(isImperial, targetPayload->engineer);
|
||||
targetPayload->upper1Left = TO_POUNDS(isImperial, targetPayload->upper1Left);
|
||||
targetPayload->upper1Right = TO_POUNDS(isImperial, targetPayload->upper1Right);
|
||||
targetPayload->upper2Left = TO_POUNDS(isImperial, targetPayload->upper2Left);
|
||||
targetPayload->upper2Right = TO_POUNDS(isImperial, targetPayload->upper2Right);
|
||||
targetPayload->upper3Left = TO_POUNDS(isImperial, targetPayload->upper3Left);
|
||||
targetPayload->upper3Right = TO_POUNDS(isImperial, targetPayload->upper3Right);
|
||||
targetPayload->upper4Left = TO_POUNDS(isImperial, targetPayload->upper4Left);
|
||||
targetPayload->upper4Right = TO_POUNDS(isImperial, targetPayload->upper4Right);
|
||||
targetPayload->lowerForward = TO_POUNDS(isImperial, targetPayload->lowerForward);
|
||||
targetPayload->lowerRear = TO_POUNDS(isImperial, targetPayload->lowerRear);
|
||||
targetPayload->leftAux = TO_POUNDS(isImperial, targetPayload->leftAux);
|
||||
targetPayload->rightAux = TO_POUNDS(isImperial, targetPayload->rightAux);
|
||||
}
|
||||
|
||||
void calculateCGs(const fPayloadData_t* const targetPayload, const FuelData_t* const fuel, double* const ZFWCG, double* const TOCG, const bool isImperial) {
|
||||
fPayloadData_t localPayload = {};
|
||||
memcpy(&localPayload, targetPayload, sizeof(localPayload));
|
||||
normalisePayload(&localPayload, isImperial);
|
||||
void calculateCGs(fPayloadData_t *const targetPayload, const FuelData_t *const fuel, const bool isImperial) {
|
||||
fPayloadData_t localPayload = {};
|
||||
memcpy(&localPayload, targetPayload, sizeof(localPayload));
|
||||
normalisePayload(&localPayload, isImperial);
|
||||
|
||||
double totalMoment = localPayload.empty * ARM_EMPTY + localPayload.pilot * ARM_PILOT + localPayload.firstOfficer * ARM_FIRST_OFFICER +
|
||||
localPayload.engineer * ARM_ENGINEER + localPayload.upper1Left * ARM_F_UPPER1_LEFT + localPayload.upper1Right * ARM_F_UPPER1_RIGHT +
|
||||
localPayload.upper2Left * ARM_F_UPPER2_LEFT + localPayload.upper2Right * ARM_F_UPPER2_RIGHT + localPayload.upper3Left * ARM_F_UPPER3_LEFT +
|
||||
localPayload.upper3Right * ARM_F_UPPER3_RIGHT + localPayload.upper4Left * ARM_F_UPPER4_LEFT + localPayload.upper4Right * ARM_F_UPPER4_RIGHT +
|
||||
localPayload.lowerForward * ARM_FORWARD_CARGO + localPayload.lowerRear * ARM_REAR_CARGO + localPayload.leftAux * ARM_LEFT_AUX +
|
||||
localPayload.rightAux * ARM_RIGHT_AUX;
|
||||
double totalMoment = localPayload.empty * ARM_EMPTY + localPayload.pilot * ARM_PILOT +
|
||||
localPayload.firstOfficer * ARM_FIRST_OFFICER + localPayload.engineer * ARM_ENGINEER +
|
||||
localPayload.upper1Left * ARM_F_UPPER1_LEFT + localPayload.upper1Right * ARM_F_UPPER1_RIGHT +
|
||||
localPayload.upper2Left * ARM_F_UPPER2_LEFT + localPayload.upper2Right * ARM_F_UPPER2_RIGHT +
|
||||
localPayload.upper3Left * ARM_F_UPPER3_LEFT + localPayload.upper3Right * ARM_F_UPPER3_RIGHT +
|
||||
localPayload.upper4Left * ARM_F_UPPER4_LEFT + localPayload.upper4Right * ARM_F_UPPER4_RIGHT +
|
||||
localPayload.lowerForward * ARM_FORWARD_CARGO + localPayload.lowerRear * ARM_REAR_CARGO +
|
||||
localPayload.leftAux * ARM_LEFT_AUX + localPayload.rightAux * ARM_RIGHT_AUX;
|
||||
|
||||
double totalWeight = localPayload.empty + localPayload.pilot + localPayload.firstOfficer + localPayload.engineer + localPayload.upper1Left +
|
||||
localPayload.upper1Right + localPayload.upper2Left + localPayload.upper2Right + localPayload.upper3Left + localPayload.upper3Right +
|
||||
localPayload.upper4Left + localPayload.upper4Right + localPayload.lowerForward + localPayload.lowerRear + localPayload.leftAux +
|
||||
localPayload.rightAux;
|
||||
double totalWeight = localPayload.empty + localPayload.pilot + localPayload.firstOfficer + localPayload.engineer +
|
||||
localPayload.upper1Left + localPayload.upper1Right + localPayload.upper2Left + localPayload.upper2Right +
|
||||
localPayload.upper3Left + localPayload.upper3Right + localPayload.upper4Left + localPayload.upper4Right +
|
||||
localPayload.lowerForward + localPayload.lowerRear + localPayload.leftAux + localPayload.rightAux;
|
||||
|
||||
*ZFWCG = TO_PERCENT_MAC(totalMoment / totalWeight);
|
||||
targetPayload->ZFWCG = TO_PERCENT_MAC(totalMoment / totalWeight);
|
||||
|
||||
totalMoment += fuel->main1 * ARM_MAIN1 + fuel->main3 * ARM_MAIN3 + fuel->main2 * ARM_MAIN2 + fuel->upperAux * ARM_UPPER_AUX +
|
||||
fuel->lowerAux * ARM_LOWER_AUX + fuel->main1Tip * ARM_MAIN1_TIP + fuel->main3Tip * ARM_MAIN3_TIP +
|
||||
fuel->tail * ARM_TAIL + fuel->forwardAux1 * ARM_FORWARD_AUX1 + fuel->forwardAux2 * ARM_FORWARD_AUX2;
|
||||
totalMoment += fuel->main1 * ARM_MAIN1 + fuel->main3 * ARM_MAIN3 + fuel->main2 * ARM_MAIN2 + fuel->upperAux * ARM_UPPER_AUX +
|
||||
fuel->lowerAux * ARM_LOWER_AUX + fuel->main1Tip * ARM_MAIN1_TIP + fuel->main3Tip * ARM_MAIN3_TIP +
|
||||
fuel->tail * ARM_TAIL + fuel->forwardAux1 * ARM_FORWARD_AUX1 + fuel->forwardAux2 * ARM_FORWARD_AUX2;
|
||||
|
||||
totalWeight += fuel->total;
|
||||
totalWeight += fuel->total;
|
||||
|
||||
*TOCG = TO_PERCENT_MAC(totalMoment / totalWeight);
|
||||
targetPayload->TOCG = TO_PERCENT_MAC(totalMoment / totalWeight);
|
||||
}
|
||||
|
||||
void load(const fPayloadData_t* const targetPayload, const HANDLE simConnect, const bool isImperial) {
|
||||
fPayloadData_t localPayload = {};
|
||||
memcpy(&localPayload, targetPayload, sizeof(localPayload));
|
||||
normalisePayload(&localPayload, isImperial);
|
||||
void load(const fPayloadData_t *const targetPayload, const HANDLE simConnect, const bool isImperial) {
|
||||
fPayloadData_t localPayload = {};
|
||||
memcpy(&localPayload, targetPayload, sizeof(localPayload));
|
||||
normalisePayload(&localPayload, isImperial);
|
||||
|
||||
SimConnect_SetDataOnSimObject(simConnect, DATA_DEFINITION_PAYLOAD_F, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(fPayloadDataSet_t), &localPayload);
|
||||
localPayload._ZFWCG = localPayload.ZFWCG / 100.0;
|
||||
|
||||
SimConnect_SetDataOnSimObject(simConnect, DATA_DEFINITION_PAYLOAD_F, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(fPayloadDataSet_t),
|
||||
&localPayload);
|
||||
}
|
||||
|
||||
void unloadF(const HANDLE simConnect, const bool isER) {
|
||||
fPayloadData_t localPayload = {};
|
||||
fPayloadData_t localPayload = {};
|
||||
|
||||
localPayload.leftAux = localPayload.rightAux = isER ? AUX_WEIGHT(true) : 0;
|
||||
localPayload.pilot = localPayload.firstOfficer = localPayload.engineer = PILOT_WEIGHT(true);
|
||||
localPayload.leftAux = localPayload.rightAux = isER ? AUX_WEIGHT(true) : 0;
|
||||
localPayload.pilot = localPayload.firstOfficer = localPayload.engineer = PILOT_WEIGHT(true);
|
||||
|
||||
SimConnect_SetDataOnSimObject(simConnect, DATA_DEFINITION_PAYLOAD_F, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(fPayloadDataSet_t), &localPayload);
|
||||
localPayload._ZFWCG = -1;
|
||||
|
||||
SimConnect_SetDataOnSimObject(simConnect, DATA_DEFINITION_PAYLOAD_F, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(fPayloadDataSet_t),
|
||||
&localPayload);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __INTELLISENSE__
|
||||
# define MODULE_EXPORT __attribute__( ( visibility( "default" ) ) )
|
||||
# define MODULE_WASM_MODNAME(mod) __attribute__((import_module(mod)))
|
||||
#define MODULE_EXPORT __attribute__((visibility("default")))
|
||||
#define MODULE_WASM_MODNAME(mod) __attribute__((import_module(mod)))
|
||||
#else
|
||||
# define MODULE_EXPORT
|
||||
# define MODULE_WASM_MODNAME(mod)
|
||||
# define __attribute__(x)
|
||||
# define __restrict__
|
||||
#define MODULE_EXPORT
|
||||
#define MODULE_WASM_MODNAME(mod)
|
||||
#define __attribute__(x)
|
||||
#define __restrict__
|
||||
#endif
|
||||
|
||||
/********************************* Headers *********************************/
|
||||
@@ -19,10 +19,11 @@
|
||||
// C++ headers
|
||||
#include <algorithm>
|
||||
// Own headers
|
||||
#include "fuel.h"
|
||||
#include "shared.h"
|
||||
|
||||
/******************************** Constants ********************************/
|
||||
//PMC pallet due to 104in door
|
||||
// PMC pallet due to 104in door
|
||||
#define MAX_UPPER_CARGO(IS_IMPERIAL) ((IS_IMPERIAL) ? (6.5 * 15000.0) : (6.5 * 6804.0))
|
||||
// Max ZFW
|
||||
#define MAX_F_ZFW(IS_IMPERIAL) ((IS_IMPERIAL) ? (451300) : (204706))
|
||||
@@ -38,74 +39,79 @@
|
||||
|
||||
/***************************** Data structures *****************************/
|
||||
typedef struct {
|
||||
// SimConnect mapped
|
||||
double pilot;
|
||||
double firstOfficer;
|
||||
double engineer;
|
||||
double upper1Left;
|
||||
double upper1Right;
|
||||
double upper2Left;
|
||||
double upper2Right;
|
||||
double upper3Left;
|
||||
double upper3Right;
|
||||
double upper4Left;
|
||||
double upper4Right;
|
||||
double lowerForward;
|
||||
double lowerRear;
|
||||
double leftAux;
|
||||
double rightAux;
|
||||
// SimConnect mapped
|
||||
double pilot;
|
||||
double firstOfficer;
|
||||
double engineer;
|
||||
double upper1Left;
|
||||
double upper1Right;
|
||||
double upper2Left;
|
||||
double upper2Right;
|
||||
double upper3Left;
|
||||
double upper3Right;
|
||||
double upper4Left;
|
||||
double upper4Right;
|
||||
double lowerForward;
|
||||
double lowerRear;
|
||||
double leftAux;
|
||||
double rightAux;
|
||||
double _ZFWCG; // DO NOT USE
|
||||
|
||||
// Additional properties
|
||||
double empty;
|
||||
double total;
|
||||
double CGTarget;
|
||||
double ZFWCG;
|
||||
double TOCG;
|
||||
struct stations {
|
||||
unsigned int upper1;
|
||||
unsigned int upper2;
|
||||
unsigned int upper3;
|
||||
unsigned int upper4;
|
||||
unsigned int total;
|
||||
} stations;
|
||||
struct sbPlanned {
|
||||
double ZFW;
|
||||
double GW;
|
||||
unsigned int cargo;
|
||||
} sbPlanned;
|
||||
// Additional properties
|
||||
double empty;
|
||||
double total;
|
||||
double CGTarget;
|
||||
double ZFWCG;
|
||||
double TOCG;
|
||||
struct stations {
|
||||
unsigned int upper1;
|
||||
unsigned int upper2;
|
||||
unsigned int upper3;
|
||||
unsigned int upper4;
|
||||
unsigned int total;
|
||||
} stations;
|
||||
struct sbPlanned {
|
||||
double ZFW;
|
||||
double GW;
|
||||
double fuel;
|
||||
unsigned int cargo;
|
||||
} sbPlanned;
|
||||
} fPayloadData_t;
|
||||
|
||||
typedef struct {
|
||||
// SimConnect mapped
|
||||
double pilot;
|
||||
double firstOfficer;
|
||||
double engineer;
|
||||
double upper1Left;
|
||||
double upper1Right;
|
||||
double upper2Left;
|
||||
double upper2Right;
|
||||
double upper3Left;
|
||||
double upper3Right;
|
||||
double upper4Left;
|
||||
double upper4Right;
|
||||
double lowerForward;
|
||||
double lowerRear;
|
||||
double leftAux;
|
||||
double rightAux;
|
||||
// SimConnect mapped
|
||||
double pilot;
|
||||
double firstOfficer;
|
||||
double engineer;
|
||||
double upper1Left;
|
||||
double upper1Right;
|
||||
double upper2Left;
|
||||
double upper2Right;
|
||||
double upper3Left;
|
||||
double upper3Right;
|
||||
double upper4Left;
|
||||
double upper4Right;
|
||||
double lowerForward;
|
||||
double lowerRear;
|
||||
double leftAux;
|
||||
double rightAux;
|
||||
double ZFWCG;
|
||||
} fPayloadDataSet_t;
|
||||
|
||||
/******************************** Functions ********************************/
|
||||
// ZFW Entry
|
||||
void distribute(fPayloadData_t* const targetPayload, const FuelData_t* const fuel, const double ZFWTarget, const UserData_t* const userData);
|
||||
void distribute(fPayloadData_t *const targetPayload, const FuelData_t *const fuel, const double ZFWTarget,
|
||||
const UserData_t *const userData);
|
||||
// SimBrief Entry
|
||||
void distribute(fPayloadData_t* const targetPayload, const FuelData_t* const fuel, unsigned int cargo, const UserData_t* const userData);
|
||||
void distribute(fPayloadData_t *const targetPayload, const FuelData_t *const fuel, unsigned int cargo,
|
||||
const UserData_t *const userData);
|
||||
// Updates pax stations with their respective weights
|
||||
// Used internally and used for Station Entry (pax only, cargo is ste directly)
|
||||
// STATION WEIGHTS ARE NOT NORMALISED TO POUNDS
|
||||
void generatePayload(fPayloadData_t* const targetPayload, const bool isImperial);
|
||||
void generatePayload(fPayloadData_t *const targetPayload, const bool isImperial);
|
||||
// Normalise to Pounds
|
||||
// For Station Entry: CALL AFTER `generatePayload`
|
||||
void normalisePayload(fPayloadData_t* const targetPayload, const bool isImperial);
|
||||
void calculateCGs(const fPayloadData_t* const targetPayload, const FuelData_t* const fuel, double* const ZFWCG, double* const TOCG, const bool isImperial);
|
||||
void load(const fPayloadData_t* const targetPayload, const HANDLE simConnect, const bool isImperial);
|
||||
void normalisePayload(fPayloadData_t *const targetPayload, const bool isImperial);
|
||||
void calculateCGs(fPayloadData_t *const targetPayload, const FuelData_t *const fuel, const bool isImperial);
|
||||
void load(const fPayloadData_t *const targetPayload, const HANDLE simConnect, const bool isImperial);
|
||||
void unloadF(const HANDLE simConnect, const bool isER);
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
#include "fuel.h"
|
||||
|
||||
// ZFW Entry
|
||||
void distribute(FuelData_t *const targetFuel, const double fuelTarget, const UserData_t *const userData) {
|
||||
double fuelLbs = TO_POUNDS(userData->isImperial, fuelTarget);
|
||||
|
||||
// Equal mains
|
||||
if (fuelLbs <= MAX_TANK_1_3_LBS * 3) {
|
||||
double tanks = fuelLbs / 3;
|
||||
// Only main
|
||||
if (tanks <= MAX_TANK_1_3_TIP_LBS) {
|
||||
targetFuel->main1 = tanks;
|
||||
targetFuel->main3 = tanks;
|
||||
targetFuel->main1Tip = 0;
|
||||
targetFuel->main3Tip = 0;
|
||||
}
|
||||
// Tips
|
||||
else if (tanks <= MAX_TANK_1_3_TIP_LBS * 2) {
|
||||
double tips = tanks - MAX_TANK_1_3_TIP_LBS;
|
||||
targetFuel->main1 = MAX_TANK_1_3_TIP_LBS;
|
||||
targetFuel->main3 = MAX_TANK_1_3_TIP_LBS;
|
||||
targetFuel->main1Tip = tips;
|
||||
targetFuel->main3Tip = tips;
|
||||
}
|
||||
// Max tip
|
||||
else {
|
||||
double mains = tanks - MAX_TANK_1_3_TIP_LBS;
|
||||
targetFuel->main1 = mains;
|
||||
targetFuel->main3 = mains;
|
||||
targetFuel->main1Tip = MAX_TANK_1_3_TIP_LBS;
|
||||
targetFuel->main3Tip = MAX_TANK_1_3_TIP_LBS;
|
||||
}
|
||||
|
||||
targetFuel->main2 = tanks;
|
||||
|
||||
targetFuel->upperAux = 0;
|
||||
targetFuel->lowerAux = 0;
|
||||
targetFuel->tail = 0;
|
||||
targetFuel->forwardAux1 = 0;
|
||||
targetFuel->forwardAux2 = 0;
|
||||
}
|
||||
// No Aux
|
||||
else if (fuelLbs <= MAX_TANK_1_3_LBS * 2 + MAX_TANK_2_LBS) {
|
||||
targetFuel->main1 = MAX_TANK_1_3_MAIN_LBS;
|
||||
targetFuel->main3 = MAX_TANK_1_3_MAIN_LBS;
|
||||
targetFuel->main1Tip = MAX_TANK_1_3_TIP_LBS;
|
||||
targetFuel->main3Tip = MAX_TANK_1_3_TIP_LBS;
|
||||
|
||||
targetFuel->main2 = fuelLbs - MAX_TANK_1_3_LBS * 2;
|
||||
|
||||
targetFuel->upperAux = 0;
|
||||
targetFuel->lowerAux = 0;
|
||||
targetFuel->tail = 0;
|
||||
targetFuel->forwardAux1 = 0;
|
||||
targetFuel->forwardAux2 = 0;
|
||||
}
|
||||
// UPR AUX
|
||||
else if (fuelLbs <= MAX_TANK_1_3_LBS * 2 + MAX_TANK_2_LBS + MAX_UPR_AUX_LBS) {
|
||||
targetFuel->main1 = MAX_TANK_1_3_MAIN_LBS;
|
||||
targetFuel->main3 = MAX_TANK_1_3_MAIN_LBS;
|
||||
targetFuel->main1Tip = MAX_TANK_1_3_TIP_LBS;
|
||||
targetFuel->main3Tip = MAX_TANK_1_3_TIP_LBS;
|
||||
targetFuel->main2 = MAX_TANK_2_LBS;
|
||||
|
||||
targetFuel->upperAux = fuelLbs - MAX_TANK_1_3_LBS * 2 - MAX_TANK_2_LBS;
|
||||
|
||||
targetFuel->lowerAux = 0;
|
||||
targetFuel->tail = 0;
|
||||
targetFuel->forwardAux1 = 0;
|
||||
targetFuel->forwardAux2 = 0;
|
||||
}
|
||||
// LWR AUX
|
||||
else if (fuelLbs <= MAX_TANK_1_3_LBS * 2 + MAX_TANK_2_LBS + MAX_UPR_AUX_LBS + MAX_LWR_AUX_LBS) {
|
||||
targetFuel->main1 = MAX_TANK_1_3_MAIN_LBS;
|
||||
targetFuel->main3 = MAX_TANK_1_3_MAIN_LBS;
|
||||
targetFuel->main1Tip = MAX_TANK_1_3_TIP_LBS;
|
||||
targetFuel->main3Tip = MAX_TANK_1_3_TIP_LBS;
|
||||
targetFuel->main2 = MAX_TANK_2_LBS;
|
||||
targetFuel->upperAux = MAX_UPR_AUX_LBS;
|
||||
|
||||
targetFuel->lowerAux = fuelLbs - MAX_TANK_1_3_LBS * 2 - MAX_TANK_2_LBS - MAX_UPR_AUX_LBS;
|
||||
|
||||
targetFuel->tail = 0;
|
||||
targetFuel->forwardAux1 = 0;
|
||||
targetFuel->forwardAux2 = 0;
|
||||
}
|
||||
// Tail
|
||||
else if (fuelLbs <= MAX_TANK_1_3_LBS * 2 + MAX_TANK_2_LBS + MAX_UPR_AUX_LBS + MAX_LWR_AUX_LBS + MAX_TAIL_LBS) {
|
||||
targetFuel->main1 = MAX_TANK_1_3_MAIN_LBS;
|
||||
targetFuel->main3 = MAX_TANK_1_3_MAIN_LBS;
|
||||
targetFuel->main1Tip = MAX_TANK_1_3_TIP_LBS;
|
||||
targetFuel->main3Tip = MAX_TANK_1_3_TIP_LBS;
|
||||
targetFuel->main2 = MAX_TANK_2_LBS;
|
||||
targetFuel->upperAux = MAX_UPR_AUX_LBS;
|
||||
targetFuel->lowerAux = MAX_LWR_AUX_LBS;
|
||||
|
||||
targetFuel->tail = fuelLbs - MAX_TANK_1_3_LBS * 2 - MAX_TANK_2_LBS - MAX_UPR_AUX_LBS - MAX_LWR_AUX_LBS;
|
||||
|
||||
targetFuel->forwardAux1 = 0;
|
||||
targetFuel->forwardAux2 = 0;
|
||||
} else if (userData->isER) {
|
||||
targetFuel->main1 = MAX_TANK_1_3_MAIN_LBS;
|
||||
targetFuel->main3 = MAX_TANK_1_3_MAIN_LBS;
|
||||
targetFuel->main1Tip = MAX_TANK_1_3_TIP_LBS;
|
||||
targetFuel->main3Tip = MAX_TANK_1_3_TIP_LBS;
|
||||
targetFuel->main2 = MAX_TANK_2_LBS;
|
||||
targetFuel->upperAux = MAX_UPR_AUX_LBS;
|
||||
targetFuel->lowerAux = MAX_LWR_AUX_LBS;
|
||||
targetFuel->tail = MAX_TAIL_LBS;
|
||||
|
||||
fuelLbs = fuelLbs - MAX_TANK_1_3_LBS * 2 - MAX_TANK_2_LBS - MAX_UPR_AUX_LBS - MAX_LWR_AUX_LBS - MAX_TAIL_LBS;
|
||||
targetFuel->forwardAux1 = min(fuelLbs / 2, MAX_FWD_AUX_LBS);
|
||||
targetFuel->forwardAux2 = min(fuelLbs / 2, MAX_FWD_AUX_LBS);
|
||||
}
|
||||
|
||||
targetFuel->total = targetFuel->main1 + targetFuel->main3 + targetFuel->main2 + targetFuel->upperAux + targetFuel->lowerAux +
|
||||
targetFuel->main1Tip + targetFuel->main3Tip + targetFuel->tail + targetFuel->forwardAux1 +
|
||||
targetFuel->forwardAux2;
|
||||
}
|
||||
|
||||
void fuel(const FuelData_t *const targetFuel, const HANDLE simConnect) {
|
||||
FuelDataSet_t localFuel = {};
|
||||
|
||||
localFuel.main1 = min(MAX_TANK_1_3_GAL, (targetFuel->main1 + targetFuel->main1Tip) / LBS_PER_GAL);
|
||||
localFuel.main2 = min(MAX_TANK_2_GAL, targetFuel->main2 / LBS_PER_GAL);
|
||||
localFuel.main3 = min(MAX_TANK_1_3_GAL, (targetFuel->main3 + targetFuel->main3Tip) / LBS_PER_GAL);
|
||||
localFuel.upperAux = min(MAX_UPR_AUX_GAL, targetFuel->upperAux / LBS_PER_GAL);
|
||||
localFuel.lowerAux = min(MAX_LWR_AUX_GAL, targetFuel->lowerAux / LBS_PER_GAL);
|
||||
localFuel.tail = min(MAX_TAIL_GAL, targetFuel->tail / LBS_PER_GAL);
|
||||
localFuel.forwardAux1 = min(MAX_FWD_AUX_GAL, targetFuel->forwardAux1 / LBS_PER_GAL);
|
||||
localFuel.forwardAux2 = min(MAX_FWD_AUX_GAL, targetFuel->forwardAux2 / LBS_PER_GAL);
|
||||
|
||||
SimConnect_SetDataOnSimObject(simConnect, DATA_DEFINITION_FUEL_SET, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(FuelDataSet_t),
|
||||
&localFuel);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __INTELLISENSE__
|
||||
#define MODULE_EXPORT __attribute__((visibility("default")))
|
||||
#define MODULE_WASM_MODNAME(mod) __attribute__((import_module(mod)))
|
||||
#else
|
||||
#define MODULE_EXPORT
|
||||
#define MODULE_WASM_MODNAME(mod)
|
||||
#define __attribute__(x)
|
||||
#define __restrict__
|
||||
#endif
|
||||
|
||||
/********************************* Headers *********************************/
|
||||
// MSFS headers
|
||||
#include <MSFS/MSFS_WindowsTypes.h>
|
||||
#include <SimConnect.h>
|
||||
// C headers
|
||||
#include <math.h>
|
||||
// C++ headers
|
||||
#include <algorithm>
|
||||
// Own headers
|
||||
#include "shared.h"
|
||||
|
||||
/******************************** Constants ********************************/
|
||||
#define LBS_PER_GAL 6.699999809
|
||||
#define MAX_TANK_1_3_MAIN_GAL 5167.907
|
||||
#define MAX_TANK_1_3_TIP_GAL 874.5
|
||||
#define MAX_TANK_1_3_GAL (5167.907 + 874.5)
|
||||
#define MAX_TANK_2_GAL 9556.95
|
||||
#define MAX_UPR_AUX_GAL 12998.58
|
||||
#define MAX_LWR_AUX_GAL 1641.82
|
||||
#define MAX_TAIL_GAL 1957.779
|
||||
#define MAX_FWD_AUX_GAL 1970.8
|
||||
#define MAX_TANK_1_3_MAIN_LBS (LBS_PER_GAL * MAX_TANK_1_3_MAIN_GAL)
|
||||
#define MAX_TANK_1_3_TIP_LBS (LBS_PER_GAL * MAX_TANK_1_3_TIP_GAL)
|
||||
#define MAX_TANK_1_3_LBS (LBS_PER_GAL * MAX_TANK_1_3_GAL)
|
||||
#define MAX_TANK_2_LBS (LBS_PER_GAL * MAX_TANK_2_GAL)
|
||||
#define MAX_UPR_AUX_LBS (LBS_PER_GAL * MAX_UPR_AUX_GAL)
|
||||
#define MAX_LWR_AUX_LBS (LBS_PER_GAL * MAX_LWR_AUX_GAL)
|
||||
#define MAX_TAIL_LBS (LBS_PER_GAL * MAX_TAIL_GAL)
|
||||
#define MAX_FWD_AUX_LBS (LBS_PER_GAL * MAX_FWD_AUX_GAL)
|
||||
|
||||
// Max Fuel
|
||||
#define MAX_FUEL(IS_IMPERIAL) ((IS_IMPERIAL) ? (256207) : (116213))
|
||||
#define MAX_FUEL_ER(IS_IMPERIAL) ((IS_IMPERIAL) ? (282619) : (128193))
|
||||
// Arms Fuel
|
||||
#define ARM_MAIN1 -240.0
|
||||
#define ARM_MAIN3 -240.0
|
||||
#define ARM_MAIN2 120.0
|
||||
#define ARM_UPPER_AUX 0.0
|
||||
#define ARM_LOWER_AUX 0.0
|
||||
#define ARM_MAIN1_TIP -468.0
|
||||
#define ARM_MAIN3_TIP -468.0
|
||||
#define ARM_TAIL -840.0
|
||||
#define ARM_FORWARD_AUX1 60.0
|
||||
#define ARM_FORWARD_AUX2 60.0
|
||||
|
||||
/***************************** Data structures *****************************/
|
||||
typedef struct {
|
||||
// SimConnect mapped
|
||||
double main1;
|
||||
double main3;
|
||||
double main2;
|
||||
double upperAux;
|
||||
double lowerAux;
|
||||
double main1Tip;
|
||||
double main3Tip;
|
||||
double tail;
|
||||
double forwardAux1;
|
||||
double forwardAux2;
|
||||
// Additional properties
|
||||
double total;
|
||||
} FuelData_t;
|
||||
|
||||
typedef struct {
|
||||
double main1;
|
||||
double main3;
|
||||
double main2;
|
||||
double upperAux;
|
||||
double lowerAux;
|
||||
double tail;
|
||||
double forwardAux1;
|
||||
double forwardAux2;
|
||||
} FuelDataSet_t;
|
||||
|
||||
/******************************** Functions ********************************/
|
||||
void distribute(FuelData_t *const targetFuel, const double fuelTarget, const UserData_t *const userData);
|
||||
void fuel(const FuelData_t *const targetFuel, const HANDLE simConnect);
|
||||
@@ -1,25 +0,0 @@
|
||||
// load-manager-cli.cpp : This file contains the 'main' function. Program execution begins and ends there.
|
||||
//
|
||||
|
||||
#include "../wasm-module/pax.h"
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
bool isImperial = false;
|
||||
bool isER = true;
|
||||
|
||||
paxPayloadData_t targetPaxPayloadData = paxPayloadData_t();
|
||||
targetPaxPayloadData.empty = FROM_POUNDS(isImperial, 283975);
|
||||
targetPaxPayloadData.pilot = PAX_WEIGHT(isImperial);
|
||||
targetPaxPayloadData.firstOfficer = PAX_WEIGHT(isImperial);
|
||||
targetPaxPayloadData.engineer = PAX_WEIGHT(isImperial);
|
||||
targetPaxPayloadData.cabinCrewFront = FRONT_CREW_WEIGHT(isImperial);
|
||||
targetPaxPayloadData.cabinCrewRear = REAR_CREW_WEIGHT(isImperial);
|
||||
targetPaxPayloadData.leftAux = isER ? AUX_WEIGHT(isImperial) : 0;
|
||||
targetPaxPayloadData.rightAux = isER ? AUX_WEIGHT(isImperial) : 0;
|
||||
FuelData_t liveFuelData = FuelData_t();
|
||||
|
||||
distribute(&targetPaxPayloadData, &liveFuelData, 162000.0, 20.5, isImperial);
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{992caf4b-b3f6-4a86-a1c1-663686082c5e}</ProjectGuid>
|
||||
<RootNamespace>loadmanagercli</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pax.cpp" />
|
||||
<ClCompile Include="load-manager-cli.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pax.h" />
|
||||
<ClInclude Include="types.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>
|
||||
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="load-manager-cli.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pax.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pax.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="types.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
||||
+1224
-1085
File diff suppressed because it is too large
Load Diff
@@ -1,45 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __INTELLISENSE__
|
||||
# define MODULE_EXPORT __attribute__( ( visibility( "default" ) ) )
|
||||
# define MODULE_WASM_MODNAME(mod) __attribute__((import_module(mod)))
|
||||
#define MODULE_EXPORT __attribute__((visibility("default")))
|
||||
#define MODULE_WASM_MODNAME(mod) __attribute__((import_module(mod)))
|
||||
#else
|
||||
# define MODULE_EXPORT
|
||||
# define MODULE_WASM_MODNAME(mod)
|
||||
# define __attribute__(x)
|
||||
# define __restrict__
|
||||
#define MODULE_EXPORT
|
||||
#define MODULE_WASM_MODNAME(mod)
|
||||
#define __attribute__(x)
|
||||
#define __restrict__
|
||||
#endif
|
||||
|
||||
/********************************* Headers *********************************/
|
||||
// MSFS headers
|
||||
#include "rapidjson/filewritestream.h"
|
||||
#include <MSFS/Legacy/gauges.h>
|
||||
#include <MSFS/MSFS.h>
|
||||
#include <MSFS/MSFS_CommBus.h>
|
||||
#include <MSFS/Legacy/gauges.h>
|
||||
#include <SimConnect.h>
|
||||
#include <rapidjson/document.h>
|
||||
#include <rapidjson/filereadstream.h>
|
||||
#include "rapidjson/filewritestream.h"
|
||||
#include <rapidjson/writer.h>
|
||||
#include <SimConnect.h>
|
||||
|
||||
// C headers
|
||||
#include <string.h>
|
||||
// C++ headers
|
||||
#include <ctime>
|
||||
// Own headers
|
||||
#include "shared.h"
|
||||
#include "pax.h"
|
||||
#include "freighter.h"
|
||||
#include "fuel.h"
|
||||
#include "pax.h"
|
||||
#include "shared.h"
|
||||
|
||||
/******************************** Constants ********************************/
|
||||
// Module identification
|
||||
#define MODULE_NAME "[KHOFMANN TFDi MD-11 Load Manager] "
|
||||
#define VERSION_STRING "1.15"
|
||||
#define VERSION_STRING "2.9-beta"
|
||||
// COMM BUS
|
||||
#define COMM_BUS_LIVE_DATA_EVENT "khofmann_tfdi_md-11_load_manager_live_data"
|
||||
#define COMM_BUS_UPDATE_TARGET_EVENT "khofmann_tfdi_md-11_load_manager_update_target"
|
||||
|
||||
/******************************** Functions ********************************/
|
||||
void commBusUpdateTargetCallback(const char* args, unsigned int size, void* ctx);
|
||||
int receiveData(const char* buf);
|
||||
void commBusUpdateTargetCallback(const char *args, unsigned int size, void *ctx);
|
||||
int receiveData(const char *buf);
|
||||
void sendData();
|
||||
void CALLBACK MyDispatchProc(SIMCONNECT_RECV* pData, DWORD cbData, void* pContext);
|
||||
void log(FILE* file, const char* format, void* optionalElement = NULL);
|
||||
void CALLBACK MyDispatchProc(SIMCONNECT_RECV *pData, DWORD cbData, void *pContext);
|
||||
void log(FILE *file, const char *format, void *optionalElement = NULL);
|
||||
|
||||
@@ -5,28 +5,16 @@ VisualStudioVersion = 17.13.36105.23
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "load-manager", "load-manager.vcxproj", "{A5468B35-BBBD-4C55-97ED-81BFE343B0E4}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "load-manager-cli", "load-manager-cli.vcxproj", "{992CAF4B-B3F6-4A86-A1C1-663686082C5E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|MSFS = Debug|MSFS
|
||||
Debug|x64 = Debug|x64
|
||||
Release|MSFS = Release|MSFS
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A5468B35-BBBD-4C55-97ED-81BFE343B0E4}.Debug|MSFS.ActiveCfg = Debug|MSFS
|
||||
{A5468B35-BBBD-4C55-97ED-81BFE343B0E4}.Debug|MSFS.Build.0 = Debug|MSFS
|
||||
{A5468B35-BBBD-4C55-97ED-81BFE343B0E4}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{A5468B35-BBBD-4C55-97ED-81BFE343B0E4}.Release|MSFS.ActiveCfg = Release|MSFS
|
||||
{A5468B35-BBBD-4C55-97ED-81BFE343B0E4}.Release|MSFS.Build.0 = Release|MSFS
|
||||
{A5468B35-BBBD-4C55-97ED-81BFE343B0E4}.Release|x64.ActiveCfg = Release|MSFS
|
||||
{992CAF4B-B3F6-4A86-A1C1-663686082C5E}.Debug|MSFS.ActiveCfg = Debug|x64
|
||||
{992CAF4B-B3F6-4A86-A1C1-663686082C5E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{992CAF4B-B3F6-4A86-A1C1-663686082C5E}.Debug|x64.Build.0 = Debug|x64
|
||||
{992CAF4B-B3F6-4A86-A1C1-663686082C5E}.Release|MSFS.ActiveCfg = Release|x64
|
||||
{992CAF4B-B3F6-4A86-A1C1-663686082C5E}.Release|x64.ActiveCfg = Release|x64
|
||||
{992CAF4B-B3F6-4A86-A1C1-663686082C5E}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -288,12 +288,14 @@ Powershell.exe -File .\copy-release.ps1</Command>
|
||||
<ClCompile Include="freighter.cpp" />
|
||||
<ClCompile Include="load-manager.cpp" />
|
||||
<ClCompile Include="pax.cpp" />
|
||||
<ClCompile Include="fuel.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="freighter.h" />
|
||||
<ClInclude Include="load-manager.h" />
|
||||
<ClInclude Include="pax.h" />
|
||||
<ClInclude Include="shared.h" />
|
||||
<ClInclude Include="fuel.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
||||
+280
-284
@@ -1,329 +1,325 @@
|
||||
#include "pax.h"
|
||||
|
||||
// ZFW Entry, fill pax first (pax+bag), rest is cargo
|
||||
void distribute(paxPayloadData_t* const targetPayload, const FuelData_t* const fuel, const double ZFWTarget, const UserData_t* const userData,
|
||||
const UserOptions_t* const userOptions) {
|
||||
// Find payload, num pax and extra cargo
|
||||
double payload = ZFWTarget - targetPayload->empty - targetPayload->pilot - targetPayload->firstOfficer - targetPayload->engineer -
|
||||
targetPayload->cabinCrewFront - targetPayload->cabinCrewRear - targetPayload->leftAux - targetPayload->rightAux;
|
||||
unsigned short numPax = max(0.0, min((double)MAX_PAX, floor(payload / (PAX_WEIGHT(userData->isImperial, userOptions) +
|
||||
BAG_WEIGHT(userData->isImperial, userOptions)))));
|
||||
unsigned int cargo = round(payload - numPax * PAX_WEIGHT(userData->isImperial, userOptions) - numPax * BAG_WEIGHT(userData->isImperial, userOptions));
|
||||
void distribute(paxPayloadData_t *const targetPayload, const FuelData_t *const fuel, const double ZFWTarget,
|
||||
const UserData_t *const userData, const UserOptions_t *const userOptions) {
|
||||
// Find payload, num pax and extra cargo
|
||||
double payload = ZFWTarget - targetPayload->empty - targetPayload->pilot - targetPayload->firstOfficer -
|
||||
targetPayload->engineer - targetPayload->cabinCrewFront - targetPayload->cabinCrewRear -
|
||||
targetPayload->leftAux - targetPayload->rightAux;
|
||||
unsigned short numPax = max(0.0, min((double)MAX_PAX, floor(payload / (PAX_WEIGHT(userData->isImperial, userOptions) +
|
||||
BAG_WEIGHT(userData->isImperial, userOptions)))));
|
||||
unsigned int cargo = round(payload - numPax * PAX_WEIGHT(userData->isImperial, userOptions) -
|
||||
numPax * BAG_WEIGHT(userData->isImperial, userOptions));
|
||||
|
||||
distribute(targetPayload, fuel, numPax, cargo, userData, userOptions);
|
||||
distribute(targetPayload, fuel, numPax, cargo, userData, userOptions);
|
||||
}
|
||||
|
||||
// SimBrief Entry, SB pax count and extra cargo
|
||||
void distribute(paxPayloadData_t* const targetPayload, const FuelData_t* const fuel, unsigned short numPax, unsigned int cargo, const UserData_t* const userData,
|
||||
const UserOptions_t* const userOptions) {
|
||||
// Clear
|
||||
targetPayload->paxCount.business1 = targetPayload->paxCount.business2 = targetPayload->paxCount.economy1 = targetPayload->paxCount.economy2 =
|
||||
targetPayload->paxCount.total = 0;
|
||||
targetPayload->forwardCargo = targetPayload->rearCargo = 0;
|
||||
|
||||
unsigned short _numPax = 0;
|
||||
unsigned int count = MAX_PAX;
|
||||
// Initial distribution pax + bags
|
||||
while (numPax > 0 && count > 0) {
|
||||
if (numPax >= 4) {
|
||||
if (targetPayload->paxCount.business1 < MAX_BUSINESS_1) {
|
||||
targetPayload->paxCount.business1++;
|
||||
_numPax++;
|
||||
}
|
||||
if (targetPayload->paxCount.business2 < MAX_BUSINESS_2) {
|
||||
targetPayload->paxCount.business2++;
|
||||
_numPax++;
|
||||
}
|
||||
if (targetPayload->paxCount.economy1 < MAX_ECONOMY_1) {
|
||||
targetPayload->paxCount.economy1++;
|
||||
_numPax++;
|
||||
}
|
||||
if (targetPayload->paxCount.economy2 < MAX_ECONOMY_2) {
|
||||
targetPayload->paxCount.economy2++;
|
||||
_numPax++;
|
||||
}
|
||||
}
|
||||
else if (numPax == 3) {
|
||||
if (targetPayload->paxCount.business2 < MAX_BUSINESS_2) {
|
||||
targetPayload->paxCount.business2++;
|
||||
_numPax++;
|
||||
}
|
||||
if (targetPayload->paxCount.economy1 < MAX_ECONOMY_1) {
|
||||
targetPayload->paxCount.economy1++;
|
||||
_numPax++;
|
||||
}
|
||||
if (targetPayload->paxCount.economy2 < MAX_ECONOMY_2) {
|
||||
targetPayload->paxCount.economy2++;
|
||||
_numPax++;
|
||||
}
|
||||
}
|
||||
else if (numPax == 2) {
|
||||
if (targetPayload->paxCount.economy1 < MAX_ECONOMY_1) {
|
||||
targetPayload->paxCount.economy1++;
|
||||
_numPax++;
|
||||
}
|
||||
if (targetPayload->paxCount.economy2 < MAX_ECONOMY_2) {
|
||||
targetPayload->paxCount.economy2++;
|
||||
_numPax++;
|
||||
}
|
||||
}
|
||||
else if (numPax == 1) {
|
||||
if (targetPayload->paxCount.economy2 < MAX_ECONOMY_2) {
|
||||
targetPayload->paxCount.economy2++;
|
||||
_numPax++;
|
||||
}
|
||||
}
|
||||
numPax -= _numPax;
|
||||
targetPayload->paxCount.total += _numPax;
|
||||
void distribute(paxPayloadData_t *const targetPayload, const FuelData_t *const fuel, unsigned short numPax, unsigned int cargo,
|
||||
const UserData_t *const userData, const UserOptions_t *const userOptions) {
|
||||
// Clear
|
||||
targetPayload->paxCount.business1 = targetPayload->paxCount.business2 = targetPayload->paxCount.economy1 =
|
||||
targetPayload->paxCount.economy2 = targetPayload->paxCount.total = 0;
|
||||
targetPayload->forwardCargo = targetPayload->rearCargo = 0;
|
||||
|
||||
if (_numPax % 2 == 0) {
|
||||
targetPayload->forwardCargo += (_numPax / 2) * BAG_WEIGHT(userData->isImperial, userOptions);
|
||||
targetPayload->rearCargo += (_numPax / 2) * BAG_WEIGHT(userData->isImperial, userOptions);
|
||||
}
|
||||
else {
|
||||
_numPax--;
|
||||
targetPayload->forwardCargo += (_numPax / 2 + 1) * BAG_WEIGHT(userData->isImperial, userOptions);
|
||||
targetPayload->rearCargo += (_numPax / 2) * BAG_WEIGHT(userData->isImperial, userOptions);
|
||||
}
|
||||
|
||||
_numPax = 0;
|
||||
|
||||
count--;
|
||||
unsigned short _numPax = 0;
|
||||
unsigned int count = MAX_PAX;
|
||||
// Initial distribution pax + bags
|
||||
while (numPax > 0 && count > 0) {
|
||||
if (numPax >= 4) {
|
||||
if (targetPayload->paxCount.business1 < MAX_BUSINESS_1) {
|
||||
targetPayload->paxCount.business1++;
|
||||
_numPax++;
|
||||
}
|
||||
if (targetPayload->paxCount.business2 < MAX_BUSINESS_2) {
|
||||
targetPayload->paxCount.business2++;
|
||||
_numPax++;
|
||||
}
|
||||
if (targetPayload->paxCount.economy1 < MAX_ECONOMY_1) {
|
||||
targetPayload->paxCount.economy1++;
|
||||
_numPax++;
|
||||
}
|
||||
if (targetPayload->paxCount.economy2 < MAX_ECONOMY_2) {
|
||||
targetPayload->paxCount.economy2++;
|
||||
_numPax++;
|
||||
}
|
||||
} else if (numPax == 3) {
|
||||
if (targetPayload->paxCount.business2 < MAX_BUSINESS_2) {
|
||||
targetPayload->paxCount.business2++;
|
||||
_numPax++;
|
||||
}
|
||||
if (targetPayload->paxCount.economy1 < MAX_ECONOMY_1) {
|
||||
targetPayload->paxCount.economy1++;
|
||||
_numPax++;
|
||||
}
|
||||
if (targetPayload->paxCount.economy2 < MAX_ECONOMY_2) {
|
||||
targetPayload->paxCount.economy2++;
|
||||
_numPax++;
|
||||
}
|
||||
} else if (numPax == 2) {
|
||||
if (targetPayload->paxCount.economy1 < MAX_ECONOMY_1) {
|
||||
targetPayload->paxCount.economy1++;
|
||||
_numPax++;
|
||||
}
|
||||
if (targetPayload->paxCount.economy2 < MAX_ECONOMY_2) {
|
||||
targetPayload->paxCount.economy2++;
|
||||
_numPax++;
|
||||
}
|
||||
} else if (numPax == 1) {
|
||||
if (targetPayload->paxCount.economy2 < MAX_ECONOMY_2) {
|
||||
targetPayload->paxCount.economy2++;
|
||||
_numPax++;
|
||||
}
|
||||
}
|
||||
count = MAX_FRONT_CARGO(userData->isImperial);
|
||||
// Initial distibution of remaining cargo
|
||||
while (cargo > 0 && count > 0) {
|
||||
if (targetPayload->forwardCargo < MAX_FRONT_CARGO(userData->isImperial)) {
|
||||
targetPayload->forwardCargo++;
|
||||
cargo--;
|
||||
}
|
||||
if (targetPayload->rearCargo < MAX_REAR_CARGO(userData->isImperial, userData->isER) && cargo > 0) {
|
||||
targetPayload->rearCargo++;
|
||||
cargo--;
|
||||
}
|
||||
numPax -= _numPax;
|
||||
targetPayload->paxCount.total += _numPax;
|
||||
|
||||
count--;
|
||||
if (_numPax % 2 == 0) {
|
||||
targetPayload->forwardCargo += (_numPax / 2) * BAG_WEIGHT(userData->isImperial, userOptions);
|
||||
targetPayload->rearCargo += (_numPax / 2) * BAG_WEIGHT(userData->isImperial, userOptions);
|
||||
} else {
|
||||
_numPax--;
|
||||
targetPayload->forwardCargo += (_numPax / 2 + 1) * BAG_WEIGHT(userData->isImperial, userOptions);
|
||||
targetPayload->rearCargo += (_numPax / 2) * BAG_WEIGHT(userData->isImperial, userOptions);
|
||||
}
|
||||
// Refinement pax
|
||||
count = MAX_PAX;
|
||||
|
||||
unsigned char minBusiness1 = round(targetPayload->paxCount.business1 / 3);
|
||||
unsigned char minBusiness2 = round(targetPayload->paxCount.business2 / 3);
|
||||
unsigned char minEconomy1 = round(targetPayload->paxCount.economy1 / 3);
|
||||
unsigned char minEconomy2 = round(targetPayload->paxCount.economy2 / 3);
|
||||
_numPax = 0;
|
||||
|
||||
while (count > 0) {
|
||||
generatePayload(targetPayload, userData->isImperial, userOptions);
|
||||
calculateCGs(targetPayload, fuel, &targetPayload->ZFWCG, &targetPayload->TOCG, userData->isImperial);
|
||||
|
||||
// in front of target
|
||||
if (targetPayload->ZFWCG < targetPayload->CGTarget - CG_TOLERANCE) {
|
||||
if (targetPayload->paxCount.business1 > minBusiness1) {
|
||||
targetPayload->paxCount.business1--;
|
||||
}
|
||||
else if (targetPayload->paxCount.business2 > minBusiness2) {
|
||||
targetPayload->paxCount.business2--;
|
||||
}
|
||||
else if (targetPayload->paxCount.economy1 > minEconomy1) {
|
||||
targetPayload->paxCount.economy1--;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
||||
if (targetPayload->paxCount.economy2 < MAX_ECONOMY_2) {
|
||||
targetPayload->paxCount.economy2++;
|
||||
}
|
||||
else if (targetPayload->paxCount.economy1 < MAX_ECONOMY_1) {
|
||||
targetPayload->paxCount.economy1++;
|
||||
}
|
||||
else if (targetPayload->paxCount.business2 < MAX_BUSINESS_2) {
|
||||
targetPayload->paxCount.business2++;
|
||||
}
|
||||
else {
|
||||
targetPayload->paxCount.business1++;
|
||||
}
|
||||
}
|
||||
// behind target
|
||||
else if (targetPayload->ZFWCG > targetPayload->CGTarget + CG_TOLERANCE) {
|
||||
if (targetPayload->paxCount.economy2 > minEconomy2) {
|
||||
targetPayload->paxCount.economy2--;
|
||||
}
|
||||
else if (targetPayload->paxCount.economy1 > minEconomy1) {
|
||||
targetPayload->paxCount.economy1--;
|
||||
}
|
||||
else if (targetPayload->paxCount.business2 > minBusiness2) {
|
||||
targetPayload->paxCount.business2--;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
||||
if (targetPayload->paxCount.business1 < MAX_BUSINESS_1) {
|
||||
targetPayload->paxCount.business1++;
|
||||
}
|
||||
else if (targetPayload->paxCount.business2 < MAX_BUSINESS_2) {
|
||||
targetPayload->paxCount.business2++;
|
||||
}
|
||||
else if (targetPayload->paxCount.economy1 < MAX_ECONOMY_1) {
|
||||
targetPayload->paxCount.economy1++;
|
||||
}
|
||||
else {
|
||||
targetPayload->paxCount.economy2++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
||||
count--;
|
||||
count--;
|
||||
}
|
||||
count = MAX_FRONT_CARGO(userData->isImperial);
|
||||
// Initial distribution of remaining cargo
|
||||
while (cargo > 0 && count > 0) {
|
||||
if (targetPayload->forwardCargo < MAX_FRONT_CARGO(userData->isImperial)) {
|
||||
targetPayload->forwardCargo++;
|
||||
cargo--;
|
||||
}
|
||||
// Refinement cargo
|
||||
count = MAX_FRONT_CARGO(userData->isImperial) + MAX_REAR_CARGO(userData->isImperial, userData->isER);
|
||||
while (count > 0) {
|
||||
generatePayload(targetPayload, userData->isImperial, userOptions);
|
||||
calculateCGs(targetPayload, fuel, &targetPayload->ZFWCG, &targetPayload->TOCG, userData->isImperial);
|
||||
|
||||
// in front of target
|
||||
if (targetPayload->ZFWCG < targetPayload->CGTarget - CG_TOLERANCE) {
|
||||
if (targetPayload->forwardCargo > 0 && targetPayload->rearCargo < MAX_REAR_CARGO(userData->isImperial, userData->isER)) {
|
||||
if (targetPayload->forwardCargo > BAG_WEIGHT(userData->isImperial, userOptions) &&
|
||||
targetPayload->rearCargo < MAX_FRONT_CARGO(userData->isImperial) - BAG_WEIGHT(userData->isImperial, userOptions)) {
|
||||
targetPayload->forwardCargo -= BAG_WEIGHT(userData->isImperial, userOptions);
|
||||
targetPayload->rearCargo += BAG_WEIGHT(userData->isImperial, userOptions);
|
||||
}
|
||||
else {
|
||||
targetPayload->forwardCargo--;
|
||||
targetPayload->rearCargo++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// behind target
|
||||
else if (targetPayload->ZFWCG > targetPayload->CGTarget + CG_TOLERANCE) {
|
||||
if (targetPayload->rearCargo > 0 && targetPayload->forwardCargo < MAX_FRONT_CARGO(userData->isImperial)) {
|
||||
if (targetPayload->rearCargo > BAG_WEIGHT(userData->isImperial, userOptions) &&
|
||||
targetPayload->forwardCargo < MAX_REAR_CARGO(userData->isImperial, userData->isER) - BAG_WEIGHT(userData->isImperial, userOptions)) {
|
||||
targetPayload->rearCargo -= BAG_WEIGHT(userData->isImperial, userOptions);
|
||||
targetPayload->forwardCargo += BAG_WEIGHT(userData->isImperial, userOptions);
|
||||
}
|
||||
else {
|
||||
targetPayload->rearCargo--;
|
||||
targetPayload->forwardCargo++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
|
||||
count--;
|
||||
if (targetPayload->rearCargo < MAX_REAR_CARGO(userData->isImperial, userData->isER) && cargo > 0) {
|
||||
targetPayload->rearCargo++;
|
||||
cargo--;
|
||||
}
|
||||
|
||||
count--;
|
||||
}
|
||||
// Refinement pax
|
||||
count = MAX_PAX;
|
||||
|
||||
unsigned char minBusiness1 = round(targetPayload->paxCount.business1 / 3);
|
||||
unsigned char minBusiness2 = round(targetPayload->paxCount.business2 / 3);
|
||||
unsigned char minEconomy1 = round(targetPayload->paxCount.economy1 / 3);
|
||||
unsigned char minEconomy2 = round(targetPayload->paxCount.economy2 / 3);
|
||||
|
||||
while (count > 0) {
|
||||
generatePayload(targetPayload, userData->isImperial, userOptions);
|
||||
calculateCGs(targetPayload, fuel, userData->isImperial);
|
||||
|
||||
// in front of target
|
||||
if (targetPayload->ZFWCG < targetPayload->CGTarget - CG_TOLERANCE) {
|
||||
if (targetPayload->paxCount.business1 > minBusiness1) {
|
||||
targetPayload->paxCount.business1--;
|
||||
} else if (targetPayload->paxCount.business2 > minBusiness2) {
|
||||
targetPayload->paxCount.business2--;
|
||||
} else if (targetPayload->paxCount.economy1 > minEconomy1) {
|
||||
targetPayload->paxCount.economy1--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
if (targetPayload->paxCount.economy2 < MAX_ECONOMY_2) {
|
||||
targetPayload->paxCount.economy2++;
|
||||
} else if (targetPayload->paxCount.economy1 < MAX_ECONOMY_1) {
|
||||
targetPayload->paxCount.economy1++;
|
||||
} else if (targetPayload->paxCount.business2 < MAX_BUSINESS_2) {
|
||||
targetPayload->paxCount.business2++;
|
||||
} else {
|
||||
targetPayload->paxCount.business1++;
|
||||
}
|
||||
}
|
||||
// behind target
|
||||
else if (targetPayload->ZFWCG > targetPayload->CGTarget + CG_TOLERANCE) {
|
||||
if (targetPayload->paxCount.economy2 > minEconomy2) {
|
||||
targetPayload->paxCount.economy2--;
|
||||
} else if (targetPayload->paxCount.economy1 > minEconomy1) {
|
||||
targetPayload->paxCount.economy1--;
|
||||
} else if (targetPayload->paxCount.business2 > minBusiness2) {
|
||||
targetPayload->paxCount.business2--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
if (targetPayload->paxCount.business1 < MAX_BUSINESS_1) {
|
||||
targetPayload->paxCount.business1++;
|
||||
} else if (targetPayload->paxCount.business2 < MAX_BUSINESS_2) {
|
||||
targetPayload->paxCount.business2++;
|
||||
} else if (targetPayload->paxCount.economy1 < MAX_ECONOMY_1) {
|
||||
targetPayload->paxCount.economy1++;
|
||||
} else {
|
||||
targetPayload->paxCount.economy2++;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
count--;
|
||||
}
|
||||
// Refinement cargo
|
||||
count = MAX_FRONT_CARGO(userData->isImperial) + MAX_REAR_CARGO(userData->isImperial, userData->isER);
|
||||
while (count > 0) {
|
||||
generatePayload(targetPayload, userData->isImperial, userOptions);
|
||||
calculateCGs(targetPayload, fuel, userData->isImperial);
|
||||
|
||||
// in front of target
|
||||
if (targetPayload->ZFWCG < targetPayload->CGTarget - CG_TOLERANCE) {
|
||||
if (targetPayload->forwardCargo > 0 && targetPayload->rearCargo < MAX_REAR_CARGO(userData->isImperial, userData->isER)) {
|
||||
if (targetPayload->forwardCargo > BAG_WEIGHT(userData->isImperial, userOptions) &&
|
||||
targetPayload->rearCargo < MAX_FRONT_CARGO(userData->isImperial) - BAG_WEIGHT(userData->isImperial, userOptions)) {
|
||||
targetPayload->forwardCargo -= BAG_WEIGHT(userData->isImperial, userOptions);
|
||||
targetPayload->rearCargo += BAG_WEIGHT(userData->isImperial, userOptions);
|
||||
} else {
|
||||
targetPayload->forwardCargo--;
|
||||
targetPayload->rearCargo++;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// behind target
|
||||
else if (targetPayload->ZFWCG > targetPayload->CGTarget + CG_TOLERANCE) {
|
||||
if (targetPayload->rearCargo > 0 && targetPayload->forwardCargo < MAX_FRONT_CARGO(userData->isImperial)) {
|
||||
if (targetPayload->rearCargo > BAG_WEIGHT(userData->isImperial, userOptions) &&
|
||||
targetPayload->forwardCargo <
|
||||
MAX_REAR_CARGO(userData->isImperial, userData->isER) - BAG_WEIGHT(userData->isImperial, userOptions)) {
|
||||
targetPayload->rearCargo -= BAG_WEIGHT(userData->isImperial, userOptions);
|
||||
targetPayload->forwardCargo += BAG_WEIGHT(userData->isImperial, userOptions);
|
||||
} else {
|
||||
targetPayload->rearCargo--;
|
||||
targetPayload->forwardCargo++;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
// Updates pax stations with their respective weights
|
||||
// Used internally and used for Station Entry (pax only, cargo is set directly)
|
||||
void generatePayload(paxPayloadData_t* const targetPayload, const bool isImperial, const UserOptions_t* const userOptions) {
|
||||
targetPayload->business1Left = targetPayload->business1Center = targetPayload->business1Right = (targetPayload->paxCount.business1 / 3.0) * PAX_WEIGHT(isImperial, userOptions);
|
||||
targetPayload->business2Left = targetPayload->business2Center = targetPayload->business2Right = (targetPayload->paxCount.business2 / 3.0) * PAX_WEIGHT(isImperial, userOptions);
|
||||
targetPayload->economy1Left = targetPayload->economy1Center = targetPayload->economy1Right = (targetPayload->paxCount.economy1 / 3.0) * PAX_WEIGHT(isImperial, userOptions);
|
||||
targetPayload->economy2Left = targetPayload->economy2Center = targetPayload->economy2Right = (targetPayload->paxCount.economy2 / 3.0) * PAX_WEIGHT(isImperial, userOptions);
|
||||
targetPayload->total = targetPayload->empty + targetPayload->pilot + targetPayload->firstOfficer + targetPayload->engineer + targetPayload->cabinCrewFront +
|
||||
targetPayload->business1Left + targetPayload->business1Center + targetPayload->business1Right + targetPayload->business2Left +
|
||||
targetPayload->business2Center + targetPayload->business2Right + targetPayload->economy1Left + targetPayload->economy1Center +
|
||||
targetPayload->economy1Right + targetPayload->economy2Left + targetPayload->economy2Center + targetPayload->economy2Right +
|
||||
targetPayload->cabinCrewRear + targetPayload->forwardCargo + targetPayload->rearCargo + targetPayload->leftAux + targetPayload->rightAux;
|
||||
void generatePayload(paxPayloadData_t *const targetPayload, const bool isImperial, const UserOptions_t *const userOptions) {
|
||||
targetPayload->business1Left = targetPayload->business1Center = targetPayload->business1Right =
|
||||
(targetPayload->paxCount.business1 / 3.0) * PAX_WEIGHT(isImperial, userOptions);
|
||||
targetPayload->business2Left = targetPayload->business2Center = targetPayload->business2Right =
|
||||
(targetPayload->paxCount.business2 / 3.0) * PAX_WEIGHT(isImperial, userOptions);
|
||||
targetPayload->economy1Left = targetPayload->economy1Center = targetPayload->economy1Right =
|
||||
(targetPayload->paxCount.economy1 / 3.0) * PAX_WEIGHT(isImperial, userOptions);
|
||||
targetPayload->economy2Left = targetPayload->economy2Center = targetPayload->economy2Right =
|
||||
(targetPayload->paxCount.economy2 / 3.0) * PAX_WEIGHT(isImperial, userOptions);
|
||||
targetPayload->total = targetPayload->empty + targetPayload->pilot + targetPayload->firstOfficer + targetPayload->engineer +
|
||||
targetPayload->cabinCrewFront + targetPayload->business1Left + targetPayload->business1Center +
|
||||
targetPayload->business1Right + targetPayload->business2Left + targetPayload->business2Center +
|
||||
targetPayload->business2Right + targetPayload->economy1Left + targetPayload->economy1Center +
|
||||
targetPayload->economy1Right + targetPayload->economy2Left + targetPayload->economy2Center +
|
||||
targetPayload->economy2Right + targetPayload->cabinCrewRear + targetPayload->forwardCargo +
|
||||
targetPayload->rearCargo + targetPayload->leftAux + targetPayload->rightAux;
|
||||
}
|
||||
|
||||
// Normalise to Pounds
|
||||
// MANDATORY BEFORE SETTING WEIGHTS
|
||||
// USE ON COPY OF GLOBAL STATE ONLY
|
||||
void normalisePayload(paxPayloadData_t* const targetPayload, const bool isImperial) {
|
||||
targetPayload->empty = TO_POUNDS(isImperial, targetPayload->empty);
|
||||
targetPayload->pilot = TO_POUNDS(isImperial, targetPayload->pilot);
|
||||
targetPayload->firstOfficer = TO_POUNDS(isImperial, targetPayload->firstOfficer);
|
||||
targetPayload->engineer = TO_POUNDS(isImperial, targetPayload->engineer);
|
||||
targetPayload->cabinCrewFront = TO_POUNDS(isImperial, targetPayload->cabinCrewFront);
|
||||
targetPayload->business1Left = TO_POUNDS(isImperial, targetPayload->business1Left);
|
||||
targetPayload->business1Center = TO_POUNDS(isImperial, targetPayload->business1Center);
|
||||
targetPayload->business1Right = TO_POUNDS(isImperial, targetPayload->business1Right);
|
||||
targetPayload->business2Left = TO_POUNDS(isImperial, targetPayload->business2Left);
|
||||
targetPayload->business2Center = TO_POUNDS(isImperial, targetPayload->business2Center);
|
||||
targetPayload->business2Right = TO_POUNDS(isImperial, targetPayload->business2Right);
|
||||
targetPayload->economy1Left = TO_POUNDS(isImperial, targetPayload->economy1Left);
|
||||
targetPayload->economy1Center = TO_POUNDS(isImperial, targetPayload->economy1Center);
|
||||
targetPayload->economy1Right = TO_POUNDS(isImperial, targetPayload->economy1Right);
|
||||
targetPayload->economy2Left = TO_POUNDS(isImperial, targetPayload->economy2Left);
|
||||
targetPayload->economy2Center = TO_POUNDS(isImperial, targetPayload->economy2Center);
|
||||
targetPayload->economy2Right = TO_POUNDS(isImperial, targetPayload->economy2Right);
|
||||
targetPayload->cabinCrewRear = TO_POUNDS(isImperial, targetPayload->cabinCrewRear);
|
||||
targetPayload->forwardCargo = TO_POUNDS(isImperial, targetPayload->forwardCargo);
|
||||
targetPayload->rearCargo = TO_POUNDS(isImperial, targetPayload->rearCargo);
|
||||
targetPayload->leftAux = TO_POUNDS(isImperial, targetPayload->leftAux);
|
||||
targetPayload->rightAux = TO_POUNDS(isImperial, targetPayload->rightAux);
|
||||
void normalisePayload(paxPayloadData_t *const targetPayload, const bool isImperial) {
|
||||
targetPayload->empty = TO_POUNDS(isImperial, targetPayload->empty);
|
||||
targetPayload->pilot = TO_POUNDS(isImperial, targetPayload->pilot);
|
||||
targetPayload->firstOfficer = TO_POUNDS(isImperial, targetPayload->firstOfficer);
|
||||
targetPayload->engineer = TO_POUNDS(isImperial, targetPayload->engineer);
|
||||
targetPayload->cabinCrewFront = TO_POUNDS(isImperial, targetPayload->cabinCrewFront);
|
||||
targetPayload->business1Left = TO_POUNDS(isImperial, targetPayload->business1Left);
|
||||
targetPayload->business1Center = TO_POUNDS(isImperial, targetPayload->business1Center);
|
||||
targetPayload->business1Right = TO_POUNDS(isImperial, targetPayload->business1Right);
|
||||
targetPayload->business2Left = TO_POUNDS(isImperial, targetPayload->business2Left);
|
||||
targetPayload->business2Center = TO_POUNDS(isImperial, targetPayload->business2Center);
|
||||
targetPayload->business2Right = TO_POUNDS(isImperial, targetPayload->business2Right);
|
||||
targetPayload->economy1Left = TO_POUNDS(isImperial, targetPayload->economy1Left);
|
||||
targetPayload->economy1Center = TO_POUNDS(isImperial, targetPayload->economy1Center);
|
||||
targetPayload->economy1Right = TO_POUNDS(isImperial, targetPayload->economy1Right);
|
||||
targetPayload->economy2Left = TO_POUNDS(isImperial, targetPayload->economy2Left);
|
||||
targetPayload->economy2Center = TO_POUNDS(isImperial, targetPayload->economy2Center);
|
||||
targetPayload->economy2Right = TO_POUNDS(isImperial, targetPayload->economy2Right);
|
||||
targetPayload->cabinCrewRear = TO_POUNDS(isImperial, targetPayload->cabinCrewRear);
|
||||
targetPayload->forwardCargo = TO_POUNDS(isImperial, targetPayload->forwardCargo);
|
||||
targetPayload->rearCargo = TO_POUNDS(isImperial, targetPayload->rearCargo);
|
||||
targetPayload->leftAux = TO_POUNDS(isImperial, targetPayload->leftAux);
|
||||
targetPayload->rightAux = TO_POUNDS(isImperial, targetPayload->rightAux);
|
||||
}
|
||||
|
||||
void calculateCGs(const paxPayloadData_t* const targetPayload, const FuelData_t* const fuel, double* const ZFWCG, double* const TOCG, const bool isImperial) {
|
||||
paxPayloadData_t localPayload = {};
|
||||
memcpy(&localPayload, targetPayload, sizeof(localPayload));
|
||||
normalisePayload(&localPayload, isImperial);
|
||||
void calculateCGs(paxPayloadData_t *const targetPayload, const FuelData_t *const fuel, const bool isImperial) {
|
||||
paxPayloadData_t localPayload = {};
|
||||
memcpy(&localPayload, targetPayload, sizeof(localPayload));
|
||||
normalisePayload(&localPayload, isImperial);
|
||||
|
||||
double totalMoment = localPayload.empty * ARM_EMPTY + localPayload.pilot * ARM_PILOT + localPayload.firstOfficer * ARM_FIRST_OFFICER +
|
||||
localPayload.engineer * ARM_ENGINEER + localPayload.cabinCrewFront * ARM_PAX_CABIN_CREW_FRONT +
|
||||
localPayload.business1Left * ARM_PAX_BUSINESS1_LEFT + localPayload.business1Center * ARM_PAX_BUSINESS1_CENTER +
|
||||
localPayload.business1Right * ARM_PAX_BUSINESS1_RIGHT + localPayload.business2Left * ARM_PAX_BUSINESS2_LEFT +
|
||||
localPayload.business2Center * ARM_PAX_BUSINESS2_CENTER + localPayload.business2Right * ARM_PAX_BUSINESS2_RIGHT +
|
||||
localPayload.economy1Left * ARM_PAX_ECONOMY1_LEFT + localPayload.economy1Center * ARM_PAX_ECONOMY1_CENTER +
|
||||
localPayload.economy1Right * ARM_PAX_ECONOMY1_RIGHT + localPayload.economy2Left * ARM_PAX_ECONOMY2_LEFT +
|
||||
localPayload.economy2Center * ARM_PAX_ECONOMY2_CENTER + localPayload.economy2Right * ARM_PAX_ECONOMY2_RIGHT +
|
||||
localPayload.cabinCrewRear * ARM_PAX_CABIN_CREW_REAR + localPayload.forwardCargo * ARM_FORWARD_CARGO +
|
||||
localPayload.rearCargo * ARM_REAR_CARGO + localPayload.leftAux * ARM_LEFT_AUX + localPayload.rightAux * ARM_RIGHT_AUX;
|
||||
double totalMoment =
|
||||
localPayload.empty * ARM_EMPTY + localPayload.pilot * ARM_PILOT + localPayload.firstOfficer * ARM_FIRST_OFFICER +
|
||||
localPayload.engineer * ARM_ENGINEER + localPayload.cabinCrewFront * ARM_PAX_CABIN_CREW_FRONT +
|
||||
localPayload.business1Left * ARM_PAX_BUSINESS1_LEFT + localPayload.business1Center * ARM_PAX_BUSINESS1_CENTER +
|
||||
localPayload.business1Right * ARM_PAX_BUSINESS1_RIGHT + localPayload.business2Left * ARM_PAX_BUSINESS2_LEFT +
|
||||
localPayload.business2Center * ARM_PAX_BUSINESS2_CENTER + localPayload.business2Right * ARM_PAX_BUSINESS2_RIGHT +
|
||||
localPayload.economy1Left * ARM_PAX_ECONOMY1_LEFT + localPayload.economy1Center * ARM_PAX_ECONOMY1_CENTER +
|
||||
localPayload.economy1Right * ARM_PAX_ECONOMY1_RIGHT + localPayload.economy2Left * ARM_PAX_ECONOMY2_LEFT +
|
||||
localPayload.economy2Center * ARM_PAX_ECONOMY2_CENTER + localPayload.economy2Right * ARM_PAX_ECONOMY2_RIGHT +
|
||||
localPayload.cabinCrewRear * ARM_PAX_CABIN_CREW_REAR + localPayload.forwardCargo * ARM_FORWARD_CARGO +
|
||||
localPayload.rearCargo * ARM_REAR_CARGO + localPayload.leftAux * ARM_LEFT_AUX + localPayload.rightAux * ARM_RIGHT_AUX;
|
||||
|
||||
double totalWeight = localPayload.empty + localPayload.pilot + localPayload.firstOfficer + localPayload.engineer + localPayload.cabinCrewFront +
|
||||
localPayload.business1Left + localPayload.business1Center + localPayload.business1Right + localPayload.business2Left +
|
||||
localPayload.business2Center + localPayload.business2Right + localPayload.economy1Left + localPayload.economy1Center +
|
||||
localPayload.economy1Right + localPayload.economy2Left + localPayload.economy2Center + localPayload.economy2Right +
|
||||
localPayload.cabinCrewRear + localPayload.forwardCargo + localPayload.rearCargo + localPayload.leftAux + localPayload.rightAux;
|
||||
double totalWeight = localPayload.empty + localPayload.pilot + localPayload.firstOfficer + localPayload.engineer +
|
||||
localPayload.cabinCrewFront + localPayload.business1Left + localPayload.business1Center +
|
||||
localPayload.business1Right + localPayload.business2Left + localPayload.business2Center +
|
||||
localPayload.business2Right + localPayload.economy1Left + localPayload.economy1Center +
|
||||
localPayload.economy1Right + localPayload.economy2Left + localPayload.economy2Center +
|
||||
localPayload.economy2Right + localPayload.cabinCrewRear + localPayload.forwardCargo +
|
||||
localPayload.rearCargo + localPayload.leftAux + localPayload.rightAux;
|
||||
|
||||
*ZFWCG = TO_PERCENT_MAC(totalMoment / totalWeight);
|
||||
targetPayload->ZFWCG = TO_PERCENT_MAC(totalMoment / totalWeight);
|
||||
|
||||
totalMoment += fuel->main1 * ARM_MAIN1 + fuel->main3 * ARM_MAIN3 + fuel->main2 * ARM_MAIN2 + fuel->upperAux * ARM_UPPER_AUX +
|
||||
fuel->lowerAux * ARM_LOWER_AUX + fuel->main1Tip * ARM_MAIN1_TIP + fuel->main3Tip * ARM_MAIN3_TIP +
|
||||
fuel->tail * ARM_TAIL + fuel->forwardAux1 * ARM_FORWARD_AUX1 + fuel->forwardAux2 * ARM_FORWARD_AUX2;
|
||||
totalMoment += fuel->main1 * ARM_MAIN1 + fuel->main3 * ARM_MAIN3 + fuel->main2 * ARM_MAIN2 + fuel->upperAux * ARM_UPPER_AUX +
|
||||
fuel->lowerAux * ARM_LOWER_AUX + fuel->main1Tip * ARM_MAIN1_TIP + fuel->main3Tip * ARM_MAIN3_TIP +
|
||||
fuel->tail * ARM_TAIL + fuel->forwardAux1 * ARM_FORWARD_AUX1 + fuel->forwardAux2 * ARM_FORWARD_AUX2;
|
||||
|
||||
totalWeight += fuel->total;
|
||||
totalWeight += fuel->total;
|
||||
|
||||
*TOCG = TO_PERCENT_MAC(totalMoment / totalWeight);
|
||||
targetPayload->TOCG = TO_PERCENT_MAC(totalMoment / totalWeight);
|
||||
}
|
||||
|
||||
void load(const paxPayloadData_t* const targetPayload, const HANDLE simConnect, const bool isImperial) {
|
||||
paxPayloadData_t localPayload = {};
|
||||
memcpy(&localPayload, targetPayload, sizeof(localPayload));
|
||||
normalisePayload(&localPayload, isImperial);
|
||||
void load(const paxPayloadData_t *const targetPayload, const HANDLE simConnect, const bool isImperial) {
|
||||
paxPayloadData_t localPayload = {};
|
||||
memcpy(&localPayload, targetPayload, sizeof(localPayload));
|
||||
normalisePayload(&localPayload, isImperial);
|
||||
|
||||
SimConnect_SetDataOnSimObject(simConnect, DATA_DEFINITION_PAYLOAD_PAX, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(paxPayloadDataSet_t), &localPayload);
|
||||
localPayload._ZFWCG = localPayload.ZFWCG / 100.0;
|
||||
|
||||
SimConnect_SetDataOnSimObject(simConnect, DATA_DEFINITION_PAYLOAD_PAX, SIMCONNECT_OBJECT_ID_USER, 0, 0,
|
||||
sizeof(paxPayloadDataSet_t), &localPayload);
|
||||
}
|
||||
|
||||
void unload(const HANDLE simConnect, const bool isER) {
|
||||
paxPayloadDataSet_t localPayload = {};
|
||||
paxPayloadData_t localPayload = {};
|
||||
|
||||
localPayload.cabinCrewFront = FRONT_CREW_WEIGHT(true);
|
||||
localPayload.cabinCrewRear = REAR_CREW_WEIGHT(true);
|
||||
localPayload.leftAux = localPayload.rightAux = isER ? AUX_WEIGHT(true) : 0;
|
||||
localPayload.pilot = localPayload.firstOfficer = localPayload.engineer = PILOT_WEIGHT(true);
|
||||
localPayload.cabinCrewFront = FRONT_CREW_WEIGHT(true);
|
||||
localPayload.cabinCrewRear = REAR_CREW_WEIGHT(true);
|
||||
localPayload.leftAux = localPayload.rightAux = isER ? AUX_WEIGHT(true) : 0;
|
||||
localPayload.pilot = localPayload.firstOfficer = localPayload.engineer = PILOT_WEIGHT(true);
|
||||
|
||||
SimConnect_SetDataOnSimObject(simConnect, DATA_DEFINITION_PAYLOAD_PAX, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(paxPayloadDataSet_t), &localPayload);
|
||||
localPayload._ZFWCG = -1;
|
||||
|
||||
SimConnect_SetDataOnSimObject(simConnect, DATA_DEFINITION_PAYLOAD_PAX, SIMCONNECT_OBJECT_ID_USER, 0, 0,
|
||||
sizeof(paxPayloadDataSet_t), &localPayload);
|
||||
}
|
||||
|
||||
const double PAX_WEIGHT(const bool isImperial, const UserOptions_t* const options) {
|
||||
return (isImperial) ? (options->paxWeightLBS) : (options->paxWeightKG);
|
||||
const double PAX_WEIGHT(const bool isImperial, const UserOptions_t *const options) {
|
||||
return (isImperial) ? (options->paxWeightLBS) : (options->paxWeightKG);
|
||||
}
|
||||
|
||||
const double BAG_WEIGHT(const bool isImperial, const UserOptions_t* const options) {
|
||||
return (isImperial) ? (options->bagWeightLBS) : (options->bagWeightKG);
|
||||
const double BAG_WEIGHT(const bool isImperial, const UserOptions_t *const options) {
|
||||
return (isImperial) ? (options->bagWeightLBS) : (options->bagWeightKG);
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __INTELLISENSE__
|
||||
# define MODULE_EXPORT __attribute__( ( visibility( "default" ) ) )
|
||||
# define MODULE_WASM_MODNAME(mod) __attribute__((import_module(mod)))
|
||||
#define MODULE_EXPORT __attribute__((visibility("default")))
|
||||
#define MODULE_WASM_MODNAME(mod) __attribute__((import_module(mod)))
|
||||
#else
|
||||
# define MODULE_EXPORT
|
||||
# define MODULE_WASM_MODNAME(mod)
|
||||
# define __attribute__(x)
|
||||
# define __restrict__
|
||||
#define MODULE_EXPORT
|
||||
#define MODULE_WASM_MODNAME(mod)
|
||||
#define __attribute__(x)
|
||||
#define __restrict__
|
||||
#endif
|
||||
|
||||
/********************************* Headers *********************************/
|
||||
@@ -19,6 +19,7 @@
|
||||
// C++ headers
|
||||
#include <algorithm>
|
||||
// Own headers
|
||||
#include "fuel.h"
|
||||
#include "shared.h"
|
||||
|
||||
/******************************** Constants ********************************/
|
||||
@@ -59,92 +60,95 @@
|
||||
|
||||
/***************************** Data structures *****************************/
|
||||
typedef struct {
|
||||
// SimConnect mapped
|
||||
double pilot;
|
||||
double firstOfficer;
|
||||
double engineer;
|
||||
double cabinCrewFront;
|
||||
double business1Left;
|
||||
double business1Center;
|
||||
double business1Right;
|
||||
double business2Left;
|
||||
double business2Center;
|
||||
double business2Right;
|
||||
double economy1Left;
|
||||
double economy1Center;
|
||||
double economy1Right;
|
||||
double economy2Left;
|
||||
double economy2Center;
|
||||
double economy2Right;
|
||||
double cabinCrewRear;
|
||||
double forwardCargo;
|
||||
double rearCargo;
|
||||
double leftAux;
|
||||
double rightAux;
|
||||
// SimConnect mapped
|
||||
double pilot;
|
||||
double firstOfficer;
|
||||
double engineer;
|
||||
double cabinCrewFront;
|
||||
double business1Left;
|
||||
double business1Center;
|
||||
double business1Right;
|
||||
double business2Left;
|
||||
double business2Center;
|
||||
double business2Right;
|
||||
double economy1Left;
|
||||
double economy1Center;
|
||||
double economy1Right;
|
||||
double economy2Left;
|
||||
double economy2Center;
|
||||
double economy2Right;
|
||||
double cabinCrewRear;
|
||||
double forwardCargo;
|
||||
double rearCargo;
|
||||
double leftAux;
|
||||
double rightAux;
|
||||
double _ZFWCG; // DO NOT USE
|
||||
|
||||
// Additional properties
|
||||
double empty;
|
||||
double total;
|
||||
double CGTarget;
|
||||
double ZFWCG;
|
||||
double TOCG;
|
||||
struct paxCount {
|
||||
unsigned char business1;
|
||||
unsigned char business2;
|
||||
unsigned char economy1;
|
||||
unsigned char economy2;
|
||||
unsigned short total;
|
||||
} paxCount;
|
||||
struct sbPlanned {
|
||||
double ZFW;
|
||||
double GW;
|
||||
unsigned short pax;
|
||||
unsigned int cargo;
|
||||
} sbPlanned;
|
||||
// Additional properties
|
||||
double empty;
|
||||
double total;
|
||||
double CGTarget;
|
||||
double ZFWCG;
|
||||
double TOCG;
|
||||
struct paxCount {
|
||||
unsigned char business1;
|
||||
unsigned char business2;
|
||||
unsigned char economy1;
|
||||
unsigned char economy2;
|
||||
unsigned short total;
|
||||
} paxCount;
|
||||
struct sbPlanned {
|
||||
double ZFW;
|
||||
double GW;
|
||||
double fuel;
|
||||
unsigned short pax;
|
||||
unsigned int cargo;
|
||||
} sbPlanned;
|
||||
} paxPayloadData_t;
|
||||
|
||||
typedef struct {
|
||||
double pilot;
|
||||
double firstOfficer;
|
||||
double engineer;
|
||||
double cabinCrewFront;
|
||||
double business1Left;
|
||||
double business1Center;
|
||||
double business1Right;
|
||||
double business2Left;
|
||||
double business2Center;
|
||||
double business2Right;
|
||||
double economy1Left;
|
||||
double economy1Center;
|
||||
double economy1Right;
|
||||
double economy2Left;
|
||||
double economy2Center;
|
||||
double economy2Right;
|
||||
double cabinCrewRear;
|
||||
double forwardCargo;
|
||||
double rearCargo;
|
||||
double leftAux;
|
||||
double rightAux;
|
||||
double pilot;
|
||||
double firstOfficer;
|
||||
double engineer;
|
||||
double cabinCrewFront;
|
||||
double business1Left;
|
||||
double business1Center;
|
||||
double business1Right;
|
||||
double business2Left;
|
||||
double business2Center;
|
||||
double business2Right;
|
||||
double economy1Left;
|
||||
double economy1Center;
|
||||
double economy1Right;
|
||||
double economy2Left;
|
||||
double economy2Center;
|
||||
double economy2Right;
|
||||
double cabinCrewRear;
|
||||
double forwardCargo;
|
||||
double rearCargo;
|
||||
double leftAux;
|
||||
double rightAux;
|
||||
double ZFWCG;
|
||||
} paxPayloadDataSet_t;
|
||||
|
||||
/******************************** Functions ********************************/
|
||||
//ZFW Entry, fill pax first (pax+bag), rest is cargo
|
||||
void distribute(paxPayloadData_t* const targetPayload, const FuelData_t* const fuel, const double ZFWTarget, const UserData_t* const userData,
|
||||
const UserOptions_t* const userOptions);
|
||||
//SimBrief Entry, SB pax count and total cargo
|
||||
void distribute(paxPayloadData_t* const targetPayload, const FuelData_t* const fuel, unsigned short numPax, unsigned int cargo, const UserData_t* const userData,
|
||||
const UserOptions_t* const userOptions);
|
||||
// ZFW Entry, fill pax first (pax+bag), rest is cargo
|
||||
void distribute(paxPayloadData_t *const targetPayload, const FuelData_t *const fuel, const double ZFWTarget,
|
||||
const UserData_t *const userData, const UserOptions_t *const userOptions);
|
||||
// SimBrief Entry, SB pax count and total cargo
|
||||
void distribute(paxPayloadData_t *const targetPayload, const FuelData_t *const fuel, unsigned short numPax, unsigned int cargo,
|
||||
const UserData_t *const userData, const UserOptions_t *const userOptions);
|
||||
// Updates pax stations with their respective weights
|
||||
// Used internally and used for Station Entry (pax only, cargo is ste directly)
|
||||
// STATION WEIGHTS ARE NOT NORMALISED TO POUNDS
|
||||
void generatePayload(paxPayloadData_t* const targetPayload, const bool isImperial, const UserOptions_t* const userOptions);
|
||||
void generatePayload(paxPayloadData_t *const targetPayload, const bool isImperial, const UserOptions_t *const userOptions);
|
||||
// Normalise to Pounds
|
||||
// For Station Entry: CALL AFTER `generatePayload`
|
||||
void normalisePayload(paxPayloadData_t* const targetPayload, const bool isImperial);
|
||||
void calculateCGs(const paxPayloadData_t* const targetPayload, const FuelData_t* const fuel, double* const ZFWCG, double* const TOCG, const bool isImperial);
|
||||
void load(const paxPayloadData_t* const targetPayload, const HANDLE simConnect, const bool isImperial);
|
||||
void normalisePayload(paxPayloadData_t *const targetPayload, const bool isImperial);
|
||||
void calculateCGs(paxPayloadData_t *const targetPayload, const FuelData_t *const fuel, const bool isImperial);
|
||||
void load(const paxPayloadData_t *const targetPayload, const HANDLE simConnect, const bool isImperial);
|
||||
void unload(const HANDLE simConnect, const bool isER);
|
||||
// Based on ICAO/LH findings
|
||||
const double PAX_WEIGHT(const bool isImperial, const UserOptions_t* const options);
|
||||
const double PAX_WEIGHT(const bool isImperial, const UserOptions_t *const options);
|
||||
// Based on ICAO/LH findings
|
||||
const double BAG_WEIGHT(const bool isImperial, const UserOptions_t* const options);
|
||||
const double BAG_WEIGHT(const bool isImperial, const UserOptions_t *const options);
|
||||
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __INTELLISENSE__
|
||||
# define MODULE_EXPORT __attribute__( ( visibility( "default" ) ) )
|
||||
# define MODULE_WASM_MODNAME(mod) __attribute__((import_module(mod)))
|
||||
#define MODULE_EXPORT __attribute__((visibility("default")))
|
||||
#define MODULE_WASM_MODNAME(mod) __attribute__((import_module(mod)))
|
||||
#else
|
||||
# define MODULE_EXPORT
|
||||
# define MODULE_WASM_MODNAME(mod)
|
||||
# define __attribute__(x)
|
||||
# define __restrict__
|
||||
#define MODULE_EXPORT
|
||||
#define MODULE_WASM_MODNAME(mod)
|
||||
#define __attribute__(x)
|
||||
#define __restrict__
|
||||
#endif
|
||||
|
||||
/******************************** Constants ********************************/
|
||||
@@ -15,16 +15,13 @@
|
||||
#define PILOT_WEIGHT(IS_IMPERIAL) ((IS_IMPERIAL) ? (190.0) : (86.0))
|
||||
// 200lbs per tank (one LD3)
|
||||
#define AUX_WEIGHT(IS_IMPERIAL) ((IS_IMPERIAL) ? (200.0) : (91.0))
|
||||
//PMC pallet due to 104in door
|
||||
// PMC pallet due to 104in door
|
||||
#define MAX_FRONT_CARGO(IS_IMPERIAL) ((IS_IMPERIAL) ? (6.0 * 15000.0) : (6.0 * 6804.0))
|
||||
//LD3s due to 70in door, ER option takes up two slots
|
||||
// LD3s due to 70in door, ER option takes up two slots
|
||||
#define MAX_REAR_CARGO(IS_IMPERIAL, IS_ER) ((IS_IMPERIAL) ? ((IS_ER ? 12.0 : 14.0) * 3500.0) : ((IS_ER ? 12.0 : 14.0) * 1588.0))
|
||||
// Max TOW
|
||||
#define MAX_TOW(IS_IMPERIAL) ((IS_IMPERIAL) ? (625500) : (283722))
|
||||
#define MAX_TOW_ER(IS_IMPERIAL) ((IS_IMPERIAL) ? (630500) : (285990))
|
||||
// Max Fuel
|
||||
#define MAX_FUEL(IS_IMPERIAL) ((IS_IMPERIAL) ? (256207) : (116213))
|
||||
#define MAX_FUEL_ER(IS_IMPERIAL) ((IS_IMPERIAL) ? (282619) : (128193))
|
||||
// Arms Shared
|
||||
#define ARM_EMPTY -120.0
|
||||
#define ARM_PILOT 984.0
|
||||
@@ -34,22 +31,11 @@
|
||||
#define ARM_REAR_CARGO -360.0
|
||||
#define ARM_LEFT_AUX 60.0
|
||||
#define ARM_RIGHT_AUX 60.0
|
||||
// Arms Fuel
|
||||
#define ARM_MAIN1 -240.0
|
||||
#define ARM_MAIN3 -240.0
|
||||
#define ARM_MAIN2 120.0
|
||||
#define ARM_UPPER_AUX 0.0
|
||||
#define ARM_LOWER_AUX 0.0
|
||||
#define ARM_MAIN1_TIP -468.0
|
||||
#define ARM_MAIN3_TIP -468.0
|
||||
#define ARM_TAIL -840.0
|
||||
#define ARM_FORWARD_AUX1 60.0
|
||||
#define ARM_FORWARD_AUX2 60.0
|
||||
// MAC
|
||||
#define ROOT_CHORD 34.68
|
||||
#define WING_SPAN 170.5
|
||||
#define WING_AREA 3648.0
|
||||
#define QUARTER_MAC -165.0 //aero_center
|
||||
#define QUARTER_MAC -165.0 // aero_center
|
||||
#define TIP_CHORD ((2.0 * WING_AREA) / WING_SPAN - ROOT_CHORD)
|
||||
#define TAPER_RATIO (TIP_CHORD / ROOT_CHORD)
|
||||
#define MAC ((2.0 / 3.0) * ROOT_CHORD * ((1.0 + TAPER_RATIO + (TAPER_RATIO * TAPER_RATIO)) / (1.0 + TAPER_RATIO)) * 12.0)
|
||||
@@ -64,91 +50,75 @@
|
||||
|
||||
/********************************* Macros **********************************/
|
||||
// Conversions
|
||||
#define TO_POUNDS(IS_IMPERIAL, VALUE) ((IS_IMPERIAL) ? (VALUE) : (VALUE) * 2.20462262185)
|
||||
#define TO_POUNDS(IS_IMPERIAL, VALUE) ((IS_IMPERIAL) ? (VALUE) : (VALUE)*2.20462262185)
|
||||
#define FROM_POUNDS(IS_IMPERIAL, VALUE) ((IS_IMPERIAL) ? (VALUE) : (VALUE) * (1.0 / 2.20462262185))
|
||||
// MAC
|
||||
#define TO_PERCENT_MAC(POS) ((((POS) - LEMAC) / MAC) * -100.0)
|
||||
#define TO_PERCENT_MAC(POS) ((((POS)-LEMAC) / MAC) * -100.0)
|
||||
|
||||
/********************************** ENUMS **********************************/
|
||||
enum DATA_DEFINITIONS {
|
||||
DATA_DEFINITION_EMPTY_WEIGHT,
|
||||
DATA_DEFINITION_PAYLOAD_PAX,
|
||||
DATA_DEFINITION_PAYLOAD_F,
|
||||
DATA_DEFINITION_FUEL,
|
||||
DATA_DEFINITION_GSX,
|
||||
DATA_DEFINITION_USER_DATA,
|
||||
DATA_DEFINITION_EMPTY_WEIGHT,
|
||||
DATA_DEFINITION_PAYLOAD_PAX,
|
||||
DATA_DEFINITION_PAYLOAD_F,
|
||||
DATA_DEFINITION_FUEL,
|
||||
DATA_DEFINITION_FUEL_SET,
|
||||
DATA_DEFINITION_GSX,
|
||||
DATA_DEFINITION_USER_DATA,
|
||||
};
|
||||
|
||||
enum DATA_REQUESTS {
|
||||
DATA_REQUEST_EMPTY_WEIGHT,
|
||||
DATA_REQUEST_PAYLOAD_PAX,
|
||||
DATA_REQUEST_PAYLOAD_F,
|
||||
DATA_REQUEST_FUEL,
|
||||
DATA_REQUEST_GSX,
|
||||
DATA_REQUEST_USER_DATA,
|
||||
DATA_REQUEST_EMPTY_WEIGHT,
|
||||
DATA_REQUEST_PAYLOAD_PAX,
|
||||
DATA_REQUEST_PAYLOAD_F,
|
||||
DATA_REQUEST_FUEL,
|
||||
DATA_REQUEST_FUEL_SET,
|
||||
DATA_REQUEST_GSX,
|
||||
DATA_REQUEST_USER_DATA,
|
||||
};
|
||||
|
||||
enum LOADING_STATES {
|
||||
LOADING_STATE_IDLE,
|
||||
LOADING_STATE_BOARDING,
|
||||
LOADING_STATE_BOARDED,
|
||||
LOADING_STATE_DEBOARDING,
|
||||
LOADING_STATE_DEBOARDED,
|
||||
LOADING_STATE_IDLE,
|
||||
LOADING_STATE_BOARDING,
|
||||
LOADING_STATE_BOARDED,
|
||||
LOADING_STATE_DEBOARDING,
|
||||
LOADING_STATE_DEBOARDED,
|
||||
};
|
||||
|
||||
enum CALL_MODES {
|
||||
CALL_MODE_SB_SET,
|
||||
CALL_MODE_ZFW_SET,
|
||||
CALL_MODE_STATION_SET,
|
||||
CALL_MODE_LOAD_SET,
|
||||
CALL_MODE_UNLOAD_SET,
|
||||
CALL_MODE_OPTIONS_SET,
|
||||
CALL_MODE_GSX_RESET,
|
||||
CALL_MODE_SB_SET,
|
||||
CALL_MODE_ZFW_SET,
|
||||
CALL_MODE_STATION_SET,
|
||||
CALL_MODE_LOAD_SET,
|
||||
CALL_MODE_UNLOAD_SET,
|
||||
CALL_MODE_OPTIONS_SET,
|
||||
CALL_MODE_GSX_RESET,
|
||||
};
|
||||
|
||||
/***************************** Data structures *****************************/
|
||||
typedef struct {
|
||||
double isCargo;
|
||||
double isER;
|
||||
double isImperial;
|
||||
double isCargo;
|
||||
double isER;
|
||||
double isImperial;
|
||||
} UserData_t;
|
||||
|
||||
typedef struct {
|
||||
// SimConnect mapped
|
||||
double couatlStarted; // boolean
|
||||
double boardingState; // See manual, 5 => active
|
||||
double deboardingState; // See manual, 5 => active
|
||||
double passengersBoarded; // Num pax
|
||||
double passengersDeboarded; // Num pax
|
||||
double cargoBoarded; // In percent
|
||||
double cargoDeboarded; // In percent
|
||||
// SimConnect mapped
|
||||
double couatlStarted; // boolean
|
||||
double boardingState; // See manual, 5 => active
|
||||
double deboardingState; // See manual, 5 => active
|
||||
double passengersBoarded; // Num pax
|
||||
double passengersDeboarded; // Num pax
|
||||
double cargoBoarded; // In percent
|
||||
double cargoDeboarded; // In percent
|
||||
|
||||
// Additional properties
|
||||
enum LOADING_STATES loadingState;
|
||||
// Additional properties
|
||||
enum LOADING_STATES loadingState;
|
||||
} GSXData_t;
|
||||
|
||||
typedef struct {
|
||||
// SimConnect mapped
|
||||
double poundsPerGallon; // DO NOT USE
|
||||
double main1;
|
||||
double main3;
|
||||
double main2;
|
||||
double upperAux;
|
||||
double lowerAux;
|
||||
double main1Tip;
|
||||
double main3Tip;
|
||||
double tail;
|
||||
double forwardAux1;
|
||||
double forwardAux2;
|
||||
|
||||
// Additional properties
|
||||
double total;
|
||||
} FuelData_t;
|
||||
|
||||
typedef struct {
|
||||
bool GSXSync;
|
||||
double paxWeightKG;
|
||||
double bagWeightKG;
|
||||
double paxWeightLBS;
|
||||
double bagWeightLBS;
|
||||
bool GSXSync;
|
||||
double paxWeightKG;
|
||||
double bagWeightKG;
|
||||
double paxWeightLBS;
|
||||
double bagWeightLBS;
|
||||
} UserOptions_t;
|
||||
Reference in New Issue
Block a user