Click or drag to resize

OnFinalInitialize Method

Called during initialization of a driver.

virtual HRESULT OnFinalInitialize();
File

Co<MainClass>.cpp

Co<RepCapClass>.cpp

Return Value

Returns S_OK if successful, otherwise a failure HRESULT.

Remarks

The OnFinalInitialize method can be used to perform driver-specific actions immediately after each client call to IIviDriver::Initialize. The OnFinalInitialize method executes on the main driver class and on any repeated capability classes. This function is called after the call to the IIviDriver::Initialize implementation.

When the OnFinalInitialize method executes, Nimbus has performed all of its required internal initialization of the driver. All of the repeated capabilities have been initialized and the ResetObjectState method has run. In addition, the instrument I/O infrastructure has been fully initialized by this point, so any of the instrument I/O functions may be used within this method.

Some common tasks that a driver may wish to perform in OnFinalInitialize include:

  • Validating any custom initialization option string values (via the OptionString parameter) and returning an IVI-defined error, such as E_IVI_BAD_OPTION_VALUE or E_IVI_BAD_OPTION_NAME.

  • Setting the trailing characters to be used when reading and writing data to the instruments with the Nimbus Template Library instrument I/O functions.

  • Querying special instrument capabilities (e.g. firmware options installed) and caching the results.

Example

The example code below shows how to use the OnFinalInitialize method to set the trailing character for instrument reads and writes.

C++
// CoAcme4321.cpp
HRESULT Acme4321::OnFinalInitialize()
{
   // Use this function to perform any driver-specific actions immediately after each call to IIviDriver::Initialize

   HRESULT hr = S_OK;

   // This will automatically remove the trailing characters 
   // when reading strings from the instrument.
   io.SetTrailingForReads(_T("\r\n"));

   // This will automatically add the trailing characters
   // when writing strings to the instrument (if the trailing characters
   // are not already present).
   io.SetTrailingForWrites(_T("\r\n"));

   return hr;
}
See Also

Download a complete CHM version of this documentation here.