66 lines
1.3 KiB
C++
66 lines
1.3 KiB
C++
|
|
/*
|
|||
|
|
* StorableValue.hh
|
|||
|
|
*
|
|||
|
|
* Created on: 3 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>. 2020 <EFBFBD>.
|
|||
|
|
* Author: <EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#ifndef UMLIBRARY_SCHEMATIC_STORABLEVALUE_HH_
|
|||
|
|
#define UMLIBRARY_SCHEMATIC_STORABLEVALUE_HH_
|
|||
|
|
|
|||
|
|
#include "../systemic/IValueAsync.hpp"
|
|||
|
|
#include "../systemic/IProcess.hh"
|
|||
|
|
#include "../peripheral/IMemoryAccess.hh"
|
|||
|
|
|
|||
|
|
namespace schematic {
|
|||
|
|
|
|||
|
|
//!<21><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
|
/*!<21><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
|
*
|
|||
|
|
*/
|
|||
|
|
class StorableValue : public systemic::IValueType<float>, public systemic::IProcess {
|
|||
|
|
public:
|
|||
|
|
struct Constraints {
|
|||
|
|
float min;
|
|||
|
|
float max;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
StorableValue( const Constraints &, peripheral::IMemoryAccess & memory, std::size_t offset, float default_value );
|
|||
|
|
|
|||
|
|
void set( float value );
|
|||
|
|
float get() const;
|
|||
|
|
|
|||
|
|
const float & value() const;
|
|||
|
|
const bool & valid() const;
|
|||
|
|
|
|||
|
|
void process();
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
float current_value;
|
|||
|
|
const float default_value;
|
|||
|
|
bool need_set = false;
|
|||
|
|
|
|||
|
|
enum {
|
|||
|
|
read,
|
|||
|
|
waitReadComplete,
|
|||
|
|
write,
|
|||
|
|
waitWriteComplete,
|
|||
|
|
idle,
|
|||
|
|
} value_state;
|
|||
|
|
|
|||
|
|
Constraints limits;
|
|||
|
|
|
|||
|
|
static const size_t buff_size = sizeof(float) + 1;
|
|||
|
|
char buff[buff_size];
|
|||
|
|
bool is_value_valid;
|
|||
|
|
|
|||
|
|
peripheral::IMemoryAccess & memory;
|
|||
|
|
const std::size_t offset;
|
|||
|
|
|
|||
|
|
char calcCrcValue( float value );
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endif /* UMLIBRARY_SCHEMATIC_STORABLEVALUE_HH_ */
|