Run block of code periodically

Hello,
I am writing a program which controls the temperature in a room. The user enters the "Start Temp", and "Goal Temp". First the program checks the "Cur Temp". THe program compares this temp with the "Start Temp"; if (Cur Temp < Start Temp) then I turn  on heaters. Once the StartTemp has been reached I am ready to move on to the next portion of my code which is cooling the room down at a user defined rate of cooling. I would like to compare the temperatures periodically. This is where I run into a problem. I have tried setting a delay before the cooling down portion of my code but it delays the hole while loop (all code in one while loop). I would like the temperature comparions to only occur every x amount of seconds (configurable by the user). So for arguments sake, I set the comparison rate at 10 seconds, every ten seconds I want to compare the previous value with the current value and determine the rate of at which it is cooling. If that rate is within in the desired rate of cooling then everything is ok. Ideally this code would not interfer with other program funcitons I have going on. Does anyone have any ideas on how I can have this code run perioically?
Thanks

There are plenty solutions possible, and they depend a little bit on what else the code does.
rchaoua wrote:
Once the StartTemp has been reached I am ready to move on to the next portion of my code which is cooling the room down at a user defined rate of cooling.
Well, the right thing is to do all in the same portion of code using a state machine architecture. There should only be one main loop with a case structure that depends on the state.
Here are some possibilities:
You can place your periodic code inside another case and only activate it whenever the loop counters is an integer multiple of some number or if a certain time has elapsed
for every 10th iteration, you would divide [i] by 10 using "quotient&remainder" and check if the remainder is zero.
Use the "elapsed time" express VI.
Do your own time tracking (e.g. using tick count and a shift register.
You can also place your slow periodic code in its seperate, parallel while loop.
LabVIEW Champion . Do more with less code and in less time .

Similar Messages

  • Easy way to schedule a job to run for a set period?

    Is there an easy way to schedule (dbms_scheduler) a job to run for a set period -say, half an hour- and then to stop.
    Currently, I schedule a procedure to do the work (a bunch of inserts or updates, say) and the first line of that procedure assigns sysdate to a variable when it starts. Then as the procedure loops through its work, I compare the current sysdate with that original one, and if the new sysdate>original one by more than 30 minutes, I raise an application error. But it's messy, and I was wondering if there was a nicer way of doing it?

    "Admin" -I think you'll find that 'end_time' merely states a time after which the job will not be run. It doesn't do anything to kill off a job which is already running at the time that comes round. Similarly, repeat_interval merely states how often the job should be run, not a time interval within which it must run and outside of which it must stop being run.
    Satish: your suggestion looks great. Do you have, or know of, any examples where that is used, though? The doco you pointed to says the parameter raises an event, but that it's up to my event handler to deal with it. I wouldn't have the first idea of how to deal with this in code myself. If I could see a simple example, it would help a lot! Unfortunately, that page doesn't contain such an example!

  • Can't Run AFAB - Posting run requested for future period

    Hi,
    While taking depreciation run for company code in AFAB system is generating the error message "Posting run for future period requested (check entry)" SAP error AA697
    Diagnosis
    There was a check of your entries in the company code and posting period fields for the current system date. The result of this check is that you requested a posting run for company code xxxx for a future fiscal period.
    Please help me, cause I must close the period.
    Thanks

    Hi
    Check Table TABA, whats your last posted period for depreciation
    If you are executing depreciation for last period + 1, then this error is not justified
    If you are doing it for last period + 2, then its justified
    Br, Ajay M

  • Posting run request for future period; check your entry message no.AA697

    Hello Guru's,
    I have below error while Depreciation run in T.Code AFAB
    "Posting run requested for future period; check your entry" message no.AA697
    Request help
    thanks in advance
    Regards
    Chintamani

    Hello Chintamani,
    Why you want to post the depreciation for future period?
    Is the future fiscal year in open or is the posting period open for that? If no, please open that period with AJRW T code if you want to post the depreciation for future period but it is not recommendable.
    Check the posting period once again because the given posting period belongs to future year? So please do re-chk and give correct period according to your current fiscal year.
    You can get your fiscal year details and assignment of fiscal year variant to the co,code details in OB29 and OB37 t codes respectfully.
    Check the OSS Note: 1150235 - Preventing depreciation posting run for future
    I hope it helps else revert us with your query.
    Thanks & Regards,
    Lakshmi S

  • Posting an unplanned depreciation run for the previous period

    Hi SDN forum,
    May I just ask if it's possible to run an unplanned posting run for a previous period wherein the depreciation run has already been executed?
    The scenario is more like a "repeat unplanned posting run"
    I can't seem to include this unplanned depreciation whenever I select the repeat run for the previous period.
    Please help.
    Thanks

    Hi
    Through T.Code: ABAA  you can able to post unplanned dep for previous period.
    Executing AFAB for previous
    1 - open FI Periods (OB52)
    2 - Post Unplanned Dep T.Code: ABAA
    3 - Run AFAB with Repeet run & Test run
    you feel it is ok with test run execute production run
    Regards
    Viswa

  • Run Forecast for previuse period

    We have certain materials with MRP type VM  and want to run forecast first The Period Indicator is M (month).
    When user press the run Forecast button, a pop up screen periods appears and you should select a current period 8.2007 or next 9.2007 to run a forecast but for testing AND Due to business requirements, we upload consumption and open PO till 31-5 so we need to run forecast for 6.2007 period to compare values with legacy system before going life.

    Hello Chintamani,
    Why you want to post the depreciation for future period?
    Is the future fiscal year in open or is the posting period open for that? If no, please open that period with AJRW T code if you want to post the depreciation for future period but it is not recommendable.
    Check the posting period once again because the given posting period belongs to future year? So please do re-chk and give correct period according to your current fiscal year.
    You can get your fiscal year details and assignment of fiscal year variant to the co,code details in OB29 and OB37 t codes respectfully.
    Check the OSS Note: 1150235 - Preventing depreciation posting run for future
    I hope it helps else revert us with your query.
    Thanks & Regards,
    Lakshmi S

  • Error in Depreciation run for 7 th period

    Hi Guruu2019s
    When we run depreciation run  year 2008 for period 7 has failed with the following error :
    Account 'Accumulated dep. account unpl. deprec.' could not be found.
    however it has posted to few assets and not posted to few assets, when I checked in the log for posting run there is a message saying that u201Cthere are error in the posting run.after correcting, restart the run.
    u201C2documetns were createdu201D
    If I go to previous log for posting there is no error message and it says with green signals that 3 documents were created. From 1 to 6 periods, in every log says that 3 document were cresated
    Only this particular run says 2 documents were created.
    Any advise?
    Thanks in advance
    Regards
    Sunitha,

    It looks like that in period 7, you do the first "unplanned depreciation". That's explain why the error only happen in period 7.
    The problem happens because GL account for "unplanned depreciation" is not created.
    Try to check in t-code : AO90 => Choose your Chart of Account => Choose Account determination for asset class in which you did the unplanned depreciation => Choose Depreciation => Check all GL accounts assignment in "UNPLANNED DEPRECIATION ACCOUNT ASSIGNMENT".
    Then check in t-code :FS00 whether the GL Accounts (in "UNPLANNED DEPRECIATION ACCOUNT ASSIGNMENT) are exist or not.
    If the GL accounts are not exist then you should created the GL accounts first. Afterwards, try to running the AFAB again using "Restart".
    Good luck.

  • Last posting run terminated (Restart in period 2010 001)

    HI,
    There is the challenge issue for Depreciation run in AFAB,
    While running the depreciation for the month of jan month system never allowing to post.
    After the upload of assets through BDC, this is the first time we are trying to run  the depreciation
    Also, in the test run, some times documents are created and for the same input parameters, if the test run is executed again, the below error appears.
    Job started
    Step 001 started (program RAPOST2000, variant &0000000000027, user ID TRAINING1)
    Last posting run terminated (Restart in period 2010 001)
    Spool request (number 0000010067) created without immediate output
    Job finished
    Can somebody help on this issue...
    Thanks & Regards
    Rajesh Kumar.S
    09620791110

    Hi Rajesh,
    Please check the depreciation (production run) log in AFBP by inputing Company Code Fiscal Year and period. This will provide you mored details of the error as to why the depreciation run went into error.
    After the errors are rectified, please run AFAB in restrat mode, this will resolve your issue.
    Thanks!!!
    Murlidhar Khatri

  • Last posting run terminated (Restart in period 2011 010) _ Depre posting

    Hi
    I am trying post depreciation for the month of October 2011 for an asset.
    I am getting the following error:
    Last posting run terminated (Restart in period 2011 010)
    Message no. AA730
    Diagnosis
    The last posting run in period 010 2011 was terminated by an error. Before any more posting runs are performed, you must restart the posting run for period 010 2011.
    Procedure
    Start the posting run for period 010 2011 again using the restart parameter.
    I checked OB52 and the settings look ok.
    Any idea what might be the reason for the error?
    Thank you in advance
    Regards
    Vedavatee

    i checked in TABA
    and found:
    Client         Co Code    Fiscal year     Posted up to  No. of posting runs FROM Doc.No.     To doc.no.     Document posted
    123     ABCD     2011     008     01          0000000001     0000000001              N
    123     ABCD     2011     009     01          0000000001     0000000001              N
    123     ABCD     2011     009     02          0000000001     0000000001              N
    123     ABCD     2011     009     03          0000000001     0000000001              N
    123     ABCD     2011     010     01          0000000001     0000000001              1

  • Atomic block of code in SwingWorker thread?

    Hi,
    I am coding a Swing application. It has a SwingWorker thread that can be interrupted by a Progress bar.
    Inside the worker thread, there are a few lines of code (not a method) that should be executed all or none. In another word,
    if the thread runs in the middle of this block, the thread must finish this block. How can this be accomplished? This block of code has nothing to do with database read/write. The reason for the block of code being atomic is that I need to make sure of data consistency. There are no other thread except for
    the main thread(event-dispatch thread) and the worker thread.
    Thanks a lot!
    David

    You need to synchronize your atomic block and the code to interrupt the thread on the same object.

  • Can't we manually type commands within run block ?

    11.2.0.3/linux
    I was doing an RMAN restore to a new server.
    Below is the code I wanted to execute to restore
    run
    SET NEWNAME FOR DATABASE TO '/fnup/hwrc/oradata/spikey';
    restore database  ;
    }Since it is just 2 lines within a run block , so I thought of typing it manually. After typing the first line (SET NEW NAME..) ending with semi colon, i pressed ENTER key to get the next line and type the RESTORE command . But I was getting the following error.
    RMAN> run
    2> {
    3> set new name for database to '/fnup/hwrc/oradata/spikey';   ###### After typing the semicolon I pressed ENTER here
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00558: error encountered while parsing input commands
    RMAN-01009: syntax error: found "new": expecting one of: "archivelog, autobackup, auxiliary, auxname, backup, command, compression, controlfile, database, dbid, decryption, echo, encryption, high, incarnation, maxcorrupt, maxseq, newname, nocfau, restore, snapshot, to restore point, until restore point, until"
    RMAN-01007: at line 3 column 5 file: standard input
    ------| Second Attempt |----------------------------------------------
    RMAN> run
    2> {
    3> set new name for database to '/fnup/hwrc/oradata/spikey'; ###### After typing the semicolon I pressed ENTER here
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00558: error encountered while parsing input commands
    RMAN-01009: syntax error: found "new": expecting one of: "archivelog, autobackup, auxiliary, auxname, backup, command, compression, controlfile, database, dbid, decryption, echo, encryption, high, incarnation, maxcorrupt, maxseq, newname, nocfau, restore, snapshot, to restore point, until restore point, until"
    RMAN-01007: at line 3 column 5 file: standard inputEventually I had to put the above 2 lines in a script and executed it using cmdfile parameter. Can we execute RMAN commands within a run block only through a script ?

    A short note...
    run
    ALLOCATE  CHANNEL ckpt_db1 DEVICE TYPE disk;
    ALLOCATE  CHANNEL ckpt_db2 DEVICE TYPE disk;
    ALLOCATE  CHANNEL ckpt_db3 DEVICE TYPE disk;
    ALLOCATE  CHANNEL ckpt_db4 DEVICE TYPE disk;
    ALLOCATE  CHANNEL ckpt_db5 DEVICE TYPE disk;
    ALLOCATE  CHANNEL ckpt_db6 DEVICE TYPE disk;
    ALLOCATE  CHANNEL ckpt_db7 DEVICE TYPE disk;
    ALLOCATE  CHANNEL ckpt_db8 DEVICE TYPE disk;
    SET NEWNAME FOR DATAFILE 1 TO '/u02/oradata/ckpt_db/system01.dbf';
    SET NEWNAME FOR DATAFILE 2 TO '/u02/oradata/ckpt_db/sysaux01.dbf';
    SET NEWNAME FOR DATAFILE 3 TO '/u02/oradata/ckpt_db/undotbs01.dbf';
    SET NEWNAME FOR DATAFILE 4 TO '/u02/oradata/ckpt_db/users01.dbf';
    SET NEWNAME FOR DATAFILE 5 TO '/u02/oradata/ckpt_db/psdefault.dbf';
    SET NEWNAME FOR DATAFILE 6 TO '/u02/oradata/ckpt_db/amapp.dbf';
    SET NEWNAME FOR DATAFILE 7 TO '/u02/oradata/ckpt_db/AMARCH.dbf';
    restore database;
    switch datafile all;
    RELEASE CHANNEL ckpt_db1;
    RELEASE CHANNEL ckpt_db2;
    RELEASE CHANNEL ckpt_db3;
    RELEASE CHANNEL ckpt_db4;
    RELEASE CHANNEL ckpt_db5;
    RELEASE CHANNEL ckpt_db6;
    RELEASE CHANNEL ckpt_db7;
    RELEASE CHANNEL ckpt_db8;
    }

  • Block company code for any usage

    Hi
    how to find the compnay code or Plant  blocked for any usage like block for transactions like master data creation or any positing like good receiot etc. Please confirm.
    Madhavan

    You can also block all posting periods, trough OB52 but it would depend in the Posting Period Variant of the company
    Regards
    Jose

  • Error while running a sample code

    Hello,
    I 'm getting the following error while i'm trying to run a
    sample code which I have imported into Flex 3.
    ===================================================================
    Severity and Description Path Resource Location Creation Time
    Id
    unable to open 'C:\Documents and Settings\sn55179\My
    Documents\Flex Builder
    3\FlexForDummies_Chapter3_Code\libs'FlexForDummies_Chapter3_Code
    Unknown 1237909480511 215
    ===================================================================
    Can anyone help me in resolving this issue.
    Many thanks in advance.

    It's very frustrating that FB stops working when the libs
    folder is missing. If you are checking in project files to a source
    control app like Perforce, empty folders don't get added, so if you
    don't add an initial dummy file, the next time you do a clean sync,
    the libs folder may not be there, and even though there is nothing
    there, FB complains. :-(

  • How to find what transaction an user was running for a given period

    hi
    could anybody tel me
    how to find what transaction a particular user was running for a given period
    in the past.............

    Hi,
    U need to findout the list of Tcode excuted by SAP user
    1) Tcode: ST03N
    2) Select Expert Mode option
               (there u find  Server Host name & Today)
       If u select Host name u find DAY/WEEK/Month (same thing will in Today option)
    3)Now u need to select the option of DAY,WEEK etc.
    Now u can find in two ways
    1) Transaction profile (Standard / EarlyWatch)
    2) User (user profile)
    If u select the Transaction profile
    Under these u find the option of Aggregation----application/package/tranasation etc.
    I hope these will help u to findout.
    Regards
    ASR

  • Crystal report run from ASP code significantly slower than when run in CRS

    We have CRS XI R2.  I developed a report that contains several on-demand sub-reports.  The report and sub-reports are very fast when run directly from CRS.  However, when I run from ASP (users run a link from the intranet), it takes 4 times longer (1 second on CRS, vs. 5-10 seconds on intranet).  The report takes longer, bringing up a sub-report takes longer and paging through sub-reports take longer.  What can be done to improve the speed of the report that is using the ASP code?  I used a sample program provided at this support site to develop the report and it is pretty basic code.  The only time I have a problem is when I have many sub-reports.  Since they are on-demand, I do not know why this would matter.

    This has been created as an incident with SAP support.  Things that you will want to check is making sure that you handle the postback to the code as you do not need to run your entire code on every postback.  This will help performance after the original load. 
    One other thing is to compare performance with the viewer within Infoview that uses the same backend server as your application, ie PSReportFactory uses the page server, so you'll want to test with the DHTML viewer.  RAS code (reportclientdocument) uses the Report Application Server so you will want to test with the Advanced DHTML viewer.

Maybe you are looking for