Thread's controlling problem

I created a thread with in a thread. While I am running program, both threads are running at a time. I want to pause the parent thread until the child thread is alive. After the child thread stops then only the parent thread again has to be start. Any answer

In parent thread, do
childThread.start();
childThread.join();
// more processing
True. That's better.
/Kaj

Similar Messages

  • Establishment of XA "Thread of Control" in a Tuxedo application

    Hello there,
    I am assigned the task of developing an XA compliant resource manager so that a client can use the C interface to our JMS messaging system from a Tuxedo application and have the application's transactions managed by it. The query I have here is abbout establishing the "thread of control" in a Tuxedo context. I'll set out my understanding and the particular queries that I have in the hope that you can confirm whether my understanding is correct and maybe point me in the right direction.
    The XA Specification clearly sets out the requirements for
    successful distributed transaction processing, and the important roles within this for the three participants: the application programme (AP), the resource manager (RM) and the transaction manager (TM). The key concept in XA is the Thread of Control as described in section 2.2.8 of
    the specification. Here is the paragraph describing the pivotal role that identification of thread of control has in transaction coordination:
    <quot>The thread concept is central to the TM's coordination on RMs. APs call RMs to request work
    while TMs call RMs to delineate transaction branches. The way the RM knows that a given work request pertains to a given branch is that the AP and the TM both call it from the same thread of control. For example, an AP thread calls the TM to declare the start of a global
    transaction. The TM records this fact and informs RMs. After the AP regains control it uses the native interface of one or more RMs to do work. The RM receives the calls from the AP and TM in the same thread of control.
    Certain XA routines, therefore, must be called from a particular thread.</quot>
    In developing a RM the key question is what should be used to identify thread of control so that work can be properly assigned to the correct transaction or more specifically XID. The obvious choice here is the thread identifier itself (such as would be returned by
    PRThread* PR_GetCurrentThread(void) when using the Netscape Portable Runtime library).
    As long as AP, RM and TM are all in one process this is not a difficult problem, however many threads may
    be created. It will also work for in our messaging system in the case where branches of the same transaction are executed in separate processes of this type. This is because "transaction assembly" occurs on the "server" when JMS messages are received there. A Message is assigned to a transaction on an individual basis. This also gives us the flexibility to implement various connection pooling mechanisms or use a single connection to transfer messages
    for many different transactions along with messages not participating in an XA transaction at all.
    However, Tuxedo presents a challenge as there cannot be a single thread in this sense as the participants are distributed across several processes. These processes are respectively, client; server and RM; TMS. There are at least two TMS to avoid blocking problems and potentially very many server-RMs. Given this situation how then is it possible for the RM to match up units of work requested by various services with the XIDs that it has been informed of by the TMS? One assumes that a different thread will run in the server/RM process for:
    a) TMS to indicate to RM that a transaction has started, ended, etc., one distinct thread for each of these calls.
    b) service execution, one distinct thread for each call, where there may be many of these making up
    the work of one transaction
    It is obviously preferable from our point of view that our RM should not have to use Tuxedo specific code, but if this is unavoidable then we shall have to live with it.
    BTW in case it is relevant I'm assuming that the RM will not use dynamic registration.
    Thanks for any help,
    Gillian Horne

    Gillian,
    When Tuxedo issues an xa_start() call, the matching xa_end() call will
    always be executed in the same thread of the same process.
    If another xa_start() is executed at a later point for the same transaction,
    that call could be made in a different process, in a different thread of the
    same process, or in the same thread of the same process.
    Tuxedo will call xa_end() with the TMSUSPEND|TMMIGRATE flag pair only for
    certain CORBA transactions. If your application does not use CORBA, then it
    would be acceptable to develop an RM with the TMNOMIGRATE flag set in the RM
    switch. Tuxedo does not use asynchronous XA operations, so you do not ened
    to develop an RM with the TMUSEASYNC flag set.
    The xa_prepare() call for a particular transaction branch can be made in
    different process or thread from the xa_commit() or xa_rollback() call that
    follows it.
    Except in the case of transactions started with the Tuxedo AUTOTRAN feature,
    the xa_prepare() and xa_commit() calls for a particular transaction branch
    will almost always be made in different processes from the processes that
    performed xa_start()/xa_end() calls for that transaction branch.
    There shouldn't be any need to write special RM code for Tuxedo. Popular
    RMs such as Oracle, Informix, DB2, MQ Series, and others have all been able
    to work with Tuxedo, with the former Top End product, with Encina, and with
    other transaction monitors.
    I hope this information is of help in implementing your RM.
    Ed
    <Gillian Horne> wrote in message news:[email protected]...
    Hello there,
    I am assigned the task of developing an XA compliant resource manager so
    that a client can use the C interface to our JMS messaging system from a
    Tuxedo application and have the application's transactions managed by it.
    The query I have here is abbout establishing the "thread of control" in a
    Tuxedo context. I'll set out my understanding and the particular queries
    that I have in the hope that you can confirm whether my understanding is
    correct and maybe point me in the right direction.
    The XA Specification clearly sets out the requirements for
    successful distributed transaction processing, and the important roles
    within this for the three participants: the application programme (AP), the
    resource manager (RM) and the transaction manager (TM). The key concept in
    XA is the Thread of Control as described in section 2.2.8 of
    the specification. Here is the paragraph describing the pivotal role that
    identification of thread of control has in transaction coordination:
    <quot>The thread concept is central to the TM's coordination on RMs. APs
    call RMs to request work
    while TMs call RMs to delineate transaction branches. The way the RM knows
    that a given work request pertains to a given branch is that the AP and the
    TM both call it from the same thread of control. For example, an AP
    thread calls the TM to declare the start of a global
    transaction. The TM records this fact and informs RMs. After the AP regains
    control it uses the native interface of one or more RMs to do work. The RM
    receives the calls from the AP and TM in the same thread of control.
    Certain XA routines, therefore, must be called from a particular
    thread.</quot>
    In developing a RM the key question is what should be used to identify
    thread of control so that work can be properly assigned to the correct
    transaction or more specifically XID. The obvious choice here is the thread
    identifier itself (such as would be returned by
    PRThread* PR_GetCurrentThread(void) when using the Netscape Portable Runtime
    library).
    As long as AP, RM and TM are all in one process this is not a difficult
    problem, however many threads may
    be created. It will also work for in our messaging system in the case where
    branches of the same transaction are executed in separate processes of this
    type. This is because "transaction assembly" occurs on the "server" when JMS
    messages are received there. A Message is assigned to a transaction on an
    individual basis. This also gives us the flexibility to implement various
    connection pooling mechanisms or use a single connection to transfer
    messages
    for many different transactions along with messages not participating in an
    XA transaction at all.
    However, Tuxedo presents a challenge as there cannot be a single thread in
    this sense as the participants are distributed across several processes.
    These processes are respectively, client; server and RM; TMS. There are at
    least two TMS to avoid blocking problems and potentially very many
    server-RMs. Given this situation how then is it possible for the RM to match
    up units of work requested by various services with the XIDs that it has
    been informed of by the TMS? One assumes that a different thread will run in
    the server/RM process for:
    a) TMS to indicate to RM that a transaction has started, ended, etc., one
    distinct thread for each of these calls.
    b) service execution, one distinct thread for each call, where there may be
    many of these making up
    the work of one transaction
    It is obviously preferable from our point of view that our RM should not
    have to use Tuxedo specific code, but if this is unavoidable then we shall
    have to live with it.
    BTW in case it is relevant I'm assuming that the RM will not use dynamic
    registration.
    Thanks for any help,
    Gillian Horne

  • User Account Control Problems with Premier Elements 7 32 bit in 64 Bit Windows 7

    I found User Account Control Problems in other forums but didn't see much in Premiere Elements, so I hope this helps others who may be having problems with 32 bit programs in a 64 bit computor. When I first got my 64 bit I didn't have problems.
    Back in February I bought a Quad Core Desktop with Windows 7 64 bit. Haven't been on the forum for 7 months since I wrote in regarding importing video with the Pyro AV Link (Premiere Elements Tips and Tricks). I was having problems importing video which started after March 28 sometime, as that was the last time I didn't have a problem importing VHS. Took me a few months off and on to find out what worked.
    I started uninstalling Windows updates and any programs I had installed back to that point in time. Checked after uninstalling each item. The capture screen would come up on a delayed basis but clicking on capture did nothing. Although no driver is required for IE1394 (so they say) I read where some people using the Legacy driver had fixed some problems, so I switched to the Legacy. Seemed to work great (for a few minutes).
    I had even uninstalled and reinstalled PE7 but no difference. Finally I noticed a shield in the PE7 Desktop icon. Thats weird. Never had that before. Just decided to show up after I had done all of the stuff I mentioned. Turns out at some point in time since I've had the computor Windows 7 decided to flag my 32 bit program as misusing the 64 bit system. User Account Control. I never bothered too much with UAC and just clicked on the yes box wen it popped up asking if I wanted this or that to take control of my computor. I tried using the minimum setting for safety reasons, and then finally turned User Account Control off. Bingo! PE7 capture works again and still working.
    While I am not recommending that people arbitrarily turn UAC off, this appeared to be my problem. I would recommed that they try turning it off before uninstallin a bunch of stuff. Having a restore point may or may not have been a fix for me. I think one of the Windows Updates caused the problem but I am not going to uninstall any more stuff at this point, I have not been back on the internet or installed any more updates in my desktop. I am going to use my laptop for internet and used the desktop for video.
    I am guessing this could be a problem for any 64 bit systems trying to use 32 bit programs. IE: XP,Vista,Windows 7 64 bit. In Vista there is also Data Execution Prevention (DEP) which you can turn on or off, supposedly to prevent misuse of memory (as I understand it), but Win7 either doesn't have it or I haven't found where it's located.
    Maybe this has been covered in the forum somewhere and I missed reading it. Hope I am not too confusing. Anyway, whatever feedback you guys have would be great.  

    John,
        Thanks for your answer, and I did check out the link you suggested. However, I have Windows 7 Home Premium as most people have I think, and the XP program was not available. I started with Vista and now have Win 7. I never could navigate around in XP anyway so am content to just leave User Account Control off.
        Interesting side note to turning UAC off is that my desktop seemed to be using more of the CPUs, where half of them were "Parked" as I wrote in also about 7 months ago when I 1st got my desktop. I am pleased to say that video processing seems to go quicker with UAC off. Have to observe things some more to confirm.
        I just thought if others were having problems after installing Windows Updates and leaving UAC off worked then they could possibly pinpoint a problem.

  • Control problem

    I create a swf by Flash locally which point to a flv in a
    remote flash media server, FLVplayback component included, it work
    fine locally. Uploaded to FMS3, played without the control problem,
    such as Play/Pause, seek bar.
    Is it something I need to configure in FMS, or in Flash.
    Please advice.
    Thanks!

    Between version 1.0 and 2.0 the API in the JBCL controls has
    changed. We are actually moving away from JBCL completely (please
    do send feedback if you have a comment on that) to a Swing and
    Infobus standard based library of visual JavaBeans.
    You will still be able to use the JBCL controls in JDeveloper
    2.0. The best thing to do is to take your 1.x based application
    AND the 1.x based JBCL.ZIP file into your new environment. This
    way you will be able to continue to use these apps and
    components. Taking the 1.x JBCL.ZIP file will make sure you have
    the same version of the JBCL library that you were used to in
    version 1.x.
    Hope this help,
    -Roel.
    Hans Duijn (guest) wrote:
    : Hi,
    : I developed an applet in v1 that worked fine. I tried to
    rebuild
    : the applet in v2 but some problems occured. One, The
    : ChoiceControl populated with the method
    : 'ChoiceControl1.setItems' but in v2, this does not work till a
    : explicitly called 'queryDataset.open'. Is the way to do it or
    do
    : I have to use special properties for the
    dataset...and...second,
    : I'm using an listControl that, in response to a selected item
    in
    : the ChoiceControl, changes frequently. No new list appears till
    : I update the applet the hard way (hide it and bring it to
    front)
    : or click the mouse on the hidden items. 'listControl.repaint()'
    : has no result. Am I doing something wrong? It worked in v1...
    : and third...when can we expect the final version 2?
    : Thanx.
    null

  • MEGA 865 fan control problems after suspend/hibernate.

    I'm seeing the CPU fan control problems, and it's REALLY ANNOYING, as it means I have to leave the machine on all the time. Specifically, after suspending or hibernating the machine, on wakeup the CPU fan goes to full speed and STAYS THERE until I reboot.
    This is on a CLEAN INSTALL of Windows XP.
    Is there going to be a fix for this from MSI soon? Because it's really ruining the experience of using the MEGA.

    Hi guys,
    I have builded a Mega 651 attaching a Celeron 2.4 Ghz.
    I installed the cooler but I got really scared when I realised that the fan run for 2 secs and then stopped.
    Is this normal?
    If yes then i am assuming that the voltage of the fan is controlled by a thermal sensor, meaning that the fan goes on when the temperature reaches a certain limit.
    Can the threshold temperature be controlled from bios so I can set it to minimum possible?
    thanks in advance

  • My I phone 4 have volume control problem did anybody know how to fix

    My I phone 4 have volume control problem did anybody know how to fix thankyou

    Try force closing the Photos and Maps apps, then resetting your phone:  double-tap the home button, locate Photos in the list at the bottom, tap and hold it until it wiggles, tap to close it.  Now locate Maps and tap to close it as well, finish by tapping the home button.  Now reset your phone: hold the on/off and home buttons until your see the Apple logo (ignoring the off slider that appears first), then release.  See if that clears things up.

  • Topic : Alesis Master Control Problem (to previous post unanswered fixed)

    Topic : Alesis Master Control Problem to the original post user: Garrud
    Me:111984cz i have an answer to ur problem.i too had the same problem with cubase 5 ,Nuendo 4 and any of Steinberg softwares with the alesis master-control studio interface. i hope u run into this to learn my fix.
    the problem is check ur midi input on your actual track.make sure it says to (master-control midi port) and not (all midi inputs).as for your device manager settings set to (master-control port) don't set your midi to all or master control port as it will interfere .now it will work perfect.this is for all who have the same problem as well.hope this helps many as i spend a lot of hours of trouble shooting.i almost thought there was something wrong with my mixer.have a great day guys!!
    Original post:
    I've installed the MasterControl driver as instructed and followed the logic set up instructions provided with the MC and all that seems to happen is the Controller acts as a midi keyboard playing different notes rather than the intended function.
    e.g if i touch one of the faders it plays a high pitched note and if i move the fader it acts like the note is being pitched, like a pitch bend function on a keyboard.
    Very strange...cannot figure out whats going on
    PLEASE HELP I'M GOING INSANE
    MacBook Pro Mac OS X (10.6.4)

    I too had the same problem and resolved it.
    However, I have had nothing but issues with the Alesis Mastercontrol since it arrived last week. I purchased mine second-hand as a replacement to a Fire-Wire / Analogue mixer made by Mackie (Onyx 1220). A fantastic amp, but not a control surface.
    I decided I wanted an all rounder, plus something I could place in-front of my iMac so I could work on the fly.
    So...
    1) Alesis Mastercontrol
    2) 1 x Rode microphone in Ch1
    3) 1 x Rode microphone in Ch2
    4) Peavey guitar in Ch3
    I use Logic Studio Pro 8.
    I finally figured out how to get the Alesis to behave and interact with Logic. So far so good!
    I then ran into a series of issues that are frustrating me.
    I cannot get the microphones to mute properly (I would also complain about the poorly position gain dials at the back of the unit for the microphones. So poor indeed that I have purchased an Art mic preamp to slap into the back (not arrived yet) and by-pass the rear controls).
    I also cannot get my semi-acoustic Peavey to record at all. I can hear it through the control desk, but it is much lower than expected and I am getting nothing when I try to record). In record mode the pair of mics record and I can't get the 3rd channel to operate, although it looks like it's functioning on the screen. I try MUTE / SOLO and selecting the correct channel, but nothing!
    All I can do is record myself playing guitar through the mics I cannot switch off.
    Strange machine! Almost wishing I'd not sold my Mackie Onyx 1220 so swiftly.

  • Another volume control problem after installing new software

    I'm having a different volume control problem than the previous poster.
    When I turn my ipod touch on, the volume control stays on the screen. I can't do anything to get rid of it. When I go into settings/sounds, the control goes away on the screen, but it will not let me turn the volume up. When I try to listen to music through my headphones, I can turn the volume up but then it automatically turns itself down. The same thing happens when I try to turn the volume up from the side control. It worked fine this morning before I installed the new software and now it's acting buggy. Any ideas on how to fix this?

    Friend should do an update again your team blackberry.
    Remember to make a backup with Desktop Manager and the BlackBerry protect
    Having BBSack to apply wipe, factory reset wipe more, following which you do a software update via Loader.
    Software For BlackBerry® Torch™ 9800 smartphone
    BlackBerry Handheld Software v6.0.0.3170 (Multilanguage) 
    Package Version: 6.0.0.3170
    Consisting of:
    Applications: 6.0.0.756
    Software Platform: 6.6.0.252
    File name: 9800M_PBr6.0.0_rel3170_PL6.6.0.252_A6.0.0.756_Vodafone_Spain.exe
    File size: 171.22MB
    https://swdownloads.blackberry.com/Downloads/entry.do?code=15D4E891D784977CACBFCBB00C48F133
    Regards.
    Kudos ** Do not forget to give those people who help and advise you regarding your questions ** Can
    Accept as Solution to ** Comments **
    @gutijose14
    BBM Channels  PIN: C0007093A
    Do not forget to give LIKE    Those people who help you and advise you about your doubts.  if the review has been SOLVED** # 4LL  #ÉliteRoad  Make a backup of your BlackBerry
    BlackBerry Protect and  BlackBerry Link constantly.  #ichooseBlackBerry10 Gutijose14 Forums Veteran I

  • Simulate signal controlling problem

    Hi
    I have this signal controlling problem. In 10,20,30,40,50 the sine wave stops. How can i avoid that?
    Attachments:
    PWM.vi ‏251 KB

    I'm more concerned about the Wait inside of a Timed Loop.  That is totally unnecessary.  Change the timed loop into a normal while loop.
    As far as the Simulate Signal, I have no clue.  The settings look find as far as I can tell.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Using a seperate thread to control motors

    Hi am new to Java and am struggling with a probelm.
    The application is to control 4 motors connected to the parallel port. When the user presses a button the motor is set to a certain speed (byte output to port). Once the button is released the port outputs to stop the motors, i also have it working so multiple motors can be driven at the same time (multiple buttons held down) i have the code working ok, but at present the program just outputs a byte of data when its worked out what buttons are pressed/released.
    The problem is i want to drive one of the motors using a crude form of PWM (output an 'on' byte, wait 1 second, output an 'off' byte, wait one second, ect)
    This is clearly going to have to be performed in a loop that is basically an infinite loop untill the key is released. However the program also need to be listening for other key inputs to turn on other motors.
    I think the best way to do it is to create a thread for the PWM that sleeps, allowing the program to do other things, and breaks out when it recieves an interrupt (triggered by another key press), however i am have major difficultly converting the code. at present the code looks like this:
    private void DebugKeyReleased(java.awt.event.KeyEvent evt) {                                 
    int c;
    c = evt.getKeyCode();
    switch (c)
    case 83:     Control(100);
                   break;
         case 68:     Control(80);
                   break;
         case 65:     Control(40);
                   break;
         case 87:     Control(20);
                   break;
    private void DebugKeyPressed(java.awt.event.KeyEvent evt) {                                
    int c;
    c = evt.getKeyCode();
    switch (c)
    case 83:     Control(1);
                   break;
    case 68:     Control(8);
                   break;
    case 65:     Control(4);
                   break;
    case 87:     Control(2);
                   break;
    private void Control(int direction){
    switch (direction)
         case 1:      forwards = 1;
                   break;
         case 100:     forwards = 0;
    break;
         case 2: backwards = 1;
                   break;
         case 20: backwards = 0;
    break;
         case 4:          right = 1;
                   break;
         case 40: right = 0;
    break;
         case 8:          left = 1;
                   break;
         case 80:     left = 0;
    break;
         global_direction = forwards*1+(backwards*2)+(left*8)+(right*4);
    if(global_direction == 0)
    moving = "Stopped";
    short stop = 255;
    lpt.output(Addr,stop);
         else if(global_direction == 1)
    moving = "Backwards";
    short Back = 239;
    lpt.output(Addr,Back);
    ECT, there are alot more if statements that account for all possibilities.
    i want the backwards and forwards cases to enter loops that output data on and off for certain time periods.
    can anybody suggest the best way to convert the code?
    thanks for any info / help
    cheers John

    A finite state machine is an abstraction in which you have a finite collection of states, and a set of transitions between states. One state is active at a time. So a traffic light might have red, green, and yellow states, and transitions between green to yellow, yellow to red, and red to green. There can be multiple transitions out of a single state.
    So for your app, each state might be a kind of signal or a kind of sequences of signals set to the motors, and the transitions would be taken when you need to change the signals. You could send the key events and time events to whatever state currently is active. That active state would then decide what transition to take based on the event.
    I'm sure there will be an entry in Wikipedia about it.
    If the code works, that's great, but (1) it's obviously not working entirely because you're posting here, and (2) code like this can get hairy very fast and thus hard to maintain and thus bug-prone. So if you can simplify it, it will only help.
    If you want to use a thread, you can. You basically have that now. But instead of Thread.interruped as you have it now, you could just have the key press event change the value of the flag to one that will stop the loop.
    (for example, you'd have a "running" boolean field, a "while(running) {" in your run() method, an the event can change the value of "running" from true to false to cause the thread to stop.

  • Resolution, brightness and controlling problem

    I've recentrly adquired my Mac Mini and I don't know how to solve this problem. My TV it's a LEC 32" FullHD connected by HDMI. I'd never had any problem with my Playstation or any other device connected by HDMI with my TV. First of all, the words seems to be a little blurry, the brightness it's very high, and the automatic adjustment of the Mac to this TV it's clarely under 1080p. But when I select manually 1080p the words are still blurry, thw bright is still high and the only significant difference it's that everything look smaller XD.
    The other issue is that I can't control bright or sound from the keyboard, I'm forced to do this from the TV remote control. Please help me with these, or I will need to change it for a PC with Windows and I don't want that.

    HI, many Mini/HDMI issues...
    https://discussions.apple.com/thread/4472316?tstart=0
    But most of yours sound a bit like some settimg on the TV, does it have input controls for like PC/TV?

  • Acrobat Reader 9.1 ActiveX control problems

    We have an application written in VB.NET 2005 which displays a PDF file using embedded ActiveX control from Acrobat Reader (using AcroPDF.dll).
    The code to open the file is very simple:
    Me.AxAcroPDF1.LoadFile(_path)
    The application was compiled on the machine that had Acrobat Reader 8 installed and distributed. The users also had Acrobat 8 installed.
    Some of the users upgraded to Acrobat 9.1. I understand that it shouldn't really matter as the ActiveX control from 9.1 should be backward compatible.
    Yet some users cannot open the file and receive the following error message:
    "Error HRESULT E_FAIL has been returned from a call to a COM component"
    Some other users can open the file but have the following message when closing the application (which calls Me.AxAcroPDF1.Dispose() ):
    "The instruction at "0x0700609c" referenced memory at "0x00000014". The memory could not be "read"."
    What can cause those problems? How can I fix them?

    OK, no one responsed to my questions but I found answers for them so I thought I might put them here for those interested.
    As for "HRESULT E_FAIL" message, all that was wrong was the "Display PDF in browser" option in Adobe Reader preferences. It needs to be ticked. A bit weird but considering that it uses the same OCX in a web browser, it makes some sense.
    As for the memory issues message, I need to unload libraries manually before exiting the application (as suggested in some other thread in this forum):
    <DllImport("ole32.dll")> _ 
    Friend Shared Sub CoFreeUnusedLibraries() 
    End Sub
    Me .AxAcroPDF1.Dispose()UnmanagedCode.CoFreeUnusedLibraries()

  • Usint thread to control PWM loop

    Hi am new to Java and am struggling with a probelm.
    The application is to control 4 motors connected to the parallel port. When the user presses a button the motor is set to a certain speed (byte output to port). Once the button is released the port outputs to stop the motors, i also have it working so multiple motors can be driven at the same time (multiple buttons held down) i have the code working ok, but at present the program just outputs a byte of data when its worked out what buttons are pressed/released.
    The problem is i want to drive one of the motors using a crude form of PWM (output an 'on' byte, wait 1 second, output an 'off' byte, wait one second, ect)
    This is clearly going to have to be performed in a loop that is basically an infinite loop untill the key is released. However the program also need to be listening for other key inputs to turn on other motors.
    I think the best way to do it is to create a thread for the PWM that sleeps, allowing the program to do other things, and breaks out when it recieves an interrupt (triggered by another key press), however i am have major difficultly converting the code. at present the code looks like this:
    private void DebugKeyReleased(java.awt.event.KeyEvent evt) {
    int c;
    c = evt.getKeyCode();
    switch (c)
    case 83: Control(100);
    break;
    case 68: Control(80);
    break;
    case 65: Control(40);
    break;
    case 87: Control(20);
    break;
    private void DebugKeyPressed(java.awt.event.KeyEvent evt) {
    int c;
    c = evt.getKeyCode();
    switch (c)
    case 83: Control(1);
    break;
    case 68: Control(8);
    break;
    case 65: Control(4);
    break;
    case 87: Control(2);
    break;
    private void Control(int direction){
    switch (direction)
    case 1: forwards = 1;
    break;
    case 100: forwards = 0;
    break;
    case 2: backwards = 1;
    break;
    case 20: backwards = 0;
    break;
    case 4: right = 1;
    break;
    case 40: right = 0;
    break;
    case 8: left = 1;
    break;
    case 80: left = 0;
    break;
    global_direction = forwards*1+(backwards*2)+(left*8)+(right*4);
    if(global_direction == 0)
    moving = "Stopped";
    short stop = 255;
    lpt.output(Addr,stop);
    else if(global_direction == 1)
    moving = "Backwards";
    short Back = 239;
    lpt.output(Addr,Back);
    ECT, there are alot more if statements that account for all possibilities.
    i want the backwards and forwards cases to enter loops that output data on and off for certain time periods.
    can anybody suggest the best way to convert the code?
    thanks for any info / help
    cheers John

    A finite state machine is an abstraction in which you have a finite collection of states, and a set of transitions between states. One state is active at a time. So a traffic light might have red, green, and yellow states, and transitions between green to yellow, yellow to red, and red to green. There can be multiple transitions out of a single state.
    So for your app, each state might be a kind of signal or a kind of sequences of signals set to the motors, and the transitions would be taken when you need to change the signals. You could send the key events and time events to whatever state currently is active. That active state would then decide what transition to take based on the event.
    I'm sure there will be an entry in Wikipedia about it.
    If the code works, that's great, but (1) it's obviously not working entirely because you're posting here, and (2) code like this can get hairy very fast and thus hard to maintain and thus bug-prone. So if you can simplify it, it will only help.
    If you want to use a thread, you can. You basically have that now. But instead of Thread.interruped as you have it now, you could just have the key press event change the value of the flag to one that will stop the loop.
    (for example, you'd have a "running" boolean field, a "while(running) {" in your run() method, an the event can change the value of "running" from true to false to cause the thread to stop.

  • OEM 10g Grid Control Problem

    Hi,
    We installed the OEM 10g Grid Control in Serparate Host..
    Installed 10.2.0.1 grid control
    and patched upto 10.2.0.3 for OMS....
    here OMS version is 10.2.0.3
    grid Control Agent Version is 10.2.0.3
    and Repository Home is 10.2.0.1
    Installed the linux Grid control agent 10.2.0.3 in target database...installation was successfull....but Target database is not showing in the grid control ..what was the problem...

    where to check the log files in target database host..do u mean that...
    i installed agent on target database home in a seperate directory...
    ORACLE_HOME is the Target Database Oracle Home
    cd $ORACLE_HOME/agent10g/sysman/log/
    is it the correct directory to check the log files..i am new to this grid control...
    =========================================================
    $cat emagent.trc
    2007-08-19 12:38:05 Thread-5947399 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:38:05 Thread-5947399 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:38:08 Thread-5980167 ERROR upload: Error in uploadXMLFiles. Trying again in 900.00 seconds or earlier.
    2007-08-19 12:38:35 Thread-5996551 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:38:35 Thread-5996551 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:39:05 Thread-6045703 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:39:05 Thread-6045703 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:39:35 Thread-6078471 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:39:35 Thread-6078471 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:40:05 Thread-6111239 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:40:05 Thread-6111239 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:40:35 Thread-6176775 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:40:35 Thread-6176775 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:41:05 Thread-6209543 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:41:05 Thread-6209543 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:41:35 Thread-6242311 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:41:35 Thread-6242311 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:42:05 Thread-6275079 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:42:05 Thread-6275079 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:42:18 Thread-65541 ERROR command: nmejcn: received no status header from repository at http://gridserver.abc.com:4889/em/upload/
    2007-08-19 12:42:35 Thread-6340615 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:42:35 Thread-6340615 ERROR pingManager: nmepm_pingReposURL: Did not receive a response header from repository
    2007-08-19 12:42:42 Thread-6406151 ERROR upload: Error in uploadXMLFiles. Trying again in 900.00 seconds or earlier.
    ================================================
    $ cat emctl.log
    15709 :: Sun Aug 19 11:42:29 2007::AgentLifeCycle.pm: Processing start agent
    15709 :: Sun Aug 19 11:42:29 2007::AgentLifeCycle.pm: EMHOME is /u02/targetdb/10.2.0/agent10g
    15709 :: Sun Aug 19 11:42:29 2007::AgentLifeCycle.pm:status agent returned with retCode=1
    15709 :: Sun Aug 19 11:42:36 2007::AgentLifeCycle.pm: Exited loop with retCode=3
    16405 :: Sun Aug 19 11:48:23 2007::AgentLifeCycle.pm: Processing status agent
    16405 :: Sun Aug 19 11:48:23 2007::AgentStatus.pm:Processing status agent
    16405 :: Sun Aug 19 11:48:23 2007::AgentStatus.pm:emdctl status returned 3
    19862 :: Sun Aug 19 12:02:42 2007::AgentLifeCycle.pm: Processing status agent
    19862 :: Sun Aug 19 12:02:42 2007::AgentStatus.pm:Processing status agent
    19862 :: Sun Aug 19 12:02:43 2007::AgentStatus.pm:emdctl status returned 3
    20326 :: Sun Aug 19 12:04:05 2007::AgentLifeCycle.pm: Processing status agent
    20326 :: Sun Aug 19 12:04:05 2007::AgentStatus.pm:Processing status agent
    20326 :: Sun Aug 19 12:04:06 2007::AgentStatus.pm:emdctl status returned 3
    20404 :: Sun Aug 19 12:05:41 2007::AgentLifeCycle.pm: Processing status agent
    20404 :: Sun Aug 19 12:05:41 2007::AgentStatus.pm:Processing status agent
    20404 :: Sun Aug 19 12:05:41 2007::AgentStatus.pm:emdctl status returned 3
    21329 :: Sun Aug 19 12:16:36 2007::AgentStatus.pm:Processing upload
    21329 :: Sun Aug 19 12:16:36 2007::AgentStatus.pm:emdctl status agent returned 3
    21329 :: Sun Aug 19 12:16:38 2007::AgentStatus.pm: emdctl upload returned with exit code 6
    21685 :: Sun Aug 19 12:22:59 2007::AgentLifeCycle.pm: Processing status agent
    21685 :: Sun Aug 19 12:22:59 2007::AgentStatus.pm:Processing status agent
    21685 :: Sun Aug 19 12:22:59 2007::AgentStatus.pm:emdctl status returned 3
    22464 :: Sun Aug 19 12:40:17 2007::AgentLifeCycle.pm: Processing status agent
    22464 :: Sun Aug 19 12:40:17 2007::AgentStatus.pm:Processing status agent
    22464 :: Sun Aug 19 12:40:18 2007::AgentStatus.pm:emdctl status returned 3

  • Windowless controls problem...

    Hello
    I'm using Measurement Studio (8.1.11.337) in a Visual Studio 2003
    (Standard Edition). Program itself is written in C++, and uses MFC. We
    have used (for years) UI controls without problems in Windowed mode.
    Recently, we decided that switching to windowless mode will allow for
    both better performance (we have configurations consisting of thousands
    of controls) and appearance (transparency and non-rectangular shapes).
    At the very beginning, NI::CNiKnob:etWindowless( true ) did nothing for us. We create all controls dynamically, like this:
    class AWindowClass : public CWnd {
    // some stuff
        NI::CNiKnob knob;
    AWindowClass:nCreate( LPCREATESTRUCT )
        gauge.Create( "", WS_VISIBLE, CRect( CPoint( 0, 0 ),
                CSize( configuration->getWindow( )->getWidth( ), configuration->getWindow( )->getHeight( ) ) ),
                this, 0, 0, FALSE, lic
        gauge.SetWindowless( true );   // nothing happens, still windowed
    Of course, lic is valid license string, configuration holds
    configuration, etc. Control starts in windowed mode, and insight into
    MFC sources shows clearly, that it has no intent to go
    windowless...Then, after some experiments with ActiveX Control Test
    Container (provided by Microsoft with Visual Studio), I found out that
    Windowless property needs to be set on control's startup, and then it
    works fine. Well...I guess that I have to live with that, so I did as
    follows:
    1) For first NI::CNiKnob ever created, I create it in special window _and_ in windowed mode
    2) Then, I set it's Windowless property to true, and
    3) Serialized whole thing using it's IPersistentStreamInit COM
    interface to COleStreamFile initialized by CreateMemoryStream function
    call. I think this is better way than using static files on disk (say
    that I upgrade libraries and file format changes?)
    4) Destroyed (by means of DestroyWindow) NI::CNiKnob just serialized
    5) And finally, created apropriate, final control by following call
    knob.CreateControl( "{4D79497E-BCBB-4477-9E5C-CBD7284EE8AC}", "WindowlessKnob", WS_VISIBLE,
                rect, parent, 1, & knobProperties, FALSE, license );
    (knobProperties being CFile just created, of course after flushing and resetting its read pointer)
    This time behavior is different. Breakpoints set in MFC show clearly
    that there is windowless activation in progress. But, alas, before I
    can see and enjoy my new windowless control on screen, I get assertion
    failure. Namely, CWnd:ubclassDlgItem(UINT nID, CWnd* pParent),
    defined in wincore.cpp (from line 4912 on) fires following assert on
    line 4929:
    ASSERT(pSite->m_hWnd != NULL);
    Quick check in MFC documentation, and it seems that m_hWnd _should_ be
    NULL for Windowless controls (it says "NULL if the control is
    windowless"). So control's CreateControl code should not call
    SubclassDlgItem at all.
    So the question is: how to get this to work? Am I doing something wrong?
    Any help appreciated.
    Michal

    Hi Michal,
    Thanks for your patience as I've finally figured out after digging through old
    and new source code what our official stance is on supporting windowless
    activation. 
    Alright so as far a windowless activation goes, in Measurement Studio 7.0 we
    were able to set that property to true.  However, when we did, the control
    did not paint correctly as a result of us not determining if the
    control site supported windowless activation So we fixed that problem in
    Measurement Studio 8.0 by coercing the Windowless property to false if the
    dialog did not support windowless activation
    So your next question might be, how does Windowless activation take place and
    how can you be sure that we are doing the right checking? Well the way that
    windowless activation takes place is that the windowless control queries
    the client site for the IOleInPlaceSiteWindowless
    interface.  If this interface is supported and
    CanWindowlessActivate returns S_OK, the control activates itself as
    windowless, otherwise the control creates a window. 
    Microsoft provides methods of querying interfaces and control sites to
    determine if they support windowless or not.  You can do this on your end
    if you want to double-check our thoughts as here is the basic code we use to
    determine this.  So basically you need to call the GetClientSite() method to retrieve a pointer to the control's
    current client site in its container.  If that pointer was called
    pClientSite, you could then say:
    IOleInPlaceSiteWindowless *pI=NULL;
    if((pClientSite && SUCCEEDED(pClientSite->QueryInterface(&pI))
    &&  pI->CanWindowlessActivate() == S_OK))
        windowlessSupport =  TRUE;
    else
        windowlessSupport = FALSE;
    Visual Basic 6.0 and other NI IDEs support the above interface and hence the
    controls can be made windowless.
    Now the MFC dialog does NOT support this (i.e. as the query CanWindowlessActivate
    fails for this) and hence the controls are not being able to be made
    windowless.  We tested both Measurement Studio ActiveX controls as well as
    custom ActiveX controls that we created in the MFC Dialog, and both were
    rendered windowed as the above query was failing. So the only way of getting
    controls to be windowless is by implementing a custom
    client site that supports windowless controls. If you are curious, the
    following article could be of some help which is called MFCClientSite. 
    Now, the thread you mentioned talks about the MFC 7.0
    container which shipped with Visual Studio .NET 2002.  At the time of the release of Visual
    Studio .NET 2002, Microsoft stated that support for Windowless controls was
    added to MFC. That means that it should be present for later versions also.
    Also, MFC supports creation of windowless ActiveX controls using the ActiveX
    wizards so they must b supporting windowless activation for their containers
    (but how? who knows).  But what I can say is that the VC++ dialog does not
    defaultly support Windowless controls.  A custom site implementation must
    be provided for a container to support Windowless controls. 
    So all in all, if you are using the default VC++ dialog, then our controls
    don't support Windowless.  So your best bet is to not mess with that
    Windowless property unless you are implementing your own custom control
    site. 
    Best Regards and I hope this clears things up,
    Jonathan N.
    National Instruments

Maybe you are looking for