Skip to content
Snippets Groups Projects
Commit 529b3992 authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

wip

parent c4d325a8
No related branches found
No related tags found
No related merge requests found
...@@ -94,7 +94,7 @@ def worker3(id,count): ...@@ -94,7 +94,7 @@ def worker3(id,count):
elif ((localcount >= 4*maxcount/7) and (localcount < 5*maxcount/7)): elif ((localcount >= 4*maxcount/7) and (localcount < 5*maxcount/7)):
ports[id].write(forward) ports[id].write(forward)
elif ((localcount >= 5*maxcount/7) and (localcount%5 == 0)): elif ((localcount >= 5*maxcount/7) and (localcount%5 == 0)):
ports[id].write(reserve) ports[id].write(reverse)
# #
# alarm event handler # alarm event handler
# #
......
...@@ -33,7 +33,6 @@ print('open '+device2+' at '+str(baud)+' delay '+str(delay)) ...@@ -33,7 +33,6 @@ print('open '+device2+' at '+str(baud)+' delay '+str(delay))
port2 = serial.Serial(device2,baudrate=baud,timeout=0) port2 = serial.Serial(device2,baudrate=baud,timeout=0)
print('open '+device3+' at '+str(baud)+' delay '+str(delay)) print('open '+device3+' at '+str(baud)+' delay '+str(delay))
port3 = serial.Serial(device3,baudrate=baud,timeout=0) port3 = serial.Serial(device3,baudrate=baud,timeout=0)
count = 0;
# #
# global variables # global variables
# #
...@@ -45,7 +44,8 @@ reverse = b'r' ...@@ -45,7 +44,8 @@ reverse = b'r'
# alarm event handler # alarm event handler
# #
def alarm(signum,stack): def alarm(signum,stack):
count.value += 1 global count
count += 1
if (count < maxcount/7): if (count < maxcount/7):
port0.write(forward) port0.write(forward)
elif ((count >= 1*maxcount/7) and (count < 2*maxcount/7)): elif ((count >= 1*maxcount/7) and (count < 2*maxcount/7)):
...@@ -59,7 +59,7 @@ def alarm(signum,stack): ...@@ -59,7 +59,7 @@ def alarm(signum,stack):
port1.write(forward) port1.write(forward)
port2.write(reverse) port2.write(reverse)
port3.write(forward) port3.write(forward)
elif (count >= 5*maxcount/7)): elif (count >= 5*maxcount/7):
if (count%2 == 0): if (count%2 == 0):
port0.write(forward) port0.write(forward)
if (count%3 == 0): if (count%3 == 0):
...@@ -68,17 +68,8 @@ def alarm(signum,stack): ...@@ -68,17 +68,8 @@ def alarm(signum,stack):
port2.write(forward) port2.write(forward)
if (count%5 == 0): if (count%5 == 0):
port3.write(reverse) port3.write(reverse)
# if (count > maxcount):
# start workers count = 0
#
p0 = multiprocessing.Process(target=worker0,args=(0,count))
p0.start()
p1 = multiprocessing.Process(target=worker1,args=(1,count))
p1.start()
p2 = multiprocessing.Process(target=worker2,args=(2,count))
p2.start()
p3 = multiprocessing.Process(target=worker3,args=(3,count))
p3.start()
# #
# start alarm # start alarm
# #
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment