The twain module also includes a demonstration program, called twexplore.py, which can be used to investigate the interface to your twain compatible device.
The application connects to and communicates with the TWAIN Source Manager program, which is implemented as twain.dll. The TWAIN Source Manager loads the program to support the device with which your application needs to communicate. The program which supports the device is called a Data Source.
The TWAIN specification defines a simple finite-state model for communicating with the TWAIN sub-system. The states are as follows:
|State Name||State Description||Application Activities||Move to next state on|
|1 - Pre-Session||Source Manager is not Loaded||None||Load DLL|
|2 - Source Manager Loaded||Source Manager DLL has been loaded.||None||Open Source Manager|
|3 - Source Manager Open||Application can communicate with the source manager||Can query the list of available sources||Open Source|
|4 - Source Open||The source for the appropriate device is open.||Application can negotiate the details of the session, e.g. image format, number of colours etc.||Request Aquisition of image|
|5 - Source Enabled||The source is attempting to acquire data on behalf of the application||None||User/Source produce image|
|6 - Transfer Ready||The source has acquired the data on behalf of the application.||Begin the transfer.||Transfer Started.|
|7 - Transfer in Progress||The source is transferring the data to the application.||Receive data.|