Adding to a List and displaying quantity in the list

2012-07-10 Thread Shamefaced
Hi
I have coded a program whihc outputs what I like, but I am trying to modify it 
to add specific result info to a list and then display the number of items in 
the list. This is easy for me with basic code, but seems difficult when trying 
to adapt my program.
My code and explanation is as follows:

class Source(Process):
""" Source generates customers randomly """

def generate(self, number, meanTBA, resource):
for i in range(number):
c = Customer(name="Customer%02d" % (i+1,))
activate(c, c.visit(b=resource))
#t = expovariate(1.0 / meanTBA)
t = 10.0
yield hold, self, t

class Customer(Process):
""" Customer arrives, is served and  leaves """

def visit(self, b):
leavelist = [] /* Name of List defined */
arrive = now()  
#tib = expovariate(1.0 / timeInBank)
tib = timeInBank 
/* Console Output results start here */
print("%8.3f %s: Here I am" % (now()/60, self.name))
yield (request, self, b), (hold, self,maxWaitTime)  
wait = now() - arrive  
if self.acquired(b): 
print("%8.3f %s: Waited %6.3f" % (now()/60, self.name, wait))
yield hold, self, tib
yield release, self, b
print("%8.3f %s: Finished" % (now()/60, self.name))
else:
print("%8.3f %s: Waited too long %6.3f" % (now()/60, self.name, 
wait) + " time units have passed - Customer has left")
leavelist.append(self.acquired)
print len(leavelist)

What I am looking to do is the "customers" who have "Waited too long" get added 
to my leavelist() as they occur.

Does this make sense?

Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Adding to a List and displaying quantity in the list

2012-07-10 Thread Shamefaced
else: 
> print("%8.3f %s: Waited too long %6.3f" % (now()/60, self.name, 
> wait) + " time units have passed - Customer has left")
 > leavelist.append(self.acquired) 

Yeah, I should have changed that back to :
leavelist.append(self.name) -- my thinking was that it would append the name of 
each item to the list.? 
-- 
http://mail.python.org/mailman/listinfo/python-list


Blank TK Window

2012-07-17 Thread Shamefaced
Hi,
Any reason why a blank Tk() window opens up when I run my code:
Code:
for run in range(RUNS):
waittime = Monitor2()
checkouttime = Monitor2()
totaltimeinshop = Monitor2()
checkout_aisle = Simulation.Resource(AISLES)
Simulation.initialize()
cf = Customer_Market()
Simulation.activate(cf, cf.run(), 0.0)
Simulation.simulate(until=CLOSING)

 
Histo = waittime.histogram(low=0.0, high=80, nbins=40)
plt = SimPlot()
plt.plotLine(Histo, xlab='Time (min)',ylab='Qty Customers', 
   
  title="Wait Time",
  color="red", width=2,
  smooth='True')  
plt.mainloop()
-- 
http://mail.python.org/mailman/listinfo/python-list