Moved to updated library
This commit is contained in:
parent
381dcbdc57
commit
098d944793
10 changed files with 15 additions and 26 deletions
|
|
@ -55,7 +55,7 @@ void Dtu::populateMicroinverters() {
|
|||
getMicroinverterBySerialNumber.second->ports.push_back(port);
|
||||
}
|
||||
else {
|
||||
Microinverter microinverter{ this->modbus_context, serialNumber };
|
||||
Microinverter microinverter{ this->modbus, serialNumber };
|
||||
this->microinverters.push_back(microinverter);
|
||||
this->microinverters.back().ports.push_back(port);
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ void Dtu::populateMicroinverters() {
|
|||
portStartAddress += 0x0028;
|
||||
|
||||
// this->modbus_context_mutex.lock();
|
||||
registerCount = modbus_read_registers(*this->modbus_context.get(), portStartAddress + 0x0021, 1, readArray);
|
||||
registerCount = this->modbus.get()->modbus_read_holding_registers(portStartAddress + 0x0021, 1, readArray);
|
||||
// this->modbus_context_mutex.unlock();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,8 @@
|
|||
#include "microinverter.h"
|
||||
#include "port.h"
|
||||
|
||||
struct _modbus;
|
||||
typedef _modbus modbus_t;
|
||||
|
||||
Microinverter::Microinverter(std::shared_ptr<modbus_t*> modbus_context, long serialNumber) {
|
||||
this->modbus_context = modbus_context;
|
||||
Microinverter::Microinverter(std::shared_ptr<class modbus> modbus, long serialNumber) {
|
||||
this->modbus = modbus;
|
||||
// this->modbus_context_mutex = modbus_context_mutex;
|
||||
|
||||
this->serialNumber = serialNumber;
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
#include "port.h"
|
||||
#include "portParameters.h"
|
||||
|
||||
Port::Port(std::shared_ptr<modbus_t*> modbus_context, uint16_t portStartAddress) {
|
||||
this->modbus_context = modbus_context;
|
||||
Port::Port(std::shared_ptr<class modbus> modbus, uint16_t portStartAddress) {
|
||||
this->modbus = modbus;
|
||||
// this->modbus_context_mutex = modbus_context_mutex;
|
||||
|
||||
this->portStartAddress = portStartAddress;
|
||||
|
|
@ -71,7 +71,7 @@ void Port::fixCurrent() {
|
|||
void Port::updateParameters() {
|
||||
std::vector<std::shared_ptr<PortParameter>>::iterator parametersIterator{this->parameters.begin()};
|
||||
while (parametersIterator != this->parameters.end()) {
|
||||
parametersIterator->get()->updateValue(this->modbus_context, this->portStartAddress);
|
||||
parametersIterator->get()->updateValue(this->modbus, this->portStartAddress);
|
||||
parametersIterator++;
|
||||
}
|
||||
this->fixCurrent();
|
||||
|
|
|
|||
|
|
@ -8,9 +8,6 @@
|
|||
|
||||
#include "portParametersGeneric.h"
|
||||
|
||||
struct _modbus;
|
||||
typedef _modbus modbus_t;
|
||||
|
||||
PortParameter::PortParameter(std::string name, uint16_t parameterAddressOffset, int registerSize) {
|
||||
this->name = name;
|
||||
|
||||
|
|
@ -32,18 +29,19 @@ std::string PortParameter::getOutputValue() {
|
|||
return "yeet";
|
||||
}
|
||||
|
||||
void PortParameter::updateValue(std::shared_ptr<modbus_t*> modbus_context, uint16_t portStartAddress) {
|
||||
void PortParameter::updateValue(std::shared_ptr<class modbus> modbus, uint16_t portStartAddress) {
|
||||
uint16_t readArray[this->registerSize];
|
||||
int registerCount;
|
||||
|
||||
// modbus_context_mutex->lock();
|
||||
registerCount = modbus_read_registers(*modbus_context.get(), portStartAddress + this->parameterAddressOffset, this->registerSize, readArray);
|
||||
registerCount = modbus.get()->modbus_read_holding_registers(portStartAddress + this->parameterAddressOffset, this->registerSize, readArray);
|
||||
// modbus_context_mutex->unlock();
|
||||
|
||||
if(registerCount == -1){
|
||||
if(registerCount != 0){
|
||||
this->age++;
|
||||
}
|
||||
else{
|
||||
registerCount = this->registerSize;
|
||||
this->setValueFromRegisters(readArray, registerCount);
|
||||
this->age = 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue