Skip to content

Commit e7ac9e5

Browse files
authored
Unify BlockState enum across sequencers (#5095)
* Use shared BlockState for sequencer * Fix formatting
1 parent 1b7c5f4 commit e7ac9e5

21 files changed

Lines changed: 109 additions & 117 deletions

Svc/CmdSequencer/CmdSequencer.fpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ module Svc {
1313
AUTO = 1
1414
}
1515

16-
@ Sequencer blocking state
17-
enum BlockState : U8 {
18-
BLOCK = 0
19-
NO_BLOCK = 1
20-
}
21-
2216
@ The stage of the file read operation
2317
enum FileReadStage : U8 {
2418
READ_HEADER

Svc/CmdSequencer/CmdSequencerImpl.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ CmdSequencerComponentImpl::CmdSequencerComponentImpl(const char* name)
3535
m_totalExecutedCount(0),
3636
m_sequencesCompletedCount(0),
3737
m_timeout(0),
38-
m_blockState(Svc::CmdSequencer_BlockState::NO_BLOCK),
38+
m_blockState(Svc::BlockState::NO_BLOCK),
3939
m_opCode(0),
4040
m_cmdSeq(0),
4141
m_join_waiting(false) {}
@@ -74,7 +74,7 @@ CmdSequencerComponentImpl::~CmdSequencerComponentImpl() {}
7474
void CmdSequencerComponentImpl::CS_RUN_cmdHandler(FwOpcodeType opCode,
7575
U32 cmdSeq,
7676
const Fw::CmdStringArg& fileName,
77-
Svc::CmdSequencer_BlockState block) {
77+
Svc::BlockState block) {
7878
if (not this->requireRunMode(STOPPED)) {
7979
if (m_join_waiting) {
8080
// Inform user previous seq file is not complete
@@ -108,7 +108,7 @@ void CmdSequencerComponentImpl::CS_RUN_cmdHandler(FwOpcodeType opCode,
108108
this->performCmd_Step();
109109
}
110110

111-
if (Svc::CmdSequencer_BlockState::NO_BLOCK == this->m_blockState) {
111+
if (Svc::BlockState::NO_BLOCK == this->m_blockState) {
112112
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
113113
}
114114
}
@@ -256,13 +256,13 @@ void CmdSequencerComponentImpl::performCmd_Cancel() {
256256
this->seqDone_out(0, 0, 0, Fw::CmdResponse::EXECUTION_ERROR);
257257
}
258258

259-
if (Svc::CmdSequencer_BlockState::BLOCK == this->m_blockState || m_join_waiting) {
259+
if (Svc::BlockState::BLOCK == this->m_blockState || m_join_waiting) {
260260
// Do not wait if sequence was canceled or a cmd failed
261261
this->m_join_waiting = false;
262262
this->cmdResponse_out(this->m_opCode, this->m_cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
263263
}
264264

265-
this->m_blockState = Svc::CmdSequencer_BlockState::NO_BLOCK;
265+
this->m_blockState = Svc::BlockState::NO_BLOCK;
266266
}
267267

268268
void CmdSequencerComponentImpl ::cmdResponseIn_handler(FwIndexType portNum,
@@ -326,7 +326,7 @@ void CmdSequencerComponentImpl ::CS_START_cmdHandler(FwOpcodeType opcode, U32 cm
326326
return;
327327
}
328328

329-
this->m_blockState = Svc::CmdSequencer_BlockState::NO_BLOCK;
329+
this->m_blockState = Svc::BlockState::NO_BLOCK;
330330
this->m_runMode = RUNNING;
331331
this->performCmd_Step();
332332
this->log_ACTIVITY_HI_CS_CmdStarted(this->m_sequence->getLogFileName());
@@ -425,12 +425,12 @@ void CmdSequencerComponentImpl::sequenceComplete() {
425425
this->seqDone_out(0, 0, 0, Fw::CmdResponse::OK);
426426
}
427427

428-
if (Svc::CmdSequencer_BlockState::BLOCK == this->m_blockState || m_join_waiting) {
428+
if (Svc::BlockState::BLOCK == this->m_blockState || m_join_waiting) {
429429
this->cmdResponse_out(this->m_opCode, this->m_cmdSeq, Fw::CmdResponse::OK);
430430
}
431431

432432
m_join_waiting = false;
433-
this->m_blockState = Svc::CmdSequencer_BlockState::NO_BLOCK;
433+
this->m_blockState = Svc::BlockState::NO_BLOCK;
434434
}
435435

436436
void CmdSequencerComponentImpl::commandComplete(const FwOpcodeType opcode) {

Svc/CmdSequencer/CmdSequencerImpl.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "Os/File.hpp"
1717
#include "Os/ValidateFile.hpp"
1818
#include "Svc/CmdSequencer/CmdSequencerComponentAc.hpp"
19+
#include "Svc/Seq/BlockStateEnumAc.hpp"
1920

2021
namespace Svc {
2122

@@ -568,7 +569,7 @@ class CmdSequencerComponentImpl final : public CmdSequencerComponentBase {
568569
void CS_RUN_cmdHandler(FwOpcodeType opCode, //!< The opcode
569570
U32 cmdSeq, //!< The command sequence number
570571
const Fw::CmdStringArg& fileName, //!< The file name
571-
Svc::CmdSequencer_BlockState block /*!< Return command status when complete or not*/
572+
Svc::BlockState block /*!< Return command status when complete or not*/
572573
) override;
573574

574575
//! Handler for command CS_START
@@ -699,7 +700,7 @@ class CmdSequencerComponentImpl final : public CmdSequencerComponentBase {
699700
Timer m_cmdTimeoutTimer;
700701

701702
//! Block mode for command status
702-
Svc::CmdSequencer_BlockState::t m_blockState;
703+
Svc::BlockState::t m_blockState;
703704
FwOpcodeType m_opCode;
704705
U32 m_cmdSeq;
705706
bool m_join_waiting;

Svc/CmdSequencer/Commands.fppi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@ Run a command sequence file
44
async command CS_RUN(
55
fileName: string size FileNameStringSize @< The name of the sequence file
6-
$block: BlockState @< Return command status when complete or not
6+
$block: Svc.BlockState @< Return command status when complete or not
77
) \
88
opcode 0
99

Svc/CmdSequencer/test/ut/AMPCS.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void CmdSequencerTester ::MissingCRC() {
3131
SequenceFiles::MissingCRCFile file(this->format);
3232
file.write();
3333
// Run the sequence
34-
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::CmdSequencer_BlockState::NO_BLOCK);
34+
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::BlockState::NO_BLOCK);
3535
this->clearAndDispatch();
3636
// Assert no response on seqDone
3737
ASSERT_from_seqDone_SIZE(0);
@@ -54,7 +54,7 @@ void CmdSequencerTester ::MissingFile() {
5454
file.write();
5555
file.remove();
5656
// Run the sequence
57-
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::CmdSequencer_BlockState::NO_BLOCK);
57+
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::BlockState::NO_BLOCK);
5858
this->clearAndDispatch();
5959
// Assert command response
6060
ASSERT_CMD_RESPONSE_SIZE(1);

Svc/CmdSequencer/test/ut/CmdSequencerTester.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ void CmdSequencerTester ::loadSequence(const char* const fileName) {
462462

463463
void CmdSequencerTester ::runSequence(const U32 cmdSeq, const char* const fileName) {
464464
// Send run command
465-
this->sendCmd_CS_RUN(0, cmdSeq, Fw::CmdStringArg(fileName), Svc::CmdSequencer_BlockState::NO_BLOCK);
465+
this->sendCmd_CS_RUN(0, cmdSeq, Fw::CmdStringArg(fileName), Svc::BlockState::NO_BLOCK);
466466
this->clearAndDispatch();
467467
// Assert command response
468468
ASSERT_CMD_RESPONSE_SIZE(1);
@@ -515,7 +515,7 @@ void CmdSequencerTester ::runLoadedSequence() {
515515

516516
void CmdSequencerTester ::startNewSequence(const char* const fileName) {
517517
// Start the sequence
518-
this->sendCmd_CS_RUN(0, 0, Fw::CmdStringArg(fileName), Svc::CmdSequencer_BlockState::NO_BLOCK);
518+
this->sendCmd_CS_RUN(0, 0, Fw::CmdStringArg(fileName), Svc::BlockState::NO_BLOCK);
519519
this->clearAndDispatch();
520520
// Assert command response
521521
ASSERT_CMD_RESPONSE_SIZE(1);

Svc/CmdSequencer/test/ut/InvalidFiles.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void CmdSequencerTester ::BadCRC() {
3838
SequenceFiles::BadCRCFile file(this->format);
3939
file.write();
4040
// Run the sequence
41-
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::CmdSequencer_BlockState::NO_BLOCK);
41+
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::BlockState::NO_BLOCK);
4242
this->clearAndDispatch();
4343
// Assert command response
4444
ASSERT_CMD_RESPONSE_SIZE(1);
@@ -70,7 +70,7 @@ void CmdSequencerTester ::BadRecordDescriptor() {
7070
ASSERT_EVENTS_SIZE(1);
7171
ASSERT_EVENTS_CS_RecordInvalid(0, file.getName().toChar(), 0, Fw::FW_DESERIALIZE_FORMAT_ERROR);
7272
// Run the sequence
73-
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::CmdSequencer_BlockState::NO_BLOCK);
73+
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::BlockState::NO_BLOCK);
7474
this->clearAndDispatch();
7575
// Assert command response
7676
ASSERT_CMD_RESPONSE_SIZE(1);
@@ -126,7 +126,7 @@ void CmdSequencerTester ::EmptyFile() {
126126
SequenceFiles::EmptyFile file(this->format);
127127
file.write();
128128
// Run the sequence
129-
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::CmdSequencer_BlockState::NO_BLOCK);
129+
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::BlockState::NO_BLOCK);
130130
this->clearAndDispatch();
131131
// Assert command response
132132
ASSERT_CMD_RESPONSE_SIZE(1);
@@ -170,7 +170,7 @@ void CmdSequencerTester ::FileTooLarge() {
170170
Fw::Time testTime(TimeBase::TB_WORKSTATION_TIME, 0, 0);
171171
this->setTestTime(testTime);
172172
// Run the sequence
173-
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::CmdSequencer_BlockState::NO_BLOCK);
173+
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::BlockState::NO_BLOCK);
174174
this->clearAndDispatch();
175175
// Assert command response
176176
ASSERT_CMD_RESPONSE_SIZE(1);
@@ -189,7 +189,7 @@ void CmdSequencerTester ::MissingCRC() {
189189
SequenceFiles::MissingCRCFile file(this->format);
190190
file.write();
191191
// Run the sequence
192-
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::CmdSequencer_BlockState::NO_BLOCK);
192+
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::BlockState::NO_BLOCK);
193193
this->clearAndDispatch();
194194
// Assert no response on seqDone
195195
ASSERT_from_seqDone_SIZE(0);
@@ -237,7 +237,7 @@ void CmdSequencerTester ::MissingFile() {
237237
SequenceFiles::MissingFile file(this->format);
238238
file.remove();
239239
// Run the sequence
240-
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::CmdSequencer_BlockState::NO_BLOCK);
240+
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::BlockState::NO_BLOCK);
241241
this->clearAndDispatch();
242242
// Assert command response
243243
ASSERT_CMD_RESPONSE_SIZE(1);
@@ -267,7 +267,7 @@ void CmdSequencerTester ::SizeFieldTooLarge() {
267267
ASSERT_EVENTS_SIZE(1);
268268
ASSERT_EVENTS_CS_RecordInvalid(0, file.getName().toChar(), 0, Fw::FW_DESERIALIZE_SIZE_MISMATCH);
269269
// Run the sequence
270-
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::CmdSequencer_BlockState::NO_BLOCK);
270+
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::BlockState::NO_BLOCK);
271271
this->clearAndDispatch();
272272
// Assert command response
273273
ASSERT_CMD_RESPONSE_SIZE(1);
@@ -295,7 +295,7 @@ void CmdSequencerTester ::SizeFieldTooSmall() {
295295
ASSERT_EVENTS_CS_RecordInvalid_SIZE(1);
296296
ASSERT_EVENTS_CS_RecordInvalid(0, file.getName().toChar(), 0, Fw::FW_DESERIALIZE_SIZE_MISMATCH);
297297
// Run the sequence
298-
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::CmdSequencer_BlockState::NO_BLOCK);
298+
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::BlockState::NO_BLOCK);
299299
this->clearAndDispatch();
300300
// Assert command response
301301
ASSERT_CMD_RESPONSE_SIZE(1);
@@ -323,7 +323,7 @@ void CmdSequencerTester ::USecFieldTooShort() {
323323
ASSERT_EVENTS_SIZE(1);
324324
ASSERT_EVENTS_CS_RecordInvalid(0, file.getName().toChar(), 0, Fw::FW_DESERIALIZE_SIZE_MISMATCH);
325325
// Run the sequence
326-
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::CmdSequencer_BlockState::NO_BLOCK);
326+
this->sendCmd_CS_RUN(0, 0, file.getName(), Svc::BlockState::NO_BLOCK);
327327
this->clearAndDispatch();
328328
// Assert command response
329329
ASSERT_CMD_RESPONSE_SIZE(1);

Svc/CmdSequencer/test/ut/NoRecords.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void CmdSequencerTester ::RunNoRecords() {
6363
file.write();
6464

6565
// Send run command
66-
this->sendCmd_CS_RUN(0, 0, Fw::CmdStringArg(fileName), Svc::CmdSequencer_BlockState::NO_BLOCK);
66+
this->sendCmd_CS_RUN(0, 0, Fw::CmdStringArg(fileName), Svc::BlockState::NO_BLOCK);
6767
this->clearAndDispatch();
6868
// Assert command response
6969
ASSERT_CMD_RESPONSE_SIZE(1);

Svc/FpySequencer/FpySequencer.cpp

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,17 @@ FpySequencer ::~FpySequencer() {}
3838
void FpySequencer::RUN_cmdHandler(FwOpcodeType opCode, //!< The opcode
3939
U32 cmdSeq, //!< The command sequence number
4040
const Fw::CmdStringArg& fileName, //!< The name of the sequence file
41-
FpySequencer_BlockState block //!< Return command status when complete or not
41+
BlockState block //!< Return command status when complete or not
4242
) {
4343
// Empty args and delegate to RUN_ARGS handler
4444
this->RUN_ARGS_cmdHandler(opCode, cmdSeq, fileName, block, Svc::SeqArgs{0, 0});
4545
}
4646

47-
void FpySequencer ::RUN_ARGS_cmdHandler(
48-
FwOpcodeType opCode, //!< The opcode
49-
U32 cmdSeq, //!< The command sequence number
50-
const Fw::CmdStringArg& fileName, //!< The name of the sequence file
51-
Svc::FpySequencer_BlockState block, //!< Return command status when complete or not
52-
Svc::SeqArgs args //!< Arguments to pass to the sequencer
47+
void FpySequencer ::RUN_ARGS_cmdHandler(FwOpcodeType opCode, //!< The opcode
48+
U32 cmdSeq, //!< The command sequence number
49+
const Fw::CmdStringArg& fileName, //!< The name of the sequence file
50+
BlockState block, //!< Return command status when complete or not
51+
Svc::SeqArgs args //!< Arguments to pass to the sequencer
5352
) {
5453
// can only run a seq while in idle
5554
if (sequencer_getState() != State::IDLE) {
@@ -58,7 +57,7 @@ void FpySequencer ::RUN_ARGS_cmdHandler(
5857
return;
5958
}
6059

61-
if (block == FpySequencer_BlockState::BLOCK) {
60+
if (block == BlockState::BLOCK) {
6261
// save the opCode and cmdSeq so we can respond later
6362
this->m_savedOpCode = opCode;
6463
this->m_savedCmdSeq = cmdSeq;
@@ -68,7 +67,7 @@ void FpySequencer ::RUN_ARGS_cmdHandler(
6867
this->sequencer_sendSignal_cmd_RUN(FpySequencer_SequenceExecutionArgs(fileName, block, args));
6968

7069
// only respond if the user doesn't want us to block further execution
71-
if (block == FpySequencer_BlockState::NO_BLOCK) {
70+
if (block == BlockState::NO_BLOCK) {
7271
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
7372
}
7473
}
@@ -104,14 +103,12 @@ void FpySequencer ::VALIDATE_ARGS_cmdHandler(FwOpcodeType opCode,
104103

105104
// VALIDATE_ARGS receives args via command interface
106105
// Store args for pushArgsToStack action when RUN_VALIDATED is called
107-
this->sequencer_sendSignal_cmd_VALIDATE(
108-
FpySequencer_SequenceExecutionArgs(fileName, FpySequencer_BlockState::BLOCK, buffer));
106+
this->sequencer_sendSignal_cmd_VALIDATE(FpySequencer_SequenceExecutionArgs(fileName, BlockState::BLOCK, buffer));
109107
}
110108

111-
void FpySequencer::RUN_VALIDATED_cmdHandler(
112-
FwOpcodeType opCode, //!< The opcode
113-
U32 cmdSeq, //!< The command sequence number
114-
FpySequencer_BlockState block //!< Return command status when complete or not
109+
void FpySequencer::RUN_VALIDATED_cmdHandler(FwOpcodeType opCode, //!< The opcode
110+
U32 cmdSeq, //!< The command sequence number
111+
BlockState block //!< Return command status when complete or not
115112
) {
116113
// can only RUN_VALIDATED if we have validated and are awaiting this exact cmd
117114
if (sequencer_getState() != State::AWAITING_CMD_RUN_VALIDATED) {
@@ -120,7 +117,7 @@ void FpySequencer::RUN_VALIDATED_cmdHandler(
120117
return;
121118
}
122119

123-
if (block == FpySequencer_BlockState::BLOCK) {
120+
if (block == BlockState::BLOCK) {
124121
// save the opCode and cmdSeq so we can respond later
125122
this->m_savedOpCode = opCode;
126123
this->m_savedCmdSeq = cmdSeq;
@@ -130,7 +127,7 @@ void FpySequencer::RUN_VALIDATED_cmdHandler(
130127
FpySequencer_SequenceExecutionArgs(this->m_sequenceFilePath, block, this->m_sequenceArgs));
131128

132129
// only respond if the user doesn't want us to block further execution
133-
if (block == FpySequencer_BlockState::NO_BLOCK) {
130+
if (block == BlockState::NO_BLOCK) {
134131
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
135132
}
136133
}
@@ -398,8 +395,7 @@ void FpySequencer::seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& f
398395

399396
// seqRunIn is never blocking - store args for pushArgsToStack action
400397
// Args must be serialized in F' big-endian format by the caller before being sent
401-
this->sequencer_sendSignal_cmd_RUN(
402-
FpySequencer_SequenceExecutionArgs(filename, FpySequencer_BlockState::NO_BLOCK, args));
398+
this->sequencer_sendSignal_cmd_RUN(FpySequencer_SequenceExecutionArgs(filename, BlockState::NO_BLOCK, args));
403399
}
404400

405401
//! Handler for input port tlmWrite

Svc/FpySequencer/FpySequencer.fpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ module Svc {
22
@ Dispatches command sequences to available command sequencers
33
active component FpySequencer {
44

5-
enum BlockState : U8 {
6-
BLOCK
7-
NO_BLOCK
8-
}
9-
105
enum GoalState : U8 {
116
RUNNING
127
VALID

0 commit comments

Comments
 (0)