/** * Get the error code returned from the NI Vision library * @return The last error code. */ int GetLastVisionError() { //int errorCode = imaqGetLastVisionError(); // error code: 0 = no error //char* errorText = GetVisionErrorText(errorCode); //dprintf (LOG_DEBUG, "Error = %i %s ", errorCode, errorText); return imaqGetLastError(); }
/** * @brief Set the current error information associated from the nivision Imaq API. * * @param success The return from the function * @param contextMessage A custom message from the code that set the error. * @param filename Filename of the error source * @param function Function of the error source * @param lineNumber Line number of the error source */ void ErrorBase::SetImaqError(int success, const char *contextMessage, const char* filename, const char* function, uint32_t lineNumber) const { #if ENABLE_NIVISION // If there was an error if (success <= 0) { char err[256]; sprintf(err, "%s: %s", contextMessage, imaqGetErrorText(imaqGetLastError())); // Set the current error information for this object. m_error.Set(imaqGetLastError(), err, filename, function, lineNumber, this); // Update the global error if there is not one already set. Synchronized mutex(_globalErrorMutex); if (_globalError.GetCode() == 0) { _globalError.Clone(m_error); } } #endif }
/** * Create a new image by loading a file. * @param fileName The path of the file to load. */ HSLImage::HSLImage(const char *fileName) : ColorImage(IMAQ_IMAGE_HSL) { int success = imaqReadFile(m_imaqImage, fileName, NULL, NULL); //printf("HSLImage Success at Reading is %d\n",success); //wpi_setImaqErrorWithContext(success, "Imaq ReadFile error"); if(success <= 0) { printf("!!!Error!!! | %s | %s\n",imaqGetErrorText(imaqGetLastError()), imaqGetLastErrorFunc()); } }
/** * imaq assert implementation. */ void wpi_imaqAssert_impl(int imaqStatus, const char *message, const char *fileName, UINT32 lineNumber, const char *funcName) { if (imaqStatus <= 0) { char err[64]; sprintf(err, "%s: %d", message, imaqGetLastError()); wpi_assertWithMessage(imaqStatus > 0, err); } }