summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utils/Timer.cc14
-rw-r--r--utils/Timer.h3
2 files changed, 15 insertions, 2 deletions
diff --git a/utils/Timer.cc b/utils/Timer.cc
index 0d63bcc..def04c1 100644
--- a/utils/Timer.cc
+++ b/utils/Timer.cc
@@ -183,7 +183,7 @@ timing scheme.}
CcuCoreTimer :: CcuCoreTimer (Millisecond period, int pulses, CcuTimerSet* s)
: MySet (s),
StatusFlag (Active),
- Period (period),
+ Period (period > 0 ? period : 10),
PulsesLeft (pulses)
{
}
@@ -210,6 +210,18 @@ CcuCoreTimer :: ChangePeriod (Millisecond period)
}
/*?
+Change the number of times a timer will go off before stopping. If
+the timer is stopped, it is not restarted.
+?*/
+void
+CcuCoreTimer :: ChangeNbPulses (int nb)
+{
+ CcuSignalBlocker b (SigAlrm);
+ PulsesLeft = nb;
+}
+
+
+/*?
Stop this timer if it was running, then start it with its current period.
This function can be used to reset a timer to the beginning of a period.
?*/
diff --git a/utils/Timer.h b/utils/Timer.h
index 55a4c17..3e5969d 100644
--- a/utils/Timer.h
+++ b/utils/Timer.h
@@ -68,7 +68,8 @@ static int IsInactive (CcuCoreTimer*);
virtual ~CcuCoreTimer ();
public:
- void ChangePeriod (Millisecond first);
+ void ChangePeriod (Millisecond);
+ void ChangeNbPulses (int);
void Stop ();
void Restart ();
void Wait ();