《管理功能接口》主要内容包括
●ut3_set_connection_checking_cycle
utility |
|
///*Utility Function
#include "hdKingAPI.h" #include "error_code.h" #include "data_types.h" #include "hd3Struct.h" #include <stdio.h> #include <string.h>
int32 main() { int32 nRet = RD_SUCCESS; HD3Connection conn; HD3PtTagProp normalTag; HD3PtTagProp tagQuery; HD3FilterItemSet filterSet; HD3FilterItem filterItem[2]; HD3Mask mask; HD3HANDLE hIter = NULL; int32 i = 0; HD3_CHARSET charset; int64 nServerTimeMs = 0;
//connect strcpy(conn.szAddress, "127.0.0.1"); conn.nPort = 5673; conn.nTimeout = 3; nRet = nt3_connect(&conn); if (nRet != RD_SUCCESS) { printf("connect to server failed, error code[%d]!\n", nRet); return -1; } printf("connect to server successful!\n");
//login nRet = sc3_login("admin", "admin"); if (nRet != RD_SUCCESS) { printf("login failed, error code[%d]!\n", nRet); return -1; } printf("login successful!\n");
//get set charset charset = HD3_SYS; ut3_set_charset(charset); printf("set charset unicode success.\n");
charset = ut3_get_charset(); printf("get charset unicode success.\n");
//set time out ut3_set_request_timeout(5); printf("set timeout successful!\n");
//set connection cycle ut3_set_connection_checking_cycle(10); printf("set connection checking cycle successful!\n");
//get server ms nRet = ut3_get_server_ms_time(&nServerTimeMs); if (nRet != RD_SUCCESS) { printf("get server ms time failed, error code [%d]!\n", nRet); nt3_disconnect(); return -1; } printf("get server ms time successful!\n");
//convert time HD3TimeStamp abTime; int32 nSec = 1; nRet = ut3_convert_sec_to_rdtime(nSec, &abTime); if (nRet != RD_SUCCESS) { printf("convert sec to rdtime failed, error code [%d]!\n", nRet); nt3_disconnect(); return -1; } printf("convert sec to rdtime successful!\n");
nRet = ut3_convert_rdtime_to_sec(&abTime, &nSec); if (nRet != RD_SUCCESS) { printf("convert rdtime to sec failed, error code [%d]!\n", nRet); nt3_disconnect(); return -1; } printf("convert rdtime to sec successful!\n", nRet);
//add tag strcpy(normalTag.szTagName, "szNormalTag"); normalTag.nTagType = HD3_TAG_TYPE_INT32; mask.nCommMask = HD3M_COMM_PROP_TAG_NAME | HD3M_COMM_PROP_TAG_TYPE; mask.nExtMask = 0; nRet = pt3_add_tag(&normalTag, &mask, "", &normalTag.nTagID); if (nRet != RD_SUCCESS) { printf("add tag[%s] failed, error code [%d]!\n", normalTag.szTagName, nRet); nt3_disconnect(); return -1; } printf("add tag[%s] successful!\n", normalTag.szTagName);
//query tags by condition filterItem[0].nItemID = HD3_TAG_COL_COMM_PROP_TAG_NAME; filterItem[0].nRelation = HD3_RELATION_LIKE; strcpy(filterItem[0].szValue, "*");
filterItem[1].nItemID = HD3_TAG_COL_COMM_PROP_TAG_TYPE; filterItem[1].nRelation = HD3_RELATION_EQUAL; sprintf(filterItem[1].szValue, "%d", HD3_TAG_TYPE_INT32); filterSet.nSize = 2; filterSet.pItem = filterItem; mask.nCommMask = HD3M_ALL; mask.nExtMask = HD3M_ALL; nRet = pt3_query_tags_cond(&filterSet, &mask, &hIter); if (nRet != RD_SUCCESS) { printf("tag_query_tags_cond, error code [%d]!\n", nRet); nt3_disconnect(); return -1; }
while (true) { nRet = ut3_get_item_step(hIter, &tagQuery); if (RD_SUCCESS == nRet) { printf("query tag successful, tag name is %s, tag id is %d!\n", tagQuery.szTagName, tagQuery.nTagID); } else if (EC_HD_API_QUERY_END == nRet) { printf("query tag complete!"); break; } else { printf("query tag failed, error code [%d]!", nRet); break; } }
ut3_free_handle(hIter);
//disconnect nt3_disconnect();
return 0; }
//*/
|