From dd731eff3115a6b3875c53e674cb84b9dfb88762 Mon Sep 17 00:00:00 2001 From: xkzou Date: Tue, 17 Nov 2020 13:50:45 +0800 Subject: [PATCH] 增加†产品id 授权 --- src/left_over/RegionSurveillanceProcess.h | 4 +++- src/left_over/ms_region_surveilance.cpp | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 65 insertions(+), 19 deletions(-) diff --git a/src/left_over/RegionSurveillanceProcess.h b/src/left_over/RegionSurveillanceProcess.h index 5d0b2d6..a7ea1b0 100644 --- a/src/left_over/RegionSurveillanceProcess.h +++ b/src/left_over/RegionSurveillanceProcess.h @@ -54,8 +54,10 @@ public: double scale; //int long_side; //int short_side; + rs_auth_type type; std::atomic thrd_run; - //boost::thread thrd; + int licence_status = -1; + int thrd_status = -1; long frame_num = 0; bool init_flag = false; sy_rect rect[MAXVERTEXNUM]; //Ч diff --git a/src/left_over/ms_region_surveilance.cpp b/src/left_over/ms_region_surveilance.cpp index 92b7fe8..3c58592 100644 --- a/src/left_over/ms_region_surveilance.cpp +++ b/src/left_over/ms_region_surveilance.cpp @@ -6,9 +6,44 @@ #include #include "sy_errorinfo.h" #include +#include "authority.h" //#define productSN "D92CBC0CFBA54BD3846DEBD4A9D36FC1" #define productSN "B5895C36B5304C9A9FE665A372BFFDA2" + +//void check_thread(RegionSurveillanceProcess* &handle, char* productsn) +//{ +// int res = -1; +//#ifndef _MSC_VER +// char wtime[15]; +// memset(wtime, 0, 15); +// char * time = wtime; +//#endif +// while (1) +// { +// //printf("xxx check status on process...\n"); +//#ifdef _MSC_VER +// res = sy_licence(productsn); +//#else +// res = sy_licence(productsn, &time); +// //printf("--------------wtime in thread: %s, status: %d\n", wtime, licence_status); +//#endif +// if (res < 0) +// { +// handle->licence_status = handle->licence_status - 1; +// } +// else +// { +// if (handle->licence_status < 0) +// { +// handle->licence_status = 0; +// } +// } +// boost::this_thread::sleep(boost::posix_time::seconds(300)); //5min +// } +//} + + //void check_thread(RegionSurveillanceProcess* handle) //{ // int res = -1; @@ -82,32 +117,42 @@ inline bool timecheck() int rs_init(void **handle, rs_param param) { - int ret = SUCCESS; + RegionSurveillanceProcess* regin = new IRegionSurveillanceCpu; + regin->type = param.type; + int ret = SUCCESS; bool auth_type = false; - if (param.type == TIME) - { - auth_type = timecheck(); - } - else + if(param.type == PRODUCT_ID) { char uuid[36] = {}; FILE *Uuid = fopen("/proc/sys/kernel/random/uuid", "r"); fgets(uuid, 36, Uuid); - //strcpy(uuid,"059bebb1-fca2-42e6-8cbd-6b3195641819"); fclose(Uuid); regin->auth = new CheckAuthor; regin->auth->Init(param.auth.url, param.auth.port, uuid, productSN, 1); auth_type = regin->auth->GetAuthorStatus(); } + if (param.type == TIME) + { + +#ifdef _MSC_VER + ret = sy_licence(productSN); +#else + char wtime[15]; + memset(wtime, 0, 15); + char * time = wtime; + ret = sy_licence(productSN, &time) +#endif + if (ret == SUCCESS) + auth_type = true; + else + auth_type = false; + + } if (auth_type) { regin->frame_num = param.frame_num; - if (!regin) - { - printf("model initial failed \n"); - return -1; - } + regin->scale = param.scale; regin->rect_num = param.rect_num; //Ч @@ -186,18 +231,17 @@ int rs_init(void **handle, rs_param param) int rs_process(void *handle, sy_img img_data, rs_result *result) { - RegionSurveillanceProcess* regin = (RegionSurveillanceProcess*)handle; - if (!regin) + if (!handle) { printf("handle is NULL \n"); return -1; } - if (regin->auth && 0 == regin->auth->GetAuthorStatus()) + RegionSurveillanceProcess* regin = (RegionSurveillanceProcess*)handle; + if (regin->type == PRODUCT_ID && (regin->auth && 0 == regin->auth->GetAuthorStatus())) { printf("auth error \n"); return -1; } - region_info pRegionInfo; pRegionInfo.alarm_info = 6; pRegionInfo.frame_num = regin->frame_num; @@ -339,7 +383,7 @@ void rs_release(void **handle) printf("handle is NULL \n"); return; } - if (regin->auth) + if (regin->type == PRODUCT_ID && regin->auth) { regin->auth->Uninit(); delete regin->auth; @@ -350,6 +394,6 @@ void rs_release(void **handle) const char * rs_get_version() { - return "left_over_det_version: v0.0.2.200402,5A72239196F54B678D311E7FC11849DC"; + return "left_over_det_version: v0.0.3.201117,B5895C36B5304C9A9FE665A372BFFDA2"; } -- libgit2 0.21.4