Commit 7c5cf8c9ed41fd1e9e273665e8ae9122ea2fc732
1 parent
7ded47c9
优化GetTaskStatus接口
Showing
5 changed files
with
19 additions
and
89 deletions
src/ai_platform/Makefile deleted
1 | -# 各项目录 | ||
2 | -LIB_DIR:=$(BUILD_DIR)/$(MODULE)/lib | ||
3 | -DEP_DIR:=$(BUILD_DIR)/$(MODULE)/.dep | ||
4 | -OBJ_DIR:=$(BUILD_DIR)/$(MODULE)/obj | ||
5 | -SRC_DIR:=$(TOP_DIR)/$(MODULE) | ||
6 | - | ||
7 | -# 源文件以及中间目标文件和依赖文件 | ||
8 | -SRCS:=$(notdir $(wildcard $(SRC_DIR)/*.cpp)) | ||
9 | -OBJS:=$(addprefix $(OBJ_DIR)/, $(patsubst %.cpp, %.o, $(SRCS))) | ||
10 | -DEPS:=$(addprefix $(DEP_DIR)/, $(patsubst %.cpp, %.d,a $(SRCS))) | ||
11 | - | ||
12 | -# 自动生成头文件依赖选项 | ||
13 | -DEPFLAGS=-MT $@ -MMD -MP -MF $(DEP_DIR)/$*.d | ||
14 | - | ||
15 | -DEFS = -DENABLE_DVPP_INTERFACE | ||
16 | - | ||
17 | -# 最终目标文件 | ||
18 | -TARGET:=$(BUILD_DIR)/bin/demo | ||
19 | - | ||
20 | - | ||
21 | -include_dir=-I/usr/local/Ascend/ascend-toolkit/6.3.RC1.alpha001/runtime/include | ||
22 | - | ||
23 | -lib_dir=-L/usr/lib \ | ||
24 | - -L/usr/local/lib \ | ||
25 | - -L/usr/local/Ascend/driver/lib64 \ | ||
26 | - -L/usr/local/Ascend/ascend-toolkit/6.3.RC1.alpha001/atc/lib64\ | ||
27 | - -L/usr/local/Ascend/ascend-toolkit/6.3.RC1.alpha001/runtime/lib64 \ | ||
28 | - -L/usr/local/Ascend/ascend-toolkit/6.3.RC1.alpha001/runtime/lib64/stub \ | ||
29 | - -L/usr/local/Ascend/ascend-toolkit/6.3.RC1.alpha001/lib64 \ | ||
30 | - -L/usr/local/Ascend/driver/lib64/driver | ||
31 | - | ||
32 | -lib=-lacl_dvpp -lascendcl -lmmpa -lglog -lgflags -lpthread -lz -lacl_dvpp_mpi -lruntime -lascendalog -lc_sec -lmsprofiler -lgert -lge_executor -lge_common \ | ||
33 | - -lgraph -lascend_protobuf -lprofapi -lerror_manager -lexe_graph -lregister -lplatform | ||
34 | - | ||
35 | -INCLUDE= -I $(TOP_DIR)/interface \ | ||
36 | - | ||
37 | -LIBSPATH= -L $(BUILD_DIR)/interface/lib -l:interface.a \ | ||
38 | - -L $(BUILD_DIR)/dvpp/lib -l:dvpp.a | ||
39 | - | ||
40 | -CXXFLAGS= -g -O0 -fPIC $(INCLUDE) $(include_dir) $(LIBSPATH) $(INCS) $(LIBS) $(lib_dir) $(lib) $(DEFS) -lpthread -lrt -lz -fexceptions -std=c++11 -fvisibility=hidden -Wl,-Bsymbolic -ldl | ||
41 | - # -DUNICODE -D_UNICODE | ||
42 | - | ||
43 | -# 默认最终目标 | ||
44 | -.PHONY:all | ||
45 | -all:$(TARGET) | ||
46 | - | ||
47 | -# 生成最终目标 | ||
48 | -$(TARGET): $(OBJS) | $(LIB_DIR) | ||
49 | - @echo -e "\e[32m""Linking static library $(TARGET)""\e[0m" | ||
50 | - @echo -e "$(CXX) -o $@ $^ $(DEPFLAGS) $(CXXFLAGS) $(MACROS)" | ||
51 | - $(CXX) -o $@ $^ $(DEPFLAGS) $(CXXFLAGS) $(MACROS) | ||
52 | - | ||
53 | -# 若没有lib目录则自动生成 | ||
54 | -$(LIB_DIR): | ||
55 | - @mkdir -p $@ | ||
56 | - | ||
57 | -# 生成中间目标文件 | ||
58 | -$(OBJ_DIR)/%.o:$(SRC_DIR)/%.cpp $(DEP_DIR)/%.d | $(OBJ_DIR) $(DEP_DIR) | ||
59 | - @echo -e "\e[33m""Building object $@""\e[0m" | ||
60 | - @echo -e "$(CXX) -c $(DEPFLAGS) $(CXXFLAGS) -o $@ $<" | ||
61 | - $(CXX) -c $(DEPFLAGS) $(CXXFLAGS) -o $@ $< | ||
62 | - | ||
63 | -# 若没有obj目录则自动生成 | ||
64 | -$(OBJ_DIR): | ||
65 | - @mkdir -p $@ | ||
66 | - | ||
67 | -# 若没有.dep目录则自动生成 | ||
68 | -$(DEP_DIR): | ||
69 | - @mkdir -p $@ | ||
70 | - | ||
71 | -# 依赖文件会在生成中间文件的时候自动生成,这里只是为了防止报错 | ||
72 | -$(DEPS): | ||
73 | - | ||
74 | -# 引入中间目标文件头文件依赖关系 | ||
75 | -include $(wildcard $(DEPS)) | ||
76 | - | ||
77 | -# 直接删除组件build目录 | ||
78 | -.PHONY:clean | ||
79 | -clean: | ||
80 | - @rm -rf $(BUILD_DIR)/$(MODULE) |
src/ai_platform/MultiSourceProcess.cpp
@@ -300,6 +300,8 @@ int CMultiSourceProcess::AddMqConn(mq_type_t mq_type, rabbitmq_conn_params_t mq_ | @@ -300,6 +300,8 @@ int CMultiSourceProcess::AddMqConn(mq_type_t mq_type, rabbitmq_conn_params_t mq_ | ||
300 | return SUCCESS; | 300 | return SUCCESS; |
301 | } | 301 | } |
302 | 302 | ||
303 | +#endif | ||
304 | + | ||
303 | /* 获取任务的状态 MQ返回 */ | 305 | /* 获取任务的状态 MQ返回 */ |
304 | int CMultiSourceProcess::GetTaskStatus(const string taskID) { | 306 | int CMultiSourceProcess::GetTaskStatus(const string taskID) { |
305 | 307 | ||
@@ -307,22 +309,30 @@ int CMultiSourceProcess::GetTaskStatus(const string taskID) { | @@ -307,22 +309,30 @@ int CMultiSourceProcess::GetTaskStatus(const string taskID) { | ||
307 | 309 | ||
308 | std::vector<std::string> taskids; | 310 | std::vector<std::string> taskids; |
309 | std::vector<int> statues; | 311 | std::vector<int> statues; |
312 | + int sta = 0; | ||
310 | if(pDecManager->isPausing(taskID)){ | 313 | if(pDecManager->isPausing(taskID)){ |
311 | taskids.emplace_back(taskID); | 314 | taskids.emplace_back(taskID); |
312 | statues.emplace_back(2); | 315 | statues.emplace_back(2); |
313 | - }else if(pDecManager->isRunning(taskID)){ | 316 | + sta = 2; |
317 | + } else if(pDecManager->isRunning(taskID)){ | ||
314 | taskids.emplace_back(taskID); | 318 | taskids.emplace_back(taskID); |
315 | statues.emplace_back(1); | 319 | statues.emplace_back(1); |
320 | + sta = 1; | ||
321 | + } else if(pDecManager->isFinished(taskID)){ | ||
322 | + taskids.emplace_back(taskID); | ||
323 | + statues.emplace_back(0); | ||
324 | + sta = 0; | ||
316 | } | 325 | } |
317 | 326 | ||
327 | +#ifdef POST_USE_RABBITMQ | ||
318 | if (!taskids.empty()) { | 328 | if (!taskids.empty()) { |
319 | auto json_str = helpers::gen_json::gen_task_status_json(taskids, statues); | 329 | auto json_str = helpers::gen_json::gen_task_status_json(taskids, statues); |
320 | mq_manager_->publish(mq_type_t::GET_TASK_MQ, json_str.c_str(),true); | 330 | mq_manager_->publish(mq_type_t::GET_TASK_MQ, json_str.c_str(),true); |
321 | } | 331 | } |
332 | +#endif | ||
322 | 333 | ||
323 | - return SUCCESS; | 334 | + return sta; |
324 | } | 335 | } |
325 | -#endif | ||
326 | 336 | ||
327 | bool CMultiSourceProcess::AddTask(task_param _cur_task_param){ | 337 | bool CMultiSourceProcess::AddTask(task_param _cur_task_param){ |
328 | DecoderManager* pDecManager = DecoderManager::getInstance(); | 338 | DecoderManager* pDecManager = DecoderManager::getInstance(); |
src/ai_platform/MultiSourceProcess.h
@@ -52,9 +52,10 @@ public: | @@ -52,9 +52,10 @@ public: | ||
52 | 52 | ||
53 | #ifdef POST_USE_RABBITMQ | 53 | #ifdef POST_USE_RABBITMQ |
54 | int AddMqConn(mq_type_t mq_type, rabbitmq_conn_params_t mq_conn_param); | 54 | int AddMqConn(mq_type_t mq_type, rabbitmq_conn_params_t mq_conn_param); |
55 | - int GetTaskStatus(const string taskID); | ||
56 | #endif | 55 | #endif |
57 | 56 | ||
57 | +int GetTaskStatus(const string taskID); | ||
58 | + | ||
58 | public: | 59 | public: |
59 | int algorthim_process_thread(); // 算法处理线程 | 60 | int algorthim_process_thread(); // 算法处理线程 |
60 | void task_finished(const string task_id); | 61 | void task_finished(const string task_id); |
src/ai_platform/stl_aiplatform.cpp
@@ -25,14 +25,14 @@ int add_mq_conn(void *handle, mq_type_t tstatus, rabbitmq_conn_params_t mq_conn_ | @@ -25,14 +25,14 @@ int add_mq_conn(void *handle, mq_type_t tstatus, rabbitmq_conn_params_t mq_conn_ | ||
25 | return tools->AddMqConn(tstatus, mq_conn_param); | 25 | return tools->AddMqConn(tstatus, mq_conn_param); |
26 | } | 26 | } |
27 | 27 | ||
28 | +#endif | ||
29 | + | ||
28 | int get_task_status(void *handle, char *task_id) | 30 | int get_task_status(void *handle, char *task_id) |
29 | { | 31 | { |
30 | CMultiSourceProcess* tools = (CMultiSourceProcess*)handle; | 32 | CMultiSourceProcess* tools = (CMultiSourceProcess*)handle; |
31 | return tools->GetTaskStatus(task_id); | 33 | return tools->GetTaskStatus(task_id); |
32 | } | 34 | } |
33 | 35 | ||
34 | -#endif | ||
35 | - | ||
36 | int add_task(void *handle, task_param param) | 36 | int add_task(void *handle, task_param param) |
37 | { | 37 | { |
38 | CMultiSourceProcess* tools = (CMultiSourceProcess*)handle; | 38 | CMultiSourceProcess* tools = (CMultiSourceProcess*)handle; |
src/ai_platform/stl_aiplatform.h
@@ -43,12 +43,11 @@ extern "C" | @@ -43,12 +43,11 @@ extern "C" | ||
43 | */ | 43 | */ |
44 | TSL_AIPLATFORM_API int add_mq_conn(void *handle, mq_type_t tstatus, rabbitmq_conn_params_t mq_conn_param); | 44 | TSL_AIPLATFORM_API int add_mq_conn(void *handle, mq_type_t tstatus, rabbitmq_conn_params_t mq_conn_param); |
45 | 45 | ||
46 | +#endif | ||
46 | 47 | ||
47 | - | 48 | + |
48 | TSL_AIPLATFORM_API int get_task_status(void *handle, char *task_id); | 49 | TSL_AIPLATFORM_API int get_task_status(void *handle, char *task_id); |
49 | 50 | ||
50 | -#endif | ||
51 | - | ||
52 | /************************************************************************* | 51 | /************************************************************************* |
53 | * FUNCTION: add_task | 52 | * FUNCTION: add_task |
54 | * PURPOSE: 添加任务 | 53 | * PURPOSE: 添加任务 |