Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions include/can/Rocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ class Rocket : public Channel, public NonNodeChannel
void SetMinimumOxPressure(std::vector<double> &params, bool testOnly);
void GetMinimumOxPressure(std::vector<double> &params, bool testOnly);

void SetMaximumTankPressure(std::vector<double> &params, bool testOnly);

void SetGSEConnectionAbortEnable(std::vector<double> &params, bool testOnly);
void GetGSEConnectionAbortTimer(std::vector<double> &params, bool testOnly);

void GetGSEConnectionAbortEnable(std::vector<double> &params, bool testOnly);

void GetMaximumTankPressure(std::vector<double> &params, bool testOnly);

void SetHolddownTimeout(std::vector<double> &params, bool testOnly);
void GetHolddownTimeout(std::vector<double> &params, bool testOnly);

Expand All @@ -62,6 +71,8 @@ class Rocket : public Channel, public NonNodeChannel
void RequestStatus(std::vector<double> &params, bool testOnly) override;
void RequestResetSettings(std::vector<double> &params, bool testOnly) override;



//-------------------------------Utility Functions-------------------------------//

void RequestCurrentState() override;
Expand Down
2 changes: 1 addition & 1 deletion include/can_houbolt
4 changes: 2 additions & 2 deletions src/can/CANManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ void CANManager::OnCANRecv(uint8_t canBusChannelID, uint32_t canID, uint8_t *pay
{
if (canIDStruct->info.direction == 0)
{
Debug::print("Direction bit master to node %d on bus %d, delegating msg...", nodeID, canBusChannelID);
Debug::info("Direction bit master to node %d on bus %d, delegating msg...", nodeID, canBusChannelID);
std::string msg;
msg += "\nNode ID: " + std::to_string(nodeID) + "\n";
msg += "Channel ID: " + std::to_string(canMsg->bit.info.channel_id) + "\n";
Expand All @@ -403,7 +403,7 @@ void CANManager::OnCANRecv(uint8_t canBusChannelID, uint32_t canID, uint8_t *pay
msg += std::to_string(canMsg->bit.data.uint8[i]) + " ";
}
msg += "\n";
Debug::print(msg);
Debug::info(msg);
//TODO: DIRTY HOTFIX, remove it
std::vector<uint8_t> channels = {0,1,2,3};
channels.erase(channels.begin()+canBusChannelID);
Expand Down
87 changes: 87 additions & 0 deletions src/can/Rocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const std::vector<std::string> Rocket::states =
"MinimumChamberPressure",
"MinimumFuelPressure",
"MinimumOxPressure",
"MaximumTankPressure",
"HolddownTimeout",
"InternalControl",
"Abort",
Expand All @@ -26,17 +27,24 @@ const std::map<std::string, std::vector<double>> Rocket::scalingMap =
{"MinimumChamberPressure", {0.0037, 0.0}},
{"MinimumFuelPressure", {0.00367, 0.0}},
{"MinimumOxPressure", {0.003735, 0.0}},
{"MaximumTankPressure", {0.001, 0.0}},
{"HolddownTimeout", {1.0, 0.0}},
{"StateRefreshDivider", {1.0, 0.0}},
{"GSEConnectionAbortEnable", {1.0, 0.0}},
{"GSEConnectionAbortTimer", {1.0, 0.0}},
};

const std::map<ROCKET_VARIABLES , std::string> Rocket::variableMap =
{
{ROCKET_MINIMUM_CHAMBER_PRESSURE, "MinimumChamberPressure"},
{ROCKET_MINIMUM_FUEL_PRESSURE, "MinimumFuelPressure"},
{ROCKET_MINIMUM_OX_PRESSURE, "MinimumOxPressure"},
{ROCKET_MAXIMUM_TANK_PRESSURE, "MaximumTankPressure"},
{ROCKET_HOLDDOWN_TIMEOUT, "HolddownTimeout"},
{ROCKET_STATE_REFRESH_DIVIDER, "StateRefreshDivider"},
{ROCKET_GSE_CONNECTION_ABORT_ENABLED,"GSEConnectionAbortEnable"},
{ROCKET_GSE_CONNECTION_ABORT_TIMER,"GSEConnectionAbortTimer"}

};

Rocket::Rocket(uint8_t channelID, std::string channelName, std::vector<double> sensorScaling, Node *parent)
Expand All @@ -49,18 +57,24 @@ Rocket::Rocket(uint8_t channelID, std::string channelName, std::vector<double> s
{"GetMinimumFuelPressure", {std::bind(&Rocket::GetMinimumFuelPressure, this, std::placeholders::_1, std::placeholders::_2), {}}},
{"SetMinimumOxPressure", {std::bind(&Rocket::SetMinimumOxPressure, this, std::placeholders::_1, std::placeholders::_2), {"Value"}}},
{"GetMinimumOxPressure", {std::bind(&Rocket::GetMinimumOxPressure, this, std::placeholders::_1, std::placeholders::_2), {}}},
{"SetMaximumTankPressure", {std::bind(&Rocket::SetMaximumTankPressure, this, std::placeholders::_1, std::placeholders::_2), {"Value"}}},
{"GetMaximumTankPressure", {std::bind(&Rocket::GetMaximumTankPressure, this, std::placeholders::_1, std::placeholders::_2), {}}},
{"SetHolddownTimeout", {std::bind(&Rocket::SetHolddownTimeout, this, std::placeholders::_1, std::placeholders::_2), {"Value"}}},
{"GetHolddownTimeout", {std::bind(&Rocket::GetHolddownTimeout, this, std::placeholders::_1, std::placeholders::_2), {}}},
{"SetStateRefreshDivider", {std::bind(&Rocket::SetStateRefreshDivider, this, std::placeholders::_1, std::placeholders::_2), {"Value"}}},
{"GetStateRefreshDivider", {std::bind(&Rocket::GetStateRefreshDivider, this, std::placeholders::_1, std::placeholders::_2), {}}},
{"SetRocketState", {std::bind(&Rocket::SetRocketState, this, std::placeholders::_1, std::placeholders::_2), {"State"}}},
{"GetRocketState", {std::bind(&Rocket::GetRocketState, this, std::placeholders::_1, std::placeholders::_2), {}}},
{"GetGSEConnectionAbortTimer", {std::bind(&Rocket::GetGSEConnectionAbortTimer, this, std::placeholders::_1, std::placeholders::_2), {}}},
{"GetGSEConnectionAbortEnable", {std::bind(&Rocket::GetGSEConnectionAbortEnable, this, std::placeholders::_1, std::placeholders::_2), {}}},
{"SetGSEConnectionAbortEnable", {std::bind(&Rocket::SetGSEConnectionAbortEnable, this, std::placeholders::_1, std::placeholders::_2), {"Value"}}},
{"ActivateInternalControl", {std::bind(&Rocket::RequestInternalControl, this, std::placeholders::_1, std::placeholders::_2), {}}},
{"Abort", {std::bind(&Rocket::RequestAbort, this, std::placeholders::_1, std::placeholders::_2), {}}},
{"EndOfFlight", {std::bind(&Rocket::RequestEndOfFlight, this, std::placeholders::_1, std::placeholders::_2), {}}},
{"AutoCheck", {std::bind(&Rocket::RequestAutoCheck, this, std::placeholders::_1, std::placeholders::_2), {}}},
{"RequestStatus", {std::bind(&Rocket::RequestStatus, this, std::placeholders::_1, std::placeholders::_2), {}}},
{"RequestResetSettings", {std::bind(&Rocket::RequestResetSettings, this, std::placeholders::_1, std::placeholders::_2), {}}},
{"RequestResetSettings", {std::bind(&Rocket::RequestResetSettings, this, std::placeholders::_1, std::placeholders::_2), {}}},
};
}

Expand Down Expand Up @@ -252,6 +266,50 @@ void Rocket::GetMinimumOxPressure(std::vector<double> &params, bool testOnly)
}
}

