ExampleGUIDebug.py :  » Development » SimPy » SimPy-2.1.0beta » SimPyModels » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Development » SimPy 
SimPy » SimPy 2.1.0beta » SimPyModels » ExampleGUIDebug.py
# Example.py - Example for SimulationGUIDebug
from SimPy.SimulationGUIDebug import *# import SimulationGUIDebug

# Creates man
class SuperBeing(Process):
  def __init__(self,earth):
    Process.__init__(self)
    self.earth = earth

  def Create(self):
    while True:
      yield hold,self,1.20
      man = Man(self.earth)
      activate(man,man.Walk())
      register(man,man.Status) # register the man instance with hook
      
# Man waits for earth resource, then becomes, baby, adult, and leaves earth
class Man(Process):
  ID = 0
  def __init__(self,earth):
    Process.__init__(self,name="Man%d"%Man.ID) # set name to ensure window title is set
    self.earth = earth
    self.status = "in heaven"
    Man.ID += 1
  
  def Walk(self):
    self.status = "waiting for earth "
    yield  request,self,self.earth
    self.status = "baby"
    yield  hold,self,1
    self.status = "adult"
    yield  hold,self,2
    self.status = "good bye earth"
    yield  release,self,self.earth
    
  def Status(self):
    return self.status

# set up 
initialize()
register(SuperBeing,name="SuperBeing") # register SuperBeing class with name

Earth = Resource(2,name="Earth") # set name to ensure window title is set
register(Earth) # register Earth Resource

SB = SuperBeing(Earth)
activate(SB,SB.Create()) # when activated SB will be registered

# simulate
simulate(until=1000)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.