/// <summary> /// Do display initialization. /// Returns true on success /// </summary> private bool DoInit() { IDW_INITRESULT initResult = new IDW_INITRESULT(); DSPResult ret = IDW_Init(initResult); //Check the API call worked if (ret != DSPResult.DSP_SUCCEEDED) { ImonErrorMessage = DSPResult2String(ret); LogError(string.Format("{0}.IsDisabled: {1}", ClassErrorName, ImonErrorMessage)); return(false); } //Check that the initialization was carried out properly else if (initResult.iInitResult != DSPNInitResult.DSPN_SUCCEEDED) { ImonErrorMessage = DSPNResult2String(initResult.iInitResult); LogError(string.Format("{0}.IsDisabled: {1}", ClassErrorName, ImonErrorMessage)); return(false); } //Check we that we have a display else if (initResult.iDspType == DSPType.DSPN_DSP_NONE) { ImonErrorMessage = UnsupportedDeviceErrorMessage; LogError(string.Format("{0}.IsDisabled: {1}", ClassErrorName, ImonErrorMessage)); return(false); } DisplayType = initResult.iDspType; Initialized = true; iInitToggleTime = DateTime.Now; return(true); }
/// <summary> /// Provide a string corresponding to the given DSPResult. /// </summary> protected string DSPResult2String(DSPResult result) { switch (result) { case DSPResult.DSP_SUCCEEDED: return("Success"); case DSPResult.DSP_E_FAIL: return("An unknown error occurred"); case DSPResult.DSP_E_OUTOFMEMORY: return("Out of memory"); case DSPResult.DSP_E_INVALIDARG: return("One or more arguments are invalid"); case DSPResult.DSP_E_NOT_INITED: return("API is not initialized"); case DSPResult.DSP_E_POINTER: return("Pointer is invalid"); default: return("An unknown error occurred"); } }
/// <summary> /// Provide a string corresponding to the given DSPResult. /// </summary> protected string DSPResult2String(DSPResult result) { switch (result) { case DSPResult.DSP_SUCCEEDED: return "Success"; case DSPResult.DSP_E_FAIL: return "An unknown error occurred"; case DSPResult.DSP_E_OUTOFMEMORY: return "Out of memory"; case DSPResult.DSP_E_INVALIDARG: return "One or more arguments are invalid"; case DSPResult.DSP_E_NOT_INITED: return "API is not initialized"; case DSPResult.DSP_E_POINTER: return "Pointer is invalid"; default: return "An unknown error occurred"; } }