TWAIN State Transition Information

Top  Previous  Next

The sequence of events that controls a TWAIN session and the application are called states. For a protocol such as TWAIN to function properly, the application must call certain functions at specific points during the lifetime of a TWAIN session.  Some of these functions include opening the Source Manager, Opening the Source, setting the Source capabilities, preparing for the image acquisition to begin, closing the Source and Source Manager, etc.  For these events to occur without error, it makes sense that these functions must be called in a specific sequence.

 

TWAIN defines seven states that can exist during a TWAIN session.  The seven states are as follows:

 

State 1 (Source Manager Not Loaded)

State 2 (Source Manager Loaded/Unloaded)

State 3 (Source Manager Opened/Closed)

State 4 (Source Opened/Closed)

State 5 (Source UI is opening/closing)

State 6 (Source is starting/ending transferring image)

State 7 (Image data is acquiring from the device)

 

For a TWAIN enabled application, the state transitions logic (knowing when to change states, which state that TWAIN is currently in, and how to change states successfully) is the responsibility of the application.  One bad move, and the whole application will fail, if not immediately, then eventually.  Many times, a TWAIN failure can render the entire operating environment unstable, causing a shutdown or a reboot of the computer to be necessary!

 

How DTWAIN handles the state transition logic:

To ease this burden (and many hours, if not many man-days of programming frustration), DTWAIN handles all TWAIN state transition logic.  Using DTWAIN, your application does not need to handle the intricacies of knowing when, where and how to change states.  This drastically reduces the overhead spent in trying to program the state transition logic and virtually eliminates the possibility that the application will not change to the proper TWAIN state at the correct time.

 

However, DTWAIN does require your application to call the DTWAIN functions in a certain order.  This 'function order' can be thought of as a variation of the TWAIN state transition logic.  The major difference is that DTWAIN offers greater flexibility and is much easier to use than coding hard to manage state transition code.

 

For persons familiar with TWAIN programming:

The DTWAIN Function Help describes any TWAIN state transitions that are occurring when a DTWAIN function is called.  This information is solely for the programmers who are familiar with TWAIN and would like to know what is happening 'behind the scenes' when calling a DTWAIN function.