2012-09-15 2 views
0

PTRobot API를 C# .NET 프로그램에 통합하려고하는데 알아낼 수없는 문제가 발생했습니다. 다음 명령을 수행하려고합니다.C# # Primera PTRobot SDK의 포인터에서 배열에 액세스

PTRobot_Initialize() 
PTRobot_EnumRobots(HANDLE * phRobots, DWORD * pdwNumRobots) 
PTRobot_GetRobotInfo(HANDLE hRobot, PTRobotInfo *pRobotInfo) 
PTRobot_EnumDrives(HANDLE hRobot, HANDLE * phDrives, DWORD * pdwNumDrives) 
PTRobot_GetDriveInfo(HANDLE hDrive, PTDriveInfo* pDrvInfo) 

API 설명서에서 제공됩니다. Primera는 DLL을 중심으로 C# 용 .NET 래퍼도 개발했습니다. 업데이트 된 기능은 다음과 같습니다.

PTRobot_Initialize() 
PTRobot_EnumRobots(ref UInt32 nRobots, ref UInt32 pnNumRobots) 
PTRobot_GetRobotInfo(UInt32 nRobotID, [In, Out] RobotInfo myRobotInfo) 
PTRobot_EnumDrives(UInt32 nRobotID, ref UInt32 nDriveIDs, ref UInt32 nNumDrives) 
PTRobot_GetDriveInfo(UInt32 nDriveID, [In, Out] DriveInfo myDriveInfo) 

내 프로그램에 .NET 기능을 통합하려고하는데 문제가 있습니다. EnumRobots의 매개 변수 인 nRobots는 "찾은 로봇을 저장하는 HANDLE의 배열을 가리 킵니다."EnumDrives 매개 변수 인 nDriveIDs는 "발견 된 드라이브를 저장할 DWORD의 배열을 가리 킵니다." 내 질문은이 uint에서 배열을 가져 오는 방법에 대한 것입니다.

답변

0

답을 찾았습니다. 궁금한 모든 사람들에게 다음을 수행하십시오.

uint numRobots = 5; 
uint numDrives = 5; 
uint[] robotArray = new uint[numRobots]; 
uint[] driveArray = new uint[numDrives]; 


DriveInfo arr = new DriveInfo(); 
PTRobotReturn rtn; 
RobotInfo rI = new RobotInfo(); 
rtn = PTRobot.Initialize(); 

rtn = PTRobot.EnumRobots(ref robotArray[0], ref numRobots); 

rtn = PTRobot.GetRobotInfo(robotArray[0], ref rI); 

rtn = PTRobot.EnumDrives(robotArray[0], ref driveArray[0], ref numDrives); 

rtn = PTRobot.LoadDrive(robotArray[0], driveArray[0], PrimeraTechnology.DiscLocation.Right_Bin, PrimeraTechnology.ClearDrive.Yes);