Skip to content

Commit e7345da

Browse files
timcanhamLeStarch
andauthored
Add File Dispatcher port to CmdSequencer (#4553)
* Added file dispatcher port * Added test case for file dispatch * Format and override --------- Co-authored-by: M Starch <[email protected]>
1 parent 5067881 commit e7345da

File tree

10 files changed

+118
-18
lines changed

10 files changed

+118
-18
lines changed

Svc/CmdSequencer/CmdSequencer.fpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ module Svc {
7979
@ Port for requests to run sequences
8080
async input port seqRunIn: Svc.CmdSeqIn
8181

82+
@ Port for file dispatches to run sequences
83+
async input port seqDispatchIn: Svc.FileDispatch
84+
8285
@ Port for sending sequence commands
8386
output port comCmdOut: Fw.Com
8487

Svc/CmdSequencer/CmdSequencerImpl.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ void CmdSequencerComponentImpl::CS_VALIDATE_cmdHandler(FwOpcodeType opCode,
133133
}
134134

135135
//! Handler for input port seqRunIn
136-
void CmdSequencerComponentImpl::seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& filename) {
136+
void CmdSequencerComponentImpl::doSequenceRun(const Fw::StringBase& filename) {
137137
if (!this->requireRunMode(STOPPED)) {
138138
this->seqDone_out(0, 0, 0, Fw::CmdResponse::EXECUTION_ERROR);
139139
return;
@@ -170,6 +170,14 @@ void CmdSequencerComponentImpl::seqRunIn_handler(FwIndexType portNum, const Fw::
170170
this->log_ACTIVITY_HI_CS_PortSequenceStarted(this->m_sequence->getLogFileName());
171171
}
172172

173+
void CmdSequencerComponentImpl::seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& filename) {
174+
this->doSequenceRun(filename);
175+
}
176+
177+
void CmdSequencerComponentImpl::seqDispatchIn_handler(FwIndexType portNum, Fw::StringBase& file_name) {
178+
this->doSequenceRun(file_name);
179+
}
180+
173181
void CmdSequencerComponentImpl ::seqCancelIn_handler(const FwIndexType portNum) {
174182
if (RUNNING == this->m_runMode) {
175183
this->performCmd_Cancel();

Svc/CmdSequencer/CmdSequencerImpl.hpp

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -511,27 +511,34 @@ class CmdSequencerComponentImpl final : public CmdSequencerComponentBase {
511511
FwOpcodeType opcode, //!< The command opcode
512512
U32 cmdSeq, //!< The command sequence number
513513
const Fw::CmdResponse& response //!< The command response
514-
);
514+
) override;
515515

516516
//! Handler for input port schedIn
517517
void schedIn_handler(FwIndexType portNum, //!< The port number
518518
U32 order //!< The call order
519-
);
519+
) override;
520520

521521
//! Handler for input port seqRunIn
522522
void seqRunIn_handler(FwIndexType portNum, //!< The port number
523523
const Fw::StringBase& filename //!< The sequence file
524-
);
524+
) override;
525+
526+
//! Handler implementation for seqDispatchIn
527+
//!
528+
//! Port for file dispatches to run sequences
529+
void seqDispatchIn_handler(FwIndexType portNum, //!< The port number
530+
Fw::StringBase& file_name //!< The file to dispatch
531+
) override;
525532

526533
//! Handler for ping port
527534
void pingIn_handler(FwIndexType portNum, //!< The port number
528535
U32 key //!< Value to return to pinger
529-
);
536+
) override;
530537

531538
//! Handler implementation for seqCancelIn
532539
//!
533540
void seqCancelIn_handler(const FwIndexType portNum /*!< The port number*/
534-
);
541+
) override;
535542

536543
private:
537544
// ----------------------------------------------------------------------
@@ -542,54 +549,54 @@ class CmdSequencerComponentImpl final : public CmdSequencerComponentBase {
542549
//! Set the run mode to AUTO.
543550
void CS_AUTO_cmdHandler(FwOpcodeType opcode, //!< The opcode
544551
U32 cmdSeq //!< The command sequence number
545-
);
552+
) override;
546553

547554
//! Handler for command CS_CANCEL
548555
//! Validate a command sequence file
549556
void CS_CANCEL_cmdHandler(FwOpcodeType opCode, //!< The opcode
550557
U32 cmdSeq //!< The command sequence number
551-
);
558+
) override;
552559

553560
//! Handler for command CS_MANUAL
554561
//! Set the run mode to MANUAL.
555562
void CS_MANUAL_cmdHandler(FwOpcodeType opcode, //!< The opcode
556563
U32 cmdSeq //!< The command sequence number
557-
);
564+
) override;
558565

559566
//! Handler for command CS_RUN
560567
void CS_RUN_cmdHandler(FwOpcodeType opCode, //!< The opcode
561568
U32 cmdSeq, //!< The command sequence number
562569
const Fw::CmdStringArg& fileName, //!< The file name
563570
Svc::CmdSequencer_BlockState block /*!< Return command status when complete or not*/
564-
);
571+
) override;
565572

566573
//! Handler for command CS_START
567574
//! Start running a command sequence
568575
void CS_START_cmdHandler(FwOpcodeType opcode, //!< The opcode
569576
U32 cmdSeq //!< The command sequence number
570-
);
577+
) override;
571578

572579
//! Handler for command CS_STEP
573580
//! Perform one step in a command sequence.
574581
//! Valid only if SequenceRunner is in MANUAL run mode.
575582
void CS_STEP_cmdHandler(FwOpcodeType opcode, //!< The opcode
576583
U32 cmdSeq //!< The command sequence number
577-
);
584+
) override;
578585

579586
//! Handler for command CS_VALIDATE
580587
//! Run a command sequence file
581588
void CS_VALIDATE_cmdHandler(FwOpcodeType opCode, //!< The opcode
582589
U32 cmdSeq, //!< The command sequence number
583590
const Fw::CmdStringArg& fileName //!< The name of the sequence file
584-
);
591+
) override;
585592

586593
//! Implementation for CS_JOIN command handler
587594
//! Wait for sequences that are running to finish.
588595
//! Allow user to run multiple seq files in SEQ_NO_BLOCK mode
589596
//! then wait for them to finish before allowing more seq run request.
590597
void CS_JOIN_WAIT_cmdHandler(const FwOpcodeType opCode, /*!< The opcode*/
591598
const U32 cmdSeq /*!< The command sequence number*/
592-
);
599+
) override;
593600

