How to register an event for LV event structure from WinApi "PostMessage"?

Hello experts,
I'm using a standard cardreader (RS232/USB) which I access via the manufacturer's API, this works fine so far. However I don't want to poll the status of the reader all the time. The cardreader sends windows messages using the WIN API "PostMessage" as soon as there is a status change (insert card into reader, reader disconnect etc.)
Now how can I use this fact to get an event for my event structure? Any ideas?
Thank you
Melanie

hello Melanie,
This may be tricky but you could use the Windows Message Queue Library example to get the messages from the USB drivers;
http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3E7AC56A4E034080020E74861&p_node=DZ52071&p_submitted=N&p_rank=&p_answer=&p_source=External
And from then create a custom user event based on the POSTMESSAGES received;
http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=B45EACE3E7AC56A4E034080020E74861&p_node=DZ52071&p_submitted=N&p_rank=&p_answer=&p_source=External
Hope this helps,
Cyril Bouton
Active LabVIEW Developper

Similar Messages

  • How to register "Enter" event  in sap xrpm

    all expert:
    how to register "Enter" event  in sap xrpm

    all expert:
    how to register "Enter" event  in sap xrpm

  • How to stop a while loop of event structure from a main vi

    Hello;
    sorry for my english
    I have to stop a subvi from my main vi, the subvi contains a while loop and an event structure so I need to stop this loop while directly from my main vi I have tried global variable but it did not work
    any help please or example !!!   
    Solved!
    Go to Solution.
    Attachments:
    stop a while loop and event structure from main vi.png ‏16 KB

    IYED wrote:
    Hello;
    sorry for my english
    I have to stop a subvi from my main vi, the subvi contains a while loop and an event structure so I need to stop this loop while directly from my main vi I have tried global variable but it did not work
    any help please or example !!!   
    If this is an example of how your code looks, I'd clean it up before the developer who has to work on it next hits you over the head with his LabVIEW Style Book. 
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • How to make an Event Structure work with a webcam feed?

    Hello,
    I'm pretty new to LabVIEW, and I really need some help on a school project.
    In the program, a webcam contantly streams video.  At the same time, I am trying to add an event structure inside of the while loop that contains the webcam information.  An event structure seems to be just the thing I need to add to make my program work, but after adding it, the webcam stopped showing its feed.  My guess is that it's specifically not working with the webcam part, because I've used event structure inside of while loops before.  How can I prevent the event structure from interfering with the webcam?
    I cannot take a screenshot of the back panel at this time, although I can do it within the next 24 hours, if necessary.  Otherwise, I can try to describe the program to the best of my ability.

    i did this a while back for my school project.
    see if its what you need
    Best regards,
    Krispiekream
    Attachments:
    Executive.zip ‏183 KB

  • If my ipad was stolen, how to register my ipad for the stolen goods, and lock the hardware requirements?

    If my ipad was stolen, how to register my ipad for the stolen goods, and lock the hardware requirements?

    It's really disappointing as a newly converted Apple customer who has already had his iPad stolen, that Apple just sits back and let's this happen. 
    I've viewed a number of posts regarding stolen iPads.  Yes, I did have the "find my iPad" enabled.  That's how I knew when the iPad was gone for good.  It's a useless function in the case of theft because the thieves know how to hack into your iPad.  It disappeared from my list of devices in the "find my iPad" utility that very same day. 
    Apple loves the fact that their devices get stolen all the time!  That way they sell more of them.  Theft could easily be significantly reduced if Apple chose to give users a means to report stolen devices on the Apple site.  They choose not to do this.  If the black market for Apple devices was limited to hackers who know they have a stolen device, the items wouldn't be such a hot commodity!  Apple knows this... I guess they want to get their devices into as many households as they can.... Legally or not. 
    So for all you hard working folks out there, find a way to make sure your Apple products are secure because if they get stolen, you're out of luck.  Apple refuses to help when they could easily do so. 

  • How do I transfer events (photos) from Iphoto to a flash drive?

    How do I transfer events (photos) from Iphoto to a flash drive?

    In iLife iPhoto on your mac you select the  the events in the source list and use "File > Export" to export the photos to your flash drive. Just select the flash drive in the file chooser dialogue that will open.
    See Terence Devlin's user tip on exporting from iPhoto:
                     Exporting From iPhoto

  • How to pick document id for perticular case id from RMS

    Hi,
    Can anybody answer if you know "how to pick document id for perticular case id
    from RMS".
    please do the needful.
    Thanks and REgards
    -Sujatha

    Alireza,
    This is a really, really, really, really, really (really) really bad idea.
    Using the max(id) + 1 trick:
    1). WILL get you duplicates (think what happens when two people do this at roughly the same time.
    2). Is horrible for scalability in general
    3). If you use table locking to get around issue #1 is truly atrociously horrible for scalability.
    [url http://forums.oracle.com/forums/thread.jspa?messageID=1901057]here is a previous discussion on this topic.
    [url http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3379873654938]here is an AskTom article on this topic (note the title of that post is "Locking Problems" - should give you a hint as to whether this is a great idea or not).
    Sorry for refusing to answer your question directly, but the best answer is here:
    I do not want to use insert triggers or
    sequence generators or stored procedures, yes, you do So i have to read the max id
    and increment it by one from inside the application. no you don't
    This is a really bad idea.
    Best,
    john

  • How can I deactive software for Photoshop Elements 10 from my computer.

    How do i deactivate software for Photoshop elements 10 from my computer. Help does not appear to have a deactivate command

    If you have the mac app store version, there's no need to deactivate.

  • How do you print ingredients for a grocery list from Recipe Box

    How do you print ingredients for a grocery list from Recipe Box?
    I would think that this basic functionality would be there to semi-automate the process.
    Thanks!

    Hi Mark,
    You'd have to do something like this;
    - Create a Rule in XPRESS that iterated over each of the Roles assigned to the user and invoke the java method available on the com.waveset.object.Role object
    java.util.List      getSubRoleList()
              Return the current list of roles assigned to this role
    <dolist name='currentRole'>
              <ref>user.waveset.roles</ref>
              <set name='roleObj'>
                <invoke name='getObject'>
                  <ref>theSession</ref>
                  <invoke name='findType' class='com.waveset.object.Type'>
                    <s>Role</s>
                  </invoke>
                  <ref>currentRole</ref>
                </invoke>
              </set>
    <block trace='true'>
              <set name='subRoles'>
                <invoke name='getSubRoleList'>
                  <ref>roleObj</ref>
                </invoke>
              </set>
             <ref>subRoles</ref>
    </block>
       </dolist>HTH,
    Paul

  • How to use a event structure with a state machine

    First, I would like to inform you that I only work on LabView part time, and have much to learn.  Anything I do learn, I usually forget until I need it again, because I only work on it part time.
    Using your StopWhileLoopMOD[1].vi, I am trying to put a state machine inside the event structure.  
    Related link: http://forums.ni.com/t5/LabVIEW/How-to-stop-while-loop-in-Event-case/td-p/465564/page/2
    Here is my application:  on the front panel, the user can select any combination of 7 different tests.  I have created cases to perform each step of each test in the correct order, but if the user presses stop, the tests won't stop because some of the cases have a while loop inside the event structure (like you mentioned is a bad idea).  The user should be able to stop the test, reselect tests to perform, and re-start the tests. 
    When the start button is pressed for the event structure, I need all the cases to run in the proper order, unless stop is pressed.
    In the past I have indexed an array and used that to run the state machine, but it won't stop immediately.  
    I have sub VIs that are built in while loops because the outputs of the product needs time to stabilize.  The state machine stops and waits up to a certain number of iterations.  If it passes the test, the while loop stops and the next state starts.  If it takes too long, it exits and reports an error.  Maybe I need to just use the state machine and not an event structure?
    Is there a good example of an event structure?
    metzler CLAD
    Solved!
    Go to Solution.

    I'm not sure exactly what you are asking, but it sounds like you want to script a bunch of tests and if the user says stop, to immediately stop the current test and abandon the others?  I'm going to assume that you know how to clear the array so that it will abandon the others, so I'm guessing that you are having trouble abandoning the current test?  If this is indeed the case, then the problem is that you are not able to propagate the message from the main VI FP which is the GUI to the sub vi which is the test, where the test may or may not have a GUI (FP visible) of it's own.  Threading was the first thing to come to mind, but this may not be necessary using events.
    You can do this by passing a refnum of the stop button to the subVI, where you can then add that wait to the event case structure.
    I've attached 2 VIs, mainvi.vi which is just a loop displays the count*2 (number of seconds passed since running) that will call subvi.vi and then check to see if the stop button is pressed.  mainvi.vi is by no means a state engine, it is just a simple loop for demonstration purposes.  subvi.vi just waits 2 seconds and leaves, it is a better structured state engine with an init state to start a poll case to wait for events and an exit state to clean up.  You can modify this any way you wish to get it to do what you want.  You will note that even if subvi.vi is being executed, it will terminate immediately when the stop button is pressed.
    Hope this helps.
    A
    Attachments:
    mainvi.vi ‏17 KB
    subvi.vi ‏33 KB

  • How to use an Event Structure responding to an image control that belongs to a parent VI.

    Hi
    I am loading a subpanel vi by pressing a button located in the user interface of the main vi which also contains an image display. Subpanel vi opens up on the side and doesn't hide the image display of the main vi. Subpanel vi contains an event structure that needs to respond to user clicking on the image display of main vi.
    Since the bug that occured while creating an image reference control isn't fixed, I am passing the main vi pane reference onto the subpanel vi. From that point I've tried to edit event structure and have it respond to the image control/pane that belongs to main vi but I don't know how.
    Any help would be appreciated.
    Thanks

    Post a screenshot of your subVI code where you register the events.
    André
    Regards,
    André
    Using whatever version of LV the customer requires. (LV5.1-LV2012) (www.carya.nl)

  • How to use a event structure in a subVI

    I am trying to use an event structure inside a subVI.  The subVI has an array builder that builds arrays, and the event structure is used so that when the program is running, it allows you to change the elements of the array.  It works, but when I implement it inside a subVI, it does not work properly.  This is going into a subVI, because it will be a part of a much larger progrram, so it needs to be modular.

    If you're using an event structure, it's not a subVI.  if you're worried about modularity, you shouldn't be using the event structure.
    You seem to have a fundamental misunderstanding of modularity.  An event structure should be placed within a while loop.  If you have a while loop within a subVI, you've handed over control of your program to the subVI.  You're not modular at this point.  Your top level GUI has no control.  You'd have to create some asinine system of variables to pass data down to that loop to stop the loop and return to your main VI.  That's not a good design decision.
    Instead of looking for a way to do something broken, you should spend effort trying to understand what you actually want to accomplish.  You should also spend some time learning how event structures work.
    This application is small right now and it's already on the path to unreadable.  That's a terrible thing to do to yourself.  Break these habits now.  se variables only when absolutely necessary.  Use subVIs to accomplish individual tasks, not run the entire application.  With event structures, use a stop button value change event to not be held hostage by the timeout.  If your variable has "2" in it, you're doing something wrong.  There has to be something different between the setpoints, put that in the name.  If you want to make subVIs, create an icon.
    But first and foremost, invest time in understanding dataflow

  • How to control the event structure

    What i am trying to do is when the condtion is true, i want the event structure to excute. But event structure wil not excute unless there the puch pattern changed, any idea how to do that ? 
    Solved!
    Go to Solution.
    Attachments:
    Try.vi ‏95 KB

    It's more likely he wants the sequence of events he has put together to run after the result changes once.  If you change the logic to check the values after each change of numeric(2), he'll need to learn to check to ensure the last iteration wasn't already true.  Otherwise, he's going to start the sequence over and over.
    Really, you need to get away from the event structure entirely.  It's not what you want.  Your code lends itself to a state machine very well.
    You'll want to ask yourself a few things:
    1) Do I want my code to run continuously or do I just want to check the two numerics once? (your code currently does the second)
    2) Do I want the user to be able to stop my code once the sequence starts? (this is generally a yes)
    3) Do I want Path 6, Path 5, or the comparison to happen first?  Do I want them all to run simultaneously?  Do I need one before another? (currently you cannot predict which will happen first.)
    Topics you'll need to understand are: state machines, data flow, case structures, timing, and race conditions.  Right now, you're looking to get yourself into trouble.

  • How to break an event structure?

    "What I have is an event structure with 2 cases, within a while loop. Case 0 is triggered by a button and contains a very very long sequence and the other (case 1) I put it just to have an stop button and then stop the while loop with its boolean TRUE value.
    What I need its to be able to stop the execution of case 0 at any time while the sequence (the sequence is made up of many subVIs and case estructures, some subVIs contains sequence structures but not the final sequence I'm dealing with) is running and stop the while loop right away (I need to let the vi finish, I dont want to abort it). Besides if the VI is waiting for an event and the abort button in case 1 is hit the VI should also finish (this is working fine). I want to do
    these 2 actions with one single "abort" button
    (My problem has nothing to do with front panel bloking)"
    Thanks

    Hi,
    I don't think there is any way to stop the execution of a sequence structure in your case 0 (well except hitting the LabVIEW Stop button). What you can do though is to use different program structure to implement the same thing. Seperate your sequences in case 0 into many individual cases in a while loop, like a state machine structure for example. This way by dividing them into different cases, you can decide exactly when an exit condition can be checked.
    Hope this helps,
    Dan

  • How to guarantee an event structure executes at least once

    I have an event structure that I want to execute one time on program start and then behave normally after that.  Is there an *elegant* way to do that?
    Lee Jay

    Jhoshkins' idea will work, but if you want the timeout to continue to function (not wait forever) you can put your code inside the True case of a True/False case structure, and use the First Call? to select it.
    PaulG.
    "I enjoy talking to you. Your mind appeals to me. It resembles my own mind except that you happen to be insane." -- George Orwell

Maybe you are looking for