Commit 690ac2d0 authored by Caughlin Bohn's avatar Caughlin Bohn
Browse files

Net path update and general updates

parent 4da86566
......@@ -19,7 +19,7 @@ strip.begin()
NetPath ={
'A': ['C'],
'B': ['B'],
'B': ['B','C'],
'C': ['A','B','D'],
'D': ['E','G','C'],
'E': ['D','M','N','F'],
......@@ -74,8 +74,8 @@ NetLights ={
'HG' :[42,41,40,39],
'LG' :[36,35,34],
'GL' :[34,35,36],
'GK' :[33,34,37],
'KG' :[37,34,33],
'GK' :[34,37,38],
'KG' :[38,37,34],
'HI' :[43,44,45],
'IH' :[45,44,43],
'HJ' :[45,46,47],
......@@ -102,8 +102,8 @@ def find_path(graph, start, end, path=[]):
newpath = find_path(graph, node, end, path)
if newpath: return newpath
return None
print("starting")
import random
#print("starting")
iter = 0
while iter < int(sys.argv[3]):
......@@ -132,7 +132,7 @@ while iter < int(sys.argv[3]):
for i in range(0,100):
strip.setPixelColor(i, Color(0,0,0))
strip.show()
time.sleep(0.05)
time.sleep(0.02)
iter += 1
except Exception as e:
......
......@@ -32,10 +32,11 @@ def workersToData(workers):
start = time.time()
print("Starting")
sendLights("head worker1 5") ### Send data to master
sendLights("head worker1 1") ### Send data to master
sendLights("file worker1 4")
workers["worker1"]["status"] = 1 ### Turn on master
workersToData(workers)
time.sleep(5)
time.sleep(2)
time.sleep(1)
print("Master On")
......@@ -43,31 +44,56 @@ for i in range(2,9): ### Send master to slave data
currentWorker = "worker"+str(i)
print(currentWorker)
sendLights("worker1 %s 2" % currentWorker)
workers[currentWorker]["status"] = 1
workersToData(workers)
workers["worker1"]["status"] = 0
workersToData(workers)
time.sleep(1)
for i in range(2,9): ### Turn slave nodes on
print("Slaves on and working")
for i in range(1,10):
currentWorker = "worker"+str(randint(1,8))
w1 = "worker"+str(randint(2,8))
w2 = "worker"+str(randint(2,8))
sendLights("%s %s 1" % (w1,w2))
sendLights("%s %s 1" % (w2,w1))
workers["worker1"]["status"] = 1
workersToData(workers)
for i in range(2,9): ### Send data back
currentWorker = "worker"+str(i)
print(currentWorker)
sendLights("%s worker1 2" % currentWorker)
workers[currentWorker]["status"] = 0
workersToData(workers)
for i in range(2,9): ### Send master to slave data
currentWorker = "worker"+str(i)
print(currentWorker)
sendLights("worker1 %s 2" % currentWorker)
workers[currentWorker]["status"] = 1
workersToData(workers)
workers["worker1"]["status"] = 0
workersToData(workers)
time.sleep(1)
print("Slaves on and working")
for i in range(1,100):
for i in range(1,10):
currentWorker = "worker"+str(randint(1,8))
w1 = "worker"+str(randint(2,8))
w2 = "worker"+str(randint(2,8))
sendLights("%s %s 1" % (w1,w2))
sendLights("%s %s 1" % (w2,w1))
workers["worker1"]["status"] = 1
workersToData(workers)
for i in range(2,9): ### Send data back
currentWorker = "worker"+str(i)
print(currentWorker)
sendLights("%s worker1 2" % currentWorker)
for i in range(2,9): ### Turn slave nodes ooff
currentWorker = "worker"+str(i)
print(currentWorker)
workers[currentWorker]["status"] = 0
workersToData(workers)
workersToData(workers)
print("Doning")
time.sleep(6)
sendLights("worker1 head 10") ### Send data to head
sendLights("worker1 file 7")
sendLights("worker1 head 1") ### Send data to head
workers["worker1"]["status"] = 0 ### Turn off master
workersToData(workers)
......
......@@ -42,7 +42,9 @@ while (time.time() - start) < 45:
if randint(0,1) == 1 and len(dead) > 0:
currentWorker = choice(dead)
workers[currentWorker]["status"] = 1
workers[currentWorker]["time"] = time.time()
sendLights("head %s 1" % currentWorker)
sendLights("file %s 1" % currentWorker)
dead.remove(currentWorker)
active.append(currentWorker)
workersToData(workers)
......@@ -50,6 +52,7 @@ while (time.time() - start) < 45:
currentWorker = choice(active)
if (time.time() - workers[currentWorker]["time"]) > 5:
workers[currentWorker]["status"] = 0
sendLights("%s file 1" % currentWorker)
sendLights("%s head 1" % currentWorker)
workersToData(workers)
active.remove(currentWorker)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment