Timer Function Documentation

Question 1:

Is there any documentation on the timer function ?

We use here DOORS 9.3 but in the integrated DXL Integration i can't find anything about this commands.

i found the command reference on the web where a set of timer functions is mentioned but only the command without any description of the parameters.



For this commands i found the parameters:



DBE dbe_timer = timer(db db_form, int i_timeout, Callback_function, "Timer")
startTimer(dbe_timer)
stopTimer(dbe_timer)



For this commands i dont know the right parameters:



getTimerInterval
getTimerName
getTimerRunning
isTimer

Question 2:

I use the timer to execute an autosave function. With a fix autosave time it works fine.

Currently i want the user to change the time to next autosave event at runtime. But the set command leads to an an "Doors internal error":

Is there any way to stop the timer set an new timeout time and restart the timer ?



void Callback_Function(DBE dbe_dummy)
{
  stopTimer(dbe_timer)
  set(dbe_timer,i_new_timeout)
  startTimer(dbe_timer)
}

 

Thanks in advance, for your answers !

 

 

 

 

 


TheKey - Thu Oct 24 05:58:45 EDT 2013

Re: Timer Function Documentation
Tony_Goodman - Thu Oct 24 10:16:45 EDT 2013

You cannot change the interval once the DBE has been created.

You should put the logic in the callback function so it only acts when a certain number of intervals have passed.

Forget the getTimer functions. They do not seem to have anything to do with the timer DBE. 

Re: Timer Function Documentation
llandale - Thu Oct 24 11:45:58 EDT 2013

Those 4 commands take an "int TimerNumber" parameter which, as Tony said, you don't care about. 

It seems the timer DBE activates a new "Timer.  I could think of no praactical use for manipulating those internal timers.

Here is some code to check it out I wrote years ago.  You want to run the code, then activate something with a timerDBE, then run the code again.

// TimerCheck.dxl
/*
 Finds timers defined in the current instance of DOORS.
 Won't find timers defined in other instances.
 Timers are defined in a Dialog via "DBE timer(db, void(DBE), string)
see file TimerMakeDialog.dxl to create a timer associated with a Dialog


Looks like the timers IDs start at 22, then every 6: 28, 34, ... when used by the 'timer' functions

*/
void CheckTimerID(int ID)
{   // '2' is random number that's not a timer.
 if (!isTimer(ID) and ID != 2) return  // Is this timer defined in some DBE
 // if (ID == 2) return
 print "ID\t" ID "\t'" (getTimerName(ID)) "'\t " (getTimerInterval(ID)) "\n"
 print "\tRunig:\t" (getTimerRunning(ID)) "\n" // Is it currently started?
// print "\tIs:   \t" (isTimer(ID)) "\n"  // Is it currently active?
// print "\tName: \t" (getTimerName(ID)) "\n" // Name used when timer defined
// print "\tIntvl:\t" (getTimerInterval(ID)) "\n" // Interval used when timer defined; rounded to 'int'
 print "\tStart:\t" (startTimer(ID)) "\n"  // In fact starts the timer.  Returns whether it was actually started
 print "\tStop: \t" (stopTimer(ID)) "\n"  // In fact stops the timer.  Always returns True if timer is defined
 // bool startTimer(DBE)
 // bool stopTimer(DBE)
 // DBE timer(DB, [real | int] void(DBE), string)
// if (ID != 2 and confirm("Start timer '" ID "'?")) startTimer(ID)
}

int i
for (i=-200; i<1000; i++)
{  CheckTimerID(i)
}

And here is someone elses sample code from years ago.

// example of using interval timer
/** @file
  *
  * @author Reik Schroeder <reik.schroeder@siemens.com>
  *
Run script TimerCheck.dxl
  */

DB db = create ("Test Timer");

DBE t;
DBE fldTime;
DBE lab, dbeStatus

void intervalTimerCB ( DBE dbe ) {
  set (fldTime, (dateAndTime today ""));
}

void startCB (DB db) {
  startTimer (t);
}

void stopCB (DB db) {
  stopTimer (t);
}

void closeCB( DB db)
{ stopTimer(t)
print "...hide(db)...\n"
  hide(db)
db = null

}

lab = label (db, "Shows usage of interval timer.");
fldTime = field (db, "Time", "", 15, true);
t       = timer (db, 2.2, intervalTimerCB, "IntervalTimer");
// t       = timer (db, 1, intervalTimerCB, "IntervalTimer");
fldTime -> "bottom" -> "form";


apply (db, "Start", startCB);
apply (db, "Stop", stopCB);
close (db, true, closeCB)

if (confirm("Show dialog?"))
     show (db)
else realize(db)

// Fin

 

-Louie