FIrs
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* @file SineArrayGAM.h
|
||||
* @brief GAM that fills a float32 array with a continuous sinusoidal waveform.
|
||||
* @date 15/05/2026
|
||||
* @author Martino Ferrari
|
||||
*
|
||||
* @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 Each Execute() call fills one float32 output array with N samples of:
|
||||
* v[k] = Amplitude * sin(2π * Frequency * (sampleOffset + k) / SamplingRate + Phase) + Offset
|
||||
*
|
||||
* The sampleOffset accumulates across calls so the waveform phase is continuous.
|
||||
*
|
||||
* Configuration:
|
||||
* <pre>
|
||||
* +MyGAM = {
|
||||
* Class = SineArrayGAM
|
||||
* Frequency = 1000.0 // Signal frequency in Hz (default 1.0)
|
||||
* Amplitude = 1.0 // Signal amplitude (default 1.0)
|
||||
* Offset = 0.0 // DC offset (default 0.0)
|
||||
* Phase = 0.0 // Phase in radians (default 0.0)
|
||||
* SamplingRate = 1000000.0 // Sample rate in Hz; must match UDPStreamer signal (default 1000000.0)
|
||||
* OutputSignals = {
|
||||
* Ch1 = { DataSource = DDB; Type = float32; NumberOfElements = 1000 }
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* Exactly one output signal of type float32 is required.
|
||||
*/
|
||||
|
||||
#ifndef SINEARRAYGAM_H_
|
||||
#define SINEARRAYGAM_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "CompilerTypes.h"
|
||||
#include "GAM.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
namespace MARTe {
|
||||
|
||||
class SineArrayGAM : public GAM {
|
||||
public:
|
||||
CLASS_REGISTER_DECLARATION()
|
||||
|
||||
/**
|
||||
* @brief Constructor. Sets safe defaults.
|
||||
*/
|
||||
SineArrayGAM();
|
||||
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~SineArrayGAM();
|
||||
|
||||
/**
|
||||
* @brief Reads Frequency, Amplitude, Offset, Phase, SamplingRate from config.
|
||||
*/
|
||||
virtual bool Initialise(StructuredDataI &data);
|
||||
|
||||
/**
|
||||
* @brief Resolves the output signal pointer and element count.
|
||||
* @return true if exactly one float32 output signal is present.
|
||||
*/
|
||||
virtual bool Setup();
|
||||
|
||||
/**
|
||||
* @brief Fills the output array with the next N sinusoidal samples.
|
||||
* @return true always.
|
||||
*/
|
||||
virtual bool Execute();
|
||||
|
||||
private:
|
||||
float64 frequency; /**< Signal frequency [Hz] */
|
||||
float64 amplitude; /**< Signal amplitude */
|
||||
float64 offset; /**< DC offset */
|
||||
float64 phase; /**< Phase offset [radians] */
|
||||
float64 samplingRate; /**< Sample rate [Hz] */
|
||||
uint32 nElements; /**< Number of output elements per cycle */
|
||||
uint64 sampleOffset; /**< Cumulative sample count for continuous phase */
|
||||
float32 *outputBuf; /**< Pointer to the output signal memory */
|
||||
};
|
||||
|
||||
} /* namespace MARTe */
|
||||
|
||||
#endif /* SINEARRAYGAM_H_ */
|
||||
Reference in New Issue
Block a user