Pax Station Entry
This commit is contained in:
@@ -35,7 +35,7 @@ extern "C" MSFS_CALLBACK void module_init(void) {
|
||||
targetFPayloadData = new fPayloadData_t();
|
||||
liveFuelData = new FuelData_t();
|
||||
|
||||
targetFPayloadData->ZFWCG = targetPaxPayloadData->ZFWCG = 21;
|
||||
targetFPayloadData->CGTarget = targetPaxPayloadData->CGTarget = 21;
|
||||
|
||||
#pragma region SimConnect
|
||||
|
||||
@@ -454,13 +454,14 @@ int receiveData(const char* buf) {
|
||||
double CGTarget = document["CGTarget"].GetDouble();
|
||||
|
||||
if (UserData->isCargo) {
|
||||
|
||||
targetPaxPayloadData->CGTarget = CGTarget;
|
||||
}
|
||||
else {
|
||||
if (!document.HasMember("numPax")) return -1;
|
||||
unsigned short numPax = document["numPax"].GetInt();
|
||||
|
||||
distribute(targetPaxPayloadData, liveFuelData, numPax, cargo, CGTarget, UserData->isImperial);
|
||||
targetPaxPayloadData->CGTarget = CGTarget;
|
||||
distribute(targetPaxPayloadData, liveFuelData, numPax, cargo, UserData->isImperial);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -471,10 +472,11 @@ int receiveData(const char* buf) {
|
||||
double CGTarget = document["CGTarget"].GetDouble();
|
||||
|
||||
if (UserData->isCargo) {
|
||||
|
||||
targetPaxPayloadData->CGTarget = CGTarget;
|
||||
}
|
||||
else {
|
||||
distribute(targetPaxPayloadData, liveFuelData, ZFWTarget, CGTarget, UserData->isImperial);
|
||||
targetPaxPayloadData->CGTarget = CGTarget;
|
||||
distribute(targetPaxPayloadData, liveFuelData, ZFWTarget, UserData->isImperial);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -495,7 +497,6 @@ int receiveData(const char* buf) {
|
||||
targetPaxPayloadData->rearCargo = document["rearCargo"].GetDouble();
|
||||
|
||||
generatePayload(targetPaxPayloadData, UserData->isImperial);
|
||||
normalisePayload(targetPaxPayloadData, UserData->isImperial);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -557,8 +558,8 @@ void sendData () {
|
||||
// CGs
|
||||
//TODO: Enable for F
|
||||
//calculateCGs(liveFPayloadData, liveFuelData, &liveFPayloadData->ZFWCG, &liveFPayloadData->TOCG, true);
|
||||
targetPayload.AddMember("ZFWCG", liveFPayloadData->ZFWCG, allocator);
|
||||
targetPayload.AddMember("TOCG", liveFPayloadData->TOCG, allocator);
|
||||
livePayload.AddMember("ZFWCG", liveFPayloadData->ZFWCG, allocator);
|
||||
livePayload.AddMember("TOCG", liveFPayloadData->TOCG, allocator);
|
||||
}
|
||||
// Pax only (converted to passengers)
|
||||
else {
|
||||
@@ -613,6 +614,7 @@ void sendData () {
|
||||
targetPayload.AddMember("lowerForward", targetFPayloadData->lowerForward, allocator);
|
||||
targetPayload.AddMember("lowerRear", targetFPayloadData->lowerRear, allocator);
|
||||
targetPayload.AddMember("total", targetFPayloadData->total, allocator);
|
||||
targetPayload.AddMember("CGTarget", targetFPayloadData->CGTarget, allocator);
|
||||
// CGs
|
||||
//TODO: Enable for F
|
||||
//calculateCGs(targetFPayloadData, liveFuelData, &targetFPayloadData->ZFWCG, &targetFPayloadData->TOCG, UserData->isImperial);
|
||||
@@ -632,6 +634,7 @@ void sendData () {
|
||||
targetPayload.AddMember("forwardCargo", targetPaxPayloadData->forwardCargo, allocator);
|
||||
targetPayload.AddMember("rearCargo", targetPaxPayloadData->rearCargo, allocator);
|
||||
targetPayload.AddMember("total", targetPaxPayloadData->total, allocator);
|
||||
targetPayload.AddMember("CGTarget", targetPaxPayloadData->CGTarget, allocator);
|
||||
// CGs
|
||||
calculateCGs(targetPaxPayloadData, liveFuelData, &targetPaxPayloadData->ZFWCG, &targetPaxPayloadData->TOCG, UserData->isImperial);
|
||||
targetPayload.AddMember("ZFWCG", targetPaxPayloadData->ZFWCG, allocator);
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
#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 double CGTarget, const bool isImperial) {
|
||||
void distribute(paxPayloadData_t* const targetPayload, const FuelData_t* const fuel, const double ZFWTarget, const bool isImperial) {
|
||||
// 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 = std::max(0.0, std::min((double)MAX_PAX, floor(payload / (PAX_WEIGHT(isImperial) + BAG_WEIGHT(isImperial)))));
|
||||
unsigned int cargo = round(payload - numPax * PAX_WEIGHT(isImperial) - numPax * BAG_WEIGHT(isImperial));
|
||||
|
||||
distribute(targetPayload, fuel, numPax, cargo, CGTarget, isImperial);
|
||||
distribute(targetPayload, fuel, numPax, cargo, isImperial);
|
||||
}
|
||||
|
||||
//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 double CGTarget, const bool isImperial) {
|
||||
void distribute(paxPayloadData_t* const targetPayload, const FuelData_t* const fuel, unsigned short numPax, unsigned int cargo, const bool isImperial) {
|
||||
// Clear
|
||||
targetPayload->paxCount.business1 = targetPayload->paxCount.business2 = targetPayload->paxCount.economy1 = targetPayload->paxCount.economy2 =
|
||||
targetPayload->paxCount.total = 0;
|
||||
@@ -108,7 +108,7 @@ void distribute(paxPayloadData_t* const targetPayload, const FuelData_t* const f
|
||||
calculateCGs(targetPayload, fuel, &targetPayload->ZFWCG, &targetPayload->TOCG, isImperial);
|
||||
|
||||
// in front of target
|
||||
if (targetPayload->ZFWCG < CGTarget - CG_TOLERANCE) {
|
||||
if (targetPayload->ZFWCG < targetPayload->CGTarget - CG_TOLERANCE) {
|
||||
if (targetPayload->paxCount.business1 > 0) {
|
||||
targetPayload->paxCount.business1--;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ void distribute(paxPayloadData_t* const targetPayload, const FuelData_t* const f
|
||||
}
|
||||
}
|
||||
// behind target
|
||||
else if (targetPayload->ZFWCG > CGTarget + CG_TOLERANCE) {
|
||||
else if (targetPayload->ZFWCG > targetPayload->CGTarget + CG_TOLERANCE) {
|
||||
if (targetPayload->paxCount.economy2 > 0) {
|
||||
targetPayload->paxCount.economy2--;
|
||||
}
|
||||
@@ -176,7 +176,7 @@ void distribute(paxPayloadData_t* const targetPayload, const FuelData_t* const f
|
||||
calculateCGs(targetPayload, fuel, &targetPayload->ZFWCG, &targetPayload->TOCG, isImperial);
|
||||
|
||||
// in front of target
|
||||
if (targetPayload->ZFWCG < CGTarget - CG_TOLERANCE) {
|
||||
if (targetPayload->ZFWCG < targetPayload->CGTarget - CG_TOLERANCE) {
|
||||
if (targetPayload->forwardCargo > 0 && targetPayload->rearCargo < MAX_REAR_CARGO(isImperial)) {
|
||||
if (targetPayload->forwardCargo > BAG_WEIGHT(isImperial) &&
|
||||
targetPayload->rearCargo < MAX_FRONT_CARGO(isImperial) - BAG_WEIGHT(isImperial)) {
|
||||
@@ -193,7 +193,7 @@ void distribute(paxPayloadData_t* const targetPayload, const FuelData_t* const f
|
||||
}
|
||||
}
|
||||
// behind target
|
||||
else if (targetPayload->ZFWCG > CGTarget + CG_TOLERANCE) {
|
||||
else if (targetPayload->ZFWCG > targetPayload->CGTarget + CG_TOLERANCE) {
|
||||
if (targetPayload->rearCargo > 0 && targetPayload->forwardCargo < MAX_FRONT_CARGO(isImperial)) {
|
||||
if (targetPayload->rearCargo > BAG_WEIGHT(isImperial) &&
|
||||
targetPayload->forwardCargo < MAX_REAR_CARGO(isImperial) - BAG_WEIGHT(isImperial)) {
|
||||
@@ -233,7 +233,7 @@ void generatePayload(paxPayloadData_t* const targetPayload, const bool isImperia
|
||||
|
||||
// Normalise to Pounds
|
||||
// MANDATORY BEFORE SETTING WEIGHTS
|
||||
// ENSURE ONLY EVER CALLED ONCE PER SET CYCLE
|
||||
// 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);
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
#include "types.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 double CGTarget, bool isImperial);
|
||||
void distribute(paxPayloadData_t* const targetPayload, const FuelData_t* const fuel, const double ZFWTarget, bool isImperial);
|
||||
//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 double CGTarget, bool isImperial);
|
||||
void distribute(paxPayloadData_t* const targetPayload, const FuelData_t* const fuel, unsigned short numPax, unsigned int cargo, bool isImperial);
|
||||
// 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
|
||||
|
||||
@@ -144,6 +144,7 @@ typedef struct {
|
||||
// Additional properties
|
||||
double empty;
|
||||
double total;
|
||||
double CGTarget;
|
||||
double ZFWCG;
|
||||
double TOCG;
|
||||
struct paxCount {
|
||||
@@ -176,6 +177,7 @@ typedef struct {
|
||||
// Additional properties
|
||||
double empty;
|
||||
double total;
|
||||
double CGTarget;
|
||||
double ZFWCG;
|
||||
double TOCG;
|
||||
} fPayloadData_t;
|
||||
|
||||
Reference in New Issue
Block a user