MotorControlModuleSDFM_TMS3.../Projects/EFC_Application/UMLibrary/driver/TableAdcResult.hh

86 lines
1.8 KiB
C++

/*
* TableAdcResult.h
*
* Created on: 29 èþë. 2019 ã.
* Author: titov
*/
#ifndef SOURCE_DRIVER_TABLEADCRESULT_H_
#define SOURCE_DRIVER_TABLEADCRESULT_H_
#include "../peripheral/IAdcResult.hpp"
#include <cstddef>
#include <stdint.h>
namespace driver {
class TableAdcResult {
public:
typedef uint16_t Id;
/*!\brief Êîíñòðóêòîð òàáëèöû ïðèíèìàåò áóôôåð äàííûõ.
* \detail
* \param[in] data Òàáëèöà ðåçóëüòàòîâ â ïîðÿäêå èõ ðåãèñòðàöèè.
* \param[in] buff Òàáëèöà ðåçóëüòàòîâ.
*
*/
TableAdcResult( volatile const uint16_t * * data,
volatile const uint16_t * * buff, Id size );
uint32_t sum() const;
bool is_filled() const;
bool attach( peripheral::IAdcResult<uint16_t> * result, Id position );
virtual ~TableAdcResult() = default;
protected:
volatile const uint16_t * * const buff;
Id quantity;
volatile const uint16_t * * const data;
const Id size;
};
class TableAdcAsAdcChannel : public TableAdcResult {
public:
TableAdcAsAdcChannel( volatile const uint16_t * * result,
volatile const uint16_t * * buff, Id size ) : TableAdcResult( result, buff, size ) {}
operator uint32_t() const;
};
class TableAdcAsValue : public TableAdcResult {
public:
TableAdcAsValue( volatile const uint16_t * * result,
volatile const uint16_t * * buff, Id size ) : TableAdcResult( result, buff, size ), result(0),
coeff(0), offset(0) {}
const volatile float & getValue() const;
struct Setting {
float coeff;
float offset;
bool isValid() const;
};
bool configure( Setting & config );
void process();
protected:
float result;
float coeff;
float offset;
};
}
#endif /* SOURCE_DRIVER_TABLEADCRESULT_H_ */