Generation working and Compilation of MARTe components
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#############################################################
|
||||
#
|
||||
# Copyright 2015 F4E | European Joint Undertaking for ITER
|
||||
# and the Development of Fusion Energy ('Fusion for Energy')
|
||||
#
|
||||
# Licensed under the EUPL, Version 1.1 or - as soon they
|
||||
# will be approved by the European Commission - subsequent
|
||||
# versions of the EUPL (the "Licence");
|
||||
# You may not use this work except in compliance with the
|
||||
# Licence.
|
||||
# You may obtain a copy of the Licence at:
|
||||
#
|
||||
# http://ec.europa.eu/idabc/eupl
|
||||
#
|
||||
# Unless required by applicable law or agreed to in
|
||||
# writing, software distributed under the Licence is
|
||||
# distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
||||
# express or implied.
|
||||
# See the Licence for the specific language governing
|
||||
# permissions and limitations under the Licence.
|
||||
#
|
||||
# $Id: Makefile.gcc 3 2012-01-15 16:26:07Z aneto $
|
||||
#
|
||||
#############################################################
|
||||
|
||||
include Makefile.inc
|
||||
@@ -0,0 +1,53 @@
|
||||
#############################################################
|
||||
#
|
||||
# Copyright 2015 F4E | European Joint Undertaking for ITER
|
||||
# and the Development of Fusion Energy ('Fusion for Energy')
|
||||
#
|
||||
# Licensed under the EUPL, Version 1.1 or - as soon they
|
||||
# will be approved by the European Commission - subsequent
|
||||
# versions of the EUPL (the "Licence");
|
||||
# You may not use this work except in compliance with the
|
||||
# Licence.
|
||||
# You may obtain a copy of the Licence at:
|
||||
#
|
||||
# http://ec.europa.eu/idabc/eupl
|
||||
#
|
||||
# Unless required by applicable law or agreed to in
|
||||
# writing, software distributed under the Licence is
|
||||
# distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
||||
# express or implied.
|
||||
# See the Licence for the specific language governing
|
||||
# permissions and limitations under the Licence.
|
||||
#
|
||||
# $Id: Makefile.inc 3 2012-01-15 16:26:07Z aneto $
|
||||
#
|
||||
#############################################################
|
||||
OBJSX=RandomDataSource.x
|
||||
|
||||
PACKAGE=DataSources
|
||||
|
||||
ROOT_DIR=../../../../obj
|
||||
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
|
||||
|
||||
INCLUDES += -I.
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
|
||||
|
||||
|
||||
all: $(OBJS) $(SUBPROJ) \
|
||||
$(BUILD_DIR)/RandomDataSource$(LIBEXT) \
|
||||
$(BUILD_DIR)/RandomDataSource$(DLLEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/**
|
||||
* @file RandomDataSource.cpp
|
||||
* @brief Source file for class RandomDataSource
|
||||
* @date 01/03/2017
|
||||
* @author Andre Neto
|
||||
*
|
||||
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
|
||||
* the Development of Fusion Energy ('Fusion for Energy').
|
||||
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
|
||||
* by the European Commission - subsequent versions of the EUPL (the "Licence")
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
|
||||
*
|
||||
* @warning Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the Licence permissions and limitations under the Licence.
|
||||
|
||||
* @details This source file contains the definition of all the methods for
|
||||
* the class RandomDataSource (public, protected, and private). Be aware that some
|
||||
* methods, such as those inline could be defined on the header file, instead.
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "AdvancedErrorManagement.h"
|
||||
#include "CompilerTypes.h"
|
||||
#include "RandomDataSource.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
RandomDataSource::RandomDataSource() :
|
||||
MARTe::DataSourceI() {
|
||||
using namespace MARTe;
|
||||
seed = 0u;
|
||||
signalPtr = NULL_PTR(MARTe::char8 *);
|
||||
signalTypeDescriptor = UnsignedInteger8Bit;
|
||||
}
|
||||
|
||||
RandomDataSource::~RandomDataSource() {
|
||||
using namespace MARTe;
|
||||
if (signalPtr) {
|
||||
delete[] signalPtr;
|
||||
}
|
||||
}
|
||||
|
||||
bool RandomDataSource::SetConfiguredDatabase(MARTe::StructuredDataI & data) {
|
||||
using namespace MARTe;
|
||||
bool ok = (DataSourceI::SetConfiguredDatabase(data));
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "DataSourceI::SetConfiguredDatabas() failed");
|
||||
}
|
||||
if (ok) {
|
||||
ok = (GetNumberOfSignals() == 1u);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "GetNumberOfSignals() != 1u");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
signalTypeDescriptor = GetSignalType(0u);
|
||||
ok = (signalTypeDescriptor.type == UnsignedInteger);
|
||||
if (!ok) {
|
||||
ok = (signalTypeDescriptor.type == SignedInteger);
|
||||
}
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "GetSignalType(0u) != Un/SignedInteger");
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool RandomDataSource::Initialise(MARTe::StructuredDataI & data) {
|
||||
using namespace MARTe;
|
||||
bool ok = DataSourceI::Initialise(data);
|
||||
if (ok) {
|
||||
ok = data.Read("Seed", seed);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "The Seed shall be specified");
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool RandomDataSource::Synchronise() {
|
||||
using namespace MARTe;
|
||||
|
||||
if (signalTypeDescriptor.numberOfBits == 8u) {
|
||||
GetValue<uint8>();
|
||||
}
|
||||
if (signalTypeDescriptor.numberOfBits == 16u) {
|
||||
GetValue<uint16>();
|
||||
}
|
||||
if (signalTypeDescriptor.numberOfBits == 32u) {
|
||||
GetValue<uint32>();
|
||||
}
|
||||
if (signalTypeDescriptor.numberOfBits == 64u) {
|
||||
GetValue<uint64>();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RandomDataSource::AllocateMemory() {
|
||||
signalPtr = new MARTe::char8[signalTypeDescriptor.numberOfBits];
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RandomDataSource::GetSignalMemoryBuffer(const MARTe::uint32 signalIdx, const MARTe::uint32 bufferIdx, void *&signalAddress) {
|
||||
signalAddress = &signalPtr[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
const MARTe::char8 *RandomDataSource::GetBrokerName(MARTe::StructuredDataI &data, const MARTe::SignalDirection direction) {
|
||||
using namespace MARTe;
|
||||
|
||||
static bool firstTime = true;
|
||||
const char8 * broker;// = NULL_PTR(const char8 *);
|
||||
if (firstTime) {
|
||||
broker = "MemoryMapSynchronisedInputBroker";
|
||||
}
|
||||
else {
|
||||
firstTime = false;
|
||||
broker = "MemoryMapInputBroker";
|
||||
}
|
||||
return broker;
|
||||
}
|
||||
|
||||
bool RandomDataSource::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CLASS_REGISTER(RandomDataSource, "1.0")
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* @file RandomDataSource.h
|
||||
* @brief Header file for class RandomDataSource
|
||||
* @date 07/06/2018
|
||||
* @author Andre Neto
|
||||
*
|
||||
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
|
||||
* the Development of Fusion Energy ('Fusion for Energy').
|
||||
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
|
||||
* by the European Commission - subsequent versions of the EUPL (the "Licence")
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
|
||||
*
|
||||
* @warning Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the Licence permissions and limitations under the Licence.
|
||||
|
||||
* @details This header file contains the declaration of the class RandomDataSource
|
||||
* with all of its public, protected and private members. It may also include
|
||||
* definitions for inline methods which need to be visible to the compiler.
|
||||
*/
|
||||
|
||||
#ifndef RANDOM_DATASOURCE_H_
|
||||
#define RANDOM_DATASOURCE_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "DataSourceI.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief DataDource which generates random numbers against a given seed.
|
||||
*
|
||||
* The configuration syntax is (names and signal quantities are only given as an example):
|
||||
* +RandomDataSource = {
|
||||
* Class = RandomDataSource
|
||||
* Seed = 8 //Seed against which the the seed will be generated. Note that each signal
|
||||
* Signals = {
|
||||
* Random1 = { //Maximum one signal
|
||||
* Type = uint64 //All the integer types are supported
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
class RandomDataSource: public MARTe::DataSourceI {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
|
||||
/**
|
||||
* @brief Constructor. NOOP.
|
||||
*/
|
||||
RandomDataSource ();
|
||||
|
||||
/**
|
||||
* @brief Destructor. NOOP.
|
||||
*/
|
||||
virtual ~RandomDataSource();
|
||||
|
||||
/**
|
||||
* @brief The configuration data detailed in the class description
|
||||
* @return true if all the compulsory parameters are set.
|
||||
*/
|
||||
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||
|
||||
/**
|
||||
* @brief Verifies that at most one signal has been set with the correct type (i.e. any integer).
|
||||
* @return true if the above conditions are met.
|
||||
*/
|
||||
virtual bool SetConfiguredDatabase(MARTe::StructuredDataI & data);
|
||||
|
||||
/**
|
||||
* @brief @see DataSourceI::Synchronise
|
||||
*/
|
||||
virtual bool Synchronise();
|
||||
|
||||
/**
|
||||
* @brief @see DataSourceI::AllocateMemory
|
||||
*/
|
||||
virtual bool AllocateMemory();
|
||||
|
||||
/**
|
||||
* @brief @see DataSourceI::GetSignalMemoryBuffer
|
||||
*/
|
||||
virtual bool GetSignalMemoryBuffer(const MARTe::uint32 signalIdx, const MARTe::uint32 bufferIdx, void *&signalAddress);
|
||||
|
||||
/**
|
||||
* @return "MemoryMapSynchronisedInputBroker"
|
||||
*/
|
||||
virtual const MARTe::char8 *GetBrokerName(MARTe::StructuredDataI &data, const MARTe::SignalDirection direction);
|
||||
|
||||
/**
|
||||
* @brief NOOP
|
||||
*/
|
||||
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName);
|
||||
|
||||
private:
|
||||
/**
|
||||
* The seed to compute the signals.
|
||||
*/
|
||||
MARTe::uint32 seed;
|
||||
|
||||
/**
|
||||
* The signal pointer
|
||||
*/
|
||||
MARTe::char8 *signalPtr;
|
||||
|
||||
/**
|
||||
* The signal type descriptor.
|
||||
*/
|
||||
MARTe::TypeDescriptor signalTypeDescriptor;
|
||||
|
||||
/**
|
||||
* Compute the random value
|
||||
*/
|
||||
template<typename T>
|
||||
void GetValue();
|
||||
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Inline method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
template<typename T>
|
||||
void RandomDataSource::GetValue() {
|
||||
*(reinterpret_cast<T *>(&signalPtr[0u])) = static_cast<T>(rand_r(&seed));
|
||||
}
|
||||
|
||||
#endif /* RANDOM_DATASOURCE_H_ */
|
||||
|
||||
Reference in New Issue
Block a user