#include "serial.h" #ifndef COMKIT_H #include #include #include #include #include namespace ranges = std::ranges; namespace views = std::ranges::views; struct ComStruct { std::string comPortName; std::string comPortInstancePath; }; template requires std::is_same_v || std::is_same_v static std::vector Split(T str, T d) { auto v = views::split(str, d) | views::transform([](auto c){return T(c.begin(), c.end());}) | views::filter([](auto word){return word != "";}); return std::vector(v.begin(), v.end()); } class ComKit { public: static bool isWorking; static serial::Serial device; static std::ostringstream oss; static std::vector *comPortNames; static std::optional GetComPortInstancePath(const std::string &comPortName); static std::optional GetUsbLocationPath(const std::string &comPortName); static std::vector *GetAllComPortNames(); static void Start(std::string, std::string); static void End(); static void Work(const std::string& port_name); static bool ChangeComPortNumber(const std::string &oldPortName, const std::string &newPortName); static std::vector watchingComPort; static std::vector commands; static std::string logContent; static void FlushLog(); static std::mutex m; static std::vector Split(std::string str); }; #endif