Two threads in a Panel

Hello
I am developing a vision with CVI application that loads the files. VBAI after login... the application interface has two positions (left and right)... I want the two buttons START calls the same function CVICALLBACK (Inspection)... and this function call the function ThreadFunction and its parameter's thread (thread number)...
I said two tables of the elements to control the two threads and I worked on these tables in the treatment ThreadFunction function...
Now, I didn't understand how I spend the number of thread for the CVICALLBACK inspection function, in fact, when I click START on left position inspection begins on the left, where it starts on the right, also, if I click on the two positions, she sailed on two positions...
Thank you for your help, it's urgent

#include 
#include 
#include 
#include 
#include 
#include "toolbox.h"
#include "nivision.h"
#include "VBAIInterfaceC.h"
#include "ann.h"

static int panelHandle;
static CmtTLVHandle tlvHandle = 0;
static volatile int exiting = 0;

static int Tab_serial_num[2]={PANEL_SERIAL_NUM,PANEL_SERIAL_NUM2};
static int Tab_inspec_name[2]={PANEL_INSPECTION_NAME,PANEL_INSPECTION_NAME2};
static int Tab_inspec_butt[2]={PANEL_INSPECT_BUTTON,PANEL_INSPECT_BUTTON2};
static int Tab_ecr_acc_stat[2]={PANEL_ECR_ACC_STAT,PANEL_ECR_ACC_STAT2};
static int Tab_led_metro_stat[2]={PANEL_LED_METRO_STAT,PANEL_LED_METRO_STAT2};
static int Tab_led_vert_stat[2]={PANEL_LED_CPL_VERT_STAT,PANEL_LED_CPL_VERT_STAT2};
static int Tab_led_rouge_stat[2]={PANEL_LED_CPL_ROUGE_STAT,PANEL_LED_CPL_ROUGE_STAT2};
static int Tab_led_jaune_stat[2]={PANEL_LED_CPL_JAUNE_STAT,PANEL_LED_CPL_JAUNE_STAT2};
static int Tab_lcd_off_stat[2]={PANEL_LCD_OFF_STAT,PANEL_LCD_OFF_STAT2};
static int Tab_lcd_on_stat[2]={PANEL_LCD_ON_STAT,PANEL_LCD_ON_STAT2};
static int Tab_main_window[2]={PANEL_MAIN_WINDOW,PANEL_MAIN_WINDOW2};
static int Tab_test_stat[2]={PANEL_TEST_STATUS,PANEL_TEST_STATUS2};
static int Tab_text_error[2]={PANEL_ERROR_TEXT,PANEL_ERROR_TEXT2};

void DisplayError(VBAIError error);
void ButtonStatDisplay(void);
void IndicatorStat(int ind, bool32 stat ) ;
static int CVICALLBACK ThreadFunction (int thread) ;

/*static int SetupApplication (void);
static int ShutdownApplication (void);*/

int main (int argc, char *argv[])
{   

    if (InitCVIRTE (0, argv, 0) == 0)
        return -1;  /* out of memory */
    if ((panelHandle = LoadPanel (0, "ann.uir", PANEL)) < 0)
        return -1;

...;

    ...;

    DisplayPanel (panelHandle);
    RunUserInterface ();
    DiscardPanel (panelHandle);

if (stepResults != NULL)
    free (stepResults);
    vbaiCloseConnection (session, 1)  ;

    return 0;
}

