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 update? (0~{0})", numOfActivated); Util.HighlightLineMulti(tempStr, "How many", "update"); Console.Write(">>>> "); int numOfDevice = Util.GetInput(1); if (0 < numOfDevice) { BS2OsdpStandardDeviceUpdate[] updateData = Util.AllocateStructureArray(numOfDevice); for (int idx = 0; idx < numOfDevice; idx++) { tempStr = String.Format(">>>> [{0}] Please enter the slave ID to be updated.", idx + 1); Util.HighlightLine(tempStr, "device ID to be updated"); Console.Write(">>>> "); updateData[idx].deviceID = Util.GetInput((UInt32)0); if (!getOsdpID(ref config, updateData[idx].deviceID, ref updateData[idx].osdpID)) { Console.WriteLine("The OSDP ID could not be found."); return; } Console.WriteLine("Do you want to change the OSDP ID? (CurrentID: {0}) [Y/n]", updateData[idx].osdpID); Console.Write(">>>> "); if (Util.IsYes()) { Util.HighlightLine(">>>> Please enter the OSDP ID. [0 ~ 126]", "OSDP ID"); Console.Write(">>>> "); updateData[idx].osdpID = Util.GetInput((byte)0); } Util.HighlightLine(">>>> Do you like to enable the OSDP device? [Y/n]", "enable"); Console.Write(">>>> "); updateData[idx].activate = Convert.ToByte(Util.IsYes()); Util.HighlightLine(">>>> Does the OSDP device use secure communication? [Y/n]", "use secure communication"); Console.Write(">>>> "); updateData[idx].useSecureSession = Convert.ToByte(Util.IsYes()); updateData[idx].deviceType = Convert.ToByte(BS2DeviceTypeEnum.THIRD_OSDP_DEVICE); } List listResult = new List(); int structSize = Marshal.SizeOf(typeof(BS2OsdpStandardDeviceUpdate)); IntPtr ptrArray = Marshal.AllocHGlobal(structSize * updateData.Length); long ptrCurrent = ptrArray.ToInt64(); BS2ErrorCode result = BS2ErrorCode.BS_SDK_SUCCESS; try { for (int idx = 0; idx < updateData.Length; idx++) { IntPtr ptrTemp = new IntPtr(ptrCurrent); Marshal.StructureToPtr(updateData[idx], ptrTemp, false); ptrCurrent += structSize; } IntPtr outResultObj = IntPtr.Zero; UInt32 numOfResult = 0; result = (BS2ErrorCode)API.BS2_UpdateOsdpStandardDevice(sdkContext, deviceID, ptrArray, (UInt32)updateData.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;