Slave Control API > BS2_RemoveOsdpStandardDevice


BS2_RemoveOsdpStandardDevice

[+ 2.9.1] CoreStation40 제거 할 OSDP 장치 식별자들과 개수를 지정하여, OSDP 장치들을 일괄 제거합니다.
제거에 대한 장치별 결과는 outResultObj 및 outNumOfResult를 통해 반환됩니다.

함수

#include "BS_API.h"
 
int BS2_RemoveOsdpStandardDevice(void* context, uint32_t deviceId, const uint32_t* osdpDeviceIds, uint32_t numOfDevice, BS2OsdpStandardDeviceResult** outResultObj, uint32_t* outNumOfResult)

파라미터

참고
outResultObj 변수는 사용 후 BS2_ReleaseObject 함수를 통해 시스템에 메모리를 반환해야 합니다.

반환값

성공적으로 수행될 경우 BS_SDK_SUCCESS를 반환하고, 에러가 발생할 경우 상응하는 에러 코드를 반환합니다.

함께 보기

BS2_AddOsdpStandardDevice
BS2_GetOsdpStandardDevice
BS2_GetAvailableOsdpStandardDevice
BS2_UpdateOsdpStandardDevice
BS2_RemoveOsdpStandardDevice
BS2_GetOsdpStandardDeviceCapability
BS2_SetOsdpStandardDeviceSecurityKey

샘플코드(C++)

sample_bs2_removeosdpstandarddevice.cpp
BS2OsdpStandardConfig config = { 0, };
vector<BS2_DEVICE_ID> removeData;
 
BS2_DEVICE_ID id = Utility::selectDeviceID(deviceList, false, false);
int sdkResult = cc.getOsdpStandardConfig(id, config);
if (BS_SDK_SUCCESS != sdkResult)
	return sdkResult;
 
uint32_t numOfActivated = cc.printOSDPDeviceID(config);
uint32_t numOfDevice = Utility::getInput<uint32_t>("How many devices do you want to remove? (0~%u)", numOfActivated);
if (0 < numOfDevice)
{
	for (uint32_t idx = 0; idx < numOfDevice; idx++)
	{
		BS2_DEVICE_ID slaveID = (BS2_DEVICE_ID)Utility::getInput<uint32_t>("[%u] Please enter the slave ID to be removed.", idx + 1);
		removeData.push_back(slaveID);
	}
 
	vector<BS2OsdpStandardDeviceResult> listResult;
	BS2OsdpStandardDeviceResult* outResultObj = NULL;
	uint32_t outNumOfResult(0);
	int sdkResult = BS2_RemoveOsdpStandardDevice(context_, id, const_cast<BS2_DEVICE_ID*>(removeData.data()), removeData.size(), &outResultObj, &outNumOfResult);
	if (BS_SDK_SUCCESS != sdkResult)
	{
		printf("BS2_RemoveOsdpStandardDevice call failed: %d", sdkResult);
	}
 
	if (outResultObj)
	{
		listResult.clear();
		for (uint32_t idx = 0; idx < outNumOfResult; idx++)
		{
			listResult.push_back(outResultObj[idx]);
		}
 
		BS2_ReleaseObject(outResultObj);
	}
}
 
return sdkResult;

샘플코드(C#)

sample_bs2_removeosdpstandarddevice.cs
BS2OsdpStandardConfig config;
if (!CommonControl.getOsdpStandardConfig(sdkContext, deviceID, out config))
	return;
 
UInt32 numOfActivated = 0;
printOSDPDeviceID(ref config, ref numOfActivated);
 
string tempStr = String.Format("How many devices do you want to remove? (0~{0})", numOfActivated);
Util.HighlightLineMulti(tempStr, "How many", "remove");
Console.Write(">>>> ");
int numOfDevice = Util.GetInput(1);
if (0 < numOfDevice)
{
	List<UInt32> removeIDs = new List<UInt32>();
	for (int idx = 0; idx < numOfDevice; idx++)
	{
		tempStr = String.Format(">>>> [{0}] Please enter the slave ID to be removed.", idx + 1);
		Util.HighlightLine(tempStr, "device ID to be removed");
		Console.Write(">>>> ");
		removeIDs.Add(Util.GetInput((UInt32)0));
	}
 
	List<BS2OsdpStandardDeviceResult> listResult = new List<BS2OsdpStandardDeviceResult>();
	int structSize = Marshal.SizeOf(typeof(UInt32));
	IntPtr ptrArray = Marshal.AllocHGlobal(structSize * removeIDs.Length);
	long ptrCurrent = ptrArray.ToInt64();
	BS2ErrorCode result = BS2ErrorCode.BS_SDK_SUCCESS;
	try
	{
		int[] tempIDs = Array.ConvertAll(removeIDs, Convert.ToInt32);
		Marshal.Copy(tempIDs, 0, ptrArray, tempIDs.Length);
 
		IntPtr outResultObj = IntPtr.Zero;
		UInt32 numOfResult = 0;
		result = (BS2ErrorCode)API.BS2_RemoveOsdpStandardDevice(sdkContext, deviceID, ptrArray, (UInt32)tempIDs.Length, out outResultObj, out numOfResult);
		if (result != BS2ErrorCode.BS_SDK_SUCCESS)
		{
			Console.WriteLine("Got error({0}).", result);
		}
		else
		{
			IntPtr curResult = outResultObj;
			int resultSize = Marshal.SizeOf(typeof(BS2OsdpStandardDeviceResult));
			for (UInt32 resultIdx = 0; resultIdx < numOfResult; resultIdx++)
			{
				BS2OsdpStandardDeviceResult item = (BS2OsdpStandardDeviceResult)Marshal.PtrToStructure(curResult, typeof(BS2OsdpStandardDeviceResult));
				//print(ref item, resultIdx);
				listResult.Add(item);
				curResult += resultSize;
			}
 
			API.BS2_ReleaseObject(outResultObj);
			Console.WriteLine("Call success.");
		}
	}
	finally
	{
		Marshal.FreeHGlobal(ptrArray);
	}
}
 
return result;