Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devin/feature/create deployables interface fprime component #20

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,18 @@ namespace Components {
if (FD_ISSET(client_fd, &set)) {
memset(buffer, 0, sizeof(buffer));
read(client_fd, buffer, sizeof(buffer));
fprintf(stderr, "From server: %s\n", buffer);

// fprintf(stderr, "From server: %s\n", buffer);
this->log_ACTIVITY_LO_receivedDeployableData(buffer);
this->deployableDataIncoming_out(0, buffer);

}
}
}

void DeployablesInterface :: closeSocket(){
close(client_fd);
fprintf(stderr, "Socket closed \n");
// fprintf(stderr, "Socket closed \n");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully all the commented out printfs are only there until you verify that logging is working?

this->log_ACTIVITY_LO_socketClosed();
}

// ----------------------------------------------------------------------
Expand All @@ -151,10 +153,10 @@ namespace Components {

ssize_t len = send(client_fd, outgoingData, strlen(outgoingData), 0);
if (len > 0) {
fprintf(stderr, "Socket send success \n");
// fprintf(stderr, "Socket send success \n");
this->log_ACTIVITY_LO_sentDeployableData(outgoingData);
} else {
fprintf(stderr, "ERROR: Socket send failure: %s \n", strerror(errno));
// fprintf(stderr, "ERROR: Socket send failure: %s \n", strerror(errno));
this->log_WARNING_HI_socketSendFailure("Socket send failure");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ namespace Components {
}

void DeployablesService :: printAllDeployablesStatus(){
std::cout << "---------- Deployables Status ----------" << std::endl;
for (const std::string& deployableName : LEOPDeploymentSequence){
const DeployableInfo& deployableInfo = deployablesMap[deployableName];

std::cout << "Deployable: " << deployableName
<< ", Status: " << getStatusString(deployableInfo.status)
<< ", Attempts: " << deployableInfo.numAttempts << std::endl;
}
std::cout << "----------------------------------------" << std::endl;
}


Expand All @@ -95,23 +96,25 @@ namespace Components {
}

void DeployablesService :: attemptDeployment(const std::string& deployableName){
const DeployableInfo& deployableInfo = deployablesMap[deployableName.c_str()];
DeployableInfo& deployableInfo = deployablesMap[deployableName.c_str()];

while(deployableInfo.numAttempts < NUMBER_OF_DEPLOYMENT_ATTEMPTS && deployableInfo.status != DeployableStatus::DEPLOYED){
//Build string to send to deployables interface
std::string burnwireSetString = "burnwire_set:" + deployableName + ":1";
//Build string to send to deployables interface
std::string burnwireSetString = "burnwire_set:" + deployableName + ":1";

//Send command to toggle target component burnwire HIGH to deployables interface via port
this->deployableToggleBurnwirePort_out(0, burnwireSetString.c_str());

//Send command to toggle target component burnwire HIGH to deployables interface via port
this->deployableToggleBurnwirePort_out(0, burnwireSetString.c_str());
while(deployableInfo.numAttempts < NUMBER_OF_DEPLOYMENT_ATTEMPTS && deployableInfo.status != DeployableStatus::DEPLOYED){
deployableInfo = deployablesMap[deployableName.c_str()];

//Wait for deployable burnwire to physically burn
sleep(BURNWIRE_WAIT_TIME_SECONDS);

//Build string to send query for target components feedback switch status
std::string switchStatusQueryString = "switch_query:" + deployableName;
std::string switchStatusRequestString = "switch_request:" + deployableName;

//Send command to query target component feedback switch status to deployables interface via port
this->deployableToggleBurnwirePort_out(0, switchStatusQueryString.c_str());
this->deployableToggleBurnwirePort_out(0, switchStatusRequestString.c_str());

//Wait for response to come in from deployables interface
sleep(SWITCH_QUERY_RESPONSE_WAIT_TIME_SECONDS);
Expand All @@ -122,7 +125,15 @@ namespace Components {
if(deployableInfo.numAttempts >= NUMBER_OF_DEPLOYMENT_ATTEMPTS){
updateDeployableStatus(deployableName, DeployableStatus::FAILED_ALL_ATTEMPTS);
}

printAllDeployablesStatus();
}

//Set burnwire LOW
burnwireSetString = "burnwire_set:" + deployableName + ":0";

this->deployableToggleBurnwirePort_out(0, burnwireSetString.c_str());

}


Expand All @@ -140,14 +151,18 @@ namespace Components {
{
//Convert the response string to std::string for easier manipulation
std::string responseString = a.toChar();

//Parse the response string to get the deployable name and feedback switch status
std::string delimiter = ":";
std::string deployableName = responseString.substr(0, responseString.find(delimiter));
std::string feedbackSwitchStatus = responseString.substr(responseString.find(delimiter) + 1, responseString.length());

fprintf(stdout,"Deployable name: %s\n", deployableName.c_str());
fprintf(stdout,"Feedback switch status: %s\n", feedbackSwitchStatus.c_str());
// Ignore the string if the first token is not a deployable name
if(deployablesMap.find(deployableName.c_str()) == deployablesMap.end()){
return;
}
std::string feedbackSwitchStatus = responseString.substr(responseString.find(delimiter) + 1, responseString.length());
// fprintf(stderr,"Deployable name: %s\n", deployableName.c_str());
// fprintf(stderr,"Feedback switch status: %s\n", feedbackSwitchStatus.c_str());

if(feedbackSwitchStatus == "1"){
updateDeployableStatus(deployableName, DeployableStatus::DEPLOYED);
Expand All @@ -166,10 +181,12 @@ namespace Components {
const U32 cmdSeq
)
{
this->log_ACTIVITY_LO_deploymentSequenceStarted();
//Loop through all items in deployables map and attempt to deploy them
for (const std::string& deployableName : LEOPDeploymentSequence){
attemptDeployment(deployableName);
}
this->log_ACTIVITY_LO_deploymentSequenceEnded();

this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Components {
# Ports
# ----------------------------------------------------------------------
@ Port for receiving status from feedback switch query
async input port deployableFeedbackSwitchPort: StringValue
sync input port deployableFeedbackSwitchPort: StringValue

@ Port for toggling a burnwire
output port deployableToggleBurnwirePort: StringValue
Expand Down Expand Up @@ -47,14 +47,14 @@ module Components {


@ Log deployment sequence started
event deploymentSequenceStarted (target_component: string) \
event deploymentSequenceStarted () \
severity activity low \
format "Deployable: {} deployment sequence started"
format "Deployment sequence started"

@ Log deployment sequence ended
event deploymentSequenceEnded(target_component: string) \
event deploymentSequenceEnded() \
severity activity low \
format "Deployable: {} deployment sequence ended"
format "Deployment sequence ended"



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define NUMBER_OF_DEPLOYABLES 7

#define BURNWIRE_WAIT_TIME_SECONDS 20
#define SWITCH_QUERY_RESPONSE_WAIT_TIME_SECONDS 5
#define SWITCH_QUERY_RESPONSE_WAIT_TIME_SECONDS 2

#define NUMBER_OF_DEPLOYMENT_ATTEMPTS 3

Expand Down
Loading