Rewritten the backend, made it hella faster

This commit is contained in:
TraYali 2024-03-28 19:44:54 +01:00
parent 4209d2767e
commit d7b59ea326
11 changed files with 176 additions and 144 deletions

View file

@ -27,12 +27,8 @@ class Dtu {
std::string modbusErrorMessage();
// void updateMicroinverters();
void updateMicroinverters(std::vector<std::string> &parametersToGet, bool allParameters, std::vector<long long> &microinvertersToGet);
// void printMicroinverters();
void printMicroinverters(std::vector<std::string> &parametersToGet, bool allParameters, std::vector<long long> &microinvertersToGet, bool shortNames, bool printTodayProduction, bool printTotalProduction);
~Dtu();

View file

@ -12,14 +12,20 @@ class Microinverter {
private:
std::shared_ptr<class modbus> modbus;
int startAddress;
public:
Microinverter(std::shared_ptr<class modbus> modbus, long long serialNumber);
Microinverter(std::shared_ptr<class modbus> modbus, int startAddress, long long serialNumber);
long long serialNumber;
int age;
std::vector<Port> ports;
void updatePorts(std::vector<std::string> &parametersToGet, bool allParameters);
// void updatePorts(std::vector<std::string> &parametersToGet, bool allParameters);
void updateParameters(std::vector<std::string> &parametersToGet, bool allParameters);
void printPorts(std::vector<std::string> &parametersToGet, bool allParameters, bool shortNames);

View file

@ -10,17 +10,15 @@
class Port {
private:
std::shared_ptr<class modbus> modbus;
void populateParameters();
void fixCurrent();
bool currentFixed;
void increaseParametersAge();
// void increaseParametersAge();
public:
Port(std::shared_ptr<class modbus> modbus, int portStartAddress);
Port(int portStartAddress);
int portStartAddress;
@ -28,7 +26,9 @@ class Port {
std::pair<std::shared_ptr<PortParameter>, bool> getParameterByName(std::string name);
void updateParameters(std::vector<std::string> &parametersToGet, bool allParameters);
// void updateParameters(std::vector<std::string> &parametersToGet, bool allParameters);
void setParametersFromMicroinverterArray(uint8_t *registers, int addressOffset);
void printParameters(std::vector<std::string> &parametersToGet, bool allParameters, bool shortNames);
};

View file

@ -5,16 +5,13 @@
class PortParameterMicroinverterSerialNumber : public PortParameterInt {
private:
void setValueFromRegisters(uint16_t *readArray, int registerCount);
void setValueFromRegisters(uint8_t *registers, int addressOffset);
public:
PortParameterMicroinverterSerialNumber();
};
class PortParameterPortNumber : public PortParameterInt {
private:
void setValueFromRegisters(uint16_t *readArray, int registerCount);
public:
PortParameterPortNumber();
};

View file

@ -13,8 +13,6 @@ class PortParameter {
uint16_t parameterAddressOffset;
int registerSize;
virtual void setValueFromRegisters(uint16_t *readArray, int registerCount);
public:
PortParameter(std::string name, std::string shortName, uint16_t parameterAddressOffset, int registerSize);
@ -35,35 +33,38 @@ class PortParameter {
std::string name;
std::string shortName;
int age;
// int age;
std::pair<PortParameterValue, PortParameterValueType> getValue();
virtual std::string getOutputValue();
void updateValue(std::shared_ptr<class modbus> modubs, uint16_t portStartAddress);
virtual void setValueFromRegisters(uint8_t *registers, int addressOffset);
// void updateValue(std::shared_ptr<class modbus> modubs, uint16_t portStartAddress);
};
class PortParameterFloat : public PortParameter {
protected:
int decimalPlaces;
virtual void setValueFromRegisters(uint16_t *readArray, int registerCount);
public:
PortParameterFloat(std::string name, std::string shortName, int decimalPlaces, uint16_t parameterAddressOffset, int registerSize);
std::string getOutputValue();
virtual void setValueFromRegisters(uint8_t *registers, int addressOffset);
};
class PortParameterInt : public PortParameter {
protected:
virtual void setValueFromRegisters(uint16_t *readArray, int registerCount);
public:
PortParameterInt(std::string name, std::string shortName, uint16_t parameterAddressOffset, int registerSize);
std::string getOutputValue();
virtual void setValueFromRegisters(uint8_t *registers, int addressOffset);
};
#endif