594601
private:
595602
// ----------------------------------------------------------------------
@@ -640,6 +647,9 @@ class CmdSequencerComponentImpl final : public CmdSequencerComponentBase {
640647
void setCmdTimeout(const Fw::Time& currentTime //!< The current time
641648
);
642649

650+
//! Sequence run helper
651+
void doSequenceRun(const Fw::StringBase& fileName);
652+
643653
private:
644654
// ----------------------------------------------------------------------
645655
// Private member variables

Svc/CmdSequencer/test/ut/CmdSequencerMain.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ TEST(Immediate, AutoByPort) {
5353
tester.AutoByPort();
5454
}
5555

56+
TEST(Immediate, AutoByFileDispatcherPort) {
57+
Svc::Immediate::CmdSequencerTester tester;
58+
tester.AutoByFileDispatcherPort();
59+
}
60+
5661
TEST(Immediate, AutoByPortAMPCS) {
5762
Svc::Immediate::CmdSequencerTester tester(Svc::SequenceFiles::File::Format::AMPCS);
5863
tester.AutoByPort();

Svc/CmdSequencer/test/ut/CmdSequencerTester.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,9 @@ void CmdSequencerTester ::connectPorts() {
391391
// seqRunIn
392392
this->connect_to_seqRunIn(0, this->component.get_seqRunIn_InputPort(0));
393393

394+
// fileDispatch
395+
this->connect_to_seqDispatchIn(0, this->component.get_seqDispatchIn_InputPort(0));
396+
394397
// timeCaller
395398
this->component.set_timeCaller_OutputPort(0, this->get_from_timeCaller(0));
396399

@@ -469,7 +472,7 @@ void CmdSequencerTester ::runSequence(const U32 cmdSeq, const char* const fileNa
469472
}
470473

471474
void CmdSequencerTester ::runSequenceByPortCall(const char* const fileName) {
472-
// Invoke the port
475+
// Invoke the seqRun port
473476
Fw::String fArg(fileName);
474477
this->invoke_to_seqRunIn(0, fArg);
475478
this->clearAndDispatch();
@@ -481,6 +484,19 @@ void CmdSequencerTester ::runSequenceByPortCall(const char* const fileName) {
481484
ASSERT_EVENTS_CS_PortSequenceStarted(0, fileName);
482485
}
483486

487+
void CmdSequencerTester ::runSequenceByFileDispatcherPortCall(const char* const fileName) {
488+
// Invoke the seqRun port
489+
Fw::String fArg(fileName);
490+
this->invoke_to_seqDispatchIn(0, fArg);
491+
this->clearAndDispatch();
492+
// Assert no command response
493+
ASSERT_CMD_RESPONSE_SIZE(0);
494+
// Assert events
495+
ASSERT_EVENTS_SIZE(2);
496+
ASSERT_EVENTS_CS_SequenceLoaded(0, fileName);
497+
ASSERT_EVENTS_CS_PortSequenceStarted(0, fileName);
498+
}
499+
484500
void CmdSequencerTester ::runLoadedSequence() {
485501
// Invoke the port
486502
Fw::String fArg("");
@@ -577,6 +593,17 @@ void CmdSequencerTester ::stepSequence(const U32 cmdSeq) {
577593
ASSERT_CMD_RESPONSE_SIZE(1);
578594
ASSERT_CMD_RESPONSE(0, CmdSequencerComponentBase::OPCODE_CS_STEP, cmdSeq, Fw::CmdResponse(Fw::CmdResponse::OK));
579595
}
596+
597+
void CmdSequencerTester::textLogIn(FwEventIdType id, //!< The event ID
598+
const Fw::Time& timeTag, //!< The time
599+
const Fw::LogSeverity severity, //!< The severity
600+
const Fw::TextLogString& text //!< The event string
601+
) {
602+
TextLogEntry e = {id, timeTag, severity, text};
603+
604+
printTextLogHistoryEntry(e, stdout);
605+
}
606+
580607
} // namespace Svc
581608

582609
namespace Os {

Svc/CmdSequencer/test/ut/CmdSequencerTester.hpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,20 @@ class CmdSequencerTester : public CmdSequencerGTestBase {
185185
FwOpcodeType opCode, //!< Command Op Code
186186
U32 cmdSeq, //!< Command Sequence
187187
const Fw::CmdResponse& response //!< The command response argument
188-
);
188+
) override;
189189

190190
//! Handler for from_comCmdOut
191191
//!
192192
void from_comCmdOut_handler(const FwIndexType portNum, //!< The port number
193193
Fw::ComBuffer& data, //!< Buffer containing packet data
194194
U32 context //!< Call context value; meaning chosen by user
195-
);
195+
) override;
196196

197197
//! Handler for from_pingOut
198198
//!
199199
void from_pingOut_handler(const FwIndexType portNum, //!< The port number
200200
U32 key //!< Value to return to pinger
201-
);
201+
) override;
202202

203203
#if VERBOSE
204204
protected:
@@ -334,6 +334,10 @@ class CmdSequencerTester : public CmdSequencerGTestBase {
334334
void runSequenceByPortCall(const char* const fileName //!< The file name
335335
);
336336

337+
//! Run a sequence by the file dispatcher port call
338+
void runSequenceByFileDispatcherPortCall(const char* const fileName //!< The file name
339+
);
340+
337341
//! Send a step command
338342
void stepSequence(const U32 cmdSeq //!< The command sequence number
339343
);
@@ -374,6 +378,12 @@ class CmdSequencerTester : public CmdSequencerGTestBase {
374378

375379
//! Open/Read interceptor
376380
Interceptor interceptor;
381+
382+
void textLogIn(FwEventIdType id, //!< The event ID
383+
const Fw::Time& timeTag, //!< The time
384+
const Fw::LogSeverity severity, //!< The severity
385+
const Fw::TextLogString& text //!< The event string
386+
) override;
377387
};
378388

379389
} // namespace Svc

Svc/CmdSequencer/test/ut/Immediate.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ void CmdSequencerTester ::AutoByPort() {
4343
this->parameterizedAutoByPort(file, numCommands, bound);
4444
}
4545

46+
void CmdSequencerTester ::AutoByFileDispatcherPort() {
47+
const U32 numRecords = 5;
48+
const U32 numCommands = numRecords;
49+
const U32 bound = numCommands;
50+
SequenceFiles::ImmediateFile file(numRecords, this->format);
51+
this->parameterizedAutoByFileDispatchPort(file, numCommands, bound);
52+
}
53+
4654
void CmdSequencerTester ::Cancel() {
4755
const U32 numRecords = 5;
4856
const U32 numCommands = numRecords;

Svc/CmdSequencer/test/ut/Immediate.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ class CmdSequencerTester : public ImmediateBase::CmdSequencerTester {
6464
//! Run an automatic sequence through a port call
6565
void AutoByPort();
6666

67+
//! Run an automatic sequence through a port call
68+
void AutoByFileDispatcherPort();
69+
6770
//! Send invalid manual commands while a sequence is running
6871
void InvalidManualCommands();
6972

Svc/CmdSequencer/test/ut/ImmediateBase.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,26 @@ void CmdSequencerTester ::parameterizedAutoByPort(SequenceFiles::File& file, con
7272
ASSERT_from_seqDone(0, 0U, 0U, Fw::CmdResponse(Fw::CmdResponse::OK));
7373
}
7474

75+
void CmdSequencerTester ::parameterizedAutoByFileDispatchPort(SequenceFiles::File& file,
76+
const U32 numCommands,
77+
const U32 bound) {
78+
// Set the time
79+
Fw::Time testTime(TimeBase::TB_WORKSTATION_TIME, 1, 1);
80+
this->setTestTime(testTime);
81+
// Write the file
82+
const char* const fileName = file.getName().toChar();
83+
file.write();
84+
// Validate the file
85+
this->validateFile(0, fileName);
86+
// Run the sequence by port call
87+
this->runSequenceByFileDispatcherPortCall(fileName);
88+
// Execute commands
89+
this->executeCommandsAuto(fileName, numCommands, bound, CmdExecMode::NO_NEW_SEQUENCE);
90+
// Check for command complete on seqDone
91+
ASSERT_from_seqDone_SIZE(1);
92+
ASSERT_from_seqDone(0, 0U, 0U, Fw::CmdResponse(Fw::CmdResponse::OK));
93+
}
94+
7595
void CmdSequencerTester ::parameterizedInvalidManualCommands(SequenceFiles::File& file) {
7696
// Set the time
7797
Fw::Time testTime(TimeBase::TB_WORKSTATION_TIME, 1, 1);

Svc/CmdSequencer/test/ut/ImmediateBase.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ class CmdSequencerTester : public Svc::CmdSequencerTester {
4646
const U32 bound //!< The number of commands to execute
4747
);
4848

49+
//! Run an automatic sequence by file dispatch port call
50+
void parameterizedAutoByFileDispatchPort(SequenceFiles::File& file, //!< The file
51+
const U32 numCommands, //!< The number of commands in the sequence
52+
const U32 bound //!< The number of commands to execute
53+
);
54+
4955
//! Send invalid manual commands while a sequence is running
5056
void parameterizedInvalidManualCommands(SequenceFiles::File& file //!< The file
5157
);

0 commit comments

Comments
 (0)