void DisplayError(VBAIError error)
{
    ...;

void IndicatorStat(int ind, bool32 stat )
{
    ...;
}

int CVICALLBACK INSPECTION (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    VBAIError error = VBAIErrorSuccess;

    switch (event)
    {
        case EVENT_COMMIT:

            !!!!!!!!! The problem !!!!!!!!!!                       

        break;

    }
    if (error)
        DisplayError(error);
    return 0;
}

static int CVICALLBACK ThreadFunction (int thread)
{   

....;

        while(!exiting){

                SetCtrlAttribute(panelHandle,Tab_inspec_name[thread],ATTR_DIMMED,0);

                     ;

                        switch(i) {
                        case 0: IndicatorStat(Tab_ecr_acc_stat[thread],inspectionStatus);
                                 break;

                        case 1: IndicatorStat(Tab_led_metro_stat[thread],inspectionStatus);
                                break;

                        case 2: IndicatorStat(Tab_led_vert_stat[thread],inspectionStatus);
                                break;

                        case 3: IndicatorStat(Tab_led_rouge_stat[thread],inspectionStatus);
                                break;
                               ;

                        case 4: IndicatorStat(Tab_led_jaune_stat[thread],inspectionStatus);

                               break;

                        case 5:IndicatorStat(Tab_lcd_off_stat[thread],inspectionStatus);

                               break;

                        case 6: IndicatorStat(Tab_lcd_on_stat[thread],inspectionStatus);

                               break;

                     }

                     Delay(0.5);
                     ...;
...;
...;

Hi schweini,.

Your thread function prototype doesn't seem correct.

His entry should be a void pointer, not an integer.

To switch to the thread of your button on which it started, you can use this setting.

But you will need to pass a pointer to a valid variable.

In your feed, you will get the value of the data pointer dereferencing.

Here's a code sample (nickname).

See if it makes sense.

//in your Start callback
static int start; //static is crucial here

switch (event)
{
  case EVENT_COMMIT:
    start = (control == PANEL_START_1 ? 1 : 2);
    CmtScheduleThreadPoolFunction (pool, ThreadFunction, &start, &funcId);
  break;
}

//in your thread function
int CVICALLBACK ThreadFunction (void *data)
{
  int which_side;

  which_side = *((int*)data);

  while (!exiting)
  {
    if (which_side == 1)
    {..}
    else
    {..}
  }
}

Tags: NI Software

Similar Questions

  • Merge two threads in the same person into one iMessage

    I know that this issue has been addressed before. Most importantly, the discussion was on did not understand what the problem is.

    So let me try to explain.

    Tarzan has an iPhone and an iMac, Jane also has an ios device.

    When Tarzan Jane sends an iMessage with his iPhone, Jane receives from "Tarzan" (the iMessage was related to his phone number)

    Now, when Tarzan sends Jane an iMessage of its iMac, Jane receives from "Tarzan", but in a separate thread. (This iMessage was related to his email address)

    Now Jane is in danger and she wants Tarzan to rescue her, she grabs his iPhone, opens the last conversation with Tarzan and Tarzan 'Help texts

    But Tarzan in the jungle and he has only his iPhone with him.

    Jane get killed because the imessage is sent to the iMac of Tarzan and not to his iPhone.

    ====

    The problem is, you get two threads in the same person, are sent to the e-mail address associated with the iMessage, one for the phone number.  But you can't see the difference between the two (except when you dig deep into the background-info).

    If my suggestion of Apple is, they appreciate Jane's life, fix this problem soon: merge those two threads into one.

    PeterSmith wrote:

    I know that this issue has been addressed before. Most importantly, the discussion was on did not understand what the problem is.

    So let me try to explain.

    Tarzan has an iPhone and an iMac, Jane also has an ios device.

    When Tarzan Jane sends an iMessage with his iPhone, Jane receives from "Tarzan" (the iMessage was related to his phone number)

    Now, when Tarzan sends Jane an iMessage of its iMac, Jane receives from "Tarzan", but in a separate thread. (This iMessage was related to his email address)

    Now Jane is in danger and she wants Tarzan to rescue her, she grabs his iPhone, opens the last conversation with Tarzan and Tarzan 'Help texts

    But Tarzan in the jungle and he has only his iPhone with him.

    Jane get killed because the imessage is sent to the iMac of Tarzan and not to his iPhone.

    ====

    The problem is, you get two threads in the same person, are sent to the e-mail address associated with the iMessage, one for the phone number.  But you can't see the difference between the two (except when you dig deep into the background-info).

    If my suggestion of Apple is, they appreciate Jane's life, fix this problem soon: merge those two threads into one.

    IMessage works as it should.

    There is also no apple here to read your thread in this forum for a user to.

    You can send your comments here http://www.apple.com/feedback/

    If Jane was smart it would always send you an imessage using your phone number and not apple id.  Here again, you can add your apple ID to imessage on your phone.

  • Dial the two thread simultaneius http

    In my application I want a main (UI) Thread and two other thread that runs at the same time, now in both the wire I want HttpConnection appeal, so it is possible for both the thread do HttpCall?

    I want to know - is it possible?

    Because if one thread calls Http between another thread also do Http call connection so that it will give the error as "Stream already open" because the first thread was opened the stream and before the closing of the first stream son second thread will open the stream, so please help me on this...

    Thank you

    There is nothing on the Blackberry that will prevent both two threads made http URLs of connections to the same (or other) at the same time.

    So the answer to your question is 'Yes it is possible. "

    Ok?

  • Two screen question: Control Panel appears on the screen 1 but the mouse is on the screen 2 and so I can't access

    I have a Sony Vaio laptop connected to a stand alone monitor. I don't use the laptop screen unless there is a problem and then I had to alternate between the two screens using Fn F7 key.

    A problem has occurred with the rundll32 process (which I'm trying to fix separately) and this led to the PC automatically flicking between screens and then stick with the independent monitor but in low resolution (so I couldn't access the tool bar along the bottom).

    I went to control panel to change the resolution to high, but the question of rundll32 kept close the process.

    This left me with icons on the desktop of the monitor stand alone, a white color on the laptop screen (it is normally black) and the ease of Fn F7 does not (said the service is not available).

    When I click on Control Panel on the screen of stand alone, it opens on the screen of the laptop, but I can't access it because the function of the mouse is on the screen to stand alone.

    Can someone help before I go out drinking?

    Thanks, Temp.

    I seem to have solved the problem. It seems that display order has been reversed and so I just had to move the mouse to the right of the screen to stand alone (I had been pushing against the left hand side) to move on the screen of the laptop. From there on, I played a bit with the display settings in the control panel and, although the issue of the always kept dllrun32 throw me out, seems to be back on the screen of stand-alone only, with the correct resolution and the Fn f7 works again. This means I can put the top back on bottle of vodka, at least until the next issue of dllrun32 arises.

  • The task bar has two control panel icons

    The task bar has two icons in Control Panel. When I added my office to the two taskbar Control Panel icons apperded. (I have the taskbar right-click, then toolbars and selected Desktop). I can delete the second icon in Control Panel, but it returns to the restart. I found as subjects during a Google search. Someone else has the same double icons? Is there a fix to Windows? I am running Windows 7 on the new system.

    That did not work.

    It does not - it did for me when I go from 7 to 8 and then 8 to 8.1

    You MUST delete a registry key.

    Create a file "deleteCPIcon.reg" with:

    Windows Registry Editor Version 5.00  [-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}] 

    Run the file

    Voila!

  • What is the name of the circular icon with two swings in the content panel?

    Adobe Bridge CS5

    Win 7 Pro 64-bit

    What is the name of the circular icon with two swings in the Panel content above the thumbnail image of a raw file? I can't find documentation about it.

    Thanks in advance.

    Thanks for the keyword "badge".

    With that, I found it's called a

    "Badge of parameters.

    There is also a badge of culture which has an icon of culture.

  • Thread of messages with false contacts

    I have a thread of messages which, since the installation of Sierra is showing the wrong contact and the mix of messages from the two contacts.

    It seems that this is because the two contacts work for the same company and have identical entries their: 'work' of phone field. If I remove the scope one of the contacts and Messages to restart, the thread returns to two threads separated by the correct contact.

    The two contacts have iPhones and different MOBILE numbers that show as being related to separate Apple ID I assume that before I upgraded, Contacts, or Messages has been able to use this information to treat them as separate persons. Also, I assume that's the way it should work.

    How do I get things to normal?

    Thank you very much

    Christian

    Hello

    Change/edit the name of the field map to read 1 or something that prevents the binding.

    Report it here http://www.apple.com/feedback/ (there is no one of the separated Contacts).

    22:00 Friday. September 30, 2016

     iMac 2.5 Ghz i5 2011 (El Capitan)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro (Snow Leopard 10.6.8) 2 GB
     Mac OS X (10.6.8).
     iPhone and iPad (2)

  • Firefox displays the two shockwave for Director 12.0.7.148 &amp; 12.0.5.146 plugins

    I am running firefox 26 and when I discovered my plugins (Tools > Modules > Plugins), I see the two Shockwave for Director, 12.0.7.148 and 12.0.5.146. When I click on the link "Check to see if your plugins are up to date", Shockwave for Director 12.0.7.148 is the only one that is listed and also shows to date.

    Is this all true, or I have to delete 12.0.5.146 and if so how?

    Thank you
    Robert

    You can remove the older Shockwave for Director plugin or remove the two (uninstall via Control Panel).

    Shockwave for Director is a different plugin than the Shockwave Flash Player and hardly use these days.

  • CmtGetLock Casuing a single thread to gel

    Hello.

    I have a test system that two identical test DUT simultaneously using two threads of the same code. Within these two threads, I need threads so that a single physical interface can be shared between the two units under test.

    My problem is that sometimes (randomly) either one of the threads seems to freeze the call of CmtGetLock and will not respond until the test software has been stopped and restarted. The other thread which does not freeze may focus on tests without problem when the other freezes.

    The vesion cut down my code is something like below:

    CmtNewLock ("Local\\UUT_IFDLL", OPT_TL_PROCESS_EVENTS_WHILE_WAITING, & gLockSTBinterfaceDll);

    |

    |

    blah blah blah

    |

    |

    CmtGetLock (gLockSTBinterfaceDll);    This is where one or other of the sons still freezes.

    |

    Use the hardware interface

    |

    CmtReleaseLock (gLockSTBinterfaceDll);

    |

    blah blah blah

    |

    Can someone suggest a reason for this? What is an OS/PC problem?

    Thank you.

    Neil.

    It looks like a block for me:

    -acquired by thread A and, for some reason, forget to release him.

    -B is waiting for the lock, which is not available since thread A does not release it.

    -wire can runundisturbed since he already has the lock, it can again acquire any number of times where he wants.

    B is waiting forever...

    are you absolutely certain that there is no path of early exit between the acquisition and the release of the lock? no way to NOT release the lock?

    I mean absolutely certain as in: no return, no break, no goto, no incomplete if... else..., asymmetrical strapless, no possible software exception, nothing that breaks the flow of control...

  • Avoid to get two theards at the same time

    Hello

    I was wondering how to avoid to run two threads at the same time in teststand. When I using teststand, I found it can run two threads in simultaneity.for example, I can open a file sequence, using single-pass enter point to run a theard, when this theard is not finished, I use single-pass or TestUUTs enter point to run other theard. I want to avoid this case. Is there settings, we can get motor teststand to tell me a thread is running or not?

    Thank you!

    You write a custom user interface? If you use an application Manager (all the example user interfaces and the sequence editor to do), you can see:

    ApplicationManager.Executions.Count > 0

    If you use just the engine that you can keep the number of executions by increment your account upon receipt of the UIMsg_StartExecution UIMessage and reduce your number when UIMsg_EndExecution is received.

    If instead you want to determine the number of executions of a sequence running, you can use RunState.Engine.GetInternalOption () to get a reference to the Application Manager (at least of the UIS and the sequence editor that use an Application Manager) and then do the following ActiveX to get the Executions.Count property.

    Hope this helps,

    -Doug

  • Received a screw naked on X 200 panel memory!

    Greetings.

    One of the two screws on the Panel on the underside of the laptop is stripped. It does not illuminate with the appropriate screwdriver. The other is fine. I have not forced, nor if I caused the damage: I received the laptop (bought new) in that State.

    The X 200 is a model of 7454-CTO.

    How can I solve this problem? Clearly, I can't upgrade the RAM if I can't open the RAM Panel.

    Thanks to anyone who might help.

    Peace,

    Claudio

    Well, I solved the problem eventually. Got a slightly larger screwdriver and who did it. Eventually, I'll look for a screw of a similar size to replace this one. So I will not communicate with Lenovo or send the laptop in assistance.

    Regarding the recovery CD, I didn't know that the ThinkPads came without. It's a great disappointment. I'm assuming that they did, as it is quite normal. I bought the operating system, after all. I'll have to find something now, because I want to do a clean install.

  • feature request - alignment of the execution of the front panel window

    I would like he's had a "pair of coordinates", marked by two positions on the Panel before which would serve the rectangle to display at the top left and bottom right positions itself for my front panel when executing. Then I wouldn't have to worry about the State of my eyes when I left edition.  I could simply mark the limits of the display and be assured that all the controls and indicators that were intended to be seen at runtime, would be visible and properly aligned with the window of the group.

    I advise you to take a look at this blog post, that addresses exactly your problem.

    It is the functions of the toolkit OpenG VI Fit window largest decoration.

    Tone

  • maximum number of threads help

    Hello

    In my application, I have download several files simultaneously over a network.

    Can someone recommend me the maximum number of threads that I can run to do this in a safe way.

    See you soon

    nish1013 wrote:

    Alll TX,

    For example, in the simple,.

    the event wire + another wire is the most secure solution?

    or you guys meant extra two threads outside the event thread?

    See you soon

    No, we mean more than two download son. Your application may have a large number of threads, but you'd better not keep more than two connections open at the same time http.

  • Network UI Thread blocking

    Hello everyone, I am developing an app for Blackberry wich uses networking capabilities. The query is executed by pressing a button with the following code:

     mainButton=new BitmapButton(Bitmap.getBitmapResource("elcomercio.gif"), Bitmap.getBitmapResource("elcomercio.gif"), Field.FOCUSABLE){
                protected boolean navigationClick(int status,int time) {
                    //It automatically add itself to the screen stack
                    waitScreen=new WaitScreen();
                    TimeOutThread timeOut=new TimeOutThread(HomeScreen.this, 10000);
                    HttpHelper helper=new HttpHelper("http://www.elcomercio.com/rss/latest", null, HomeScreen.this, HttpHelper.GET);
                    UiApplication.getUiApplication().invokeLater(timeOut);
                    UiApplication.getUiApplication().invokeLater(helper);
                    return true;
                }
            };
    

    As you can see TimeOutThread and HttpHelper inherit both Thread, so that they can be called outside the main flow of execution.  Two of them also receive the current as a delegate object screen, so that I can execute methods later on the screen. in this case timeout executes the following function.

    public void onTimeout() {
            if(!didTimeout.booleanValue()){
                UiApplication.getUiApplication().popScreen(waitScreen);
                didTimeout=Boolean.TRUE;
            }
        }
    

    The timeout method is called sucessfully... even the waitScreen is poppedOut with success and the last screen is shown. But the user interface crashes right now... it is like the HttpThread I got runs always block the user interface... I know, because when the network thread times out... the user interface is responsive again. What I am doing wrong?

    You do not use your son as separate threads - instead, plan you on the event Thread run() methods (this is what invokeLater). The right way is to use their start() methods to start two threads separately. So, replace your

    UiApplication.getUiApplication().invokeLater(timeOut);
    

    with

    timeOut.start();
    

    and do the same with your thread for assistance.

    Good luck!

  • threads and oracle jdbc driver

    Hello

    I can't understand the following:

    JDBC Oracle driver supports multithreaded applications, but the 'connection' object cannot be used at the same time by two threads, so one of the threads will have to wait for each other.

    The idea: these threads call a stored database procedure.


    We can still talk about concurrency in this case, discussions, sharing the same object of "connection"? Or it is a series access?

    Thank you in advance.

    a single connection can have a database at a time.

    Good bye

    DPT

Maybe you are looking for