Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/cmd sequencer heli #882

Merged
merged 12 commits into from
Aug 12, 2021
2 changes: 1 addition & 1 deletion Ref/test/int/ref_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,5 +279,5 @@ def test_seqgen(self):
== 0
), "Failed to run fprime-seqgen"
self.assert_command(
"cmdSeq.CS_RUN", args=["/tmp/ref_test_int.bin"], max_delay=5
"cmdSeq.CS_RUN", args=["/tmp/ref_test_int.bin", "SEQ_BLOCK"], max_delay=5
)
3,428 changes: 1,821 additions & 1,607 deletions Svc/CmdSequencer/CmdSequencerComponent.mdxml

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion Svc/CmdSequencer/CmdSequencerComponentAi.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="../../Autocoders/schema/ISF/component_schema.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>

<!--
Copyright (C) 2009-2018 California Institute of Technology.
ALL RIGHTS RESERVED. United States Government Sponsorship
acknowledged.
-->

<component name="CmdSequencer" kind="active" namespace="Svc" modeler="true">

Expand All @@ -7,6 +14,7 @@
<import_port_type>Svc/Ping/PingPortAi.xml</import_port_type>
<import_port_type>Fw/Tlm/TlmPortAi.xml</import_port_type>
<import_port_type>Fw/Cmd/CmdResponsePortAi.xml</import_port_type>
<import_port_type>Svc/Seq/CmdSeqCancelPortAi.xml</import_port_type>
<import_port_type>Fw/Time/TimePortAi.xml</import_port_type>
<import_port_type>Fw/Com/ComPortAi.xml</import_port_type>
<import_port_type>Fw/Cmd/CmdPortAi.xml</import_port_type>
Expand Down Expand Up @@ -34,6 +42,9 @@
<port name="cmdResponseOut" data_type="Fw::CmdResponse" kind="output" role="CmdResponse" max_number="1">
</port>

<port name="seqCancelIn" data_type="Svc::CmdSeqCancel" kind="async_input" max_number="1">
</port>

<port name="timeCaller" data_type="Fw::Time" kind="output" role="TimeGet" max_number="1">
</port>

Expand Down Expand Up @@ -62,4 +73,4 @@
</port>
</ports>

</component>
</component>
49 changes: 42 additions & 7 deletions Svc/CmdSequencer/CmdSequencerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
// \author Bocchino/Canham
// \brief cpp file for CmdDispatcherComponentBase component implementation class
//
// \copyright
// Copyright (C) 2009-2018 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
//
// ======================================================================

