Skip to content

Commit ed950aa

Browse files
committed
Add Cancel Port
1 parent 0b645c2 commit ed950aa

4 files changed

Lines changed: 40 additions & 0 deletions

File tree

Svc/FpySequencer/FpySequencer.cpp

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

393+
void FpySequencer ::seqCancelIn_handler(FwIndexType portNum) {
394+
// only state you can't cancel in is IDLE
395+
if (sequencer_getState() == State::IDLE) {
396+
this->log_WARNING_HI_InvalidCommand(static_cast<I32>(sequencer_getState()));
397+
return;
398+
}
399+
this->sequencer_sendSignal_cmd_CANCEL();
400+
}
401+
393402
//! Handler for input port seqRunIn
394403
void FpySequencer::seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& filename) {
395404
// 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
@@ -483,6 +483,12 @@ class FpySequencer : public FpySequencerComponentBase {
483483
//! Handler for input port seqRunIn
484484
void seqRunIn_handler(FwIndexType portNum, const Fw::StringBase& filename) override;
485485

486+
//! Handler implementation for seqCancelIn
487+
//!
488+
//! port for requesting to cancel the currently running sequence
489+
void seqCancelIn_handler(FwIndexType portNum //!< The port number
490+
) override;
491+
486492
//! Handler for input port pingIn
487493
void pingIn_handler(FwIndexType portNum, //!< The port number
488494
U32 key //!< Value to return to pinger

Svc/FpySequencer/test/ut/FpySequencerTestMain.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3299,6 +3299,27 @@ TEST_F(FpySequencerTester, seqRunIn) {
32993299
removeFile("test.bin");
33003300
}
33013301

3302+
TEST_F(FpySequencerTester, seqCancelIn) {
3303+
this->tester_setState(State::IDLE);
3304+
this->invoke_to_seqCancelIn(0);
3305+
this->tester_doDispatch();
3306+
// should fail if we're in IDLE
3307+
ASSERT_EVENTS_InvalidCommand_SIZE(1);
3308+
3309+
dispatchCurrentMessages(cmp);
3310+
ASSERT_EQ(this->tester_getState(), State::IDLE);
3311+
3312+
this->clearHistory();
3313+
this->tester_setState(State::RUNNING_SLEEPING);
3314+
this->invoke_to_seqCancelIn(0);
3315+
this->tester_doDispatch();
3316+
// should go back to idle
3317+
dispatchUntilState(State::IDLE);
3318+
ASSERT_EVENTS_SequenceCancelled_SIZE(1);
3319+
ASSERT_from_seqDoneOut(0, 0, 0, Fw::CmdResponse::EXECUTION_ERROR);
3320+
}
3321+
3322+
33023323
TEST_F(FpySequencerTester, flag_EXIT_ON_CMD_FAIL) {
33033324
// test a simple seq that fails because a cmd fails
33043325
this->paramSet_FLAG_DEFAULT_EXIT_ON_CMD_FAIL(true, Fw::ParamValid::VALID);

0 commit comments

Comments
 (0)