86 lines
1.9 KiB
C++
86 lines
1.9 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_ */
|