| 1 |
NAME SoTimeCounter SoTimeCounter "" { timed integer counter } |
| 2 |
|
| 3 |
DESC { |
| 4 |
This engine is a counter that outputs numbers, starting |
| 5 |
at a minimum value, increasing by a step value, and ending with |
| 6 |
a number that does not exceed the maximum value. When the |
| 7 |
maximum number is reached, it starts counting from the beginning again. |
| 8 |
\p |
| 9 |
The difference between this engine and the \cSoCounter\. engine, is |
| 10 |
that this engine also has a \vtimeIn\. input, which allows the |
| 11 |
counting cycles to be timed. This engine counts automatically over time; |
| 12 |
it does not need to be triggered to go to the next step. |
| 13 |
By default, the \vtimeIn\. input is connected to the \vrealTime\. global field. |
| 14 |
It can, however, be connected to any time source. |
| 15 |
\p |
| 16 |
The \vfrequency\. input field controls how many min-to-max cycles |
| 17 |
are performed per second. For example, a \vfrequency\. value of 0.5 means |
| 18 |
that it will take 2 seconds to complete a single min-to-max cycle. |
| 19 |
\p |
| 20 |
The steps in the count cycle do not necessarily all have the same duration. |
| 21 |
Using the \vduty\. input field, you can arbitrarily split the time period |
| 22 |
of the count cycle between the steps. |
| 23 |
For example, if there are 5 steps in the cycle, a duty input of |
| 24 |
(1., 2., 2., 2., 1.) |
| 25 |
will make the second, third, and fourth steps take twice as long as the |
| 26 |
first and last steps. |
| 27 |
\p |
| 28 |
At any time the counter can be reset to a specific value. If you |
| 29 |
set the \vreset\. input field to a value, the engine will |
| 30 |
continue counting from there. Note that the counter will |
| 31 |
always output numbers based on the \vmin\., \vmax\. and \vstep\. values, |
| 32 |
and setting the \vreset\. value does not affect the those input fields. |
| 33 |
If the reset value is not a legal counter value, the counter will still |
| 34 |
behave as though it is: |
| 35 |
\b |
| 36 |
If \vreset\. is greater than \vmax\., the counter is set to \vmax\.. |
| 37 |
If \vreset\. is less than \vmin\., the counter is set to \vmin\.. |
| 38 |
If \vreset\. is between step values, the counter is set to the lower step. |
| 39 |
\. |
| 40 |
Each time a counting cycle is started, the \vsyncOut\. output is triggered. |
| 41 |
This output can be used to synchronize some other event with the |
| 42 |
counting cycle. |
| 43 |
Other events can also synchronize the counter by triggering the |
| 44 |
\vsyncIn\. input. |
| 45 |
\p |
| 46 |
You can pause the engine, by setting the \von\. input to FALSE, and |
| 47 |
it will stop updating the output field. |
| 48 |
When you turn off the pause, by setting \von\. to TRUE, it |
| 49 |
will start counting again from where it left off. |
| 50 |
} |
| 51 |
|
| 52 |
INCLUDE engines/SoTimeCounter.h |
| 53 |
|
| 54 |
INPUT timeIn { Running time. } |
| 55 |
INPUT min { Minimum value for the counter. } |
| 56 |
INPUT max { Maximum value for the counter. } |
| 57 |
INPUT step { Counter step value. } |
| 58 |
INPUT on { Counter pauses if this is set to FALSE. } |
| 59 |
INPUT frequency { Number of \vmin\.-to-\vmax\. cycles per second. } |
| 60 |
INPUT duty { Duty cycle values. } |
| 61 |
INPUT reset { Reset the counter to the specified value. } |
| 62 |
INPUT syncIn { Restart at the beginning of the cycle. } |
| 63 |
|
| 64 |
OUTPUT output { Counts \vmin\.-to-\vmax\., in \vstep\. increments. } |
| 65 |
OUTPUT syncOut { Triggers at cycle start. } |
| 66 |
|
| 67 |
METHOD Create SoTimeCounter() { Constructor } |
| 68 |
|
| 69 |
ALSO { SoCounter, SoElapsedTime, SoEngineOutput } |