Open dmknutsen opened 1 month ago
There's one more that wasn't listed: HS_ENABLE_APPMON_DBG_EID
Thanks for the heads up!
@dmknutsen Something like this?:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* Disable applications monitor command */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
CFE_Status_t HS_DisableAppMonCmd(const HS_DisableAppMonCmd_t *BufPtr)
{
HS_AppData.CmdCount++;
if (HS_AppData.CurrentAppMonState == HS_STATE_DISABLED)
{
CFE_EVS_SendEvent(HS_DISABLE_APPMON_INF_EID, CFE_EVS_EventType_INFORMATION, "Application Monitoring *already* Disabled");
}
else
{
HS_AppData.CurrentAppMonState = HS_STATE_DISABLED;
CFE_EVS_SendEvent(HS_DISABLE_APPMON_INF_EID, CFE_EVS_EventType_INFORMATION, "Application Monitoring Disabled");
}
return CFE_SUCCESS;
}
A separate question - create a new EID for these 'already in that state' events or re-use the successful command EIDs? (as per the above code snippet)
Consider setting a string based on state and just have one SendEvent call (with the same EID) for slightly less duplication.
OK, so how's this? ping @dmknutsen and/or @skliper
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* Disable applications monitor command */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
CFE_Status_t HS_DisableAppMonCmd(const HS_DisableAppMonCmd_t *BufPtr)
{
char EventText[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH];
HS_AppData.CmdCount++; /* Currently always successful*/
/* Check if already in the commanded state */
if (HS_AppData.CurrentAppMonState == HS_STATE_DISABLED)
{
snprintf(EventText, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Application Monitoring *already* Disabled");
}
else
{
HS_AppData.CurrentAppMonState = HS_STATE_DISABLED;
snprintf(EventText, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, "Application Monitoring Disabled");
}
CFE_EVS_SendEvent(HS_DISABLE_APPMON_INF_EID, CFE_EVS_EventType_INFORMATION, EventText);
return CFE_SUCCESS; /* Currently always returns success*/
}
In the end the 'less duplicative' version is longer...
Either look good to me!
Either look good to me!
Went with option 1.
Checklist (Please check before submitting)
Is your feature request related to a problem? Please describe. cFS should have standardized command responses for commands that set a state/mode like enable/disable, on/off, true/false, start/stop/pause/resume, etc.
For those commands, the app should respond as describe below:
If the current setting is not in that commanded state,
If the current setting is already in that commanded state,
The following event IDs issued for successful commands are debug type - which does not align with the standard:
Describe the solution you'd like Update logic to align with the standard.
Requester Info Dan Knutsen NASA Goddard