- # This interval starts at this edge.
- self.ss_block = self.start_samplenum
- # Store the new rising edge position and the ending
- # edge interval.
- self.start_samplenum = self.es_block = self.samplenum
+ # Get the next two edges. Setup some variables that get
+ # referenced in the calculation and in put() routines.
+ start_samplenum = self.samplenum
+ self.wait({0: 'e'})
+ end_samplenum = self.samplenum
+ self.wait({0: 'e'})
+ self.ss_block = start_samplenum
+ self.es_block = self.samplenum
+
+ # Calculate the period, the duty cycle, and its ratio.
+ period = self.samplenum - start_samplenum
+ duty = end_samplenum - start_samplenum
+ ratio = float(duty / period)