Package SimPy :: Module SimulationRT
[show private | hide private]
[frames | no frames]

Module SimPy.SimulationRT

SimulationRT 1.6.1
__version__ = '$Revision: 1.1.1.9 $ $Date: 2005/11/12 05:43:35 $ kgm'
LICENSE:
Copyright (C) 2002, 2005  Klaus G. Muller, Tony Vignaux
mailto: kgmuller@xs4all.nl and Tony.Vignaux@vuw.ac.nz

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

    This library 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
    Lesser General Public License for more details.

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

Implements SimPy Processes, resources, and the backbone simulation scheduling
by coroutine calls.
Based on generators (Python 2.2 and later)



**Change history:**
    4/8/2003: - Experimental introduction of synchronization of simulation
                time and real time (idea of Geoff Jarrad of CSIRO -- thanks,
                Geoff!).
                * Changes made to class __Evlist, _nextev(), simulate()

    Dec 11, 2003:
            - Updated to Simulation 1.4alpha API

    13 Dec 2003: Merged in Monitor and Histogram

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

    19 May 2004: Added erroneously omitted Histogram class.

    5 Sep 2004: Added SimEvents synchronization constructs
    
    17 Sep 2004: Added waituntil synchronization construct
    
    28 Sep 2004: Changed handling of real time -- now uses time.clock for Win32, and
                 time.time for all other OS (works better on Linux, Unix).

    01 Dec 2004: SimPy version 1.5
                 Changes in this module: Repaired SimEvents bug re proc.eventsFired

    12 Jan 2005: SimPy version 1.5.1
                 Changes in this module: Monitor objects now have a default name
                                         'a_Monitor'
                                         
    29 Mar 2005: Start SimPy 1.6: compound "yield request" statements
    
    05 Jun 2005: Fixed bug in _request method -- waitMon did not work properly in
                 preemption case
                 
    09 Jun 2005: Added test in 'activate' to see whether 'initialize()' was called first.
    
    23 Aug 2005: - Added Tally data collection class
                 - Adjusted Resource to work with Tally
                 - Redid function allEventNotices() (returns prettyprinted string with event
                   times and names of process instances
                 - Added function allEventTimes (returns event times of all scheduled events)

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; FIFO is default queuing discipline.
SimEvent Supports one-shot signalling between processes.
Tally  
__Evlist Defines event list and operations on it
_Action Structure (who=process owner, generator=process)

Exceptions
FatalSimerror  
Simerror  

Function Summary
  activate(object, process, at, delay, prior)
Application function to activate passive process.
  allEventNotices()
Returns string with eventlist as t1: [procname,procname2] t2: [procname4,procname5, .
  allEventTimes()
Returns list of all times for which events are scheduled.
  holdfunc(a)
  initialize()
  now()
  passivatefunc(a)
  queueevfunc(a)
  reactivate(object, at, delay, prior)
Application function to reactivate a process which is active, suspended or passive.
  releasefunc(a)
  requestfunc(a)
Handles 'yield request,self,res' and 'yield (request,self,res),(<code>,self,<par>)'.
  rtnow()
  scheduler(till)
Schedules Processes/semi-coroutines until time 'till'.
  simulate(until, real_time, rel_speed)
Schedules Processes/semi-coroutines until time 'until'
  stopSimulation()
Application function to stop simulation run
  test_demo()
  test_interrupt()
  testSimEvents()
  testwaituntil()
Demo of waitUntil capability.
  waitevfunc(a)
  waituntilfunc(par)
  _startWUStepping()
Application function to start stepping through simulation for waituntil construct.
  _stopWUStepping()
Application function to stop stepping through simulation.
  _test()
Gets called by simulate after every event, as long as there are processes waiting in condQ for a condition to be satisfied.
  _waitUntilFunc(proc, cond)

Variable Summary
str __version__ = '1.6.1 Nov 2005'
list condQ = []
int False = 0                                                                     
int hold = 1234                                                                  
int passivate = 5678                                                                  
int queueevent = 8765                                                                  
int release = 246                                                                   
int request = 135                                                                   
float rtstart = 7.6229557499649128e-006                                               
int True = 1                                                                     
int waitevent = 4321                                                                  
int waituntil = 999                                                                   
bool __TESTING = False
NoneType _e = None                                                                  
int _endtime = 0                                                                     
bool _stop = True
int _t = 0                                                                     

Function Details

activate(object, process, at='undefined', delay='undefined', prior=0)

Application function to activate passive process.

allEventNotices()

Returns string with eventlist as t1: [procname,procname2] t2: [procname4,procname5, . . . ] . . . .

allEventTimes()

Returns list of all times for which events are scheduled.

reactivate(object, at='undefined', delay='undefined', prior=0)

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

requestfunc(a)

Handles 'yield request,self,res' and 'yield (request,self,res),(<code>,self,<par>)'.

scheduler(till=0)

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

simulate(until=0, real_time=0, rel_speed=1)

Schedules Processes/semi-coroutines until time 'until'

stopSimulation()

Application function to stop simulation run

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.

_startWUStepping()

Application function to start stepping through simulation for waituntil construct.

_stopWUStepping()

Application function to stop stepping through simulation.

_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.

Variable Details

__version__

Type:
str
Value:
'1.6.1 Nov 2005'                                                       

condQ

Type:
list
Value:
[]                                                                     

False

Type:
int
Value:
0                                                                     

hold

Type:
int
Value:
1234                                                                  

passivate

Type:
int
Value:
5678                                                                  

queueevent

Type:
int
Value:
8765                                                                  

release

Type:
int
Value:
246                                                                   

request

Type:
int
Value:
135                                                                   

rtstart

Type:
float
Value:
7.6229557499649128e-006                                               

True

Type:
int
Value:
1                                                                     

waitevent

Type:
int
Value:
4321                                                                  

waituntil

Type:
int
Value:
999                                                                   

__TESTING

Type:
bool
Value:
False                                                                  

_e

Type:
NoneType
Value:
None                                                                  

_endtime

Type:
int
Value:
0                                                                     

_stop

Type:
bool
Value:
True                                                                   

_t

Type:
int
Value:
0                                                                     

Generated by Epydoc 2.1 on Wed Nov 16 12:02:45 2005 http://epydoc.sf.net