|
|
Algorithm 2 Duty cycle algorithm. |
|
| DutyCyclePeriods ← 3,600,000, 1,800,000, 600,000, 300,000, 60,000, 10,000, 3000 |
| AccDataCollection ← ∅ |
| Threshold ← 0.3 |
| Alast ← Ø |
| AmevaIsRunning ← true |
| WindowsSleep ← 0 |
| MinWindowsSleep ← 5 |
| DutyIndex ← 0 |
| WinSamples ← WindowLength(WindowSize); |
| while
AmevaIsRunning
do
|
| while
size(AccDataCollection) < WinSamples
do
|
| AccDataCollection ← GetLastAccData() |
| end while
|
| WindowV ar ← V ar(AccDataCollection) |
| if
WindowVar < Threshold
then
|
| Alast ← NoDevice
|
| WindowsSleep ← WindowsSleep + 1 |
| if
WindowsSleep == MinWindowsSleep
then
|
| if
DutyIndex < size(DutyCyclePeriods) then
|
| DutyIndex ← DutyIndex + 1 |
| end if
Sleep(DutyCyclePeriods[DutyIndex]) |
| end if
|
| else
|
| DutyIndex ← 0 |
| end if
|
| end while
|
|