diff --git a/MeoAssistance/InfrastConfiger.cpp b/MeoAssistance/InfrastConfiger.cpp new file mode 100644 index 0000000000..6bbe771675 --- /dev/null +++ b/MeoAssistance/InfrastConfiger.cpp @@ -0,0 +1,68 @@ +#include "InfrastConfiger.h" + +#include +#include + +#include +#include "Logger.hpp" + +using namespace asst; + +bool InfrastConfiger::load(const std::string& filename) +{ + DebugTraceFunction; + DebugTrace("Configer::load | ", filename); + + InfrastConfiger temp; + if (temp._load(filename)) { + *this = std::move(temp); + return true; + } + else { + return false; + } +} + +bool InfrastConfiger::_load(const std::string& filename) +{ + std::ifstream ifs(filename, std::ios::in); + if (!ifs.is_open()) { + return false; + } + std::stringstream iss; + iss << ifs.rdbuf(); + ifs.close(); + std::string content(iss.str()); + + auto&& ret = json::parser::parse(content); + if (!ret) { + DebugTrace("parse error", content); + return false; + } + + json::value root = ret.value(); + try { + // վ + for (json::value& comb_info : root["Manufacturing"]["combs"].as_array()) + { + std::vector comb_vec; + for (json::value& oper_name : comb_info["comb"].as_array()) + { + std::string oper_name_str = oper_name.as_string(); + m_mfg_opers.emplace(oper_name_str); + comb_vec.emplace_back(std::move(oper_name_str)); + } + m_mfg_combs.emplace_back(std::move(comb_vec)); + } + m_mfg_end = root["Manufacturing"]["end"].as_string(); + + // óվ TODO + } + catch (json::exception& e) { + DebugTraceError("Load config json error!", e.what()); + return false; + } + DebugTrace("Load config succeed"); + + return true; +} \ No newline at end of file diff --git a/MeoAssistance/MeoAssistance.vcxproj b/MeoAssistance/MeoAssistance.vcxproj index 630f320157..cd0ef8ffbe 100644 --- a/MeoAssistance/MeoAssistance.vcxproj +++ b/MeoAssistance/MeoAssistance.vcxproj @@ -26,25 +26,28 @@ + - + + - + - + + @@ -155,7 +158,7 @@ true true true - NDEBUG;_CONSOLE;CSHARP_API;MEO_DLL_EXPORTS;%(PreprocessorDefinitions) + NDEBUG;_CONSOLE;MEO_DLL_EXPORTS;%(PreprocessorDefinitions) true stdcpp17 stdc11 @@ -196,7 +199,7 @@ xcopy /e /y /i $(SolutionDir)3rdPart\resource $(TargetDir)resource false true - NDEBUG;_CONSOLE;CSHARP_API;MEO_DLL_EXPORTS;LOG_TRACE;%(PreprocessorDefinitions) + NDEBUG;_CONSOLE;MEO_DLL_EXPORTS;LOG_TRACE;DEBUG_API;%(PreprocessorDefinitions) true stdcpp17 stdc11 diff --git a/MeoAssistance/MeoAssistance.vcxproj.filters b/MeoAssistance/MeoAssistance.vcxproj.filters index 8c07d230c9..f09ac5310a 100644 --- a/MeoAssistance/MeoAssistance.vcxproj.filters +++ b/MeoAssistance/MeoAssistance.vcxproj.filters @@ -13,20 +13,23 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + {07a812fe-6b28-4be0-b6d4-33554824d3c5} + + + {74bd94e1-4973-412a-a17a-d8457de387af} + + + {87c9dee5-847b-41e6-818e-387a6385ea8b} + - - 头文件 - 头文件 头文件 - - 头文件 - 头文件 @@ -36,32 +39,35 @@ 头文件 - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - 头文件 + + 头文件\configer + + + 头文件\configer + + + 头文件\configer + + + 头文件\type + + + 头文件\type + + + 头文件\type + + + 头文件\type + + + 头文件\type + - - 源文件 - - - 源文件 - 源文件 @@ -74,18 +80,30 @@ 源文件 - - 源文件 - 源文件 + + 源文件\configer + + + 源文件 + + + 源文件\configer + + + 源文件\configer + 资源文件 - + + 资源文件 + + 资源文件 diff --git a/MeoAssistance/include/Assistance.h b/MeoAssistance/include/Assistance.h index 9175d575ef..828cdd2020 100644 --- a/MeoAssistance/include/Assistance.h +++ b/MeoAssistance/include/Assistance.h @@ -29,11 +29,14 @@ namespace asst { // ʼˢ bool start_sanity(); - // ʼʻ + // ʼʺѻ bool start_visit(); // ʼļ bool start_open_recruit(const std::vector& required_level, bool set_time = true); + // ʼ + bool start_infrast(); + // ʼƥ񣬵 bool start_match_task(const std::string& task, int retry_times = ProcessTaskRetryTimesDefault, bool block = true); // ʼOCRԣ @@ -43,6 +46,9 @@ namespace asst { bool set_param(const std::string& type, const std::string& param, const std::string& value); + // + bool swipe(const Point& p1, const Point& p2); + static constexpr int ProcessTaskRetryTimesDefault = 20; static constexpr int OpenRecruitTaskRetyrTimesDefault = 5; diff --git a/MeoAssistance/include/AsstCaller.h b/MeoAssistance/include/AsstCaller.h index 77429eeca6..055010ca6d 100644 --- a/MeoAssistance/include/AsstCaller.h +++ b/MeoAssistance/include/AsstCaller.h @@ -18,10 +18,12 @@ extern "C" { MEOAPI_PORT void AsstStop(asst::Assistance* p_asst); MEOAPI_PORT bool AsstSetParam(asst::Assistance* p_asst, const char* type, const char* param, const char* value); MEOAPI_PORT bool AsstRunOpenRecruit(asst::Assistance* p_asst, const int required_level[], bool set_time); + MEOAPI_PORT bool AsstStartInfrast(asst::Assistance* p_asst); MEOAPI_PORT bool AsstTestOcr(asst::Assistance* p_asst, const char** text_array, int array_size, bool need_click); MEOAPI_PORT bool CheckVersionUpdate(char* tag_buffer, int tag_bufsize, char* html_url_buffer, int html_bufsize, char* body_buffer, int body_bufsize); + MEOAPI_PORT bool AsstTestSwipe(asst::Assistance* p_asst, int x1, int y1, int x2, int y2); #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/MeoAssistance/include/AsstDef.h b/MeoAssistance/include/AsstDef.h index e5ce23a76f..e0d1e190d0 100644 --- a/MeoAssistance/include/AsstDef.h +++ b/MeoAssistance/include/AsstDef.h @@ -103,6 +103,7 @@ namespace asst { std::string path; std::string connect; std::string click; + std::string swipe; std::string display; std::string display_regex; int display_width = 0; diff --git a/MeoAssistance/include/Configer.h b/MeoAssistance/include/Configer.h index 2705c135ba..bf4e006cef 100644 --- a/MeoAssistance/include/Configer.h +++ b/MeoAssistance/include/Configer.h @@ -2,7 +2,6 @@ #include #include -#include #include #include "AsstDef.h" @@ -22,9 +21,6 @@ namespace asst { bool set_param(const std::string& type, const std::string& param, const std::string& value); - Configer& operator=(const Configer& rhs) = default; - Configer& operator=(Configer&& rhs) noexcept = default; - constexpr static int DefaultWindowWidth = 1280; constexpr static int DefaultWindowHeight = 720; constexpr static double Defaulttempl_threshold = 0.9; @@ -42,6 +38,9 @@ namespace asst { Configer(const Configer& rhs) = default; Configer(Configer&& rhs) noexcept = default; + Configer& operator=(const Configer& rhs) = default; + Configer& operator=(Configer && rhs) noexcept = default; + bool _load(const std::string& filename); }; } diff --git a/MeoAssistance/include/Identify.h b/MeoAssistance/include/Identify.h index 6b3fcfb0fa..fe5d1df02f 100644 --- a/MeoAssistance/include/Identify.h +++ b/MeoAssistance/include/Identify.h @@ -29,7 +29,7 @@ namespace asst { std::tuple find_image(const cv::Mat& image, const std::string& templ, double templ_threshold); // for debug - void feature_matching(const cv::Mat& mat); + std::vector