Generation working and Compilation of MARTe components
This commit is contained in:
@@ -0,0 +1,366 @@
|
|||||||
|
/**
|
||||||
|
* @file JAEPICSCAInput.cpp
|
||||||
|
* @brief Source file for class JAEPICSCAInput
|
||||||
|
* @date 20/04/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 JAEPICSCAInput (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 "JAEPICSCAInput.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#include "AdvancedErrorManagement.h"
|
||||||
|
#include "MemoryMapInputBroker.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
namespace MARTe {
|
||||||
|
/**
|
||||||
|
* @brief Callback function for the ca_create_subscription. Single point of access which
|
||||||
|
* delegates the events to the corresponding JAEPICSPV instance.
|
||||||
|
*/
|
||||||
|
static FastPollingMutexSem eventCallbackFastMux;
|
||||||
|
/*lint -e{1746} function must match required prototype and thus cannot be changed to constant reference.*/
|
||||||
|
void JAEPICSCAInputEventCallback(struct event_handler_args const args) {
|
||||||
|
(void) eventCallbackFastMux.FastLock();
|
||||||
|
PVWrapper *pv = static_cast<PVWrapper *>(args.usr);
|
||||||
|
if (pv != NULL_PTR(PVWrapper *)) {
|
||||||
|
(void) MemoryOperationsHelper::Copy(pv->memory, args.dbr, pv->memorySize);
|
||||||
|
}
|
||||||
|
eventCallbackFastMux.FastUnLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
namespace MARTe {
|
||||||
|
JAEPICSCAInput::JAEPICSCAInput() :
|
||||||
|
DataSourceI(), EmbeddedServiceMethodBinderI(), executor(*this) {
|
||||||
|
pvs = NULL_PTR(PVWrapper *);
|
||||||
|
stackSize = THREADS_DEFAULT_STACKSIZE * 4u;
|
||||||
|
cpuMask = 0xffu;
|
||||||
|
eventCallbackFastMux.Create();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*lint -e{1551} must stop the SingleThreadService in the destructor.*/
|
||||||
|
JAEPICSCAInput::~JAEPICSCAInput() {
|
||||||
|
if (!executor.Stop()) {
|
||||||
|
if (!executor.Stop()) {
|
||||||
|
REPORT_ERROR(ErrorManagement::FatalError, "Could not stop SingleThreadService.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(void) eventCallbackFastMux.FastLock();
|
||||||
|
uint32 nOfSignals = GetNumberOfSignals();
|
||||||
|
if (pvs != NULL_PTR(PVWrapper *)) {
|
||||||
|
uint32 n;
|
||||||
|
for (n = 0u; (n < nOfSignals); n++) {
|
||||||
|
if (pvs[n].memory != NULL_PTR(void *)) {
|
||||||
|
GlobalObjectsDatabase::Instance()->GetStandardHeap()->Free(pvs[n].memory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete[] pvs;
|
||||||
|
}
|
||||||
|
eventCallbackFastMux.FastUnLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAEPICSCAInput::Initialise(StructuredDataI & data) {
|
||||||
|
bool ok = DataSourceI::Initialise(data);
|
||||||
|
if (ok) {
|
||||||
|
if (!data.Read("CPUs", cpuMask)) {
|
||||||
|
REPORT_ERROR(ErrorManagement::Information, "No CPUs defined. Using default = %d", cpuMask);
|
||||||
|
}
|
||||||
|
if (!data.Read("StackSize", stackSize)) {
|
||||||
|
REPORT_ERROR(ErrorManagement::Information, "No StackSize defined. Using default = %d", stackSize);
|
||||||
|
}
|
||||||
|
executor.SetStackSize(stackSize);
|
||||||
|
executor.SetCPUMask(cpuMask);
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.MoveRelative("Signals");
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Could not move to the Signals section");
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Copy(originalSignalInformation);
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = originalSignalInformation.MoveToRoot();
|
||||||
|
}
|
||||||
|
//Do not allow to add signals in run-time
|
||||||
|
if (ok) {
|
||||||
|
ok = signalsDatabase.MoveRelative("Signals");
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = signalsDatabase.Write("Locked", 1u);
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = signalsDatabase.MoveToAncestor(1u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.MoveToAncestor(1u);
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAEPICSCAInput::SetConfiguredDatabase(StructuredDataI & data) {
|
||||||
|
bool ok = DataSourceI::SetConfiguredDatabase(data);
|
||||||
|
//Check the signal index of the timing signal.
|
||||||
|
uint32 nOfSignals = GetNumberOfSignals();
|
||||||
|
if (ok) {
|
||||||
|
ok = (nOfSignals > 0u);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "At least one signal shall be defined");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
//Do not allow samples
|
||||||
|
uint32 functionNumberOfSignals = 0u;
|
||||||
|
uint32 n;
|
||||||
|
if (GetFunctionNumberOfSignals(InputSignals, 0u, functionNumberOfSignals)) {
|
||||||
|
for (n = 0u; (n < functionNumberOfSignals) && (ok); n++) {
|
||||||
|
uint32 nSamples;
|
||||||
|
ok = GetFunctionSignalSamples(InputSignals, 0u, n, nSamples);
|
||||||
|
if (ok) {
|
||||||
|
ok = (nSamples == 1u);
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "The number of samples shall be exactly 1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
pvs = new PVWrapper[nOfSignals];
|
||||||
|
uint32 n;
|
||||||
|
for (n = 0u; (n < nOfSignals); n++) {
|
||||||
|
pvs[n].memory = NULL_PTR(void *);
|
||||||
|
}
|
||||||
|
for (n = 0u; (n < nOfSignals) && (ok); n++) {
|
||||||
|
//Note that the RealTimeApplicationConfigurationBuilder is allowed to change the order of the signals w.r.t. to the originalSignalInformation
|
||||||
|
StreamString orderedSignalName;
|
||||||
|
ok = GetSignalName(n, orderedSignalName);
|
||||||
|
if (ok) {
|
||||||
|
//Have to mix and match between the original setting of the DataSource signal
|
||||||
|
//and the ones which are later added by the RealTimeApplicationConfigurationBuilder
|
||||||
|
ok = originalSignalInformation.MoveRelative(orderedSignalName.Buffer());
|
||||||
|
}
|
||||||
|
StreamString pvName;
|
||||||
|
if (ok) {
|
||||||
|
ok = originalSignalInformation.Read("PVName", pvName);
|
||||||
|
if (!ok) {
|
||||||
|
uint32 nn = n;
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "No PVName specified for signal at index %d", nn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TypeDescriptor td = GetSignalType(n);
|
||||||
|
if (ok) {
|
||||||
|
(void) StringHelper::CopyN(&pvs[n].pvName[0], pvName.Buffer(), PV_NAME_MAX_SIZE);
|
||||||
|
if (td == CharString) {
|
||||||
|
pvs[n].pvType = DBR_STRING;
|
||||||
|
}
|
||||||
|
else if (td == Character8Bit) {
|
||||||
|
pvs[n].pvType = DBR_STRING;
|
||||||
|
}
|
||||||
|
else if (td == SignedInteger8Bit) {
|
||||||
|
pvs[n].pvType = DBR_CHAR;
|
||||||
|
}
|
||||||
|
else if (td == UnsignedInteger8Bit) {
|
||||||
|
pvs[n].pvType = DBR_CHAR;
|
||||||
|
}
|
||||||
|
else if (td == SignedInteger16Bit) {
|
||||||
|
pvs[n].pvType = DBR_SHORT;
|
||||||
|
}
|
||||||
|
else if (td == UnsignedInteger16Bit) {
|
||||||
|
pvs[n].pvType = DBR_SHORT;
|
||||||
|
}
|
||||||
|
else if (td == SignedInteger32Bit) {
|
||||||
|
pvs[n].pvType = DBR_LONG;
|
||||||
|
}
|
||||||
|
else if (td == UnsignedInteger32Bit) {
|
||||||
|
pvs[n].pvType = DBR_LONG;
|
||||||
|
}
|
||||||
|
else if (td == Float32Bit) {
|
||||||
|
pvs[n].pvType = DBR_FLOAT;
|
||||||
|
}
|
||||||
|
else if (td == Float64Bit) {
|
||||||
|
pvs[n].pvType = DBR_DOUBLE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Type %s is not supported", TypeDescriptor::GetTypeNameFromTypeDescriptor(td));
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint32 numberOfElements = 1u;
|
||||||
|
if (ok) {
|
||||||
|
ok = GetSignalNumberOfElements(n, numberOfElements);
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
if (pvs[n].pvType == DBR_STRING) {
|
||||||
|
ok = (numberOfElements == 40u);
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
|
//Could support arrays of strings with multiples of char8[40]
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Strings shall be defined with 40 elements char8[40]. Arrays of strings are not currently supported");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
pvs[n].numberOfElements = numberOfElements;
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
pvs[n].memorySize = td.numberOfBits;
|
||||||
|
pvs[n].memorySize /= 8u;
|
||||||
|
pvs[n].memorySize *= numberOfElements;
|
||||||
|
pvs[n].memory = GlobalObjectsDatabase::Instance()->GetStandardHeap()->Malloc(pvs[n].memorySize);
|
||||||
|
ok = originalSignalInformation.MoveToAncestor(1u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
ok = (executor.Start() == ErrorManagement::NoError);
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAEPICSCAInput::AllocateMemory() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 JAEPICSCAInput::GetNumberOfMemoryBuffers() {
|
||||||
|
return 1u;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: The signalAddress is independent of the bufferIdx.*/
|
||||||
|
bool JAEPICSCAInput::GetSignalMemoryBuffer(const uint32 signalIdx, const uint32 bufferIdx, void*& signalAddress) {
|
||||||
|
bool ok = (pvs != NULL_PTR(PVWrapper *));
|
||||||
|
if (ok) {
|
||||||
|
ok = (signalIdx < GetNumberOfSignals());
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
//lint -e{613} pvs cannot as otherwise ok would be false
|
||||||
|
signalAddress = pvs[signalIdx].memory;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: The brokerName only depends on the direction */
|
||||||
|
const char8* JAEPICSCAInput::GetBrokerName(StructuredDataI& data, const SignalDirection direction) {
|
||||||
|
const char8* brokerName = "";
|
||||||
|
if (direction == InputSignals) {
|
||||||
|
brokerName = "MemoryMapInputBroker";
|
||||||
|
}
|
||||||
|
return brokerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAEPICSCAInput::GetInputBrokers(ReferenceContainer& inputBrokers, const char8* const functionName, void* const gamMemPtr) {
|
||||||
|
ReferenceT<MemoryMapInputBroker> broker("MemoryMapInputBroker");
|
||||||
|
bool ok = broker->Init(InputSignals, *this, functionName, gamMemPtr);
|
||||||
|
if (ok) {
|
||||||
|
ok = inputBrokers.Insert(broker);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: OutputBrokers are not supported. Function returns false irrespectively of the parameters.*/
|
||||||
|
bool JAEPICSCAInput::GetOutputBrokers(ReferenceContainer& outputBrokers, const char8* const functionName, void* const gamMemPtr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: NOOP at StateChange, independently of the function parameters.*/
|
||||||
|
bool JAEPICSCAInput::PrepareNextState(const char8* const currentStateName, const char8* const nextStateName) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorManagement::ErrorType JAEPICSCAInput::Execute(ExecutionInfo& info) {
|
||||||
|
ErrorManagement::ErrorType err = ErrorManagement::NoError;
|
||||||
|
if (info.GetStage() == ExecutionInfo::StartupStage) {
|
||||||
|
(void) eventCallbackFastMux.FastLock();
|
||||||
|
/*lint -e{9130} -e{835} -e{845} -e{747} Several false positives. lint is getting confused here for some reason.*/
|
||||||
|
if (ca_context_create(ca_enable_preemptive_callback) != ECA_NORMAL) {
|
||||||
|
err = ErrorManagement::FatalError;
|
||||||
|
REPORT_ERROR(err, "ca_enable_preemptive_callback failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 n;
|
||||||
|
uint32 nOfSignals = GetNumberOfSignals();
|
||||||
|
if (pvs != NULL_PTR(PVWrapper *)) {
|
||||||
|
for (n = 0u; (n < nOfSignals); n++) {
|
||||||
|
/*lint -e{9130} -e{835} -e{845} -e{747} Several false positives. lint is getting confused here for some reason.*/
|
||||||
|
if (ca_create_channel(&pvs[n].pvName[0], NULL_PTR(caCh *), NULL_PTR(void *), 20u, &pvs[n].pvChid) != ECA_NORMAL) {
|
||||||
|
err = ErrorManagement::FatalError;
|
||||||
|
REPORT_ERROR(err, "ca_create_channel failed for PV with name %s", pvs[n].pvName);
|
||||||
|
}
|
||||||
|
if (err.ErrorsCleared()) {
|
||||||
|
/*lint -e{9130} -e{835} -e{845} -e{747} Several false positives. lint is getting confused here for some reason.*/
|
||||||
|
if (ca_create_subscription(pvs[n].pvType, pvs[n].numberOfElements, pvs[n].pvChid, DBE_VALUE, &JAEPICSCAInputEventCallback, &pvs[n],
|
||||||
|
&pvs[n].pvEvid) != ECA_NORMAL) {
|
||||||
|
err = ErrorManagement::FatalError;
|
||||||
|
REPORT_ERROR(err, "ca_create_subscription failed for PV %s", pvs[n].pvName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
eventCallbackFastMux.FastUnLock();
|
||||||
|
}
|
||||||
|
else if (info.GetStage() != ExecutionInfo::BadTerminationStage) {
|
||||||
|
Sleep::Sec(1.0F);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
(void) eventCallbackFastMux.FastLock();
|
||||||
|
uint32 n;
|
||||||
|
uint32 nOfSignals = GetNumberOfSignals();
|
||||||
|
if (pvs != NULL_PTR(PVWrapper *)) {
|
||||||
|
for (n = 0u; (n < nOfSignals); n++) {
|
||||||
|
(void) ca_clear_subscription(pvs[n].pvEvid);
|
||||||
|
(void) ca_clear_event(pvs[n].pvEvid);
|
||||||
|
(void) ca_clear_channel(pvs[n].pvChid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ca_detach_context();
|
||||||
|
ca_context_destroy();
|
||||||
|
eventCallbackFastMux.FastUnLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 JAEPICSCAInput::GetStackSize() const {
|
||||||
|
return stackSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 JAEPICSCAInput::GetCPUMask() const {
|
||||||
|
return cpuMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAEPICSCAInput::Synchronise() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JAEPICSCAInput, "1.0")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,260 @@
|
|||||||
|
/**
|
||||||
|
* @file EPICSCAInput.h
|
||||||
|
* @brief Header file for class EPICSCAInput
|
||||||
|
* @date 20/04/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 header file contains the declaration of the class EPICSCAInput
|
||||||
|
* 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 JAEPICSCAINPUT_H_
|
||||||
|
#define JAEPICSCAINPUT_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#include <cadef.h>
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#include "DataSourceI.h"
|
||||||
|
#include "EmbeddedServiceMethodBinderI.h"
|
||||||
|
#include "EventSem.h"
|
||||||
|
#include "SingleThreadService.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
namespace MARTe {
|
||||||
|
/**
|
||||||
|
* Maximum size that a PV name may have
|
||||||
|
*/
|
||||||
|
/*lint -esym(551, MARTe::PV_NAME_MAX_SIZE) the symbol is used to define the size of PVWrapper below*/
|
||||||
|
const uint32 PV_NAME_MAX_SIZE = 64u;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps a PV
|
||||||
|
*/
|
||||||
|
struct PVWrapper {
|
||||||
|
/**
|
||||||
|
* The channel identifier
|
||||||
|
*/
|
||||||
|
chid pvChid;
|
||||||
|
/**
|
||||||
|
* The event identifier
|
||||||
|
*/
|
||||||
|
evid pvEvid;
|
||||||
|
/**
|
||||||
|
* The PV type
|
||||||
|
*/
|
||||||
|
chtype pvType;
|
||||||
|
/**
|
||||||
|
* The memory of the signal associated to this channel
|
||||||
|
*/
|
||||||
|
void *memory;
|
||||||
|
void *previousValue;
|
||||||
|
/**
|
||||||
|
* The number of elements > 0
|
||||||
|
*/
|
||||||
|
uint32 numberOfElements;
|
||||||
|
/**
|
||||||
|
* The memory size
|
||||||
|
*/
|
||||||
|
uint32 memorySize;
|
||||||
|
/**
|
||||||
|
* The PV name
|
||||||
|
*/
|
||||||
|
char8 pvName[PV_NAME_MAX_SIZE];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A DataSource which allows to retrieved data from any number of PVs using the EPICS channel access client protocol.
|
||||||
|
* Data is asynchronously retrieved using ca_create_subscriptions in the context of a different thread (w.r.t. to the real-time thread).
|
||||||
|
*
|
||||||
|
* The configuration syntax is (names are only given as an example):
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* +EPICSCAInput_1 = {
|
||||||
|
* Class = JAEPICSCA::JAEPICSCAInput
|
||||||
|
* StackSize = 1048576 //Optional the EmbeddedThread stack size. Default value is THREADS_DEFAULT_STACKSIZE * 4u
|
||||||
|
* CPUs = 0xff //Optional the affinity of the EmbeddedThread (where the EPICS context is attached).
|
||||||
|
* Signals = {
|
||||||
|
* PV1 = { //At least one shall be defined
|
||||||
|
* PVName = My::PV1 //Compulsory. Name of the PV.
|
||||||
|
* Type = uint32 //Compulsory. Supported types are char8[40], string[40], uint8, int8, uint16, int16, int32, uint32, uint64, int64, float32 and float64
|
||||||
|
* NumberOfElements = 1 //Arrays also supported
|
||||||
|
* }
|
||||||
|
* ...
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
class JAEPICSCAInput: public DataSourceI, public EmbeddedServiceMethodBinderI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Default constructor. NOOP.
|
||||||
|
*/
|
||||||
|
JAEPICSCAInput();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Destructor.
|
||||||
|
* @details TODO.
|
||||||
|
*/
|
||||||
|
virtual ~JAEPICSCAInput();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief See DataSourceI::AllocateMemory. NOOP.
|
||||||
|
* @return true.
|
||||||
|
*/
|
||||||
|
virtual bool AllocateMemory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief See DataSourceI::GetNumberOfMemoryBuffers.
|
||||||
|
* @return 1.
|
||||||
|
*/
|
||||||
|
virtual uint32 GetNumberOfMemoryBuffers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief See DataSourceI::GetSignalMemoryBuffer.
|
||||||
|
* @pre
|
||||||
|
* SetConfiguredDatabase
|
||||||
|
*/
|
||||||
|
virtual bool GetSignalMemoryBuffer(const uint32 signalIdx,
|
||||||
|
const uint32 bufferIdx,
|
||||||
|
void *&signalAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief See DataSourceI::GetNumberOfMemoryBuffers.
|
||||||
|
* @details Only InputSignals are supported.
|
||||||
|
* @return MemoryMapInputBroker.
|
||||||
|
*/
|
||||||
|
virtual const char8 *GetBrokerName(StructuredDataI &data,
|
||||||
|
const SignalDirection direction);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief See DataSourceI::GetInputBrokers.
|
||||||
|
* @details adds a memory MemoryMapInputBroker instance to the inputBrokers
|
||||||
|
* @return true.
|
||||||
|
*/
|
||||||
|
virtual bool GetInputBrokers(ReferenceContainer &inputBrokers,
|
||||||
|
const char8* const functionName,
|
||||||
|
void * const gamMemPtr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief See DataSourceI::GetOutputBrokers.
|
||||||
|
* @return false.
|
||||||
|
*/
|
||||||
|
virtual bool GetOutputBrokers(ReferenceContainer &outputBrokers,
|
||||||
|
const char8* const functionName,
|
||||||
|
void * const gamMemPtr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief See DataSourceI::PrepareNextState. NOOP.
|
||||||
|
* @return true.
|
||||||
|
*/
|
||||||
|
virtual bool PrepareNextState(const char8 * const currentStateName,
|
||||||
|
const char8 * const nextStateName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Loads and verifies the configuration parameters detailed in the class description.
|
||||||
|
* @return true if all the mandatory parameters are correctly specified and if the specified optional parameters have valid values.
|
||||||
|
*/
|
||||||
|
virtual bool Initialise(StructuredDataI & data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Final verification of all the parameters. Setup of the memory required to hold all the signals.
|
||||||
|
* @details This method verifies that all the parameters requested by the GAMs interacting with this DataSource
|
||||||
|
* are valid and consistent with the parameters set during the initialisation phase.
|
||||||
|
* In particular the following conditions shall be met:
|
||||||
|
* - All the signals have the PVName defined
|
||||||
|
* - All the signals have one of the following types: uint32, int32, float32 or float64.
|
||||||
|
* @return true if all the parameters are valid and the conditions above are met.
|
||||||
|
*/
|
||||||
|
virtual bool SetConfiguredDatabase(StructuredDataI & data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the affinity of the thread which is going to be used to asynchronously read data from the ca_create_subscription.
|
||||||
|
* @return the the affinity of the thread which is going to be used to asynchronously read data from the ca_create_subscription.
|
||||||
|
*/
|
||||||
|
uint32 GetCPUMask() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the stack size of the thread which is going to be used to asynchronously read data from the ca_create_subscription.
|
||||||
|
* @return the stack size of the thread which is going to be used to asynchronously read data from the ca_create_subscription.
|
||||||
|
*/
|
||||||
|
uint32 GetStackSize() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Provides the context to execute all the EPICS relevant calls.
|
||||||
|
* @details Executes in the context of a spawned thread the following EPICS calls:
|
||||||
|
* ca_context_create, ca_create_channel, ca_create_subscription, ca_clear_subscription,
|
||||||
|
* ca_clear_event, ca_clear_channel, ca_detach_context and ca_context_destroy
|
||||||
|
* @return ErrorManagement::NoError if all the EPICS calls return without any error.
|
||||||
|
*/
|
||||||
|
virtual ErrorManagement::ErrorType Execute(ExecutionInfo & info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief See DataSourceI::Synchronise.
|
||||||
|
* @return false.
|
||||||
|
*/
|
||||||
|
virtual bool Synchronise();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Registered as the ca_create_subscription callback function.
|
||||||
|
* It calls updates the memory of the corresponding PV variable.
|
||||||
|
*/
|
||||||
|
friend void JAEPICSCAInputEventCallback(struct event_handler_args args);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of PVs.
|
||||||
|
*/
|
||||||
|
PVWrapper *pvs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The CPU mask for the executor
|
||||||
|
*/
|
||||||
|
uint32 cpuMask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The stack size
|
||||||
|
*/
|
||||||
|
uint32 stackSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The EmbeddedThread where the ca_pend_event is executed.
|
||||||
|
*/
|
||||||
|
SingleThreadService executor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the configuration information received at Initialise.
|
||||||
|
*/
|
||||||
|
ConfigurationDatabase originalSignalInformation;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* EPICSCADATASOURCE_H_ */
|
||||||
|
|
||||||
@@ -0,0 +1,375 @@
|
|||||||
|
/**
|
||||||
|
* @file EPICSCAOutput.cpp
|
||||||
|
* @brief Source file for class EPICSCAOutput
|
||||||
|
* @date 20/04/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 EPICSCAOutput (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 "JAEPICSCAOutput.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#include "AdvancedErrorManagement.h"
|
||||||
|
#include "MemoryMapAsyncOutputBroker.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
namespace MARTe {
|
||||||
|
JAEPICSCAOutput::JAEPICSCAOutput() :
|
||||||
|
DataSourceI() {
|
||||||
|
pvs = NULL_PTR(PVWrapper *);
|
||||||
|
stackSize = THREADS_DEFAULT_STACKSIZE * 4u;
|
||||||
|
cpuMask = 0xffu;
|
||||||
|
numberOfBuffers = 0u;
|
||||||
|
ignoreBufferOverrun = 1u;
|
||||||
|
threadContextSet = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*lint -e{1551} must free the memory allocated to the different PVs.*/
|
||||||
|
JAEPICSCAOutput::~JAEPICSCAOutput() {
|
||||||
|
uint32 nOfSignals = GetNumberOfSignals();
|
||||||
|
if (pvs != NULL_PTR(PVWrapper *)) {
|
||||||
|
uint32 n;
|
||||||
|
for (n = 0u; (n < nOfSignals); n++) {
|
||||||
|
if (pvs[n].pvChid != NULL_PTR(chid)) {
|
||||||
|
(void) ca_clear_channel(pvs[n].pvChid);
|
||||||
|
}
|
||||||
|
if (pvs[n].memory != NULL_PTR(void *)) {
|
||||||
|
GlobalObjectsDatabase::Instance()->GetStandardHeap()->Free(pvs[n].memory);
|
||||||
|
GlobalObjectsDatabase::Instance()->GetStandardHeap()->Free(pvs[n].previousValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete[] pvs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAEPICSCAOutput::Initialise(StructuredDataI & data) {
|
||||||
|
bool ok = DataSourceI::Initialise(data);
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("NumberOfBuffers", numberOfBuffers);
|
||||||
|
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "NumberOfBuffers shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
if (!data.Read("CPUs", cpuMask)) {
|
||||||
|
REPORT_ERROR(ErrorManagement::Information, "No CPUs defined. Using default = %d", cpuMask);
|
||||||
|
}
|
||||||
|
if (!data.Read("StackSize", stackSize)) {
|
||||||
|
REPORT_ERROR(ErrorManagement::Information, "No StackSize defined. Using default = %d", stackSize);
|
||||||
|
}
|
||||||
|
if (!data.Read("IgnoreBufferOverrun", ignoreBufferOverrun)) {
|
||||||
|
REPORT_ERROR(ErrorManagement::Information, "No IgnoreBufferOverrun defined. Using default = %d", ignoreBufferOverrun);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.MoveRelative("Signals");
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Could not move to the Signals section");
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Copy(originalSignalInformation);
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = originalSignalInformation.MoveToRoot();
|
||||||
|
}
|
||||||
|
//Do not allow to add signals in run-time
|
||||||
|
if (ok) {
|
||||||
|
ok = signalsDatabase.MoveRelative("Signals");
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = signalsDatabase.Write("Locked", 1u);
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = signalsDatabase.MoveToAncestor(1u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.MoveToAncestor(1u);
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAEPICSCAOutput::SetConfiguredDatabase(StructuredDataI & data) {
|
||||||
|
bool ok = DataSourceI::SetConfiguredDatabase(data);
|
||||||
|
//Check the signal index of the timing signal.
|
||||||
|
uint32 nOfSignals = GetNumberOfSignals();
|
||||||
|
if (ok) {
|
||||||
|
ok = (nOfSignals > 0u);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "At least one signal shall be defined");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
//Do not allow samples
|
||||||
|
uint32 functionNumberOfSignals = 0u;
|
||||||
|
uint32 n;
|
||||||
|
if (GetFunctionNumberOfSignals(OutputSignals, 0u, functionNumberOfSignals)) {
|
||||||
|
for (n = 0u; (n < functionNumberOfSignals) && (ok); n++) {
|
||||||
|
uint32 nSamples;
|
||||||
|
ok = GetFunctionSignalSamples(OutputSignals, 0u, n, nSamples);
|
||||||
|
if (ok) {
|
||||||
|
ok = (nSamples == 1u);
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "The number of samples shall be exactly 1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Only one and one GAM allowed to interact with this DataSourceI
|
||||||
|
if (ok) {
|
||||||
|
ok = (GetNumberOfFunctions() == 1u);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Exactly one Function allowed to interact with this DataSourceI");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
pvs = new PVWrapper[nOfSignals];
|
||||||
|
uint32 n;
|
||||||
|
for (n = 0u; (n < nOfSignals); n++) {
|
||||||
|
pvs[n].memory = NULL_PTR(void *); //value to write PV
|
||||||
|
pvs[n].previousValue = NULL_PTR(void *); //written value
|
||||||
|
pvs[n].pvChid = NULL_PTR(chid);
|
||||||
|
|
||||||
|
}
|
||||||
|
for (n = 0u; (n < nOfSignals) && (ok); n++) {
|
||||||
|
//Note that the RealTimeApplicationConfigurationBuilder is allowed to change the order of the signals w.r.t. to the originalSignalInformation
|
||||||
|
StreamString orderedSignalName;
|
||||||
|
ok = GetSignalName(n, orderedSignalName);
|
||||||
|
if (ok) {
|
||||||
|
//Have to mix and match between the original setting of the DataSource signal
|
||||||
|
//and the ones which are later added by the RealTimeApplicationConfigurationBuilder
|
||||||
|
ok = originalSignalInformation.MoveRelative(orderedSignalName.Buffer());
|
||||||
|
}
|
||||||
|
StreamString pvName;
|
||||||
|
if (ok) {
|
||||||
|
ok = originalSignalInformation.Read("PVName", pvName);
|
||||||
|
if (!ok) {
|
||||||
|
uint32 nn = n;
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "No PVName specified for signal at index %d", nn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TypeDescriptor td = GetSignalType(n);
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
(void) StringHelper::CopyN(&pvs[n].pvName[0], pvName.Buffer(), PV_NAME_MAX_SIZE);
|
||||||
|
if (td == CharString) {
|
||||||
|
pvs[n].pvType = DBR_STRING;
|
||||||
|
}
|
||||||
|
else if (td == Character8Bit) {
|
||||||
|
pvs[n].pvType = DBR_STRING;
|
||||||
|
}
|
||||||
|
else if (td == SignedInteger8Bit) {
|
||||||
|
pvs[n].pvType = DBR_CHAR;
|
||||||
|
}
|
||||||
|
else if (td == UnsignedInteger8Bit) {
|
||||||
|
pvs[n].pvType = DBR_CHAR;
|
||||||
|
}
|
||||||
|
else if (td == SignedInteger16Bit) {
|
||||||
|
pvs[n].pvType = DBR_SHORT;
|
||||||
|
}
|
||||||
|
else if (td == UnsignedInteger16Bit) {
|
||||||
|
pvs[n].pvType = DBR_SHORT;
|
||||||
|
}
|
||||||
|
else if (td == SignedInteger32Bit) {
|
||||||
|
pvs[n].pvType = DBR_LONG;
|
||||||
|
}
|
||||||
|
else if (td == UnsignedInteger32Bit) {
|
||||||
|
pvs[n].pvType = DBR_LONG;
|
||||||
|
}
|
||||||
|
else if (td == Float32Bit) {
|
||||||
|
pvs[n].pvType = DBR_FLOAT;
|
||||||
|
}
|
||||||
|
else if (td == Float64Bit) {
|
||||||
|
pvs[n].pvType = DBR_DOUBLE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Type %s is not supported", TypeDescriptor::GetTypeNameFromTypeDescriptor(td));
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uint32 numberOfElements = 1u;
|
||||||
|
if (ok) {
|
||||||
|
ok = GetSignalNumberOfElements(n, numberOfElements);
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
if (pvs[n].pvType == DBR_STRING) {
|
||||||
|
ok = (numberOfElements == 40u);
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
|
//Could support arrays of strings with multiples of char8[40]
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError,
|
||||||
|
"Strings shall be defined with 40 elements char8[40]. Arrays of strings are not currently supported");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
pvs[n].numberOfElements = numberOfElements;
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
pvs[n].memorySize = td.numberOfBits;
|
||||||
|
pvs[n].memorySize /= 8u;
|
||||||
|
pvs[n].memorySize *= numberOfElements;
|
||||||
|
pvs[n].memory = GlobalObjectsDatabase::Instance()->GetStandardHeap()->Malloc(pvs[n].memorySize);
|
||||||
|
pvs[n].previousValue = GlobalObjectsDatabase::Instance()->GetStandardHeap()->Malloc(pvs[n].memorySize);
|
||||||
|
ok = originalSignalInformation.MoveToAncestor(1u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAEPICSCAOutput::AllocateMemory() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 JAEPICSCAOutput::GetNumberOfMemoryBuffers() {
|
||||||
|
return 1u;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: The signalAddress is independent of the bufferIdx.*/
|
||||||
|
bool JAEPICSCAOutput::GetSignalMemoryBuffer(const uint32 signalIdx, const uint32 bufferIdx, void*& signalAddress) {
|
||||||
|
bool ok = (pvs != NULL_PTR(PVWrapper *));
|
||||||
|
if (ok) {
|
||||||
|
ok = (signalIdx < GetNumberOfSignals());
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
//lint -e{613} pvs cannot as otherwise ok would be false
|
||||||
|
signalAddress = pvs[signalIdx].memory;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: The brokerName only depends on the direction */
|
||||||
|
const char8* JAEPICSCAOutput::GetBrokerName(StructuredDataI& data, const SignalDirection direction) {
|
||||||
|
const char8* brokerName = "";
|
||||||
|
if (direction == OutputSignals) {
|
||||||
|
brokerName = "MemoryMapAsyncOutputBroker";
|
||||||
|
}
|
||||||
|
return brokerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: InputBrokers are not supported. Function returns false irrespectively of the parameters.*/
|
||||||
|
bool JAEPICSCAOutput::GetInputBrokers(ReferenceContainer& inputBrokers, const char8* const functionName, void* const gamMemPtr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAEPICSCAOutput::GetOutputBrokers(ReferenceContainer& outputBrokers, const char8* const functionName, void* const gamMemPtr) {
|
||||||
|
ReferenceT<MemoryMapAsyncOutputBroker> broker("MemoryMapAsyncOutputBroker");
|
||||||
|
bool ok = broker->InitWithBufferParameters(OutputSignals, *this, functionName, gamMemPtr, numberOfBuffers, cpuMask, stackSize);
|
||||||
|
if (ok) {
|
||||||
|
ok = outputBrokers.Insert(broker);
|
||||||
|
broker->SetIgnoreBufferOverrun(ignoreBufferOverrun == 1u);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: NOOP at StateChange, independently of the function parameters.*/
|
||||||
|
bool JAEPICSCAOutput::PrepareNextState(const char8* const currentStateName, const char8* const nextStateName) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 JAEPICSCAOutput::GetStackSize() const {
|
||||||
|
return stackSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 JAEPICSCAOutput::GetCPUMask() const {
|
||||||
|
return cpuMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 JAEPICSCAOutput::GetNumberOfBuffers() const {
|
||||||
|
return numberOfBuffers;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAEPICSCAOutput::Synchronise() {
|
||||||
|
bool ok = true;
|
||||||
|
uint32 n;
|
||||||
|
uint32 nOfSignals = GetNumberOfSignals();
|
||||||
|
if (!threadContextSet) {
|
||||||
|
ok = (ca_context_create(ca_enable_preemptive_callback) == ECA_NORMAL);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::FatalError, "ca_enable_preemptive_callback failed");
|
||||||
|
}
|
||||||
|
threadContextSet = ok;
|
||||||
|
if (pvs != NULL_PTR(PVWrapper *)) {
|
||||||
|
for (n = 0u; (n < nOfSignals); n++) {
|
||||||
|
ok = (ca_create_channel(&pvs[n].pvName[0], NULL_PTR(caCh *), NULL_PTR(void *), 20u, &pvs[n].pvChid) == ECA_NORMAL);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::FatalError, "ca_create_channel failed for PV with name %s", pvs[n].pvName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Allow to write event at the first time!
|
||||||
|
if (threadContextSet) {
|
||||||
|
if (pvs != NULL_PTR(PVWrapper *)) {
|
||||||
|
for (n = 0u; (n < nOfSignals); n++) {
|
||||||
|
bool isNewValue = true;
|
||||||
|
if (pvs[n].pvType == DBR_STRING) {
|
||||||
|
if(strcmp((char*)pvs[n].memory,(char*)pvs[n].previousValue)==0){
|
||||||
|
isNewValue = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(isNewValue){
|
||||||
|
ok = (ca_put(pvs[n].pvType, pvs[n].pvChid, pvs[n].memory) == ECA_NORMAL);
|
||||||
|
memcpy(pvs[n].previousValue,pvs[n].memory, pvs[n].numberOfElements);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(memcmp(pvs[n].memory, pvs[n].previousValue, pvs[n].numberOfElements)==0){
|
||||||
|
isNewValue = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(isNewValue){
|
||||||
|
ok = (ca_array_put(pvs[n].pvType, pvs[n].numberOfElements, pvs[n].pvChid, pvs[n].memory) == ECA_NORMAL);
|
||||||
|
memcpy(pvs[n].previousValue, pvs[n].memory, pvs[n].numberOfElements);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::FatalError, "ca_put failed for PV: %s", pvs[n].pvName);
|
||||||
|
}
|
||||||
|
(void) ca_pend_io(0.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAEPICSCAOutput::IsIgnoringBufferOverrun() const {
|
||||||
|
return (ignoreBufferOverrun == 1u);
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JAEPICSCAOutput, "1.0")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,233 @@
|
|||||||
|
/**
|
||||||
|
* @file EPICSCAOutput.h
|
||||||
|
* @brief Header file for class EPICSCAOutput
|
||||||
|
* @date 20/04/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 header file contains the declaration of the class EPICSCAOutput
|
||||||
|
* 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 JAEPICSCAOutput_H_
|
||||||
|
#define JAEPICSCAOutput_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#include <cadef.h>
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#include "DataSourceI.h"
|
||||||
|
#include "JAEPICSCAInput.h"
|
||||||
|
#include "EmbeddedServiceMethodBinderI.h"
|
||||||
|
#include "EventSem.h"
|
||||||
|
#include "SingleThreadService.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
namespace MARTe {
|
||||||
|
//Maximum size that a PV name may have
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A DataSource which allows to output data into any number of PVs using the EPICS channel access client protocol.
|
||||||
|
* Data is asynchronously ca_put in the context of a different thread (w.r.t. to the real-time thread).
|
||||||
|
*
|
||||||
|
* The configuration syntax is (names are only given as an example):
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* +EPICSCAOutput_1 = {
|
||||||
|
* Class = EPICSCA::EPICSCAOutput
|
||||||
|
* StackSize = 1048576 //Optional the EmbeddedThread stack size. Default value is THREADS_DEFAULT_STACKSIZE * 4u
|
||||||
|
* CPUs = 0xff //Optional the affinity of the EmbeddedThread (where the EPICS context is attached).
|
||||||
|
* IgnoreBufferOverrun = 1 //Optional. If true no error will be triggered when the thread that writes into EPICS does not consume the data fast enough.
|
||||||
|
* NumberOfBuffers = 10 //Compulsory. Number of buffers in a circular buffer that asynchronously writes the PV values. Each buffer is capable of holding a copy of all the DataSourceI signals.
|
||||||
|
* Signals = {
|
||||||
|
* PV1 = { //At least one shall be defined
|
||||||
|
* PVName = My::PV1 //Compulsory. Name of the PV.
|
||||||
|
* Type = uint32 //Compulsory. Supported types are char8[40], string[40], uint8, int8, uint16, int16, int32, uint32, float32 and float64
|
||||||
|
* }
|
||||||
|
* ...
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
class JAEPICSCAOutput: public DataSourceI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Default constructor. NOOP.
|
||||||
|
*/
|
||||||
|
JAEPICSCAOutput();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Destructor.
|
||||||
|
* @details TODO.
|
||||||
|
*/
|
||||||
|
virtual ~JAEPICSCAOutput();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief See DataSourceI::AllocateMemory. NOOP.
|
||||||
|
* @return true.
|
||||||
|
*/
|
||||||
|
virtual bool AllocateMemory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief See DataSourceI::GetNumberOfMemoryBuffers.
|
||||||
|
* @return 1.
|
||||||
|
*/
|
||||||
|
virtual uint32 GetNumberOfMemoryBuffers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief See DataSourceI::GetSignalMemoryBuffer.
|
||||||
|
* @pre
|
||||||
|
* SetConfiguredDatabase
|
||||||
|
*/
|
||||||
|
virtual bool GetSignalMemoryBuffer(const uint32 signalIdx,
|
||||||
|
const uint32 bufferIdx,
|
||||||
|
void *&signalAddress);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief See DataSourceI::GetNumberOfMemoryBuffers.
|
||||||
|
* @details Only OutputSignals are supported.
|
||||||
|
* @return MemoryMapAsyncOutputBroker.
|
||||||
|
*/
|
||||||
|
virtual const char8 *GetBrokerName(StructuredDataI &data,
|
||||||
|
const SignalDirection direction);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief See DataSourceI::GetInputBrokers.
|
||||||
|
* @return false.
|
||||||
|
*/
|
||||||
|
virtual bool GetInputBrokers(ReferenceContainer &inputBrokers,
|
||||||
|
const char8* const functionName,
|
||||||
|
void * const gamMemPtr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief See DataSourceI::GetOutputBrokers.
|
||||||
|
* @details adds a memory MemoryMapOutputBroker instance to the outputBrokers
|
||||||
|
* @return true.
|
||||||
|
*/
|
||||||
|
virtual bool GetOutputBrokers(ReferenceContainer &outputBrokers,
|
||||||
|
const char8* const functionName,
|
||||||
|
void * const gamMemPtr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief See DataSourceI::PrepareNextState. NOOP.
|
||||||
|
* @return true.
|
||||||
|
*/
|
||||||
|
virtual bool PrepareNextState(const char8 * const currentStateName,
|
||||||
|
const char8 * const nextStateName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Loads and verifies the configuration parameters detailed in the class description.
|
||||||
|
* @return true if all the mandatory parameters are correctly specified and if the specified optional parameters have valid values.
|
||||||
|
*/
|
||||||
|
virtual bool Initialise(StructuredDataI & data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Final verification of all the parameters. Setup of the memory required to hold all the signals.
|
||||||
|
* @details This method verifies that all the parameters requested by the GAMs interacting with this DataSource
|
||||||
|
* are valid and consistent with the parameters set during the initialisation phase.
|
||||||
|
* In particular the following conditions shall be met:
|
||||||
|
* - All the signals have the PVName defined
|
||||||
|
* - All the signals have one of the following types: uint32, int32, float32 or float64.
|
||||||
|
* @return true if all the parameters are valid and the conditions above are met.
|
||||||
|
*/
|
||||||
|
virtual bool SetConfiguredDatabase(StructuredDataI & data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the affinity of the thread which is going to be used to asynchronously write data with ca_put.
|
||||||
|
* @return the affinity of the thread which is going to be used to asynchronously write data with ca_put.
|
||||||
|
*/
|
||||||
|
uint32 GetCPUMask() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the stack size of the thread which is going to be used to asynchronously write data with ca_put.
|
||||||
|
* @return the stack size of the thread which is going to be used to asynchronously write data with ca_put.
|
||||||
|
*/
|
||||||
|
uint32 GetStackSize() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the number of buffers in the circular buffer that asynchronously writes the PV values.
|
||||||
|
* @return the number of buffers in the circular buffer that asynchronously writes the PV values.
|
||||||
|
*/
|
||||||
|
uint32 GetNumberOfBuffers() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Provides the context to execute all the EPICS ca_put calls.
|
||||||
|
* @details Executes in the context of the MemoryMapAsyncOutputBroker thread the following EPICS calls:
|
||||||
|
* ca_context_create, ca_create_channel, ca_create_subscription, ca_clear_subscription,
|
||||||
|
* ca_clear_event, ca_clear_channel, ca_detach_context and ca_context_destroy
|
||||||
|
* @return true if all the EPICS calls return without any error.
|
||||||
|
*/
|
||||||
|
virtual bool Synchronise();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets if buffer overruns is being ignored (i.e. the consumer thread which writes into EPICS is not consuming the data fast enough).
|
||||||
|
* @return if true no error is to be triggered when there is a buffer overrun.
|
||||||
|
*/
|
||||||
|
bool IsIgnoringBufferOverrun() const;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* List of PVs.
|
||||||
|
*/
|
||||||
|
PVWrapper *pvs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The CPU mask for the executor
|
||||||
|
*/
|
||||||
|
uint32 cpuMask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The stack size
|
||||||
|
*/
|
||||||
|
uint32 stackSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the configuration information received at Initialise.
|
||||||
|
*/
|
||||||
|
ConfigurationDatabase originalSignalInformation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of buffers for the circular buffer that flushes data into EPICS
|
||||||
|
*/
|
||||||
|
uint32 numberOfBuffers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True once the epics thread context is set
|
||||||
|
*/
|
||||||
|
bool threadContextSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If true no error will be triggered when the data cannot be consumed by the thread doing the caputs.
|
||||||
|
*/
|
||||||
|
uint32 ignoreBufferOverrun;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* EPICSCADATASOURCE_H_ */
|
||||||
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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$(EPICS_BASE)/lib/$(EPICS_HOST_ARCH)/ -lca
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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=JAEPICSCAOutput.x JAEPICSCAInput.x
|
||||||
|
|
||||||
|
PACKAGE=DataSources
|
||||||
|
|
||||||
|
ROOT_DIR=../../../../obj
|
||||||
|
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
|
||||||
|
|
||||||
|
INCLUDES += -I.
|
||||||
|
INCLUDES += -I$(EPICS_BASE)/include/
|
||||||
|
INCLUDES += -I$(EPICS_BASE)/include/os/Linux/
|
||||||
|
INCLUDES += -I$(EPICS_BASE)/include/compiler/gcc/
|
||||||
|
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$(MARTe2_DIR)/Source/Core/Scheduler/L5GAMs
|
||||||
|
|
||||||
|
all: $(OBJS) $(SUBPROJ) \
|
||||||
|
$(BUILD_DIR)/JAEPICSCA$(LIBEXT) \
|
||||||
|
$(BUILD_DIR)/JAEPICSCA$(DLLEXT)
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include depends.$(TARGET)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
|
|
||||||
28
EC-GN-JA-PCF-IN/src/main/c++/DataSources/Makefile
Normal file
28
EC-GN-JA-PCF-IN/src/main/c++/DataSources/Makefile
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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 $
|
||||||
|
#
|
||||||
|
#############################################################
|
||||||
|
export TARGET=x86-linux
|
||||||
|
|
||||||
|
include Makefile.gcc
|
||||||
26
EC-GN-JA-PCF-IN/src/main/c++/DataSources/Makefile.gcc
Normal file
26
EC-GN-JA-PCF-IN/src/main/c++/DataSources/Makefile.gcc
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
#############################################################
|
||||||
|
|
||||||
|
include Makefile.inc
|
||||||
|
|
||||||
42
EC-GN-JA-PCF-IN/src/main/c++/DataSources/Makefile.inc
Normal file
42
EC-GN-JA-PCF-IN/src/main/c++/DataSources/Makefile.inc
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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 $
|
||||||
|
#
|
||||||
|
#############################################################
|
||||||
|
SPB = RandomDataSource.x NI6528.x JAEPICSCA.x
|
||||||
|
|
||||||
|
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
|
||||||
|
|
||||||
|
ROOT_DIR=../../../obj
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
|
||||||
|
|
||||||
|
all: $(OBJS) $(SUBPROJ) check-env
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
|
|
||||||
|
check-env:
|
||||||
|
ifndef MARTe2_DIR
|
||||||
|
$(error MARTe2_DIR is undefined)
|
||||||
|
endif
|
||||||
|
|
||||||
30
EC-GN-JA-PCF-IN/src/main/c++/DataSources/NI6528/Makefile.gcc
Normal file
30
EC-GN-JA-PCF-IN/src/main/c++/DataSources/NI6528/Makefile.gcc
Normal file
@@ -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
|
||||||
|
|
||||||
53
EC-GN-JA-PCF-IN/src/main/c++/DataSources/NI6528/Makefile.inc
Normal file
53
EC-GN-JA-PCF-IN/src/main/c++/DataSources/NI6528/Makefile.inc
Normal file
@@ -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=../../../../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
|
||||||
|
INCLUDES += -I$(CODAC_ROOT)/include/
|
||||||
|
|
||||||
|
all: $(OBJS) $(SUBPROJ) \
|
||||||
|
$(BUILD_DIR)/NI6528$(LIBEXT) \
|
||||||
|
$(BUILD_DIR)/NI6528$(DLLEXT)
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
|
|
||||||
141
EC-GN-JA-PCF-IN/src/main/c++/DataSources/NI6528/NI6528.cpp
Normal file
141
EC-GN-JA-PCF-IN/src/main/c++/DataSources/NI6528/NI6528.cpp
Normal file
@@ -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")
|
||||||
|
|
||||||
143
EC-GN-JA-PCF-IN/src/main/c++/DataSources/NI6528/NI6528.h
Normal file
143
EC-GN-JA-PCF-IN/src/main/c++/DataSources/NI6528/NI6528.h
Normal file
@@ -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_ */
|
||||||
|
|
||||||
@@ -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_ */
|
||||||
|
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
/**
|
||||||
|
* @file JABitReverseGAM.cpp
|
||||||
|
* @brief Source file for class JABitReverseGAM
|
||||||
|
* @date Nov 26, 2018
|
||||||
|
* @author aneto
|
||||||
|
*
|
||||||
|
* @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 JABitReverseGAM (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 "JABitReverseGAM.h"
|
||||||
|
|
||||||
|
#include "AdvancedErrorManagement.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
JABitReverseGAM::JABitReverseGAM() {
|
||||||
|
//Input signals.
|
||||||
|
input1 = NULL_PTR(MARTe::uint8 *);
|
||||||
|
|
||||||
|
//Output signals.
|
||||||
|
output1= NULL_PTR(MARTe::uint8 *);
|
||||||
|
}
|
||||||
|
|
||||||
|
JABitReverseGAM::~JABitReverseGAM() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JABitReverseGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||||
|
//GAM parameters are initialized.
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = GAM::Initialise(data);
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JABitReverseGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||||
|
//This method changes internal parameter based on next realtime state.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JABitReverseGAM::Setup() {
|
||||||
|
// Setup memory for input/output signals on the GAM.
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = (numberOfInputSignals == 1u);
|
||||||
|
if (ok) {
|
||||||
|
ok = (numberOfOutputSignals == 1u);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "One output signal shall be defined");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "One input signals shall be defined");
|
||||||
|
}
|
||||||
|
// Do type check for input signals.
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||||
|
ok = ((inputType == UnsignedInteger8Bit));
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint8.", signalName.Buffer());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Do type check for output signals
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfOutputSignals; c++) {
|
||||||
|
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
|
||||||
|
ok = ((outputType == UnsignedInteger8Bit));
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint8.", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Do type cast.
|
||||||
|
if (ok) {
|
||||||
|
input1 = reinterpret_cast<uint8 *>(GetInputSignalMemory(0));
|
||||||
|
|
||||||
|
output1 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(0));
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JABitReverseGAM::Execute() {
|
||||||
|
// This method is called every realtime state thread cycle.
|
||||||
|
using namespace MARTe;
|
||||||
|
*output1 = ~(*input1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JABitReverseGAM, "1.0")
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/**
|
||||||
|
* @file JABitReverseGAM.h
|
||||||
|
* @brief Header file for class JABitReverseGAM
|
||||||
|
* @date Mar 18, 2020
|
||||||
|
* @author kuchida
|
||||||
|
*
|
||||||
|
* @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 JABitReverseGAM
|
||||||
|
* 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 GAMS_JABitReverseGAM_H_
|
||||||
|
#define GAMS_JABitReverseGAM_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "GAM.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class JABitReverseGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
JABitReverseGAM();
|
||||||
|
|
||||||
|
virtual ~JABitReverseGAM();
|
||||||
|
|
||||||
|
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||||
|
|
||||||
|
virtual bool Setup();
|
||||||
|
|
||||||
|
virtual bool Execute();
|
||||||
|
|
||||||
|
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
|
||||||
|
const MARTe::char8 * const nextStateName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
//The list of possible states
|
||||||
|
|
||||||
|
// Input signals
|
||||||
|
MARTe::uint8 *input1;
|
||||||
|
|
||||||
|
// Output signals
|
||||||
|
MARTe::uint8 *output1;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* GAMS_JABitReverseGAM_H_ */
|
||||||
@@ -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,55 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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=JABitReverseGAM.x
|
||||||
|
|
||||||
|
PACKAGE=GAMs
|
||||||
|
|
||||||
|
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
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
all: $(OBJS) $(SUBPROJ) \
|
||||||
|
$(BUILD_DIR)/JABitReverseGAM$(LIBEXT) \
|
||||||
|
$(BUILD_DIR)/JABitReverseGAM$(DLLEXT)
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
143
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JABitSumGAM/JABitSumGAM.cpp
Normal file
143
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JABitSumGAM/JABitSumGAM.cpp
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
/**
|
||||||
|
* @file JABitSumGAM.cpp
|
||||||
|
* @brief Source file for class JABitSumGAM
|
||||||
|
* @date Feb 10, 2020
|
||||||
|
* @author kuchida
|
||||||
|
*
|
||||||
|
* @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 JABitSumGAM (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 "JABitSumGAM.h"
|
||||||
|
|
||||||
|
#include "AdvancedErrorManagement.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
JABitSumGAM::JABitSumGAM() {
|
||||||
|
//Input signals.
|
||||||
|
input0 = NULL_PTR(MARTe::uint32 *);
|
||||||
|
input1 = NULL_PTR(MARTe::uint32 *);
|
||||||
|
input2 = NULL_PTR(MARTe::uint32 *);
|
||||||
|
input3 = NULL_PTR(MARTe::uint32 *);
|
||||||
|
input4 = NULL_PTR(MARTe::uint32 *);
|
||||||
|
input5 = NULL_PTR(MARTe::uint32 *);
|
||||||
|
input6 = NULL_PTR(MARTe::uint32 *);
|
||||||
|
input7 = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
//Output signals.
|
||||||
|
output= NULL_PTR(MARTe::uint8 *);
|
||||||
|
}
|
||||||
|
|
||||||
|
JABitSumGAM::~JABitSumGAM() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JABitSumGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||||
|
//GAM parameters are initialized.
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = GAM::Initialise(data);
|
||||||
|
if (!ok){
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "ParametersError in init.");
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JABitSumGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||||
|
//This method changes internal parameter based on next realtime state.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JABitSumGAM::Setup() {
|
||||||
|
// Setup memory for input/output signals on the GAM.
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = (numberOfInputSignals == 8u);
|
||||||
|
if (ok) {
|
||||||
|
ok = (numberOfOutputSignals == 1u);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "One output signal shall be defined");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Eight input signals shall be defined");
|
||||||
|
}
|
||||||
|
// Do type check for input signals.
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||||
|
ok = (inputType == UnsignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32.", signalName.Buffer());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Do type check for output signals
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfOutputSignals; c++) {
|
||||||
|
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
|
||||||
|
ok = (outputType == UnsignedInteger8Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint8.", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Do type cast.
|
||||||
|
if (ok) {
|
||||||
|
input0 = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||||
|
input1 = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
|
||||||
|
input2 = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
|
||||||
|
input3 = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
|
||||||
|
input4 = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
|
||||||
|
input5 = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
|
||||||
|
input6 = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
|
||||||
|
input7 = reinterpret_cast<uint32 *>(GetInputSignalMemory(7));
|
||||||
|
|
||||||
|
output = reinterpret_cast<uint8 *>(GetOutputSignalMemory(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JABitSumGAM::Execute() {
|
||||||
|
// This method is called every realtime state thread cycle.
|
||||||
|
using namespace MARTe;
|
||||||
|
*output = *input0 + *input1*2 + *input2*4 + *input3*8 + *input4*16 +
|
||||||
|
*input5*32 + *input6*64 + *input7*128;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JABitSumGAM, "1.0")
|
||||||
81
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JABitSumGAM/JABitSumGAM.h
Normal file
81
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JABitSumGAM/JABitSumGAM.h
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
/**
|
||||||
|
* @file JABitSumGAM.h
|
||||||
|
* @brief Header file for class JABitSumGAM
|
||||||
|
* @date Feb 10, 2020
|
||||||
|
* @author kuchida
|
||||||
|
*
|
||||||
|
* @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 JABitSumGAM
|
||||||
|
* 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 GAMS_JABitSumGAM_H_
|
||||||
|
#define GAMS_JABitSumGAM_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "GAM.h"
|
||||||
|
#include "stdio.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class JABitSumGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
JABitSumGAM();
|
||||||
|
|
||||||
|
virtual ~JABitSumGAM();
|
||||||
|
|
||||||
|
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||||
|
|
||||||
|
virtual bool Setup();
|
||||||
|
|
||||||
|
virtual bool Execute();
|
||||||
|
|
||||||
|
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
|
||||||
|
const MARTe::char8 * const nextStateName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Input signals
|
||||||
|
MARTe::uint32 *input0;
|
||||||
|
MARTe::uint32 *input1;
|
||||||
|
MARTe::uint32 *input2;
|
||||||
|
MARTe::uint32 *input3;
|
||||||
|
MARTe::uint32 *input4;
|
||||||
|
MARTe::uint32 *input5;
|
||||||
|
MARTe::uint32 *input6;
|
||||||
|
MARTe::uint32 *input7;
|
||||||
|
|
||||||
|
// Output signals
|
||||||
|
MARTe::uint8 *output;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* GAMS_JABitSumGAM_H_ */
|
||||||
27
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JABitSumGAM/Makefile.gcc
Normal file
27
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JABitSumGAM/Makefile.gcc
Normal file
@@ -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
|
||||||
55
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JABitSumGAM/Makefile.inc
Normal file
55
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JABitSumGAM/Makefile.inc
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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=JABitSumGAM.x
|
||||||
|
|
||||||
|
PACKAGE=GAMs
|
||||||
|
|
||||||
|
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
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
all: $(OBJS) $(SUBPROJ) \
|
||||||
|
$(BUILD_DIR)/JABitSumGAM$(LIBEXT) \
|
||||||
|
$(BUILD_DIR)/JABitSumGAM$(DLLEXT)
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
@@ -0,0 +1,309 @@
|
|||||||
|
/**
|
||||||
|
* @file JAConditionalSignalUpdateGAM.cpp
|
||||||
|
* @brief Source file for class JAConditionalSignalUpdateGAM
|
||||||
|
* @date Jan, 2019
|
||||||
|
* @author rhari
|
||||||
|
*
|
||||||
|
* @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 JAConditionalSignalUpdateGAM (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 "JAConditionalSignalUpdateGAM.h"
|
||||||
|
#include "AdvancedErrorManagement.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
JAConditionalSignalUpdateGAM::JAConditionalSignalUpdateGAM() {
|
||||||
|
inputSignals = NULL_PTR(void **);
|
||||||
|
inputSignalTypes = NULL_PTR(MARTe::TypeDescriptor *);
|
||||||
|
values = NULL_PTR(MARTe::uint32 *);
|
||||||
|
valuesCount = 0u;
|
||||||
|
outputSignals = NULL_PTR(MARTe::uint32 **);
|
||||||
|
defaultValues = NULL_PTR(MARTe::uint32 **);
|
||||||
|
needsReset = false;
|
||||||
|
expectedValues = NULL_PTR(MARTe::uint32 *);
|
||||||
|
expectedValuesCount = 0u;
|
||||||
|
operation = And;
|
||||||
|
comparators = NULL_PTR(ComparisonMode *);
|
||||||
|
}
|
||||||
|
|
||||||
|
JAConditionalSignalUpdateGAM::~JAConditionalSignalUpdateGAM() {
|
||||||
|
if (outputSignals != NULL_PTR(MARTe::uint32 **)) {
|
||||||
|
delete[] outputSignals;
|
||||||
|
}
|
||||||
|
if (inputSignals != NULL_PTR(void **)) {
|
||||||
|
delete[] inputSignals;
|
||||||
|
}
|
||||||
|
if (inputSignalTypes != NULL_PTR(MARTe::TypeDescriptor *)) {
|
||||||
|
delete[] inputSignalTypes;
|
||||||
|
}
|
||||||
|
if (values != NULL_PTR(MARTe::uint32 *)) {
|
||||||
|
delete[] values;
|
||||||
|
}
|
||||||
|
if (comparators != NULL_PTR(ComparisonMode *)) {
|
||||||
|
delete[] comparators;
|
||||||
|
}
|
||||||
|
if (defaultValues != NULL_PTR(MARTe::uint32 **)) {
|
||||||
|
delete[] defaultValues;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAConditionalSignalUpdateGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = GAM::Initialise(data);
|
||||||
|
if (ok) {
|
||||||
|
// Read expected values.
|
||||||
|
AnyType valuesArray = data.GetType("ExpectedValues");
|
||||||
|
|
||||||
|
if (valuesArray.GetDataPointer() != NULL) {
|
||||||
|
expectedValuesCount = valuesArray.GetNumberOfElements(0u);
|
||||||
|
|
||||||
|
expectedValues = new uint32[expectedValuesCount];
|
||||||
|
|
||||||
|
Vector<uint32> valuesVector(expectedValues, expectedValuesCount);
|
||||||
|
ok = (data.Read("ExpectedValues", valuesVector));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
// Read comparators.
|
||||||
|
AnyType comparatorsArray = data.GetType("Comparators");
|
||||||
|
if (comparatorsArray.GetDataPointer() != NULL) {
|
||||||
|
uint32 count;
|
||||||
|
if (ok) {
|
||||||
|
count = comparatorsArray.GetNumberOfElements(0u);
|
||||||
|
ok = count == expectedValuesCount;
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
comparators = new ComparisonMode[count];
|
||||||
|
StreamString* comp = new StreamString[count];
|
||||||
|
Vector<StreamString> compVector(comp, count);
|
||||||
|
|
||||||
|
ok = (data.Read("Comparators", compVector));
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
for (uint32 i = 0; i < count; ++i) {
|
||||||
|
if (comp[i] == "EQUALS") {
|
||||||
|
comparators[i] = Equals;
|
||||||
|
} else if (comp[i] == "NOT") {
|
||||||
|
comparators[i] = Not;
|
||||||
|
} else if (comp[i] == "GREATER") {
|
||||||
|
comparators[i] = Greater;
|
||||||
|
} else if (comp[i] == "EQUALS_OR_GREATER") {
|
||||||
|
comparators[i] = EqualsOrGreater;
|
||||||
|
} else if (comp[i] == "LESS") {
|
||||||
|
comparators[i] = Less;
|
||||||
|
} else if (comp[i] == "EQUALS_OR_LESS") {
|
||||||
|
comparators[i] = EqualsOrLess;
|
||||||
|
} else {
|
||||||
|
ok = false;
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Comparator %s is not defined.", comp[i].Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete[] comp;
|
||||||
|
} else {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Expected values and operators shall have the same "
|
||||||
|
"number of elements.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Create default comparators (equals) when they aren't provided in the configuration.
|
||||||
|
comparators = new ComparisonMode[expectedValuesCount];
|
||||||
|
for (uint32 i = 0; i < expectedValuesCount; ++i) {
|
||||||
|
comparators[i] = Equals;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
MARTe::StreamString operationStr;
|
||||||
|
if (data.Read("Operation", operationStr)) {
|
||||||
|
if (operationStr == "AND") {
|
||||||
|
operation = And;
|
||||||
|
}
|
||||||
|
else if (operationStr == "OR") {
|
||||||
|
operation = Or;
|
||||||
|
}
|
||||||
|
else if (operationStr == "NOR") {
|
||||||
|
operation = Nor;
|
||||||
|
}
|
||||||
|
else if (operationStr == "XOR") {
|
||||||
|
operation = Xor;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ok = false;
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Operation %s is not defined", operationStr.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
// Read output signal values to be set.
|
||||||
|
AnyType valuesArray = data.GetType("Values");
|
||||||
|
ok = (valuesArray.GetDataPointer() != NULL);
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
valuesCount = valuesArray.GetNumberOfElements(0u);
|
||||||
|
ok = valuesCount > 0u;
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
values = new uint32[valuesCount];
|
||||||
|
|
||||||
|
Vector<uint32> valuesVector(values, valuesCount);
|
||||||
|
ok = (data.Read("Values", valuesVector));
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Values shall be defined.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAConditionalSignalUpdateGAM::Setup() {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = numberOfInputSignals == (expectedValuesCount + numberOfOutputSignals);
|
||||||
|
if (ok) {
|
||||||
|
inputSignals = new void*[expectedValuesCount];
|
||||||
|
defaultValues = new uint32*[numberOfOutputSignals];
|
||||||
|
uint32 i;
|
||||||
|
for (i = 0u; i < expectedValuesCount; i++) {
|
||||||
|
inputSignals[i] = GetInputSignalMemory(i);
|
||||||
|
}
|
||||||
|
for (; i < numberOfInputSignals; i++) {
|
||||||
|
defaultValues[i - expectedValuesCount] = reinterpret_cast<uint32 *>(GetInputSignalMemory(i));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Number of input signals shall be equal to number "
|
||||||
|
"of expected values plus number of output signals.");
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
inputSignalTypes = new TypeDescriptor[expectedValuesCount];
|
||||||
|
uint32 i;
|
||||||
|
for (i = 0u; (i < expectedValuesCount) && (ok); i++) {
|
||||||
|
inputSignalTypes[i] = GetSignalType(InputSignals, i);
|
||||||
|
ok = ((inputSignalTypes[i] == UnsignedInteger32Bit) || (inputSignalTypes[i] == UnsignedInteger16Bit));
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, i, signalName);
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or uint16", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = numberOfOutputSignals == valuesCount;
|
||||||
|
if (ok) {
|
||||||
|
ok = numberOfOutputSignals > 0u;
|
||||||
|
if (ok) {
|
||||||
|
outputSignals = new uint32*[numberOfOutputSignals];
|
||||||
|
uint32 i;
|
||||||
|
for (i = 0u; i < numberOfOutputSignals; i++) {
|
||||||
|
outputSignals[i] = reinterpret_cast<uint32 *>(GetOutputSignalMemory(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "At least one output signal shall be defined");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Number of output signals shall be the same as "
|
||||||
|
"number of provided values.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAConditionalSignalUpdateGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||||
|
needsReset = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAConditionalSignalUpdateGAM::Execute() {
|
||||||
|
if (!needsReset) {
|
||||||
|
bool eventDetected = expectedValuesCount == 0;
|
||||||
|
if (!eventDetected) {
|
||||||
|
if (operation == Or) {
|
||||||
|
MARTe::uint32 j;
|
||||||
|
for (j = 0; (j < expectedValuesCount) && (!eventDetected); j++) {
|
||||||
|
eventDetected = Compare(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (operation == Nor) {
|
||||||
|
MARTe::uint32 j;
|
||||||
|
for (j = 0; (j < expectedValuesCount) && (!eventDetected); j++) {
|
||||||
|
eventDetected = Compare(j);
|
||||||
|
}
|
||||||
|
eventDetected = !eventDetected;
|
||||||
|
}
|
||||||
|
else if (operation == And) {
|
||||||
|
MARTe::uint32 j;
|
||||||
|
eventDetected = Compare(0);
|
||||||
|
for (j = 1; (j < expectedValuesCount); j++) {
|
||||||
|
eventDetected &= Compare(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (operation == Xor) {
|
||||||
|
MARTe::uint32 j;
|
||||||
|
MARTe::uint32 eventDetectedUint32;
|
||||||
|
if (inputSignalTypes[0] == MARTe::UnsignedInteger32Bit) {
|
||||||
|
eventDetectedUint32 = *static_cast<MARTe::uint32 *>(inputSignals[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
eventDetectedUint32 = *static_cast<MARTe::uint16 *>(inputSignals[0]);
|
||||||
|
}
|
||||||
|
for (j = 1; (j < expectedValuesCount); j++) {
|
||||||
|
eventDetectedUint32 ^= Compare(j);
|
||||||
|
}
|
||||||
|
eventDetected = (eventDetectedUint32 == 1u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (eventDetected) {
|
||||||
|
needsReset = true;
|
||||||
|
MARTe::uint32 i;
|
||||||
|
for (i = 0u; i < numberOfOutputSignals; ++i) {
|
||||||
|
*outputSignals[i] = values[i];
|
||||||
|
MARTe::StreamString signalName;
|
||||||
|
(void) GetSignalName(MARTe::OutputSignals, i, signalName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MARTe::uint32 i;
|
||||||
|
for (i = 0u; i < numberOfOutputSignals; ++i) {
|
||||||
|
*outputSignals[i] = *defaultValues[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAConditionalSignalUpdateGAM::Compare(MARTe::uint32 index) {
|
||||||
|
if (inputSignalTypes[index] == MARTe::UnsignedInteger32Bit) {
|
||||||
|
return Compare<MARTe::uint32>(index);
|
||||||
|
}
|
||||||
|
return Compare<MARTe::uint16>(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JAConditionalSignalUpdateGAM, "1.0")
|
||||||
@@ -0,0 +1,180 @@
|
|||||||
|
/**
|
||||||
|
* @file JAConditionalSignalUpdateGAM.h
|
||||||
|
* @brief Header file for class JAConditionalSignalUpdateGAM
|
||||||
|
* @date Jan, 2019
|
||||||
|
* @author rhari
|
||||||
|
*
|
||||||
|
* @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 JAConditionalSignalUpdateGAM
|
||||||
|
* 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 GAMS_JACONDITIONALSIGNALUPDATEGAM_H_
|
||||||
|
#define GAMS_JACONDITIONALSIGNALUPDATEGAM_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#include "GAM.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GAM that writes predefined values to output signals when a condition is met.
|
||||||
|
* If there are no conditional signals provided, the condition is presumed to be met.
|
||||||
|
*
|
||||||
|
* +ASYNCShotlengthControlGAM = {
|
||||||
|
* Class = JAConditionalSignalUpdateGAM
|
||||||
|
* Operation = OR // Logical operation performed between conditional signals
|
||||||
|
* // Supported values: AND, OR, XOR, NOR
|
||||||
|
* // Default: AND
|
||||||
|
* ExpectedValues = {1 1} // Values to which conditional signals will be compared.
|
||||||
|
* Comparators = {EQUALS EQUALS} // Operator between conditional signal an expected value
|
||||||
|
* // Supported values: EQUALS, NOT, GREATER, EQUALS_OR_GREATER, LESS, EQUALS_OR_LESS
|
||||||
|
* // Default: EQUALS
|
||||||
|
* Values = {0 3} // Values that will be written to output signals when condition is met.
|
||||||
|
* InputSignals = {
|
||||||
|
* // Conditional Signals
|
||||||
|
* SHOTLEN_FLAG = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* MODE_SHOTLEN_FLAG = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* // Default values (set to output signals before the condition is met)
|
||||||
|
* APS_SWON = { // APS_SWON will keep the value from previous state.
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* BPS_SWON_DEFAULT = { // BPS_SWON will be set to 7 before condition is met.
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* Default = 7
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* OutputSignals = {
|
||||||
|
* APS_SWON = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* BPS_SWON = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
class JAConditionalSignalUpdateGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
JAConditionalSignalUpdateGAM();
|
||||||
|
|
||||||
|
virtual ~JAConditionalSignalUpdateGAM();
|
||||||
|
|
||||||
|
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||||
|
|
||||||
|
virtual bool Setup();
|
||||||
|
|
||||||
|
virtual bool Execute();
|
||||||
|
|
||||||
|
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
|
||||||
|
const MARTe::char8 * const nextStateName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief Does the input signal at provided index have the expected value.
|
||||||
|
* @param[in] index of the signal.
|
||||||
|
* @return true if the signal has expected value.
|
||||||
|
*/
|
||||||
|
bool Compare(MARTe::uint32 index);
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
bool Compare(MARTe::uint32 index);
|
||||||
|
|
||||||
|
enum OperationMode {
|
||||||
|
And, Or, Xor, Nor
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ComparisonMode {
|
||||||
|
Equals, Not, Greater, EqualsOrGreater, Less, EqualsOrLess
|
||||||
|
};
|
||||||
|
|
||||||
|
// Input signals
|
||||||
|
void **inputSignals;
|
||||||
|
|
||||||
|
MARTe::TypeDescriptor *inputSignalTypes;
|
||||||
|
|
||||||
|
// Condition operation.
|
||||||
|
OperationMode operation;
|
||||||
|
|
||||||
|
// Array of expected values of input signals.
|
||||||
|
MARTe::uint32* expectedValues;
|
||||||
|
|
||||||
|
// Expected values count (must be equal to numberOfInputSignals)
|
||||||
|
MARTe::uint32 expectedValuesCount;
|
||||||
|
|
||||||
|
// Array of comparators
|
||||||
|
ComparisonMode* comparators;
|
||||||
|
|
||||||
|
// Values to be written on output signals when input signal has the expected value.
|
||||||
|
MARTe::uint32 *values;
|
||||||
|
|
||||||
|
// Number of values (must be equal to numberOfOutputSignals)
|
||||||
|
MARTe::uint32 valuesCount;
|
||||||
|
|
||||||
|
// Output signals
|
||||||
|
MARTe::uint32 **outputSignals;
|
||||||
|
|
||||||
|
// Default values of output signals
|
||||||
|
MARTe::uint32 **defaultValues;
|
||||||
|
|
||||||
|
// Were output signals already set and we are waiting for a state change before they are set again.
|
||||||
|
bool needsReset;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
bool JAConditionalSignalUpdateGAM::Compare(MARTe::uint32 index) {
|
||||||
|
switch (comparators[index]) {
|
||||||
|
case Equals:
|
||||||
|
return *static_cast<T *>(inputSignals[index]) == static_cast<T>(expectedValues[index]);
|
||||||
|
case Not:
|
||||||
|
return *static_cast<T *>(inputSignals[index]) != static_cast<T>(expectedValues[index]);
|
||||||
|
case Greater:
|
||||||
|
return *static_cast<T *>(inputSignals[index]) > static_cast<T>(expectedValues[index]);
|
||||||
|
case EqualsOrGreater:
|
||||||
|
return *static_cast<T *>(inputSignals[index]) >= static_cast<T>(expectedValues[index]);
|
||||||
|
case Less:
|
||||||
|
return *static_cast<T *>(inputSignals[index]) < static_cast<T>(expectedValues[index]);
|
||||||
|
default: // case EqualsOrLess:
|
||||||
|
return *static_cast<T *>(inputSignals[index]) <= static_cast<T>(expectedValues[index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* GAMS_JACONDITIONALSIGNALUPDATEGAM_H_ */
|
||||||
@@ -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=JAConditionalSignalUpdateGAM.x
|
||||||
|
|
||||||
|
PACKAGE=GAMs
|
||||||
|
|
||||||
|
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)/JAConditionalSignalUpdateGAM$(LIBEXT) \
|
||||||
|
$(BUILD_DIR)/JAConditionalSignalUpdateGAM$(DLLEXT)
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
|
|
||||||
347
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JAMessageGAM/JAMessageGAM.cpp
Normal file
347
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JAMessageGAM/JAMessageGAM.cpp
Normal file
@@ -0,0 +1,347 @@
|
|||||||
|
/**
|
||||||
|
* @file JAMessageGAM.cpp
|
||||||
|
* @brief Source file for class JAMessageGAM
|
||||||
|
* @date Jan, 2019
|
||||||
|
* @author rhari
|
||||||
|
*
|
||||||
|
* @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 JAMessageGAM (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 "JAMessageGAM.h"
|
||||||
|
#include "MessageI.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class T, class U>
|
||||||
|
bool Compare(JAMessageGAM::ComparisonMode comparator, void *inputSignal, U expectedValue) {
|
||||||
|
switch (comparator) {
|
||||||
|
case JAMessageGAM::Equals:
|
||||||
|
return *static_cast<T *>(inputSignal) == expectedValue;
|
||||||
|
case JAMessageGAM::Not:
|
||||||
|
return *static_cast<T *>(inputSignal) != expectedValue;
|
||||||
|
case JAMessageGAM::Greater:
|
||||||
|
return *static_cast<T *>(inputSignal) > expectedValue;
|
||||||
|
case JAMessageGAM::EqualsOrGreater:
|
||||||
|
return *static_cast<T *>(inputSignal) >= expectedValue;
|
||||||
|
case JAMessageGAM::Less:
|
||||||
|
return *static_cast<T *>(inputSignal) < expectedValue;
|
||||||
|
default: // case EqualsOrLess:
|
||||||
|
return *static_cast<T *>(inputSignal) <= expectedValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JAMessageGAM::JAMessageGAM() {
|
||||||
|
inputSignals = NULL_PTR(void **);
|
||||||
|
inputSignalTypes = NULL_PTR(MARTe::TypeDescriptor *);
|
||||||
|
operation = And;
|
||||||
|
needsReset = false;
|
||||||
|
expectedValuesInt = NULL_PTR(MARTe::uint64 *);
|
||||||
|
expectedValuesFloat = NULL_PTR(MARTe::float64 *);
|
||||||
|
intValuesCount = 0u;
|
||||||
|
floatValuesCount = 0u;
|
||||||
|
comparators = NULL_PTR(ComparisonMode *);
|
||||||
|
}
|
||||||
|
|
||||||
|
JAMessageGAM::~JAMessageGAM() {
|
||||||
|
if (inputSignals != NULL_PTR(void **)) {
|
||||||
|
delete[] inputSignals;
|
||||||
|
}
|
||||||
|
if (inputSignalTypes != NULL_PTR(MARTe::TypeDescriptor *)) {
|
||||||
|
delete[] inputSignalTypes;
|
||||||
|
}
|
||||||
|
if (expectedValuesInt != NULL_PTR(MARTe::uint64 *)) {
|
||||||
|
delete[] expectedValuesInt;
|
||||||
|
}
|
||||||
|
if (expectedValuesFloat != NULL_PTR(MARTe::float64 *)) {
|
||||||
|
delete[] expectedValuesFloat;
|
||||||
|
}
|
||||||
|
if (comparators != NULL_PTR(ComparisonMode *)) {
|
||||||
|
delete[] comparators;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAMessageGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = GAM::Initialise(data);
|
||||||
|
if (ok) {
|
||||||
|
// Read expected integer values.
|
||||||
|
AnyType valuesArray = data.GetType("ExpectedIntValues");
|
||||||
|
bool intValuesProvided = (valuesArray.GetDataPointer() != NULL);
|
||||||
|
|
||||||
|
if (intValuesProvided) {
|
||||||
|
intValuesCount = valuesArray.GetNumberOfElements(0u);
|
||||||
|
}
|
||||||
|
if (intValuesProvided) {
|
||||||
|
expectedValuesInt = new uint64[intValuesCount];
|
||||||
|
|
||||||
|
Vector<uint64> valuesVector(expectedValuesInt, intValuesCount);
|
||||||
|
ok = (data.Read("ExpectedIntValues", valuesVector));
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Failed to read ExpectedIntValues.");
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Read expected float values.
|
||||||
|
valuesArray = data.GetType("ExpectedFloatValues");
|
||||||
|
bool floatValuesProvided = (valuesArray.GetDataPointer() != NULL);
|
||||||
|
|
||||||
|
if (floatValuesProvided) {
|
||||||
|
floatValuesCount = valuesArray.GetNumberOfElements(0u);
|
||||||
|
}
|
||||||
|
if (floatValuesProvided) {
|
||||||
|
expectedValuesFloat = new float64[floatValuesCount];
|
||||||
|
|
||||||
|
Vector<float64> valuesVector(expectedValuesFloat, floatValuesCount);
|
||||||
|
ok = (data.Read("ExpectedFloatValues", valuesVector));
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Failed to read ExpectedFloatValues.");
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ok = (floatValuesCount + intValuesCount) > 0u;
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "ExpectedFloatValues and or ExpectedIntValues shall be defined.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
// Read comparators.
|
||||||
|
AnyType comparatorsArray = data.GetType("Comparators");
|
||||||
|
if (comparatorsArray.GetDataPointer() != NULL) {
|
||||||
|
uint32 count = comparatorsArray.GetNumberOfElements(0u);
|
||||||
|
ok = count == (intValuesCount + floatValuesCount);
|
||||||
|
if (ok) {
|
||||||
|
comparators = new ComparisonMode[count];
|
||||||
|
StreamString* comp = new StreamString[count];
|
||||||
|
Vector<StreamString> compVector(comp, count);
|
||||||
|
|
||||||
|
ok = (data.Read("Comparators", compVector));
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
for (uint32 i = 0; i < count; ++i) {
|
||||||
|
if (comp[i] == "EQUALS") {
|
||||||
|
comparators[i] = Equals;
|
||||||
|
} else if (comp[i] == "NOT") {
|
||||||
|
comparators[i] = Not;
|
||||||
|
} else if (comp[i] == "GREATER") {
|
||||||
|
comparators[i] = Greater;
|
||||||
|
} else if (comp[i] == "EQUALS_OR_GREATER") {
|
||||||
|
comparators[i] = EqualsOrGreater;
|
||||||
|
} else if (comp[i] == "LESS") {
|
||||||
|
comparators[i] = Less;
|
||||||
|
} else if (comp[i] == "EQUALS_OR_LESS") {
|
||||||
|
comparators[i] = EqualsOrLess;
|
||||||
|
} else {
|
||||||
|
ok = false;
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Comparator %s is not defined.", comp[i].Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Expected values and operators shall have the same "
|
||||||
|
"number of elements.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uint32 count = intValuesCount + floatValuesCount;
|
||||||
|
if (ok) {
|
||||||
|
// Create default comparators (equals) when they aren't provided in the configuration.
|
||||||
|
comparators = new ComparisonMode[count];
|
||||||
|
for (uint32 i = 0; i < count; ++i) {
|
||||||
|
comparators[i] = Equals;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Expected values and operators shall have the same "
|
||||||
|
"number of elements.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
MARTe::StreamString operationStr;
|
||||||
|
if (data.Read("Operation", operationStr)) {
|
||||||
|
if (operationStr == "AND") {
|
||||||
|
operation = And;
|
||||||
|
}
|
||||||
|
else if (operationStr == "OR") {
|
||||||
|
operation = Or;
|
||||||
|
}
|
||||||
|
else if (operationStr == "NOR") {
|
||||||
|
operation = Nor;
|
||||||
|
}
|
||||||
|
else if (operationStr == "XOR") {
|
||||||
|
operation = Xor;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ok = false;
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Operation %s is not defined", operationStr.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = (Size() == 1);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "A Message object shall be added to this container");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
eventMsg = Get(0);
|
||||||
|
ok = (eventMsg.IsValid());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "A valid Message shall be added to this container");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAMessageGAM::Setup() {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = numberOfInputSignals == (intValuesCount + floatValuesCount);
|
||||||
|
if (ok) {
|
||||||
|
ok = numberOfInputSignals > 0u;
|
||||||
|
if (ok) {
|
||||||
|
inputSignals = new void*[numberOfInputSignals];
|
||||||
|
uint32 i;
|
||||||
|
for (i = 0u; i < numberOfInputSignals; i++) {
|
||||||
|
inputSignals[i] = GetInputSignalMemory(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "At least one input signal shall be defined");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Number of input signals shall be the same as "
|
||||||
|
"number of expected values.");
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
inputSignalTypes = new TypeDescriptor[numberOfInputSignals];
|
||||||
|
uint32 i;
|
||||||
|
for (i = 0u; (i < numberOfInputSignals) && (ok); i++) {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, i);
|
||||||
|
inputSignalTypes[i] = inputType;
|
||||||
|
ok = (inputType == UnsignedInteger32Bit) || (inputType == SignedInteger32Bit) ||
|
||||||
|
(inputType == UnsignedInteger16Bit) || (inputType == SignedInteger16Bit) ||
|
||||||
|
(inputType == UnsignedInteger8Bit) || (inputType == SignedInteger8Bit) ||
|
||||||
|
(inputType == Float64Bit) || (inputType == Float32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, i, signalName);
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Signal %s shall be defined as 32/16/8 bit signed/unsigned integer "
|
||||||
|
"or as 64/32 float.", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAMessageGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||||
|
needsReset = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAMessageGAM::Execute() {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = true;
|
||||||
|
bool eventDetected = false;
|
||||||
|
uint32 inputPortIndex = 0;
|
||||||
|
uint32 intIndex = 0;
|
||||||
|
uint32 floatIndex = 0;
|
||||||
|
if (operation == Or) {
|
||||||
|
for (inputPortIndex = 0; (inputPortIndex < numberOfInputSignals) && (!eventDetected); inputPortIndex++) {
|
||||||
|
eventDetected = Compare(inputPortIndex, floatIndex, intIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (operation == Nor) {
|
||||||
|
for (inputPortIndex = 0; (inputPortIndex < numberOfInputSignals) && (!eventDetected); inputPortIndex++) {
|
||||||
|
eventDetected = Compare(inputPortIndex, floatIndex, intIndex);
|
||||||
|
}
|
||||||
|
eventDetected = !eventDetected;
|
||||||
|
}
|
||||||
|
else if (operation == And) {
|
||||||
|
eventDetected = Compare(0, floatIndex, intIndex);
|
||||||
|
for (inputPortIndex = 1; (inputPortIndex < numberOfInputSignals); inputPortIndex++) {
|
||||||
|
eventDetected &= Compare(inputPortIndex, floatIndex, intIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (operation == Xor) {
|
||||||
|
uint32 eventDetectedUInt32 = Compare(inputPortIndex, floatIndex, intIndex);
|
||||||
|
for (inputPortIndex = 1; (inputPortIndex < numberOfInputSignals); inputPortIndex++) {
|
||||||
|
eventDetectedUInt32 ^= Compare(inputPortIndex, floatIndex, intIndex);
|
||||||
|
}
|
||||||
|
eventDetected = (eventDetectedUInt32 == 1u);
|
||||||
|
}
|
||||||
|
if (eventDetected) {
|
||||||
|
if (!needsReset) {
|
||||||
|
ok = (MessageI::SendMessage(eventMsg, this) == ErrorManagement::NoError);
|
||||||
|
needsReset = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAMessageGAM::Compare(MARTe::uint32 inputPortIndex, MARTe::uint32 &floatValueIndex, MARTe::uint32 &intValueIndex) {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ret = false;
|
||||||
|
if (inputSignalTypes[inputPortIndex] == UnsignedInteger32Bit) {
|
||||||
|
ret = ::Compare<uint32>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
|
||||||
|
++intValueIndex;
|
||||||
|
}
|
||||||
|
else if (inputSignalTypes[inputPortIndex] == SignedInteger32Bit) {
|
||||||
|
ret = ::Compare<int32>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
|
||||||
|
++intValueIndex;
|
||||||
|
}
|
||||||
|
else if (inputSignalTypes[inputPortIndex] == UnsignedInteger16Bit) {
|
||||||
|
ret = ::Compare<uint16>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
|
||||||
|
++intValueIndex;
|
||||||
|
}
|
||||||
|
else if (inputSignalTypes[inputPortIndex] == SignedInteger16Bit) {
|
||||||
|
ret = ::Compare<int16>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
|
||||||
|
++intValueIndex;
|
||||||
|
}
|
||||||
|
else if (inputSignalTypes[inputPortIndex] == UnsignedInteger8Bit) {
|
||||||
|
ret = ::Compare<uint8>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
|
||||||
|
++intValueIndex;
|
||||||
|
}
|
||||||
|
else if (inputSignalTypes[inputPortIndex] == SignedInteger8Bit) {
|
||||||
|
ret = ::Compare<int8>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesInt[intValueIndex]);
|
||||||
|
++intValueIndex;
|
||||||
|
}
|
||||||
|
else if (inputSignalTypes[inputPortIndex] == Float64Bit) {
|
||||||
|
ret = ::Compare<float64>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesFloat[floatValueIndex]);
|
||||||
|
++floatValueIndex;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ret = ::Compare<float32>(comparators[inputPortIndex], inputSignals[inputPortIndex], expectedValuesFloat[floatValueIndex]);
|
||||||
|
++floatValueIndex;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JAMessageGAM, "1.0")
|
||||||
149
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JAMessageGAM/JAMessageGAM.h
Normal file
149
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JAMessageGAM/JAMessageGAM.h
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
/**
|
||||||
|
* @file JAMessageGAM.h
|
||||||
|
* @brief Header file for class JAMessageGAM
|
||||||
|
* @date Jan, 2019
|
||||||
|
* @author rhari
|
||||||
|
*
|
||||||
|
* @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 JAMessageGAM
|
||||||
|
* 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 GAMS_JAMESSAGEGAM_H_
|
||||||
|
#define GAMS_JAMESSAGEGAM_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "GAM.h"
|
||||||
|
#include "Message.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GAM that sends a message when input signals have expected values. Message will not be sent multiple
|
||||||
|
* times without first changing the application state.
|
||||||
|
*
|
||||||
|
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||||
|
* <pre>
|
||||||
|
* +MessageGAM = {
|
||||||
|
* Class = JAMessageGAM
|
||||||
|
* Operation = AND // Accepted values are: AND, OR, XOR, NOR. Default value is AND.
|
||||||
|
* ExpectedIntValues = {1 10} // Expected values for input signals of integral type.
|
||||||
|
* ExpectedFloatValues = {3.5} // Expected values for float signals of floting point type.
|
||||||
|
* Comparators = {EQUALS GREATER NOT} // Accepted values are: EQUALS, NOT, GREATER, EQUALS_OR_GREATER, LESS, EQUALS_OR_LESS
|
||||||
|
* // Comparators element is optional. Default comparator is EQUALS.
|
||||||
|
* InputSignals = {
|
||||||
|
* Sig1 = {
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* Sig2 = {
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = float32
|
||||||
|
* }
|
||||||
|
* Sig3 = {
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* +Event = { // Message to be sent when condition is true.
|
||||||
|
* Class = Message
|
||||||
|
* Destination = StateMachine
|
||||||
|
* Function = GoDisabled
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
* This example will send Event message when Sig1 == 1 && Sig2 > 3.5 && Sig3 != 10
|
||||||
|
*/
|
||||||
|
class JAMessageGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
JAMessageGAM();
|
||||||
|
|
||||||
|
virtual ~JAMessageGAM();
|
||||||
|
|
||||||
|
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||||
|
|
||||||
|
virtual bool Setup();
|
||||||
|
|
||||||
|
virtual bool Execute();
|
||||||
|
|
||||||
|
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
|
||||||
|
const MARTe::char8 * const nextStateName);
|
||||||
|
|
||||||
|
enum ComparisonMode {
|
||||||
|
Equals, Not, Greater, EqualsOrGreater, Less, EqualsOrLess
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief Does the input signal at provided index have the expected value.
|
||||||
|
* @param[in] index of the signal.
|
||||||
|
* @param[out] floatValueIndex lookup index for expected float values array.
|
||||||
|
* @param[out] intValueIndex lookup index for expected integer values array.
|
||||||
|
* @return true if the signal has expected value.
|
||||||
|
*/
|
||||||
|
bool Compare(MARTe::uint32 index, MARTe::uint32 &floatValueIndex, MARTe::uint32 &intValueIndex);
|
||||||
|
|
||||||
|
enum OperationMode {
|
||||||
|
And, Or, Xor, Nor
|
||||||
|
};
|
||||||
|
|
||||||
|
// Input signals
|
||||||
|
void **inputSignals;
|
||||||
|
|
||||||
|
MARTe::TypeDescriptor *inputSignalTypes;
|
||||||
|
|
||||||
|
// Condition operation.
|
||||||
|
OperationMode operation;
|
||||||
|
|
||||||
|
// Message to be sent when conditions are met.
|
||||||
|
MARTe::ReferenceT<MARTe::Message> eventMsg;
|
||||||
|
|
||||||
|
// Was the message already sent and we are waiting for a state change before next message can be sent.
|
||||||
|
bool needsReset;
|
||||||
|
|
||||||
|
// Array of expected integer values of input signals.
|
||||||
|
MARTe::uint64* expectedValuesInt;
|
||||||
|
|
||||||
|
// Array of expected float values for input signals.
|
||||||
|
MARTe::float64* expectedValuesFloat;
|
||||||
|
|
||||||
|
// Expected integer values count (must be equal to numberOfInputSignals - floatValuesCount)
|
||||||
|
MARTe::uint32 intValuesCount;
|
||||||
|
|
||||||
|
// Expected integer values count (must be equal to numberOfInputSignals - floatValuesCount)
|
||||||
|
MARTe::uint32 floatValuesCount;
|
||||||
|
|
||||||
|
// Array of comparators
|
||||||
|
ComparisonMode* comparators;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* GAMS_JAMESSAGEGAM_H_ */
|
||||||
27
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JAMessageGAM/Makefile.gcc
Normal file
27
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JAMessageGAM/Makefile.gcc
Normal file
@@ -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
|
||||||
53
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JAMessageGAM/Makefile.inc
Normal file
53
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JAMessageGAM/Makefile.inc
Normal file
@@ -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=JAMessageGAM.x
|
||||||
|
|
||||||
|
PACKAGE=GAMs
|
||||||
|
|
||||||
|
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)/JAMessageGAM$(LIBEXT) \
|
||||||
|
$(BUILD_DIR)/JAMessageGAM$(DLLEXT)
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
|
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
/**
|
||||||
|
* @file JAModeControlGAM.cpp
|
||||||
|
* @brief Source file for class JAModeControlGAM
|
||||||
|
* @date Jan, 2019
|
||||||
|
* @author kuchida
|
||||||
|
*
|
||||||
|
* @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 JAModeControlGAM (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 "JAModeControlGAM.h"
|
||||||
|
#include "AdvancedErrorManagement.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
JAModeControlGAM::JAModeControlGAM() {
|
||||||
|
inputSignals = NULL_PTR(MARTe::uint32 **);
|
||||||
|
outputSignal = NULL_PTR(MARTe::uint32 *);
|
||||||
|
pulseLengthLimit = 360000000u;
|
||||||
|
resetRemainingTime = true;
|
||||||
|
previousState = 0u;
|
||||||
|
}
|
||||||
|
|
||||||
|
JAModeControlGAM::~JAModeControlGAM() {
|
||||||
|
if (inputSignals != NULL_PTR(MARTe::uint32 **)) {
|
||||||
|
delete[] inputSignals;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAModeControlGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||||
|
/* read hard coded on cfg file parameter values by using key name. */
|
||||||
|
using namespace MARTe;
|
||||||
|
return GAM::Initialise(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAModeControlGAM::Setup() {
|
||||||
|
/* read GAM Input signal */
|
||||||
|
using namespace MARTe;
|
||||||
|
/* read 4 mode bits and 4 shot length limit values */
|
||||||
|
|
||||||
|
bool ok = numberOfInputSignals == 11;
|
||||||
|
if (ok) {
|
||||||
|
uint32 i;
|
||||||
|
for (i = 0u; (i < numberOfInputSignals) && (ok); i++) {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, i);
|
||||||
|
ok = inputType == UnsignedInteger32Bit;
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, i, signalName);
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "InputSignel %s shall be defined as uint32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Eleven input signals shall be defined.");
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = numberOfOutputSignals == 1;
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "One output signal shall be defined.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor type = GetSignalType(OutputSignals, 0);
|
||||||
|
ok = type == UnsignedInteger32Bit;
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(OutputSignals, 0, signalName);
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
outputSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
|
||||||
|
inputSignals = new uint32*[numberOfInputSignals];
|
||||||
|
uint32 i;
|
||||||
|
for (i = 0u; i < 11; i++) {
|
||||||
|
inputSignals[i] = reinterpret_cast<uint32 *>(GetInputSignalMemory(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAModeControlGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||||
|
*outputSignal = 0u;
|
||||||
|
previousState = 0u;
|
||||||
|
resetRemainingTime = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAModeControlGAM::Execute() {
|
||||||
|
using namespace MARTe;
|
||||||
|
//When RT state goes to RFON state, update the limit.
|
||||||
|
if(previousState == 0u && *inputSignals[8] == 1u && resetRemainingTime) {
|
||||||
|
rfonTime = *inputSignals[9];
|
||||||
|
resetRemainingTime = false;
|
||||||
|
pulseLengthLimit = CalcPulseLengthLimit(inputSignals);
|
||||||
|
REPORT_ERROR(ErrorManagement::Debug, "Pulse Length was set to Limit:%d", pulseLengthLimit);
|
||||||
|
}
|
||||||
|
// Turn on the flag during RFON if the pulse legth over the limit.
|
||||||
|
if ((*inputSignals[9] - rfonTime <= pulseLengthLimit) && (previousState == 1u)) {
|
||||||
|
*outputSignal = 0u;
|
||||||
|
return true;
|
||||||
|
} else if(*inputSignals[9] == 1u){
|
||||||
|
resetRemainingTime = true;
|
||||||
|
*outputSignal = 1u;
|
||||||
|
}
|
||||||
|
|
||||||
|
previousState = *inputSignals[8];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MARTe::uint32 JAModeControlGAM::CalcPulseLengthLimit(MARTe::uint32 **inputSignals) {
|
||||||
|
if (*inputSignals[0] == 1) {
|
||||||
|
return *inputSignals[1];
|
||||||
|
} else if (*inputSignals[2] == 1) {
|
||||||
|
return *inputSignals[3];
|
||||||
|
} else if (*inputSignals[4] == 1) {
|
||||||
|
return *inputSignals[5];
|
||||||
|
} else if (*inputSignals[6] == 1) {
|
||||||
|
return *inputSignals[7];
|
||||||
|
} else {
|
||||||
|
return 3600000000;//us
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CLASS_REGISTER(JAModeControlGAM, "1.0")
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
/**
|
||||||
|
* @file JAModeControlGAM.h
|
||||||
|
* @brief Header file for class JAModeControlGAM
|
||||||
|
* @date Jan, 2019
|
||||||
|
* @author kuchida
|
||||||
|
*
|
||||||
|
* @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 JAModeControlGAM
|
||||||
|
* 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 GAMS_JAMODECONTROLGAM_H_
|
||||||
|
#define GAMS_JAMODECONTROLGAM_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "GAM.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GAM that check the pulse lenght limit.
|
||||||
|
*
|
||||||
|
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||||
|
* <pre>
|
||||||
|
* +ModeLimitGAM = {
|
||||||
|
* Class = JAModeControlGAM
|
||||||
|
* InputSignals = {
|
||||||
|
* PLC_MODE1 = {
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* MD1_SHOTLEN_LIM = {
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* PLC_MODE2 = {
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* MD2_SHOTLEN_LIM = {
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* PLC_MODE3 = {
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* MD3_SHOTLEN_LIM = {
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* PLC_MODE4 = {
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* MD4_SHOTLEN_LIM = {
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* RFON = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* Time = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* HVInjection = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* OutputSignals = {
|
||||||
|
* MODE_SHOTLEN_FLAG = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
* If MODE1 is ON and Time is exceed MD1_SHOTLEN_LIM, MODE_SHOTLEN_FLAG become ON.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class JAModeControlGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
JAModeControlGAM();
|
||||||
|
|
||||||
|
virtual ~JAModeControlGAM();
|
||||||
|
|
||||||
|
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||||
|
|
||||||
|
virtual bool Setup();
|
||||||
|
|
||||||
|
virtual bool Execute();
|
||||||
|
|
||||||
|
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
|
||||||
|
const MARTe::char8 * const nextStateName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
MARTe::uint32 CalcPulseLengthLimit(MARTe::uint32 **inputSignals);
|
||||||
|
|
||||||
|
// Input signals
|
||||||
|
MARTe::uint32 **inputSignals;
|
||||||
|
|
||||||
|
// Output signals
|
||||||
|
MARTe::uint32 *outputSignal;
|
||||||
|
|
||||||
|
// Calculated pulse lenght limit.
|
||||||
|
MARTe::uint32 pulseLengthLimit;
|
||||||
|
|
||||||
|
// Amount of time passed per execution cycle.
|
||||||
|
MARTe::uint32 rfonTime;
|
||||||
|
|
||||||
|
// reset flag
|
||||||
|
bool resetRemainingTime;
|
||||||
|
MARTe::uint32 previousState;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* GAMS_JAMODECONTROLGAM_H_ */
|
||||||
@@ -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,52 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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=JAModeControlGAM.x
|
||||||
|
|
||||||
|
PACKAGE=GAMs
|
||||||
|
|
||||||
|
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)/JAModeControlGAM$(LIBEXT) \
|
||||||
|
$(BUILD_DIR)/JAModeControlGAM$(DLLEXT)
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
@@ -0,0 +1,460 @@
|
|||||||
|
/**
|
||||||
|
* @file JAPreProgrammedGAM.cpp
|
||||||
|
* @brief Source file for class JAPreProgrammedGAM
|
||||||
|
* @date Jan, 2019
|
||||||
|
* @author rhari
|
||||||
|
*
|
||||||
|
* @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 JAPreProgrammedGAM (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 "CLASSMETHODREGISTER.h"
|
||||||
|
#include "File.h"
|
||||||
|
#include "JAPreProgrammedGAM.h"
|
||||||
|
#include "MessageI.h"
|
||||||
|
#include "RegisteredMethodsMessageFilter.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// How often output signals are updated.
|
||||||
|
const MARTe::uint32 cycleMs = 10u;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
JAPreProgrammedGAM::JAPreProgrammedGAM() :
|
||||||
|
GAM() {
|
||||||
|
using namespace MARTe;
|
||||||
|
filenameSignalIndex = 0u;
|
||||||
|
timeSignal = NULL_PTR(MARTe::int32 *);
|
||||||
|
loadTriggerSignal = NULL_PTR(MARTe::uint32 *);
|
||||||
|
fhpsrefSignal = NULL_PTR(MARTe::float32 *);
|
||||||
|
rfonStateSignal = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
valueSignals = NULL_PTR(MARTe::float32 **);
|
||||||
|
preProgrammedValues = NULL_PTR(MARTe::float32 **);
|
||||||
|
preProgrammedTime = NULL_PTR(MARTe::int32 *);
|
||||||
|
fileLoadedSignal = NULL_PTR(MARTe::uint32 *);
|
||||||
|
fileLoadErrorOutput = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
startTime = 0u;
|
||||||
|
numberOfPreProgrammedValues = 0u;
|
||||||
|
numberOfPreProgrammedTimeRows = 0u;
|
||||||
|
currentRow = 0u;
|
||||||
|
mode = None;
|
||||||
|
preProgrammedExecutaionPeriodMs = 0u;
|
||||||
|
msCounter = 0u;
|
||||||
|
preProgrammedRow = 0u;
|
||||||
|
resetOutputSignals = false;
|
||||||
|
readOnce = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
JAPreProgrammedGAM::~JAPreProgrammedGAM() {
|
||||||
|
DeleteArrays();
|
||||||
|
if (valueSignals != NULL_PTR(MARTe::float32 **)) {
|
||||||
|
delete[] valueSignals;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAPreProgrammedGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = GAM::Initialise(data);
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("Directory", directory);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Directory shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("PreProgrammedPeriodMs", preProgrammedExecutaionPeriodMs);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Directory shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAPreProgrammedGAM::Setup() {
|
||||||
|
using namespace MARTe;
|
||||||
|
//Signal number check.
|
||||||
|
bool ok = (numberOfInputSignals == 4u);
|
||||||
|
if (ok) {
|
||||||
|
ok = (numberOfOutputSignals > 2u);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "At least two output signal shall be defined");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Four input signals with the filename and file load trigger shall be defined");
|
||||||
|
}
|
||||||
|
//Input signals type consistency check.
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "Filename";
|
||||||
|
ok = GetSignalIndex(InputSignals, filenameSignalIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Filename input signal shall be defined");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, filenameSignalIndex);
|
||||||
|
ok = (inputType == CharString);
|
||||||
|
if (!ok) {
|
||||||
|
ok = (inputType == Character8Bit);
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, filenameSignalIndex, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as string", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "CSV_LOAD";
|
||||||
|
uint32 loadSignalIndex;
|
||||||
|
ok = GetSignalIndex(InputSignals, loadSignalIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "CSV_LOAD input signal shall be defined");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, loadSignalIndex);
|
||||||
|
ok = (inputType == UnsignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, loadSignalIndex, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||||
|
} else {
|
||||||
|
loadTriggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(loadSignalIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "FHPS_REF";
|
||||||
|
uint32 fhpsrefIndex;
|
||||||
|
ok = GetSignalIndex(InputSignals, fhpsrefIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "FHPS_REF input signal shall be defined");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, fhpsrefIndex);
|
||||||
|
ok = (inputType == Float32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, fhpsrefIndex, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as float32", signalName.Buffer());
|
||||||
|
} else {
|
||||||
|
fhpsrefSignal = reinterpret_cast<float32 *>(GetInputSignalMemory(fhpsrefIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "RFON";
|
||||||
|
uint32 rfonIndex;
|
||||||
|
ok = GetSignalIndex(InputSignals, rfonIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "RFON input signal shall be defined");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, rfonIndex);
|
||||||
|
ok = (inputType == UnsignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, rfonIndex, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as float32", signalName.Buffer());
|
||||||
|
} else {
|
||||||
|
rfonStateSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(rfonIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Output signals type check.
|
||||||
|
if (ok) {
|
||||||
|
TypeDescriptor timeType = GetSignalType(OutputSignals, 0);
|
||||||
|
ok = (timeType == SignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, 0, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as int32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 i;
|
||||||
|
for (i = 1u; (i <= 6) && (ok); i++) {
|
||||||
|
TypeDescriptor outputType = GetSignalType(OutputSignals, i);
|
||||||
|
ok = (outputType == Float32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(OutputSignals, i, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as float32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
TypeDescriptor fileLoadedType = GetSignalType(OutputSignals, 7u);
|
||||||
|
ok = (fileLoadedType == UnsignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(OutputSignals, 6u, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
TypeDescriptor fileLoadErrorOutputType = GetSignalType(OutputSignals, 8u);
|
||||||
|
ok = (fileLoadErrorOutputType == UnsignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(OutputSignals, 7u, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Register signal memory
|
||||||
|
if (ok) {
|
||||||
|
timeSignal = reinterpret_cast<int32 *>(GetOutputSignalMemory(0));
|
||||||
|
valueSignals = new float32*[6u];
|
||||||
|
uint32 i;
|
||||||
|
for (i = 1u; i <= 6u; i++) {
|
||||||
|
valueSignals[i - 1] = reinterpret_cast<float32 *>(GetOutputSignalMemory(i));
|
||||||
|
}
|
||||||
|
fileLoadedSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(7u));
|
||||||
|
fileLoadErrorOutput = reinterpret_cast<uint32 *>(GetOutputSignalMemory(8u));
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAPreProgrammedGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||||
|
bool ok = true;
|
||||||
|
if (strcmp(nextStateName, "WaitReady") == 0) {
|
||||||
|
mode = LoadFileMode;
|
||||||
|
resetOutputSignals = true;
|
||||||
|
// Reset read once flag when reentering WaitReady state.
|
||||||
|
readOnce = true;
|
||||||
|
} else if (strcmp(nextStateName, "WaitPermit") == 0) {
|
||||||
|
mode = LoadFileMode;
|
||||||
|
resetOutputSignals = true;
|
||||||
|
currentRow = 0u;
|
||||||
|
} else if (strcmp(nextStateName, "WaitHVON_PREP") == 0 || strcmp(nextStateName, "WaitHVON_SDN_PREP") == 0) {
|
||||||
|
ok = numberOfPreProgrammedTimeRows > 0;
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::IllegalOperation, "Entering PreProgrammed mode without any waveform data.");
|
||||||
|
}
|
||||||
|
mode = PreProgrammedMode;
|
||||||
|
msCounter = cycleMs;
|
||||||
|
currentRow = 0u;
|
||||||
|
} else {
|
||||||
|
mode = None;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAPreProgrammedGAM::LoadFile() {
|
||||||
|
using namespace MARTe;
|
||||||
|
|
||||||
|
DeleteArrays();
|
||||||
|
|
||||||
|
bool ok = true;
|
||||||
|
|
||||||
|
const MARTe::char8 * const filenameSignal = reinterpret_cast<const char8 * const >(GetInputSignalMemory(filenameSignalIndex));
|
||||||
|
//Prepare full path to the configuration file.
|
||||||
|
StreamString filename = directory;
|
||||||
|
filename += DIRECTORY_SEPARATOR;
|
||||||
|
filename += filenameSignal;
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::Debug, "Opening file %s", filename.Buffer());
|
||||||
|
|
||||||
|
//parse prepro configuration file into two arrays(time, values).
|
||||||
|
File f;
|
||||||
|
ok = f.Open(filename.Buffer(), BasicFile::ACCESS_MODE_R);
|
||||||
|
if (ok) {
|
||||||
|
//Count up number of file Rows.
|
||||||
|
numberOfPreProgrammedTimeRows = 0u;
|
||||||
|
StreamString tokenLine;
|
||||||
|
while (f.GetLine(tokenLine)) {
|
||||||
|
if (tokenLine[0] != '#' && tokenLine[0] != '-') {
|
||||||
|
numberOfPreProgrammedTimeRows++;
|
||||||
|
}
|
||||||
|
tokenLine = "";
|
||||||
|
}
|
||||||
|
//Count up number of file lines
|
||||||
|
numberOfPreProgrammedValues = 0u;
|
||||||
|
f.Seek(0);
|
||||||
|
uint32 t = 0u;
|
||||||
|
tokenLine = "";
|
||||||
|
while ((ok) && (f.GetLine(tokenLine))) {
|
||||||
|
// Skip comment line and minus time
|
||||||
|
if (tokenLine[0] == '#' || tokenLine[0] == '-') {
|
||||||
|
tokenLine = "";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Prepare two arrays at first.
|
||||||
|
if (numberOfPreProgrammedValues == 0) {
|
||||||
|
StreamString token;
|
||||||
|
char8 ignored;
|
||||||
|
tokenLine.Seek(0);
|
||||||
|
while (tokenLine.GetToken(token, ",", ignored)) {
|
||||||
|
numberOfPreProgrammedValues++;
|
||||||
|
token = "";
|
||||||
|
}
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError,"numberOfPreProgrammedVal %d", numberOfPreProgrammedValues);
|
||||||
|
ok = (numberOfPreProgrammedValues == 7u);//From time row to FHPS row.
|
||||||
|
numberOfPreProgrammedValues -= 1u; //From MHVPS row to FHPS row.
|
||||||
|
if (ok) {
|
||||||
|
preProgrammedTime = new int32[numberOfPreProgrammedTimeRows];
|
||||||
|
preProgrammedValues = new float32*[numberOfPreProgrammedTimeRows];
|
||||||
|
uint32 j;
|
||||||
|
for (j = 0u; j < numberOfPreProgrammedTimeRows; j++) {
|
||||||
|
preProgrammedValues[j] = new float32[numberOfPreProgrammedValues];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError,
|
||||||
|
"Number of columns in csv file (%d) is not consistent with the number of output signals (%d)",
|
||||||
|
numberOfPreProgrammedValues, 6u);
|
||||||
|
*fileLoadErrorOutput = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Add loaded data into two arrays.
|
||||||
|
if (ok) {
|
||||||
|
StreamString token;
|
||||||
|
char8 ignored;
|
||||||
|
tokenLine.Seek(0);
|
||||||
|
uint32 idx = 0u;
|
||||||
|
while (tokenLine.GetToken(token, ",", ignored)) {
|
||||||
|
if (idx == 0u) {
|
||||||
|
preProgrammedTime[t] = atoi(token.Buffer());
|
||||||
|
if (t == 0 && preProgrammedTime[0] != 0) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::Debug, "Prepro start from none zero time.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ok = ((idx - 1) < numberOfPreProgrammedValues);
|
||||||
|
if (ok) {
|
||||||
|
preProgrammedValues[t][idx - 1] = static_cast<float32>(atof(token.Buffer()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::FatalError, "Number of columns in csv file is not consistent with the number of output signals in line %d", t);
|
||||||
|
*fileLoadErrorOutput = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
token = "";
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
t++;
|
||||||
|
}
|
||||||
|
tokenLine = "";
|
||||||
|
}
|
||||||
|
f.Close();
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
currentRow = 0u;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
numberOfPreProgrammedTimeRows = 0u;
|
||||||
|
REPORT_ERROR(ErrorManagement::Warning, "Failed to read waveform data from file.");
|
||||||
|
*fileLoadErrorOutput = 2;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAPreProgrammedGAM::Execute() {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = true;
|
||||||
|
|
||||||
|
switch (mode) {
|
||||||
|
case LoadFileMode: {
|
||||||
|
if (*loadTriggerSignal == 1u) {
|
||||||
|
if (readOnce) {
|
||||||
|
*fileLoadErrorOutput = 0;
|
||||||
|
*fileLoadedSignal = LoadFile() ? 1 : 0;
|
||||||
|
readOnce = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Reset read once flag when loadTriggerSignal is reset.
|
||||||
|
readOnce = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resetOutputSignals) {
|
||||||
|
// Write default values to output signals
|
||||||
|
*timeSignal = 0u;
|
||||||
|
*valueSignals[FHPS-1] = *fhpsrefSignal;
|
||||||
|
resetOutputSignals = false;
|
||||||
|
} else {
|
||||||
|
*valueSignals[FHPS-1] = *fhpsrefSignal; //copy input(2) to val_arr(4)
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case PreProgrammedMode: {
|
||||||
|
ok = numberOfPreProgrammedTimeRows > 0;
|
||||||
|
|
||||||
|
//add 20210105. Before RFON, prepro setpoints should be same as the values listed at csv first line.
|
||||||
|
if (ok && *rfonStateSignal == 0) {
|
||||||
|
uint32 j;
|
||||||
|
for (j = 0u; j < FHPS; j++) {
|
||||||
|
*valueSignals[j] = preProgrammedValues[0][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//end 20210105
|
||||||
|
|
||||||
|
if (ok && currentRow < numberOfPreProgrammedTimeRows && *rfonStateSignal == 1) {
|
||||||
|
if (msCounter >= cycleMs) {
|
||||||
|
msCounter -= cycleMs;
|
||||||
|
int32 currentTime = preProgrammedTime[currentRow];
|
||||||
|
//REPORT_ERROR(MARTe::ErrorManagement::Debug, "Write Time at %d",currentRow);
|
||||||
|
// Write to output signals
|
||||||
|
*timeSignal = currentTime;
|
||||||
|
uint32 j;
|
||||||
|
for (j = 0u; j < FHPS; j++) {
|
||||||
|
*valueSignals[j] = preProgrammedValues[currentRow][j];
|
||||||
|
//REPORT_ERROR(MARTe::ErrorManagement::Debug, "Write Value %f at row %d",preProgrammedValues[currentRow][j], currentRow);
|
||||||
|
}
|
||||||
|
//REPORT_ERROR(MARTe::ErrorManagement::Debug, "Writing pre programmed data for time %d", currentTime);
|
||||||
|
|
||||||
|
// Update row
|
||||||
|
++currentRow;
|
||||||
|
}
|
||||||
|
msCounter += preProgrammedExecutaionPeriodMs;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
default:
|
||||||
|
// Nothing to do.
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::Warning, "Unhandled mode.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JAPreProgrammedGAM::DeleteArrays() {
|
||||||
|
if (preProgrammedValues != NULL_PTR(MARTe::float32 **)) {
|
||||||
|
MARTe::uint32 i;
|
||||||
|
for (i = 0u; i < numberOfPreProgrammedValues; i++) {
|
||||||
|
delete preProgrammedValues[i];
|
||||||
|
}
|
||||||
|
delete[] preProgrammedValues;
|
||||||
|
}
|
||||||
|
if (preProgrammedTime != NULL_PTR(MARTe::int32 *)) {
|
||||||
|
delete[] preProgrammedTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JAPreProgrammedGAM, "1.0")
|
||||||
@@ -0,0 +1,187 @@
|
|||||||
|
/**
|
||||||
|
* @file JAPreProgrammedGAM.h
|
||||||
|
* @brief Header file for class JAPreProgrammedGAM
|
||||||
|
* @date Jan, 2019
|
||||||
|
* @author rhari
|
||||||
|
*
|
||||||
|
* @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 JAPreProgrammedGAM
|
||||||
|
* 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 GAMS_JAPREPROGRAMMEDGAM_H_
|
||||||
|
#define GAMS_JAPREPROGRAMMEDGAM_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
#include "GAM.h"
|
||||||
|
#include "Message.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GAM that update PS output value for pre-programmed operation.
|
||||||
|
*
|
||||||
|
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||||
|
* <pre>
|
||||||
|
* +PreProgrammedGAM = {
|
||||||
|
* Class = JAPreProgrammedGAM
|
||||||
|
* Directory = "../Configurations" // Directory which has pre-pro configuration file.
|
||||||
|
* PreProgrammedPeriodMs = 1 // RFON state is executed every millisecond.
|
||||||
|
* InputSignals = {
|
||||||
|
* CSV_LOAD = {
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* Filename = {
|
||||||
|
* Alias = CSV_NAME
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* }
|
||||||
|
* FHPS_REF = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = float32
|
||||||
|
* }
|
||||||
|
* RFON = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* OutputSignals = {
|
||||||
|
* GYA_PREHEAT_TIME = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = int32
|
||||||
|
* }
|
||||||
|
* MHVPS_REF = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = float32
|
||||||
|
* }
|
||||||
|
* BPS_REF = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = float32
|
||||||
|
* }
|
||||||
|
* APS_REF = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = float32
|
||||||
|
* }
|
||||||
|
* MCPS_TRG_CURR_SET = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = float32
|
||||||
|
* }
|
||||||
|
* GCPS_TRG_CURR_SET = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = float32
|
||||||
|
* }
|
||||||
|
* FHPS_REF = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = float32
|
||||||
|
* }
|
||||||
|
* CSV_LOADED = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* CSV_ERR = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class JAPreProgrammedGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
JAPreProgrammedGAM();
|
||||||
|
|
||||||
|
virtual ~JAPreProgrammedGAM();
|
||||||
|
|
||||||
|
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||||
|
|
||||||
|
virtual bool Setup();
|
||||||
|
|
||||||
|
virtual bool Execute();
|
||||||
|
|
||||||
|
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
|
||||||
|
const MARTe::char8 * const nextStateName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool LoadFile();
|
||||||
|
|
||||||
|
void DeleteArrays();
|
||||||
|
|
||||||
|
//Parameters
|
||||||
|
MARTe::StreamString directory; //Location for prepro configuration file.
|
||||||
|
MARTe::uint32 preProgrammedExecutaionPeriodMs; // Time between to execution cycles in milliseconds in pre-programmed mode.
|
||||||
|
|
||||||
|
//Input Signals
|
||||||
|
MARTe::uint32 *loadTriggerSignal; //index:0
|
||||||
|
MARTe::uint32 filenameSignalIndex;//index:1
|
||||||
|
MARTe::float32 *fhpsrefSignal; //index:2
|
||||||
|
MARTe::uint32 *rfonStateSignal; //index:3
|
||||||
|
|
||||||
|
//Output Signals
|
||||||
|
MARTe::int32 *timeSignal; //index:0
|
||||||
|
MARTe::float32 **valueSignals; //index:1-5 = BPS,APS,MC,GC,FHPS
|
||||||
|
MARTe::uint32 *fileLoadedSignal; //index:6
|
||||||
|
MARTe::uint32 *fileLoadErrorOutput;//index:7
|
||||||
|
|
||||||
|
//Internal variables
|
||||||
|
MARTe::int32 *preProgrammedTime;
|
||||||
|
MARTe::float32 **preProgrammedValues;
|
||||||
|
|
||||||
|
MARTe::uint32 startTime;
|
||||||
|
|
||||||
|
//Number of columns in csv, EXCLUDING the time
|
||||||
|
MARTe::uint32 numberOfPreProgrammedValues; //is 5.(BPS, APS, MC, GC, FHPS)
|
||||||
|
MARTe::uint32 numberOfPreProgrammedTimeRows; //This start from t=0 row.
|
||||||
|
MARTe::uint32 currentRow;
|
||||||
|
|
||||||
|
// Number of milliseconds since the last time output signals were updated.
|
||||||
|
MARTe::uint32 msCounter;
|
||||||
|
|
||||||
|
// Row number where the pre-programmed data begins (time == 0).
|
||||||
|
MARTe::uint32 preProgrammedRow;
|
||||||
|
|
||||||
|
enum OperationMode {
|
||||||
|
LoadFileMode, PreProgrammedMode, None
|
||||||
|
};
|
||||||
|
enum PreProTableDefinition {
|
||||||
|
Time, MHVPS, BPS, APS, MCPS, GCPS, FHPS
|
||||||
|
};
|
||||||
|
|
||||||
|
OperationMode mode;
|
||||||
|
|
||||||
|
bool resetOutputSignals;
|
||||||
|
|
||||||
|
// Flag determining whether file should be read (so it isn't read multiple time)
|
||||||
|
bool readOnce;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* GAMS_JAPREPROGRAMMEDGAM_H_ */
|
||||||
@@ -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,56 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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=JAPreProgrammedGAM.x
|
||||||
|
|
||||||
|
PACKAGE=GAMs
|
||||||
|
|
||||||
|
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
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
all: $(OBJS) $(SUBPROJ) \
|
||||||
|
$(BUILD_DIR)/JAPreProgrammedGAM$(LIBEXT) \
|
||||||
|
$(BUILD_DIR)/JAPreProgrammedGAM$(DLLEXT)
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
|
|
||||||
@@ -0,0 +1,411 @@
|
|||||||
|
/**
|
||||||
|
* @file JARTStateMachineGAM.cpp
|
||||||
|
* @brief Source file for class JARTStateMachineGAM
|
||||||
|
* @date Nov 26, 2018
|
||||||
|
* @author aneto
|
||||||
|
*
|
||||||
|
* @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 JARTStateMachineGAM (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 "JARTStateMachineGAM.h"
|
||||||
|
|
||||||
|
#include "AdvancedErrorManagement.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static MARTe::uint64 getCurrentTimeUs() {
|
||||||
|
using namespace MARTe;
|
||||||
|
return static_cast<uint64>(HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1e6f + 0.5f);
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
JARTStateMachineGAM::JARTStateMachineGAM() {
|
||||||
|
currentState = WaitTrigger; // Set Entry state.
|
||||||
|
plcOnTime = 0; // Triggered time holder.
|
||||||
|
|
||||||
|
//Output and condition in a given state.
|
||||||
|
conditionTrigger = 1;
|
||||||
|
aps_hvon = 0;
|
||||||
|
aps_swon = 0;
|
||||||
|
bps_hvon = 0;
|
||||||
|
bps_swon = 0;
|
||||||
|
mhvps_hvon = 0;
|
||||||
|
|
||||||
|
// Parameters which get from Input signals.
|
||||||
|
triggerSignal = NULL_PTR(MARTe::uint32 *);
|
||||||
|
currentTime = NULL_PTR(MARTe::uint32 *);
|
||||||
|
turn_off_delay = 2000; //us
|
||||||
|
|
||||||
|
triggerDelay_mhvps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_aps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_aps_swon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_bps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_bps_swon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_shotlen = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
stopRequest = NULL_PTR(MARTe::uint32 *);
|
||||||
|
modePulseLengthLimit = NULL_PTR(MARTe::uint32 *);
|
||||||
|
short_pulse_mode = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
modulation = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
// write out target.
|
||||||
|
outputSignal = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputBeamON = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputHVArmed = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputHVInjection = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputRFON = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputBeamONTime = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputRFONTime = NULL_PTR(MARTe::uint32 *);
|
||||||
|
shotCounter = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
mhvps_hvon_is_on = false;
|
||||||
|
aps_hvon_is_on = false;
|
||||||
|
aps_swon_is_on = false;
|
||||||
|
bps_hvon_is_on = false;
|
||||||
|
bps_swon_is_on = false;
|
||||||
|
|
||||||
|
apsSwonHighResolutionTime = 0;
|
||||||
|
|
||||||
|
aps_hvon_state=0;
|
||||||
|
aps_swon_state=0;
|
||||||
|
mhvps_hvon_state=0;
|
||||||
|
bps_hvon_state=0;
|
||||||
|
bps_swon_state=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
JARTStateMachineGAM::~JARTStateMachineGAM() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JARTStateMachineGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = GAM::Initialise(data);
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("ConditionTrigger", conditionTrigger);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Condition1 shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("mhvps_hvon", mhvps_hvon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The mhvps_hvon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("aps_hvon", aps_hvon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_hvon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("aps_swon", aps_swon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_swon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("bps_hvon", bps_hvon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_hvon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("bps_swon", bps_swon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_swon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JARTStateMachineGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JARTStateMachineGAM::Setup() {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = (numberOfInputSignals == 12u);
|
||||||
|
if (ok) {
|
||||||
|
ok = (numberOfOutputSignals == 16u);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Seven output signals shall be defined %d",numberOfOutputSignals);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Nine input signals shall be defined");
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||||
|
ok = (inputType == UnsignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfOutputSignals; c++) {
|
||||||
|
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
|
||||||
|
ok = (outputType == UnsignedInteger32Bit || outputType == UnsignedInteger8Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
currentTime = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||||
|
triggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
|
||||||
|
triggerDelay_mhvps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
|
||||||
|
triggerDelay_aps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
|
||||||
|
triggerDelay_aps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
|
||||||
|
triggerDelay_bps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
|
||||||
|
triggerDelay_bps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
|
||||||
|
triggerDelay_shotlen = reinterpret_cast<uint32 *>(GetInputSignalMemory(7));
|
||||||
|
stopRequest = reinterpret_cast<uint32 *>(GetInputSignalMemory(8));
|
||||||
|
modePulseLengthLimit = reinterpret_cast<uint32 *>(GetInputSignalMemory(9));
|
||||||
|
short_pulse_mode = reinterpret_cast<uint32 *>(GetInputSignalMemory(10));
|
||||||
|
modulation = reinterpret_cast<uint32 *>(GetInputSignalMemory(11));
|
||||||
|
|
||||||
|
|
||||||
|
outputSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
|
||||||
|
outputBeamON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(1));
|
||||||
|
outputHVArmed = reinterpret_cast<uint32 *>(GetOutputSignalMemory(2));
|
||||||
|
outputHVInjection = reinterpret_cast<uint32 *>(GetOutputSignalMemory(3));
|
||||||
|
outputRFON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(4));
|
||||||
|
outputBeamONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(5));
|
||||||
|
outputRFONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(6));
|
||||||
|
shotCounter = reinterpret_cast<uint32 *>(GetOutputSignalMemory(7));
|
||||||
|
|
||||||
|
outputAPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(8));
|
||||||
|
outputAPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(9));
|
||||||
|
outputBPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(10));
|
||||||
|
outputBPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(11));
|
||||||
|
outputMHVPSON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(12));
|
||||||
|
|
||||||
|
outputSignalNI6259 = reinterpret_cast<uint32 *>(GetOutputSignalMemory(13));
|
||||||
|
outputSignalNI6528P3 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(14));
|
||||||
|
outputSignalNI6528P4 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(15));
|
||||||
|
|
||||||
|
*shotCounter = 0;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JARTStateMachineGAM::Execute() {
|
||||||
|
using namespace MARTe;
|
||||||
|
|
||||||
|
if (currentState == WaitTrigger) {
|
||||||
|
|
||||||
|
//State Transition condition
|
||||||
|
if ((*triggerSignal == conditionTrigger)) {
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "Start beam-on sequence at %d.", *currentTime);
|
||||||
|
plcOnTime = *currentTime; //Save pulse start time.
|
||||||
|
//*outputBeamON = 0;
|
||||||
|
//State transition.
|
||||||
|
currentState = SwitchingHVPS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (currentState == SwitchingHVPS) {
|
||||||
|
|
||||||
|
//Actions in this state.
|
||||||
|
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||||
|
*outputSignal = 0;
|
||||||
|
currentState = HVTerminate;
|
||||||
|
}
|
||||||
|
if (*currentTime >= (plcOnTime + *triggerDelay_bps_hvon) && bps_hvon_is_on == false){
|
||||||
|
//Do action
|
||||||
|
*outputSignal += bps_hvon;
|
||||||
|
bps_hvon_is_on = true; bps_hvon_state=1;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "bps_hvon was set to outputSignal at %d.", *currentTime);
|
||||||
|
*outputBPSHVON=1;
|
||||||
|
}
|
||||||
|
if (*currentTime >= (plcOnTime + *triggerDelay_aps_hvon) && aps_hvon_is_on == false) {
|
||||||
|
//Do action
|
||||||
|
*outputSignal += aps_hvon;
|
||||||
|
aps_hvon_is_on = true; aps_hvon_state=1;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "aps_hvon was set to outputSignal at %d.", *currentTime);
|
||||||
|
*outputAPSHVON=1;
|
||||||
|
}
|
||||||
|
if (*currentTime >= (plcOnTime + *triggerDelay_bps_swon) && bps_swon_is_on==false){
|
||||||
|
//Do action
|
||||||
|
*outputSignal += bps_swon;
|
||||||
|
bps_swon_is_on = true; bps_swon_state=1;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "bps_swon was set to outputSignal at %d.", *currentTime);
|
||||||
|
*outputBPSSWON=1;
|
||||||
|
}
|
||||||
|
if (*currentTime >= (plcOnTime + *triggerDelay_mhvps_hvon) && mhvps_hvon_is_on==false) {
|
||||||
|
//Do action
|
||||||
|
*outputSignal += mhvps_hvon;
|
||||||
|
mhvps_hvon_is_on = true; mhvps_hvon_state=1;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "mhvps_hvon was set to outputSignal at %d.", *currentTime);
|
||||||
|
*outputMHVPSON=1;
|
||||||
|
}
|
||||||
|
if (bps_swon_is_on && mhvps_hvon_is_on && *currentTime >= (plcOnTime + *triggerDelay_aps_swon)){
|
||||||
|
//Do action
|
||||||
|
*outputSignal += aps_swon;
|
||||||
|
aps_swon_is_on = true; aps_swon_state=1;
|
||||||
|
apsSwonHighResolutionTime = getCurrentTimeUs();
|
||||||
|
apsSwonTime = *currentTime;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "aps_swon was set to outputSignal at %d.", *currentTime);
|
||||||
|
*outputAPSSWON=1;
|
||||||
|
}
|
||||||
|
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
|
||||||
|
if (bps_hvon_is_on && aps_hvon_is_on){
|
||||||
|
*outputHVArmed = 1;
|
||||||
|
}
|
||||||
|
if (bps_swon_is_on || mhvps_hvon_is_on){
|
||||||
|
*outputHVInjection = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//State transition condition
|
||||||
|
if (aps_swon_is_on){
|
||||||
|
currentState = RFON;
|
||||||
|
*outputRFON = 0;
|
||||||
|
*outputBeamON = 1;
|
||||||
|
*shotCounter += 1;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to RFON");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (currentState == RFON) {
|
||||||
|
|
||||||
|
//Action in this state.
|
||||||
|
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||||
|
//debug
|
||||||
|
//if((*stopRequest != 0)){
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "Stop request was called.!!!");
|
||||||
|
//} else {
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset.!!!");
|
||||||
|
//}
|
||||||
|
*outputSignal -= aps_swon;
|
||||||
|
mhvps_hvon_is_on = false; mhvps_hvon_state=0;
|
||||||
|
aps_hvon_is_on = false; aps_hvon_state=0;
|
||||||
|
aps_swon_is_on = false; aps_swon_state=0;
|
||||||
|
bps_hvon_is_on = false; bps_hvon_state=0;
|
||||||
|
bps_swon_is_on = false; bps_swon_state=0;
|
||||||
|
currentState = HVTerminate;
|
||||||
|
*outputAPSHVON=0;
|
||||||
|
*outputAPSSWON=0;
|
||||||
|
*outputBPSHVON=0;
|
||||||
|
*outputBPSSWON=0;
|
||||||
|
*outputMHVPSON=0;
|
||||||
|
}
|
||||||
|
uint32 updatePeriod = 100; // in microsecnds (get this from Timer)
|
||||||
|
if ((*modePulseLengthLimit == 1u) || (getCurrentTimeUs() + updatePeriod >= (apsSwonHighResolutionTime + *triggerDelay_shotlen))) {
|
||||||
|
|
||||||
|
// Now we do busy wait
|
||||||
|
while (getCurrentTimeUs() < (apsSwonHighResolutionTime + *triggerDelay_shotlen)) {
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "!");
|
||||||
|
}
|
||||||
|
// We stop busy waiting #executionOverhead before expected pulse off time
|
||||||
|
//debug
|
||||||
|
//if((*modePulseLengthLimit == 1u)){
|
||||||
|
// REPORT_ERROR(ErrorManagement::Debug, "Mode limit detected.!!!");
|
||||||
|
//} else {
|
||||||
|
// REPORT_ERROR(ErrorManagement::Debug, "Shot length reached to the setpoint.!!!");
|
||||||
|
//}
|
||||||
|
//debug end.
|
||||||
|
//Do action
|
||||||
|
*outputSignal -= aps_swon; //Turn off only APS_SWON first.
|
||||||
|
mhvps_hvon_is_on = false;
|
||||||
|
aps_hvon_is_on = false;
|
||||||
|
aps_swon_is_on = false; aps_swon_state=0;
|
||||||
|
bps_hvon_is_on = false;
|
||||||
|
bps_swon_is_on = false;
|
||||||
|
*outputAPSHVON=0;
|
||||||
|
*outputAPSSWON=0;
|
||||||
|
*outputBPSHVON=0;
|
||||||
|
*outputBPSSWON=0;
|
||||||
|
*outputMHVPSON=0;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "0 was set to outputSignal at %d.", *currentTime);
|
||||||
|
}
|
||||||
|
*outputRFON = 1;
|
||||||
|
*outputBeamONTime = *currentTime - plcOnTime;
|
||||||
|
*outputRFONTime = *currentTime - apsSwonTime;
|
||||||
|
|
||||||
|
|
||||||
|
//State transition condition
|
||||||
|
if (!aps_swon_is_on && !bps_swon_is_on && !mhvps_hvon_is_on) {
|
||||||
|
currentState = HVTerminate;
|
||||||
|
apsSwoffTime = *currentTime;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to HVTerminate");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (currentState == HVTerminate) {
|
||||||
|
//In the HVTerminate state, turn APS_SWON off first, and wait 1ms. Finally turn other PS off.
|
||||||
|
//Action in this state.
|
||||||
|
*outputBeamON = 0;
|
||||||
|
*outputHVArmed = 0;
|
||||||
|
*outputHVInjection = 0;
|
||||||
|
*outputRFON = 0;
|
||||||
|
|
||||||
|
// State transition condition.
|
||||||
|
if (*currentTime - apsSwoffTime >= turn_off_delay){
|
||||||
|
*outputSignal = 0;
|
||||||
|
mhvps_hvon_state=0;
|
||||||
|
aps_hvon_state=0;
|
||||||
|
bps_hvon_state=0;
|
||||||
|
bps_swon_state=0;
|
||||||
|
}
|
||||||
|
if (*triggerSignal == false){
|
||||||
|
//Check PLC_ON is reset
|
||||||
|
currentState = WaitTrigger;
|
||||||
|
*outputSignal = 0;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset. The State was changed to WaitTrigger at %d.", *currentTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(*short_pulse_mode == 1){
|
||||||
|
p3Value = 1*aps_hvon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
|
||||||
|
*outputSignalNI6259 = 1*aps_swon_state;
|
||||||
|
*outputSignalNI6528P3 = ~p3Value;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "short pulse mode with p3: %d.", p3Value);
|
||||||
|
} else {
|
||||||
|
p3Value = 1*aps_hvon_state +2*aps_swon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
|
||||||
|
*outputSignalNI6528P3 = ~p3Value;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "long pulse mode with p3: %d.", p3Value);
|
||||||
|
}
|
||||||
|
if (modulation) {
|
||||||
|
p4Value = 8*mhvps_hvon_state + 32;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
p4Value = 8*mhvps_hvon_state;
|
||||||
|
}
|
||||||
|
//*outputSignalNI6528P4 = ~(*ni6528p4Value | p4Value);
|
||||||
|
*outputSignalNI6528P4 = ~p4Value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JARTStateMachineGAM, "1.0")
|
||||||
@@ -0,0 +1,262 @@
|
|||||||
|
/**
|
||||||
|
* @file JARTStateMachineGAM.h
|
||||||
|
* @brief Header file for class JARTStateMachineGAM
|
||||||
|
* @date Nov 26, 2018
|
||||||
|
* @author aneto
|
||||||
|
*
|
||||||
|
* @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 JARTStateMachineGAM
|
||||||
|
* 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 GAMS_JARTSTATEMACHINEGAM_H_
|
||||||
|
#define GAMS_JARTSTATEMACHINEGAM_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "GAM.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GAM that provides real-time state machine.
|
||||||
|
*
|
||||||
|
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||||
|
* <pre>
|
||||||
|
* +GAMRealTimeStateMachine = {
|
||||||
|
* Class = JARTStateMachineGAM
|
||||||
|
* ConditionTrigger = 1
|
||||||
|
* mhvps_hvon = 4
|
||||||
|
* aps_hvon = 1
|
||||||
|
* aps_swon = 16
|
||||||
|
* bps_hvon = 2
|
||||||
|
* bps_swon = 8
|
||||||
|
* InputSignals = {
|
||||||
|
* Time = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* PLC_ON = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* MHVPS_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* APS_HVON_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* APS_SWON_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* BPS_HVON_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* BPS_SWON_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* SHOTLEN = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* StopRequest = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* MODE_SHOTLEN_FLAG = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* OutputSignals = {
|
||||||
|
* Value = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* Trigger = 1
|
||||||
|
* }
|
||||||
|
* BEAM_ON_STAT = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* HVARMED = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* HVINJECTION = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* RFON = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* BeamONTime = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* RFONTime = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* SHOT_ID = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class JARTStateMachineGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
JARTStateMachineGAM();
|
||||||
|
|
||||||
|
virtual ~JARTStateMachineGAM();
|
||||||
|
|
||||||
|
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||||
|
|
||||||
|
virtual bool Setup();
|
||||||
|
|
||||||
|
virtual bool Execute();
|
||||||
|
|
||||||
|
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
|
||||||
|
const MARTe::char8 * const nextStateName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
//The list of possible states
|
||||||
|
enum JARealTimeState {
|
||||||
|
WaitTrigger = 0,
|
||||||
|
SwitchingHVPS = 1,
|
||||||
|
RFON = 2,
|
||||||
|
HVTerminate = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
//The current rtState
|
||||||
|
JARealTimeState currentState;
|
||||||
|
|
||||||
|
//A given condition
|
||||||
|
MARTe::uint32 conditionTrigger;
|
||||||
|
|
||||||
|
//What to output in a given state and condition
|
||||||
|
MARTe::uint32 mhvps_hvon;
|
||||||
|
MARTe::uint32 aps_hvon;
|
||||||
|
MARTe::uint32 aps_swon;
|
||||||
|
MARTe::uint32 bps_hvon;
|
||||||
|
MARTe::uint32 bps_swon;
|
||||||
|
|
||||||
|
//The trigger signal (PLC_ON)
|
||||||
|
MARTe::uint32 *triggerSignal;
|
||||||
|
|
||||||
|
//Time signal
|
||||||
|
MARTe::uint32 *currentTime;
|
||||||
|
|
||||||
|
// Input signals for trigger delay parameters
|
||||||
|
MARTe::uint32 *triggerDelay_mhvps_hvon;
|
||||||
|
MARTe::uint32 *triggerDelay_aps_hvon;
|
||||||
|
MARTe::uint32 *triggerDelay_aps_swon;
|
||||||
|
MARTe::uint32 *triggerDelay_bps_hvon;
|
||||||
|
MARTe::uint32 *triggerDelay_bps_swon;
|
||||||
|
MARTe::uint32 *triggerDelay_shotlen;
|
||||||
|
|
||||||
|
// Input signal for sequence stop request.
|
||||||
|
MARTe::uint32 *stopRequest;
|
||||||
|
// Input signal for pulse length limit by mode.
|
||||||
|
MARTe::uint32 *modePulseLengthLimit;
|
||||||
|
// Input signal for short pulse mode.
|
||||||
|
MARTe::uint32 *short_pulse_mode;
|
||||||
|
// Input signal for modulation pv.
|
||||||
|
MARTe::uint32 *modulation;
|
||||||
|
|
||||||
|
// Output signal to which the output value will be written.
|
||||||
|
// One state write One signal.
|
||||||
|
MARTe::uint32 *outputSignal;
|
||||||
|
// state notify output
|
||||||
|
MARTe::uint32 *outputBeamON;
|
||||||
|
MARTe::uint32 *outputHVArmed;
|
||||||
|
MARTe::uint32 *outputHVInjection;
|
||||||
|
MARTe::uint32 *outputRFON;
|
||||||
|
// elapsed time notify output;
|
||||||
|
MARTe::uint32 *outputBeamONTime;
|
||||||
|
MARTe::uint32 *outputRFONTime;
|
||||||
|
// shot counter (coutup every RFON time.)
|
||||||
|
MARTe::uint32 *shotCounter;
|
||||||
|
|
||||||
|
// Added for HVPS state (20201117)
|
||||||
|
MARTe::uint32 *outputAPSHVON;
|
||||||
|
MARTe::uint32 *outputAPSSWON;
|
||||||
|
MARTe::uint32 *outputBPSHVON;
|
||||||
|
MARTe::uint32 *outputBPSSWON;
|
||||||
|
MARTe::uint32 *outputMHVPSON;
|
||||||
|
|
||||||
|
// Output signals for NI devices
|
||||||
|
MARTe::uint32 *outputSignalNI6259;
|
||||||
|
MARTe::uint8 *outputSignalNI6528P3;
|
||||||
|
MARTe::uint8 *outputSignalNI6528P4;
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
//Internal Parameters
|
||||||
|
//////////////////////////////
|
||||||
|
//PLC_ON time holder
|
||||||
|
MARTe::uint32 plcOnTime;
|
||||||
|
//APS_SWON time holder
|
||||||
|
MARTe::uint32 apsSwonTime;
|
||||||
|
MARTe::uint32 apsSwoffTime;
|
||||||
|
MARTe::uint64 apsSwonHighResolutionTime;
|
||||||
|
|
||||||
|
//PS turn off delay
|
||||||
|
MARTe::uint32 turn_off_delay;
|
||||||
|
|
||||||
|
//HVPS state holder
|
||||||
|
bool mhvps_hvon_is_on;
|
||||||
|
bool aps_hvon_is_on;
|
||||||
|
bool aps_swon_is_on;
|
||||||
|
bool bps_hvon_is_on;
|
||||||
|
bool bps_swon_is_on;
|
||||||
|
|
||||||
|
// terminal values
|
||||||
|
MARTe::uint8 p3Value;
|
||||||
|
MARTe::uint8 p4Value;
|
||||||
|
MARTe::uint8 aps_hvon_state;
|
||||||
|
MARTe::uint8 aps_swon_state;
|
||||||
|
MARTe::uint8 mhvps_hvon_state;
|
||||||
|
MARTe::uint8 bps_hvon_state;
|
||||||
|
MARTe::uint8 bps_swon_state;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* GAMS_JARTSTATEMACHINEGAM_H_ */
|
||||||
@@ -0,0 +1,409 @@
|
|||||||
|
/**
|
||||||
|
* @file JARTStateMachineGAM.cpp
|
||||||
|
* @brief Source file for class JARTStateMachineGAM
|
||||||
|
* @date Nov 26, 2018
|
||||||
|
* @author aneto
|
||||||
|
*
|
||||||
|
* @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 JARTStateMachineGAM (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 "JARTStateMachineGAM.h"
|
||||||
|
|
||||||
|
#include "AdvancedErrorManagement.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static MARTe::uint64 getCurrentTimeUs() {
|
||||||
|
using namespace MARTe;
|
||||||
|
return static_cast<uint64>(HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1e6f + 0.5f);
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
JARTStateMachineGAM::JARTStateMachineGAM() {
|
||||||
|
currentState = WaitTrigger; // Set Entry state.
|
||||||
|
plcOnTime = 0; // Triggered time holder.
|
||||||
|
|
||||||
|
//Output and condition in a given state.
|
||||||
|
conditionTrigger = 1;
|
||||||
|
aps_hvon = 0;
|
||||||
|
aps_swon = 0;
|
||||||
|
bps_hvon = 0;
|
||||||
|
bps_swon = 0;
|
||||||
|
mhvps_hvon = 0;
|
||||||
|
|
||||||
|
// Parameters which get from Input signals.
|
||||||
|
triggerSignal = NULL_PTR(MARTe::uint32 *);
|
||||||
|
currentTime = NULL_PTR(MARTe::uint32 *);
|
||||||
|
turn_off_delay = 2000; //us
|
||||||
|
|
||||||
|
triggerDelay_mhvps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_aps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_aps_swon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_bps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_bps_swon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_shotlen = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
stopRequest = NULL_PTR(MARTe::uint32 *);
|
||||||
|
modePulseLengthLimit = NULL_PTR(MARTe::uint32 *);
|
||||||
|
short_pulse_mode = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
modulation = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
// write out target.
|
||||||
|
outputSignal = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputBeamON = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputHVArmed = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputHVInjection = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputRFON = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputBeamONTime = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputRFONTime = NULL_PTR(MARTe::uint32 *);
|
||||||
|
shotCounter = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
mhvps_hvon_is_on = false;
|
||||||
|
aps_hvon_is_on = false;
|
||||||
|
aps_swon_is_on = false;
|
||||||
|
bps_hvon_is_on = false;
|
||||||
|
bps_swon_is_on = false;
|
||||||
|
|
||||||
|
apsSwonHighResolutionTime = 0;
|
||||||
|
|
||||||
|
aps_hvon_state=0;
|
||||||
|
aps_swon_state=0;
|
||||||
|
mhvps_hvon_state=0;
|
||||||
|
bps_hvon_state=0;
|
||||||
|
bps_swon_state=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
JARTStateMachineGAM::~JARTStateMachineGAM() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JARTStateMachineGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = GAM::Initialise(data);
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("ConditionTrigger", conditionTrigger);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Condition1 shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("mhvps_hvon", mhvps_hvon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The mhvps_hvon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("aps_hvon", aps_hvon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_hvon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("aps_swon", aps_swon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_swon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("bps_hvon", bps_hvon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_hvon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("bps_swon", bps_swon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_swon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JARTStateMachineGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JARTStateMachineGAM::Setup() {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = (numberOfInputSignals == 13u);
|
||||||
|
if (ok) {
|
||||||
|
ok = (numberOfOutputSignals == 16u);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Seven output signals shall be defined %d",numberOfOutputSignals);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Nine input signals shall be defined");
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||||
|
ok = (inputType == UnsignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfOutputSignals; c++) {
|
||||||
|
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
|
||||||
|
ok = (outputType == UnsignedInteger32Bit || outputType == UnsignedInteger8Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
currentTime = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||||
|
triggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
|
||||||
|
triggerDelay_mhvps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
|
||||||
|
triggerDelay_aps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
|
||||||
|
triggerDelay_aps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
|
||||||
|
triggerDelay_bps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
|
||||||
|
triggerDelay_bps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
|
||||||
|
triggerDelay_shotlen = reinterpret_cast<uint32 *>(GetInputSignalMemory(7));
|
||||||
|
stopRequest = reinterpret_cast<uint32 *>(GetInputSignalMemory(8));
|
||||||
|
modePulseLengthLimit = reinterpret_cast<uint32 *>(GetInputSignalMemory(9));
|
||||||
|
short_pulse_mode = reinterpret_cast<uint32 *>(GetInputSignalMemory(10));
|
||||||
|
modulation = reinterpret_cast<uint32 *>(GetInputSignalMemory(11));
|
||||||
|
pauseSet = reinterpret_cast<uint32 *>(GetInputSignalMemory(12));
|
||||||
|
|
||||||
|
|
||||||
|
outputSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
|
||||||
|
outputBeamON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(1));
|
||||||
|
outputHVArmed = reinterpret_cast<uint32 *>(GetOutputSignalMemory(2));
|
||||||
|
outputHVInjection = reinterpret_cast<uint32 *>(GetOutputSignalMemory(3));
|
||||||
|
outputRFON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(4));
|
||||||
|
outputBeamONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(5));
|
||||||
|
outputRFONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(6));
|
||||||
|
shotCounter = reinterpret_cast<uint32 *>(GetOutputSignalMemory(7));
|
||||||
|
|
||||||
|
outputAPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(8));
|
||||||
|
outputAPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(9));
|
||||||
|
outputBPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(10));
|
||||||
|
outputBPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(11));
|
||||||
|
outputMHVPSON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(12));
|
||||||
|
|
||||||
|
outputSignalNI6259 = reinterpret_cast<uint32 *>(GetOutputSignalMemory(13));
|
||||||
|
outputSignalNI6528P3 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(14));
|
||||||
|
outputSignalNI6528P4 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(15));
|
||||||
|
|
||||||
|
*shotCounter = 0;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JARTStateMachineGAM::Execute() {
|
||||||
|
using namespace MARTe;
|
||||||
|
|
||||||
|
if (currentState == WaitTrigger) {
|
||||||
|
|
||||||
|
//State Transition condition
|
||||||
|
if ((*triggerSignal == conditionTrigger)) {
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "Start beam-on sequence at %d.", *currentTime);
|
||||||
|
plcOnTime = *currentTime; //Save pulse start time.
|
||||||
|
//*outputBeamON = 0;
|
||||||
|
//State transition.
|
||||||
|
currentState = SwitchingHVPS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (currentState == SwitchingHVPS) {
|
||||||
|
|
||||||
|
//Actions in this state.
|
||||||
|
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||||
|
*outputSignal = 0;
|
||||||
|
currentState = HVTerminate;
|
||||||
|
}
|
||||||
|
if (*currentTime >= (plcOnTime + *triggerDelay_bps_hvon) && bps_hvon_is_on == false){
|
||||||
|
//Do action
|
||||||
|
*outputSignal += bps_hvon;
|
||||||
|
bps_hvon_is_on = true; bps_hvon_state=1;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "bps_hvon was set to outputSignal at %d.", *currentTime);
|
||||||
|
*outputBPSHVON=1;
|
||||||
|
}
|
||||||
|
if (*currentTime >= (plcOnTime + *triggerDelay_aps_hvon) && aps_hvon_is_on == false) {
|
||||||
|
//Do action
|
||||||
|
*outputSignal += aps_hvon;
|
||||||
|
aps_hvon_is_on = true; aps_hvon_state=1;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "aps_hvon was set to outputSignal at %d.", *currentTime);
|
||||||
|
*outputAPSHVON=1;
|
||||||
|
}
|
||||||
|
if (*currentTime >= (plcOnTime + *triggerDelay_bps_swon) && bps_swon_is_on==false){
|
||||||
|
//Do action
|
||||||
|
*outputSignal += bps_swon;
|
||||||
|
bps_swon_is_on = true; bps_swon_state=1;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "bps_swon was set to outputSignal at %d.", *currentTime);
|
||||||
|
*outputBPSSWON=1;
|
||||||
|
}
|
||||||
|
if (*currentTime >= (plcOnTime + *triggerDelay_mhvps_hvon) && mhvps_hvon_is_on==false) {
|
||||||
|
//Do action
|
||||||
|
*outputSignal += mhvps_hvon;
|
||||||
|
mhvps_hvon_is_on = true; mhvps_hvon_state=1;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "mhvps_hvon was set to outputSignal at %d.", *currentTime);
|
||||||
|
*outputMHVPSON=1;
|
||||||
|
}
|
||||||
|
if (bps_swon_is_on && mhvps_hvon_is_on && *currentTime >= (plcOnTime + *triggerDelay_aps_swon)){
|
||||||
|
//Do action
|
||||||
|
*outputSignal += aps_swon;
|
||||||
|
aps_swon_is_on = true; aps_swon_state=1;
|
||||||
|
apsSwonHighResolutionTime = getCurrentTimeUs();
|
||||||
|
apsSwonTime = *currentTime;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "aps_swon was set to outputSignal at %d.", *currentTime);
|
||||||
|
*outputAPSSWON=1;
|
||||||
|
}
|
||||||
|
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
|
||||||
|
if (bps_hvon_is_on && aps_hvon_is_on){
|
||||||
|
*outputHVArmed = 1;
|
||||||
|
}
|
||||||
|
if (bps_swon_is_on || mhvps_hvon_is_on){
|
||||||
|
*outputHVInjection = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//State transition condition
|
||||||
|
if (aps_swon_is_on){
|
||||||
|
currentState = RFON;
|
||||||
|
*outputRFON = 0;
|
||||||
|
*outputBeamON = 1;
|
||||||
|
*shotCounter += 1;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to RFON");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (currentState == RFON) {
|
||||||
|
|
||||||
|
//Action in this state.
|
||||||
|
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||||
|
//debug
|
||||||
|
//if((*stopRequest != 0)){
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "Stop request was called.!!!");
|
||||||
|
//} else {
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset.!!!");
|
||||||
|
//}
|
||||||
|
*outputSignal -= aps_swon;
|
||||||
|
mhvps_hvon_is_on = false; mhvps_hvon_state=0;
|
||||||
|
aps_hvon_is_on = false; aps_hvon_state=0;
|
||||||
|
aps_swon_is_on = false; aps_swon_state=0;
|
||||||
|
bps_hvon_is_on = false; bps_hvon_state=0;
|
||||||
|
bps_swon_is_on = false; bps_swon_state=0;
|
||||||
|
currentState = HVTerminate;
|
||||||
|
*outputAPSHVON=0;
|
||||||
|
*outputAPSSWON=0;
|
||||||
|
*outputBPSHVON=0;
|
||||||
|
*outputBPSSWON=0;
|
||||||
|
*outputMHVPSON=0;
|
||||||
|
}
|
||||||
|
uint32 updatePeriod = 100; // in microsecnds (get this from Timer)
|
||||||
|
if ((*modePulseLengthLimit == 1u) || (getCurrentTimeUs() + updatePeriod >= (apsSwonHighResolutionTime + *triggerDelay_shotlen))) {
|
||||||
|
|
||||||
|
// Now we do busy wait
|
||||||
|
while (getCurrentTimeUs() < (apsSwonHighResolutionTime + *triggerDelay_shotlen)) {
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "!");
|
||||||
|
}
|
||||||
|
// We stop busy waiting #executionOverhead before expected pulse off time
|
||||||
|
//debug
|
||||||
|
//if((*modePulseLengthLimit == 1u)){
|
||||||
|
// REPORT_ERROR(ErrorManagement::Debug, "Mode limit detected.!!!");
|
||||||
|
//} else {
|
||||||
|
// REPORT_ERROR(ErrorManagement::Debug, "Shot length reached to the setpoint.!!!");
|
||||||
|
//}
|
||||||
|
//debug end.
|
||||||
|
//Do action
|
||||||
|
*outputSignal -= aps_swon; //Turn off only APS_SWON first.
|
||||||
|
mhvps_hvon_is_on = false;
|
||||||
|
aps_hvon_is_on = false;
|
||||||
|
aps_swon_is_on = false; aps_swon_state=0;
|
||||||
|
bps_hvon_is_on = false;
|
||||||
|
bps_swon_is_on = false;
|
||||||
|
*outputAPSHVON=0;
|
||||||
|
*outputAPSSWON=0;
|
||||||
|
*outputBPSHVON=0;
|
||||||
|
*outputBPSSWON=0;
|
||||||
|
*outputMHVPSON=0;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "0 was set to outputSignal at %d.", *currentTime);
|
||||||
|
}
|
||||||
|
*outputRFON = 1;
|
||||||
|
*outputBeamONTime = *currentTime - plcOnTime;
|
||||||
|
*outputRFONTime = *currentTime - apsSwonTime;
|
||||||
|
|
||||||
|
|
||||||
|
//State transition condition
|
||||||
|
if (!aps_swon_is_on && !bps_swon_is_on && !mhvps_hvon_is_on) {
|
||||||
|
currentState = HVTerminate;
|
||||||
|
apsSwoffTime = *currentTime;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to HVTerminate");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (currentState == HVTerminate) {
|
||||||
|
//In the HVTerminate state, turn APS_SWON off first, and wait 1ms. Finally turn other PS off.
|
||||||
|
//Action in this state.
|
||||||
|
*outputBeamON = 0;
|
||||||
|
*outputHVArmed = 0;
|
||||||
|
*outputHVInjection = 0;
|
||||||
|
*outputRFON = 0;
|
||||||
|
|
||||||
|
// State transition condition.
|
||||||
|
if (*currentTime - apsSwoffTime >= turn_off_delay){
|
||||||
|
*outputSignal = 0;
|
||||||
|
mhvps_hvon_state=0;
|
||||||
|
aps_hvon_state=0;
|
||||||
|
bps_hvon_state=0;
|
||||||
|
bps_swon_state=0;
|
||||||
|
}
|
||||||
|
if (*triggerSignal == false){
|
||||||
|
//Check PLC_ON is reset
|
||||||
|
currentState = WaitTrigger;
|
||||||
|
*outputSignal = 0;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset. The State was changed to WaitTrigger at %d.", *currentTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(*short_pulse_mode == 1){
|
||||||
|
p3Value = 1*aps_hvon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
|
||||||
|
*outputSignalNI6259 = 1*aps_swon_state;
|
||||||
|
*outputSignalNI6528P3 = ~p3Value;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "short pulse mode with p3: %d.", p3Value);
|
||||||
|
} else {
|
||||||
|
p3Value = 1*aps_hvon_state +2*aps_swon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
|
||||||
|
*outputSignalNI6528P3 = ~p3Value;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "long pulse mode with p3: %d.", p3Value);
|
||||||
|
}
|
||||||
|
p4Value = 8*mhvps_hvon_state;
|
||||||
|
if (modulation) p4Value += 32;
|
||||||
|
if (pauseSet) p4Value += 1;
|
||||||
|
//*outputSignalNI6528P4 = ~(*ni6528p4Value | p4Value);
|
||||||
|
*outputSignalNI6528P4 = ~p4Value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JARTStateMachineGAM, "1.0")
|
||||||
@@ -0,0 +1,264 @@
|
|||||||
|
/**
|
||||||
|
* @file JARTStateMachineGAM.h
|
||||||
|
* @brief Header file for class JARTStateMachineGAM
|
||||||
|
* @date Nov 26, 2018
|
||||||
|
* @author aneto
|
||||||
|
*
|
||||||
|
* @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 JARTStateMachineGAM
|
||||||
|
* 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 GAMS_JARTSTATEMACHINEGAM_H_
|
||||||
|
#define GAMS_JARTSTATEMACHINEGAM_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "GAM.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GAM that provides real-time state machine.
|
||||||
|
*
|
||||||
|
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||||
|
* <pre>
|
||||||
|
* +GAMRealTimeStateMachine = {
|
||||||
|
* Class = JARTStateMachineGAM
|
||||||
|
* ConditionTrigger = 1
|
||||||
|
* mhvps_hvon = 4
|
||||||
|
* aps_hvon = 1
|
||||||
|
* aps_swon = 16
|
||||||
|
* bps_hvon = 2
|
||||||
|
* bps_swon = 8
|
||||||
|
* InputSignals = {
|
||||||
|
* Time = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* PLC_ON = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* MHVPS_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* APS_HVON_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* APS_SWON_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* BPS_HVON_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* BPS_SWON_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* SHOTLEN = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* StopRequest = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* MODE_SHOTLEN_FLAG = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* OutputSignals = {
|
||||||
|
* Value = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* Trigger = 1
|
||||||
|
* }
|
||||||
|
* BEAM_ON_STAT = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* HVARMED = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* HVINJECTION = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* RFON = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* BeamONTime = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* RFONTime = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* SHOT_ID = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class JARTStateMachineGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
JARTStateMachineGAM();
|
||||||
|
|
||||||
|
virtual ~JARTStateMachineGAM();
|
||||||
|
|
||||||
|
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||||
|
|
||||||
|
virtual bool Setup();
|
||||||
|
|
||||||
|
virtual bool Execute();
|
||||||
|
|
||||||
|
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
|
||||||
|
const MARTe::char8 * const nextStateName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
//The list of possible states
|
||||||
|
enum JARealTimeState {
|
||||||
|
WaitTrigger = 0,
|
||||||
|
SwitchingHVPS = 1,
|
||||||
|
RFON = 2,
|
||||||
|
HVTerminate = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
//The current rtState
|
||||||
|
JARealTimeState currentState;
|
||||||
|
|
||||||
|
//A given condition
|
||||||
|
MARTe::uint32 conditionTrigger;
|
||||||
|
|
||||||
|
//What to output in a given state and condition
|
||||||
|
MARTe::uint32 mhvps_hvon;
|
||||||
|
MARTe::uint32 aps_hvon;
|
||||||
|
MARTe::uint32 aps_swon;
|
||||||
|
MARTe::uint32 bps_hvon;
|
||||||
|
MARTe::uint32 bps_swon;
|
||||||
|
|
||||||
|
//The trigger signal (PLC_ON)
|
||||||
|
MARTe::uint32 *triggerSignal;
|
||||||
|
|
||||||
|
//Time signal
|
||||||
|
MARTe::uint32 *currentTime;
|
||||||
|
|
||||||
|
// Input signals for trigger delay parameters
|
||||||
|
MARTe::uint32 *triggerDelay_mhvps_hvon;
|
||||||
|
MARTe::uint32 *triggerDelay_aps_hvon;
|
||||||
|
MARTe::uint32 *triggerDelay_aps_swon;
|
||||||
|
MARTe::uint32 *triggerDelay_bps_hvon;
|
||||||
|
MARTe::uint32 *triggerDelay_bps_swon;
|
||||||
|
MARTe::uint32 *triggerDelay_shotlen;
|
||||||
|
|
||||||
|
// Input signal for sequence stop request.
|
||||||
|
MARTe::uint32 *stopRequest;
|
||||||
|
// Input signal for pulse length limit by mode.
|
||||||
|
MARTe::uint32 *modePulseLengthLimit;
|
||||||
|
// Input signal for short pulse mode.
|
||||||
|
MARTe::uint32 *short_pulse_mode;
|
||||||
|
// Input signal for modulation pv.
|
||||||
|
MARTe::uint32 *modulation;
|
||||||
|
// Input signal for pause signal set pv.
|
||||||
|
MARTe::uint32 *pauseSet;
|
||||||
|
|
||||||
|
// Output signal to which the output value will be written.
|
||||||
|
// One state write One signal.
|
||||||
|
MARTe::uint32 *outputSignal;
|
||||||
|
// state notify output
|
||||||
|
MARTe::uint32 *outputBeamON;
|
||||||
|
MARTe::uint32 *outputHVArmed;
|
||||||
|
MARTe::uint32 *outputHVInjection;
|
||||||
|
MARTe::uint32 *outputRFON;
|
||||||
|
// elapsed time notify output;
|
||||||
|
MARTe::uint32 *outputBeamONTime;
|
||||||
|
MARTe::uint32 *outputRFONTime;
|
||||||
|
// shot counter (coutup every RFON time.)
|
||||||
|
MARTe::uint32 *shotCounter;
|
||||||
|
|
||||||
|
// Added for HVPS state (20201117)
|
||||||
|
MARTe::uint32 *outputAPSHVON;
|
||||||
|
MARTe::uint32 *outputAPSSWON;
|
||||||
|
MARTe::uint32 *outputBPSHVON;
|
||||||
|
MARTe::uint32 *outputBPSSWON;
|
||||||
|
MARTe::uint32 *outputMHVPSON;
|
||||||
|
|
||||||
|
// Output signals for NI devices
|
||||||
|
MARTe::uint32 *outputSignalNI6259;
|
||||||
|
MARTe::uint8 *outputSignalNI6528P3;
|
||||||
|
MARTe::uint8 *outputSignalNI6528P4;
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
//Internal Parameters
|
||||||
|
//////////////////////////////
|
||||||
|
//PLC_ON time holder
|
||||||
|
MARTe::uint32 plcOnTime;
|
||||||
|
//APS_SWON time holder
|
||||||
|
MARTe::uint32 apsSwonTime;
|
||||||
|
MARTe::uint32 apsSwoffTime;
|
||||||
|
MARTe::uint64 apsSwonHighResolutionTime;
|
||||||
|
|
||||||
|
//PS turn off delay
|
||||||
|
MARTe::uint32 turn_off_delay;
|
||||||
|
|
||||||
|
//HVPS state holder
|
||||||
|
bool mhvps_hvon_is_on;
|
||||||
|
bool aps_hvon_is_on;
|
||||||
|
bool aps_swon_is_on;
|
||||||
|
bool bps_hvon_is_on;
|
||||||
|
bool bps_swon_is_on;
|
||||||
|
|
||||||
|
// terminal values
|
||||||
|
MARTe::uint8 p3Value;
|
||||||
|
MARTe::uint8 p4Value;
|
||||||
|
MARTe::uint8 aps_hvon_state;
|
||||||
|
MARTe::uint8 aps_swon_state;
|
||||||
|
MARTe::uint8 mhvps_hvon_state;
|
||||||
|
MARTe::uint8 bps_hvon_state;
|
||||||
|
MARTe::uint8 bps_swon_state;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* GAMS_JARTSTATEMACHINEGAM_H_ */
|
||||||
@@ -0,0 +1,402 @@
|
|||||||
|
/**
|
||||||
|
* @file JARTStateMachineGAM.cpp
|
||||||
|
* @brief Source file for class JARTStateMachineGAM
|
||||||
|
* @date Nov 26, 2018
|
||||||
|
* @author aneto
|
||||||
|
*
|
||||||
|
* @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 JARTStateMachineGAM (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 "JARTStateMachineGAM.h"
|
||||||
|
|
||||||
|
#include "AdvancedErrorManagement.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static MARTe::uint64 getCurrentTimeUs() {
|
||||||
|
using namespace MARTe;
|
||||||
|
return static_cast<uint64>(HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1e6f + 0.5f);
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
JARTStateMachineGAM::JARTStateMachineGAM() {
|
||||||
|
currentState = WaitTrigger; // Set Entry state.
|
||||||
|
plcOnTime = 0; // Triggered time holder.
|
||||||
|
|
||||||
|
//Output and condition in a given state.
|
||||||
|
conditionTrigger = 1;
|
||||||
|
aps_hvon = 0;
|
||||||
|
aps_swon = 0;
|
||||||
|
bps_hvon = 0;
|
||||||
|
bps_swon = 0;
|
||||||
|
mhvps_hvon = 0;
|
||||||
|
|
||||||
|
// Parameters which get from Input signals.
|
||||||
|
triggerSignal = NULL_PTR(MARTe::uint32 *);
|
||||||
|
currentTime = NULL_PTR(MARTe::uint32 *);
|
||||||
|
turn_off_delay = 2000; //us
|
||||||
|
|
||||||
|
triggerDelay_mhvps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_aps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_aps_swon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_bps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_bps_swon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_shotlen = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
stopRequest = NULL_PTR(MARTe::uint32 *);
|
||||||
|
modePulseLengthLimit = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
// write out target.
|
||||||
|
outputSignal = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputBeamON = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputHVArmed = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputHVInjection = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputRFON = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputBeamONTime = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputRFONTime = NULL_PTR(MARTe::uint32 *);
|
||||||
|
shotCounter = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
mhvps_hvon_is_on = false;
|
||||||
|
aps_hvon_is_on = false;
|
||||||
|
aps_swon_is_on = false;
|
||||||
|
bps_hvon_is_on = false;
|
||||||
|
bps_swon_is_on = false;
|
||||||
|
|
||||||
|
apsSwonHighResolutionTime = 0;
|
||||||
|
|
||||||
|
aps_hvon_state=0;
|
||||||
|
aps_swon_state=0;
|
||||||
|
mhvps_hvon_state=0;
|
||||||
|
bps_hvon_state=0;
|
||||||
|
bps_swon_state=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
JARTStateMachineGAM::~JARTStateMachineGAM() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JARTStateMachineGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = GAM::Initialise(data);
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("ConditionTrigger", conditionTrigger);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Condition1 shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("mhvps_hvon", mhvps_hvon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The mhvps_hvon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("aps_hvon", aps_hvon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_hvon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("aps_swon", aps_swon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_swon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("bps_hvon", bps_hvon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_hvon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("bps_swon", bps_swon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_swon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JARTStateMachineGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JARTStateMachineGAM::Setup() {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = (numberOfInputSignals == 11u);
|
||||||
|
if (ok) {
|
||||||
|
ok = (numberOfOutputSignals == 16u);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Seven output signals shall be defined %d",numberOfOutputSignals);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Nine input signals shall be defined");
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||||
|
ok = (inputType == UnsignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfOutputSignals; c++) {
|
||||||
|
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
|
||||||
|
ok = (outputType == UnsignedInteger32Bit || outputType == UnsignedInteger8Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
currentTime = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||||
|
triggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
|
||||||
|
triggerDelay_mhvps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
|
||||||
|
triggerDelay_aps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
|
||||||
|
triggerDelay_aps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
|
||||||
|
triggerDelay_bps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
|
||||||
|
triggerDelay_bps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
|
||||||
|
triggerDelay_shotlen = reinterpret_cast<uint32 *>(GetInputSignalMemory(7));
|
||||||
|
stopRequest = reinterpret_cast<uint32 *>(GetInputSignalMemory(8));
|
||||||
|
modePulseLengthLimit = reinterpret_cast<uint32 *>(GetInputSignalMemory(9));
|
||||||
|
short_pulse_mode = reinterpret_cast<uint32 *>(GetInputSignalMemory(10));
|
||||||
|
|
||||||
|
|
||||||
|
outputSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
|
||||||
|
outputBeamON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(1));
|
||||||
|
outputHVArmed = reinterpret_cast<uint32 *>(GetOutputSignalMemory(2));
|
||||||
|
outputHVInjection = reinterpret_cast<uint32 *>(GetOutputSignalMemory(3));
|
||||||
|
outputRFON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(4));
|
||||||
|
outputBeamONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(5));
|
||||||
|
outputRFONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(6));
|
||||||
|
shotCounter = reinterpret_cast<uint32 *>(GetOutputSignalMemory(7));
|
||||||
|
|
||||||
|
outputAPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(8));
|
||||||
|
outputAPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(9));
|
||||||
|
outputBPSHVON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(10));
|
||||||
|
outputBPSSWON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(11));
|
||||||
|
outputMHVPSON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(12));
|
||||||
|
|
||||||
|
outputSignalNI6259 = reinterpret_cast<uint32 *>(GetOutputSignalMemory(13));
|
||||||
|
outputSignalNI6528P3 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(14));
|
||||||
|
outputSignalNI6528P4 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(15));
|
||||||
|
|
||||||
|
*shotCounter = 0;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JARTStateMachineGAM::Execute() {
|
||||||
|
using namespace MARTe;
|
||||||
|
|
||||||
|
if (currentState == WaitTrigger) {
|
||||||
|
|
||||||
|
//State Transition condition
|
||||||
|
if ((*triggerSignal == conditionTrigger)) {
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "Start beam-on sequence at %d.", *currentTime);
|
||||||
|
plcOnTime = *currentTime; //Save pulse start time.
|
||||||
|
//*outputBeamON = 0;
|
||||||
|
//State transition.
|
||||||
|
currentState = SwitchingHVPS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (currentState == SwitchingHVPS) {
|
||||||
|
|
||||||
|
//Actions in this state.
|
||||||
|
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||||
|
*outputSignal = 0;
|
||||||
|
currentState = HVTerminate;
|
||||||
|
}
|
||||||
|
if (*currentTime >= (plcOnTime + *triggerDelay_bps_hvon) && bps_hvon_is_on == false){
|
||||||
|
//Do action
|
||||||
|
*outputSignal += bps_hvon;
|
||||||
|
bps_hvon_is_on = true; bps_hvon_state=1;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "bps_hvon was set to outputSignal at %d.", *currentTime);
|
||||||
|
*outputBPSHVON=1;
|
||||||
|
}
|
||||||
|
if (*currentTime >= (plcOnTime + *triggerDelay_aps_hvon) && aps_hvon_is_on == false) {
|
||||||
|
//Do action
|
||||||
|
*outputSignal += aps_hvon;
|
||||||
|
aps_hvon_is_on = true; aps_hvon_state=1;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "aps_hvon was set to outputSignal at %d.", *currentTime);
|
||||||
|
*outputAPSHVON=1;
|
||||||
|
}
|
||||||
|
if (*currentTime >= (plcOnTime + *triggerDelay_bps_swon) && bps_swon_is_on==false){
|
||||||
|
//Do action
|
||||||
|
*outputSignal += bps_swon;
|
||||||
|
bps_swon_is_on = true; bps_swon_state=1;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "bps_swon was set to outputSignal at %d.", *currentTime);
|
||||||
|
*outputBPSSWON=1;
|
||||||
|
}
|
||||||
|
if (*currentTime >= (plcOnTime + *triggerDelay_mhvps_hvon) && mhvps_hvon_is_on==false) {
|
||||||
|
//Do action
|
||||||
|
*outputSignal += mhvps_hvon;
|
||||||
|
mhvps_hvon_is_on = true; mhvps_hvon_state=1;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "mhvps_hvon was set to outputSignal at %d.", *currentTime);
|
||||||
|
*outputMHVPSON=1;
|
||||||
|
}
|
||||||
|
if (bps_swon_is_on && mhvps_hvon_is_on && *currentTime >= (plcOnTime + *triggerDelay_aps_swon)){
|
||||||
|
//Do action
|
||||||
|
*outputSignal += aps_swon;
|
||||||
|
aps_swon_is_on = true; aps_swon_state=1;
|
||||||
|
apsSwonHighResolutionTime = getCurrentTimeUs();
|
||||||
|
apsSwonTime = *currentTime;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "aps_swon was set to outputSignal at %d.", *currentTime);
|
||||||
|
*outputAPSSWON=1;
|
||||||
|
}
|
||||||
|
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
|
||||||
|
if (bps_hvon_is_on && aps_hvon_is_on){
|
||||||
|
*outputHVArmed = 1;
|
||||||
|
}
|
||||||
|
if (bps_swon_is_on || mhvps_hvon_is_on){
|
||||||
|
*outputHVInjection = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//State transition condition
|
||||||
|
if (aps_swon_is_on){
|
||||||
|
currentState = RFON;
|
||||||
|
*outputRFON = 0;
|
||||||
|
*outputBeamON = 1;
|
||||||
|
*shotCounter += 1;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to RFON");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (currentState == RFON) {
|
||||||
|
|
||||||
|
//Action in this state.
|
||||||
|
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||||
|
//debug
|
||||||
|
//if((*stopRequest != 0)){
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "Stop request was called.!!!");
|
||||||
|
//} else {
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset.!!!");
|
||||||
|
//}
|
||||||
|
*outputSignal -= aps_swon;
|
||||||
|
mhvps_hvon_is_on = false; mhvps_hvon_state=0;
|
||||||
|
aps_hvon_is_on = false; aps_hvon_state=0;
|
||||||
|
aps_swon_is_on = false; aps_swon_state=0;
|
||||||
|
bps_hvon_is_on = false; bps_hvon_state=0;
|
||||||
|
bps_swon_is_on = false; bps_swon_state=0;
|
||||||
|
currentState = HVTerminate;
|
||||||
|
*outputAPSHVON=0;
|
||||||
|
*outputAPSSWON=0;
|
||||||
|
*outputBPSHVON=0;
|
||||||
|
*outputBPSSWON=0;
|
||||||
|
*outputMHVPSON=0;
|
||||||
|
}
|
||||||
|
uint32 updatePeriod = 100; // in microsecnds (get this from Timer)
|
||||||
|
if ((*modePulseLengthLimit == 1u) || (getCurrentTimeUs() + updatePeriod >= (apsSwonHighResolutionTime + *triggerDelay_shotlen))) {
|
||||||
|
|
||||||
|
// Now we do busy wait
|
||||||
|
while (getCurrentTimeUs() < (apsSwonHighResolutionTime + *triggerDelay_shotlen)) {
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "!");
|
||||||
|
}
|
||||||
|
// We stop busy waiting #executionOverhead before expected pulse off time
|
||||||
|
//debug
|
||||||
|
//if((*modePulseLengthLimit == 1u)){
|
||||||
|
// REPORT_ERROR(ErrorManagement::Debug, "Mode limit detected.!!!");
|
||||||
|
//} else {
|
||||||
|
// REPORT_ERROR(ErrorManagement::Debug, "Shot length reached to the setpoint.!!!");
|
||||||
|
//}
|
||||||
|
//debug end.
|
||||||
|
//Do action
|
||||||
|
*outputSignal -= aps_swon; //Turn off only APS_SWON first.
|
||||||
|
mhvps_hvon_is_on = false;
|
||||||
|
aps_hvon_is_on = false;
|
||||||
|
aps_swon_is_on = false; aps_swon_state=0;
|
||||||
|
bps_hvon_is_on = false;
|
||||||
|
bps_swon_is_on = false;
|
||||||
|
*outputAPSHVON=0;
|
||||||
|
*outputAPSSWON=0;
|
||||||
|
*outputBPSHVON=0;
|
||||||
|
*outputBPSSWON=0;
|
||||||
|
*outputMHVPSON=0;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "0 was set to outputSignal at %d.", *currentTime);
|
||||||
|
}
|
||||||
|
*outputRFON = 1;
|
||||||
|
*outputBeamONTime = *currentTime - plcOnTime;
|
||||||
|
*outputRFONTime = *currentTime - apsSwonTime;
|
||||||
|
|
||||||
|
|
||||||
|
//State transition condition
|
||||||
|
if (!aps_swon_is_on && !bps_swon_is_on && !mhvps_hvon_is_on) {
|
||||||
|
currentState = HVTerminate;
|
||||||
|
apsSwoffTime = *currentTime;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "state was changed to HVTerminate");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (currentState == HVTerminate) {
|
||||||
|
//In the HVTerminate state, turn APS_SWON off first, and wait 1ms. Finally turn other PS off.
|
||||||
|
//Action in this state.
|
||||||
|
*outputBeamON = 0;
|
||||||
|
*outputHVArmed = 0;
|
||||||
|
*outputHVInjection = 0;
|
||||||
|
*outputRFON = 0;
|
||||||
|
|
||||||
|
// State transition condition.
|
||||||
|
if (*currentTime - apsSwoffTime >= turn_off_delay){
|
||||||
|
*outputSignal = 0;
|
||||||
|
mhvps_hvon_state=0;
|
||||||
|
aps_hvon_state=0;
|
||||||
|
bps_hvon_state=0;
|
||||||
|
bps_swon_state=0;
|
||||||
|
}
|
||||||
|
if (*triggerSignal == false){
|
||||||
|
//Check PLC_ON is reset
|
||||||
|
currentState = WaitTrigger;
|
||||||
|
*outputSignal = 0;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "PLC_ON was reset. The State was changed to WaitTrigger at %d.", *currentTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(*short_pulse_mode == 1){
|
||||||
|
p3Value = 1*aps_hvon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
|
||||||
|
*outputSignalNI6259 = 1*aps_swon_state;
|
||||||
|
*outputSignalNI6528P3 = ~p3Value;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "short pulse mode with p3: %d.", p3Value);
|
||||||
|
} else {
|
||||||
|
p3Value = 1*aps_hvon_state +2*aps_swon_state + 8*bps_hvon_state +16*bps_swon_state + 64*(*outputBeamON);
|
||||||
|
*outputSignalNI6528P3 = ~p3Value;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "long pulse mode with p3: %d.", p3Value);
|
||||||
|
}
|
||||||
|
p4Value = 8*mhvps_hvon_state;
|
||||||
|
//*outputSignalNI6528P4 = ~(*ni6528p4Value | p4Value);
|
||||||
|
*outputSignalNI6528P4 = ~p4Value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JARTStateMachineGAM, "1.0")
|
||||||
@@ -0,0 +1,260 @@
|
|||||||
|
/**
|
||||||
|
* @file JARTStateMachineGAM.h
|
||||||
|
* @brief Header file for class JARTStateMachineGAM
|
||||||
|
* @date Nov 26, 2018
|
||||||
|
* @author aneto
|
||||||
|
*
|
||||||
|
* @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 JARTStateMachineGAM
|
||||||
|
* 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 GAMS_JARTSTATEMACHINEGAM_H_
|
||||||
|
#define GAMS_JARTSTATEMACHINEGAM_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "GAM.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GAM that provides real-time state machine.
|
||||||
|
*
|
||||||
|
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||||
|
* <pre>
|
||||||
|
* +GAMRealTimeStateMachine = {
|
||||||
|
* Class = JARTStateMachineGAM
|
||||||
|
* ConditionTrigger = 1
|
||||||
|
* mhvps_hvon = 4
|
||||||
|
* aps_hvon = 1
|
||||||
|
* aps_swon = 16
|
||||||
|
* bps_hvon = 2
|
||||||
|
* bps_swon = 8
|
||||||
|
* InputSignals = {
|
||||||
|
* Time = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* PLC_ON = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* MHVPS_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* APS_HVON_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* APS_SWON_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* BPS_HVON_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* BPS_SWON_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* SHOTLEN = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* StopRequest = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* MODE_SHOTLEN_FLAG = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* OutputSignals = {
|
||||||
|
* Value = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* Trigger = 1
|
||||||
|
* }
|
||||||
|
* BEAM_ON_STAT = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* HVARMED = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* HVINJECTION = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* RFON = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* BeamONTime = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* RFONTime = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* SHOT_ID = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class JARTStateMachineGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
JARTStateMachineGAM();
|
||||||
|
|
||||||
|
virtual ~JARTStateMachineGAM();
|
||||||
|
|
||||||
|
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||||
|
|
||||||
|
virtual bool Setup();
|
||||||
|
|
||||||
|
virtual bool Execute();
|
||||||
|
|
||||||
|
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
|
||||||
|
const MARTe::char8 * const nextStateName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
//The list of possible states
|
||||||
|
enum JARealTimeState {
|
||||||
|
WaitTrigger = 0,
|
||||||
|
SwitchingHVPS = 1,
|
||||||
|
RFON = 2,
|
||||||
|
HVTerminate = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
//The current rtState
|
||||||
|
JARealTimeState currentState;
|
||||||
|
|
||||||
|
//A given condition
|
||||||
|
MARTe::uint32 conditionTrigger;
|
||||||
|
|
||||||
|
//What to output in a given state and condition
|
||||||
|
MARTe::uint32 mhvps_hvon;
|
||||||
|
MARTe::uint32 aps_hvon;
|
||||||
|
MARTe::uint32 aps_swon;
|
||||||
|
MARTe::uint32 bps_hvon;
|
||||||
|
MARTe::uint32 bps_swon;
|
||||||
|
|
||||||
|
//The trigger signal (PLC_ON)
|
||||||
|
MARTe::uint32 *triggerSignal;
|
||||||
|
|
||||||
|
//Time signal
|
||||||
|
MARTe::uint32 *currentTime;
|
||||||
|
|
||||||
|
// Input signals for trigger delay parameters
|
||||||
|
MARTe::uint32 *triggerDelay_mhvps_hvon;
|
||||||
|
MARTe::uint32 *triggerDelay_aps_hvon;
|
||||||
|
MARTe::uint32 *triggerDelay_aps_swon;
|
||||||
|
MARTe::uint32 *triggerDelay_bps_hvon;
|
||||||
|
MARTe::uint32 *triggerDelay_bps_swon;
|
||||||
|
MARTe::uint32 *triggerDelay_shotlen;
|
||||||
|
|
||||||
|
// Input signal for sequence stop request.
|
||||||
|
MARTe::uint32 *stopRequest;
|
||||||
|
// Input signal for pulse length limit by mode.
|
||||||
|
MARTe::uint32 *modePulseLengthLimit;
|
||||||
|
// Input signal for short pulse mode.
|
||||||
|
MARTe::uint32 *short_pulse_mode;
|
||||||
|
|
||||||
|
// Output signal to which the output value will be written.
|
||||||
|
// One state write One signal.
|
||||||
|
MARTe::uint32 *outputSignal;
|
||||||
|
// state notify output
|
||||||
|
MARTe::uint32 *outputBeamON;
|
||||||
|
MARTe::uint32 *outputHVArmed;
|
||||||
|
MARTe::uint32 *outputHVInjection;
|
||||||
|
MARTe::uint32 *outputRFON;
|
||||||
|
// elapsed time notify output;
|
||||||
|
MARTe::uint32 *outputBeamONTime;
|
||||||
|
MARTe::uint32 *outputRFONTime;
|
||||||
|
// shot counter (coutup every RFON time.)
|
||||||
|
MARTe::uint32 *shotCounter;
|
||||||
|
|
||||||
|
// Added for HVPS state (20201117)
|
||||||
|
MARTe::uint32 *outputAPSHVON;
|
||||||
|
MARTe::uint32 *outputAPSSWON;
|
||||||
|
MARTe::uint32 *outputBPSHVON;
|
||||||
|
MARTe::uint32 *outputBPSSWON;
|
||||||
|
MARTe::uint32 *outputMHVPSON;
|
||||||
|
|
||||||
|
// Output signals for NI devices
|
||||||
|
MARTe::uint32 *outputSignalNI6259;
|
||||||
|
MARTe::uint8 *outputSignalNI6528P3;
|
||||||
|
MARTe::uint8 *outputSignalNI6528P4;
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
//Internal Parameters
|
||||||
|
//////////////////////////////
|
||||||
|
//PLC_ON time holder
|
||||||
|
MARTe::uint32 plcOnTime;
|
||||||
|
//APS_SWON time holder
|
||||||
|
MARTe::uint32 apsSwonTime;
|
||||||
|
MARTe::uint32 apsSwoffTime;
|
||||||
|
MARTe::uint64 apsSwonHighResolutionTime;
|
||||||
|
|
||||||
|
//PS turn off delay
|
||||||
|
MARTe::uint32 turn_off_delay;
|
||||||
|
|
||||||
|
//HVPS state holder
|
||||||
|
bool mhvps_hvon_is_on;
|
||||||
|
bool aps_hvon_is_on;
|
||||||
|
bool aps_swon_is_on;
|
||||||
|
bool bps_hvon_is_on;
|
||||||
|
bool bps_swon_is_on;
|
||||||
|
|
||||||
|
// terminal values
|
||||||
|
MARTe::uint8 p3Value;
|
||||||
|
MARTe::uint8 p4Value;
|
||||||
|
MARTe::uint8 aps_hvon_state;
|
||||||
|
MARTe::uint8 aps_swon_state;
|
||||||
|
MARTe::uint8 mhvps_hvon_state;
|
||||||
|
MARTe::uint8 bps_hvon_state;
|
||||||
|
MARTe::uint8 bps_swon_state;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* GAMS_JARTSTATEMACHINEGAM_H_ */
|
||||||
@@ -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,56 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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=JARTStateMachineGAM.x
|
||||||
|
|
||||||
|
PACKAGE=GAMs
|
||||||
|
|
||||||
|
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
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
all: $(OBJS) $(SUBPROJ) \
|
||||||
|
$(BUILD_DIR)/JARTStateMachineGAM$(LIBEXT) \
|
||||||
|
$(BUILD_DIR)/JARTStateMachineGAM$(DLLEXT)
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
|
|
||||||
295
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JARampupGAM/JARampupGAM.cpp
Normal file
295
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JARampupGAM/JARampupGAM.cpp
Normal file
@@ -0,0 +1,295 @@
|
|||||||
|
/**
|
||||||
|
* @file JARampupGAM.cpp
|
||||||
|
* @brief Source file for class JARampupGAM
|
||||||
|
* @date Jan, 2019
|
||||||
|
* @author rhari
|
||||||
|
*
|
||||||
|
* @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 JARampupGAM (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 "JARampupGAM.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
JARampupGAM::JARampupGAM() : GAM() {
|
||||||
|
current_setpoint = NULL_PTR(MARTe::float32 *);
|
||||||
|
target_value = NULL_PTR(MARTe::float32 *);
|
||||||
|
rampup_time = NULL_PTR(MARTe::float32 *);
|
||||||
|
start = NULL_PTR(MARTe::uint32 *);
|
||||||
|
standby = NULL_PTR(MARTe::uint32 *);
|
||||||
|
isAuto = NULL_PTR(MARTe::uint32 *);
|
||||||
|
FHPS_PrePro = NULL_PTR(MARTe::float32 *);
|
||||||
|
|
||||||
|
output = NULL_PTR(MARTe::float32 *);
|
||||||
|
state = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
rampup_rate = 0.0f;
|
||||||
|
inRampup = false;
|
||||||
|
resetFlag = true;
|
||||||
|
inWaitHVON = false;
|
||||||
|
inWaitStandby = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
JARampupGAM::~JARampupGAM() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JARampupGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||||
|
using namespace MARTe;
|
||||||
|
return GAM::Initialise(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JARampupGAM::Setup() {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = (numberOfInputSignals == 7u);
|
||||||
|
if (ok) {
|
||||||
|
ok = (numberOfOutputSignals == 2u);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Two output signals shall be defined.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Six input signals shall be defined.");
|
||||||
|
}
|
||||||
|
uint32 currentspvIndex;
|
||||||
|
uint32 targetvIndex;
|
||||||
|
uint32 timeIndex;
|
||||||
|
uint32 startIndex;
|
||||||
|
uint32 standbyIndex;
|
||||||
|
uint32 isAutoIndex;
|
||||||
|
uint32 fhpsPreProIndex;
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "Currspv";
|
||||||
|
ok = GetSignalIndex(InputSignals, currentspvIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Currspv input signal shall be defined.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, currentspvIndex);
|
||||||
|
ok = (inputType == Float32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Currspv shall be defined as float32.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "Targetv";
|
||||||
|
ok = GetSignalIndex(InputSignals, targetvIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Targetv input signal shall be defined.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, targetvIndex);
|
||||||
|
ok = (inputType == Float32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Targetv shall be defined as float32.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "Time";
|
||||||
|
ok = GetSignalIndex(InputSignals, timeIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Time input signal shall be defined.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, timeIndex);
|
||||||
|
ok = (inputType == Float32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Time shall be defined as float32.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "Start";
|
||||||
|
ok = GetSignalIndex(InputSignals, startIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Start input signal shall be defined.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, startIndex);
|
||||||
|
ok = (inputType == UnsignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Start shall be defined as uint32.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "PLC_STANDBY";
|
||||||
|
ok = GetSignalIndex(InputSignals, standbyIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "PLC_STANDBY input signal shall be defined.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, standbyIndex);
|
||||||
|
ok = (inputType == UnsignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "PLC_STANDBY shall be defined as uint32.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "MANUAL_AUTO";
|
||||||
|
ok = GetSignalIndex(InputSignals, isAutoIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "MANUAL_AUTO input signal shall be defined.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, isAutoIndex);
|
||||||
|
ok = (inputType == UnsignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "MANUAL_AUTO shall be defined as uint32.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "FHPS_PrePro";
|
||||||
|
ok = GetSignalIndex(InputSignals, fhpsPreProIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "FHPS_PrePro input signal shall be defined.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, fhpsPreProIndex);
|
||||||
|
ok = (inputType == Float32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Signal FHPS_PrePro shall be defined as float32.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
TypeDescriptor inputType = GetSignalType(OutputSignals, 0);
|
||||||
|
ok = (inputType == Float32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Output shall be defined as float32.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
TypeDescriptor inputType = GetSignalType(OutputSignals, 1);
|
||||||
|
ok = (inputType == UnsignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Signal state shall be defined as float32.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
current_setpoint = reinterpret_cast<float32 *>(GetInputSignalMemory(currentspvIndex));
|
||||||
|
target_value = reinterpret_cast<float32 *>(GetInputSignalMemory(targetvIndex));
|
||||||
|
rampup_time = reinterpret_cast<float32 *>(GetInputSignalMemory(timeIndex));
|
||||||
|
start = reinterpret_cast<uint32 *>(GetInputSignalMemory(startIndex));
|
||||||
|
standby = reinterpret_cast<uint32 *>(GetInputSignalMemory(standbyIndex));
|
||||||
|
isAuto = reinterpret_cast<uint32 *>(GetInputSignalMemory(isAutoIndex));
|
||||||
|
FHPS_PrePro = reinterpret_cast<float32 *>(GetInputSignalMemory(fhpsPreProIndex));
|
||||||
|
|
||||||
|
output = reinterpret_cast<float32 *>(GetOutputSignalMemory(0));
|
||||||
|
state = reinterpret_cast<uint32 *>(GetOutputSignalMemory(1));
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JARampupGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName){
|
||||||
|
if(strcmp(nextStateName, "WaitHVON_PREP")==0 || strcmp(nextStateName, "WaitHVON_SDN_PREP")==0 ||
|
||||||
|
strcmp(nextStateName, "WaitHVON")==0 || strcmp(nextStateName, "WaitHVON_SDN")==0){
|
||||||
|
inWaitHVON = true;
|
||||||
|
inWaitStandby = false;
|
||||||
|
} else{
|
||||||
|
inWaitHVON = false;
|
||||||
|
if(strcmp(nextStateName,"WaitStandby")==0 ){
|
||||||
|
inWaitStandby = true;
|
||||||
|
} else {
|
||||||
|
inWaitStandby = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JARampupGAM::Execute() {
|
||||||
|
using namespace MARTe;
|
||||||
|
if(!inWaitHVON){
|
||||||
|
if (*target_value <= 0.0f || *standby == 0u) {
|
||||||
|
*output = 0.0f;
|
||||||
|
rampup_rate = 0.0f;
|
||||||
|
if(*target_value <= 0.0f){
|
||||||
|
*state = 3u;
|
||||||
|
} else {
|
||||||
|
*state = 0u;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*start == 1u && *isAuto==0u){ //isAuto = 1.Manual, 0.auto-rampup.
|
||||||
|
inRampup = true;
|
||||||
|
resetFlag = true;
|
||||||
|
*output = 0.0f; //Enable if it should start always zero.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calcrate new rampup rate.
|
||||||
|
if(*rampup_time != 0 && resetFlag == true){
|
||||||
|
rampup_rate = (*target_value - *current_setpoint) / *rampup_time/1000.0f; // Volt/msec
|
||||||
|
resetFlag = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update Parameter
|
||||||
|
if(*standby == 1u ){
|
||||||
|
if(*isAuto == 1u){
|
||||||
|
if (inWaitStandby){
|
||||||
|
*output = *target_value;
|
||||||
|
} else{
|
||||||
|
*output = *FHPS_PrePro;
|
||||||
|
}
|
||||||
|
//*output = *target_value;
|
||||||
|
*state = 0u;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (inRampup){
|
||||||
|
if (*output + rampup_rate < *target_value && *rampup_time != 0){
|
||||||
|
*output = *output + rampup_rate;
|
||||||
|
*state = 1u;
|
||||||
|
} else {
|
||||||
|
*output = *target_value;
|
||||||
|
*state = 2u;
|
||||||
|
inRampup = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
if(*isAuto == 0){
|
||||||
|
*output = *FHPS_PrePro;
|
||||||
|
} else{
|
||||||
|
*output = *target_value;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JARampupGAM, "1.0")
|
||||||
141
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JARampupGAM/JARampupGAM.h
Normal file
141
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JARampupGAM/JARampupGAM.h
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
/**
|
||||||
|
* @file JARampupGAM.h
|
||||||
|
* @brief Header file for class JARampupGAM
|
||||||
|
* @date Jan, 2019
|
||||||
|
* @author rhari
|
||||||
|
*
|
||||||
|
* @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 JARampupGAM
|
||||||
|
* 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 GAMS_JARampupGAM_H_
|
||||||
|
#define GAMS_JARampupGAM_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "GAM.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GAM that rampup output value with specified target value and duration.
|
||||||
|
*
|
||||||
|
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||||
|
* <pre>
|
||||||
|
* +FHPSRampupGAM = {
|
||||||
|
* Class = JARampupGAM
|
||||||
|
* InputSignals = {
|
||||||
|
* Currspv = {
|
||||||
|
* Alias = FHPS_REF
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = float32
|
||||||
|
* }
|
||||||
|
* Targetv = {
|
||||||
|
* Alias = FHPS_AUTO_TAGV
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = float32
|
||||||
|
* }
|
||||||
|
* Time = {
|
||||||
|
* Alias = FHPS_AUTO_TIME
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = float32
|
||||||
|
* }
|
||||||
|
* Start = {
|
||||||
|
* Alias = FHPS_AUTO_START
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* OutputSignals = {
|
||||||
|
* FHPS_REF = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = float32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class JARampupGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
JARampupGAM();
|
||||||
|
|
||||||
|
virtual ~JARampupGAM();
|
||||||
|
|
||||||
|
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||||
|
|
||||||
|
virtual bool Setup();
|
||||||
|
|
||||||
|
virtual bool Execute();
|
||||||
|
|
||||||
|
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
|
||||||
|
const MARTe::char8 * const nextStateName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Input signal containing current current_setpoint
|
||||||
|
MARTe::float32 *current_setpoint;
|
||||||
|
|
||||||
|
// Input signal containing the frequency of the waveform.
|
||||||
|
MARTe::float32 *target_value;
|
||||||
|
|
||||||
|
// Input signal containing the amplitude of the waveform.
|
||||||
|
MARTe::float32 *rampup_time;
|
||||||
|
|
||||||
|
// Input signal containing CCPS_ON_REQUEST
|
||||||
|
MARTe::uint32 *start;
|
||||||
|
|
||||||
|
// Input signal PLC_STANDBY
|
||||||
|
MARTe::uint32 *standby;
|
||||||
|
|
||||||
|
// MANUAL AUTO button
|
||||||
|
MARTe::uint32 *isAuto;
|
||||||
|
|
||||||
|
// Input signal
|
||||||
|
MARTe::float32 *FHPS_PrePro;
|
||||||
|
|
||||||
|
// Output
|
||||||
|
MARTe::float32 *output;
|
||||||
|
// State output
|
||||||
|
MARTe::uint32 *state; //0:NotOperation, 1:InOperation, 2:Finish, 3:Error
|
||||||
|
|
||||||
|
// Internal variables
|
||||||
|
MARTe::float32 rampup_rate;
|
||||||
|
bool inRampup;
|
||||||
|
bool resetFlag;
|
||||||
|
bool inWaitHVON;
|
||||||
|
bool inWaitStandby;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* GAMS_JARampupGAM_H_ */
|
||||||
27
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JARampupGAM/Makefile.gcc
Normal file
27
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JARampupGAM/Makefile.gcc
Normal file
@@ -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
|
||||||
55
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JARampupGAM/Makefile.inc
Normal file
55
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JARampupGAM/Makefile.inc
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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=JARampupGAM.x
|
||||||
|
|
||||||
|
PACKAGE=GAMs
|
||||||
|
|
||||||
|
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
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
all: $(OBJS) $(SUBPROJ) \
|
||||||
|
$(BUILD_DIR)/JARampupGAM$(LIBEXT) \
|
||||||
|
$(BUILD_DIR)/JARampupGAM$(DLLEXT)
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
@@ -0,0 +1,361 @@
|
|||||||
|
/**
|
||||||
|
* @file JASDNRTStateMachineGAM.cpp
|
||||||
|
* @brief Source file for class JASDNRTStateMachineGAM
|
||||||
|
* @date Nov 26, 2018
|
||||||
|
* @author aneto
|
||||||
|
*
|
||||||
|
* @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 JASDNRTStateMachineGAM (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 "JASDNRTStateMachineGAM.h"
|
||||||
|
|
||||||
|
#include "AdvancedErrorManagement.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
JASDNRTStateMachineGAM::JASDNRTStateMachineGAM() {
|
||||||
|
currentState = WaitTrigger; // Set Entry state.
|
||||||
|
plcOnTime = 0; // Triggered time holder.
|
||||||
|
sdnTriggerTime = 0;
|
||||||
|
//Output and condition in a given state.
|
||||||
|
conditionTrigger = 1;
|
||||||
|
aps_hvon = 0;
|
||||||
|
aps_swon = 0;
|
||||||
|
bps_hvon = 0;
|
||||||
|
bps_swon = 0;
|
||||||
|
mhvps_hvon = 0;
|
||||||
|
|
||||||
|
// Parameters which get from Input signals.
|
||||||
|
triggerSignal = NULL_PTR(MARTe::uint32 *);
|
||||||
|
currentTime = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_mhvps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_aps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_aps_swon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_bps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_bps_swon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
triggerDelay_shotlen = NULL_PTR(MARTe::uint32 *);
|
||||||
|
stopRequest = NULL_PTR(MARTe::uint32 *);
|
||||||
|
modePulseLengthLimit = NULL_PTR(MARTe::uint32 *);
|
||||||
|
sdnCommand = NULL_PTR(MARTe::uint16 *);
|
||||||
|
|
||||||
|
// write out target.
|
||||||
|
outputSignal = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputBeamON = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputHVArmed = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputHVInjection = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputRFON = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputBeamONTime = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputRFONTime = NULL_PTR(MARTe::uint32 *);
|
||||||
|
shotCounter = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
mhvps_hvon_is_on = false;
|
||||||
|
aps_hvon_is_on = false;
|
||||||
|
aps_swon_is_on = false;
|
||||||
|
bps_hvon_is_on = false;
|
||||||
|
bps_swon_is_on = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
JASDNRTStateMachineGAM::~JASDNRTStateMachineGAM() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JASDNRTStateMachineGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = GAM::Initialise(data);
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("ConditionTrigger", conditionTrigger);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Condition1 shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("mhvps_hvon", mhvps_hvon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The mhvps_hvon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("aps_hvon", aps_hvon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_hvon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("aps_swon", aps_swon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_swon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("bps_hvon", bps_hvon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_hvon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("bps_swon", bps_swon);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_swon shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JASDNRTStateMachineGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JASDNRTStateMachineGAM::Setup() {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = (numberOfInputSignals == 11u);
|
||||||
|
if (ok) {
|
||||||
|
ok = (numberOfOutputSignals == 8u);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Seven output signals shall be defined");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Nine input signals shall be defined");
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||||
|
ok = (inputType == UnsignedInteger32Bit || inputType == UnsignedInteger16Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or uint16", signalName.Buffer());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfOutputSignals; c++) {
|
||||||
|
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
|
||||||
|
ok = (outputType == UnsignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
currentTime = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||||
|
triggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
|
||||||
|
triggerDelay_mhvps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
|
||||||
|
triggerDelay_aps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
|
||||||
|
triggerDelay_aps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
|
||||||
|
triggerDelay_bps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
|
||||||
|
triggerDelay_bps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
|
||||||
|
triggerDelay_shotlen = reinterpret_cast<uint32 *>(GetInputSignalMemory(7));
|
||||||
|
stopRequest = reinterpret_cast<uint32 *>(GetInputSignalMemory(8));
|
||||||
|
modePulseLengthLimit = reinterpret_cast<uint32 *>(GetInputSignalMemory(9));
|
||||||
|
sdnCommand = reinterpret_cast<uint16 *>(GetInputSignalMemory(10));
|
||||||
|
|
||||||
|
outputSignal = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
|
||||||
|
outputBeamON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(1));
|
||||||
|
outputHVArmed = reinterpret_cast<uint32 *>(GetOutputSignalMemory(2));
|
||||||
|
outputHVInjection = reinterpret_cast<uint32 *>(GetOutputSignalMemory(3));
|
||||||
|
outputRFON = reinterpret_cast<uint32 *>(GetOutputSignalMemory(4));
|
||||||
|
outputBeamONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(5));
|
||||||
|
outputRFONTime = reinterpret_cast<uint32 *>(GetOutputSignalMemory(6));
|
||||||
|
shotCounter = reinterpret_cast<uint32 *>(GetOutputSignalMemory(7));
|
||||||
|
*shotCounter = 0;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JASDNRTStateMachineGAM::Execute() {
|
||||||
|
using namespace MARTe;
|
||||||
|
if (currentState == WaitTrigger) {
|
||||||
|
|
||||||
|
//State Transition condition
|
||||||
|
if ((*triggerSignal == conditionTrigger)) {
|
||||||
|
REPORT_ERROR(ErrorManagement::Debug, "Start beam-on sequence in SDN mode.");
|
||||||
|
plcOnTime = *currentTime; //Save pulse start time.
|
||||||
|
*outputBeamON = 0;
|
||||||
|
//State transition.
|
||||||
|
currentState = SwitchingHVPS_HVON;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (currentState == SwitchingHVPS_HVON) {
|
||||||
|
|
||||||
|
//Actions in this state.
|
||||||
|
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||||
|
*outputSignal -= aps_swon;
|
||||||
|
currentState = HVTerminate;
|
||||||
|
}
|
||||||
|
if (*currentTime >= (plcOnTime + *triggerDelay_bps_hvon) && bps_hvon_is_on == false){
|
||||||
|
//Do action
|
||||||
|
*outputSignal += bps_hvon;
|
||||||
|
bps_hvon_is_on = true;
|
||||||
|
REPORT_ERROR(ErrorManagement::Debug, "bps_hvon was set to outputSignal at %d.", *currentTime);
|
||||||
|
}
|
||||||
|
if (*currentTime >= (plcOnTime + *triggerDelay_aps_hvon) && aps_hvon_is_on == false) {
|
||||||
|
//Do action
|
||||||
|
*outputSignal += aps_hvon;
|
||||||
|
aps_hvon_is_on = true;
|
||||||
|
REPORT_ERROR(ErrorManagement::Debug, "aps_hvon was set to outputSignal.");
|
||||||
|
}
|
||||||
|
|
||||||
|
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
|
||||||
|
if (bps_hvon_is_on && aps_hvon_is_on){
|
||||||
|
*outputHVArmed = 0;
|
||||||
|
currentState = WaitSDNTrigger;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (currentState == WaitSDNTrigger) {
|
||||||
|
|
||||||
|
// Action in this state
|
||||||
|
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
|
||||||
|
|
||||||
|
// State change conditions
|
||||||
|
if (*sdnCommand == 1){
|
||||||
|
sdnTriggerTime = *currentTime;
|
||||||
|
currentState = SwitchingHVPS_SWON;
|
||||||
|
}
|
||||||
|
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||||
|
*outputSignal = 0;
|
||||||
|
currentState = HVTerminate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (currentState == SwitchingHVPS_SWON) {
|
||||||
|
|
||||||
|
//Actions in this state.
|
||||||
|
if (*stopRequest != 0 || *triggerSignal != conditionTrigger) {
|
||||||
|
*outputSignal = 0;
|
||||||
|
currentState = HVTerminate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*currentTime >= (sdnTriggerTime + *triggerDelay_bps_swon) && bps_swon_is_on==false){
|
||||||
|
//Do action
|
||||||
|
*outputSignal += bps_swon;
|
||||||
|
bps_swon_is_on = true;
|
||||||
|
REPORT_ERROR(ErrorManagement::Debug, "bps_swon was set to outputSignal at %d.", *currentTime);
|
||||||
|
}
|
||||||
|
if (*currentTime >= (sdnTriggerTime + *triggerDelay_mhvps_hvon) && mhvps_hvon_is_on==false) {
|
||||||
|
//Do action
|
||||||
|
*outputSignal += mhvps_hvon;
|
||||||
|
mhvps_hvon_is_on = true;
|
||||||
|
REPORT_ERROR(ErrorManagement::Debug, "mhvps_hvon was set to outputSignal at %d.", *currentTime);
|
||||||
|
}
|
||||||
|
if (bps_swon_is_on && mhvps_hvon_is_on && *currentTime >= (sdnTriggerTime + *triggerDelay_aps_swon)){
|
||||||
|
//Do action
|
||||||
|
*outputSignal += aps_swon;
|
||||||
|
aps_swon_is_on = true;
|
||||||
|
apsSwonTime = *currentTime;
|
||||||
|
REPORT_ERROR(ErrorManagement::Debug, "aps_swon was set to outputSignal at %d.", *currentTime);
|
||||||
|
}
|
||||||
|
*outputBeamONTime = *currentTime - plcOnTime; //Save RFON start time.
|
||||||
|
|
||||||
|
if (bps_swon_is_on || mhvps_hvon_is_on){
|
||||||
|
*outputHVInjection = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//State transition condition
|
||||||
|
if (aps_swon_is_on){
|
||||||
|
currentState = RFON;
|
||||||
|
*outputRFON = 0;
|
||||||
|
*shotCounter += 1;
|
||||||
|
REPORT_ERROR(ErrorManagement::Debug, "state was changed to RFON");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (currentState == RFON) {
|
||||||
|
|
||||||
|
//SDN command processing.
|
||||||
|
if (*sdnCommand == 4 && aps_swon_is_on) {
|
||||||
|
*outputSignal -= aps_swon;
|
||||||
|
aps_swon_is_on = false;
|
||||||
|
REPORT_ERROR(ErrorManagement::Debug, "sdn command was 4");
|
||||||
|
}
|
||||||
|
if (*sdnCommand == 3 && !aps_swon_is_on) {
|
||||||
|
*outputSignal += aps_swon;
|
||||||
|
aps_swon_is_on = true;
|
||||||
|
REPORT_ERROR(ErrorManagement::Debug, "sdn command was 3");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Action in this state.
|
||||||
|
if ((*sdnCommand == 2) || (*modePulseLengthLimit == 1u) || (*currentTime >= (sdnTriggerTime + *triggerDelay_aps_swon + *triggerDelay_shotlen))) {
|
||||||
|
REPORT_ERROR(ErrorManagement::Debug, "shotlen: %d", *triggerDelay_shotlen);
|
||||||
|
if (*sdnCommand == 2) {
|
||||||
|
REPORT_ERROR(ErrorManagement::Information, "sdn command was 2");
|
||||||
|
} else if (*currentTime >= (sdnTriggerTime + *triggerDelay_aps_swon + *triggerDelay_shotlen)){
|
||||||
|
REPORT_ERROR(ErrorManagement::Information, "pulse length reached setpoint.");
|
||||||
|
}
|
||||||
|
//Do action
|
||||||
|
*outputSignal -= aps_swon; //Turn off only aps_swon
|
||||||
|
mhvps_hvon_is_on = false;
|
||||||
|
aps_hvon_is_on = false;
|
||||||
|
aps_swon_is_on = false;
|
||||||
|
bps_hvon_is_on = false;
|
||||||
|
bps_swon_is_on = false;
|
||||||
|
REPORT_ERROR(ErrorManagement::Debug, "0 was set to outputSignal at %d.", *currentTime);
|
||||||
|
}
|
||||||
|
*outputRFON = 0;
|
||||||
|
*outputBeamONTime = *currentTime - plcOnTime;
|
||||||
|
*outputRFONTime = *currentTime - apsSwonTime;
|
||||||
|
|
||||||
|
|
||||||
|
//State transition condition
|
||||||
|
if (!aps_swon_is_on && !bps_swon_is_on && !mhvps_hvon_is_on) {
|
||||||
|
currentState = HVTerminate;
|
||||||
|
apsSwoffTime = *currentTime;
|
||||||
|
REPORT_ERROR(ErrorManagement::Information, "state was changed to HVTerminate");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (currentState == HVTerminate) {
|
||||||
|
|
||||||
|
//Action in this state.
|
||||||
|
*outputBeamON = 1;
|
||||||
|
*outputHVArmed = 1;
|
||||||
|
*outputHVInjection = 1;
|
||||||
|
*outputRFON = 1;
|
||||||
|
|
||||||
|
// State transition condition.
|
||||||
|
if (*currentTime - apsSwoffTime >= turn_off_delay){
|
||||||
|
*outputSignal = 0;
|
||||||
|
}
|
||||||
|
if (*triggerSignal == false){
|
||||||
|
//Check PLC_ON is reset
|
||||||
|
currentState = WaitTrigger;
|
||||||
|
*outputSignal = 0;
|
||||||
|
REPORT_ERROR(ErrorManagement::Debug, "state was changed to WaitTrigger");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JASDNRTStateMachineGAM, "1.0")
|
||||||
@@ -0,0 +1,250 @@
|
|||||||
|
/**
|
||||||
|
* @file JARTStateMachineGAM.h
|
||||||
|
* @brief Header file for class JASDNRTStateMachineGAM
|
||||||
|
* @date Nov 26, 2018
|
||||||
|
* @author aneto
|
||||||
|
*
|
||||||
|
* @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 JARTStateMachineGAM
|
||||||
|
* 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 GAMS_JASDNRTSTATEMACHINEGAM_H_
|
||||||
|
#define GAMS_JASDNRTSTATEMACHINEGAM_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "GAM.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GAM provides real-time state machine that communicate with SDN packet.
|
||||||
|
*
|
||||||
|
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||||
|
* <pre>
|
||||||
|
* +GAMSDNRealTimeStateMachine = {
|
||||||
|
* Class = JASDNRTStateMachineGAM
|
||||||
|
* ConditionTrigger = 1
|
||||||
|
* mhvps_hvon = 4
|
||||||
|
* aps_hvon = 1
|
||||||
|
* aps_swon = 16
|
||||||
|
* bps_hvon = 2
|
||||||
|
* bps_swon = 8
|
||||||
|
* InputSignals = {
|
||||||
|
* Time = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* PLC_ON = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* MHVPS_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* APS_HVON_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* APS_SWON_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* BPS_HVON_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* BPS_SWON_DT = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* SHOTLEN = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* StopRequest = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* MODE_SHOTLEN_FLAG = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* Command = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint16
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* OutputSignals = {
|
||||||
|
* Value = {
|
||||||
|
* //DataSource = NI6259
|
||||||
|
* DataSource = Display
|
||||||
|
* Type = uint32
|
||||||
|
* Trigger = 1
|
||||||
|
* }
|
||||||
|
* BeamON = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* HVARMED = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* HVINJECTION = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* RFON = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* BeamONTime = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* RFONTime = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* SHOT_ID = {
|
||||||
|
* DataSource = RealTimeThreadAsyncBridge
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class JASDNRTStateMachineGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
JASDNRTStateMachineGAM();
|
||||||
|
|
||||||
|
virtual ~JASDNRTStateMachineGAM();
|
||||||
|
|
||||||
|
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||||
|
|
||||||
|
virtual bool Setup();
|
||||||
|
|
||||||
|
virtual bool Execute();
|
||||||
|
|
||||||
|
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
|
||||||
|
const MARTe::char8 * const nextStateName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
//The list of possible states
|
||||||
|
enum JARealTimeState {
|
||||||
|
WaitTrigger = 0,
|
||||||
|
SwitchingHVPS_HVON = 1,
|
||||||
|
WaitSDNTrigger = 2,
|
||||||
|
SwitchingHVPS_SWON = 3,
|
||||||
|
RFON = 4,
|
||||||
|
HVTerminate = 5
|
||||||
|
};
|
||||||
|
|
||||||
|
//The current rtState
|
||||||
|
JARealTimeState currentState;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
// Static parameter given by cfg File
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
//A given condition
|
||||||
|
MARTe::uint32 conditionTrigger;
|
||||||
|
//What to output in a given state and condition
|
||||||
|
MARTe::uint32 mhvps_hvon;
|
||||||
|
MARTe::uint32 aps_hvon;
|
||||||
|
MARTe::uint32 aps_swon;
|
||||||
|
MARTe::uint32 bps_hvon;
|
||||||
|
MARTe::uint32 bps_swon;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
// Input signals
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
//The trigger signal (PLC_ON)
|
||||||
|
MARTe::uint32 *triggerSignal;
|
||||||
|
//Time signal (Time from TimerGAM)
|
||||||
|
MARTe::uint32 *currentTime;
|
||||||
|
// Input signals for trigger delay parameters
|
||||||
|
MARTe::uint32 *triggerDelay_mhvps_hvon;
|
||||||
|
MARTe::uint32 *triggerDelay_aps_hvon;
|
||||||
|
MARTe::uint32 *triggerDelay_aps_swon;
|
||||||
|
MARTe::uint32 *triggerDelay_bps_hvon;
|
||||||
|
MARTe::uint32 *triggerDelay_bps_swon;
|
||||||
|
MARTe::uint32 *triggerDelay_shotlen;
|
||||||
|
// Input signal for sequence stop request.
|
||||||
|
MARTe::uint32 *stopRequest;
|
||||||
|
// Input signal for pulse length limit by mode.
|
||||||
|
MARTe::uint32 *modePulseLengthLimit;
|
||||||
|
// Input signal for SDN commands.
|
||||||
|
MARTe::uint16 *sdnCommand;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
// Output signal to which the output value will be written.
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
// One state write One signal.
|
||||||
|
MARTe::uint32 *outputSignal;
|
||||||
|
// state notify output
|
||||||
|
MARTe::uint32 *outputBeamON;
|
||||||
|
MARTe::uint32 *outputHVArmed;
|
||||||
|
MARTe::uint32 *outputHVInjection;
|
||||||
|
MARTe::uint32 *outputRFON;
|
||||||
|
// elapsed time notify output;
|
||||||
|
MARTe::uint32 *outputBeamONTime;
|
||||||
|
MARTe::uint32 *outputRFONTime;
|
||||||
|
// shot counter (coutup every RFON time.)
|
||||||
|
MARTe::uint32 *shotCounter;
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
//Internal Parameters
|
||||||
|
//////////////////////////////
|
||||||
|
//PLC_ON time holder
|
||||||
|
MARTe::uint32 plcOnTime;
|
||||||
|
//APS_SWON time holder
|
||||||
|
MARTe::uint32 apsSwonTime;
|
||||||
|
MARTe::uint32 apsSwoffTime;
|
||||||
|
|
||||||
|
//PS turn off delay
|
||||||
|
MARTe::uint32 turn_off_delay;
|
||||||
|
|
||||||
|
//SDN trigger command arrival time.
|
||||||
|
MARTe::uint32 sdnTriggerTime;
|
||||||
|
//HVPS state holder
|
||||||
|
bool mhvps_hvon_is_on;
|
||||||
|
bool aps_hvon_is_on;
|
||||||
|
bool aps_swon_is_on;
|
||||||
|
bool bps_hvon_is_on;
|
||||||
|
bool bps_swon_is_on;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* GAMS_JASDNRTSTATEMACHINEGAM_H_ */
|
||||||
@@ -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,55 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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=JASDNRTStateMachineGAM.x
|
||||||
|
|
||||||
|
PACKAGE=GAMs
|
||||||
|
|
||||||
|
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
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
all: $(OBJS) $(SUBPROJ) \
|
||||||
|
$(BUILD_DIR)/JASDNRTStateMachineGAM$(LIBEXT) \
|
||||||
|
$(BUILD_DIR)/JASDNRTStateMachineGAM$(DLLEXT)
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
177
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JASampleGAM/JASampleGAM.cpp
Normal file
177
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JASampleGAM/JASampleGAM.cpp
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
/**
|
||||||
|
* @file JASampleGAM.cpp
|
||||||
|
* @brief Source file for class JASampleGAM
|
||||||
|
* @date Nov 26, 2018
|
||||||
|
* @author aneto
|
||||||
|
*
|
||||||
|
* @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 JASampleGAM (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 "JASampleGAM.h"
|
||||||
|
|
||||||
|
#include "AdvancedErrorManagement.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
JASampleGAM::JASampleGAM() {
|
||||||
|
// initialize member variables.
|
||||||
|
param1 = 0;
|
||||||
|
param2 = 0;
|
||||||
|
|
||||||
|
//Input signals.
|
||||||
|
input1 = NULL_PTR(MARTe::uint32 *);
|
||||||
|
input2 = NULL_PTR(MARTe::float32 *);
|
||||||
|
//Output signals.
|
||||||
|
output1= NULL_PTR(MARTe::uint32 *);
|
||||||
|
output2 = NULL_PTR(MARTe::float32 *);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
JASampleGAM::~JASampleGAM() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JASampleGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||||
|
//GAM parameters are initialized.
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = GAM::Initialise(data);
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("param1", param1);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The param1 shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("param2", param2);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The param2 shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JASampleGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||||
|
//This method changes internal parameter based on next realtime state.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JASampleGAM::Setup() {
|
||||||
|
// Setup memory for input/output signals on the GAM.
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = (numberOfInputSignals == 2u);
|
||||||
|
if (ok) {
|
||||||
|
ok = (numberOfOutputSignals == 2u);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Two output signals shall be defined");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Two input signals shall be defined");
|
||||||
|
}
|
||||||
|
// Do type check for input signals.
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||||
|
ok = ((inputType == UnsignedInteger32Bit) || (inputType == Float32Bit));
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or flaot32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Do type check for output signals
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfOutputSignals; c++) {
|
||||||
|
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
|
||||||
|
ok = ((outputType == UnsignedInteger32Bit) || (outputType == Float32Bit));
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or float32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Signal id can get by signal name in configuration file
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "InputXXX"; //Variable name in configuration file.
|
||||||
|
uint32 signalxxxIndex; //Index is copied to this variable by using signal name.
|
||||||
|
ok = GetSignalIndex(InputSignals, signalxxxIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "InputXXX input signal shall be defined");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, signalxxxIndex);
|
||||||
|
ok = (inputType == Float32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, signalxxxIndex, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as float32", signalName.Buffer());
|
||||||
|
} else {
|
||||||
|
inputXXX = reinterpret_cast<float32 *>(GetInputSignalMemory(signalxxxIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do type cast. with explicit signal id.
|
||||||
|
if (ok) {
|
||||||
|
input1 = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||||
|
input2 = reinterpret_cast<float32 *>(GetInputSignalMemory(1));
|
||||||
|
|
||||||
|
output1 = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
|
||||||
|
output2 = reinterpret_cast<float32 *>(GetOutputSignalMemory(1));
|
||||||
|
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JASampleGAM::Execute() {
|
||||||
|
// This method is called every realtime state thread cycle.
|
||||||
|
using namespace MARTe;
|
||||||
|
REPORT_ERROR(ErrorManagement::Information, "input1 is %d.", *input1);
|
||||||
|
REPORT_ERROR(ErrorManagement::Information, "input2 is %f.", *input2);
|
||||||
|
REPORT_ERROR(ErrorManagement::Information, "inputXXX is %f.", *inputXXX);
|
||||||
|
|
||||||
|
REPORT_ERROR(ErrorManagement::Information, "maltiply param value to input.");
|
||||||
|
|
||||||
|
*output1 = *input1 * param1;
|
||||||
|
*output2 = *input2 * param2;
|
||||||
|
|
||||||
|
REPORT_ERROR(ErrorManagement::Information, "output1 is %d.", *output1);
|
||||||
|
REPORT_ERROR(ErrorManagement::Information, "output2 is %f.", *output2);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JASampleGAM, "1.0")
|
||||||
122
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JASampleGAM/JASampleGAM.h
Normal file
122
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JASampleGAM/JASampleGAM.h
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
/**
|
||||||
|
* @file JASampleGAM.h
|
||||||
|
* @brief Header file for class JASampleGAM
|
||||||
|
* @date Nov 26, 2018
|
||||||
|
* @author aneto
|
||||||
|
*
|
||||||
|
* @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 JASampleGAM
|
||||||
|
* 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 GAMS_JASampleGAM_H_
|
||||||
|
#define GAMS_JASampleGAM_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "GAM.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* @brief GAM Sample Usage.
|
||||||
|
* @details Sample
|
||||||
|
*
|
||||||
|
* The configuration syntax is:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* +SampleGAM = {
|
||||||
|
* Class = JASampleGAM
|
||||||
|
* InputSignals = {
|
||||||
|
* Input1 = {
|
||||||
|
* DataSource = "DDB"
|
||||||
|
* Type = uint32
|
||||||
|
* Default = 0
|
||||||
|
* }
|
||||||
|
* Input2 = {
|
||||||
|
* DataSource = "DDB"
|
||||||
|
* Type = float32
|
||||||
|
* Default = 100
|
||||||
|
* }
|
||||||
|
* InputXXX = {
|
||||||
|
* DataSource = "DDB"
|
||||||
|
* Type = float32
|
||||||
|
* NumberOfElements = 1
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* OutputSignals = {
|
||||||
|
* Output1 = {
|
||||||
|
* DataSource = "DDB"
|
||||||
|
* Type = uint32
|
||||||
|
* Default = 0
|
||||||
|
* }
|
||||||
|
* Output2 = {
|
||||||
|
* DataSource = "DDB"
|
||||||
|
* Type = int32
|
||||||
|
* Default = 100
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class JASampleGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
JASampleGAM();
|
||||||
|
|
||||||
|
virtual ~JASampleGAM();
|
||||||
|
|
||||||
|
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||||
|
|
||||||
|
virtual bool Setup();
|
||||||
|
|
||||||
|
virtual bool Execute();
|
||||||
|
|
||||||
|
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
|
||||||
|
const MARTe::char8 * const nextStateName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
//GAM fixed parameters.
|
||||||
|
MARTe::uint32 param1;
|
||||||
|
MARTe::float32 param2;
|
||||||
|
|
||||||
|
// Input signals
|
||||||
|
MARTe::uint32 *input1;
|
||||||
|
MARTe::float32 *input2;
|
||||||
|
MARTe::float32 *inputXXX;
|
||||||
|
|
||||||
|
// Output signals
|
||||||
|
MARTe::uint32 *output1;
|
||||||
|
MARTe::float32 *output2;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* GAMS_JASampleGAM_H_ */
|
||||||
27
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JASampleGAM/Makefile.gcc
Normal file
27
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JASampleGAM/Makefile.gcc
Normal file
@@ -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
|
||||||
55
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JASampleGAM/Makefile.inc
Normal file
55
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JASampleGAM/Makefile.inc
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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=JARTSampleGAM.x
|
||||||
|
|
||||||
|
PACKAGE=GAMs
|
||||||
|
|
||||||
|
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
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
all: $(OBJS) $(SUBPROJ) \
|
||||||
|
$(BUILD_DIR)/JARTSampleGAM$(LIBEXT) \
|
||||||
|
$(BUILD_DIR)/JARTSampleGAM$(DLLEXT)
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
/**
|
||||||
|
* @file JASourceChoiseGAM.cpp
|
||||||
|
* @brief Source file for class JASourceChoiseGAM
|
||||||
|
* @date Nov 26, 2018
|
||||||
|
* @author aneto
|
||||||
|
*
|
||||||
|
* @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 JASourceChoiseGAM (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 "JASourceChoiseGAM.h"
|
||||||
|
|
||||||
|
#include "AdvancedErrorManagement.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
JASourceChoiseGAM::JASourceChoiseGAM() {
|
||||||
|
// initialize member variables.
|
||||||
|
numberOfPVs = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
JASourceChoiseGAM::~JASourceChoiseGAM() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JASourceChoiseGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||||
|
//GAM parameters are initialized.
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = GAM::Initialise(data);
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("numberOfPVs", numberOfPVs);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The numberOfPVs parameter shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JASourceChoiseGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||||
|
//This method changes internal parameter based on next realtime state.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JASourceChoiseGAM::Setup() {
|
||||||
|
// Setup memory for input/output signals on the GAM.
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = (numberOfInputSignals == numberOfPVs*3u);
|
||||||
|
if (ok) {
|
||||||
|
ok = (numberOfOutputSignals == numberOfPVs);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "%d *3 output signals shall be defined", numberOfPVs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "%d input signals shall be defined", numberOfPVs);
|
||||||
|
}
|
||||||
|
// Do type check for input signals.
|
||||||
|
int int_num = 0;
|
||||||
|
int float_num = 0;
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||||
|
if(inputType == UnsignedInteger32Bit){
|
||||||
|
int_num++;
|
||||||
|
} else if (inputType == Float32Bit) {
|
||||||
|
float_num++;
|
||||||
|
} else {
|
||||||
|
ok = false;
|
||||||
|
};
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or flaot32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Do type check for output signals
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfOutputSignals; c++) {
|
||||||
|
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
|
||||||
|
ok = ((outputType == UnsignedInteger32Bit) || (outputType == Float32Bit));
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or float32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Set memory
|
||||||
|
inputUInt32.resize(numberOfPVs*2);
|
||||||
|
inputFloat32.resize(numberOfPVs*2);
|
||||||
|
choise.resize(numberOfPVs);
|
||||||
|
outputUInt32.resize(numberOfPVs);
|
||||||
|
outputFloat32.resize(numberOfPVs);
|
||||||
|
|
||||||
|
prevUInt32.resize(numberOfPVs*2);
|
||||||
|
prevFloat32.resize(numberOfPVs*2);
|
||||||
|
|
||||||
|
if(ok){
|
||||||
|
for(uint32 i=0; i<numberOfPVs; i++){ //Expected inp1, inp2, choise order in signal list.
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, i*3);
|
||||||
|
if(inputType == UnsignedInteger32Bit){
|
||||||
|
inputUInt32[2*i] = reinterpret_cast<uint32 *>(GetInputSignalMemory(3*i));
|
||||||
|
inputUInt32[2*i+1] = reinterpret_cast<uint32 *>(GetInputSignalMemory(3*i+1));
|
||||||
|
choise[i] = reinterpret_cast<uint32 *>(GetInputSignalMemory(3*i+2));
|
||||||
|
outputUInt32[i] = reinterpret_cast<uint32 *>(GetOutputSignalMemory(i));
|
||||||
|
} else if(inputType == Float32Bit){
|
||||||
|
inputFloat32[2*i] = reinterpret_cast<float *>(GetInputSignalMemory(3*i));
|
||||||
|
inputFloat32[2*i+1] = reinterpret_cast<float *>(GetInputSignalMemory(3*i+1));
|
||||||
|
choise[i] = reinterpret_cast<uint32 *>(GetInputSignalMemory(3*i+2));
|
||||||
|
outputFloat32[i] = reinterpret_cast<float32 *>(GetOutputSignalMemory(i));
|
||||||
|
}
|
||||||
|
prevUInt32[2*i] = 0;
|
||||||
|
prevUInt32[2*i+1] = 0;
|
||||||
|
prevFloat32[2*i] = 0;
|
||||||
|
prevFloat32[2*i+1] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JASourceChoiseGAM::Execute() {
|
||||||
|
// This method is called every realtime state thread cycle.
|
||||||
|
using namespace MARTe;
|
||||||
|
|
||||||
|
for (uint32 i=0; i < numberOfPVs; i++){
|
||||||
|
if(*choise[i]==0){
|
||||||
|
if(outputUInt32[i]){
|
||||||
|
if(prevUInt32[i*2] != *inputUInt32[i*2]){
|
||||||
|
*outputUInt32[i] = *inputUInt32[i*2];
|
||||||
|
prevUInt32[i*2] = *inputUInt32[i*2];
|
||||||
|
prevUInt32[1+i*2] = *inputUInt32[1+i*2];
|
||||||
|
}
|
||||||
|
} else if(outputFloat32[i]){
|
||||||
|
if(prevFloat32[i*2] != *inputFloat32[i*2]){
|
||||||
|
*outputFloat32[i] = *inputFloat32[i*2];
|
||||||
|
prevFloat32[i*2] = *inputFloat32[i*2];
|
||||||
|
prevFloat32[1+i*2] = *inputFloat32[1+i*2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(outputUInt32[i]){
|
||||||
|
if(prevUInt32[1+i*2] != *inputUInt32[1+i*2]){
|
||||||
|
*outputUInt32[i] = *inputUInt32[1+i*2];
|
||||||
|
prevUInt32[i*2] = *inputUInt32[i*2];
|
||||||
|
prevUInt32[1+i*2] = *inputUInt32[1+i*2];
|
||||||
|
}
|
||||||
|
} else if (outputFloat32[i]){
|
||||||
|
if(prevFloat32[1+i*2] != *inputFloat32[1+i*2]){
|
||||||
|
*outputFloat32[i] = *inputFloat32[1+i*2];
|
||||||
|
prevFloat32[i*2] = *inputFloat32[i*2];
|
||||||
|
prevFloat32[1+i*2] = *inputFloat32[1+i*2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JASourceChoiseGAM, "1.0")
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
/**
|
||||||
|
* @file JASourceChoiseGAM.h
|
||||||
|
* @brief Header file for class JASourceChoiseGAM
|
||||||
|
* @date Mar 04, 2019
|
||||||
|
* @author kuchida
|
||||||
|
*
|
||||||
|
* @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 JASourceChoiseGAM
|
||||||
|
* 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 GAMS_JASourceChoiseGAM_H_
|
||||||
|
#define GAMS_JASourceChoiseGAM_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "GAM.h"
|
||||||
|
#include <vector>
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class JASourceChoiseGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
JASourceChoiseGAM();
|
||||||
|
|
||||||
|
virtual ~JASourceChoiseGAM();
|
||||||
|
|
||||||
|
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||||
|
|
||||||
|
virtual bool Setup();
|
||||||
|
|
||||||
|
virtual bool Execute();
|
||||||
|
|
||||||
|
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
|
||||||
|
const MARTe::char8 * const nextStateName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
//The list of possible states
|
||||||
|
//GAM fixed parameters.
|
||||||
|
MARTe::uint32 numberOfPVs;
|
||||||
|
|
||||||
|
// Input signals
|
||||||
|
std::vector<MARTe::uint32 *> inputUInt32;
|
||||||
|
std::vector<MARTe::float32 *> inputFloat32;
|
||||||
|
std::vector<MARTe::uint32 *> choise;
|
||||||
|
|
||||||
|
// Output signals
|
||||||
|
std::vector<MARTe::uint32 *> outputUInt32;
|
||||||
|
std::vector<MARTe::float32 *> outputFloat32;
|
||||||
|
|
||||||
|
// Previous Input value
|
||||||
|
std::vector<MARTe::uint32> prevUInt32;
|
||||||
|
std::vector<MARTe::float32> prevFloat32;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* GAMS_JASourceChoiseGAM_H_ */
|
||||||
@@ -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,55 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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=JASourceChoiseGAM.x
|
||||||
|
|
||||||
|
PACKAGE=GAMs
|
||||||
|
|
||||||
|
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
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
all: $(OBJS) $(SUBPROJ) \
|
||||||
|
$(BUILD_DIR)/JASourceChoiseGAM$(LIBEXT) \
|
||||||
|
$(BUILD_DIR)/JASourceChoiseGAM$(DLLEXT)
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
@@ -0,0 +1,206 @@
|
|||||||
|
/**
|
||||||
|
* @file JATerminalInterfaceGAM.cpp
|
||||||
|
* @brief Source file for class JATerminalInterfaceGAM
|
||||||
|
* @date Feb 19, 2019
|
||||||
|
* @author kuchida
|
||||||
|
*
|
||||||
|
* @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 JATerminalInterfaceGAM (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 "JATerminalInterfaceGAM.h"
|
||||||
|
|
||||||
|
#include "AdvancedErrorManagement.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
JATerminalInterfaceGAM::JATerminalInterfaceGAM() {
|
||||||
|
|
||||||
|
// Fixed GAM input
|
||||||
|
aps_hvon_term = 0;
|
||||||
|
|
||||||
|
// Parameters which get from Input signals.
|
||||||
|
mhvps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
aps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
aps_swon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
bps_hvon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
bps_swon = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
stateMachineOutput = NULL_PTR(MARTe::uint32 *);
|
||||||
|
|
||||||
|
// write out target.
|
||||||
|
outputSignalNI6259 = NULL_PTR(MARTe::uint32 *);
|
||||||
|
outputSignalNI6528P3 = NULL_PTR(MARTe::uint8 *);
|
||||||
|
outputSignalNI6528P4 = NULL_PTR(MARTe::uint8 *);
|
||||||
|
|
||||||
|
aps_hvon_state = 0;
|
||||||
|
aps_swon_state = 0;
|
||||||
|
mhvps_hvon_state = 0;
|
||||||
|
bps_hvon_state = 0;
|
||||||
|
bps_swon_state = 0;
|
||||||
|
p3Value = 0;
|
||||||
|
p4Value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
JATerminalInterfaceGAM::~JATerminalInterfaceGAM() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JATerminalInterfaceGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = GAM::Initialise(data);
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("mhvps_hvon_term", mhvps_hvon_term);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The mhvps_hvon_term shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("aps_hvon_term", aps_hvon_term);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_hvon_term shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("aps_swon_term", aps_swon_term);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The aps_swon_term shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("bps_hvon_term", bps_hvon_term);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_hvon_term shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("bps_swon_term", bps_swon_term);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The bps_swon_term shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JATerminalInterfaceGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JATerminalInterfaceGAM::Setup() {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = (numberOfInputSignals == 9u);
|
||||||
|
if (ok) {
|
||||||
|
ok = (numberOfOutputSignals == 3u);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Three output signals shall be defined");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Nine input signals shall be defined");
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfInputSignals; c++) {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, c);
|
||||||
|
ok = (inputType == UnsignedInteger32Bit || inputType == UnsignedInteger8Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or uint8", signalName.Buffer());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
uint32 c;
|
||||||
|
for (c = 0u; c < numberOfOutputSignals; c++) {
|
||||||
|
TypeDescriptor outputType = GetSignalType(OutputSignals, c);
|
||||||
|
ok = (outputType == UnsignedInteger32Bit || outputType == UnsignedInteger8Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, c, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32 or uint8", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
//mhvps_manm = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||||
|
mhvps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(0));
|
||||||
|
//aps_manm = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
|
||||||
|
aps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(1));
|
||||||
|
aps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(2));
|
||||||
|
//bps_manm = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
|
||||||
|
bps_hvon = reinterpret_cast<uint32 *>(GetInputSignalMemory(3));
|
||||||
|
bps_swon = reinterpret_cast<uint32 *>(GetInputSignalMemory(4));
|
||||||
|
short_pulse_mode = reinterpret_cast<uint32 *>(GetInputSignalMemory(5));
|
||||||
|
stateMachineOutput = reinterpret_cast<uint32 *>(GetInputSignalMemory(6));
|
||||||
|
ni6528p3Value = reinterpret_cast<uint8 *>(GetInputSignalMemory(7));
|
||||||
|
ni6528p4Value = reinterpret_cast<uint8 *>(GetInputSignalMemory(8));
|
||||||
|
|
||||||
|
outputSignalNI6259 = reinterpret_cast<uint32 *>(GetOutputSignalMemory(0));
|
||||||
|
outputSignalNI6528P3 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(1));
|
||||||
|
outputSignalNI6528P4 = reinterpret_cast<uint8 *>(GetOutputSignalMemory(2));
|
||||||
|
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JATerminalInterfaceGAM::Execute() {
|
||||||
|
using namespace MARTe;
|
||||||
|
uint8 sm = *stateMachineOutput;
|
||||||
|
|
||||||
|
|
||||||
|
//Update HVPS state
|
||||||
|
aps_hvon_state = ((sm >> (0))&1);
|
||||||
|
aps_swon_state = ((sm >> (4))&1);
|
||||||
|
mhvps_hvon_state = ((sm >> (2))&1);
|
||||||
|
bps_hvon_state = ((sm >> (1))&1);
|
||||||
|
bps_swon_state = ((sm >> (3))&1);
|
||||||
|
|
||||||
|
if(*short_pulse_mode == 1){
|
||||||
|
p3Value = 1*aps_hvon_state + 8*bps_hvon_state +16*bps_swon_state;
|
||||||
|
*outputSignalNI6259 = 1*aps_swon_state;
|
||||||
|
//uint8 ni6528p3ValueTemp = 0;//*ni6528p3Value;
|
||||||
|
//ni6528p3ValueTemp &= ~(1<<2); //Does not turn on ni6258 aps switch
|
||||||
|
//Update terminal value
|
||||||
|
//*outputSignalNI6528P3 = ~(ni6528p3ValueTemp | p3Value);
|
||||||
|
*outputSignalNI6528P3 = ~p3Value;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "short pulse mode with p3: %d.", p3Value);
|
||||||
|
} else {
|
||||||
|
p3Value = 1*aps_hvon_state +2*aps_swon_state + 8*bps_hvon_state +16*bps_swon_state;
|
||||||
|
//REPORT_ERROR(ErrorManagement::Debug, "long pulse mode with p3: %d.", p3Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
p4Value = 8*mhvps_hvon_state;
|
||||||
|
*outputSignalNI6528P4 = ~(*ni6528p4Value | p4Value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JATerminalInterfaceGAM, "1.0")
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
/**
|
||||||
|
* @file JATerminalInterfaceGAM.h
|
||||||
|
* @brief Header file for class JATerminalInterfaceGAM
|
||||||
|
* @date Feb 19, 2020
|
||||||
|
* @author kuchida
|
||||||
|
*
|
||||||
|
* @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 JATerminalInterfaceGAM
|
||||||
|
* 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 GAMS_JATerminalInterfaceGAM_H_
|
||||||
|
#define GAMS_JATerminalInterfaceGAM_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "GAM.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GAM calculates one output value by comparing input value and fixed parameters.
|
||||||
|
*
|
||||||
|
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* +terminalInterfaceGAM = {
|
||||||
|
* Class = JATerminalInterfaceGAM
|
||||||
|
* mhvps_hvon_term = 4
|
||||||
|
* aps_hvon_term = 1
|
||||||
|
* aps_swon_term = 16
|
||||||
|
* bps_hvon_term = 2
|
||||||
|
* bps_swon_term = 8
|
||||||
|
* InputSignals = {
|
||||||
|
* MHVPS_HVON = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* APS_HVON = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* APS_SWON = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* BPS_HVON = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* BPS_SWON = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* Value = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* OutputSignals = {
|
||||||
|
* Value = {
|
||||||
|
* DataSource = NI6259
|
||||||
|
* Type = uint32
|
||||||
|
* Trigger = 1
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class JATerminalInterfaceGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
JATerminalInterfaceGAM();
|
||||||
|
|
||||||
|
virtual ~JATerminalInterfaceGAM();
|
||||||
|
|
||||||
|
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||||
|
|
||||||
|
virtual bool Setup();
|
||||||
|
|
||||||
|
virtual bool Execute();
|
||||||
|
|
||||||
|
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
|
||||||
|
const MARTe::char8 * const nextStateName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Fixed GAM input
|
||||||
|
MARTe::uint32 mhvps_hvon_term;
|
||||||
|
MARTe::uint32 aps_hvon_term;
|
||||||
|
MARTe::uint32 aps_swon_term;
|
||||||
|
MARTe::uint32 bps_hvon_term;
|
||||||
|
MARTe::uint32 bps_swon_term;
|
||||||
|
|
||||||
|
// Input signals
|
||||||
|
//MARTe::uint32 *mhvps_manm;
|
||||||
|
MARTe::uint32 *mhvps_hvon;
|
||||||
|
|
||||||
|
//MARTe::uint32 *aps_manm;
|
||||||
|
MARTe::uint32 *aps_hvon;
|
||||||
|
MARTe::uint32 *aps_swon;
|
||||||
|
|
||||||
|
//MARTe::uint32 *bps_manm;
|
||||||
|
MARTe::uint32 *bps_hvon;
|
||||||
|
MARTe::uint32 *bps_swon;
|
||||||
|
|
||||||
|
MARTe::uint32 *short_pulse_mode;
|
||||||
|
|
||||||
|
MARTe::uint32 *stateMachineOutput;
|
||||||
|
MARTe::uint8 *ni6528p3Value;
|
||||||
|
MARTe::uint8 *ni6528p4Value;
|
||||||
|
|
||||||
|
// Output signals
|
||||||
|
MARTe::uint32 *outputSignalNI6259;
|
||||||
|
MARTe::uint8 *outputSignalNI6528P3;
|
||||||
|
MARTe::uint8 *outputSignalNI6528P4;
|
||||||
|
|
||||||
|
MARTe::uint8 aps_hvon_state;
|
||||||
|
MARTe::uint8 aps_swon_state;
|
||||||
|
MARTe::uint8 mhvps_hvon_state;
|
||||||
|
MARTe::uint8 bps_hvon_state;
|
||||||
|
MARTe::uint8 bps_swon_state;
|
||||||
|
MARTe::uint8 p3Value;
|
||||||
|
MARTe::uint8 p4Value;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* GAMS_JATerminalInterfaceGAM_H_ */
|
||||||
@@ -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,55 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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=JATerminalInterfaceGAM.x
|
||||||
|
|
||||||
|
PACKAGE=GAMs
|
||||||
|
|
||||||
|
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
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
all: $(OBJS) $(SUBPROJ) \
|
||||||
|
$(BUILD_DIR)/JATerminalInterfaceGAM$(LIBEXT) \
|
||||||
|
$(BUILD_DIR)/JATerminalInterfaceGAM$(DLLEXT)
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
@@ -0,0 +1,178 @@
|
|||||||
|
/**
|
||||||
|
* @file JATriangleWaveGAM.cpp
|
||||||
|
* @brief Source file for class JATriangleWaveGAM
|
||||||
|
* @date Jan, 2019
|
||||||
|
* @author rhari
|
||||||
|
*
|
||||||
|
* @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 JATriangleWaveGAM (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 "JATriangleWaveGAM.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
MARTe::float32 absFloat(MARTe::float32 x) {
|
||||||
|
if (x < 0.0f) {
|
||||||
|
return -x;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
JATriangleWaveGAM::JATriangleWaveGAM() {
|
||||||
|
frequency = NULL_PTR(MARTe::float32 *);
|
||||||
|
amplitude = NULL_PTR(MARTe::float32 *);
|
||||||
|
offset = NULL_PTR(MARTe::float32 *);
|
||||||
|
plcStandby = NULL_PTR(MARTe::uint32 *);
|
||||||
|
waveOutput = NULL_PTR(MARTe::float32 *);
|
||||||
|
time = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
JATriangleWaveGAM::~JATriangleWaveGAM() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JATriangleWaveGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||||
|
using namespace MARTe;
|
||||||
|
return GAM::Initialise(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JATriangleWaveGAM::Setup() {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = (numberOfInputSignals == 4u);
|
||||||
|
if (ok) {
|
||||||
|
ok = (numberOfOutputSignals == 1u);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "One output signal shall be defined.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Four input signals shall be defined.");
|
||||||
|
}
|
||||||
|
uint32 freqIndex;
|
||||||
|
uint32 ampIndex;
|
||||||
|
uint32 offsetIndex;
|
||||||
|
uint32 plcStandbyIndex;
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "Frequency";
|
||||||
|
ok = GetSignalIndex(InputSignals, freqIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Frequency input signal shall be defined.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, freqIndex);
|
||||||
|
ok = (inputType == Float32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Frequency shall be defined as float32.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "Amplitude";
|
||||||
|
ok = GetSignalIndex(InputSignals, ampIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Amplitude input signal shall be defined.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, ampIndex);
|
||||||
|
ok = (inputType == Float32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Amplitude shall be defined as float32.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "Offset";
|
||||||
|
ok = GetSignalIndex(InputSignals, offsetIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Offset input signal shall be defined.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, offsetIndex);
|
||||||
|
ok = (inputType == Float32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Offset shall be defined as float32.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "PLCSTANDBY";
|
||||||
|
ok = GetSignalIndex(InputSignals, plcStandbyIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "PLCSTANDBY input signal shall be defined.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, plcStandbyIndex);
|
||||||
|
ok = (inputType == UnsignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "PLCSTANDBY shall be defined as uint32.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
TypeDescriptor inputType = GetSignalType(OutputSignals, 0);
|
||||||
|
ok = (inputType == Float32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::ParametersError, "Signal Amplitude shall be defined as float32.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
frequency = reinterpret_cast<float32 *>(GetInputSignalMemory(freqIndex));
|
||||||
|
amplitude = reinterpret_cast<float32 *>(GetInputSignalMemory(ampIndex));
|
||||||
|
offset = reinterpret_cast<float32 *>(GetInputSignalMemory(offsetIndex));
|
||||||
|
plcStandby = reinterpret_cast<uint32 *>(GetInputSignalMemory(plcStandbyIndex));
|
||||||
|
waveOutput = reinterpret_cast<float32 *>(GetOutputSignalMemory(0));
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JATriangleWaveGAM::Execute() {
|
||||||
|
using namespace MARTe;
|
||||||
|
// If frequency is not set, output 0.
|
||||||
|
if (*frequency <= 0.0f || *plcStandby == 0u) {
|
||||||
|
*waveOutput = 0.0f;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Increase the current time.
|
||||||
|
++time;
|
||||||
|
// Calculate the period in milliseconds
|
||||||
|
float32 periodMs = 1000.0 / *frequency;
|
||||||
|
// Make sure the time is on [0, periodMs] interval.
|
||||||
|
while (time > periodMs) {
|
||||||
|
time -= periodMs;
|
||||||
|
}
|
||||||
|
// Formula:
|
||||||
|
// f(x) = |x - 0.5| * 2 * amplitude
|
||||||
|
// where x is between 0 and 1
|
||||||
|
*waveOutput = absFloat((time / periodMs) - 0.5f) * 2.0f * (*amplitude) + *offset;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JATriangleWaveGAM, "1.0")
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
/**
|
||||||
|
* @file JATriangleWaveGAM.h
|
||||||
|
* @brief Header file for class JATriangleWaveGAM
|
||||||
|
* @date Jan, 2019
|
||||||
|
* @author rhari
|
||||||
|
*
|
||||||
|
* @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 JATriangleWaveGAM
|
||||||
|
* 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 GAMS_JATRIANGLEWAVEGAM_H_
|
||||||
|
#define GAMS_JATRIANGLEWAVEGAM_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "GAM.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GAM provides triangular waveform output within 1kHz thread.
|
||||||
|
*
|
||||||
|
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||||
|
* <pre>
|
||||||
|
* +CCPSWaveformGAM = {
|
||||||
|
* Class = JATriangleWaveGAM
|
||||||
|
* InputSignals = {
|
||||||
|
* Offset = {
|
||||||
|
* Alias = OFFSET
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = float32
|
||||||
|
* }
|
||||||
|
* Frequency = {
|
||||||
|
* Alias = CCPS_OUTPUT_FREQ
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = float32
|
||||||
|
* }
|
||||||
|
* Amplitude = {
|
||||||
|
* Alias = CCPS_OUTPUT_AMP
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = float32
|
||||||
|
* }
|
||||||
|
* PLCCCPSON = {
|
||||||
|
* Alias = PLC_CCPSON
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* READY = {
|
||||||
|
* Alias = PLC_READY
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* OutputSignals = {
|
||||||
|
* CCPS_REF = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* Type = float32
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class JATriangleWaveGAM : public MARTe::GAM {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
JATriangleWaveGAM();
|
||||||
|
|
||||||
|
virtual ~JATriangleWaveGAM();
|
||||||
|
|
||||||
|
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||||
|
|
||||||
|
virtual bool Setup();
|
||||||
|
|
||||||
|
virtual bool Execute();
|
||||||
|
private:
|
||||||
|
// Input signal containing the frequency of the waveform.
|
||||||
|
MARTe::float32 *frequency;
|
||||||
|
|
||||||
|
// Input signal containing the amplitude of the waveform.
|
||||||
|
MARTe::float32 *amplitude;
|
||||||
|
|
||||||
|
// Input signal cantaining the offset of the waveform.
|
||||||
|
MARTe::float32 *offset;
|
||||||
|
|
||||||
|
// Input signal containing CCPS_ON_REQUEST
|
||||||
|
//MARTe::uint32 *plcccpson;
|
||||||
|
|
||||||
|
// Input signal condition CCPS_READY
|
||||||
|
//MARTe::uint32 *plcReady;
|
||||||
|
|
||||||
|
// Input signal condition CCPS_STANDBY
|
||||||
|
MARTe::uint32 *plcStandby;
|
||||||
|
|
||||||
|
MARTe::float32 *waveOutput;
|
||||||
|
|
||||||
|
MARTe::float32 time;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* GAMS_JATRIANGLEWAVEGAM_H_ */
|
||||||
@@ -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,56 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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=JATriangleWaveGAM.x
|
||||||
|
|
||||||
|
PACKAGE=GAMs
|
||||||
|
|
||||||
|
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
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
all: $(OBJS) $(SUBPROJ) \
|
||||||
|
$(BUILD_DIR)/JATriangleWaveGAM$(LIBEXT) \
|
||||||
|
$(BUILD_DIR)/JATriangleWaveGAM$(DLLEXT)
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
|
|
||||||
@@ -0,0 +1,317 @@
|
|||||||
|
/**
|
||||||
|
* @file JAWFRecordGAM.cpp
|
||||||
|
* @brief Source file for class JAWFRecordGAM
|
||||||
|
* @date Jan, 2019
|
||||||
|
* @author rhari
|
||||||
|
*
|
||||||
|
* @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 JAWFRecordGAM (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 "JAWFRecordGAM.h"
|
||||||
|
|
||||||
|
#include "AdvancedErrorManagement.h"
|
||||||
|
#include "CLASSMETHODREGISTER.h"
|
||||||
|
#include "File.h"
|
||||||
|
#include "MessageI.h"
|
||||||
|
#include "RegisteredMethodsMessageFilter.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Static definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// How often output signals are updated.
|
||||||
|
const MARTe::uint32 cycleMs = 10u;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
JAWFRecordGAM::JAWFRecordGAM() :
|
||||||
|
GAM() {
|
||||||
|
filenameSignalIndex = 0u;
|
||||||
|
timeSignal = NULL_PTR(MARTe::int32 *);
|
||||||
|
loadTriggerSignal = NULL_PTR(MARTe::uint32 *);
|
||||||
|
valueSignals = NULL_PTR(MARTe::float32 **);
|
||||||
|
maxElements = 0u;
|
||||||
|
readOnce = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
JAWFRecordGAM::~JAWFRecordGAM() {
|
||||||
|
if (valueSignals != NULL_PTR(MARTe::float32 **)) {
|
||||||
|
delete[] valueSignals;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAWFRecordGAM::Initialise(MARTe::StructuredDataI & data) {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = GAM::Initialise(data);
|
||||||
|
if (ok) {
|
||||||
|
ok = data.Read("Directory", directory);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "The Directory shall be specified");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAWFRecordGAM::Setup() {
|
||||||
|
using namespace MARTe;
|
||||||
|
bool ok = (numberOfInputSignals == 2u);
|
||||||
|
if (ok) {
|
||||||
|
ok = (numberOfOutputSignals > 1u);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "At least two output signal shall be defined");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Two input signal with the filename and file load trigger shall be defined");
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "Filename";
|
||||||
|
ok = GetSignalIndex(InputSignals, filenameSignalIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Filename input signal shall be defined");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, filenameSignalIndex);
|
||||||
|
ok = (inputType == CharString);
|
||||||
|
if (!ok) {
|
||||||
|
ok = (inputType == Character8Bit);
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, filenameSignalIndex, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as string", signalName.Buffer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
StreamString signalName = "CSV_LOAD";
|
||||||
|
uint32 loadSignalIndex;
|
||||||
|
ok = GetSignalIndex(InputSignals, loadSignalIndex, signalName.Buffer());
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "CSV_LOAD input signal shall be defined");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TypeDescriptor inputType = GetSignalType(InputSignals, loadSignalIndex);
|
||||||
|
ok = (inputType == UnsignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, loadSignalIndex, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as uint32", signalName.Buffer());
|
||||||
|
} else {
|
||||||
|
loadTriggerSignal = reinterpret_cast<uint32 *>(GetInputSignalMemory(loadSignalIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
TypeDescriptor timeType = GetSignalType(OutputSignals, 0);
|
||||||
|
|
||||||
|
ok = (timeType == SignedInteger32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(InputSignals, 0, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as int32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 i;
|
||||||
|
for (i = 1u; (i < numberOfOutputSignals) && (ok); i++) {
|
||||||
|
TypeDescriptor outputType = GetSignalType(OutputSignals, i);
|
||||||
|
ok = (outputType == Float32Bit);
|
||||||
|
if (!ok) {
|
||||||
|
StreamString signalName;
|
||||||
|
(void) GetSignalName(OutputSignals, i, signalName);
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Signal %s shall be defined as float32", signalName.Buffer());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
uint32 dimentionsCount;
|
||||||
|
ok = GetSignalNumberOfDimensions(OutputSignals, 0u, dimentionsCount);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Output signals shall have 1 dimension.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
uint32 elementsCount;
|
||||||
|
ok = GetSignalNumberOfElements(OutputSignals, 0u, elementsCount);
|
||||||
|
if (maxElements == 0) {
|
||||||
|
maxElements = elementsCount;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ok = (maxElements == elementsCount);
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Output signals shall have consistent number of elements.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
valueSignals = new float32*[numberOfOutputSignals - 1u];
|
||||||
|
uint32 i;
|
||||||
|
for (i = 1u; i < numberOfOutputSignals; i++) {
|
||||||
|
valueSignals[i - 1] = reinterpret_cast<float32 *>(GetOutputSignalMemory(i));
|
||||||
|
}
|
||||||
|
timeSignal = reinterpret_cast<int32 *>(GetOutputSignalMemory(0));
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAWFRecordGAM::PrepareNextState(const MARTe::char8 * const currentStateName, const MARTe::char8 * const nextStateName) {
|
||||||
|
if (strcmp(nextStateName, "WaitReady") == 0) {
|
||||||
|
// Reset read once flag when reentering WaitReady state.
|
||||||
|
readOnce = true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JAWFRecordGAM::LoadFile() {
|
||||||
|
using namespace MARTe;
|
||||||
|
|
||||||
|
bool ok = true;
|
||||||
|
|
||||||
|
const char8 * const filenameSignal = reinterpret_cast<const char8 * const >(GetInputSignalMemory(filenameSignalIndex));
|
||||||
|
StreamString filename = directory;
|
||||||
|
filename += DIRECTORY_SEPARATOR;
|
||||||
|
filename += filenameSignal;
|
||||||
|
REPORT_ERROR(ErrorManagement::Debug, "Opening file %s", filename.Buffer());
|
||||||
|
|
||||||
|
File f;
|
||||||
|
ok = f.Open(filename.Buffer(), BasicFile::ACCESS_MODE_R);
|
||||||
|
|
||||||
|
uint32 numberOfPreProgrammedTimeRows = 0u;
|
||||||
|
int32 *preProgrammedTime;
|
||||||
|
float32 **preProgrammedValues;
|
||||||
|
uint32 numberOfPreProgrammedValues = 0u;
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
StreamString tokenLine;
|
||||||
|
while (f.GetLine(tokenLine)) {
|
||||||
|
if (tokenLine[0] != '#') {
|
||||||
|
numberOfPreProgrammedTimeRows++;
|
||||||
|
}
|
||||||
|
tokenLine = "";
|
||||||
|
}
|
||||||
|
f.Seek(0);
|
||||||
|
uint32 t = 0u;
|
||||||
|
tokenLine = "";
|
||||||
|
while ((ok) && (f.GetLine(tokenLine))) {
|
||||||
|
if (tokenLine[0] == '#') {
|
||||||
|
tokenLine = "";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (numberOfPreProgrammedValues == 0) {
|
||||||
|
StreamString token;
|
||||||
|
char8 ignored;
|
||||||
|
tokenLine.Seek(0);
|
||||||
|
while (tokenLine.GetToken(token, ",", ignored)) {
|
||||||
|
numberOfPreProgrammedValues++;
|
||||||
|
token = "";
|
||||||
|
}
|
||||||
|
ok = numberOfPreProgrammedValues == numberOfOutputSignals;
|
||||||
|
// Remove time from pre-programmed values count.
|
||||||
|
numberOfPreProgrammedValues -= 1u;
|
||||||
|
if (ok) {
|
||||||
|
preProgrammedTime = new int32[maxElements];
|
||||||
|
memset(preProgrammedTime, 0, maxElements * sizeof(int32));
|
||||||
|
preProgrammedValues = new float32*[numberOfPreProgrammedValues];
|
||||||
|
uint32 j;
|
||||||
|
for (j = 0u; j < numberOfPreProgrammedValues; j++) {
|
||||||
|
preProgrammedValues[j] = new float32[maxElements];
|
||||||
|
memset(preProgrammedValues[j], 0, maxElements * sizeof(float32));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(MARTe::ErrorManagement::ParametersError, "Number of columns in csv file (%d) is not consistent with the number of output signals (%d)", numberOfPreProgrammedValues,
|
||||||
|
numberOfOutputSignals - 1u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
StreamString token;
|
||||||
|
char8 ignored;
|
||||||
|
tokenLine.Seek(0);
|
||||||
|
uint32 idx = 0u;
|
||||||
|
while (tokenLine.GetToken(token, ",", ignored)) {
|
||||||
|
if (idx == 0u) {
|
||||||
|
preProgrammedTime[t] = atoi(token.Buffer());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ok = ((idx - 1) < numberOfPreProgrammedValues);
|
||||||
|
if (ok) {
|
||||||
|
preProgrammedValues[idx - 1][t] = static_cast<float32>(atof(token.Buffer()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
REPORT_ERROR(ErrorManagement::FatalError, "Number of columns in csv file is not consistent with the number of output signals in line %d", t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
token = "";
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
t++;
|
||||||
|
}
|
||||||
|
tokenLine = "";
|
||||||
|
}
|
||||||
|
f.Close();
|
||||||
|
} else {
|
||||||
|
REPORT_ERROR(ErrorManagement::Debug, "Cannot open the file %s", filename.Buffer());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (numberOfPreProgrammedTimeRows > maxElements) {
|
||||||
|
REPORT_ERROR(ErrorManagement::Warning, "Only %d (out of %d) of pre-programmed values will be written to waveform record.",
|
||||||
|
maxElements, numberOfPreProgrammedTimeRows);
|
||||||
|
}
|
||||||
|
ok = MemoryOperationsHelper::Copy(timeSignal, preProgrammedTime, maxElements * sizeof(int32));
|
||||||
|
uint32 i;
|
||||||
|
for (i = 0u; (i < numberOfPreProgrammedValues) && (ok); ++i) {
|
||||||
|
ok = MemoryOperationsHelper::Copy(valueSignals[i], preProgrammedValues[i], maxElements * sizeof(float32));
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
|
REPORT_ERROR(ErrorManagement::Warning, "Failed to write data to waveform record.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preProgrammedValues != NULL_PTR(float32 **)) {
|
||||||
|
uint32 i;
|
||||||
|
for (i = 0u; i < numberOfPreProgrammedValues; i++) {
|
||||||
|
delete preProgrammedValues[i];
|
||||||
|
}
|
||||||
|
delete[] preProgrammedValues;
|
||||||
|
}
|
||||||
|
if (preProgrammedTime != NULL_PTR(int32 *)) {
|
||||||
|
delete[] preProgrammedTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JAWFRecordGAM::Execute() {
|
||||||
|
if (*loadTriggerSignal == 1u) {
|
||||||
|
if (readOnce) {
|
||||||
|
LoadFile();
|
||||||
|
readOnce = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Reset read once flag when loadTriggerSignal is reset.
|
||||||
|
readOnce = true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLASS_REGISTER(JAWFRecordGAM, "1.0")
|
||||||
130
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JAWFRecordGAM/JAWFRecordGAM.h
Normal file
130
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JAWFRecordGAM/JAWFRecordGAM.h
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
/**
|
||||||
|
* @file JAWFRecordGAM.h
|
||||||
|
* @brief Header file for class JAWFRecordGAM
|
||||||
|
* @date Jan, 2019
|
||||||
|
* @author rhari
|
||||||
|
*
|
||||||
|
* @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 JAWFRecordGAM
|
||||||
|
* 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 GAMS_JAWFRECORDGAM_H_
|
||||||
|
#define GAMS_JAWFRECORDGAM_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Standard header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Project header includes */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "GAM.h"
|
||||||
|
#include "Message.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Class declaration */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GAM that is used for pre-programmed operation.
|
||||||
|
*
|
||||||
|
* The configuration syntax is (names and signal quantity are only given as an example):
|
||||||
|
* <pre>
|
||||||
|
* +WFRecordGAM = {
|
||||||
|
* Class = JAWFRecordGAM
|
||||||
|
* Directory = "../Configurations"
|
||||||
|
* InputSignals = {
|
||||||
|
* CSV_LOAD = {
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* Type = uint32
|
||||||
|
* }
|
||||||
|
* Filename = {
|
||||||
|
* Alias = CSV_NAME
|
||||||
|
* DataSource = EPICSCAInput
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* OutputSignals = {
|
||||||
|
* PREP_TIME_WF = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* }
|
||||||
|
* * MHVPS_PREP_WF = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* }
|
||||||
|
* BPS_PREP_WF = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* }
|
||||||
|
* APS_PREP_WF = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* }
|
||||||
|
* MCPS_PREP_WF = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* }
|
||||||
|
* GCPS_PREP_WF = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* }
|
||||||
|
* FHPS_PREP_WF = {
|
||||||
|
* DataSource = DDB1
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class JAWFRecordGAM : public MARTe::GAM, public MARTe::StatefulI {
|
||||||
|
public:
|
||||||
|
CLASS_REGISTER_DECLARATION()
|
||||||
|
|
||||||
|
JAWFRecordGAM();
|
||||||
|
|
||||||
|
virtual ~JAWFRecordGAM();
|
||||||
|
|
||||||
|
virtual bool Initialise(MARTe::StructuredDataI & data);
|
||||||
|
|
||||||
|
virtual bool Setup();
|
||||||
|
|
||||||
|
virtual bool Execute();
|
||||||
|
|
||||||
|
virtual bool PrepareNextState(const MARTe::char8 * const currentStateName,
|
||||||
|
const MARTe::char8 * const nextStateName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void LoadFile();
|
||||||
|
|
||||||
|
MARTe::uint32 filenameSignalIndex;
|
||||||
|
|
||||||
|
MARTe::uint32 *loadTriggerSignal;
|
||||||
|
|
||||||
|
MARTe::StreamString directory;
|
||||||
|
|
||||||
|
MARTe::float32 **valueSignals;
|
||||||
|
|
||||||
|
MARTe::int32 *timeSignal;
|
||||||
|
|
||||||
|
MARTe::uint32 maxElements;
|
||||||
|
|
||||||
|
// Flag determining whether file should be read (so it isn't read multiple time)
|
||||||
|
bool readOnce;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Inline method definitions */
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* GAMS_JAWFRECORDGAM_H_ */
|
||||||
27
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JAWFRecordGAM/Makefile.gcc
Normal file
27
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JAWFRecordGAM/Makefile.gcc
Normal file
@@ -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
|
||||||
56
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JAWFRecordGAM/Makefile.inc
Normal file
56
EC-GN-JA-PCF-IN/src/main/c++/GAMs/JAWFRecordGAM/Makefile.inc
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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=JAWFRecordGAM.x
|
||||||
|
|
||||||
|
PACKAGE=GAMs
|
||||||
|
|
||||||
|
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
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
||||||
|
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
all: $(OBJS) $(SUBPROJ) \
|
||||||
|
$(BUILD_DIR)/JAWFRecordGAM$(LIBEXT) \
|
||||||
|
$(BUILD_DIR)/JAWFRecordGAM$(DLLEXT)
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
|
|
||||||
28
EC-GN-JA-PCF-IN/src/main/c++/GAMs/Makefile
Normal file
28
EC-GN-JA-PCF-IN/src/main/c++/GAMs/Makefile
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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 $
|
||||||
|
#
|
||||||
|
#############################################################
|
||||||
|
export TARGET=x86-linux
|
||||||
|
|
||||||
|
include Makefile.gcc
|
||||||
26
EC-GN-JA-PCF-IN/src/main/c++/GAMs/Makefile.gcc
Normal file
26
EC-GN-JA-PCF-IN/src/main/c++/GAMs/Makefile.gcc
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
#############################################################
|
||||||
|
|
||||||
|
include Makefile.inc
|
||||||
|
|
||||||
45
EC-GN-JA-PCF-IN/src/main/c++/GAMs/Makefile.inc
Normal file
45
EC-GN-JA-PCF-IN/src/main/c++/GAMs/Makefile.inc
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# 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 $
|
||||||
|
#
|
||||||
|
#############################################################
|
||||||
|
|
||||||
|
SPB = JAMessageGAM.x JAPreProgrammedGAM.x JAModeControlGAM.x \
|
||||||
|
JAWFRecordGAM.x JATriangleWaveGAM.x JARampupGAM.x \
|
||||||
|
JARTStateMachineGAM.x JASDNRTStateMachineGAM.x JATerminalInterfaceGAM.x \
|
||||||
|
JABitSumGAM.x JAConditionalSignalUpdateGAM.x JASourceChoiseGAM.x JABitReverseGAM.x
|
||||||
|
|
||||||
|
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
|
||||||
|
|
||||||
|
ROOT_DIR=../../../obj
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
|
||||||
|
|
||||||
|
all: $(OBJS) $(SUBPROJ) check-env
|
||||||
|
echo $(OBJS)
|
||||||
|
|
||||||
|
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||||
|
|
||||||
|
check-env:
|
||||||
|
ifndef MARTe2_DIR
|
||||||
|
$(error MARTe2_DIR is undefined)
|
||||||
|
endif
|
||||||
639
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/Gyrotron01DAN.cpp
Normal file
639
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/Gyrotron01DAN.cpp
Normal file
@@ -0,0 +1,639 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* $HeadURL: https://svnpub.iter.org/codac/iter/codac/dev/units/m-codac-unit-templates/tags/CODAC-CORE-6.0.0/templates/cpp-sdn/main/c++/prog/prog.cpp.template $
|
||||||
|
* $Id: prog.cpp.template 83098 2018-01-08 13:23:38Z cesnikt $
|
||||||
|
*
|
||||||
|
* Project : CODAC Core System
|
||||||
|
*
|
||||||
|
* Description : GyrotronDAN program
|
||||||
|
*
|
||||||
|
* Author : codac-dev
|
||||||
|
*
|
||||||
|
* Copyright (c) : 2010-2018 ITER Organization,
|
||||||
|
* CS 90 046
|
||||||
|
* 13067 St. Paul-lez-Durance Cedex
|
||||||
|
* France
|
||||||
|
*
|
||||||
|
* This file is part of ITER CODAC software.
|
||||||
|
* For the terms and conditions of redistribution or use of this software
|
||||||
|
* refer to the file ITER-LICENSE.TXT located in the top level directory
|
||||||
|
* of the distribution package.
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
/* header files */
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <error.h>
|
||||||
|
//#include <xseries-lib.h>
|
||||||
|
#define float32_t float32_t1
|
||||||
|
#include <xseries-lib.h>
|
||||||
|
#undef float32_t
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <dan.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <ca-if.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <tcn.h>
|
||||||
|
|
||||||
|
#include <log.h>
|
||||||
|
|
||||||
|
// global variables
|
||||||
|
static bool __terminate = false;
|
||||||
|
char pxie6368_0_ai_fd[] = "/dev/pxie-6368.0.ai"; // ai segment
|
||||||
|
char pxie6368_0_device[] = "/dev/pxie-6368.0"; // device descriptor
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int daq_smpl_rate;
|
||||||
|
int daq_mode;
|
||||||
|
double daq_smpl_st_dly;
|
||||||
|
double daq_len;
|
||||||
|
double daq_pub_dly;
|
||||||
|
} daq_parameters;
|
||||||
|
|
||||||
|
void signal_handler(int signal) {
|
||||||
|
log_info("Received signal '%d' to terminate", signal);
|
||||||
|
__terminate = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// DAN parameter reload function ------------------------------------------------
|
||||||
|
int reload_daq_conf(int *aifd, int *ai_chan_fd, daq_parameters *daq_p) {
|
||||||
|
std::cout << "reload_daq_conf was called \n";
|
||||||
|
|
||||||
|
// Common variables
|
||||||
|
int retval;
|
||||||
|
unsigned long number_of_samples;
|
||||||
|
int chan_num = 10; // Channel number to add.
|
||||||
|
uint32_t sample_period_divisor;
|
||||||
|
uint32_t base_clock = 100000000; // TB3:100MHz, TB2:100 kHz
|
||||||
|
uint32_t pre_samples = 1000;
|
||||||
|
uint32_t post_samples = 1000;
|
||||||
|
char str[40];
|
||||||
|
xseries_ai_conf_t conf; // ai segment configuraton data
|
||||||
|
|
||||||
|
// calculate sampling period divisor
|
||||||
|
if (daq_p->daq_smpl_rate != 0) {
|
||||||
|
sample_period_divisor = base_clock / daq_p->daq_smpl_rate;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop ai segment----------------------------------------------------------------------
|
||||||
|
retval = xseries_stop_ai(*aifd);
|
||||||
|
if (retval) {
|
||||||
|
log_error("ai segment stop failed.\n");
|
||||||
|
} else {
|
||||||
|
log_info("ai segment stopped.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// reset ai segment---------------------------------------------------------------------
|
||||||
|
retval = xseries_reset_ai(*aifd);
|
||||||
|
if (retval) {
|
||||||
|
log_error("ai segment reset failed.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure AI segment mode ------------------------------------------------------------
|
||||||
|
switch (daq_p->daq_mode) {
|
||||||
|
case 0:
|
||||||
|
conf = xseries_software_timed_ai();
|
||||||
|
log_info("software_timed mode.\n");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
conf = xseries_finite_ai(number_of_samples);
|
||||||
|
log_info("finite mode.\n");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
conf = xseries_retriggerable_finite_ai(number_of_samples);
|
||||||
|
log_info("retriggerable_finite mode.\n");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
conf = xseries_continuous_ai();
|
||||||
|
log_info("continuous mode.\n");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
conf = xseries_reference_ai(pre_samples, post_samples);
|
||||||
|
log_info("reference mode.\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// disable external gate
|
||||||
|
retval = xseries_set_ai_external_gate(&conf,
|
||||||
|
XSERIES_AI_EXTERNAL_GATE_DISABLED, // No external pause signal
|
||||||
|
XSERIES_AI_POLARITY_ACTIVE_LOW_OR_FALLING_EDGE); // Don't care
|
||||||
|
if (retval) {
|
||||||
|
log_error("Cannot set gate trigger.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// select start trigger (START1 signal)
|
||||||
|
retval = xseries_set_ai_start_trigger(&conf,
|
||||||
|
XSERIES_AI_START_TRIGGER_SW_PULSE, // Set the line to software-driven
|
||||||
|
XSERIES_AI_POLARITY_ACTIVE_HIGH_OR_RISING_EDGE, // Make line active on rising...
|
||||||
|
1); // ... edge (not high level)
|
||||||
|
if (retval) {
|
||||||
|
log_error("Cannot set start trigger.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set sampling clock source----------------------------------------------------------------------------------------
|
||||||
|
retval = xseries_set_ai_sample_clock(&conf,
|
||||||
|
XSERIES_AI_SAMPLE_CONVERT_CLOCK_INTERNALTIMING,
|
||||||
|
XSERIES_AI_POLARITY_ACTIVE_HIGH_OR_RISING_EDGE, 1);
|
||||||
|
if (retval) {
|
||||||
|
log_error("Cannot configure sampling clock.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set scan interval -------------------------------------------------------------------------------------------------------------------------
|
||||||
|
retval = xseries_set_ai_scan_interval_counter(&conf,
|
||||||
|
XSERIES_SCAN_INTERVAL_COUNTER_TB3, // TB3 : 100MHz base clock, TB2 : 100kHz base clock
|
||||||
|
XSERIES_SCAN_INTERVAL_COUNTER_POLARITY_RISING_EDGE,
|
||||||
|
sample_period_divisor, 2); // Wait 2*100MHz sec after sampling trig.
|
||||||
|
if (retval) {
|
||||||
|
log_error("Cannot configure scan counter.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set DMA buffer size-----------------------------------------------------------------------------------------------------------------------
|
||||||
|
retval = xseries_set_ai_attribute(&conf, XSERIES_AI_DMA_BUFFER_SIZE, 1000);
|
||||||
|
if (retval) {
|
||||||
|
log_error("DMA configuration was failed.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add AI channels ---------------------------------------------------------------------------------------------------------------------------
|
||||||
|
for (int i = 0; i < chan_num; i++) {
|
||||||
|
retval = xseries_add_ai_channel(&conf, i, XSERIES_INPUT_RANGE_10V,
|
||||||
|
XSERIES_AI_CHANNEL_TYPE_DIFFERENTIAL, 0);
|
||||||
|
if (retval) {
|
||||||
|
log_error("Add AI channel %d was failed.\n", i);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sleep(3);
|
||||||
|
|
||||||
|
// Load configuration.-----------------------------------------------------------------------------------------------------------------------
|
||||||
|
retval = xseries_load_ai_conf(*aifd, conf);
|
||||||
|
if (retval) {
|
||||||
|
log_error("xseries_load_ai_conf was failed. error code: %d \n", retval);
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
sleep(3);
|
||||||
|
|
||||||
|
// Open channels--------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
for (int i = 0; i < chan_num; i++) {
|
||||||
|
sprintf(str, "%s.ai.%u", pxie6368_0_device, i);
|
||||||
|
//ai_chan_fd[i] = open(str, O_RDWR | O_NONBLOCK);
|
||||||
|
ai_chan_fd[i] = open(str, O_RDWR);
|
||||||
|
if (ai_chan_fd[i] < 0) {
|
||||||
|
log_error("Cannot open ai channel %d .\n",i);
|
||||||
|
sleep(1);
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// start ai segment task-----------------------------------------------------------------------------------------------------------------------
|
||||||
|
retval = xseries_start_ai(*aifd);
|
||||||
|
if (retval) {
|
||||||
|
log_error("ERROR, starting AI segment failed: %s\n", strerror(retval));
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
log_info("PXIe-6368 configuration was finished.\n");
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
using namespace std;
|
||||||
|
unsigned long n_sample_quotient = 0;
|
||||||
|
|
||||||
|
log_initialize(NULL);
|
||||||
|
|
||||||
|
while (!__terminate) {
|
||||||
|
// Install signal handler to support graceful termination
|
||||||
|
sigset(SIGTERM, signal_handler);
|
||||||
|
sigset(SIGINT, signal_handler);
|
||||||
|
sigset(SIGHUP, signal_handler);
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
|
// Running parameter declaration
|
||||||
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
|
// pxie6368 hardware parameters
|
||||||
|
int pxie6368_0_device_number = 0; // device discriptor number
|
||||||
|
int aifd = 0; // ai segment file discriptor
|
||||||
|
xseries_ai_conf_t conf; // ai segment config
|
||||||
|
xseries_ai_attribute_t aiatrb; // ai segment attributes
|
||||||
|
char str[40]; // fd tmp var
|
||||||
|
int ai_chan_fd[16]; // ai channels file discriptor
|
||||||
|
int pxie6368_sampling_rate = 1000; // sampling rate Hz
|
||||||
|
uint32_t sample_period_divisor = 100000000 / pxie6368_sampling_rate; // TB3 100MHz, TB2:100kHz, TB1:20MHz
|
||||||
|
int sampleSize = 2; // Sample size in bytes <---> uInt16
|
||||||
|
int n_channels; // Number of opened channels
|
||||||
|
struct xseries_dma *dma; // Ptr to dma struct
|
||||||
|
int chan_num = 10; // Channel number to add.
|
||||||
|
|
||||||
|
// DAN parameters
|
||||||
|
char dan_source_name[] = "GYADanSource"; // DAN data source (ds) name
|
||||||
|
long offset_ai = 0; // offset size in published data
|
||||||
|
int dma_mode = 1; // 0:All, 1:AI only, 2:AO only
|
||||||
|
dan_DataCore dc = NULL; // Datacore reference declaration
|
||||||
|
dan_Source ds = NULL; // DAN source declaration
|
||||||
|
long samplesCounter = 0; // Total acquired sample size
|
||||||
|
size_t n_samples; // prepared sample size to publish
|
||||||
|
|
||||||
|
// TCN parameters
|
||||||
|
uint64_t tBase_old = 0;
|
||||||
|
uint64_t tBase = 0; // TCN publishing base time
|
||||||
|
uint64_t nanos; // time length for sampling
|
||||||
|
hpn_timestamp_t delay = 1e7; // wait for publishing (10ms)
|
||||||
|
char buf[ISO_8601_LEN];
|
||||||
|
uint64_t tBase0 = 0;
|
||||||
|
|
||||||
|
// Operation tmp parameter
|
||||||
|
int result; // For result values.
|
||||||
|
int exValue;
|
||||||
|
bool toterminate = false;
|
||||||
|
int retval;
|
||||||
|
bool daq_start = false;
|
||||||
|
int testcounter = 10000;
|
||||||
|
|
||||||
|
// Connected EPCIS PV
|
||||||
|
|
||||||
|
// DAQ config PVs
|
||||||
|
chid daq_smpl_rate_id;
|
||||||
|
chtype daq_smpl_rate_type;
|
||||||
|
int daq_smpl_rate;
|
||||||
|
chid daq_smpl_rate_rb_id;
|
||||||
|
chtype daq_smpl_rate_rb_type;
|
||||||
|
int daq_smpl_rate_rb;
|
||||||
|
chid daq_mode_id;
|
||||||
|
chtype daq_mode_type;
|
||||||
|
int daq_mode;
|
||||||
|
chid daq_mode_rb_id;
|
||||||
|
chtype daq_mode_rb_type;
|
||||||
|
int daq_mode_rb;
|
||||||
|
chid daq_sw_trig_id;
|
||||||
|
chtype daq_sw_trig_type;
|
||||||
|
int daq_sw_trig;
|
||||||
|
chid daq_smpl_st_dly_id;
|
||||||
|
chtype daq_smpl_st_dly_type;
|
||||||
|
double daq_smpl_st_dly;
|
||||||
|
chid daq_smpl_st_dly_rb_id;
|
||||||
|
chtype daq_smpl_st_dly_rb_type;
|
||||||
|
double daq_smpl_st_dly_rb;
|
||||||
|
chid daq_len_id;
|
||||||
|
chtype daq_len_type;
|
||||||
|
double daq_len;
|
||||||
|
chid daq_len_rb_id;
|
||||||
|
chtype daq_len_rb_type;
|
||||||
|
double daq_len_rb;
|
||||||
|
chid daq_reconf_id;
|
||||||
|
chtype daq_reconf_type;
|
||||||
|
int daq_reconf;
|
||||||
|
chid daq_pub_dly_id;
|
||||||
|
chtype daq_pub_dly_type;
|
||||||
|
double daq_pub_dly;
|
||||||
|
chid daq_pub_dly_rb_id;
|
||||||
|
chtype daq_pub_dly_rb_type;
|
||||||
|
double daq_pub_dly_rb;
|
||||||
|
|
||||||
|
chid daq_stat_id;
|
||||||
|
chtype daq_stat_type;
|
||||||
|
int daq_stat;
|
||||||
|
chid daq_conf_stat_id;
|
||||||
|
chtype daq_conf_stat_type;
|
||||||
|
int daq_conf_stat;
|
||||||
|
|
||||||
|
daq_parameters daq_p = { 0 }; // = {daq_smpl_rate, daq_smpl_rate_rb, daq_mode, daq_mode_rb};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
// EPICS PV connection
|
||||||
|
// ----------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//Initialize ChannelAccess interface
|
||||||
|
CAInterface_Initialize();
|
||||||
|
|
||||||
|
// Connect to EPICS PVs
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-SMPL-RATE", daq_smpl_rate_id);
|
||||||
|
daq_smpl_rate_type = DBR_LONG;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-SMPL-RATE-RB", daq_smpl_rate_rb_id);
|
||||||
|
daq_smpl_rate_rb_type = DBR_LONG;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-MODE", daq_mode_id);
|
||||||
|
daq_mode_type = DBR_ENUM;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-MODE-RB", daq_mode_rb_id);
|
||||||
|
daq_mode_rb_type = DBR_ENUM;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-SW-TRIG", daq_sw_trig_id);
|
||||||
|
daq_sw_trig_type = DBR_ENUM;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-SMPL-ST-DLY", daq_smpl_st_dly_id);
|
||||||
|
daq_smpl_st_dly_type = DBR_DOUBLE;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-SMPL-ST-DLY-RB", daq_smpl_st_dly_rb_id);
|
||||||
|
daq_smpl_st_dly_rb_type = DBR_DOUBLE;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-LEN", daq_len_id);
|
||||||
|
daq_len_type = DBR_DOUBLE;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-LEN-RB", daq_len_rb_id);
|
||||||
|
daq_len_rb_type = DBR_DOUBLE;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-RECONF", daq_reconf_id);
|
||||||
|
daq_reconf_type = DBR_ENUM;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-PUB-DLY", daq_pub_dly_id);
|
||||||
|
daq_pub_dly_type = DBR_DOUBLE;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-PUB-DLY-RB", daq_pub_dly_rb_id);
|
||||||
|
daq_pub_dly_rb_type = DBR_DOUBLE;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-STAT", daq_stat_id);
|
||||||
|
daq_stat_type = DBR_ENUM;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-CONF-STAT", daq_conf_stat_id);
|
||||||
|
daq_conf_stat_type = DBR_ENUM;
|
||||||
|
|
||||||
|
tcn_sleep(3e9);// Wait for a while.
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
|
// Initialize tcn library
|
||||||
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
|
int tcn_err;
|
||||||
|
tcn_err = tcn_init();
|
||||||
|
if (tcn_err != TCN_SUCCESS) {
|
||||||
|
log_error("TCN Initialization failed.\n");
|
||||||
|
exValue = 1;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
|
// pxie-6368 settings
|
||||||
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
|
// Open ai segment----------------------------------------------------------------------
|
||||||
|
aifd = open(pxie6368_0_ai_fd, O_RDWR);
|
||||||
|
if (aifd <= 0) {
|
||||||
|
log_error("Open PXIe6368 AI fd failed.\n");
|
||||||
|
exValue = -1;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait ai segment setup start
|
||||||
|
do {
|
||||||
|
CAInterface_ReadVariable(daq_reconf_id, daq_reconf_type, (void*) &daq_reconf);
|
||||||
|
} while (!daq_reconf and !__terminate);
|
||||||
|
|
||||||
|
// read parameter
|
||||||
|
result = CAInterface_ReadVariable(daq_smpl_rate_id, daq_smpl_rate_type, (void *) &daq_p.daq_smpl_rate);
|
||||||
|
if (!result) {
|
||||||
|
log_error("CA_READ failed.\n");
|
||||||
|
}
|
||||||
|
// read parameter
|
||||||
|
result = CAInterface_ReadVariable(daq_mode_id, daq_mode_type, (void *) &daq_p.daq_mode);
|
||||||
|
if (!result) {
|
||||||
|
log_error("CA_READ failed.\n");
|
||||||
|
}
|
||||||
|
// read parameter
|
||||||
|
result = CAInterface_ReadVariable(daq_smpl_st_dly_id, daq_smpl_st_dly_type, (void *) &daq_p.daq_smpl_st_dly);
|
||||||
|
if (!result) {
|
||||||
|
log_error("CA_READ failed.\n");
|
||||||
|
}
|
||||||
|
// read parameter
|
||||||
|
result = CAInterface_ReadVariable(daq_len_id, daq_len_type, (void *) &daq_p.daq_len);
|
||||||
|
if (!result) {
|
||||||
|
log_error("CA_READ failed.\n");
|
||||||
|
}
|
||||||
|
// read parameter
|
||||||
|
result = CAInterface_ReadVariable(daq_pub_dly_id, daq_pub_dly_type, (void *) &daq_p.daq_pub_dly);
|
||||||
|
if (!result) {
|
||||||
|
log_error("CA_READ failed.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "SAMPLE RATE:" << daq_p.daq_smpl_rate << endl;
|
||||||
|
std::cout << "MODE :" << daq_p.daq_mode << endl;
|
||||||
|
std::cout << "START DELAY:" <<daq_p.daq_smpl_st_dly << endl;
|
||||||
|
std::cout << "DAQ LENGTH:" << daq_p.daq_len << endl;
|
||||||
|
std::cout << "PUB DELAY :" << daq_p.daq_pub_dly << endl;
|
||||||
|
|
||||||
|
// Configure ai segment and dan parameter by using EPICS PV.
|
||||||
|
result = reload_daq_conf(&aifd, ai_chan_fd, &daq_p);
|
||||||
|
if (result < 0) {
|
||||||
|
log_error("Load DAQ CONF failed.\n");
|
||||||
|
daq_stat = 3; // 0:Not ready, 1:Waiting trigger, 2:Aquiring, 3:Error
|
||||||
|
CAInterface_WriteVariable(daq_stat_id, daq_stat_type, &daq_stat);
|
||||||
|
daq_conf_stat = 0; // 0:Not Ready, 1: Ready
|
||||||
|
CAInterface_WriteVariable(daq_conf_stat_id, daq_conf_stat_type, &daq_conf_stat);
|
||||||
|
goto END;
|
||||||
|
} else {
|
||||||
|
// All parameters were configured correctly, update readback PV
|
||||||
|
CAInterface_WriteVariable(daq_smpl_rate_rb_id, daq_smpl_rate_rb_type, &daq_p.daq_smpl_rate);
|
||||||
|
CAInterface_WriteVariable(daq_mode_rb_id, daq_mode_rb_type, &daq_p.daq_mode);
|
||||||
|
CAInterface_WriteVariable(daq_smpl_st_dly_rb_id, daq_smpl_st_dly_rb_type, &daq_p.daq_smpl_st_dly);
|
||||||
|
CAInterface_WriteVariable(daq_len_rb_id, daq_len_rb_type, &daq_p.daq_len);
|
||||||
|
CAInterface_WriteVariable(daq_pub_dly_rb_id, daq_pub_dly_rb_type, &daq_p.daq_pub_dly);
|
||||||
|
daq_conf_stat = 1;
|
||||||
|
CAInterface_WriteVariable(daq_conf_stat_id, daq_conf_stat_type, &daq_conf_stat);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------
|
||||||
|
// ----- DAN Publisher.
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------
|
||||||
|
// Initialize DAN DataCore
|
||||||
|
dc = dan_initLibrary();
|
||||||
|
if (dc == NULL) {
|
||||||
|
log_error("dan_init failed.\n");
|
||||||
|
exValue = 1;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----- DMA initialization
|
||||||
|
dma = xseries_dma_init(pxie6368_0_device_number, 1); // (devid, dma_mode) mode 0:mapping all dma mem, 1:AI only.
|
||||||
|
if (dma == NULL) {
|
||||||
|
cout << "Failed to connect to samples buffer.\n go to END.\n";
|
||||||
|
exValue = -1;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push a new data block into source.
|
||||||
|
ds = dan_publisher_publishSource(dc, dan_source_name, pxie6368_0_device,
|
||||||
|
DAN_DAQ_MMAP, dma->ai.count * sampleSize, 4096);
|
||||||
|
|
||||||
|
//dan_DataCore, ds_name, devName, enum_daq_type refType, long refSize, long refOffset
|
||||||
|
if (ds == NULL) {
|
||||||
|
log_error("Error while publishing DAN source %s ", dan_source_name);
|
||||||
|
exValue = 1;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
n_channels = dan_publisher_getNumberOfChannels(ds);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------
|
||||||
|
// ----- DAN Streamer.
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------
|
||||||
|
// ----- Open a new stream ---------------------------------------------------------------------
|
||||||
|
dan_publisher_openStream(ds, daq_p.daq_smpl_rate, 0);
|
||||||
|
sleep(1);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------
|
||||||
|
// ----- Main DAN Loop.
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------
|
||||||
|
while (!__terminate) {
|
||||||
|
// Wait for the master trigger.----------------------------------------------------------------------------
|
||||||
|
daq_stat = 1; //0:Not Ready, 1: Waiting trigger, 2:Acquiring 3:Error
|
||||||
|
CAInterface_WriteVariable(daq_stat_id, daq_stat_type, &daq_stat);
|
||||||
|
daq_conf_stat = 1; //0:Not ready, 1: Ready
|
||||||
|
CAInterface_WriteVariable(daq_conf_stat_id, daq_conf_stat_type, &daq_conf_stat);
|
||||||
|
|
||||||
|
// Wait DAQ Start Software Trigger.
|
||||||
|
do {
|
||||||
|
// check daq_sw_trigger to start DAQ sequence.
|
||||||
|
CAInterface_ReadVariable(daq_sw_trig_id, daq_sw_trig_type, (void*) &daq_sw_trig);
|
||||||
|
tcn_sleep(1e7); // wait 0.01 s
|
||||||
|
if (daq_sw_trig) {
|
||||||
|
daq_start = true;
|
||||||
|
}
|
||||||
|
} while (daq_start != true and !__terminate);
|
||||||
|
|
||||||
|
daq_start = false; //reset daq_start flag.
|
||||||
|
delay = (long) (1e6 * daq_p.daq_pub_dly); //check publish period.
|
||||||
|
|
||||||
|
// Wait a time to start DAQ. ----------------------------------------------------------------------------------------------------------------------
|
||||||
|
tcn_sleep(daq_p.daq_smpl_st_dly * 1e6); // in ms
|
||||||
|
|
||||||
|
// After the wating, trigger DAQ ------------------------------------------------------------------------------------------------------------------
|
||||||
|
retval = xseries_pulse_ai(aifd, XSERIES_START_TRIGGER);
|
||||||
|
daq_stat = 2;
|
||||||
|
CAInterface_WriteVariable(daq_stat_id, daq_stat_type, &daq_stat);
|
||||||
|
if (retval) {
|
||||||
|
std::cout << "Cannot generate start trigger!\n";
|
||||||
|
goto END;
|
||||||
|
} else {
|
||||||
|
tcn_get_time(&tBase); // get DAQ start time.
|
||||||
|
tBase0 = tBase; // save DAQ start time to tBase0;
|
||||||
|
tBase_old = tBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DAQ Publish Loop. ----------------------------------------------------------------------------------------------------------------------------
|
||||||
|
// DAN data publish is executed every delay time interval.
|
||||||
|
while (!__terminate && (tcn_wait_until_hr((tBase + delay), &tBase, 0) == TCN_SUCCESS)) {
|
||||||
|
// Get the number of available samples in PXIe6368 buffer.
|
||||||
|
n_samples = xsereis_ai_dma_samples_in_buffer(dma); // samples
|
||||||
|
|
||||||
|
if (n_samples > dma->ai.count) {
|
||||||
|
//log_error("DMA Buffer overflow: Number of new samples in buffer = %ld, AI buffer size = %ld,\n", n_samples, dma->ai.count);
|
||||||
|
} else if (n_samples > 0) {
|
||||||
|
//log_info("Current Time:\n%s\n", tcn_strftime(tBase, buf, ISO_8601_LEN));
|
||||||
|
if (tBase == 0) {
|
||||||
|
// "tBase was reset.------------------------------------------------------\n";
|
||||||
|
tcn_get_time(&tBase);
|
||||||
|
tBase -= n_samples * 100000000 / pxie6368_sampling_rate;
|
||||||
|
nanos = 0;
|
||||||
|
} else {
|
||||||
|
// update time offset value.
|
||||||
|
nanos = n_samples * 100000000 / daq_p.daq_smpl_rate;
|
||||||
|
}
|
||||||
|
n_sample_quotient = floor(n_samples / chan_num);
|
||||||
|
n_samples = n_sample_quotient * chan_num;
|
||||||
|
|
||||||
|
// Publish a new data block --------------------------------------------------------------------------------------------------------------------------
|
||||||
|
result = dan_publisher_putBlockReference(ds,
|
||||||
|
tBase_old + nanos, // timestamp in epoch nanoseconds
|
||||||
|
n_samples * sampleSize, // datablock size in bytes
|
||||||
|
offset_ai * sampleSize, // Offset in DAQ buffer
|
||||||
|
NULL); // No datablock header....
|
||||||
|
// Detected overflow in pass datablock reference queue
|
||||||
|
if (result == -1) {
|
||||||
|
log_info("%s, Queue overflow with policy %d\n", dan_source_name, dan_publisher_getCheckPolicy(ds));
|
||||||
|
} else if (result == -2) {
|
||||||
|
log_info("%s, DAQ buffer overflow with policy %d\n", dan_source_name, dan_publisher_getCheckPolicy(ds));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
samplesCounter += n_samples; // Increment total of published sampes
|
||||||
|
offset_ai = (offset_ai + n_samples) % dma->ai.count; // Update offset of memory
|
||||||
|
dma->ai.last_transfer_count = samplesCounter; // Update dma last_transfer_count
|
||||||
|
|
||||||
|
// Check exit condition.
|
||||||
|
if ((daq_p.daq_len * 1e6 <= (tBase - tBase0))) {
|
||||||
|
retval = xseries_stop_ai(aifd);
|
||||||
|
if (retval) {
|
||||||
|
std::cout << "Stop AI segment failed.\n";
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
//restart ai segment.
|
||||||
|
tcn_sleep(1e9); // wait
|
||||||
|
retval = xseries_start_ai(aifd);
|
||||||
|
if (retval) {
|
||||||
|
std::cout << "Start AI segment failed.\n";
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
//debug
|
||||||
|
tcn_sleep(1e8);
|
||||||
|
n_samples = xsereis_ai_dma_samples_in_buffer(dma);
|
||||||
|
cout << "n_samples check : " << n_samples << endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tBase_old = tBase;
|
||||||
|
} // End of DAQ publish loop.
|
||||||
|
break;
|
||||||
|
} // End of DAN main loop.
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------
|
||||||
|
// ----- Closing program.
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------
|
||||||
|
log_info("DAN end of acquisition, closing all resources");
|
||||||
|
|
||||||
|
//Closing stream
|
||||||
|
dan_publisher_closeStream(ds);
|
||||||
|
exValue = 0;
|
||||||
|
|
||||||
|
// Close all channels
|
||||||
|
for (int channel = 0; channel < chan_num; channel++) {
|
||||||
|
close(ai_chan_fd[channel]);
|
||||||
|
}
|
||||||
|
goto END;
|
||||||
|
|
||||||
|
END: daq_conf_stat = 0;
|
||||||
|
CAInterface_WriteVariable(daq_conf_stat_id, daq_conf_stat_type, &daq_conf_stat);
|
||||||
|
daq_stat = 0;
|
||||||
|
CAInterface_WriteVariable(daq_stat_id, daq_stat_type, &daq_stat);
|
||||||
|
// Destroy CA context
|
||||||
|
CAInterface_Finalize();
|
||||||
|
// Close pxie6368
|
||||||
|
if (dma != NULL) {
|
||||||
|
xseries_dma_close(dma);
|
||||||
|
cout << "pxie-6368 dma was clesed.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
close(aifd);
|
||||||
|
|
||||||
|
// Unpublishing source from DAN API
|
||||||
|
if (ds != NULL) {
|
||||||
|
dan_publisher_unpublishSource(dc, ds);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Closing DAN API library
|
||||||
|
if (dc != NULL) {
|
||||||
|
dan_closeLibrary(dc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Closing TCN library
|
||||||
|
result = tcn_finalize();
|
||||||
|
if (result != TCN_SUCCESS) {
|
||||||
|
//log_error("Error finalizing TCN lib.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
} // loop end from initialization
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
}
|
||||||
68
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/Makefile
Normal file
68
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/Makefile
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
#+======================================================================
|
||||||
|
# $HeadURL: https://svnpub.iter.org/codac/iter/codac/dev/units/m-codac-unit-templates/tags/CODAC-CORE-6.0.0/templates/cpp/main/c++/prog/Makefile.template $
|
||||||
|
# $Id: Makefile.template 83098 2018-01-08 13:23:38Z cesnikt $
|
||||||
|
#
|
||||||
|
# Project : CODAC Core System
|
||||||
|
#
|
||||||
|
# Description : gyrotronDAN Makefile
|
||||||
|
#
|
||||||
|
# Author : This file was generated by CODAC development toolkit
|
||||||
|
#
|
||||||
|
# Copyright (c) : 2010-2018 ITER Organization,
|
||||||
|
# CS 90 046
|
||||||
|
# 13067 St. Paul-lez-Durance Cedex
|
||||||
|
# France
|
||||||
|
#
|
||||||
|
# This file is part of ITER CODAC software.
|
||||||
|
# For the terms and conditions of redistribution or use of this software
|
||||||
|
# refer to the file ITER-LICENSE.TXT located in the top level directory
|
||||||
|
# of the distribution package.
|
||||||
|
#
|
||||||
|
#-======================================================================
|
||||||
|
|
||||||
|
PROGNAME=Gyrotron01DAN
|
||||||
|
|
||||||
|
LIBRARIES=ca dan_api dan_client_api dan_stream dan_base xml2 log sdn sdn-core ccs-core rt pthread tcn nixseries
|
||||||
|
LIBRARY_DIRS=
|
||||||
|
INCLUDE_DIRS=. ../include $(CODAC_ROOT)/include $(EPICS_BASE)/include/os/Linux $(EPICS_BASE)/include/compiler/gcc $(EPICS_BASE)/include /usr/include/libxml2 $(SDN_TOPIC_DIRECTORY)
|
||||||
|
|
||||||
|
TARGET=../../../../target
|
||||||
|
BINARY_DIR=$(TARGET)/bin
|
||||||
|
OBJECT_DIR=$(TARGET)/obj/$(PROGNAME)
|
||||||
|
SOURCE_DIR=.
|
||||||
|
|
||||||
|
EXECUTABLE=$(BINARY_DIR)/$(PROGNAME)
|
||||||
|
INCLUDES=$(foreach inc,$(INCLUDE_DIRS),-I$(inc))
|
||||||
|
LDLIBS=-L$(CODAC_ROOT)/lib -L$(EPICS_BASE)/lib/$(EPICS_HOST_ARCH) $(foreach libs,$(LIBRARY_DIRS),-L$(libs) -Wl,-rpath,$(libs)) $(foreach libs,$(LIBRARIES),-l$(libs))
|
||||||
|
SOURCES=$(SOURCE_DIR)/$(PROGNAME).cpp $(SOURCE_DIR)/configure_sdn.cpp
|
||||||
|
# to build executable from all sources in the program directory:
|
||||||
|
#SOURCES=$(wildcard $(SOURCE_DIR)/*.cpp $(SOURCE_DIR)/*.c)
|
||||||
|
OBJECTS=$(addprefix $(OBJECT_DIR)/,$(patsubst %.cpp,%.o,$(notdir $(SOURCES))))
|
||||||
|
|
||||||
|
C=gcc
|
||||||
|
CC=g++
|
||||||
|
CFLAGS=-c -Wall
|
||||||
|
CCFLAGS=-c -Wall -std=c++11
|
||||||
|
LDFLAGS=
|
||||||
|
|
||||||
|
.PHONY: all clean run
|
||||||
|
|
||||||
|
all: $(SOURCES) $(EXECUTABLE)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf "$(EXECUTABLE)" "$(OBJECT_DIR)"
|
||||||
|
|
||||||
|
run: $(SOURCES) $(EXECUTABLE)
|
||||||
|
$(EXECUTABLE)
|
||||||
|
|
||||||
|
$(EXECUTABLE): $(OBJECTS)
|
||||||
|
mkdir -p $(BINARY_DIR)
|
||||||
|
$(CC) $(LDFLAGS) $(LDLIBS) $(OBJECTS) -o $@
|
||||||
|
|
||||||
|
$(OBJECT_DIR)/%.o: $(SOURCE_DIR)/%.cpp
|
||||||
|
mkdir -p $(OBJECT_DIR)
|
||||||
|
$(CC) $(CCFLAGS) $(INCLUDES) $< -o $@
|
||||||
|
|
||||||
|
$(OBJECT_DIR)/%.o: $(SOURCE_DIR)/%.c
|
||||||
|
mkdir -p $(OBJECT_DIR)
|
||||||
|
$(C) $(CFLAGS) $(INCLUDES) $< -o $@
|
||||||
165
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/ca-if.h
Normal file
165
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/ca-if.h
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
#ifndef CA_IF_H
|
||||||
|
#define CA_IF_H
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* $HeadURL: https://svnpub.iter.org/codac/iter/codac/dev/units/m-log-lib/trunk/src/main/c++/include/tools/any-type.h $
|
||||||
|
* $Id: any-type.h 50547 2014-10-09 12:09:51Z bauvirb $
|
||||||
|
*
|
||||||
|
* Project : CODAC Core System
|
||||||
|
*
|
||||||
|
* Description : Channel Access Interface
|
||||||
|
*
|
||||||
|
* Author : Bertrand Bauvir
|
||||||
|
*
|
||||||
|
* Copyright (c) : 2010-2014 ITER Organization,
|
||||||
|
* CS 90 046
|
||||||
|
* 13067 St. Paul-lez-Durance Cedex
|
||||||
|
* France
|
||||||
|
*
|
||||||
|
* This file is part of ITER CODAC software.
|
||||||
|
* For the terms and conditions of redistribution or use of this software
|
||||||
|
* refer to the file ITER-LICENSE.TXT located in the top level directory
|
||||||
|
* of the distribution package.
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
/* Global header files */
|
||||||
|
#include <iostream>
|
||||||
|
#include <cadef.h> /* Channel Access API definition, etc. */
|
||||||
|
//#include <log.h> /* CCS logging library */
|
||||||
|
|
||||||
|
/* Local header files */
|
||||||
|
|
||||||
|
/* Constants */
|
||||||
|
|
||||||
|
#ifndef log_trace
|
||||||
|
#define log_trace(arg_msg...) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef log_error
|
||||||
|
#define log_error(arg_msg...){}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Type definition */
|
||||||
|
|
||||||
|
/* Global variables */
|
||||||
|
|
||||||
|
/* Public function declaration */
|
||||||
|
|
||||||
|
static inline bool CAInterface_Initialize(void) {
|
||||||
|
bool status = false;
|
||||||
|
ca_context_create (ca_disable_preemptive_callback); //Default
|
||||||
|
//ca_context_create(ca_enable_preemptive_callback);
|
||||||
|
status = true;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline bool CAInterface_Finalize(void) {
|
||||||
|
bool status = false;
|
||||||
|
ca_context_destroy();
|
||||||
|
status = true;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline bool CAInterface_ConnectVariable(char* name, chid& id) {
|
||||||
|
bool status = false;
|
||||||
|
/* Connect to channels */
|
||||||
|
if (ca_create_channel(name, NULL, NULL, 10, &id) != ECA_NORMAL) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait for connections */
|
||||||
|
if (ca_pend_io(1) != ECA_NORMAL) {
|
||||||
|
log_error("%s - ca_pend_io failed", __FUNCTION__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Verify channel */
|
||||||
|
if (ca_state(id) != cs_conn) {
|
||||||
|
//log_warning("Connection to channel '%s' has not been successful", name);
|
||||||
|
} else {
|
||||||
|
//log_info("Connection to channel '%s' has been successfully verified", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
status = true;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline bool CAInterface_ReadVariable(chid channel, chtype type,
|
||||||
|
void* p_value) {
|
||||||
|
bool status = false;
|
||||||
|
if (ca_state(channel) != cs_conn) {
|
||||||
|
//log_error("%s - Connection to channel has been lost");
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ca_get(type, channel, p_value) != ECA_NORMAL) {
|
||||||
|
//log_error("%s - ca_get failed", __FUNCTION__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Flush the requests */
|
||||||
|
if (ca_pend_io(1) != ECA_NORMAL) {
|
||||||
|
//log_error("%s - ca_pend_io failed", __FUNCTION__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = true;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline bool CAInterface_WriteVariable(chid channel, chtype type,
|
||||||
|
void* p_value) {
|
||||||
|
bool status = false;
|
||||||
|
|
||||||
|
if (ca_state(channel) != cs_conn) {
|
||||||
|
//log_error("%s - Connection to channel has been lost", __FUNCTION__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ca_put(type, channel, p_value) != ECA_NORMAL) {
|
||||||
|
//log_warning("%s - ca_put failed", __FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Flush the requests */
|
||||||
|
if (ca_pend_io(1) != ECA_NORMAL) {
|
||||||
|
//log_error("%s - ca_pend_io failed", __FUNCTION__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = true;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef void (*pCallBack)(struct event_handler_args);
|
||||||
|
|
||||||
|
static inline bool CAInterface_SubscribeVariable(chid channel, chtype type,
|
||||||
|
pCallBack cb_func, void* p_value) {
|
||||||
|
bool status = false;
|
||||||
|
if (ca_state(channel) != cs_conn) {
|
||||||
|
//log_error("%s - Connection to channel has been lost", __FUNCTION__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ca_create_subscription(type, 0, channel, DBE_VALUE, cb_func, NULL, NULL)
|
||||||
|
!= ECA_NORMAL) {
|
||||||
|
//log_error("%s - ca_create_subscription failed", __FUNCTION__);
|
||||||
|
return status;
|
||||||
|
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if(ca_pend_event(0.0) != ECA_NORMAL){
|
||||||
|
//log_error("%s - ca_pend_event failed", __FUNCTION__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
status = true;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* CA_IF_H */
|
||||||
68
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/configure_sdn.cpp
Normal file
68
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/configure_sdn.cpp
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
//+======================================================================
|
||||||
|
// $HeadURL: https://svnpub.iter.org/codac/iter/codac/dev/units/m-sdd-translator-parts/tags/CODAC-CORE-6.0.0/org.iter.codac.sdd.translators/src/main/resources/templates/sdn/configure_sdn.cpp.vm $
|
||||||
|
// $Id: configure_sdn.cpp.vm 83098 2018-01-08 13:23:38Z cesnikt $
|
||||||
|
//
|
||||||
|
// Project : CODAC Core System
|
||||||
|
//
|
||||||
|
// Description : SDN Program - Gyrotron01DAN
|
||||||
|
//
|
||||||
|
// Author : Kirti Mahajan, Lana Abadie and TCS (link with velocity and SDD model)
|
||||||
|
//
|
||||||
|
// Copyright (c) : 2010-2018 ITER Organization,
|
||||||
|
// CS 90 046
|
||||||
|
// 13067 St. Paul-lez-Durance Cedex
|
||||||
|
// France
|
||||||
|
//
|
||||||
|
// This file is part of ITER CODAC software.
|
||||||
|
// For the terms and conditions of redistribution or use of this software
|
||||||
|
// refer to the file ITER-LICENSE.TXT located in the top level directory
|
||||||
|
// of the distribution package.
|
||||||
|
//
|
||||||
|
//-======================================================================
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <sdn.h>
|
||||||
|
#include "includetopics.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
/* Create variables for the topics on which application is publishing */
|
||||||
|
//+P=====================================================================
|
||||||
|
//-P=====================================================================
|
||||||
|
|
||||||
|
/* Create variables for topics on which application is subscribing */
|
||||||
|
//+S=====================================================================
|
||||||
|
//-S=====================================================================
|
||||||
|
|
||||||
|
int configureSDN()
|
||||||
|
{
|
||||||
|
|
||||||
|
SR_RET sr_ret = SR_OK;
|
||||||
|
|
||||||
|
//+P=====================================================================
|
||||||
|
//-P=====================================================================
|
||||||
|
|
||||||
|
//+S=====================================================================
|
||||||
|
//-S=====================================================================
|
||||||
|
|
||||||
|
return sr_ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int cleanupSDN()
|
||||||
|
{
|
||||||
|
|
||||||
|
SR_RET sr_ret = SR_OK;
|
||||||
|
|
||||||
|
/* Unregister publisher */
|
||||||
|
//+P=====================================================================
|
||||||
|
//-P=====================================================================
|
||||||
|
|
||||||
|
/* Unregister subscriber */
|
||||||
|
//+S=====================================================================
|
||||||
|
//-S=====================================================================
|
||||||
|
|
||||||
|
return sr_ret;
|
||||||
|
|
||||||
|
}
|
||||||
17
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/environmentVarDev
Normal file
17
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/environmentVarDev
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
########################################
|
||||||
|
# Program-specific environment variables
|
||||||
|
########################################
|
||||||
|
|
||||||
|
# INFO - This file is part of the I&C project. It can be modified without risk of being overwritten.
|
||||||
|
# INFO - This file is sourced when invoking 'mvn run -Dprog=<prog_name>' to allow for setting development-specific environment variables.
|
||||||
|
|
||||||
|
# Override SDN interface name for test purposes
|
||||||
|
# Default: lo
|
||||||
|
# Project: Target host <iface_name> in SDD database
|
||||||
|
#SDN_INTERFACE_NAME=lo
|
||||||
|
|
||||||
|
# INFO - This file can be further extended with anything specific required by the program.
|
||||||
|
|
||||||
|
#LOG_FILE_ENABLE=false
|
||||||
|
#LOG_FILTER_LEVEL=info
|
||||||
|
#LOG_FWD_MODE=asyn
|
||||||
29
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/includetopics.h
Normal file
29
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/includetopics.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
//+======================================================================
|
||||||
|
// $HeadURL: https://svnpub.iter.org/codac/iter/codac/dev/units/m-sdd-translator-parts/tags/CODAC-CORE-6.0.0/org.iter.codac.sdd.translators/src/main/resources/templates/sdn/includetopics.h.vm $
|
||||||
|
// $Id: includetopics.h.vm 83098 2018-01-08 13:23:38Z cesnikt $
|
||||||
|
//
|
||||||
|
// Project : CODAC Core System
|
||||||
|
//
|
||||||
|
// Description : SDN Program - Gyrotron01DAN
|
||||||
|
//
|
||||||
|
// Author : Kirti Mahajan, Lana Abadie and TCS (link with velocity and SDD model)
|
||||||
|
//
|
||||||
|
// Copyright (c) : 2010-2018 ITER Organization,
|
||||||
|
// CS 90 046
|
||||||
|
// 13067 St. Paul-lez-Durance Cedex
|
||||||
|
// France
|
||||||
|
//
|
||||||
|
// This file is part of ITER CODAC software.
|
||||||
|
// For the terms and conditions of redistribution or use of this software
|
||||||
|
// refer to the file ITER-LICENSE.TXT located in the top level directory
|
||||||
|
// of the distribution package.
|
||||||
|
//
|
||||||
|
//-======================================================================
|
||||||
|
|
||||||
|
#ifndef INCLUDETOPICS_H
|
||||||
|
#define INCLUDETOPICS_H
|
||||||
|
|
||||||
|
#include <sdn.h>
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
15
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/sdd-dan.cpp
Normal file
15
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/sdd-dan.cpp
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#include "sdd-dan.h"
|
||||||
|
#include <log.h>
|
||||||
|
#include "stdlib.h"
|
||||||
|
|
||||||
|
int declareDANStruct(dan_Source ds ){
|
||||||
|
|
||||||
|
int result=0;
|
||||||
|
int Cnt=0;
|
||||||
|
if(ds==NULL){
|
||||||
|
log_error("Invalid call to declareDANStruct, dan source not initialized \n ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
8
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/sdd-dan.h
Normal file
8
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/sdd-dan.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#ifndef SDD_DAN_H
|
||||||
|
#define SDD_DAN_H
|
||||||
|
#include "dan.h"
|
||||||
|
|
||||||
|
static const char ICProgName[] = "Gyrotron01DAN";
|
||||||
|
static const char GYADanSource[] = "GYADanSource";
|
||||||
|
|
||||||
|
#endif /* SDD_DAN_H */
|
||||||
14
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/sdd-data.h
Normal file
14
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/sdd-data.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef SDD_DATA_H
|
||||||
|
#define SDD_DATA_H
|
||||||
|
|
||||||
|
#include "sdd-pon-if.h"
|
||||||
|
#include "sdd-iomodule.h"
|
||||||
|
|
||||||
|
static SDD_PONVar pvlist []={
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
static SDD_IOModule iomlist []={
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* SDD_DATA_H */
|
||||||
37
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/sdd-iomodule.h
Normal file
37
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/sdd-iomodule.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#ifndef SDD_IOMODULE_H
|
||||||
|
#define SDD_IOMODULE_H
|
||||||
|
|
||||||
|
//include all linux libraries for IO module listed in the programs
|
||||||
|
|
||||||
|
|
||||||
|
//max is 15 for component name
|
||||||
|
#define SDD_CPMAXLENGTH 50
|
||||||
|
#define SDD_SERIALNBMAXLENGTH 60
|
||||||
|
#define SDD_FDPREFIXMAXLENGTH 100
|
||||||
|
|
||||||
|
struct SDD_IOModule {
|
||||||
|
|
||||||
|
//name of the module
|
||||||
|
char name[SDD_CPMAXLENGTH];
|
||||||
|
|
||||||
|
//type of the module
|
||||||
|
char modtype[SDD_CPMAXLENGTH];
|
||||||
|
|
||||||
|
//module index
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
//file descriptor name
|
||||||
|
char filedescrip_prefix[SDD_FDPREFIXMAXLENGTH];
|
||||||
|
|
||||||
|
//serial number
|
||||||
|
char serial_number [SDD_SERIALNBMAXLENGTH];
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//list of symbol for IOModule : IO module type and fd
|
||||||
|
typedef enum SDD_IOModuleEnum {
|
||||||
|
|
||||||
|
} SDD_IOModuleEnum;
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SDD_IOMODULE_H */
|
||||||
36
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/sdd-pon-if.h
Normal file
36
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/sdd-pon-if.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#ifndef SDD_PON_IF_H
|
||||||
|
#define SDD_PON_IF_H
|
||||||
|
|
||||||
|
#include <cadef.h> /* Channel Access API definition, etc. */
|
||||||
|
|
||||||
|
|
||||||
|
#define SDD_PVMAXLENGTH 40
|
||||||
|
#define SDD_STRING_MAX_LENGTH 100
|
||||||
|
#define SDD_NB_OF_PONVAR 0 //generated by SDD
|
||||||
|
|
||||||
|
struct SDD_PONVar {
|
||||||
|
|
||||||
|
char name[SDD_PVMAXLENGTH];
|
||||||
|
|
||||||
|
//if read-> monitor=yes otherwise false
|
||||||
|
bool isMonitored;
|
||||||
|
|
||||||
|
chtype type;
|
||||||
|
|
||||||
|
//the code can cast
|
||||||
|
char initialvalue[SDD_STRING_MAX_LENGTH];
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//list of symbols
|
||||||
|
typedef enum SDD_PONVarEnum {
|
||||||
|
|
||||||
|
|
||||||
|
} SDD_PONVarEnum;
|
||||||
|
|
||||||
|
//for each enum (bi/bo/mbbi/mbbo) name is symbolname suffix with _enum
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SDD_PON_IF_H */
|
||||||
36
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/topicvars.h
Normal file
36
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron01DAN/topicvars.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
//+======================================================================
|
||||||
|
// $HeadURL: https://svnpub.iter.org/codac/iter/codac/dev/units/m-sdd-translator-parts/tags/CODAC-CORE-6.0.0/org.iter.codac.sdd.translators/src/main/resources/templates/sdn/topicvars.h.vm $
|
||||||
|
// $Id: topicvars.h.vm 83098 2018-01-08 13:23:38Z cesnikt $
|
||||||
|
//
|
||||||
|
// Project : CODAC Core System
|
||||||
|
//
|
||||||
|
// Description : SDN Program - Gyrotron01DAN
|
||||||
|
//
|
||||||
|
// Author : Kirti Mahajan, Lana Abadie and TCS (link with velocity and SDD model)
|
||||||
|
//
|
||||||
|
// Copyright (c) : 2010-2018 ITER Organization,
|
||||||
|
// CS 90 046
|
||||||
|
// 13067 St. Paul-lez-Durance Cedex
|
||||||
|
// France
|
||||||
|
//
|
||||||
|
// This file is part of ITER CODAC software.
|
||||||
|
// For the terms and conditions of redistribution or use of this software
|
||||||
|
// refer to the file ITER-LICENSE.TXT located in the top level directory
|
||||||
|
// of the distribution package.
|
||||||
|
//
|
||||||
|
//-======================================================================
|
||||||
|
|
||||||
|
#ifndef TOPICVARS_H
|
||||||
|
#define TOPICVARS_H
|
||||||
|
|
||||||
|
#include "includetopics.h"
|
||||||
|
|
||||||
|
/* Declare variables for the topics on which application is publishing. */
|
||||||
|
//+P=====================================================================
|
||||||
|
//-P=====================================================================
|
||||||
|
|
||||||
|
/* Declare variables for the topics to which application is subscribing. */
|
||||||
|
//+S=====================================================================
|
||||||
|
//-S=====================================================================
|
||||||
|
|
||||||
|
#endif
|
||||||
639
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron02DAN/Gyrotron02DAN.cpp
Normal file
639
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron02DAN/Gyrotron02DAN.cpp
Normal file
@@ -0,0 +1,639 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* $HeadURL: https://svnpub.iter.org/codac/iter/codac/dev/units/m-codac-unit-templates/tags/CODAC-CORE-6.0.0/templates/cpp-sdn/main/c++/prog/prog.cpp.template $
|
||||||
|
* $Id: prog.cpp.template 83098 2018-01-08 13:23:38Z cesnikt $
|
||||||
|
*
|
||||||
|
* Project : CODAC Core System
|
||||||
|
*
|
||||||
|
* Description : GyrotronDAN program
|
||||||
|
*
|
||||||
|
* Author : codac-dev
|
||||||
|
*
|
||||||
|
* Copyright (c) : 2010-2018 ITER Organization,
|
||||||
|
* CS 90 046
|
||||||
|
* 13067 St. Paul-lez-Durance Cedex
|
||||||
|
* France
|
||||||
|
*
|
||||||
|
* This file is part of ITER CODAC software.
|
||||||
|
* For the terms and conditions of redistribution or use of this software
|
||||||
|
* refer to the file ITER-LICENSE.TXT located in the top level directory
|
||||||
|
* of the distribution package.
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
/* header files */
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <error.h>
|
||||||
|
//#include <xseries-lib.h>
|
||||||
|
#define float32_t float32_t1
|
||||||
|
#include <xseries-lib.h>
|
||||||
|
#undef float32_t
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <dan.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <ca-if.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <tcn.h>
|
||||||
|
|
||||||
|
#include <log.h>
|
||||||
|
|
||||||
|
// global variables
|
||||||
|
static bool __terminate = false;
|
||||||
|
char pxie6368_0_ai_fd[] = "/dev/pxie-6368.1.ai"; // ai segment
|
||||||
|
char pxie6368_0_device[] = "/dev/pxie-6368.1"; // device descriptor
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int daq_smpl_rate;
|
||||||
|
int daq_mode;
|
||||||
|
double daq_smpl_st_dly;
|
||||||
|
double daq_len;
|
||||||
|
double daq_pub_dly;
|
||||||
|
} daq_parameters;
|
||||||
|
|
||||||
|
void signal_handler(int signal) {
|
||||||
|
log_info("Received signal '%d' to terminate", signal);
|
||||||
|
__terminate = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// DAN parameter reload function ------------------------------------------------
|
||||||
|
int reload_daq_conf(int *aifd, int *ai_chan_fd, daq_parameters *daq_p) {
|
||||||
|
std::cout << "reload_daq_conf was called \n";
|
||||||
|
|
||||||
|
// Common variables
|
||||||
|
int retval;
|
||||||
|
unsigned long number_of_samples;
|
||||||
|
int chan_num = 10; // Channel number to add.
|
||||||
|
uint32_t sample_period_divisor;
|
||||||
|
uint32_t base_clock = 100000000; // TB3:100MHz, TB2:100 kHz
|
||||||
|
uint32_t pre_samples = 1000;
|
||||||
|
uint32_t post_samples = 1000;
|
||||||
|
char str[40];
|
||||||
|
xseries_ai_conf_t conf; // ai segment configuraton data
|
||||||
|
|
||||||
|
// calculate sampling period divisor
|
||||||
|
if (daq_p->daq_smpl_rate != 0) {
|
||||||
|
sample_period_divisor = base_clock / daq_p->daq_smpl_rate;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop ai segment----------------------------------------------------------------------
|
||||||
|
retval = xseries_stop_ai(*aifd);
|
||||||
|
if (retval) {
|
||||||
|
log_error("ai segment stop failed.\n");
|
||||||
|
} else {
|
||||||
|
log_info("ai segment stopped.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// reset ai segment---------------------------------------------------------------------
|
||||||
|
retval = xseries_reset_ai(*aifd);
|
||||||
|
if (retval) {
|
||||||
|
log_error("ai segment reset failed.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure AI segment mode ------------------------------------------------------------
|
||||||
|
switch (daq_p->daq_mode) {
|
||||||
|
case 0:
|
||||||
|
conf = xseries_software_timed_ai();
|
||||||
|
log_info("software_timed mode.\n");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
conf = xseries_finite_ai(number_of_samples);
|
||||||
|
log_info("finite mode.\n");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
conf = xseries_retriggerable_finite_ai(number_of_samples);
|
||||||
|
log_info("retriggerable_finite mode.\n");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
conf = xseries_continuous_ai();
|
||||||
|
log_info("continuous mode.\n");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
conf = xseries_reference_ai(pre_samples, post_samples);
|
||||||
|
log_info("reference mode.\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// disable external gate
|
||||||
|
retval = xseries_set_ai_external_gate(&conf,
|
||||||
|
XSERIES_AI_EXTERNAL_GATE_DISABLED, // No external pause signal
|
||||||
|
XSERIES_AI_POLARITY_ACTIVE_LOW_OR_FALLING_EDGE); // Don't care
|
||||||
|
if (retval) {
|
||||||
|
log_error("Cannot set gate trigger.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// select start trigger (START1 signal)
|
||||||
|
retval = xseries_set_ai_start_trigger(&conf,
|
||||||
|
XSERIES_AI_START_TRIGGER_SW_PULSE, // Set the line to software-driven
|
||||||
|
XSERIES_AI_POLARITY_ACTIVE_HIGH_OR_RISING_EDGE, // Make line active on rising...
|
||||||
|
1); // ... edge (not high level)
|
||||||
|
if (retval) {
|
||||||
|
log_error("Cannot set start trigger.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set sampling clock source----------------------------------------------------------------------------------------
|
||||||
|
retval = xseries_set_ai_sample_clock(&conf,
|
||||||
|
XSERIES_AI_SAMPLE_CONVERT_CLOCK_INTERNALTIMING,
|
||||||
|
XSERIES_AI_POLARITY_ACTIVE_HIGH_OR_RISING_EDGE, 1);
|
||||||
|
if (retval) {
|
||||||
|
log_error("Cannot configure sampling clock.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set scan interval -------------------------------------------------------------------------------------------------------------------------
|
||||||
|
retval = xseries_set_ai_scan_interval_counter(&conf,
|
||||||
|
XSERIES_SCAN_INTERVAL_COUNTER_TB3, // TB3 : 100MHz base clock, TB2 : 100kHz base clock
|
||||||
|
XSERIES_SCAN_INTERVAL_COUNTER_POLARITY_RISING_EDGE,
|
||||||
|
sample_period_divisor, 2); // Wait 2*100MHz sec after sampling trig.
|
||||||
|
if (retval) {
|
||||||
|
log_error("Cannot configure scan counter.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set DMA buffer size-----------------------------------------------------------------------------------------------------------------------
|
||||||
|
retval = xseries_set_ai_attribute(&conf, XSERIES_AI_DMA_BUFFER_SIZE, 1000);
|
||||||
|
if (retval) {
|
||||||
|
log_error("DMA configuration was failed.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add AI channels ---------------------------------------------------------------------------------------------------------------------------
|
||||||
|
for (int i = 0; i < chan_num; i++) {
|
||||||
|
retval = xseries_add_ai_channel(&conf, i, XSERIES_INPUT_RANGE_10V,
|
||||||
|
XSERIES_AI_CHANNEL_TYPE_DIFFERENTIAL, 0);
|
||||||
|
if (retval) {
|
||||||
|
log_error("Add AI channel %d was failed.\n", i);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sleep(3);
|
||||||
|
|
||||||
|
// Load configuration.-----------------------------------------------------------------------------------------------------------------------
|
||||||
|
retval = xseries_load_ai_conf(*aifd, conf);
|
||||||
|
if (retval) {
|
||||||
|
log_error("xseries_load_ai_conf was failed. error code: %d \n", retval);
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
sleep(3);
|
||||||
|
|
||||||
|
// Open channels--------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
for (int i = 0; i < chan_num; i++) {
|
||||||
|
sprintf(str, "%s.ai.%u", pxie6368_0_device, i);
|
||||||
|
//ai_chan_fd[i] = open(str, O_RDWR | O_NONBLOCK);
|
||||||
|
ai_chan_fd[i] = open(str, O_RDWR);
|
||||||
|
if (ai_chan_fd[i] < 0) {
|
||||||
|
log_error("Cannot open ai channel %d .\n",i);
|
||||||
|
sleep(1);
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// start ai segment task-----------------------------------------------------------------------------------------------------------------------
|
||||||
|
retval = xseries_start_ai(*aifd);
|
||||||
|
if (retval) {
|
||||||
|
log_error("ERROR, starting AI segment failed: %s\n", strerror(retval));
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
log_info("PXIe-6368 configuration was finished.\n");
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
using namespace std;
|
||||||
|
unsigned long n_sample_quotient = 0;
|
||||||
|
|
||||||
|
log_initialize(NULL);
|
||||||
|
|
||||||
|
while (!__terminate) {
|
||||||
|
// Install signal handler to support graceful termination
|
||||||
|
sigset(SIGTERM, signal_handler);
|
||||||
|
sigset(SIGINT, signal_handler);
|
||||||
|
sigset(SIGHUP, signal_handler);
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
|
// Running parameter declaration
|
||||||
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
|
// pxie6368 hardware parameters
|
||||||
|
int pxie6368_0_device_number = 1; // device discriptor number
|
||||||
|
int aifd = 0; // ai segment file discriptor
|
||||||
|
xseries_ai_conf_t conf; // ai segment config
|
||||||
|
xseries_ai_attribute_t aiatrb; // ai segment attributes
|
||||||
|
char str[40]; // fd tmp var
|
||||||
|
int ai_chan_fd[16]; // ai channels file discriptor
|
||||||
|
int pxie6368_sampling_rate = 1000; // sampling rate Hz
|
||||||
|
uint32_t sample_period_divisor = 100000000 / pxie6368_sampling_rate; // TB3 100MHz, TB2:100kHz, TB1:20MHz
|
||||||
|
int sampleSize = 2; // Sample size in bytes <---> uInt16
|
||||||
|
int n_channels; // Number of opened channels
|
||||||
|
struct xseries_dma *dma; // Ptr to dma struct
|
||||||
|
int chan_num = 10; // Channel number to add.
|
||||||
|
|
||||||
|
// DAN parameters
|
||||||
|
char dan_source_name[] = "GYBDanSource"; // DAN data source (ds) name
|
||||||
|
long offset_ai = 0; // offset size in published data
|
||||||
|
int dma_mode = 1; // 0:All, 1:AI only, 2:AO only
|
||||||
|
dan_DataCore dc = NULL; // Datacore reference declaration
|
||||||
|
dan_Source ds = NULL; // DAN source declaration
|
||||||
|
long samplesCounter = 0; // Total acquired sample size
|
||||||
|
size_t n_samples; // prepared sample size to publish
|
||||||
|
|
||||||
|
// TCN parameters
|
||||||
|
uint64_t tBase_old = 0;
|
||||||
|
uint64_t tBase = 0; // TCN publishing base time
|
||||||
|
uint64_t nanos; // time length for sampling
|
||||||
|
hpn_timestamp_t delay = 1e7; // wait for publishing (10ms)
|
||||||
|
char buf[ISO_8601_LEN];
|
||||||
|
uint64_t tBase0 = 0;
|
||||||
|
|
||||||
|
// Operation tmp parameter
|
||||||
|
int result; // For result values.
|
||||||
|
int exValue;
|
||||||
|
bool toterminate = false;
|
||||||
|
int retval;
|
||||||
|
bool daq_start = false;
|
||||||
|
int testcounter = 10000;
|
||||||
|
|
||||||
|
// Connected EPCIS PV
|
||||||
|
|
||||||
|
// DAQ config PVs
|
||||||
|
chid daq_smpl_rate_id;
|
||||||
|
chtype daq_smpl_rate_type;
|
||||||
|
int daq_smpl_rate;
|
||||||
|
chid daq_smpl_rate_rb_id;
|
||||||
|
chtype daq_smpl_rate_rb_type;
|
||||||
|
int daq_smpl_rate_rb;
|
||||||
|
chid daq_mode_id;
|
||||||
|
chtype daq_mode_type;
|
||||||
|
int daq_mode;
|
||||||
|
chid daq_mode_rb_id;
|
||||||
|
chtype daq_mode_rb_type;
|
||||||
|
int daq_mode_rb;
|
||||||
|
chid daq_sw_trig_id;
|
||||||
|
chtype daq_sw_trig_type;
|
||||||
|
int daq_sw_trig;
|
||||||
|
chid daq_smpl_st_dly_id;
|
||||||
|
chtype daq_smpl_st_dly_type;
|
||||||
|
double daq_smpl_st_dly;
|
||||||
|
chid daq_smpl_st_dly_rb_id;
|
||||||
|
chtype daq_smpl_st_dly_rb_type;
|
||||||
|
double daq_smpl_st_dly_rb;
|
||||||
|
chid daq_len_id;
|
||||||
|
chtype daq_len_type;
|
||||||
|
double daq_len;
|
||||||
|
chid daq_len_rb_id;
|
||||||
|
chtype daq_len_rb_type;
|
||||||
|
double daq_len_rb;
|
||||||
|
chid daq_reconf_id;
|
||||||
|
chtype daq_reconf_type;
|
||||||
|
int daq_reconf;
|
||||||
|
chid daq_pub_dly_id;
|
||||||
|
chtype daq_pub_dly_type;
|
||||||
|
double daq_pub_dly;
|
||||||
|
chid daq_pub_dly_rb_id;
|
||||||
|
chtype daq_pub_dly_rb_type;
|
||||||
|
double daq_pub_dly_rb;
|
||||||
|
|
||||||
|
chid daq_stat_id;
|
||||||
|
chtype daq_stat_type;
|
||||||
|
int daq_stat;
|
||||||
|
chid daq_conf_stat_id;
|
||||||
|
chtype daq_conf_stat_type;
|
||||||
|
int daq_conf_stat;
|
||||||
|
|
||||||
|
daq_parameters daq_p = { 0 }; // = {daq_smpl_rate, daq_smpl_rate_rb, daq_mode, daq_mode_rb};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
// EPICS PV connection
|
||||||
|
// ----------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
//Initialize ChannelAccess interface
|
||||||
|
CAInterface_Initialize();
|
||||||
|
|
||||||
|
// Connect to EPICS PVs
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-SMPL-RATE", daq_smpl_rate_id);
|
||||||
|
daq_smpl_rate_type = DBR_LONG;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-SMPL-RATE-RB", daq_smpl_rate_rb_id);
|
||||||
|
daq_smpl_rate_rb_type = DBR_LONG;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-MODE", daq_mode_id);
|
||||||
|
daq_mode_type = DBR_ENUM;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-MODE-RB", daq_mode_rb_id);
|
||||||
|
daq_mode_rb_type = DBR_ENUM;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-SW-TRIG", daq_sw_trig_id);
|
||||||
|
daq_sw_trig_type = DBR_ENUM;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-SMPL-ST-DLY", daq_smpl_st_dly_id);
|
||||||
|
daq_smpl_st_dly_type = DBR_DOUBLE;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-SMPL-ST-DLY-RB", daq_smpl_st_dly_rb_id);
|
||||||
|
daq_smpl_st_dly_rb_type = DBR_DOUBLE;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-LEN", daq_len_id);
|
||||||
|
daq_len_type = DBR_DOUBLE;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-LEN-RB", daq_len_rb_id);
|
||||||
|
daq_len_rb_type = DBR_DOUBLE;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-RECONF", daq_reconf_id);
|
||||||
|
daq_reconf_type = DBR_ENUM;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-PUB-DLY", daq_pub_dly_id);
|
||||||
|
daq_pub_dly_type = DBR_DOUBLE;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-PUB-DLY-RB", daq_pub_dly_rb_id);
|
||||||
|
daq_pub_dly_rb_type = DBR_DOUBLE;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-STAT", daq_stat_id);
|
||||||
|
daq_stat_type = DBR_ENUM;
|
||||||
|
|
||||||
|
CAInterface_ConnectVariable("EC-GN-P01-GPF:STAT-DAQ-CONF-STAT", daq_conf_stat_id);
|
||||||
|
daq_conf_stat_type = DBR_ENUM;
|
||||||
|
|
||||||
|
tcn_sleep(3e9);// Wait for a while.
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
|
// Initialize tcn library
|
||||||
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
|
int tcn_err;
|
||||||
|
tcn_err = tcn_init();
|
||||||
|
if (tcn_err != TCN_SUCCESS) {
|
||||||
|
log_error("TCN Initialization failed.\n");
|
||||||
|
exValue = 1;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
|
// pxie-6368 settings
|
||||||
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
|
// Open ai segment----------------------------------------------------------------------
|
||||||
|
aifd = open(pxie6368_0_ai_fd, O_RDWR);
|
||||||
|
if (aifd <= 0) {
|
||||||
|
log_error("Open PXIe6368 AI fd failed.\n");
|
||||||
|
exValue = -1;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
// wait ai segment setup start
|
||||||
|
do {
|
||||||
|
CAInterface_ReadVariable(daq_reconf_id, daq_reconf_type, (void*) &daq_reconf);
|
||||||
|
} while (!daq_reconf and !__terminate);
|
||||||
|
|
||||||
|
// read parameter
|
||||||
|
result = CAInterface_ReadVariable(daq_smpl_rate_id, daq_smpl_rate_type, (void *) &daq_p.daq_smpl_rate);
|
||||||
|
if (!result) {
|
||||||
|
log_error("CA_READ failed.\n");
|
||||||
|
}
|
||||||
|
// read parameter
|
||||||
|
result = CAInterface_ReadVariable(daq_mode_id, daq_mode_type, (void *) &daq_p.daq_mode);
|
||||||
|
if (!result) {
|
||||||
|
log_error("CA_READ failed.\n");
|
||||||
|
}
|
||||||
|
// read parameter
|
||||||
|
result = CAInterface_ReadVariable(daq_smpl_st_dly_id, daq_smpl_st_dly_type, (void *) &daq_p.daq_smpl_st_dly);
|
||||||
|
if (!result) {
|
||||||
|
log_error("CA_READ failed.\n");
|
||||||
|
}
|
||||||
|
// read parameter
|
||||||
|
result = CAInterface_ReadVariable(daq_len_id, daq_len_type, (void *) &daq_p.daq_len);
|
||||||
|
if (!result) {
|
||||||
|
log_error("CA_READ failed.\n");
|
||||||
|
}
|
||||||
|
// read parameter
|
||||||
|
result = CAInterface_ReadVariable(daq_pub_dly_id, daq_pub_dly_type, (void *) &daq_p.daq_pub_dly);
|
||||||
|
if (!result) {
|
||||||
|
log_error("CA_READ failed.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "SAMPLE RATE:" << daq_p.daq_smpl_rate << endl;
|
||||||
|
std::cout << "MODE :" << daq_p.daq_mode << endl;
|
||||||
|
std::cout << "START DELAY:" <<daq_p.daq_smpl_st_dly << endl;
|
||||||
|
std::cout << "DAQ LENGTH:" << daq_p.daq_len << endl;
|
||||||
|
std::cout << "PUB DELAY :" << daq_p.daq_pub_dly << endl;
|
||||||
|
|
||||||
|
// Configure ai segment and dan parameter by using EPICS PV.
|
||||||
|
result = reload_daq_conf(&aifd, ai_chan_fd, &daq_p);
|
||||||
|
if (result < 0) {
|
||||||
|
log_error("Load DAQ CONF failed.\n");
|
||||||
|
daq_stat = 3; // 0:Not ready, 1:Waiting trigger, 2:Aquiring, 3:Error
|
||||||
|
CAInterface_WriteVariable(daq_stat_id, daq_stat_type, &daq_stat);
|
||||||
|
daq_conf_stat = 0; // 0:Not Ready, 1: Ready
|
||||||
|
CAInterface_WriteVariable(daq_conf_stat_id, daq_conf_stat_type, &daq_conf_stat);
|
||||||
|
goto END;
|
||||||
|
} else {
|
||||||
|
// All parameters were configured correctly, update readback PV
|
||||||
|
CAInterface_WriteVariable(daq_smpl_rate_rb_id, daq_smpl_rate_rb_type, &daq_p.daq_smpl_rate);
|
||||||
|
CAInterface_WriteVariable(daq_mode_rb_id, daq_mode_rb_type, &daq_p.daq_mode);
|
||||||
|
CAInterface_WriteVariable(daq_smpl_st_dly_rb_id, daq_smpl_st_dly_rb_type, &daq_p.daq_smpl_st_dly);
|
||||||
|
CAInterface_WriteVariable(daq_len_rb_id, daq_len_rb_type, &daq_p.daq_len);
|
||||||
|
CAInterface_WriteVariable(daq_pub_dly_rb_id, daq_pub_dly_rb_type, &daq_p.daq_pub_dly);
|
||||||
|
daq_conf_stat = 1;
|
||||||
|
CAInterface_WriteVariable(daq_conf_stat_id, daq_conf_stat_type, &daq_conf_stat);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------
|
||||||
|
// ----- DAN Publisher.
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------
|
||||||
|
// Initialize DAN DataCore
|
||||||
|
dc = dan_initLibrary();
|
||||||
|
if (dc == NULL) {
|
||||||
|
log_error("dan_init failed.\n");
|
||||||
|
exValue = 1;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----- DMA initialization
|
||||||
|
dma = xseries_dma_init(pxie6368_0_device_number, 1); // (devid, dma_mode) mode 0:mapping all dma mem, 1:AI only.
|
||||||
|
if (dma == NULL) {
|
||||||
|
cout << "Failed to connect to samples buffer.\n go to END.\n";
|
||||||
|
exValue = -1;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Push a new data block into source.
|
||||||
|
ds = dan_publisher_publishSource(dc, dan_source_name, pxie6368_0_device,
|
||||||
|
DAN_DAQ_MMAP, dma->ai.count * sampleSize, 4096);
|
||||||
|
|
||||||
|
//dan_DataCore, ds_name, devName, enum_daq_type refType, long refSize, long refOffset
|
||||||
|
if (ds == NULL) {
|
||||||
|
log_error("Error while publishing DAN source %s ", dan_source_name);
|
||||||
|
exValue = 1;
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
|
|
||||||
|
n_channels = dan_publisher_getNumberOfChannels(ds);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------
|
||||||
|
// ----- DAN Streamer.
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------
|
||||||
|
// ----- Open a new stream ---------------------------------------------------------------------
|
||||||
|
dan_publisher_openStream(ds, daq_p.daq_smpl_rate, 0);
|
||||||
|
sleep(1);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------
|
||||||
|
// ----- Main DAN Loop.
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------
|
||||||
|
while (!__terminate) {
|
||||||
|
// Wait for the master trigger.----------------------------------------------------------------------------
|
||||||
|
daq_stat = 1; //0:Not Ready, 1: Waiting trigger, 2:Acquiring 3:Error
|
||||||
|
CAInterface_WriteVariable(daq_stat_id, daq_stat_type, &daq_stat);
|
||||||
|
daq_conf_stat = 1; //0:Not ready, 1: Ready
|
||||||
|
CAInterface_WriteVariable(daq_conf_stat_id, daq_conf_stat_type, &daq_conf_stat);
|
||||||
|
|
||||||
|
// Wait DAQ Start Software Trigger.
|
||||||
|
do {
|
||||||
|
// check daq_sw_trigger to start DAQ sequence.
|
||||||
|
CAInterface_ReadVariable(daq_sw_trig_id, daq_sw_trig_type, (void*) &daq_sw_trig);
|
||||||
|
tcn_sleep(1e7); // wait 0.01 s
|
||||||
|
if (daq_sw_trig) {
|
||||||
|
daq_start = true;
|
||||||
|
}
|
||||||
|
} while (daq_start != true and !__terminate);
|
||||||
|
|
||||||
|
daq_start = false; //reset daq_start flag.
|
||||||
|
delay = (long) (1e6 * daq_p.daq_pub_dly); //check publish period.
|
||||||
|
|
||||||
|
// Wait a time to start DAQ. ----------------------------------------------------------------------------------------------------------------------
|
||||||
|
tcn_sleep(daq_p.daq_smpl_st_dly * 1e6); // in ms
|
||||||
|
|
||||||
|
// After the wating, trigger DAQ ------------------------------------------------------------------------------------------------------------------
|
||||||
|
retval = xseries_pulse_ai(aifd, XSERIES_START_TRIGGER);
|
||||||
|
daq_stat = 2;
|
||||||
|
CAInterface_WriteVariable(daq_stat_id, daq_stat_type, &daq_stat);
|
||||||
|
if (retval) {
|
||||||
|
std::cout << "Cannot generate start trigger!\n";
|
||||||
|
goto END;
|
||||||
|
} else {
|
||||||
|
tcn_get_time(&tBase); // get DAQ start time.
|
||||||
|
tBase0 = tBase; // save DAQ start time to tBase0;
|
||||||
|
tBase_old = tBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DAQ Publish Loop. ----------------------------------------------------------------------------------------------------------------------------
|
||||||
|
// DAN data publish is executed every delay time interval.
|
||||||
|
while (!__terminate && (tcn_wait_until_hr((tBase + delay), &tBase, 0) == TCN_SUCCESS)) {
|
||||||
|
// Get the number of available samples in PXIe6368 buffer.
|
||||||
|
n_samples = xsereis_ai_dma_samples_in_buffer(dma); // samples
|
||||||
|
|
||||||
|
if (n_samples > dma->ai.count) {
|
||||||
|
//log_error("DMA Buffer overflow: Number of new samples in buffer = %ld, AI buffer size = %ld,\n", n_samples, dma->ai.count);
|
||||||
|
} else if (n_samples > 0) {
|
||||||
|
//log_info("Current Time:\n%s\n", tcn_strftime(tBase, buf, ISO_8601_LEN));
|
||||||
|
if (tBase == 0) {
|
||||||
|
// "tBase was reset.------------------------------------------------------\n";
|
||||||
|
tcn_get_time(&tBase);
|
||||||
|
tBase -= n_samples * 100000000 / pxie6368_sampling_rate;
|
||||||
|
nanos = 0;
|
||||||
|
} else {
|
||||||
|
// update time offset value.
|
||||||
|
nanos = n_samples * 100000000 / daq_p.daq_smpl_rate;
|
||||||
|
}
|
||||||
|
n_sample_quotient = floor(n_samples / chan_num);
|
||||||
|
n_samples = n_sample_quotient * chan_num;
|
||||||
|
|
||||||
|
// Publish a new data block --------------------------------------------------------------------------------------------------------------------------
|
||||||
|
result = dan_publisher_putBlockReference(ds,
|
||||||
|
tBase_old + nanos, // timestamp in epoch nanoseconds
|
||||||
|
n_samples * sampleSize, // datablock size in bytes
|
||||||
|
offset_ai * sampleSize, // Offset in DAQ buffer
|
||||||
|
NULL); // No datablock header....
|
||||||
|
// Detected overflow in pass datablock reference queue
|
||||||
|
if (result == -1) {
|
||||||
|
log_info("%s, Queue overflow with policy %d\n", dan_source_name, dan_publisher_getCheckPolicy(ds));
|
||||||
|
} else if (result == -2) {
|
||||||
|
log_info("%s, DAQ buffer overflow with policy %d\n", dan_source_name, dan_publisher_getCheckPolicy(ds));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
samplesCounter += n_samples; // Increment total of published sampes
|
||||||
|
offset_ai = (offset_ai + n_samples) % dma->ai.count; // Update offset of memory
|
||||||
|
dma->ai.last_transfer_count = samplesCounter; // Update dma last_transfer_count
|
||||||
|
|
||||||
|
// Check exit condition.
|
||||||
|
if ((daq_p.daq_len * 1e6 <= (tBase - tBase0))) {
|
||||||
|
retval = xseries_stop_ai(aifd);
|
||||||
|
if (retval) {
|
||||||
|
std::cout << "Stop AI segment failed.\n";
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
//restart ai segment.
|
||||||
|
tcn_sleep(1e9); // wait
|
||||||
|
retval = xseries_start_ai(aifd);
|
||||||
|
if (retval) {
|
||||||
|
std::cout << "Start AI segment failed.\n";
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
//debug
|
||||||
|
tcn_sleep(1e8);
|
||||||
|
n_samples = xsereis_ai_dma_samples_in_buffer(dma);
|
||||||
|
cout << "n_samples check : " << n_samples << endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tBase_old = tBase;
|
||||||
|
} // End of DAQ publish loop.
|
||||||
|
break;
|
||||||
|
} // End of DAN main loop.
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------
|
||||||
|
// ----- Closing program.
|
||||||
|
// ------------------------------------------------------------------------------------------------------------------
|
||||||
|
log_info("DAN end of acquisition, closing all resources");
|
||||||
|
|
||||||
|
//Closing stream
|
||||||
|
dan_publisher_closeStream(ds);
|
||||||
|
exValue = 0;
|
||||||
|
|
||||||
|
// Close all channels
|
||||||
|
for (int channel = 0; channel < chan_num; channel++) {
|
||||||
|
close(ai_chan_fd[channel]);
|
||||||
|
}
|
||||||
|
goto END;
|
||||||
|
|
||||||
|
END: daq_conf_stat = 0;
|
||||||
|
CAInterface_WriteVariable(daq_conf_stat_id, daq_conf_stat_type, &daq_conf_stat);
|
||||||
|
daq_stat = 0;
|
||||||
|
CAInterface_WriteVariable(daq_stat_id, daq_stat_type, &daq_stat);
|
||||||
|
// Destroy CA context
|
||||||
|
CAInterface_Finalize();
|
||||||
|
// Close pxie6368
|
||||||
|
if (dma != NULL) {
|
||||||
|
xseries_dma_close(dma);
|
||||||
|
cout << "pxie-6368 dma was clesed.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
close(aifd);
|
||||||
|
|
||||||
|
// Unpublishing source from DAN API
|
||||||
|
if (ds != NULL) {
|
||||||
|
dan_publisher_unpublishSource(dc, ds);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Closing DAN API library
|
||||||
|
if (dc != NULL) {
|
||||||
|
dan_closeLibrary(dc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Closing TCN library
|
||||||
|
result = tcn_finalize();
|
||||||
|
if (result != TCN_SUCCESS) {
|
||||||
|
//log_error("Error finalizing TCN lib.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
} // loop end from initialization
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
}
|
||||||
68
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron02DAN/Makefile
Normal file
68
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron02DAN/Makefile
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
#+======================================================================
|
||||||
|
# $HeadURL: https://svnpub.iter.org/codac/iter/codac/dev/units/m-codac-unit-templates/tags/CODAC-CORE-6.0.0/templates/cpp/main/c++/prog/Makefile.template $
|
||||||
|
# $Id: Makefile.template 83098 2018-01-08 13:23:38Z cesnikt $
|
||||||
|
#
|
||||||
|
# Project : CODAC Core System
|
||||||
|
#
|
||||||
|
# Description : gyrotronDAN Makefile
|
||||||
|
#
|
||||||
|
# Author : This file was generated by CODAC development toolkit
|
||||||
|
#
|
||||||
|
# Copyright (c) : 2010-2018 ITER Organization,
|
||||||
|
# CS 90 046
|
||||||
|
# 13067 St. Paul-lez-Durance Cedex
|
||||||
|
# France
|
||||||
|
#
|
||||||
|
# This file is part of ITER CODAC software.
|
||||||
|
# For the terms and conditions of redistribution or use of this software
|
||||||
|
# refer to the file ITER-LICENSE.TXT located in the top level directory
|
||||||
|
# of the distribution package.
|
||||||
|
#
|
||||||
|
#-======================================================================
|
||||||
|
|
||||||
|
PROGNAME=Gyrotron02DAN
|
||||||
|
|
||||||
|
LIBRARIES=ca dan_api dan_client_api dan_stream dan_base xml2 log sdn sdn-core ccs-core rt pthread tcn nixseries
|
||||||
|
LIBRARY_DIRS=
|
||||||
|
INCLUDE_DIRS=. ../include $(CODAC_ROOT)/include $(EPICS_BASE)/include/os/Linux $(EPICS_BASE)/include/compiler/gcc $(EPICS_BASE)/include /usr/include/libxml2 $(SDN_TOPIC_DIRECTORY)
|
||||||
|
|
||||||
|
TARGET=../../../../target
|
||||||
|
BINARY_DIR=$(TARGET)/bin
|
||||||
|
OBJECT_DIR=$(TARGET)/obj/$(PROGNAME)
|
||||||
|
SOURCE_DIR=.
|
||||||
|
|
||||||
|
EXECUTABLE=$(BINARY_DIR)/$(PROGNAME)
|
||||||
|
INCLUDES=$(foreach inc,$(INCLUDE_DIRS),-I$(inc))
|
||||||
|
LDLIBS=-L$(CODAC_ROOT)/lib -L$(EPICS_BASE)/lib/$(EPICS_HOST_ARCH) $(foreach libs,$(LIBRARY_DIRS),-L$(libs) -Wl,-rpath,$(libs)) $(foreach libs,$(LIBRARIES),-l$(libs))
|
||||||
|
SOURCES=$(SOURCE_DIR)/$(PROGNAME).cpp $(SOURCE_DIR)/configure_sdn.cpp
|
||||||
|
# to build executable from all sources in the program directory:
|
||||||
|
#SOURCES=$(wildcard $(SOURCE_DIR)/*.cpp $(SOURCE_DIR)/*.c)
|
||||||
|
OBJECTS=$(addprefix $(OBJECT_DIR)/,$(patsubst %.cpp,%.o,$(notdir $(SOURCES))))
|
||||||
|
|
||||||
|
C=gcc
|
||||||
|
CC=g++
|
||||||
|
CFLAGS=-c -Wall
|
||||||
|
CCFLAGS=-c -Wall -std=c++11
|
||||||
|
LDFLAGS=
|
||||||
|
|
||||||
|
.PHONY: all clean run
|
||||||
|
|
||||||
|
all: $(SOURCES) $(EXECUTABLE)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf "$(EXECUTABLE)" "$(OBJECT_DIR)"
|
||||||
|
|
||||||
|
run: $(SOURCES) $(EXECUTABLE)
|
||||||
|
$(EXECUTABLE)
|
||||||
|
|
||||||
|
$(EXECUTABLE): $(OBJECTS)
|
||||||
|
mkdir -p $(BINARY_DIR)
|
||||||
|
$(CC) $(LDFLAGS) $(LDLIBS) $(OBJECTS) -o $@
|
||||||
|
|
||||||
|
$(OBJECT_DIR)/%.o: $(SOURCE_DIR)/%.cpp
|
||||||
|
mkdir -p $(OBJECT_DIR)
|
||||||
|
$(CC) $(CCFLAGS) $(INCLUDES) $< -o $@
|
||||||
|
|
||||||
|
$(OBJECT_DIR)/%.o: $(SOURCE_DIR)/%.c
|
||||||
|
mkdir -p $(OBJECT_DIR)
|
||||||
|
$(C) $(CFLAGS) $(INCLUDES) $< -o $@
|
||||||
165
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron02DAN/ca-if.h
Normal file
165
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron02DAN/ca-if.h
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
#ifndef CA_IF_H
|
||||||
|
#define CA_IF_H
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* $HeadURL: https://svnpub.iter.org/codac/iter/codac/dev/units/m-log-lib/trunk/src/main/c++/include/tools/any-type.h $
|
||||||
|
* $Id: any-type.h 50547 2014-10-09 12:09:51Z bauvirb $
|
||||||
|
*
|
||||||
|
* Project : CODAC Core System
|
||||||
|
*
|
||||||
|
* Description : Channel Access Interface
|
||||||
|
*
|
||||||
|
* Author : Bertrand Bauvir
|
||||||
|
*
|
||||||
|
* Copyright (c) : 2010-2014 ITER Organization,
|
||||||
|
* CS 90 046
|
||||||
|
* 13067 St. Paul-lez-Durance Cedex
|
||||||
|
* France
|
||||||
|
*
|
||||||
|
* This file is part of ITER CODAC software.
|
||||||
|
* For the terms and conditions of redistribution or use of this software
|
||||||
|
* refer to the file ITER-LICENSE.TXT located in the top level directory
|
||||||
|
* of the distribution package.
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
/* Global header files */
|
||||||
|
#include <iostream>
|
||||||
|
#include <cadef.h> /* Channel Access API definition, etc. */
|
||||||
|
//#include <log.h> /* CCS logging library */
|
||||||
|
|
||||||
|
/* Local header files */
|
||||||
|
|
||||||
|
/* Constants */
|
||||||
|
|
||||||
|
#ifndef log_trace
|
||||||
|
#define log_trace(arg_msg...) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef log_error
|
||||||
|
#define log_error(arg_msg...){}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Type definition */
|
||||||
|
|
||||||
|
/* Global variables */
|
||||||
|
|
||||||
|
/* Public function declaration */
|
||||||
|
|
||||||
|
static inline bool CAInterface_Initialize(void) {
|
||||||
|
bool status = false;
|
||||||
|
ca_context_create (ca_disable_preemptive_callback); //Default
|
||||||
|
//ca_context_create(ca_enable_preemptive_callback);
|
||||||
|
status = true;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline bool CAInterface_Finalize(void) {
|
||||||
|
bool status = false;
|
||||||
|
ca_context_destroy();
|
||||||
|
status = true;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline bool CAInterface_ConnectVariable(char* name, chid& id) {
|
||||||
|
bool status = false;
|
||||||
|
/* Connect to channels */
|
||||||
|
if (ca_create_channel(name, NULL, NULL, 10, &id) != ECA_NORMAL) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wait for connections */
|
||||||
|
if (ca_pend_io(1) != ECA_NORMAL) {
|
||||||
|
log_error("%s - ca_pend_io failed", __FUNCTION__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Verify channel */
|
||||||
|
if (ca_state(id) != cs_conn) {
|
||||||
|
//log_warning("Connection to channel '%s' has not been successful", name);
|
||||||
|
} else {
|
||||||
|
//log_info("Connection to channel '%s' has been successfully verified", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
status = true;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline bool CAInterface_ReadVariable(chid channel, chtype type,
|
||||||
|
void* p_value) {
|
||||||
|
bool status = false;
|
||||||
|
if (ca_state(channel) != cs_conn) {
|
||||||
|
//log_error("%s - Connection to channel has been lost");
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ca_get(type, channel, p_value) != ECA_NORMAL) {
|
||||||
|
//log_error("%s - ca_get failed", __FUNCTION__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Flush the requests */
|
||||||
|
if (ca_pend_io(1) != ECA_NORMAL) {
|
||||||
|
//log_error("%s - ca_pend_io failed", __FUNCTION__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = true;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline bool CAInterface_WriteVariable(chid channel, chtype type,
|
||||||
|
void* p_value) {
|
||||||
|
bool status = false;
|
||||||
|
|
||||||
|
if (ca_state(channel) != cs_conn) {
|
||||||
|
//log_error("%s - Connection to channel has been lost", __FUNCTION__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ca_put(type, channel, p_value) != ECA_NORMAL) {
|
||||||
|
//log_warning("%s - ca_put failed", __FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Flush the requests */
|
||||||
|
if (ca_pend_io(1) != ECA_NORMAL) {
|
||||||
|
//log_error("%s - ca_pend_io failed", __FUNCTION__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = true;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef void (*pCallBack)(struct event_handler_args);
|
||||||
|
|
||||||
|
static inline bool CAInterface_SubscribeVariable(chid channel, chtype type,
|
||||||
|
pCallBack cb_func, void* p_value) {
|
||||||
|
bool status = false;
|
||||||
|
if (ca_state(channel) != cs_conn) {
|
||||||
|
//log_error("%s - Connection to channel has been lost", __FUNCTION__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ca_create_subscription(type, 0, channel, DBE_VALUE, cb_func, NULL, NULL)
|
||||||
|
!= ECA_NORMAL) {
|
||||||
|
//log_error("%s - ca_create_subscription failed", __FUNCTION__);
|
||||||
|
return status;
|
||||||
|
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if(ca_pend_event(0.0) != ECA_NORMAL){
|
||||||
|
//log_error("%s - ca_pend_event failed", __FUNCTION__);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
status = true;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* CA_IF_H */
|
||||||
68
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron02DAN/configure_sdn.cpp
Normal file
68
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron02DAN/configure_sdn.cpp
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
//+======================================================================
|
||||||
|
// $HeadURL: https://svnpub.iter.org/codac/iter/codac/dev/units/m-sdd-translator-parts/tags/CODAC-CORE-6.0.0/org.iter.codac.sdd.translators/src/main/resources/templates/sdn/configure_sdn.cpp.vm $
|
||||||
|
// $Id: configure_sdn.cpp.vm 83098 2018-01-08 13:23:38Z cesnikt $
|
||||||
|
//
|
||||||
|
// Project : CODAC Core System
|
||||||
|
//
|
||||||
|
// Description : SDN Program - Gyrotron02DAN
|
||||||
|
//
|
||||||
|
// Author : Kirti Mahajan, Lana Abadie and TCS (link with velocity and SDD model)
|
||||||
|
//
|
||||||
|
// Copyright (c) : 2010-2018 ITER Organization,
|
||||||
|
// CS 90 046
|
||||||
|
// 13067 St. Paul-lez-Durance Cedex
|
||||||
|
// France
|
||||||
|
//
|
||||||
|
// This file is part of ITER CODAC software.
|
||||||
|
// For the terms and conditions of redistribution or use of this software
|
||||||
|
// refer to the file ITER-LICENSE.TXT located in the top level directory
|
||||||
|
// of the distribution package.
|
||||||
|
//
|
||||||
|
//-======================================================================
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <sdn.h>
|
||||||
|
#include "includetopics.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
/* Create variables for the topics on which application is publishing */
|
||||||
|
//+P=====================================================================
|
||||||
|
//-P=====================================================================
|
||||||
|
|
||||||
|
/* Create variables for topics on which application is subscribing */
|
||||||
|
//+S=====================================================================
|
||||||
|
//-S=====================================================================
|
||||||
|
|
||||||
|
int configureSDN()
|
||||||
|
{
|
||||||
|
|
||||||
|
SR_RET sr_ret = SR_OK;
|
||||||
|
|
||||||
|
//+P=====================================================================
|
||||||
|
//-P=====================================================================
|
||||||
|
|
||||||
|
//+S=====================================================================
|
||||||
|
//-S=====================================================================
|
||||||
|
|
||||||
|
return sr_ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int cleanupSDN()
|
||||||
|
{
|
||||||
|
|
||||||
|
SR_RET sr_ret = SR_OK;
|
||||||
|
|
||||||
|
/* Unregister publisher */
|
||||||
|
//+P=====================================================================
|
||||||
|
//-P=====================================================================
|
||||||
|
|
||||||
|
/* Unregister subscriber */
|
||||||
|
//+S=====================================================================
|
||||||
|
//-S=====================================================================
|
||||||
|
|
||||||
|
return sr_ret;
|
||||||
|
|
||||||
|
}
|
||||||
17
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron02DAN/environmentVarDev
Normal file
17
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron02DAN/environmentVarDev
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
########################################
|
||||||
|
# Program-specific environment variables
|
||||||
|
########################################
|
||||||
|
|
||||||
|
# INFO - This file is part of the I&C project. It can be modified without risk of being overwritten.
|
||||||
|
# INFO - This file is sourced when invoking 'mvn run -Dprog=<prog_name>' to allow for setting development-specific environment variables.
|
||||||
|
|
||||||
|
# Override SDN interface name for test purposes
|
||||||
|
# Default: lo
|
||||||
|
# Project: Target host <iface_name> in SDD database
|
||||||
|
#SDN_INTERFACE_NAME=lo
|
||||||
|
|
||||||
|
# INFO - This file can be further extended with anything specific required by the program.
|
||||||
|
|
||||||
|
#LOG_FILE_ENABLE=false
|
||||||
|
#LOG_FILTER_LEVEL=info
|
||||||
|
#LOG_FWD_MODE=asyn
|
||||||
29
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron02DAN/includetopics.h
Normal file
29
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron02DAN/includetopics.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
//+======================================================================
|
||||||
|
// $HeadURL: https://svnpub.iter.org/codac/iter/codac/dev/units/m-sdd-translator-parts/tags/CODAC-CORE-6.0.0/org.iter.codac.sdd.translators/src/main/resources/templates/sdn/includetopics.h.vm $
|
||||||
|
// $Id: includetopics.h.vm 83098 2018-01-08 13:23:38Z cesnikt $
|
||||||
|
//
|
||||||
|
// Project : CODAC Core System
|
||||||
|
//
|
||||||
|
// Description : SDN Program - Gyrotron02DAN
|
||||||
|
//
|
||||||
|
// Author : Kirti Mahajan, Lana Abadie and TCS (link with velocity and SDD model)
|
||||||
|
//
|
||||||
|
// Copyright (c) : 2010-2018 ITER Organization,
|
||||||
|
// CS 90 046
|
||||||
|
// 13067 St. Paul-lez-Durance Cedex
|
||||||
|
// France
|
||||||
|
//
|
||||||
|
// This file is part of ITER CODAC software.
|
||||||
|
// For the terms and conditions of redistribution or use of this software
|
||||||
|
// refer to the file ITER-LICENSE.TXT located in the top level directory
|
||||||
|
// of the distribution package.
|
||||||
|
//
|
||||||
|
//-======================================================================
|
||||||
|
|
||||||
|
#ifndef INCLUDETOPICS_H
|
||||||
|
#define INCLUDETOPICS_H
|
||||||
|
|
||||||
|
#include <sdn.h>
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
15
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron02DAN/sdd-dan.cpp
Normal file
15
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron02DAN/sdd-dan.cpp
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#include "sdd-dan.h"
|
||||||
|
#include <log.h>
|
||||||
|
#include "stdlib.h"
|
||||||
|
|
||||||
|
int declareDANStruct(dan_Source ds ){
|
||||||
|
|
||||||
|
int result=0;
|
||||||
|
int Cnt=0;
|
||||||
|
if(ds==NULL){
|
||||||
|
log_error("Invalid call to declareDANStruct, dan source not initialized \n ");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
8
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron02DAN/sdd-dan.h
Normal file
8
EC-GN-JA-PCF-IN/src/main/c++/Gyrotron02DAN/sdd-dan.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#ifndef SDD_DAN_H
|
||||||
|
#define SDD_DAN_H
|
||||||
|
#include "dan.h"
|
||||||
|
|
||||||
|
static const char ICProgName[] = "Gyrotron02DAN";
|
||||||
|
static const char GYBDanSource[] = "GYBDanSource";
|
||||||
|
|
||||||
|
#endif /* SDD_DAN_H */
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user