Compare commits

..

No commits in common. "main" and "0.1.0" have entirely different histories.
main ... 0.1.0

4 changed files with 2 additions and 13 deletions

View File

@ -2,7 +2,4 @@ FROM archlinux:latest
RUN pacman --noconfirm -Sy gcc make RUN pacman --noconfirm -Sy gcc make
COPY . . COPY . .
RUN make RUN make
RUN pacman --noconfirm -Rnsu gcc make
RUN useradd batstat
USER batstat
CMD [ "build/batstat" ] CMD [ "build/batstat" ]

View File

@ -12,12 +12,10 @@ namespace dlore
std::string Technology; std::string Technology;
unsigned int CellSeriesCount; unsigned int CellSeriesCount;
unsigned int Capacity; unsigned int Capacity;
unsigned int CapacityDesign;
float Vnow; float Vnow;
float Vmin; float Vmin;
unsigned int ChargeNow; unsigned int ChargeNow;
unsigned int ChargeFull; unsigned int ChargeFull;
unsigned int ChargeFullPercentageDesign;
unsigned int ChargeFullDesign; unsigned int ChargeFullDesign;
} typedef BatteryInfo; } typedef BatteryInfo;

View File

@ -7,7 +7,7 @@ namespace dlore
std::string readData(std::filesystem::path path) std::string readData(std::filesystem::path path)
{ {
std::ifstream file(path, std::ios::in); std::ifstream file(path, std::ios::in);
if(!file) return "0"; if(!file) return "";
std::string ret; std::string ret;
std::getline(file, ret); std::getline(file, ret);
file.close(); file.close();
@ -26,11 +26,6 @@ namespace dlore
info.ChargeFull = std::stoi(readData(classPath / "charge_full")) / 1000; info.ChargeFull = std::stoi(readData(classPath / "charge_full")) / 1000;
info.ChargeFullDesign = std::stoi(readData(classPath / "charge_full_design")) / 1000; info.ChargeFullDesign = std::stoi(readData(classPath / "charge_full_design")) / 1000;
if(info.ChargeFullDesign != 0) {
info.ChargeFullPercentageDesign = 100 * info.ChargeFull / info.ChargeFullDesign;
info.CapacityDesign = 100 * info.ChargeNow / info.ChargeFullDesign;
}
int Vnow = std::stoi(readData(classPath / "voltage_now")) / 1000; int Vnow = std::stoi(readData(classPath / "voltage_now")) / 1000;
int Vmin = std::stoi(readData(classPath / "voltage_min_design")) / 1000; int Vmin = std::stoi(readData(classPath / "voltage_min_design")) / 1000;

View File

@ -16,13 +16,12 @@ void printBattery(std::filesystem::path classPath)
std::cout << std::endl << "\tTechnology: " << bat.Technology; std::cout << std::endl << "\tTechnology: " << bat.Technology;
std::cout << std::endl << "\tCell series count: " << bat.CellSeriesCount << 's' << std::endl; std::cout << std::endl << "\tCell series count: " << bat.CellSeriesCount << 's' << std::endl;
std::cout << std::endl << "\tCapacity: " << bat.Capacity << '%'; std::cout << std::endl << "\tCapacity: " << bat.Capacity << '%';
std::cout << std::endl << "\tCapacity (design): " << bat.CapacityDesign << '%';
std::cout << std::endl << "\tVmin: " << bat.Vmin << 'V'; std::cout << std::endl << "\tVmin: " << bat.Vmin << 'V';
std::cout << " Per cell: " << bat.Vmin / bat.CellSeriesCount << 'V'; std::cout << " Per cell: " << bat.Vmin / bat.CellSeriesCount << 'V';
std::cout << std::endl << "\tVnow: " << bat.Vnow << 'V'; std::cout << std::endl << "\tVnow: " << bat.Vnow << 'V';
std::cout << " Per cell: " << bat.Vnow / bat.CellSeriesCount << 'V'; std::cout << " Per cell: " << bat.Vnow / bat.CellSeriesCount << 'V';
std::cout << std::endl << "\tCharge now: " << bat.ChargeNow << "mAh"; std::cout << std::endl << "\tCharge now: " << bat.ChargeNow << "mAh";
std::cout << std::endl << "\tCharge full: " << bat.ChargeFull << "mAh (" << bat.ChargeFullPercentageDesign << "% of design)"; std::cout << std::endl << "\tCharge full: " << bat.ChargeFull << "mAh";
std::cout << std::endl << "\tCharge full (design): " << bat.ChargeFullDesign << "mAh" << std::endl; std::cout << std::endl << "\tCharge full (design): " << bat.ChargeFullDesign << "mAh" << std::endl;
} }