int GetRegisterData(int addr, EYMCDataType type, uint RegisterDataNumber, out Int16[] Reg_ShortData, out Int32[] Reg_LongData) { Debug.Assert(INPUT_ORIGIN <= addr && addr <= OUTPUT_END); Reg_ShortData = new Int16[RegisterDataNumber]; Reg_LongData = new Int32[RegisterDataNumber]; #if SIMULATION_IO return(SUCCESS); #endif uint hDataHandle; int iResult = GetRegisterDataHandle(addr, type, out hDataHandle); if (iResult != SUCCESS) { return(iResult); } UInt32 ReadDataNumber = 0; // Number of obtained registers //UInt32 RegisterDataNumber = 1; // Number of read-in registers //Int16[] Reg_ShortData = new Int16[1]; // W or B size register data storage variable //Int32[] Reg_LongData = new Int32[1]; // L size register data storage variable uint rc; if (type == EYMCDataType.B || type == EYMCDataType.W) { rc = CMotionAPI.ymcGetRegisterData(hDataHandle, RegisterDataNumber, Reg_ShortData, ref ReadDataNumber); } else { rc = CMotionAPI.ymcGetRegisterData(hDataHandle, RegisterDataNumber, Reg_LongData, ref ReadDataNumber); } if (rc != CMotionAPI.MP_SUCCESS) { string str = $"Error ymcGetRegisterData MB \nErrorCode [ 0x{rc.ToString("X")} ]"; WriteLog(str, ELogType.Debug, ELogWType.Error, true); return(GenerateErrorCode(ERR_YMC_FAIL_GET_DATA)); } return(SUCCESS); }
int GetRegisterDataHandle(int addr, EYMCDataType type, out uint hDataHandle) { Debug.Assert(INPUT_ORIGIN <= addr && addr <= OUTPUT_END); hDataHandle = 0; #if SIMULATION_IO return(SUCCESS); #endif string registerName; // register type if (addr < OUTPUT_ORIGIN) { registerName = EYMCRegisterType.I.ToString(); } else { registerName = EYMCRegisterType.O.ToString(); } // data type registerName += type.ToString(); // address 계산 부분 registerName += "0000"; // get handle uint rc = CMotionAPI.ymcGetRegisterDataHandle(registerName, ref hDataHandle); if (rc != CMotionAPI.MP_SUCCESS) { string str = $"Error ymcGetRegisterDataHandle ML \nErrorCode [ 0x{rc.ToString("X")} ]"; WriteLog(str, ELogType.Debug, ELogWType.Error, true); return(GenerateErrorCode(ERR_YMC_FAIL_GET_DATA_HANDLE)); } return(SUCCESS); }