﻿

{"id":15843,"date":"2023-10-11T16:03:04","date_gmt":"2023-10-11T07:03:04","guid":{"rendered":"https:\/\/www.bitstrong.com\/jp\/?p=15843"},"modified":"2023-12-13T09:50:08","modified_gmt":"2023-12-13T00:50:08","slug":"card-based-access-control-searching-for-access-control-event","status":"publish","type":"post","link":"https:\/\/www.bitstrong.com\/jp\/card-based-access-control-searching-for-access-control-event\/","title":{"rendered":"\u3010Card-Based Access Control\u3011Searching For Access Control Event"},"content":{"rendered":"<p><strong><span style=\"font-size: 18pt;\">\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0<\/span><\/strong><\/p>\n<div>\/\/<\/div>\n<div>\/\/ Device Network SDK (Card-Based Access Control)<\/div>\n<div>\/\/ Alarm and Event Receiving<\/div>\n<div>\/\/ Search for Access Control Events<\/div>\n<div>\/\/ Sample Code of Searching for Access Control Event<\/div>\n<div>\/\/<\/div>\n<div>#include &lt;stdio.h&gt;<\/div>\n<div>#include &lt;iostream&gt;<\/div>\n<div>#include &#8220;Windows.h&#8221;<\/div>\n<div>#include &#8220;HCNetSDK.h&#8221;<\/div>\n<p>using namespace std;<\/p>\n<div>BOOL CALLBACK MSesGCallback(LONG lCommand, NET_DVR_ALARMER *pAlarmer, char *pAlarmInfo, DWORD dwBufLen, void* pUser)<\/div>\n<div>{<\/div>\n<div>\/\/As the operations with long time consumption are not allowed in the callback function,<\/div>\n<div>\u00a0 \u00a0 \u00a0 \u00a0 \/\/do not call the API of HCNetSDK.DLL in the callback function.<\/div>\n<div>\/\/The following code is for reference only, actually, processing data in the callback function is not suggested.<\/div>\n<p>\/\/for example, process in the message response function as PostMessage<\/p>\n<div>switch (lCommand)<\/div>\n<div>{<\/div>\n<div>case COMM_ALARM_ACS:\/\/Alarm information of access controller<\/div>\n<div>{<\/div>\n<div>NET_DVR_ACS_ALARM_INFO struAcsAlarmInfo = {0};<\/div>\n<div>memcpy(&amp;struAcsAlarmInfo, pAlarmInfo, sizeof(struAcsAlarmInfo));<\/div>\n<div>\/\/Handle other information in the alarm structure as desired&#8230;<\/div>\n<div>break;<\/div>\n<div>}<\/div>\n<div>case COMM_PASSNUM_INFO_ALARM:\/\/Number of passed persons<\/div>\n<div>{<\/div>\n<div>NET_DVR_PASSNUM_INFO_ALARM struPassnumInfo = {0};<\/div>\n<div>memcpy(&amp;struPassnumInfo, pAlarmInfo, sizeof(struPassnumInfo));<\/div>\n<div>\/\/Handle other information in the alarm structure as desired&#8230;<\/div>\n<div>break;<\/div>\n<div>}<\/div>\n<div>default:<\/div>\n<div>break;<\/div>\n<div>}<\/div>\n<div>return true;<\/div>\n<p>}<\/p>\n<div>void main()<\/div>\n<div>{<\/div>\n<div>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/div>\n<div>\/\/Initialize<\/div>\n<p>NET_DVR_Init();<\/p>\n<div>\/\/Set connection timeout and reconnection function<\/div>\n<div>NET_DVR_SetConnectTime(2000, 1);<\/div>\n<p>NET_DVR_SetReconnect(10000, true);<\/p>\n<div>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/div>\n<div>\/\/Log in to device<\/div>\n<div>LONG lUserID;<\/div>\n<div>\/\/Login parameters, including device IP address, user name, password, and so on<\/div>\n<div>NET_DVR_USER_LOGIN_INFO struLoginInfo = {0};<\/div>\n<div>struLoginInfo.bUseAsynLogin = 0; \/\/Synchronous login mode<\/div>\n<div>strcpy(struLoginInfo.sDeviceAddress, &#8220;192.168.1.64&#8221;); \/\/Device IP address<\/div>\n<div>struLoginInfo.wPort = 8000; \/\/Device service port number<\/div>\n<div>strcpy(struLoginInfo.sUserName, &#8220;admin&#8221;); \/\/User name<\/div>\n<p>strcpy(struLoginInfo.sPassword, &#8220;abcd1234&#8221;); \/\/Password<\/p>\n<div>\/\/Device information, output parameter<\/div>\n<div>NET_DVR_DEVICEINFO_V40 struDeviceInfoV40 = {0};<\/div>\n<div>lUserID = NET_DVR_Login_V40(&amp;struLoginInfo, &amp;struDeviceInfoV40);<\/div>\n<div>if (lUserID &lt; 0)<\/div>\n<div>{<\/div>\n<div>printf(&#8220;Login failed, error code: %d\\n&#8221;, NET_DVR_GetLastError());<\/div>\n<div>NET_DVR_Cleanup();<\/div>\n<div>return;<\/div>\n<p>}<\/p>\n<div>\/\/Set alarm callback function for card swiping event<\/div>\n<div>NET_DVR_SetDVRMessageCallBack_V31(MSesGCallback, NULL);<\/div>\n<div>\/\/Set up channel for uploading alarm information<\/div>\n<div>NET_DVR_SETUPALARM_PARAM struSetupParam={0};<\/div>\n<p>struSetupParam.dwSize=sizeof(NET_DVR_SETUPALARM_PARAM);<\/p>\n<div>LONG\u00a0 lHandle = NET_DVR_SetupAlarmChan_V41(lUserID,&amp;struSetupParam);<\/div>\n<div>if (lHandle &lt; 0)<\/div>\n<div>{<\/div>\n<div>printf(&#8220;NET_DVR_SetupAlarmChan_V41 error, %d\\n&#8221;, NET_DVR_GetLastError());<\/div>\n<div>NET_DVR_Logout(lUserID);<\/div>\n<div>NET_DVR_Cleanup();<\/div>\n<div>return;<\/div>\n<p>}<\/p>\n<div>\/\/Wait for 60s for receiving captured picture uploaded by device<\/div>\n<div>Sleep(60000);<\/div>\n<div>\/\/Close alarm uploading channel<\/div>\n<div>if (!NET_DVR_CloseAlarmChan_V30(lHandle))<\/div>\n<div>{<\/div>\n<div>printf(&#8220;NET_DVR_CloseAlarmChan_V30 error, %d\\n&#8221;, NET_DVR_GetLastError());<\/div>\n<div>NET_DVR_Logout(lUserID);<\/div>\n<div>NET_DVR_Cleanup();<\/div>\n<div>return;<\/div>\n<p>}<\/p>\n<div>\/\/Log out<\/div>\n<div>NET_DVR_Logout(lUserID);<\/div>\n<div>\/\/Release SDK resource<\/div>\n<div>NET_DVR_Cleanup();<\/div>\n<div>return;<\/div>\n<div>}<\/div>\n","protected":false},"excerpt":{"rendered":"\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0 \/\/ \/\/ Device Network SDK (Card-Based Access Control) \/\/ Alarm and Event Receiving \/\/ Search for Access Control Events \/\/ Sample Code of Searchin...","protected":false},"author":2,"featured_media":15936,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_sitemap_exclude":false,"_sitemap_priority":"","_sitemap_frequency":"","footnotes":""},"categories":[107],"tags":[],"class_list":["post-15843","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-camera-connection"],"_links":{"self":[{"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/posts\/15843","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/comments?post=15843"}],"version-history":[{"count":3,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/posts\/15843\/revisions"}],"predecessor-version":[{"id":15846,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/posts\/15843\/revisions\/15846"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/media\/15936"}],"wp:attachment":[{"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/media?parent=15843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/categories?post=15843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bitstrong.com\/jp\/wp-json\/wp\/v2\/tags?post=15843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}