| 34 | |
| 35 | |
| 36 | class CycleSequence: |
| 37 | |
| 38 | def __init__(self, sequence, quantity): |
| 39 | self.sequence = sequence |
| 40 | self.quantity = quantity |
| 41 | |
| 42 | @property |
| 43 | def averageTime(self): |
| 44 | """Get average time between cycles.""" |
| 45 | return self._getTime() / self._getCycleQuantity() |
| 46 | |
| 47 | def iterCycles(self): |
| 48 | i = 0 |
| 49 | while i < self.quantity: |
| 50 | for cycleInfo in self.sequence: |
| 51 | for cycleTime, inactiveTime, isInactivityReload in cycleInfo.iterCycles(): |
| 52 | yield cycleTime, inactiveTime, isInactivityReload |
| 53 | i += 1 |
| 54 | |
| 55 | def _getCycleQuantity(self): |
| 56 | quantity = 0 |
| 57 | for item in self.sequence: |
| 58 | quantity += item._getCycleQuantity() |
| 59 | return quantity |
| 60 | |
| 61 | def _getTime(self): |
| 62 | time = 0 |
| 63 | for item in self.sequence: |
| 64 | time += item._getTime() |
| 65 | return time |
| 66 | |
| 67 | def __repr__(self): |
| 68 | spec = ['sequence', 'quantity'] |
| 69 | return makeReprStr(self, spec) |
no outgoing calls
no test coverage detected