Generation working and Compilation of MARTe components
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#############################################################
|
||||
#
|
||||
# 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
|
||||
|
||||
LIBRARIES += -L$(CODAC_ROOT)/lib/ -lpxi6528
|
||||
|
||||
@@ -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=NI6528.x
|
||||
|
||||
PACKAGE=DataSources
|
||||
|
||||
ROOT_DIR=../../
|
||||
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
|
||||
INCLUDES += -I$(CODAC_ROOT)/include/
|
||||
|
||||
all: $(OBJS) $(SUBPROJ) \
|
||||
$(BUILD_DIR)/NI6528$(LIBEXT) \
|
||||
$(BUILD_DIR)/NI6528$(DLLEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* @file NI6528.cpp
|
||||
* @brief Source file for class NI6528
|
||||
* @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 NI6528 (public, protected, and private). Be aware that some
|
||||
* methods, such as those inline could be defined on the header file, instead.
|
||||
*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "AdvancedErrorManagement.h"
|
||||
#include "CompilerTypes.h"
|
||||
#include "NI6528.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Static definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
NI6528::NI6528() :
|
||||
MARTe::DataSourceI() {
|
||||
using namespace MARTe;
|
||||
previousValue = 0u;
|
||||
value = 0u;
|
||||
port = 0u;
|
||||
boardFileDescriptor = 0;
|
||||
}
|
||||
|
||||
NI6528::~NI6528() {
|
||||
using namespace MARTe;
|
||||
(void) pxi6528_close_device(boardFileDescriptor);
|
||||
}
|
||||
|
||||
bool NI6528::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) {
|
||||
ok = (GetSignalType(0u) == UnsignedInteger8Bit);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "GetSignalType(0u) != UnsignedInteger8Bit");
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool NI6528::Initialise(MARTe::StructuredDataI & data) {
|
||||
using namespace MARTe;
|
||||
bool ok = DataSourceI::Initialise(data);
|
||||
if (ok) {
|
||||
ok = data.Read("Port", port);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "The Port shall be specified");
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
ok = data.Read("DeviceName", deviceName);
|
||||
if (!ok) {
|
||||
REPORT_ERROR(ErrorManagement::ParametersError, "The DeviceName shall be specified");
|
||||
}
|
||||
}
|
||||
int32 ret = pxi6528_open_device(&boardFileDescriptor, deviceName.Buffer(), O_NONBLOCK);
|
||||
ok = (ret == 0);
|
||||
if (!ok) {
|
||||
StreamString err = strerror(-ret);
|
||||
REPORT_ERROR(ErrorManagement::FatalError, "Could not open device (%s) : %s", deviceName.Buffer(), err.Buffer());
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool NI6528::Synchronise() {
|
||||
using namespace MARTe;
|
||||
if(previousValue != value){
|
||||
int32 ret = (pxi6528_write_port(boardFileDescriptor, port, value) > 0);
|
||||
previousValue = value;
|
||||
bool ok = (ret > -1);
|
||||
if (!ok) {
|
||||
StreamString err = strerror(-ret);
|
||||
REPORT_ERROR(ErrorManagement::FatalError, "Could not write to device (%s) : %s", deviceName.Buffer(), err.Buffer());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NI6528::AllocateMemory() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NI6528::GetSignalMemoryBuffer(const MARTe::uint32 signalIdx, const MARTe::uint32 bufferIdx, void *&signalAddress) {
|
||||
signalAddress = &value;
|
||||
return true;
|
||||
}
|
||||
|
||||
const MARTe::char8 *NI6528::GetBrokerName(MARTe::StructuredDataI &data, const MARTe::SignalDirection direction) {
|
||||
using namespace MARTe;
|
||||
return "MemoryMapSynchronisedOutputBroker";
|
||||
}
|
||||
|
||||
bool NI6528::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CLASS_REGISTER(NI6528, "1.0")
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
* @file NI6528.h
|
||||
* @brief Header file for class NI6528
|
||||
* @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 NI6528
|
||||
* 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 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include <pxi6528.h>
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "DataSourceI.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief NI6528 simplified data source implementation.
|
||||
*
|
||||
* The configuration syntax is (names and signal quantities are only given as an example):
|
||||
* +NI6528 = {
|
||||
* Class = NI6528
|
||||
* DeviceName = "/dev/pxi6528.0" //Mandatory
|
||||
* Port = 0 //The port where to write
|
||||
* Signals = {
|
||||
* currentValue = {Type = uint8}
|
||||
* bitmask = {Type = uint8}
|
||||
* Value = {Type = uint8}
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
class NI6528: public MARTe::DataSourceI {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
|
||||
/**
|
||||
* @brief Constructor. NOOP.
|
||||
*/
|
||||
NI6528 ();
|
||||
|
||||
/**
|
||||
* @brief Destructor. NOOP.
|
||||
*/
|
||||
virtual ~NI6528();
|
||||
|
||||
/**
|
||||
* @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 previous value to write.
|
||||
*/
|
||||
MARTe::uint8 previousValue;
|
||||
|
||||
/**
|
||||
* The bitmask to write value. (new value) = (current value) || (bitmask) && (write value)
|
||||
*/
|
||||
MARTe::uint8 bitmask;
|
||||
|
||||
/**
|
||||
* The value to write.
|
||||
*/
|
||||
MARTe::uint8 value;
|
||||
|
||||
/**
|
||||
* The port number
|
||||
*/
|
||||
MARTe::uint32 port;
|
||||
|
||||
/**
|
||||
* The board file descriptor
|
||||
*/
|
||||
pxi6528_device_t boardFileDescriptor;
|
||||
|
||||
/**
|
||||
* The device name
|
||||
*/
|
||||
MARTe::StreamString deviceName;
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Inline method definitions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* RANDOM_DATASOURCE_H_ */
|
||||
|
||||
Reference in New Issue
Block a user