:c
This commit is contained in:
parent
8eb18c12d2
commit
fd6476cd6e
10 changed files with 258 additions and 4 deletions
34
src/hoymiles/sunspec.cpp
Normal file
34
src/hoymiles/sunspec.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <memory>
|
||||
|
||||
#include "sunspec.h"
|
||||
#include "modbus.h"
|
||||
#include "sunspecParameters.h"
|
||||
|
||||
Sunspec::Sunspec(int address, std::shared_ptr<class modbus> modbus) {
|
||||
this->modbus = modbus;
|
||||
this->sunspecAddress = address;
|
||||
|
||||
this->populateParameters();
|
||||
|
||||
this->setValues();
|
||||
}
|
||||
|
||||
void Sunspec::setValues() {
|
||||
uint16_t registers[70];
|
||||
|
||||
int registerCount;
|
||||
registerCount = this->modbus.get()->modbus_read_holding_registers(this->sunspecAddress, 70, registers);
|
||||
|
||||
std::vector<std::shared_ptr<SunspecParameter>>::iterator parametersIterator = this->parameters.begin();
|
||||
while(parametersIterator != this->parameters.end()) {
|
||||
parametersIterator->get()->setValueFromRegisters(registers, 0);
|
||||
parametersIterator++;
|
||||
}
|
||||
}
|
||||
|
||||
void Sunspec::populateParameters() {
|
||||
SunspecParameterManufacturer manufacturer{};
|
||||
this->parameters.push_back(std::make_shared<SunspecParameterManufacturer>(manufacturer));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue