Handling windows messages within an event structure

Hello all.
I've got an event driven VI which makes use of an event structure. I'd like my VI to be able to respond to some custom windows messages (i.e. WM_USER) sent from a separate process that listens on a telemetry card (sends a message when it receives data).
I have tried modifying the Windows Messaging Queue VI example provided by NI so that the VI will process windows messages during the timeout event in the event structure but this doesn't seem to work.
Any suggestions?
If labview events and windows messages don't mix then I guess I could do away with the event structure and go entirely with windows messages. This could be done by defining some custom messages that replace the labview events (e.g., W
M_STOPBUTTON_PRESSED = stop button, value changed event) and have the VI post these messages using PostMessage from User32.DLL and then catch these messages in the same manner as the NI Windows Messaging Queue VI.
My preference is to make use of the event structure if I can because its more inline with the labview methodology.
This is really interprocess communication question so if there are other ways of achieving the same result (sockets, named pipes, shared memory?) I'm keen to listen.
cheers,
Novak.

These 'sockets' sound interesting. What exactly are they? Could you direct
me to an example?
Thanks
Denis
"VI Guy" wrote in message
news:[email protected]..
> LabVIEW Events and Windows messages don't mix. To implement as such,
> you would have to do as you describe.
>
> Using sockets as an inter process communication scheme works great.
> And on a single machine, they dont leave the computer (i.e. no round
> trip on the network). Also, its cross platform compatable, not to
> mention it adds the possibility of being able to seperate your
> processes across several machines. Add to this that sockets are as
> easy to code as serial communication (with the benefit of "sleeping"
> waits instead
of "serial polling") and you get a solution fits many
> applications and needs.
>
> Get the idea I am sold on sockets?
>
> Good luck.

Similar Messages

  • Can I use an event structure within another event structure

    Hi
    Can use an event structure within another event structure?
    Thanks
    Yasamin
    Solved!
    Go to Solution.

    I attached my Vi from my old project (MY OLD VI). It is worked correctly.
    But I decided that use event structure instead of case structure.
    I attached my new VI as a picture and as a LabVIEW VI too (network_analyzer_8510_920527 Frequency Sweep.vi )
    My graphs show by pressing "case 5: button (Bottom of page right hand).
    Then I want to show each of graph in a large window( in a new VI) by clicking a key (for example "show 1").
    Thanks
    Yasamin
    Attachments:
    my VI.JPG ‏256 KB
    network_analyzer_8510_920527 Frequency Sweep.vi ‏72 KB
    MY OLD VI.vi ‏69 KB

  • While loop with stop button within event structure locks up front panel.

    I am not sure if this is a bug with my program or a bug within LabVIEW.  If you believe that this is a bug with my program then I will post my program to be looked at.
    The problem I am having is there is a while loop within an event structure that fires when a particular value changes.  Once the "Activate" button is pressed the while loop within the event structure starts going with a polling frequency of 1hz (1000ms wired to the "wait till next ms multiple" vi).  There is a "Deactivate" button that is wired to the stop control of the while loop and an outter while loop that resets the event structure so that the activate button is being listened to again.
    Once inside the while loop, however, none of the button are responsive within the front panel.  The VI continues to run, and only 60% of my CPU is being consumed, but none of the button or scroll bars work.  The only way for me to terminate the program is with the "Abort" button next to the "Run" button.  If I remove the event structure so that the while loop in question runs as soon as the program starts, the front panel remains responsive.  I've inserted probes within the while loop and verified that it is not running prior to the "Activate" button being asserted, and it is running after the assertion of the "Activate" button with the expected polling frequency set by the "wait till next ms multiple" vi.
    Can anyone help?  Do I need to post my code?
    -Nic

    It is typically not a good idea to stall an event structure by placing loops inside event cases. What good is an event structure if it is not free to repond to events?
    Have a look at some alternative solutions, such as in the following link:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=224817#M224817
    LabVIEW Champion . Do more with less code and in less time .

  • Firing events from a Menu using Event Structure - all in the same Event Window?

    I have an ap where I have three menus, and several selections from
    those three menus. I'm trying to keep everything within the Event
    Structure, but it seems that ALL of the events fired from the Menu must
    be contained within one "frame" of the Event Structure, that being the
    Menu Selection (user) Event. In other words, if I have 16 events that
    can be fired from the menu, do I have to put them ALL in this one event
    frame?
    I can't seem to use a T/F indicator within the Menu Selection (user)
    Event to access another Event. For example, within the Menu Selection
    (user) Event, I placed a boolean named X and can turn it on with a menu
    selection. Now, make a new Event Structure to look for X Value Change -
    doesn't work.
    Message Edited by Broken Arrow on 11-30-2005 10:24 AM
    Richard

    I use one event, Menu Selection (user). to trap all of my menu events.  Use Item Path and / or Item Tag to figure out what menu item was selected then branch code based on selection.  Wtih Booleans and menus you need to update the state of the boolean on the menu by setting it True or False.  It doesn't automatically toggle like you would expect.
    Matt
    Matthew Fitzsimons
    Certified LabVIEW Architect
    LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
    Attachments:
    menuSelect.JPG ‏45 KB

  • Event structures for dummies

    After all the great help with data handling, I thought I would ask a question about event structures.
    I have a main VI that sits around and lets me read in files and change variables. Once I am happy, I press start which fires up some sub VI that start running in the background. I have tried this using event structures. But then disaster strikes!! One of my variables is wrong and I need to stop/reset the sub VIs (without stopping the main program). However, my subVI is running in a timed loop continuously, within the event structure, so it's stuck. Attached is a very simplified VI of what I mean.
    I basically want to run a program, set up some variables, set off a background subVI, update/reset if needs be and then press the big continue button to the next stage whilst the subVI is still chugging.
    Any suggestions from the Guru's? I do not think event structures are the way forward
    "When I read about the horrors of drinking, I gave up reading"
    Attachments:
    event structures for idiots.vi ‏90 KB

    The important thing about event structures is to use them in the right way. For example as a rule of thumb, don't put into an event handler anything that will take more than about 200 msec or so to complete. Why? Studies have shown that 200 msec is the longest delay you can generate without the user noticing the delay (obviously YMMV).
    One good solution (as corys pointed out) is the Producer/Consumer Loop - but there are a variety of others. For example, I have created applications where pressing a button launched a long task as a separate process running in the background. When it finished it passed data back to the GUI using another event, queue or some other mechanism.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Event structure and a cluster - lagging input

    I am running into problem using a cluster of controls that I want to use with an event structure. Each control tied to an event case. Simple enough.
    I used the cluster because the number of controls I am using is quite large. The problem is that I need to read the cluster to get the latest state before I unbundle and handle the event. The issue is that in order to pull this off, I need to use a local variable of the cluster for each event. Since the event structure could have ten or so cases, I end up with ten or so of the reviled and maligned local variables. 
    The cluster has great advantages for what I am doing, but the local variable break old taboos in the LabVIEW style rulebook.
    I am attaching a micro-version of the vi so you can see the problem. You have to imagine expanding this to a lot of event cases to see the problem. Below the simple front panel is the real front panel I want to work with just so you have an example.
    So, am I wrong to use the variables and should I break the cluster and lose it advantages, or is this a valid use of the local?
    For those of you that don't see why the locals are needed, just run the vi. You'll see that the direct wired version always lags one state behind the control. The reason is that on an event trigger (toggling the boolean) , the last state of the control is already at the event structure boundry. The event code executes immediately with the previous data. Putting the local inside forces the case to read the current state of the control and use the correct data.
    Long winded and not much meat, but somebody must be bored out there and willing to jump into the fray.
    David A. Taylor
    Attachments:
    Clusters and events.vi ‏19 KB

    Ray.R wrote:
    which route?
    the bottom one is going to give you the wrong value which is what he had as a problem..
    OR
    you probably mean something similar to what I posted, but got the reference from within the Event Structure... Yeah, I also prefer that one
    The latter, it ties the event direct to the control triggering the event, and you could use it for several boolean controls.
    Now in total retrospect, the event (Value Change) will also output the 'New Value', so there's actually no need for the local/reference.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • VI containing Event Structure will not receive front panel events in LabVIEW Real-Time.

    Hi again, I'm working in my first UI (attached VI).
    It works when running directly from PC. It doesn't when running from cRIO, there's the message "VI containing Event Structure will not receive front panel events in LabVIEW Real-Time". I've been reading and I found that "Event structures on RT targets do not support events associated with user interface objects, such as VI panels or controls. For example, associating the Value Change event with a control does not work. RT targets support only user events".
    Is that the problem? If it is, how can I create Mouse Up, Mouse Enter, Value Change (or other user interface events) user events?
    If I run my VI in FPGA mode should it run?
    Attachments:
    HMI.vi ‏33 KB

    Since it looks like you are new to the whole RT and machine control, I recommend giving this a good read: NI LabVIEW for CompactRIO Developer's Guide
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Case structure & event structure

    1.What are the disadvantages of case strucure?
    2.What are the advantages of event structure?

    Are these test questions? I could name 10 for each, but why are you asking?
    While there are often many ways to accomplish the same thing, Case structures and Event structures serve different purposes. Straight from the Help file:
    Case Structure
    Has one or more subdiagrams, or cases, exactly one of which
    executes when the structure executes. The value wired to the selector terminal
    determines which case to execute and can be Boolean, string, integer, or
    enumerated type. Right-click the structure border to add or delete cases. Use
    the Labeling tool to enter value(s) in the case selector label and configure the
    value(s) handled by each case.
    Event Structure (Not in Base Package)
    Has one or more
    subdiagrams, or event cases, exactly one of which executes when the structure
    executes. The Event structure waits until an event happens, then executes the
    appropriate case to handle that event.
    Right-click the structure border to add new event cases and configure which
    events to handle. Wire a value to the Timeout
    terminal at the top left of the Event structure to specify the number of
    milliseconds the Event structure should wait for an event to occur. The default
    is –1, indicating never to time out.

  • Event Structure: update the structure with a tab control

    Hi!
    I want to be able to update the code contained within an event structure by a tab control value change, in addition to the usual bool controller in the UI. 
    The problem is that the event structure don't seem to run when the bool has a value change for the tab control. I have made a short .vi to demonstrate. A counter is placed in the Event structure so it is possible to see if it is running or not. 
    Any ideas?
    Best regards
    Is my avatar the dog from the fraggle rock?
    Attachments:
    forum_question.vi ‏12 KB

    Here is a version of your code using a Value Signaling property node.
    I "think" it does what you want ...
    steve
    Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
    question. Give "Kudos" to replies that help.
    Attachments:
    forum_question_mod 2009.vi ‏15 KB

  • Handling DAQmx Sampling Rate within Event Structure

    Hello all,
    I've been programming in Labview for a while now, but have recently been introduced to Event Structures. They are useful, however I think in the program below, the event structure is causing me trouble.
    VI (Written in Labview 8.0): http://myweb.dal.ca/~jwoodacr/Pendulum.vi
    The program itself is fairly straightforward, and by no means complete. One event allows the user to acquire data in real-time (Preview Data Event), and uses the Wait VI to control speed (I know this is not particularly accurate, but the preview does not have to be). The other event is meant to collect data with a well defined time interval between data points.
    The problem is, I can press the "Collect" button once, and the "Collect" event will run fine with the values of "Time to Collect" and "Data points / sec" that were input by the user prior to pressing Collect. But, if one wishes to press collect again, no matter how you change the "Time to Collect" and "Data point / sec" controls, the express VI "DAQ Assistant 2" will only remember the very first values you gave it, and will output data with these parameters. So, if you change "Time to collect" to from one (1) to two (2) seconds after having run it initially with one (1) second, it will continue to remember the one (1), and collect data for only one second.
    I've attempted to replace the express VI with all the proper DAQmx VI's used to collect in an identical fashion, but those also do not update past the initial conditions that are set. If you enable "Highlight Execution" and watch as the task proceeds, the numbers that are sent to the "DAQ Assistant2" VI are all as they should be, based on everything input on the front panel. It simply seems to ignore them upon execution.
    This seems an odd problem, but I am hoping someone may be able to shed some light on it, or has experienced something similar in the past.
    Thanks in advance.
    Cheers,
    Jeff

    The DAQ Assistant only initializes the first time it is called.  Thus each subsequent call, it does not care about the inputs into it.  Another option is use DAQmx VIs and use a property node to modify whichever propreties you want.  You must stop the task before changing its properties.
    Brian R.
    District Sales Manager
    Washington DC
    National Instruments

  • WPF UI running in seperate runspace - able to set/get controls via synchronized hash table, but referencing the control via the hash table from within an event handler causes both runspaces to hang.

    I am trying to build a proof of concept where a WPF form is hosted in a seperate runspace and updates are handled from the primary shell/runspace. I have had some success thanks to a great article by Boe Prox, but I am having an issue I wanted to open up
    to see if anyone had a suggestion.
    My goals are as follows:
    1.) Set control properties from the primary runspace (Completed)
    2.) Get control properties from the primary runspace (Completed)
    3.) Respond to WPF form events in the UI runspace from the primary runspace (Kind of broken).
    I have the ability to read/write values to the form, but I am having difficulty with events. Specifically, I can fire and handle events, but the minute I try to reference the $SyncHash from within the event it appears to cause a blocking condition hanging both
    runspaces. As a result, I am unable to update the form based on an event being fired by a control.
    In the example below, the form is loaded and the following steps occur:
    1.) Update-Combobox is called and it populates the combobox with a list of service names and selects the first item.
    2.) update-textbox is called and sets the Text property of the textbox.
    3.) The Text value of the textbox is read by the function read-textbox and output using write-host.
    4.) An event handle is registered for the SelectionChanged event for the combobox to call the update-textbox function used earlier.
    5.) If you change the selection on the combobox, the shell and UI hangs as soon as $SyncHash is referenced. I suspect this is causing some sort of blocking condition from multiple threads trying to access the synchronized nature of the hash table, but I am
    unsure as to why / how to work around it. If you comment out the line "$SyncHash.TXT_Output.Dispatcher.Invoke("Send",[action]{$SyncHash.TXT_Output.Text = $Value})" within update-textbox the event handler will execute/complete.
    $UI_JobScript =
    try{
    Function New-Form ([XML]$XAML_Form){
    $XML_Node_Reader=(New-Object System.Xml.XmlNodeReader $XAML_Form)
    [Windows.Markup.XamlReader]::Load($XML_Node_Reader)
    try{
    Add-Type –AssemblyName PresentationFramework
    Add-Type –AssemblyName PresentationCore
    Add-Type –AssemblyName WindowsBase
    catch{
    Throw "Unable to load the requisite Windows Presentation Foundation assemblies. Please verify that the .NET Framework 3.5 Service Pack 1 or later is installed on this system."
    $Form = New-Form -XAML_Form $SyncHash.XAML_Form
    $SyncHash.Form = $Form
    $SyncHash.CMB_Services = $SyncHash.Form.FindName("CMB_Services")
    $SyncHash.TXT_Output = $SyncHash.Form.FindName("TXT_Output")
    $SyncHash.Form.ShowDialog() | Out-Null
    $SyncHash.Error = $Error
    catch{
    write-host $_.Exception.Message
    #End UI_JobScript
    #Begin Main
    add-type -AssemblyName WindowsBase
    [XML]$XAML_Form = @"
    <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Window.Resources>
    <DataTemplate x:Key="DTMPL_Name">
    <TextBlock Text="{Binding Path=Name}" />
    </DataTemplate>
    </Window.Resources>
    <DockPanel LastChildFill="True">
    <StackPanel Orientation="Horizontal" DockPanel.Dock="Top">
    <Label Name="LBL_Services" Content="Services:" />
    <ComboBox Name="CMB_Services" ItemTemplate="{StaticResource DTMPL_Name}"/>
    </StackPanel>
    <TextBox Name="TXT_Output"/>
    </DockPanel>
    </Window>
    $SyncHash = [hashtable]::Synchronized(@{})
    $SyncHash.Add("XAML_Form",$XAML_Form)
    $SyncHash.Add("InitialScript", $InitialScript)
    $Normal = [System.Windows.Threading.DispatcherPriority]::Normal
    $UI_Runspace =[RunspaceFactory]::CreateRunspace()
    $UI_Runspace.ApartmentState = [System.Threading.ApartmentState]::STA
    $UI_Runspace.ThreadOptions = [System.Management.Automation.Runspaces.PSThreadOptions]::ReuseThread
    $UI_Runspace.Open()
    $UI_Runspace.SessionStateProxy.SetVariable("SyncHash",$SyncHash)
    $UI_Pipeline = [PowerShell]::Create()
    $UI_Pipeline.Runspace=$UI_Runspace
    $UI_Pipeline.AddScript($UI_JobScript) | out-Null
    $Job = $UI_Pipeline.BeginInvoke()
    $SyncHash.ServiceList = get-service | select name, status | Sort-Object -Property Name
    Function Update-Combobox{
    write-host "`nBegin Update-Combobox [$(get-date)]"
    $SyncHash.CMB_Services.Dispatcher.Invoke($Normal,[action]{$SyncHash.CMB_Services.ItemsSource = $SyncHash.ServiceList})
    $SyncHash.CMB_Services.Dispatcher.Invoke($Normal,[action]{$SyncHash.CMB_Services.SelectedIndex = 0})
    write-host "`End Update-Combobox [$(get-date)]"
    Function Update-Textbox([string]$Value){
    write-host "`nBegin Update-Textbox [$(get-date)]"
    $SyncHash.TXT_Output.Dispatcher.Invoke("Send",[action]{$SyncHash.TXT_Output.Text = $Value})
    write-host "End Update-Textbox [$(get-date)]"
    Function Read-Textbox(){
    write-host "`nBegin Read-Textbox [$(get-date)]"
    $SyncHash.TXT_Output.Dispatcher.Invoke($Normal,[action]{$Global:Return = $SyncHash.TXT_Output.Text})
    $Global:Return
    remove-variable -Name Return -scope Global
    write-host "End Read-Textbox [$(get-date)]"
    #Give the form some time to load in the other runspace
    $MaxWaitCycles = 5
    while (($SyncHash.Form.IsInitialized -eq $Null)-and ($MaxWaitCycles -gt 0)){
    Start-Sleep -Milliseconds 200
    $MaxWaitCycles--
    Update-ComboBox
    Update-Textbox -Value $("Initial Load: $(get-date)")
    Write-Host "Value Read From Textbox: $(Read-TextBox)"
    Register-ObjectEvent -InputObject $SyncHash.CMB_Services -EventName SelectionChanged -SourceIdentifier "CMB_Services.SelectionChanged" -action {Update-Textbox -Value $("From Selection Changed Event: $(get-date)")}

    Thanks again for the responses. This may not be possible, but I thought I would throw it out there. I appreciate your help in looking into this.
    To clarify the "Respond to control events in the main runspace"... I'm would like to have an event generated by a form object in the UI runspace (ex: combo box selectionchanged event) trigger a delegate within the main runspace and have that delegate in
    the main runspace update the form in the UI runspace.
    ex:
    1.) User changes selection on combo box generating form event
    2.) Event calls delegate (which I have gotten to work)
    3.) Delegate does some basic processing (works)
    4.) Delegate attempts to update form in UI runspace (hangs)
    As to the delegates / which runspace they are running in. I see the $synchash variable if I run get-var within a delegate, but I do not see the $Form variable so I am assuming that they are in the main runspace. Do you agree with that assumption?

  • Event structure to detect value change of a control within a cluster in an array

    I have 1D array that contains a cluster. The cluster contains a numeric and a boolean control.
    If the user starts to edit the numeric control value i would like to call one subVI, and if the boolean control value is changed, call a different subVI.
    The array control on the front panel allows the user to edit a number of the array elements. 
    I would like to use an event structure to detect a value change in the cluster. When editing the Events, in the Event Sources panel i get the option to select only the array, not the cluster within the array or the controls within the cluster. Can the Event structure be opened up to show controls within clusters and arrays?
    The solution i am using is to detect a mouse up event on the array and then use property nodes to  determine if the key focus is on the numeric, and  a case structure to determine which subVI to call. This works, but is there a better (simpler) way?
    Thanks, Blue.

    Thanks for the responses guys.
    The tricky bit was that i wanted the numeric control values to flag they were going to be edited, so i could call a subVI, before their values were changed by the user. This is done by using the key focus property node, - i need to detect changes on the fly rather than post the event.  Probably didn't make this clear enough in my original post. 
    The array is of variable size depending on if the user decides to insert or delete elements. The user also has the option to click and edit the array without having to do to much scrolling through the array index, as the FP shows several elements at a time. The Event Structure does a good job of automatically determining which element in the array is being edited, and returning those values to the property nodes. Turned out simpler than i thought it might be at one point!
    Cheers, Blue. 
    Message Edited by BlueTwo on 01-15-2009 06:52 AM
    Attachments:
    evstrct1.jpg ‏63 KB

  • How do I get callback or windows messaging Events working on a 6534 card do pattern output?

    Hi,
    I am working on a fast track project and I am trying unsuccesfully to get my buffered output to work. I have 827 different size buffers of data that I need to output to a digital output. I need to wait until each buffer is output, then call some other functions before outputing the next buffer.
    Although I only want to set one bit on and off I have i16 buffers that contains my data. I have based my program on the 6523SingleBufferedOutput NI-DAQ example. However I do not want to poll the number of buffer elements remaining, I want to use the NI-DAQ event message to tell my code when the DIG_Block_Out function is complete. This appears to be message type 2. I am basing the ev
    ent code from another example in the Function Reference Manual. I have tried both a callback and an window message, but neither function is ever called. I am not sure if the problem is to do with the event configuration or the DO not completing. It does look like only part of my data is being output, however I tried with message type to send a message after n scans and it did not call my functions either.
    I can send code to anyone who is willing to help. Help would be really be appreciated as I am behind now on my project,
    Thanks,
    David

    Here is the code
    CImagePipeline::CImagePipeline(CGilbertDlg* pGilbertDlg, CSettings* pPrintSettings, CFloydFile* pDataFile) :
    m_pGilbertDlg(pGilbertDlg), m_pPrintSettings(pPrintSettings), m_pImageFile(pDataFile), m_nPgTB(0), m_nReqInt(0),
    iRetVal(0), iDevice(1), iGroup (1), iGroupSize (2), iPort (0), iDir (1)
    , iPgConfig (1), iReqSource (0), iExtGate (0), iStartTrigON (1), iStartTrigOFF (0)
    , iStartPol (0), iStopTrig (0), iStopPol (0), ulPtsAfterStopTrig (0), ulPattern (0)
    , ulPatternMask (0), iResource (11), ulRemaining (1), ulAlignIndex (0), iIgnoreWarning (0)
    , iYieldON (1), iDBModeON (1), iDBModeOFF(0), iOldDataStop(1), iPartialTransfer(0), lTimeout(180)
    , m_nStatus(0), iStatus(0), ulCount(0), ulBufferSize(0)
    CalculateTimebase();
    Cleanup();
    CleanupNIDAQEvents();
    ReformatPipelineData();
    m_nStatus = Configure();
    iStatus = SetupNIDAQEvents();
    if (iStatus != 0)
    iRetVal = NIDAQErrorHandler(iStatus, "SetupNIDAQEvents",
    iIgnoreWarning);
    //##ModelId=3D496BB30271
    CImagePipeline::~CImagePipeline()
    CleanupNIDAQEvents();
    Cleanup();
    i16 CImagePipeline:etupNIDAQEvents()
    // declare/initialize local variables
    short iErr = 0,
    iDevCode = 0,
    iTimeBase = 0;
    static short
    ipBuffer[1000] = {0};
    unsigned short
    uSampInterval = 0;
    unsigned long
    ulCount = 1000;
    char cpChanStr[5] = {0};
    * INITIALIZE DAQ Device (optional)
    iErr = Init_DA_Brds(iDevice, &iDevCode);
    CHECK_RETURN_CONDITION(iErr);
    * CONFIGURE DAQ Event
    // setup channel string for DAQ Event
    wsprintf(cpChanStr, "DOGRP%-d\0", iGroup);
    // call Config_DAQ_Event_Message
    iErr = Config_DAQ_Event_Message(iDevice,
    (i16) 1, // add message
    cpChanStr, // channel string
    (i16) 1,// daq event type
    (i32) 1,// DAQTrigVal0
    (i32) 0,// DAQTrigVal1
    (u32) 0,// trigSkipCount
    (u32) 0,// preTrigScans
    (u32) 0,// postTrigScans
    m_pGilbertDlg->m_hWnd,// handle
    (i16) WM_NIDAQ_MSG,// message
    (u32) NULL);// callbackAddr
    CHECK_RETURN_CONDITION(iErr);
    iErr = Config_DAQ_Event_Message(iDevice,
    (i16) 1, // add message
    cpChanStr, // channel string
    (i16) 2,// daq event type
    (i32) 0,// DAQTrigVal0
    (i32) 0,// DAQTrigVal1
    (u32) 0,// trigSkipCount
    (u32) 0,// preTrigScans
    (u32) 0,// postTrigScans
    NULL,// handle
    (i16) NULL,// message
    (u32) &mycallback);// callbackAddr
    CHECK_RETURN_CONDITION(iErr);
    return 0;
    // FUNCTION: CleanupNIDAQEvents
    // CHANGE THIS AS NECESSARY
    void CImagePipeline::CleanupNIDAQEvents()
    * Stop async operation
    DAQ_Clear(iDevice);
    * CLEAR all DAQ Events!
    Config_DAQ_Event_Message(iDevice,
    (i16) 0,
    (i16) 2,
    (i32) 0,
    (i32) 0,
    (u32) 0,
    (u32) 0,
    (u32) 0,
    NULL,
    (i16) NULL,
    (u32) NULL);
    void mycallback(short handle, short msg, unsigned short wParam, unsigned long lParam)
    short doneFlag = (wParam & 0xFF00) >> 8;
    if (doneFlag)
    if (!SetEvent(CGilbertDlg::m_hTrackDone))
    DWORD dwErrorCode = GetLastError();
    void CImagePipeline::GenerateSingleTrackData(int trackNum)
    static i16 piBuffer[400] = {0};
    u32 ulCount = 200;
    iStatus = NIDAQMakeBuffer(piBuffer, ulCount, WFM_DATA_I16);
    if (iStatus == 0)
    m_nStatus = Configure();
    ulBufferSize = ulCount * 2;
    iStatus = Align_DMA_Buffer(iDevice, iResource, piBuffer,
    ulCount, ulBufferSize, &ulAlignIndex);
    iRetVal = NIDAQErrorHandler(iStatus, "Align_DMA_Buffer",
    iIgnoreWarning);
    /* Start the pattern generation output of 100 "items" upon the
    digital start trigger. */
    iStatus = DIG_Block_Out(iDevice, iGroup, piBuffer, ulCount+1);
    iRetVal = NIDAQErrorHandler(iStatus, "DIG_Block_Out",
    iIgnoreWarning);
    else {
    AfxMessageBox(" The buffer was not made correctly. Check the parameters for NIDAQMakeBuffer.");
    short CImagePipeline::Configure()
    short status = 0;
    iStatus = DIG_Grp_Config(iDevice, iGroup, iGroupSize, iPort,
    iDir);
    if (iStatus != 0)
    iRetVal = NIDAQErrorHandler(iStatus, "DIG_Grp_Config",
    iIgnoreWarning);
    status = iStatus;
    /* Configure internally timed pattern generation with timebase
    m_nPgTB, interval m_nReqInt, and no external gating. */
    iStatus = DIG_Block_PG_Config(iDevice, iGroup, iPgConfig,
    iReqSource, m_nPgTB, m_nReqInt, iExtGate);
    if (iStatus != 0)
    iRetVal = NIDAQErrorHandler(iStatus, "DIG_Block_PG_Config",
    iIgnoreWarning);
    status = iStatus;
    /* Configure for digital start trigger. */
    iStatus = DIG_Trigger_Config(iDevice, iGroup, iStartTrigOFF,
    iStartPol, iStopTrig, iStopPol, ulPtsAfterStopTrig, ulPattern,
    ulPatternMask);
    if (iStatus != 0)
    iRetVal = NIDAQErrorHandler(iStatus, "DIG_Trigger_Config",
    iIgnoreWarning);
    status = iStatus;
    return status;
    int CImagePipeline::Cleanup()
    /* CLEANUP - Don't check for errors on purpose. */
    /* Set trigger mode to initial state. */
    iStatus = DIG_Trigger_Config(iDevice, iGroup, iStartTrigOFF,
    iStartPol, iStopTrig, iStopPol, ulPtsAfterStopTrig, ulPattern,
    ulPatternMask);
    /* Clear the block operation. */
    iStatus = DIG_Block_Clear(iDevice, iGroup);
    /* Unconfigure group. */
    iStatus = DIG_Grp_Config(iDevice, iGroup, 0, 0, 0);
    int numTracks = m_pImageFile->m_FileHeader.get_NumTracks();
    for (int trackNum = 0; trackNum < numTracks; trackNum++)// loop through all tracks
    if (m_vTrackData.size()>0)
    if (m_vTrackData.at(trackNum))
    delete m_vTrackData.at(trackNum);
    return iStatus;
    void CImagePipeline::CleanupNIDAQEvents()
    * Stop async operation
    DAQ_Clear(iDevice);
    * CLEAR all DAQ Events!
    Config_DAQ_Event_Message(iDevice,
    (i16) 0,
    (i16) 2,
    (i32) 0,
    (i32) 0,
    (u32) 0,
    (u32) 0,
    (u32) 0,
    NULL,
    (i16) NULL,
    (u32) NULL);

  • How to handle event structures for two buttons and two counters.

         *I have two buttons A and B, and have to compare the difference in hits between them.  So do I place an event structure within a while loop for each button (2 buttons, 2 event structures, 2 while loops), or does it need to be one event structure with cases for both buttons whithin one while loop? 
         *How do I pass the values of buttons A and B's hit counters out of the while loop in order to calculate the differences between them after each increment, not just the final count after the stop button is hit? 
         *How would I make one stop button work to handle both buttons A and B?   I tried to place the actual stop button in one button A's structure and its global in B's structure, but It wont seem to let me use a local variable for a latchable control
    Checker

    You should probably have not started a new thread and waited until your question in the original thread was answered. You can modify altenbach's example for a second button. You have a single event structure with a new event for the second button. You have a second shift register to track the number of times the second button is pressed. Inside the while loop but outside the event structure, you just have a subtract function in or to report the difference. do not modify the posted example for the stop button. It works perfectly as is.

  • Event Structure Edit Window

    I am using LabVIEW 2013. When I place an event structure on the BD and right clikc and 'Add Event Case' or 'Edit Events Handled by This Case' the Edit Events window does not pop up.  An animation happens like it has opened up but the window is no where to be seen.  If I try to click anywhere else in labview my computer just beeps at me like the window is open and I'm clicking outside of it. If I press Esc I can get back to my BD and continue as normal. Unfortunately I can't edit my events.  Any ideas? Is there some option I may have changed that is making this happen? 
    Thank you for any help
    Jesse Zamora
    P.S. This is happening in a VI I started this morning and it also happens in a new VI.
    Solved!
    Go to Solution.

    Close LabVIEW
    Look in LabVIEW.ini for "EditEventsDlgSize="
    delete the line.
    you should have much joy.  (this appears to be a known issue)
    Jeff

Maybe you are looking for