Example #1
0
    def __init__(self, priority=False, monitorQ=False, \
                 unitName="packet", capacity="unbounded", \
                 initialBuffered=None, **kwargs):
        """Constructor.

        :param priority:  Boolean; if True, use priority queueing.
        :param monitorQ:  Boolean; if True, support `enQ`, `deQ`, and `drp`.
        :param unitName:  Description of units stored in `Queue`.
        :param capacity:  Capacity of underlying Store [default='unbounded'].
        :param initialBuffered: Initialize list of buffered objects.
        :param kwargs:    Keywords passed to `Traceable` constructors.
        """
        # check that initialBuffered is properly formatted
        if initialBuffered and priority:
            isPrio = all([isinstance(s,tuple) for s in initialBuffered] )
            if not isPrio: initialBuffered = [(p, 0) for p in initialBuffered]
        # call constructors
        Store.__init__(self, unitName=unitName, capacity=capacity, \
                       initialBuffered=initialBuffered, \
                       putQType=PriorityQ, getQType=PriorityQ)
        Traceable.__init__(self, **kwargs)
        # set other parameters
        self.tracename = self.tracename + "%d"%(self.uid)
        self.__priority = priority
        self.monitorQ = monitorQ
        self.enQ = SimEvent(name=self.name+".enQ")
        self.deQ = SimEvent(name=self.name+".deQ")
        self.drp = SimEvent(name=self.name+".drp")
        self.__dummy = SimEvent(name=self.name+".dummy")
        # set up Queue for priority
        if self.priority:
            self.theBuffer = _PriorityList(self.theBuffer)
        self.addSort(None) # setup addSort for priority queueing
Example #2
0
    def __init__(self, maxweight=False, quiet=False, timeout=None, **kwargs):
        """Constructor.

        :param maxweight: If true, this module will use the maximum weight path.
        :param quiet: If true, operate in quiet mode (do not log events).
        """
        Traceable.__init__(self, **kwargs)
        self.data = {}
        self.maxweight = maxweight
        self.quiet = quiet
        self.timeout = timeout
Example #3
0
    def __init__(self, rate=None, **kwargs):
        """Constructor.

        :param rate: Coding rate [default='1/2']
        
        If specified, `rate` **must** be supported by `params`. By default,
        `rate` is set to the mother code rate (i.e. '1/2').
        """
        self.__rate = None
        if rate is None: rate = "1/2"
        Traceable.__init__(self, **kwargs)
        # set parameters
        self.rate = rate
Example #4
0
    def __init__(self, n, k, m=None, t=None, **kwargs):
        """Constructor.

        :param n: Block length in symbols.
        :param k: Uncoded message length in symbols.
        :param m: Number of bits per symbol [default=ceil(log2(n+1))]
        :param t: Number of correctable errors [default=(n-k) div 2].
        """
        Traceable.__init__(self, **kwargs)
        # set parameters
        self.blocklength   = None
        self.messagelength = None
        self.bitspersymbol = None
        self.ncorrectable  = None
        self.set_rate(n, k, m, t)
Example #5
0
    def __init__(self, start=True, **kwargs):
        """Constructor.

        :param start: Boolean; if true, call `start()` at the end of constructor.
        :param kwargs: Keywords passed to `Traceable` constructor and
                       `configure()` method.

        After this method invokes the `Traceable` constructor, it calls the
        `configure()` method, and then optionally calls the `start()` method.
        All keywords will be passed to the `Traceable` constructor as well as
        the `configure()` method.
        """
        self.__started = False
        Traceable.__init__(self, **kwargs)
        self.configure(**kwargs)
        if start: self.start()
Example #6
0
    def __init__(self, initstate=None, start=False, **kwargs):
        """Constructor.

        :param initstate: Initial state to `goto`.
        :param start: Boolean; if true, `start()` immediately.
        :param kwargs: Keywords passed to `Traceable` constructor.
        """
        Traceable.__init__(self, **kwargs)
        Process.__init__(self, name=self.name)
        self.__sem = None
        self.__state = None
        self.__started = False
        self.__initstate = self.HALT, (), {}
        # patch SimPy to fix hold
        if not FSM._fixsimhold:
            self.sim._dispatch[fsmhold] = fsmholdfunc
            self.sim._commandcodes = self.sim._dispatch.keys()
            self.sim._commandwords[fsmhold] = 'fsmhold'
            self.sim.reactivate = lambda *args, **kwargs: _fixreactivate(self.sim, *args, **kwargs)
            FSM._fixsimhold = True
        # continue initializing FSM
        if initstate: self.goto(initstate)
        if start: self.start()
Example #7
0
 def __init__(self, **kwargs):
     """Constructor."""
     self.__active = True
     Traceable.__init__(self, **kwargs)
     self.tracename = "%s%s"%(self.tracename, self.uid)
Example #8
0
 def __init__(self, **kwargs):
     """Constructor."""
     Traceable.__init__(self, **kwargs)
Example #9
0
 def log(self, evt=None, p=None, *args, **kwargs):
     """Overloaded to check verbose level and set common annotations."""
     force = False
     if ('verbose' in kwargs): force = (kwargs['verbose']>FSM_VERBOSE)
     if self.verbose>FSM_VERBOSE or force:
         Traceable.log(self, evt, p, *args, **kwargs)
Example #10
0
 def __init__(self, **kwargs):
     """Constructor."""
     Traceable.__init__(self, **kwargs)
     self.cache = {}
     self.sendbuffer = {}