Skip to content

Commit 5d748fd

Browse files
Add Cancel Port To FpySequencer (nasa#5056)
* Add Cancel Port * Cancel Event * InvalidSeqCancelCall * Added missing brace for FpySequencer UT --------- Co-authored-by: Brian Campuzano <brian.campuzano@fireflyspace.com>
1 parent 5843907 commit 5d748fd

5 files changed

Lines changed: 43 additions & 0 deletions

File tree

Svc/FpySequencer/FpySequencer.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,15 @@ void FpySequencer::cmdResponseIn_handler(FwIndexType portNum, //!< T
379379
this->m_runtime.stack.push(static_cast<I32>(response.e));
380380
}
381381

382+
void FpySequencer ::seqCancelIn_handler(FwIndexType portNum) {
383+
// only state you can't cancel in is IDLE
384+
if (sequencer_getState() == State::IDLE) {
385+
this->log_WARNING_HI_InvalidSeqCancelCall(static_cast<I32>(sequencer_getState()));
386+
return;
387+
}
388+
this->sequencer_sendSignal_cmd_CANCEL();
389+
}
390+
382391
//! Handler for input port seqRunIn
383392
void FpySequencer::seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& filename, const Svc::SeqArgs& args) {
384393
// can only run a seq while in idle

Svc/FpySequencer/FpySequencer.fpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ module Svc {
5353
# same priority as RUN cmd
5454
async input port seqRunIn: Svc.CmdSeqIn priority 7 assert
5555

56+
@ port for requesting to cancel the currently running sequence
57+
# same priority as CANCEL cmd
58+
async input port seqCancelIn: Svc.CmdSeqCancel priority 8 assert
59+
5660
@ called when a sequence begins running
5761
output port seqStartOut: Svc.CmdSeqIn
5862

Svc/FpySequencer/FpySequencer.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,12 @@ class FpySequencer : public FpySequencerComponentBase {
514514
//! Handler for input port seqRunIn
515515
void seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& filename, const Svc::SeqArgs& args) override;
516516

517+
//! Handler implementation for seqCancelIn
518+
//!
519+
//! port for requesting to cancel the currently running sequence
520+
void seqCancelIn_handler(FwIndexType portNum //!< The port number
521+
) override;
522+
517523
//! Handler for input port pingIn
518524
void pingIn_handler(FwIndexType portNum, //!< The port number
519525
U32 key //!< Value to return to pinger

Svc/FpySequencer/FpySequencerEvents.fppi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ event InvalidSeqRunCall($state: I32) \
66
severity warning high \
77
format "Cannot run sequence from a port in state {}"
88

9+
event InvalidSeqCancelCall($state: I32) \
10+
severity warning high \
11+
format "Cannot cancel sequence from a port in state {}"
12+
913
event FileOpenError(
1014
filePath: string
1115
errorCode: I32

Svc/FpySequencer/test/ut/FpySequencerTestMain.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3340,6 +3340,26 @@ TEST_F(FpySequencerTester, seqRunIn) {
33403340
removeFile("test.bin");
33413341
}
33423342

3343+
TEST_F(FpySequencerTester, seqCancelIn) {
3344+
this->tester_setState(State::IDLE);
3345+
this->invoke_to_seqCancelIn(0);
3346+
this->tester_doDispatch();
3347+
// should fail if we're in IDLE
3348+
ASSERT_EVENTS_InvalidSeqCancelCall_SIZE(1);
3349+
3350+
dispatchCurrentMessages(cmp);
3351+
ASSERT_EQ(this->tester_getState(), State::IDLE);
3352+
3353+
this->clearHistory();
3354+
this->tester_setState(State::RUNNING_SLEEPING);
3355+
this->invoke_to_seqCancelIn(0);
3356+
this->tester_doDispatch();
3357+
// should go back to idle
3358+
dispatchUntilState(State::IDLE);
3359+
ASSERT_EVENTS_SequenceCancelled_SIZE(1);
3360+
ASSERT_from_seqDoneOut(0, 0, 0, Fw::CmdResponse::EXECUTION_ERROR);
3361+
}
3362+
33433363
TEST_F(FpySequencerTester, seqRunInArgs) {
33443364
allocMem();
33453365
add_LOAD_REL(0, 4); // Load first arg (U32 at offset 0) - duplicates it on stack

0 commit comments

Comments
 (0)