2024-03-12 23:26:23 +01:00
|
|
|
#include <iostream>
|
2024-03-13 00:18:10 +01:00
|
|
|
#include <string>
|
2024-03-13 16:54:03 +01:00
|
|
|
#include <chrono>
|
|
|
|
|
#include <thread>
|
|
|
|
|
|
2024-03-13 00:18:10 +01:00
|
|
|
#include "modbus.h"
|
2024-03-16 21:15:15 +01:00
|
|
|
#include "dtu.h"
|
2024-03-12 23:26:23 +01:00
|
|
|
|
|
|
|
|
int main(){
|
|
|
|
|
|
2024-03-13 00:18:10 +01:00
|
|
|
std::string ip_address {"192.168.31.136"};
|
|
|
|
|
int port {502};
|
|
|
|
|
|
2024-03-18 22:58:12 +01:00
|
|
|
auto startTime = std::chrono::high_resolution_clock::now();
|
2024-03-16 22:51:32 +01:00
|
|
|
Dtu dtu {ip_address.c_str(), port};
|
2024-03-18 22:58:12 +01:00
|
|
|
auto endTime = std::chrono::high_resolution_clock::now();
|
2024-03-18 23:48:37 +01:00
|
|
|
std::cout << "Construction time: " << std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count() << "ms" << std::endl;
|
2024-03-18 22:58:12 +01:00
|
|
|
|
2024-03-19 12:54:05 +01:00
|
|
|
while(dtu.isConnected()) {
|
2024-03-18 22:58:12 +01:00
|
|
|
auto startTime = std::chrono::high_resolution_clock::now();
|
2024-03-16 22:51:32 +01:00
|
|
|
dtu.updateMicroinverters();
|
2024-03-18 22:58:12 +01:00
|
|
|
auto endTime = std::chrono::high_resolution_clock::now();
|
2024-03-18 23:48:37 +01:00
|
|
|
std::cout << "Update time: " << std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count() << "ms" << std::endl;
|
|
|
|
|
dtu.printMicroinverters();
|
2024-03-16 22:51:32 +01:00
|
|
|
}
|
2024-03-15 11:46:44 +01:00
|
|
|
|
2024-03-12 23:26:23 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|