fprime/Svc/CmdSequencer/test/ut/SequenceFiles/BadDescriptorFile.cpp
Robert L. Bocchino Jr db6be3acea Revise command sequencer
Update copyright notices in comments
2018-04-08 16:23:45 -07:00

102 lines
3.2 KiB
C++

// ======================================================================
// \title BadDescriptorFile.cpp
// \author Rob Bocchino
// \brief BadDescriptorFile implementation
//
// \copyright
// Copyright (C) 2018 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// 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 "Svc/CmdSequencer/test/ut/SequenceFiles/AMPCS/AMPCS.hpp"
#include "Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.hpp"
#include "Svc/CmdSequencer/test/ut/SequenceFiles/BadDescriptorFile.hpp"
#include "Svc/CmdSequencer/test/ut/SequenceFiles/FPrime/FPrime.hpp"
#include "gtest/gtest.h"
namespace Svc {
namespace SequenceFiles {
BadDescriptorFile ::
BadDescriptorFile(const U32 n, const Format::t format) :
File(format),
n(n)
{
Fw::EightyCharString baseName;
baseName.format("bad_descriptor_%u", n);
this->setName(baseName.toChar());
}
void BadDescriptorFile ::
serializeFPrime(Fw::SerializeBufferBase& buffer)
{
// Header
const TimeBase timeBase = TB_WORKSTATION_TIME;
const U32 timeContext = 0;
const U32 recordDataSize =
this->n * SequenceFiles::FPrime::Records::STANDARD_SIZE;
const U32 dataSize = recordDataSize + FPrime::CRCs::SIZE;
FPrime::Headers::serialize(
dataSize,
this->n,
timeBase,
timeContext,
buffer
);
// Records
for (U32 record = 0; record < this->n; record++) {
Fw::Time t(TB_WORKSTATION_TIME, 0, 0);
// Force an invalid record descriptor
FPrime::Records::Descriptor descriptor =
static_cast<FPrime::Records::Descriptor>(10);
FPrime::Records::serialize(
descriptor,
t,
record,
record + 1,
buffer
);
}
// CRC
FPrime::CRCs::serialize(buffer);
}
void BadDescriptorFile ::
serializeAMPCS(Fw::SerializeBufferBase& buffer)
{
// Header
AMPCS::Headers::serialize(buffer);
// Records
for (U32 i = 0; i < this->n; ++i) {
// Force an invalid time flag
const AMPCSSequence::Record::TimeFlag::t timeFlag =
static_cast<AMPCSSequence::Record::TimeFlag::t>(10);
const AMPCSSequence::Record::Time::t time = 0;
const AMPCSSequence::Record::Opcode::t opcode = i;
const U32 argument = i + 1;
AMPCS::Records::serialize(
timeFlag,
time,
opcode,
argument,
buffer
);
}
// CRC
AMPCS::CRCs::createFile(buffer, this->getName().toChar());
}
}
}