# PeriodicSampler.py

# creates a thread for periodic sampling, e.g. to be used for long-run
# queue length; the arguments Per, Mon and Fun are the sampling period,
# the monitor to be used, and the function to be called to get the data
# to be recorded

from SimPy.Simulation import *

class PerSmp(Process):
   def __init__(self,Per,Mon,Fun):
      Process.__init__(self)  
      self.Per = Per
      self.Mon = Mon
      self.Fun = Fun
   def Run(self):
      while 1:
         yield hold,self,self.Per
         Data = self.Fun()
         self.Mon.observe(Data)