#include <Fw/Types/Assert.hpp>
#include <Fw/Types/SerialBuffer.hpp>
Expand Down Expand Up @@ -38,7 +35,10 @@ namespace Svc {
m_executedCount(0),
m_totalExecutedCount(0),
m_sequencesCompletedCount(0),
m_timeout(0)
m_timeout(0),
m_blockState(SEQ_NO_BLOCK),
m_opCode(0),
m_cmdSeq(0)
{

}
Expand All @@ -48,7 +48,7 @@ namespace Svc {
CmdSequencerComponentBase::init(queueDepth, instance);
}

void CmdSequencerComponentImpl::setTimeout(NATIVE_UINT_TYPE timeout) {
void CmdSequencerComponentImpl::setTimeout(const NATIVE_UINT_TYPE timeout) {
this->m_timeout = timeout;
}

Expand Down Expand Up @@ -94,13 +94,18 @@ namespace Svc {
void CmdSequencerComponentImpl::CS_RUN_cmdHandler(
FwOpcodeType opCode,
U32 cmdSeq,
const Fw::CmdStringArg& fileName) {
const Fw::CmdStringArg& fileName,
SeqBlkState block) {

if (not this->requireRunMode(STOPPED)) {
this->cmdResponse_out(opCode, cmdSeq, Fw::COMMAND_EXECUTION_ERROR);
return;
}

this->m_blockState = block;
this->m_cmdSeq = cmdSeq;
this->m_opCode = opCode;

// load commands
if (not this->loadFile(fileName)) {
this->cmdResponse_out(opCode, cmdSeq, Fw::COMMAND_EXECUTION_ERROR);
Expand All @@ -115,7 +120,9 @@ namespace Svc {
this->performCmd_Step();
}

this->cmdResponse_out(opCode, cmdSeq, Fw::COMMAND_OK);
if (SEQ_NO_BLOCK == this->m_blockState) {
this->cmdResponse_out(opCode, cmdSeq, Fw::COMMAND_OK);
}
}

void CmdSequencerComponentImpl::CS_VALIDATE_cmdHandler(
Expand Down Expand Up @@ -184,6 +191,20 @@ namespace Svc {
this->log_ACTIVITY_HI_CS_PortSequenceStarted(this->m_sequence->getLogFileName());
}

void CmdSequencerComponentImpl ::
seqCancelIn_handler(
const NATIVE_INT_TYPE portNum
) {
if (RUNNING == this->m_runMode) {
this->performCmd_Cancel();
this->log_ACTIVITY_HI_CS_SequenceCanceled(this->m_sequence->getLogFileName());
++this->m_cancelCmdCount;
this->tlmWrite_CS_CancelCommands(this->m_cancelCmdCount);
} else {
this->log_WARNING_LO_CS_NoSequenceActive();
}
}

void CmdSequencerComponentImpl::CS_CANCEL_cmdHandler(
FwOpcodeType opCode, U32 cmdSeq) {
if (RUNNING == this->m_runMode) {
Expand Down Expand Up @@ -230,6 +251,11 @@ namespace Svc {
this->seqDone_out(0,0,0,Fw::COMMAND_EXECUTION_ERROR);
}

if (SEQ_BLOCK == this->m_blockState) {
this->cmdResponse_out(this->m_opCode, this->m_cmdSeq, Fw::COMMAND_EXECUTION_ERROR);
}

this->m_blockState = SEQ_NO_BLOCK;
}

void CmdSequencerComponentImpl ::
Expand Down Expand Up @@ -304,6 +330,8 @@ namespace Svc {
this->cmdResponse_out(opcode, cmdSeq, Fw::COMMAND_EXECUTION_ERROR);
return;
}

this->m_blockState = SEQ_NO_BLOCK;
this->m_runMode = RUNNING;
this->performCmd_Step();
this->log_ACTIVITY_HI_CS_CmdStarted(this->m_sequence->getLogFileName());
Expand Down Expand Up @@ -417,6 +445,13 @@ namespace Svc {
if (this->isConnected_seqDone_OutputPort(0)) {
this->seqDone_out(0,0,0,Fw::COMMAND_OK);
}

if (SEQ_BLOCK == this->m_blockState) {
this->cmdResponse_out(this->m_opCode, this->m_cmdSeq, Fw::COMMAND_OK);
}

this->m_blockState = SEQ_NO_BLOCK;

}

void CmdSequencerComponentImpl::commandComplete(const U32 opcode) {
Expand Down
31 changes: 20 additions & 11 deletions Svc/CmdSequencer/CmdSequencerImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
// \author Bocchino/Canham
// \brief hpp file for CmdSequencer component implementation class
//
// \copyright
// Copyright (C) 2009-2018 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
//
// ======================================================================

#ifndef Svc_CmdSequencerImpl_HPP
#define Svc_CmdSequencerImpl_HPP
Expand Down Expand Up @@ -128,14 +125,14 @@ namespace Svc {

//! Time base mismatch
void timeBaseMismatch(
const FwTimeBaseStoreType currTimeBase, //!< The current time base
const FwTimeBaseStoreType seqTimeBase //!< The sequence file time base
const U32 currTimeBase, //!< The current time base
const U32 seqTimeBase //!< The sequence file time base
);

//! Time context mismatch
void timeContextMismatch(
const FwTimeContextStoreType currTimeContext, //!< The current time context
const FwTimeContextStoreType seqTimeContext //!< The sequence file time context
const U32 currTimeContext, //!< The current time context
const U32 seqTimeContext //!< The sequence file time context
);

PRIVATE:
Expand Down Expand Up @@ -241,9 +238,9 @@ namespace Svc {

//! Give the sequence representation a memory buffer
void allocateBuffer(
const NATIVE_INT_TYPE identifier, //!< The identifier
NATIVE_INT_TYPE identifier, //!< The identifier
Fw::MemAllocator& allocator, //!< The allocator
const NATIVE_UINT_TYPE bytes //!< The number of bytes
NATIVE_UINT_TYPE bytes //!< The number of bytes
);

//! Deallocate the buffer
Expand Down Expand Up @@ -552,7 +549,7 @@ namespace Svc {
//! Sequence will quit if a command takes longer than the number of
//! seconds in the timeout value.
void setTimeout(
NATIVE_UINT_TYPE seconds //!< The number of seconds
const NATIVE_UINT_TYPE seconds //!< The number of seconds
);

//! (Optional) Set the sequence format.
Expand Down Expand Up @@ -618,6 +615,12 @@ namespace Svc {
U32 key //!< Value to return to pinger
);

//! Handler implementation for seqCancelIn
//!
void seqCancelIn_handler(
const NATIVE_INT_TYPE portNum /*!< The port number*/
);

PRIVATE:

// ----------------------------------------------------------------------
Expand Down Expand Up @@ -649,7 +652,8 @@ namespace Svc {
void CS_RUN_cmdHandler(
FwOpcodeType opCode, //!< The opcode
U32 cmdSeq, //!< The command sequence number
const Fw::CmdStringArg& fileName //!< The file name
const Fw::CmdStringArg& fileName, //!< The file name
SeqBlkState block /*!< Return command status when complete or not*/
);

//! Handler for command CS_START
Expand Down Expand Up @@ -780,6 +784,11 @@ namespace Svc {
//! timeout timer
Timer m_cmdTimeoutTimer;

//! Block mode for command status
SeqBlkState m_blockState;
FwOpcodeType m_opCode;
U32 m_cmdSeq;

};

};
Expand Down
62 changes: 38 additions & 24 deletions Svc/CmdSequencer/Commands.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="../../Autocoders/schema/ISF/command_schema.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>

<!--
Copyright (C) 2009-2018 California Institute of Technology.
ALL RIGHTS RESERVED. United States Government Sponsorship
acknowledged.
-->

<!--============ CmdSequencer Commands =================================== -->

<commands>
<command kind="async" opcode="0" mnemonic="CS_RUN">
<comment>Run a command sequence file</comment>
<args>
<arg type="string" name="fileName" size="240">
<comment>The name of the sequence file</comment>
</arg>
</args>
</command>
<command kind="async" opcode="0" mnemonic="CS_RUN">
<comment>Run a command sequence file</comment>
<args>
<arg type="string" name="fileName" size="100">
<comment>The name of the sequence file</comment>
</arg>
<arg type="ENUM" name="block">
<comment>Return command status when complete or not</comment>
<enum name="SeqBlkState">
<item name="SEQ_BLOCK"/>
<item name="SEQ_NO_BLOCK"/>
</enum>
</arg>
</args>
</command>
<command kind="async" opcode="1" mnemonic="CS_VALIDATE">
<comment>Validate a command sequence file</comment>
<args>
<arg type="string" name="fileName" size="240">
<arg type="string" name="fileName" size="100">
<comment>The name of the sequence file</comment>
</arg>
</args>
</command>
<command kind="async" opcode="2" mnemonic="CS_CANCEL">
<comment>Cancel a command sequence</comment>
</command>
<command kind="async" opcode="3" mnemonic="CS_START">
<comment>Start running a command sequence</comment>
</command>
<command kind="async" opcode="4" mnemonic="CS_STEP">
<comment>Perform one step in a command sequence. Valid only if CmdSequencer is in MANUAL run mode.</comment>
</command>
<command kind="async" opcode="5" mnemonic="CS_AUTO">
<comment>Set the run mode to AUTO.</comment>
</command>
<command kind="async" opcode="6" mnemonic="CS_MANUAL">
<comment>Set the run mode to MANUAL.</comment>
</command>
<command kind="async" opcode="2" mnemonic="CS_CANCEL">
<comment>Cancel a command sequence</comment>
</command>
<command kind="async" opcode="3" mnemonic="CS_START">
<comment>Start running a command sequence</comment>
</command>
<command kind="async" opcode="4" mnemonic="CS_STEP">
<comment>Perform one step in a command sequence. Valid only if CmdSequencer is in MANUAL run mode.</comment>
</command>
<command kind="async" opcode="5" mnemonic="CS_AUTO">
<comment>Set the run mode to AUTO.</comment>
</command>
<command kind="async" opcode="6" mnemonic="CS_MANUAL">
<comment>Set the run mode to MANUAL.</comment>
</command>
</commands>
9 changes: 3 additions & 6 deletions Svc/CmdSequencer/Events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
// \author Bocchino
// \brief Implementation for CmdSequencerComponentImpl::Sequence::Events
//
// \copyright
// Copyright (C) 2009-2018 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
//
// ======================================================================

#include "Fw/Types/Assert.hpp"
#include "Svc/CmdSequencer/CmdSequencerImpl.hpp"
Expand Down Expand Up @@ -148,7 +145,7 @@ namespace Svc {
}

void CmdSequencerComponentImpl::Sequence::Events ::
timeBaseMismatch(const FwTimeBaseStoreType currTimeBase, const FwTimeBaseStoreType seqTimeBase)
timeBaseMismatch(const U32 currTimeBase, const U32 seqTimeBase)
{
Fw::LogStringArg& logFileName = this->m_sequence.getLogFileName();
CmdSequencerComponentImpl& component = this->m_sequence.m_component;
Expand All @@ -162,8 +159,8 @@ namespace Svc {

void CmdSequencerComponentImpl::Sequence::Events ::
timeContextMismatch(
const FwTimeContextStoreType currTimeContext,
const FwTimeContextStoreType seqTimeContext
const U32 currTimeContext,
const U32 seqTimeContext
)
{
Fw::LogStringArg& logFileName = this->m_sequence.getLogFileName();
Expand Down
7 changes: 7 additions & 0 deletions Svc/CmdSequencer/Events.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="../../Autocoders/schema/ISF/event_schema.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>

<!--
Copyright (C) 2009-2018 California Institute of Technology.
ALL RIGHTS RESERVED. United States Government Sponsorship
acknowledged.
-->

<!--===== Svc CmdSequencer Events =========== -->

Expand Down
3 changes: 0 additions & 3 deletions Svc/CmdSequencer/FPrimeSequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
// \author Bocchino/Canham
// \brief CmdSequencerComponentImpl::FPrimeSequence implementation
//
// \copyright
// Copyright (C) 2009-2018 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
//
// ======================================================================

#include "Fw/Types/Assert.hpp"
#include "Svc/CmdSequencer/CmdSequencerImpl.hpp"
Expand Down
Loading