def __init__(self, radio, timerMux, schedule, id): """ @param schedule: L{Schedule} object giving transmission scheduling. @param id: The device ID of this node. """ MAC.__init__(self, radio, timerMux) self.schedule = schedule self.id = id self.dataTxSlot = self.schedule.dataTxSlot(self.id) self.slotTimer = VirtualTimer(timerMux, self._slotTimerHandler) self.slot = len(self.schedule.dataSlots) self.txPacket = None
def __init__(self, radio, timerMux, schedule, id, packetHandler=None): """ @param packetHandler: Handler to call on reception of a slave-slave packet. The packet will be passed as an argument. """ SlaveMAC.__init__(self, radio, timerMux, schedule, id) self.auxTxSlots = self.schedule.slaveAuxTxSlots(self.id) self.auxRxSlots = self.schedule.slaveAuxRxSlots(self.id) self.auxSlotTimer = VirtualTimer(timerMux, self._auxSlotTimerHandler) self.auxPackets = {} self.packetHandler = packetHandler self.radio.channel = schedule.dataChannel
def __init__(self, radio, timerMux, schedule, frameHandler=None): """ @param schedule: L{Schedule} object giving transmission scheduling. @param frameHandler: Handler function to call at the end of each frame. The packets received in that frame will be passed as a list. """ MAC.__init__(self, radio, timerMux) self.schedule = schedule self.frameHandler = frameHandler self.frameTimer = VirtualTimer(timerMux, self._frameTimerHandler) self.packets = [] self.frameTimer.start(self.schedule.framePeriod, repeat=True)
def __init__(self, imu, samplingPeriod, calibration=None, filter=None, sampleCallback=None, initialTime=0): """ Initialise IMU behaviour. @param imu: L{IMU} on which the behaviour executes. @param samplingPeriod: Interval at which to sample and process (float). @param calibration: Mapping from IMU L{Sensor}s to L{SensorCalibration}s (dict). @param filter: L{OrientationFilter} to update with each set of samples. @param sampleCallback: Function to call after each sample. The behaviour object will be passed as a single argument. @param initialTime: Initial time for local timekeeping. """ self.imu = imu self.samplingPeriod = samplingPeriod self.calibration = calibration self.filter = filter for sensor in imu.sensors: sensor.rawMeasurements = TimeSeries() if self.calibration is not None: sensor.calibratedMeasurements = TimeSeries() self.sampleCallback = sampleCallback self.timerMux = TimerMultiplexer(imu.timer) PeriodicSampler(imu.adc, imu.sensors, VirtualTimer(self.timerMux), samplingPeriod, self._handleSample) self._time = initialTime