| | |
| | | # nngæ¬å°æå¡å°å |
| | | server_url=tcp://127.0.0.1:8801 |
| | | |
| | | # server_url=tcp://192.168.20.104:8801 |
| | | server_url=tcp://192.168.20.104:7701 |
| | | # nngè¿ç¨è°ç¨å°åå°å |
| | | client_url=tcp://127.0.0.1:7701 |
| | | client_url=tcp://192.168.20.104:7702 |
| | | # client_url=tcp://192.168.20.10:8802 |
| | | |
| | | # å¿è·³æå¡å¨ |
| | | heart_server=tcp://192.168.20.10:5006 |
| | | |
| | | # è´è´£ä¸è½½ä»»å¡ççº¿ç¨æ± çæ°é |
| | | workers=4 |
| | |
| | | "port" : 8000, |
| | | "username" : "admin" |
| | | }, |
| | | "11111" : { |
| | | "deviceType" : "HC", |
| | | "host" : "192.168.20.11", |
| | | "loginUUID" : "11111", |
| | | "password" : "a1234567", |
| | | "port" : 8000, |
| | | "username" : "admin" |
| | | }, |
| | | "2" : { |
| | | "deviceType" : "HC", |
| | | "host" : "192.168.20.11", |
| | |
| | | # Makefile for common library. |
| | | # |
| | | ROOT=.. |
| | | LDLIBS+=-Wl,-rpath=$(ROOT)/lib/hc:$(ROOT)/lib/hc/HCNetSDKCom:$(ROOT)/common |
| | | LDLIBS+=-Wl,-rpath=$(ROOT)/lib/hc:$(ROOT)/lib/hc/HCNetSDKCom:$(ROOT)/common:$(ROOT)/lib/jsoncpp |
| | | LDDIR += -L$(ROOT)/lib/hc -L$(ROOT)/lib/hc/HCNetSDKCom |
| | | LDDIR += -L$(ROOT)/lib/jsoncpp -L$(ROOT)/lib/nng |
| | | LDLIBS += -lhcnetsdk -lhpr -lHCCore |
| | | LDLIBS += -lpthread -ljsoncpp |
| | | LIB_NETDISK = libnetdisk.a |
| | |
| | | request.channel, |
| | | mktime(&start), |
| | | i); |
| | | |
| | | if(downloadByTime_wrapper(userid, request.channel, &start, &end, destfile) != -1) { |
| | | std::cout << "destfile:" << destfile << std::endl; |
| | | char *destfiledup = strdup(destfile); |
| | | if(downloadByTime_wrapper(userid, request.channel, &start, &end, destfiledup) != -1) { |
| | | if(files != NULL) { |
| | | // std::cout << "push destfile:" << destfile << std::endl; |
| | | files->push_back(destfile); |
| | | } |
| | | } |
| | | free(destfiledup); |
| | | |
| | | start = end; |
| | | i++; |
| | |
| | | /** |
| | | * @return success: 0, failture : -1 |
| | | */ |
| | | int HCNetdisk::downloadByTime_wrapper(long userid, int channel, struct tm *start, struct tm *end, char *destfile) { |
| | | int HCNetdisk::downloadByTime_wrapper(const long userid, const int channel, const struct tm *start, const struct tm *end, const char *destfile) { |
| | | NET_DVR_FILECOND_V40 struFileCond = {0}; |
| | | struFileCond.dwFileType = 0xFF; |
| | | |
| | |
| | | |
| | | int HCNetdisk::saveRecordFile(int userId, char * srcfile, char * destfile) |
| | | { |
| | | printf("destfile=%s\n", destfile); |
| | | int bRes = 1; |
| | | int hPlayback = 0; |
| | | //ææä»¶åä¸è½½å½å |
| | |
| | | return bRes; |
| | | } |
| | | int nPos = 0; |
| | | //ä¸è½½è¿åº¦ |
| | | for (nPos = 0; nPos < 100 && nPos >= 0; nPos = NET_DVR_GetDownloadPos(hPlayback)) |
| | | { |
| | | printf("Be downloading...%d %%\n", nPos); |
| | | sleep(1); |
| | | //ä¸è½½è¿åº¦ |
| | | //millisecond |
| | | } |
| | | printf("have got %d\n", nPos); |
| | | //忢ä¸è½½ |
| | |
| | | |
| | | private: |
| | | |
| | | int downloadByTime_wrapper(long userid, int channel, struct tm *start, struct tm *end, char *destfile); |
| | | int downloadByTime_wrapper(const long userid, const int channel, const struct tm *start, const struct tm *end, const char *destfile); |
| | | int saveRecordFile(int userId, char * srcfile, char * destfile); |
| | | |
| | | int _login(Netdisk_LoginInfo &loginInfo); |
| | |
| | | request.end.tm_year = 2020-1900; // è¿ä¸ªæ¶é´ç±»åä»1900å¼å§ç®ä½ç¬¬ä¸å¹´ |
| | | request.end.tm_mon = 4-1; // 0æ¯ç¬¬ä¸ä¸ªæ |
| | | request.end.tm_mday = 10; |
| | | request.end.tm_hour = 15; |
| | | request.end.tm_min = 20; |
| | | request.end.tm_hour = 14; |
| | | request.end.tm_min = 21; |
| | | request.end.tm_sec = 0; |
| | | |
| | | request.channel = 1; |
| | |
| | | int main() { |
| | | |
| | | Netdisk_EnvConfig config; |
| | | config.libpath = "../hclib/"; |
| | | config.libpath = "../lib/hc"; |
| | | HCNetdisk::netdisk_init(&config); |
| | | |
| | | test1(); |
| | |
| | | #include <nng/nng.h> |
| | | #include <nng/protocol/reqrep0/rep.h> |
| | | #include <nng/protocol/reqrep0/req.h> |
| | | #include <nng/protocol/survey0/survey.h> |
| | | #include <nng/protocol/survey0/respond.h> |
| | | |
| | | using namespace std; |
| | | |
| | |
| | | if ((rv = nng_recv(sock, &buf, &sz, NNG_FLAG_ALLOC)) != 0) { |
| | | fatal("nng_recv", rv); |
| | | } |
| | | |
| | | printf("RECEIVED RPC REQUEST:\n %s", buf); |
| | | jsonreader.parse(buf, request); |
| | | nng_free(buf, sz); |
| | | std::string method = request["method"].asString(); |
| | |
| | | pthread_create(&tid, NULL, worker, NULL); |
| | | } |
| | | |
| | | |
| | | void heartBeat(const char *url, const char *name) |
| | | { |
| | | nng_socket sock; |
| | | int rv; |
| | | |
| | | if ((rv = nng_respondent0_open(&sock)) != 0) { |
| | | fatal("nng_respondent0_open", rv); |
| | | } |
| | | if ((rv = nng_dial(sock, url, NULL, NNG_FLAG_NONBLOCK)) != 0) { |
| | | fatal("nng_dial", rv); |
| | | } |
| | | for (;;) { |
| | | char *buf = NULL; |
| | | size_t sz; |
| | | if ((rv = nng_recv(sock, &buf, &sz, NNG_FLAG_ALLOC)) == 0) { |
| | | printf("CLIENT (%s): RECEIVED \"%s\" SURVEY REQUEST\n", name, buf); |
| | | nng_free(buf, sz); |
| | | char response[1024]; |
| | | sprintf(response, "%s-%d", name, getpid()); |
| | | printf("CLIENT (%s): SENDING SURVEY RESPONSE:%s\n", name, response); |
| | | if ((rv = nng_send(sock, response, strlen(response) + 1, 0)) != 0) { |
| | | fatal("nng_send", rv); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | void *heart(void *vargp) |
| | | { |
| | | pthread_detach(pthread_self()); |
| | | heartBeat(config.get("heart_server").c_str(), "netdisk"); |
| | | return NULL; |
| | | } |
| | | |
| | | // å¿è·³åéè¿ç¨ |
| | | void initHeart() { |
| | | pthread_t tid; |
| | | pthread_create(&tid, NULL, heart, NULL); |
| | | } |
| | | |
| | | int main() |
| | | { |
| | | //ç¯å¢åéåå§å |
| | |
| | | hcEnvConfig.libpath = "../lib/hc"; |
| | | HCNetdisk::netdisk_init(&hcEnvConfig); |
| | | |
| | | |
| | | |
| | | registRequestHandleFun(); |
| | | |
| | | initThreadPool(); |
| | | initHeart(); |
| | | |
| | | startServer(config.get("server_url").c_str()); |
| | | |
| | |
| | | response["msg"] = rmsg; |
| | | response["payload"] = payload; |
| | | const std::string str = response.toStyledString(); |
| | | |
| | | err_msg(0, "login send back:\n %s", str.c_str()); |
| | | // nngå
é¨ä¼éæ¾buf |
| | | rv = nng_send(sock, strdup(str.c_str()), str.length(), NNG_FLAG_ALLOC); |
| | | //free(buf); |
| | |
| | | end["year"] = 2020; |
| | | end["mon"] = 4; |
| | | end["day"] = 10; |
| | | end["hour"] = 15; |
| | | end["min"] = 20; |
| | | end["hour"] = 14; |
| | | end["min"] = 30; |
| | | end["sec"] = 0; |
| | | arguments["end"] = end; |
| | | |
| | | arguments["channel"] = 1; |
| | | arguments["destpath"] = "/home/basic/data/Downloads/test"; |
| | | arguments["destpath"] = "/home/basic/data/Downloads"; |
| | | arguments["host"] = "192.168.20.11"; |
| | | arguments["port"] = 8000; |
| | | |
| | |
| | | # è§é¢æå¡çå°å |
| | | |
| | | tcp://192.168.20.104:8801 |
| | | |
| | | # æ¶æ¯ä½å®ä¹ |
| | | |
| | | |
| | | éä¿¡æ¶æ¯ä½éç¨jsonçæ°æ®æ ¼å¼ã |
| | | |
| | | ## 1. ç»å½ |