void Rocket::SetMaximumTankPressure(std::vector<double> &params, bool testOnly)
{
std::vector<double> scalingParams = scalingMap.at("MaximumTankPressure");

try
{
SetVariable(ROCKET_REQ_SET_VARIABLE, parent->GetNodeID(), ROCKET_MAXIMUM_TANK_PRESSURE,
scalingParams, params, parent->GetCANBusChannelID(), parent->GetCANDriver(), testOnly);
}
catch (std::exception &e)
{
throw std::runtime_error("Rocket - SetMaximumTankPressure: " + std::string(e.what()));
}
}

void Rocket::SetGSEConnectionAbortEnable(std::vector<double> &params, bool testOnly)
{
std::vector<double> scalingParams = scalingMap.at("MinimumChamberPressure");

try
{
SetVariable(ROCKET_REQ_SET_VARIABLE, parent->GetNodeID(), ROCKET_GSE_CONNECTION_ABORT_ENABLED,
scalingParams, params, parent->GetCANBusChannelID(), parent->GetCANDriver(), testOnly);
}
catch (std::exception &e)
{
throw std::runtime_error("Rocket - SetGSEConnectionAbortEnable: " + std::string(e.what()));
}
}


void Rocket::GetMaximumTankPressure(std::vector<double> &params, bool testOnly)
{
try
{
GetVariable(ROCKET_REQ_GET_VARIABLE, parent->GetNodeID(), ROCKET_MAXIMUM_TANK_PRESSURE,
params, parent->GetCANBusChannelID(), parent->GetCANDriver(), testOnly);
}
catch (std::exception &e)
{
throw std::runtime_error("Rocket - GetMaximumTankPressure: " + std::string(e.what()));
}
}

void Rocket::SetHolddownTimeout(std::vector<double> &params, bool testOnly)
{
std::vector<double> scalingParams = scalingMap.at("HolddownTimeout");
Expand Down Expand Up @@ -416,14 +474,43 @@ void Rocket::RequestResetSettings(std::vector<double> &params, bool testOnly)
}
}

void Rocket::GetGSEConnectionAbortEnable(std::vector<double> &params, bool testOnly)
{
try
{
GetVariable(ROCKET_REQ_GET_VARIABLE, parent->GetNodeID(),ROCKET_GSE_CONNECTION_ABORT_ENABLED,
params, parent->GetCANBusChannelID(), parent->GetCANDriver(), testOnly);
}
catch (std::exception &e)
{
throw std::runtime_error("Rocket - GetGSEConnectionAbortEnable: " + std::string(e.what()));
}
}
void Rocket::GetGSEConnectionAbortTimer(std::vector<double> &params, bool testOnly)
{
try
{
GetVariable(ROCKET_REQ_GET_VARIABLE, parent->GetNodeID(),ROCKET_GSE_CONNECTION_ABORT_TIMER,
params, parent->GetCANBusChannelID(), parent->GetCANDriver(), testOnly);
}
catch (std::exception &e)
{
throw std::runtime_error("Rocket - GetGSEConnectionAbortTimer: " + std::string(e.what()));
}
}


void Rocket::RequestCurrentState()
{
std::vector<double> params;

GetMinimumChamberPressure(params, false);
GetMinimumFuelPressure(params, false);
GetMinimumOxPressure(params, false);
GetMaximumTankPressure(params, false);
GetHolddownTimeout(params, false);
GetStateRefreshDivider(params, false);
GetRocketState(params, false);
GetGSEConnectionAbortEnable(params,false);
GetGSEConnectionAbortTimer(params, false);
}