Release for adding short names
This commit is contained in:
parent
a0d06edf7b
commit
25fef43d66
10 changed files with 49 additions and 37 deletions
|
|
@ -90,7 +90,7 @@ void Dtu::updateMicroinverters(std::vector<std::string> ¶metersToGet, bool a
|
|||
}
|
||||
}
|
||||
|
||||
void Dtu::printMicroinverters(std::vector<std::string> ¶metersToGet, bool allParameters, std::vector<long long> µinvertersToGet) {
|
||||
void Dtu::printMicroinverters(std::vector<std::string> ¶metersToGet, bool allParameters, std::vector<long long> µinvertersToGet, bool shortNames) {
|
||||
if (microinvertersToGet.empty()) {
|
||||
std::vector<Microinverter>::iterator microinvertersIterator = this->microinverters.begin();
|
||||
while (microinvertersIterator != this->microinverters.end()) {
|
||||
|
|
@ -103,7 +103,7 @@ void Dtu::printMicroinverters(std::vector<std::string> ¶metersToGet, bool al
|
|||
while (microinvertersToGetIterator != microinvertersToGet.end()) {
|
||||
std::pair<bool, Microinverter *> microinverterPair = this->getMicroinverterBySerialNumber(*microinvertersToGetIterator);
|
||||
if (microinverterPair.first) {
|
||||
microinverterPair.second->printPorts(parametersToGet, allParameters);
|
||||
microinverterPair.second->printPorts(parametersToGet, allParameters, shortNames);
|
||||
}
|
||||
microinvertersToGetIterator++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ void Microinverter::updatePorts(std::vector<std::string> ¶metersToGet, bool
|
|||
}
|
||||
}
|
||||
|
||||
void Microinverter::printPorts(std::vector<std::string> ¶metersToGet, bool allParameters) {
|
||||
void Microinverter::printPorts(std::vector<std::string> ¶metersToGet, bool allParameters, bool shortNames) {
|
||||
std::cout << "Microinverter: " << this->serialNumber << std::endl;
|
||||
|
||||
std::vector<Port>::iterator portsIterator = this->ports.begin();
|
||||
while (portsIterator != this->ports.end()) {
|
||||
portsIterator->printParameters(parametersToGet, allParameters);
|
||||
portsIterator->printParameters(parametersToGet, allParameters, shortNames);
|
||||
std::cout << std::endl;
|
||||
portsIterator++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ void Port::updateParameters(std::vector<std::string> ¶metersToGet, bool allP
|
|||
}
|
||||
}
|
||||
|
||||
void Port::printParameters(std::vector<std::string> ¶metersToGet, bool allParameters) {
|
||||
void Port::printParameters(std::vector<std::string> ¶metersToGet, bool allParameters, bool shortNames) {
|
||||
if (allParameters && parametersToGet.size() < this->parameters.size()) {
|
||||
std::vector<std::shared_ptr<PortParameter>>::iterator parametersIterator = this->parameters.begin();
|
||||
while (parametersIterator != this->parameters.end()) {
|
||||
|
|
@ -134,7 +134,14 @@ void Port::printParameters(std::vector<std::string> ¶metersToGet, bool allPa
|
|||
|
||||
parameterPair = this->getParameterByName(*parametersToGetIterator);
|
||||
if (parameterPair.second) {
|
||||
std::cout << " " << parameterPair.first->name << ": " << parameterPair.first->getOutputValue() << " |";
|
||||
std::cout << " ";
|
||||
if(shortNames) {
|
||||
std::cout << parameterPair.first->shortName;
|
||||
}
|
||||
else {
|
||||
std::cout << parameterPair.first->name;
|
||||
}
|
||||
std::cout << ": " << parameterPair.first->getOutputValue() << " |";
|
||||
}
|
||||
parametersToGetIterator++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "portParameters.h"
|
||||
|
||||
PortParameterMicroinverterSerialNumber::PortParameterMicroinverterSerialNumber() : PortParameterInt("microinverterSerialNumber", 0x0001, 6), PortParameter("microinverterSerialNumber", 0x0001, 6) {}
|
||||
PortParameterMicroinverterSerialNumber::PortParameterMicroinverterSerialNumber() : PortParameterInt("microinverterSerialNumber", "mSN", 0x0001, 6) {}
|
||||
|
||||
void PortParameterMicroinverterSerialNumber::setValueFromRegisters(uint16_t *readArray, int registerCount) {
|
||||
uint16_t readValue;
|
||||
|
|
@ -20,7 +20,7 @@ void PortParameterMicroinverterSerialNumber::setValueFromRegisters(uint16_t *rea
|
|||
this->value.i = std::stoll(readValueString);
|
||||
}
|
||||
|
||||
PortParameterPortNumber::PortParameterPortNumber() : PortParameterInt("portNumber", 0x0007, 1), PortParameter("portNumber", 0x0007, 1) {}
|
||||
PortParameterPortNumber::PortParameterPortNumber() : PortParameterInt("portNumber", "pN", 0x0007, 1) {}
|
||||
|
||||
void PortParameterPortNumber::setValueFromRegisters(uint16_t *readArray, int registerCount) {
|
||||
if (registerCount > 0) {
|
||||
|
|
@ -31,28 +31,28 @@ void PortParameterPortNumber::setValueFromRegisters(uint16_t *readArray, int reg
|
|||
}
|
||||
}
|
||||
|
||||
PortParameterPvVoltage::PortParameterPvVoltage() : PortParameterFloat("pvVoltage", 1, 0x0008, 2), PortParameter("pvVoltage", 0x0008, 2) {}
|
||||
PortParameterPvVoltage::PortParameterPvVoltage() : PortParameterFloat("pvVoltage", "pvU", 1, 0x0008, 2) {}
|
||||
|
||||
PortParameterPvCurrentMi::PortParameterPvCurrentMi() : PortParameterFloat("pvCurrentMI", 1, 0x000a, 2), PortParameter("pvCurrentMI", 0x000a, 2) {}
|
||||
PortParameterPvCurrentMi::PortParameterPvCurrentMi() : PortParameterFloat("pvCurrentMI", "pvIMI", 1, 0x000a, 2) {}
|
||||
|
||||
PortParameterPvCurrentHm::PortParameterPvCurrentHm() : PortParameterFloat("pvCurrentHM", 2, 0x000a, 2), PortParameter("pvCurrentHM", 0x000a, 2) {}
|
||||
PortParameterPvCurrentHm::PortParameterPvCurrentHm() : PortParameterFloat("pvCurrentHM", "pvIHM", 2, 0x000a, 2) {}
|
||||
|
||||
PortParameterGridVoltage::PortParameterGridVoltage() : PortParameterFloat("gridVoltage", 1, 0x000c, 2), PortParameter("gridVoltage", 0x000c, 2) {}
|
||||
PortParameterGridVoltage::PortParameterGridVoltage() : PortParameterFloat("gridVoltage", "gU", 1, 0x000c, 2) {}
|
||||
|
||||
PortParameterGridFrequency::PortParameterGridFrequency() : PortParameterFloat("gridFrequency", 2, 0x000e, 2), PortParameter("gridFrequency", 0x000e, 2) {}
|
||||
PortParameterGridFrequency::PortParameterGridFrequency() : PortParameterFloat("gridFrequency", "gF", 2, 0x000e, 2) {}
|
||||
|
||||
PortParameterPvPower::PortParameterPvPower() : PortParameterFloat("pvPower", 1, 0x0010, 2), PortParameter("pvPower", 0x0010, 2) {}
|
||||
PortParameterPvPower::PortParameterPvPower() : PortParameterFloat("pvPower", "pvP", 1, 0x0010, 2) {}
|
||||
|
||||
PortParameterTodayProduction::PortParameterTodayProduction() : PortParameterInt("todayProduction", 0x0012, 2), PortParameter("todayProduction", 0x0012, 2) {}
|
||||
PortParameterTodayProduction::PortParameterTodayProduction() : PortParameterInt("todayProduction", "tdP", 0x0012, 2) {}
|
||||
|
||||
PortParameterTotalProduction::PortParameterTotalProduction() : PortParameterInt("totalProduction", 0x0014, 4), PortParameter("totalProduction", 0x0014, 4) {}
|
||||
PortParameterTotalProduction::PortParameterTotalProduction() : PortParameterInt("totalProduction", "ttP", 0x0014, 4) {}
|
||||
|
||||
PortParameterTemperature::PortParameterTemperature() : PortParameterFloat("temperature", 1, 0x0018, 2), PortParameter("temperature", 0x0018, 2) {}
|
||||
PortParameterTemperature::PortParameterTemperature() : PortParameterFloat("temperature", "t", 1, 0x0018, 2) {}
|
||||
|
||||
PortParameterOperatingStatus::PortParameterOperatingStatus() : PortParameterInt("operatingStatus", 0x001a, 2), PortParameter("operatingStatus", 0x001a, 2) {}
|
||||
PortParameterOperatingStatus::PortParameterOperatingStatus() : PortParameterInt("operatingStatus", "oS", 0x001a, 2) {}
|
||||
|
||||
PortParameterAlarmCode::PortParameterAlarmCode() : PortParameterInt("alarmCode", 0x001c, 2), PortParameter("alarmCode", 0x001c, 2) {}
|
||||
PortParameterAlarmCode::PortParameterAlarmCode() : PortParameterInt("alarmCode", "aC", 0x001c, 2) {}
|
||||
|
||||
PortParameterAlarmCount::PortParameterAlarmCount() : PortParameterInt("alarmCount", 0x001e, 2), PortParameter("alarmCount", 0x001e, 2) {}
|
||||
PortParameterAlarmCount::PortParameterAlarmCount() : PortParameterInt("alarmCount", "aCnt", 0x001e, 2) {}
|
||||
|
||||
PortParameterLinkStatus::PortParameterLinkStatus() : PortParameterInt("linkStatus", 0x020, 2), PortParameter("linkStatus", 0x020, 2) {}
|
||||
PortParameterLinkStatus::PortParameterLinkStatus() : PortParameterInt("linkStatus", "lS", 0x020, 2) {}
|
||||
|
|
@ -8,8 +8,9 @@
|
|||
|
||||
#include "portParametersGeneric.h"
|
||||
|
||||
PortParameter::PortParameter(std::string name, uint16_t parameterAddressOffset, int registerSize) {
|
||||
PortParameter::PortParameter(std::string name, std::string shortName, uint16_t parameterAddressOffset, int registerSize) {
|
||||
this->name = name;
|
||||
this->shortName = shortName;
|
||||
|
||||
this->parameterAddressOffset = parameterAddressOffset;
|
||||
this->registerSize = registerSize;
|
||||
|
|
@ -33,9 +34,7 @@ void PortParameter::updateValue(std::shared_ptr<class modbus> modbus, uint16_t p
|
|||
uint16_t readArray[this->registerSize];
|
||||
int registerCount;
|
||||
|
||||
// modbus_context_mutex->lock();
|
||||
registerCount = modbus.get()->modbus_read_holding_registers(portStartAddress + this->parameterAddressOffset, this->registerSize, readArray);
|
||||
// modbus_context_mutex->unlock();
|
||||
|
||||
if(registerCount != 0){
|
||||
this->age++;
|
||||
|
|
@ -47,7 +46,7 @@ void PortParameter::updateValue(std::shared_ptr<class modbus> modbus, uint16_t p
|
|||
}
|
||||
}
|
||||
|
||||
PortParameterFloat::PortParameterFloat(std::string name, int decimalPlaces, uint16_t parameterAddressOffset, int registerSize) : PortParameter(name, parameterAddressOffset, registerSize) {
|
||||
PortParameterFloat::PortParameterFloat(std::string name, std::string shortName, int decimalPlaces, uint16_t parameterAddressOffset, int registerSize) : PortParameter(name, shortName, parameterAddressOffset, registerSize) {
|
||||
this->decimalPlaces = decimalPlaces;
|
||||
|
||||
this->valueType = Float;
|
||||
|
|
@ -68,7 +67,7 @@ std::string PortParameterFloat::getOutputValue() {
|
|||
return valueStringStream.str().append(separator.append(std::to_string(this->age)));
|
||||
}
|
||||
|
||||
PortParameterInt::PortParameterInt(std::string name, uint16_t parameterAddressOffset, int registerSize) : PortParameter(name, parameterAddressOffset, registerSize) {
|
||||
PortParameterInt::PortParameterInt(std::string name, std::string shortName, uint16_t parameterAddressOffset, int registerSize) : PortParameter(name, shortName, parameterAddressOffset, registerSize) {
|
||||
this->valueType = Int;
|
||||
|
||||
this->value.i = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue