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.

7 changes: 6 additions & 1 deletion Svc/CmdSequencer/CmdSequencerComponentAi.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?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"?>

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

Expand All @@ -7,6 +8,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 +36,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 +67,4 @@
</port>
</ports>

</component>
</component>
62 changes: 56 additions & 6 deletions Svc/CmdSequencer/CmdSequencerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
// \copyright
// Copyright (C) 2009-2018 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
// acknowledged. Any commercial use must be negotiated with the Office
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up headers:

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A ton of these updated!

// of Technology Transfer at the California Institute of Technology.
//
// This software may be subject to U.S. export control laws and
// regulations. By accepting this document, the user agrees to comply
// with all U.S. export laws and regulations. User has the
// responsibility to obtain export licenses, or other export authority
// as may be required before exporting such information to foreign
// countries or providing access to foreign persons.
// ======================================================================

#include <Fw/Types/Assert.hpp>
Expand All @@ -26,8 +33,13 @@ namespace Svc {
// ----------------------------------------------------------------------

CmdSequencerComponentImpl::
#if FW_OBJECT_NAMES == 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use this check anymore. Just keep line 37-38. We intercept the name at a higher level such that this construct is not needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, remove those. Also in the header file.

CmdSequencerComponentImpl(const char* name) :
CmdSequencerComponentBase(name),
#else
CmdSequencerComponentImpl(void) :
CmdSequencerComponentBase(),
#endif
m_FPrimeSequence(*this),
m_sequence(&this->m_FPrimeSequence),
m_loadCmdCount(0),
Expand All @@ -38,7 +50,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 @@ -60,9 +75,9 @@ namespace Svc {

void CmdSequencerComponentImpl ::
allocateBuffer(
const NATIVE_INT_TYPE identifier,
NATIVE_INT_TYPE identifier,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these inputs should remain const here like they were before. This affects:

NATIVE_INT_TYPE identifier,
...
NATIVE_UINT_TYPE bytes

Should be:

const NATIVE_INT_TYPE identifier,
...
const NATIVE_UINT_TYPE bytes

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const updates added.

Fw::MemAllocator& allocator,
const NATIVE_UINT_TYPE bytes
NATIVE_UINT_TYPE bytes
)
{
this->m_sequence->allocateBuffer(identifier, allocator, bytes);
Expand Down Expand Up @@ -94,13 +109,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 +135,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 +206,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 +266,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 +345,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 +460,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
43 changes: 33 additions & 10 deletions Svc/CmdSequencer/CmdSequencerImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
// \copyright
// Copyright (C) 2009-2018 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
// acknowledged. Any commercial use must be negotiated with the Office
// of Technology Transfer at the California Institute of Technology.
//
// This software may be subject to U.S. export control laws and
// regulations. By accepting this document, the user agrees to comply
// with all U.S. export laws and regulations. User has the
// responsibility to obtain export licenses, or other export authority
// as may be required before exporting such information to foreign
// countries or providing access to foreign persons.
// ======================================================================

#ifndef Svc_CmdSequencerImpl_HPP
Expand Down Expand Up @@ -128,14 +135,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 +248,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 @@ -539,7 +546,11 @@ namespace Svc {

//! Construct a CmdSequencer
CmdSequencerComponentImpl(
#if FW_OBJECT_NAMES == 1
const char* compName //!< The component name
#else
void
#endif
);

//! Initialize a CmdSequencer
Expand Down Expand Up @@ -567,9 +578,9 @@ namespace Svc {
//! Call this after constructor and init, and after setting
//! the sequence format, but before task is spawned.
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
);

//! (Optional) Load a sequence to run later.
Expand Down Expand Up @@ -618,6 +629,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 +666,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 +798,11 @@ namespace Svc {
//! timeout timer
Timer m_cmdTimeoutTimer;

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

};

};
Expand Down
56 changes: 32 additions & 24 deletions Svc/CmdSequencer/Commands.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
<?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"?>

<!--============ 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>
15 changes: 11 additions & 4 deletions Svc/CmdSequencer/Events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
// \copyright
// Copyright (C) 2009-2018 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
// acknowledged. Any commercial use must be negotiated with the Office
// of Technology Transfer at the California Institute of Technology.
//
// This software may be subject to U.S. export control laws and
// regulations. By accepting this document, the user agrees to comply
// with all U.S. export laws and regulations. User has the
// responsibility to obtain export licenses, or other export authority
// as may be required before exporting such information to foreign
// countries or providing access to foreign persons.
// ======================================================================

#include "Fw/Types/Assert.hpp"
Expand Down Expand Up @@ -148,7 +155,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 +169,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
1 change: 1 addition & 0 deletions Svc/CmdSequencer/Events.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?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"?>

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

Expand Down
Loading