Table of Contents

Module: SimulationTrace .\simpy1_5\SimPy\SimulationTrace.py

SimulationTrace 1.5 __version__ = $Revision: 1.11 $ $Date: 2004-12-04 16:07:18+01 $ kgm LICENSE: Copyright (C) 2002 Klaus G. Muller, Tony Vignaux mailto: kgmuller@xs4all.nl and Tony.Vignaux@vuw.ac.nz

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. END OF LICENSE

Implements a trace capability for SimPy 1.3. Based on generators (Python 2.2 and later)

Change history: 9 May 03: SimulationTrace module based on SimPy 1.3

12/5/2003: Changed eventlist handling from dictionary to bisect

9/6/2003: - Changed eventlist handling from pure dictionary to bisect- sorted "timestamps" list of keys, resulting in greatly improved performance for models with large numbers of event notices with differing event times. ========================================================= This great change was suggested by Prof. Simon Frost. Thank you, Simon! This version 1.3 is dedicated to you! ========================================================= - Added import of Lister which supports well-structured printing of all attributes of Process and Resource instances.

November 03: Brought up to Simulation 1.4alpha

  1. Dec 2003: Merged in Monitor and Histogram

  2. Feb 2004: Repaired bug in activeQ monitor of class Resource. Now actMon correctly records departures from activeQ.

  3. May 2004: Added erroneously omitted Histogram class.

  4. Sep 2004: Added SimEvents synchronization constructs

  5. Sep 2004: Added waituntil synchronization construct

Imported modules   
from SimPy.Lister import *
from __future__ import generators
import bisect
import sys
import types
Functions   
_startWUStepping
_stopWUStepping
_test
_waitUntilFunc
activate
allEventNotices
holdfunc
initialize
now
passivatefunc
queueevfunc
reactivate
releasefunc
requestfunc
scheduler
simulate
stopSimulation
testSimEvents
test_demo
test_interrupt
testwaituntil
waitevfunc
waituntilfunc
  _startWUStepping 
_startWUStepping ()

Application function to start stepping through simulation for waituntil construct.

  _stopWUStepping 
_stopWUStepping ()

Application function to stop stepping through simulation.

  _test 
_test ()

Gets called by simulate after every event, as long as there are processes waiting in condQ for a condition to be satisfied. Tests the conditions for all waiting processes. Where condition satisfied, reactivates that process immediately and removes it from queue.

begin waituntil functionality

  _waitUntilFunc 
_waitUntilFunc ( proc,  cond )

  activate 
activate (
        object,
        process,
        at="undefined",
        delay="undefined",
        prior=False,
        )

Application function to activate passive process.

Exceptions   
Simerror( "Fatal SimPy error: activating function which" + " is not a generator (contains no 'yield')" )
  allEventNotices 
allEventNotices ()

Returns string with eventlist as list of tuples (eventtime,action)

  holdfunc 
holdfunc ( a )

  initialize 
initialize ()

  now 
now ()

  passivatefunc 
passivatefunc ( a )

  queueevfunc 
queueevfunc ( a )

  reactivate 
reactivate (
        object,
        at="undefined",
        delay="undefined",
        prior=False,
        )

Application function to reactivate a process which is active, suspended or passive.

  releasefunc 
releasefunc ( a )

  requestfunc 
requestfunc ( a )

  scheduler 
scheduler ( till=0 )

Schedules Processes/semi-coroutines until time till. Deprecated since version 0.5.

  simulate 
simulate ( until=0 )

Schedules Processes/semi-coroutines until time until

Exceptions   
Simerror( "Fatal SimPy error: Simulation not initialized" )
  stopSimulation 
stopSimulation ()

Application function to stop simulation run

  testSimEvents 
testSimEvents ()

  test_demo 
test_demo ()

Test/demo functions #############

  test_interrupt 
test_interrupt ()

  testwaituntil 
testwaituntil ()

Demo of waitUntil capability.

Scenario: Three workers require sets of tools to do their jobs. Tools are shared, scarce resources for which they compete.

  waitevfunc 
waitevfunc ( a )

  waituntilfunc 
waituntilfunc ( par )

Classes   

FIFO

Histogram

A histogram gathering and sampling class

Monitor

Monitored variables

PriorityQ

Queue is always ordered according to priority.

Process

Superclass of classes which may use generator functions

Queue

Resource

Models shared, limited capacity resources with queuing;

SimEvent

Supports one-shot signalling between processes. All processes waiting for an event to occur

Simerror

Trace

_Action

Structure (who=process owner, generator=process)

__Evlist

Defines event list and operations on it


Table of Contents

This document was automatically generated on Tue Dec 07 19:52:27 2004 by HappyDoc version 2.1