From 085cf5d70ed04ae529c192026ecdd55f79a2f9d1 Mon Sep 17 00:00:00 2001 From: Bernardo Carvalho Date: Thu, 10 Oct 2024 22:11:23 +0000 Subject: [PATCH] Added WriteEoWo Message Signed-off-by: Bernardo Carvalho --- Configurations/RTApp-AtcaIop.cfg | 44 ++-- DataSources/AtcaIop/AtcaIopConfig.cpp | 354 ++++++++++++++++++++++++++ DataSources/AtcaIop/AtcaIopConfig.h | 257 +++++++++++++++++++ DataSources/AtcaIop/Makefile.inc | 2 +- 4 files changed, 637 insertions(+), 20 deletions(-) create mode 100644 DataSources/AtcaIop/AtcaIopConfig.cpp create mode 100644 DataSources/AtcaIop/AtcaIopConfig.h diff --git a/Configurations/RTApp-AtcaIop.cfg b/Configurations/RTApp-AtcaIop.cfg index 32ef852..345483e 100644 --- a/Configurations/RTApp-AtcaIop.cfg +++ b/Configurations/RTApp-AtcaIop.cfg @@ -1,7 +1,7 @@ +EPICSCAInterface = { Class = "EPICS::EPICSCAClient" StackSize = "1048576" - CPUs = "0x10" + CPUs = "0x010" AutoStart = "0" +PV_STATUS = { Class = "EPICS::EPICSPV" @@ -129,6 +129,12 @@ param1 = "-1" // param1 = "-1" Auto number } } + +WriteEoWoMsg = { + Class = "Message" + Destination = "IsttokApp.Data.AtcaIopConfig_DS" + Function = "WriteEoWo" + Mode = "ExpectsReply" + } +ChangeToRunMsg = { Class = "Message" Destination = "IsttokApp" @@ -645,13 +651,13 @@ $IsttokApp = { } OutputSignals = { EO = { - DataSource = AtcaIopConfigEoWo_DS + DataSource = AtcaIopConfig_DS Type = int32 NumberOfElements = "16" Trigger = 1 } WO = { - DataSource = AtcaIopConfigEoWo_DS + DataSource = AtcaIopConfig_DS NumberOfElements = "16" Type = float32 } @@ -1287,11 +1293,11 @@ $IsttokApp = { +Timings = { Class = "TimingDataSource" } - +AtcaIopConfigEoWo_DS = { - Class = AtcaIop::AtcaIopConfigEoWo - //CPUMask = "0xC" + +AtcaIopConfig_DS = { + Class = AtcaIop::AtcaIopConfig + CPUMask = "0x020" DeviceName = "/dev/atca_v6" - BoardId = 2 //Mandatory + BoardId = 9 Signals = { EO = { Type = int32 //Mandatory. Only type that is supported. @@ -1303,9 +1309,9 @@ $IsttokApp = { } +AtcaIopDac_DS = { Class = "AtcaIop::AtcaIopDAC" - //CPUMask = "0xC" + CPUMask = "0x020" DeviceName = "/dev/atca_v6" - BoardId = 2 //Mandatory + BoardId = 9 //NumberOfChannels = 2 Signals = { DAC0 = { @@ -1321,14 +1327,14 @@ $IsttokApp = { } +AtcaIopAdc_DS = { Class = "AtcaIop::AtcaIopADC" - CPUMask = "0xC" + CPUMask = "0x040" DeviceName = "/dev/atca_v6" - BoardId = 2 //Mandatory + BoardId = 9 DeviceDmaName = "/dev/atca_v6_dmart_2" NumberOfChannels = "12" IsMaster = "1" SleepNature = "Busy" - SleepPercentage = "40" + SleepPercentage = "50" ADCFrequency = "2000000" RTDecimation = "200" ChopperPeriod = "2000" @@ -1446,7 +1452,7 @@ $IsttokApp = { +SignalsWriter = { Class = "MDSWriter::MDSWriter" NumberOfBuffers = "120000" - CPUMask = "0x10" + CPUMask = "0x080" StackSize = "10000000" TreeName = "rtappisttok" StoreOnTrigger = "0" @@ -1716,7 +1722,7 @@ $IsttokApp = { +EPICSCAOutput = { Class = "EPICSCA::EPICSCAOutput" StackSize = "1048576" - CPUs = "0x10" + CPUs = "0x010" IgnoreBufferOverrun = "1" NumberOfBuffers = "10" Signals = { @@ -1741,7 +1747,7 @@ $IsttokApp = { +EPICSCAInput = { Class = "EPICSCA::EPICSCAInput" StackSize = "1048576" //Optional the EmbeddedThread stack size. Default value is THREADS_DEFAULT_STACKSIZE * 4u - CPUs = "0xf0" //Optional the affinity of the EmbeddedThread (where the EPICS context is attached). + CPUs = "0x0F0" //Optional the affinity of the EmbeddedThread (where the EPICS context is attached). Signals = { PVEo = { //At least one shall be defined PVName = "ISTTOK:central:ATCAIOP1-EO" //Compulsory. Name of the PV. @@ -1757,7 +1763,7 @@ $IsttokApp = { +EPICSCAOutputHist = { Class = "EPICSCA::EPICSCAOutput" StackSize = "1048576" - CPUs = "0x10" + CPUs = "0x010" IgnoreBufferOverrun = "1" NumberOfBuffers = "10" Signals = { @@ -1780,7 +1786,7 @@ $IsttokApp = { Class = "ReferenceContainer" +Thread1 = { Class = "RealTimeThread" - CPUs = "0x8" + CPUs = "0x100" //Functions = {"AtcaGAMInput" "DacConstants" "AtcaGAMOutput" "GAMConvert2Volt" "GAMConvert2Float" "GAMHistogramCycleTimes" "GAMCAOutput"} Functions = {"AtcaGAMInput" "DacConstants" "AtcaGAMOutput" "AtcaGAMEoWoOutput" "GAMConvert2Volt" "GAMConvert2Float" "GAMHistogramCycleTimes" "GAMCAOutput" "GAMCAInput"} @@ -1793,7 +1799,7 @@ $IsttokApp = { Class = "ReferenceContainer" +Thread1 = { Class = "RealTimeThread" - CPUs = "0x8" + CPUs = "0x100" Functions = {"AtcaGAMInput" "DacConstants" "AtcaGAMOutput" "AtcaGAMEoWoOutput" "GAMConvert2Volt" "GAMConvert2Float" "GAMHistogramCycleTimes" "GAMCAOutput" "GAMCAInput" "GAMSignalsWriter"} } } @@ -1804,7 +1810,7 @@ $IsttokApp = { Class = "ReferenceContainer" +Thread1 = { Class = "RealTimeThread" - CPUs = "0x8" + CPUs = "0x100" Functions = {"AtcaGAMInput"} } } diff --git a/DataSources/AtcaIop/AtcaIopConfig.cpp b/DataSources/AtcaIop/AtcaIopConfig.cpp new file mode 100644 index 0000000..67903c0 --- /dev/null +++ b/DataSources/AtcaIop/AtcaIopConfig.cpp @@ -0,0 +1,354 @@ +/** + * @file AtcaIopConfig.cpp + * @brief Source file for class AtcaIopConfig + * @date 19/04/2024 + * @author Andre Neto / Bernardo Carvalho + * + * @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 AtcaIopConfig (public, protected, and private). Be aware that some + * methods, such as those inline could be defined on the header file, instead. + * + */ + +#define DLL_API + +/*---------------------------------------------------------------------------*/ +/* Standard header includes */ +/*---------------------------------------------------------------------------*/ +#include + +#include // for close() +//#include + +/*---------------------------------------------------------------------------*/ +/* Project header includes */ +/*---------------------------------------------------------------------------*/ +#include "MemoryMapSynchronisedOutputBroker.h" + +#include "AtcaIopConfig.h" +#include "atca-v6-iop-ioctl.h" + +/*---------------------------------------------------------------------------*/ +/* Static definitions */ +/*---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------*/ +/* Method definitions */ +/*---------------------------------------------------------------------------*/ +namespace MARTe { + const float32 DAC_RANGE = 20.0; + const float32 ATCA_IOP_MAX_DAC_RANGE = 20.0; + AtcaIopConfig::AtcaIopConfig() : + DataSourceI(), + MessageI() { + devFileDescriptor = -1; + //numberOfDACsEnabled = 0u; + //isMaster = 0u; + deviceName = ""; + boardId = 0u; + triggerSet = false; + uint32 n; + synchCounter = 0u; + + //channelsMemory = NULL_PTR(float32 *); + eoValues = NULL_PTR(int32 *); + woValues = NULL_PTR(float32 *); + eoWriteFlag = false; + + filter = ReferenceT(GlobalObjectsDatabase::Instance()->GetStandardHeap()); + filter->SetDestination(this); + ErrorManagement::ErrorType ret = MessageI::InstallMessageFilter(filter); + if (!ret.ErrorsCleared()) { + REPORT_ERROR(ErrorManagement::FatalError, "Failed to install message filters"); + } + } + + /*lint -e{1551} the destructor must guarantee that the Timer SingleThreadService is stopped.*/ + AtcaIopConfig::~AtcaIopConfig() { + if (devFileDescriptor != -1) { + uint32 statusReg = 0; + close(devFileDescriptor); + REPORT_ERROR(ErrorManagement::Information, "Close device %d OK. Status Reg 0x%x,", devFileDescriptor, statusReg); + } + if (eoValues != NULL_PTR(int32 *)) { + delete[] eoValues; + } + if (woValues != NULL_PTR(float32 *)) { + delete[] woValues; + } + //if (channelsMemory != NULL_PTR(float32 *)) { + //delete[] channelsMemory; + //} + } + + bool AtcaIopConfig::AllocateMemory() { + return true; + } + + uint32 AtcaIopConfig::GetNumberOfMemoryBuffers() { + return 1u; + } + + /*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: The memory buffer is independent of the bufferIdx.*/ + bool AtcaIopConfig::GetSignalMemoryBuffer(const uint32 signalIdx, const uint32 bufferIdx, void*& signalAddress) { + //bool ok = (signalIdx < (ATCA_IOP_EOWO_N_SIGNALS)); + bool ok = true; + if (signalIdx == 0u) { + signalAddress = &eoValues[0]; + } + else if (signalIdx == 1u) { + signalAddress = woValues; //&counterAndTimer[1]; + } + else { + ok = false; + } + /* + bool ok = (signalIdx < (ATCA_IOP_MAX_DAC_CHANNELS)); + if (ok) { + if (channelsMemory != NULL_PTR(float32 *)) { + signalAddress = &(channelsMemory[signalIdx]); + } + } + */ + return ok; + } + + const char8* AtcaIopConfig::GetBrokerName(StructuredDataI& data, const SignalDirection direction) { + const char8 *brokerName = NULL_PTR(const char8 *); + if (direction == OutputSignals) { + uint32 trigger = 0u; + if (!data.Read("Trigger", trigger)) { + trigger = 0u; + } + + if (trigger == 1u) { + brokerName = "MemoryMapSynchronisedOutputBroker"; + triggerSet = true; + } + else { + brokerName = "MemoryMapOutputBroker"; + } + } + else { + REPORT_ERROR(ErrorManagement::ParametersError, "DataSource not compatible with InputSignals"); + } + return brokerName; + } + + bool AtcaIopConfig::GetInputBrokers(ReferenceContainer& inputBrokers, const char8* const functionName, void* const gamMemPtr) { + return false; + } + + bool AtcaIopConfig::GetOutputBrokers(ReferenceContainer& outputBrokers, const char8* const functionName, void* const gamMemPtr) { + //Check if there is a Trigger signal for this function. + uint32 functionIdx = 0u; + uint32 nOfFunctionSignals = 0u; + uint32 i; + bool triggerGAM = false; + bool ok = GetFunctionIndex(functionIdx, functionName); + + if (ok) { + ok = GetFunctionNumberOfSignals(OutputSignals, functionIdx, nOfFunctionSignals); + } + uint32 trigger = 0u; + for (i = 0u; (i < nOfFunctionSignals) && (ok) && (!triggerGAM); i++) { + ok = GetFunctionSignalTrigger(OutputSignals, functionIdx, i, trigger); + triggerGAM = (trigger == 1u); + } + if ((ok) && (triggerGAM)) { + ReferenceT broker("MemoryMapSynchronisedOutputBroker"); + ok = broker.IsValid(); + + if (ok) { + ok = broker->Init(OutputSignals, *this, functionName, gamMemPtr); + } + if (ok) { + ok = outputBrokers.Insert(broker); + } + //Must also add the signals which are not triggering but that belong to the same GAM... + if (ok) { + if (nOfFunctionSignals > 1u) { + ReferenceT brokerNotSync("MemoryMapOutputBroker"); + ok = brokerNotSync.IsValid(); + if (ok) { + ok = brokerNotSync->Init(OutputSignals, *this, functionName, gamMemPtr); + } + if (ok) { + ok = outputBrokers.Insert(brokerNotSync); + } + } + } + } + else { + ReferenceT brokerNotSync("MemoryMapOutputBroker"); + ok = brokerNotSync.IsValid(); + if (ok) { + ok = brokerNotSync->Init(OutputSignals, *this, functionName, gamMemPtr); + } + if (ok) { + ok = outputBrokers.Insert(brokerNotSync); + } + } + return ok; + } + + /*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: the counter and the timer are always reset irrespectively of the states being changed.*/ + bool AtcaIopConfig::PrepareNextState(const char8* const currentStateName, const char8* const nextStateName) { + return true; + } + + bool AtcaIopConfig::Initialise(StructuredDataI& data) { + bool ok = DataSourceI::Initialise(data); + if (ok) { + ok = data.Read("DeviceName", deviceName); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, "The DeviceName shall be specified"); + } + } + if (ok) { + ok = data.Read("BoardId", boardId); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, "The BoardId shall be specified"); + } + } + + + return ok; + } + + bool AtcaIopConfig::SetConfiguredDatabase(StructuredDataI& data) { + uint32 i; + bool ok = DataSourceI::SetConfiguredDatabase(data); + + if (ok) { + ok = triggerSet; + } + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, "At least one Trigger signal shall be set."); + } + + // Check the signal index + uint32 nOfSignals = GetNumberOfSignals(); + if (ok) { + ok = (nOfSignals > 0u); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, "At least one signal shall be defined"); + } + } + if (ok) { + ok = (GetSignalType(0).type == SignedInteger); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, "EO signal shall be of type SignedInteger"); + } + else { + //In member function ‘virtual bool MARTe::AtcaIopConfig::SetConfiguredDatabase(MARTe::StructuredDataI&)’: + //AtcaIopConfig.cpp:311:49: error: no match for ‘operator==’ (operand types are ‘MARTe::BitRange’ and ‘const MARTe::TypeDescriptor’) + ok = (GetSignalType(1) == Float32Bit); + if (!ok) { + REPORT_ERROR(ErrorManagement::ParametersError, "WO signal shall be of type Float32Bit"); + } + } + } + uint32 nOfFunctions = GetNumberOfFunctions(); + uint32 functionIdx; + StreamString fullDeviceName; + + //Configure the board + if (ok) { + ok = fullDeviceName.Printf("%s_eo_%d", deviceName.Buffer(), boardId); + } + if (ok) { + ok = fullDeviceName.Seek(0LLU); + } + if (ok) { + devFileDescriptor = open(fullDeviceName.Buffer(), O_RDWR); + ok = (devFileDescriptor > -1); + if (!ok) { + REPORT_ERROR_PARAMETERS(ErrorManagement::ParametersError, "Could not open device %s", fullDeviceName); + } + else + REPORT_ERROR(ErrorManagement::Information, "Open device %s OK", fullDeviceName); + } + if (ok) { + //Allocate memory + eoValues = new int32[ATCA_IOP_MAX_ADC_CHANNELS]; + woValues = new float32[ATCA_IOP_MAX_ADC_CHANNELS]; + } + + return ok; + } + + + bool AtcaIopConfig::Synchronise() { + bool ok = true; +/* +#ifdef DEBUG_POLL + if((synchCounter++)%4096 == 0) { + //i = (synchCounter/4096) & 0xF; + REPORT_ERROR(ErrorManagement::Information, "Synchronise eo0:%d wo0%0.3f", eoValues[0], woValues[0]); + } +#endif +*/ + if (eoWriteFlag) { + eoWriteFlag = false; + ok = IoWriteEoWo(); + // REPORT_ERROR(ErrorManagement::Information, "AtcaIopConfig::Synchronise. Do IoWriteEoWO!"); + } + return ok; + } + + ErrorManagement::ErrorType AtcaIopConfig::WriteEoWo() { + ErrorManagement::ErrorType err; + REPORT_ERROR(ErrorManagement::Information, "AtcaIopConfig::WriteEoWo. Got Message!"); + + //ret = err.ErrorsCleared(); + eoWriteFlag = true; + return err; + } + + bool AtcaIopConfig::IoWriteEoWo() { + bool ok = true; + int rv; + uint32 i; + struct atca_eo_config eo_conf; + struct atca_wo_config wo_conf; + + for (i=0u; i < ATCA_IOP_MAX_ADC_CHANNELS; i++) { + eo_conf.offset[i] = eoValues[i]; + wo_conf.offset[i] = static_cast(woValues[i] * 65536); + } + rv = ioctl(devFileDescriptor, ATCA_PCIE_IOPS_EO_OFFSETS, &eo_conf); + if (rv ) { + REPORT_ERROR(ErrorManagement::ParametersError, "Fail Write eo0:%d", eoValues[0]); + ok = false; + } + rv = ioctl(devFileDescriptor, ATCA_PCIE_IOPS_WO_OFFSETS, &wo_conf); + if (rv ) { + REPORT_ERROR(ErrorManagement::ParametersError, "Fail Write wo0:%6.3f", woValues[0]); + ok = false; + } + rv = ioctl(devFileDescriptor, ATCA_PCIE_IOPT_RST_INTEG); + if (rv ) { + REPORT_ERROR(ErrorManagement::ParametersError, "Fail reset Integrators"); + ok = false; + } + return ok; + } + + CLASS_REGISTER(AtcaIopConfig, "1.0") + CLASS_METHOD_REGISTER(AtcaIopConfig, WriteEoWo) + +} +// vim: syntax=cpp ts=4 sw=4 sts=4 sr et diff --git a/DataSources/AtcaIop/AtcaIopConfig.h b/DataSources/AtcaIop/AtcaIopConfig.h new file mode 100644 index 0000000..d1f8eb2 --- /dev/null +++ b/DataSources/AtcaIop/AtcaIopConfig.h @@ -0,0 +1,257 @@ +/** + * @file AtcaIopConfig.h + * @brief Header file for class AtcaIopConfig + * @date 19/04/2024 + * @author Andre Neto / Bernardo Carvalho + * + * Based on Example: + * + * + * @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 AtcaIopConfig + * 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 ATCA_IOP_DAC_H +#define ATCA_IOP_DAC_H + +/*---------------------------------------------------------------------------*/ +/* Standard header includes */ +/*-------DTYP--------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------*/ +/* Project header includes */ +/*---------------------------------------------------------------------------*/ +#include "AdvancedErrorManagement.h" +#include "CLASSMETHODREGISTER.h" +#include "DataSourceI.h" +//#include "EventSem.h" +//#include "EmbeddedServiceMethodBinderI.h" +//#include "SingleThreadService.h" +#include "MessageI.h" +#include "RegisteredMethodsMessageFilter.h" + +/*---------------------------------------------------------------------------*/ +/* Class declaration */ +/*---------------------------------------------------------------------------*/ +namespace MARTe { + + /** + * The number of signals + */ + + //const uint32 ATCA_IOP_N_DACs = 2u; + const uint32 ATCA_IOP_EOWO_N_SIGNALS = 2u; + //const uint32 ATCA_IOP_MAX_DAC_CHANNELS = 16u; + const uint32 ATCA_IOP_MAX_ADC_CHANNELS = 16u; + +/** + * @brief A DataSource which provides an analogue output interface to the ATCA IOP boards. + * @details The configuration syntax is (names are only given as an example): + * + *
+ * +AtcaIopConfig_2 = {
+ *     Class = AtcaIop::AtcaIopConfig
+ *     DeviceName = "/dev/atca_v6" //Mandatory
+ *     BoardId = 0 //Mandatory
+ *     Signals = {
+ *         EO = {
+ *             Type = int32 //Mandatory. Only type that is supported.
+ *         }
+ *         WO = {
+ *             Type = float32 //Mandatory. Only type that is supported.
+ *         }
+ *     }
+ * }
+ * 
+ * Note that at least one of the GAMs writing to this DataSource must have set one of the signals with Trigger=1 (which forces the writing of all the signals to the DAC). + */ + class AtcaIopConfig: public DataSourceI, public MessageI { + public: + CLASS_REGISTER_DECLARATION() + /** + * @brief Default constructor + * @post + * Counter = 0 + * Time = 0 + */ + AtcaIopConfig (); + + /** + * @brief Destructor. Stops the EmbeddedThread. + */ + virtual ~AtcaIopConfig(); + + /** + * @brief See DataSourceI::AllocateMemory. + * * @return true. + */ + virtual bool AllocateMemory(); + + /** + gg* @brief See DataSourceI::GetNumberOfMemoryBuffers. + * @return 1. + */ + virtual uint32 GetNumberOfMemoryBuffers(); + + /** + * @brief See DataSourceI::GetSignalMemoryBuffer. + */ + virtual bool GetSignalMemoryBuffer(const uint32 signalIdx, + const uint32 bufferIdx, + void *&signalAddress); + + + /** + * @brief See DataSourceI::GetNumberOfMemoryBuffers. + * @details Only OutputSignals are supported. + * @return MemoryMapSynchronisedOutputBroker if Trigger == 1 for any of the signals, MemoryMapOutputBroker otherwise. + */ + 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 If the functionName is one of the functions which requested a Trigger, + * it adds a MemoryMapSynchronisedOutputBroker instance to the outputBrokers, + * otherwise it adds a MemoryMapOutputBroker instance to the outputBrokers. + * @param[out] outputBrokers where the BrokerI instances have to be added to. + * @param[in] functionName name of the function being queried. + * @param[in] gamMemPtr the GAM memory where the signals will be read from. + * @return true if the outputBrokers can be successfully configured. + */ + virtual bool GetOutputBrokers(ReferenceContainer &outputBrokers, + const char8* const functionName, + void * const gamMemPtr); + + + /** + * @brief See StatefulI::PrepareNextState. + * @details 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. + uint32 synchCounter; + */ + + virtual bool Initialise(StructuredDataI & data); + + + /** + * @brief Final verification of all the parameters and setup of the board configuration. + * @details This method verifies that all the parameters (e.g. number of samples) requested by the GAMs interacting with this DataSource + * are valid and consistent with the board parameters set during the initialisation phase. + * In particular the following conditions shall be met: + * - At least one triggering signal was requested by a GAM (with the property Trigger = 1) + * - All the DAC channels have type float32. + uint32 synchCounter; + * - The number of samples of all the DAC channels is exactly one. + * @return true if all the parameters are valid and consistent with the board parameters and if the board can be successfully configured with + * these parameters. + */ + virtual bool SetConfiguredDatabase(StructuredDataI & data); + + + /** + * @details Writes the value of all the DAC channels to the board. + * @return true if the writing of all the channels is successful. + */ + virtual bool Synchronise(); + + /** + * @brief Set flag to write Eo, Wo Synchronisly + * @details This method + * It can be called within a + * MARTe message. + */ + //ErrorManagement::ErrorType Reset(); + ErrorManagement::ErrorType WriteEoWo(); + + + private: + /** + * The board device name + */ + StreamString deviceName; + /** + * The board identifier + */ + uint32 boardId; + + /** + * The board file descriptor + */ + int32 devFileDescriptor; + + uint32 synchCounter; + /** + * DAC values + */ +// int32 dacValues[ATCA_IOP_N_DACs]; + + /** + * EO values Signal + */ + int32 *eoValues; + + /** + * WO valuesa Signal + */ + float32 *woValues; + + bool eoWriteFlag; + + /** + * The signal memory + */ +// float32 *channelsMemory; + + + /** + * Filter to receive the RPC which allows to change the... + */ + ReferenceT filter; + + /** + * True if at least one trigger was set. + */ + bool triggerSet; + + bool IoWriteEoWo(); + //int32 SetDacReg(uint32 channel, float32 val) const; + + }; +} + +/*---------------------------------------------------------------------------*/ +/* Inline method definitions */ +/*---------------------------------------------------------------------------*/ + +#endif /* ATCA_IOP_DAC_H */ + +// vim: syntax=cpp ts=4 sw=4 sts=4 sr et diff --git a/DataSources/AtcaIop/Makefile.inc b/DataSources/AtcaIop/Makefile.inc index bc67379..207cb02 100644 --- a/DataSources/AtcaIop/Makefile.inc +++ b/DataSources/AtcaIop/Makefile.inc @@ -22,7 +22,7 @@ # ############################################################# -OBJSX=AtcaIopDAC.x AtcaIopADC.x AtcaIopConfigEoWo.x +OBJSX=AtcaIopDAC.x AtcaIopADC.x AtcaIopConfig.x PACKAGE=Components/DataSources