Files
pip/main.cpp
T
2026-09-22 20:38:15 +03:00

71 lines
2.1 KiB
C++

#include "libs/http_client/curl_thread_pool_p.h"
#include "picodeparser.h"
#include "pidigest.h"
#include "pihttpclient.h"
#include "piliterals.h"
#include "pimqttclient.h"
#include "pip.h"
#include "piunits.h"
#include "pivaluetree_conversions.h"
using namespace PICoutManipulators;
using namespace PIHTTP;
PIKbdListener kbd;
int main(int argc, char * argv[]) {
PIEthernet tcp(PIEthernet::TCP_Server);
tcp.setReadAddress("0.0.0.0:26000");
CONNECTL(&tcp, newConnection, [](PIEthernet * c) { piCout << "New client" << c; });
piForTimes(10) {
piCout << "\nlisten";
tcp.listen(true);
3_s .sleep();
piCout << "stop" << tcp.isOpened();
tcp.stopThreadedListen();
100_ms .sleep();
}
return 0;
// piCout << "ifconfigPath:" << PISystemInfo::instance()->ifconfigPath;
// piCout << " execCommand:" << PISystemInfo::instance()->execCommand;
// piCout << " hostname:" << PISystemInfo::instance()->hostname;
// piCout << " user:" << PISystemInfo::instance()->user;
// piCout << " OS_name:" << PISystemInfo::instance()->OS_name;
// piCout << " OS_version:" << PISystemInfo::instance()->OS_version;
// piCout << "architecture:" << PISystemInfo::instance()->architecture;
// piCout << "execDateTime:" << PISystemInfo::instance()->execDateTime;
// piCout << PISystemInfo::instance()->processorsCount << PISystemInfo::instance()->processorsCountP
// << PISystemInfo::instance()->processorsCountE;
// piCout << "hello мир!"_u8;
// PISerial ser("/dev/ttyUSB0");
// ser.open();
// return 0;
int i = 0;
PIThreadPoolLoop pool(8);
pool.setPowerPolicy(PIThread::ppEfficiency);
pool.setFunction([&i](int) { i = piHash(i); });
pool.start(0, 0x7FFFFFFF);
piSleep(10);
// PIVector<PIThread *> threads;
// for (int i = 0; i < 8; ++i) {
// threads << new PIThread();
// }
// for (auto * t: threads) {
// t->setPowerPolicy(PIThread::ppPerformance);
// t->start([&i] { i = piHash(i); });
// }
// piSleep(10);
// for (auto * t: threads) {
// t->stopAndWait();
// }
// piDeleteAllAndClear(threads);
return 0;
kbd.enableExitCapture('Q');
WAIT_FOR_EXIT
piCout << "exiting ...";
}