Home › Forums › TWAIN Classic › Transition from state 5 to 6
- This topic has 14 replies, 6 voices, and was last updated 9 years, 10 months ago by AbbeyOpiela.
- AuthorPosts
As far as I understand my RC and CC messages I try to use the DG_IMAGE, DAT_IMAGEFILEXFER, MSG_GET command before being in state 6, but how do I get into state 6.
I thought it is enough if I enable the userinterface (state 5) and then sent from the source to the application the message XFERREADY and then I am in state 6 or was this a bit to easy?thanks for help!
The transition from State 5 to 6 is triggered by the Source notifying the application that the transfer is ready. (pg 19)
basically you don’t move into 6, you move into 5 and when the source is ready it moves into 6 on its own.
how does the source tell the application that something is ready? Can I do this with
sm = (*pDSM_Entry) (&ds_id, &app_id, DG_CONTROL, DAT_NULL, MSG_XFERREADY, NULL) ?
because I don’t really understand how a scanner knows that there is something to scan except you press the SCAN button – which, as far as I understood some other discussions here in the forum, is not very easy to implement.>>how does the source tell the application that something is ready?
it sends you a message.
>>..how a scanner knows that there is something to scan ..
you post EnableDs to the source. at that point you’ve specificed with or without Ui and if the Ui doesn’t come up scanning should being or if the Ui does come up there is usually a button that says Scan and after the button is clicked scanning should begin.>>the SCAN button… ….is not very easy to implement.
it isn’t covered in the twain spec but last time i looked at it, it seemed to me that a solution should be possible with deviceEvents and STI (the Still Image Api) but yeah – it looked like more work then it was worth to me.as far as I understand that, by setting showUI=FALSE and DAT_USERINTERFACE MSG_ENABLEDS I am in state 5 and the source knows that there is something to scan. then it should send a message to the application with XFERREADY. which brings it to state 6 and then I can get the picture with DG_IMAGE, DAT_IMAGEFILEXFER, MSG_GET which takes place in state 7.
the only thing which I still don’t understand is if I have to do anything special to make the source send the XFERREADY message like sending requests if there are any messages ready for me.
The only thing I found in the spec was MSG_PROCESSEVENT but I understood that this is only needed if I want to use Windows messages to start the scan process.>>SCAN BUTTON
yes I looked up a few windows commands (GetSTILaunchInformation, RegisterLaunchApplication,…) which looked useful but I want to have a program which doesn’t only work in windows.
I also found MSG_DEVICEEVENT and CAP_DEVICEEVENT but they are unfortunately not supported by most devices, but maybe with the new TWAIN 2.0….hopefullyif enableDs returns success, yes you’ll be in state 5.
When you send a handle to your app to the source the source will use that handle for communication and you’ll pick up the messages in your messageloop (the one you modified like it says in the spec).
ImageFileXfer.Get would be the correct call as long as the transfer mode is disk, but if the transfermode is is buffered you’d use ImageMemXfer and if the xfermode is native (the default) you’d use ImageNativeXfer.
do you think there is a possibility to do all of this without the message loop? I don’t really need to wait till the source sends a XFERREADY message-> if I start the program a scan shall be performed
my aim is to have a program which loads the source, does all the scan settings, enables the userinterface (but doesn’t show it) scans the picture und saves it without the user doing anything.
if i implement this message loop into my program then I am more or lessing waiting for some input from the user and this is what I don’t wantby the way: THANK YOU VERY MUCH gabe for your help and the time you spend on answering my probably stupid questions 😉
a messageloop must exist to use twain. and yeah have to wait for the source to send xferReady – sorry thats just how twain works.
you don’t want the user to anything?… surely the user has to at least signal that they want something scanned, push the big red scan button in the program or something…
but if your goal is just a little automation and you are looking for the settings to be applied without the user setting them up every time you’ll be ok.
One question. Are you planning for the user to setup the scanner at least once? The direction of my question is, if the user never sets up anything then they’ll get either default settings or the settings that are still in place from the last time they scanned something with another program (sota depends on the device). It doesn’t seem to me that this is what almost anyone really expects.
It seems to me (and granted it maybe only to me here) that users who are looking for automation usualy want some control of what is automated.Or are you planning to code in every setting? The idea of coding in every setting is both a bunch of work and doomed (doomed, doomed I say moohoo haha…) the reason I don’t believe in coding in every setting is that all of the settings for a given device aren’t documented – that is the twain spec contains a basic set of capabilities but it leaves a lot of room for the device vendors to put in custom capabilites (that may be using custom values that you won’t have the docs for) and besides, a really fantastic configuration Ui is already built for most devices – the built in one. If you use EnabledsUiOnly in a setup phase, then the device Ui will pop up and when the user OKs the dialog you can (for most devices) query the device for the settings, then in step 2 (normal production) you can replay the settings back to the device. It works out pretty well for a number of reasons – you don’t have to put in miles of code to each and every setting and the device’s standard Ui will take care or those nasty custom caps for you – its a win-win. You can enable the device bring it online and have it run the saved configuration all without the user seeing a Ui, you can just tie it up behind a big red scan button (except for sources that don’t honor the ShowUi=False setting) the only input from the user that you have to have from the user is them clicking the big red button. and if you’re worried about waiting for the xferReady message, don’t. you can add code to handle that message, it shouldn’t take any longer than a regualr scan and the vast majority of it can be automated so that the user doesn’t have to much more than start the scanning.
And you’re welcome, we were all there once. Ask until you run out of questions or find me on IM, my contact details are on my profile.
.
you are right. in the end the user will push the big red scan button either on the scanner or in a UI, because if everything works well my little program should be implemented in another program which also has a userinterface. So there I will need this messageloop anyway.
Over the weekend I organized a second scanner a CANON PIXMA and to my great relief my program works without any problems there, no matter if I just use TWAIN or if I adress the scanner via WIA.
I guess the way my program works now is not the best way but for the moment it is enough to explore more of the different TWAIN features. I think this whole XFERREADY thing will solve itself later when I add my big red scan button 😉in terms of settings my idea was that there is a file which contains information about resolution, bitdepth, file type, file name,…. and when the program is started it reads all the settings from there and sets it. the settings I don’t set are left to default. I know this doesn’t sound very user friendly but my task is that there is one scanner which is used by loads of people and the little they can set themselves the little they can do wrong and the faster they can scan.
thank your for the warning about not documented settings. the idea of setting everything once with a device UI sounds good to me. I will keep this in mind for later, because for now it is enough if I have a rough solution and hopefully the fine tuning is done by people who know more about programming than I do.
and of course another question: do you know any command which gives me what type of container a capability-item is stored in:
if I get the settings for xresolution for example the container type can either be TWON_RANGE or TWON_ENUMERATION and I would like to know in advance which one it is.p.s. I thought it is better if I go on posting my questions here so that people who have the same questions can read the answers and don’t have to ask you again and you have to write everything over and over again. hope thats ok with you.
@TheCrow99 wrote:
do you know any command which gives me what type of container a capability-item is stored in:
if I get the settings for xresolution for example the container type can either be TWON_RANGE or TWON_ENUMERATION and I would like to know in advance which one it is.xResolution.Get usually returns as an enum (could just be the devices I use), but I imagine that you’re really just going to have to check for each device. If you already know what device you’ll be supporting just run Twacker.
The loading settings from a file – doesn’t sound like a bad idea. If the file or a portion of the file were based on CustonDsData you’d really be on your way to completely controlling the device, but your project goals seem modest – you don’t always need to build a rocketship, sometimes you just need a raft. If you have a solution that is working, great.
If you have questions just ask
.found a solution for the resolution:
just set cap_id.ConType = TWON_DONTCARE16 and send (*pDSM_Entry) (pOrg, pDest, DG_CONTROL, DAT_CAPABILITY, MSG_GET, &cap_id)
afterwards cap_id.ConType tells you what container this capability uses
In this modern and high technology world which is also called the “information era”. There is no doubt that people now want to own the life that is safe and free and do the thing that they like and want to do. And usually such kind of life is not so easy to own for some people and as they are monitored by some device. If so the cellphone GPS signal blockers at jammerfromchina.com can be your good assistant.
Still feel annoying when being disturbed cell phone calls? Don’t want this bad thing to happen again and again in your life and work? Ok, do not be anxious, the mobile phone jammer can be your first and best selection. And if you want to know more about this kind of device, from jam signal you can gain the useful information you want.
The activity of the animal beings has become acutely active everywhere on this earth. Bodies do not get time to booty a blow for a while. With the accretion use of altered gadgets of Gps Jammer, the possibilities of accepting the aboriginal of blow accept absolutely finished. The adaptable phones or the corpuscle phones are some of these accessories that accumulate the bodies consistently in blow with the alfresco world. The adaptable building are additionally accessible about everywhere these canicule and due to this the accessibility of the Cell Phone Jammer has become alike added quick and authentic. Today, you cannot break out of ability of these adaptable building as their signals can bolt your about anywhere. The bearings of bodies who accord to altered business professions has become actual analytical of gps jammer as their authorities bolt them anywhere any moment.
As you know that the mobile phone signal jammer can cut off the signals of the mobile phones and soon make it impossible to make phone calls or send messages. In this way when you need the peaceful condition and want to stay in it, you can just use the best mobile phone jammer to help you achieve your goal. And now as the technology develops with high speed the advanced cell phone jamming has come into the market and are well welcomed by the group of people who need the jammer product.
- AuthorPosts