Commit 4da86566 authored by Caughlin Bohn's avatar Caughlin Bohn
Browse files

HTC Random Now

parent f49711f1
import time
import socket
from random import randint
from random import randint,choice
import subprocess
workers = {
"worker1": {"status":0,"time":0},
......@@ -30,26 +30,80 @@ def workersToData(workers):
data.append(workers["worker%d" % i]["status"])
writeWeb(data)
workersToData(workers)
active = []
dead = []
start = time.time()
for i in range(1,9):
currentWorker = "worker%d" % i
print(currentWorker)
sendLights("head %s 1" % currentWorker)
time.sleep(0.02)
dead.append("worker%d" % i)
workersToData(workers)
while (time.time() - start) < 45:
if randint(0,1) == 1 and len(dead) > 0:
currentWorker = choice(dead)
workers[currentWorker]["status"] = 1
sendLights("head %s 1" % currentWorker)
dead.remove(currentWorker)
active.append(currentWorker)
workersToData(workers)
print(workers[currentWorker]["status"])
time.sleep(0.3)
time.sleep(15)
for i in range(1,9):
currentWorker = "worker%d" % i
print(currentWorker)
sendLights("%s head 1" % currentWorker)
time.sleep(0.2)
if randint(0,1) == 1 and len(active) > 0:
currentWorker = choice(active)
if (time.time() - workers[currentWorker]["time"]) > 5:
workers[currentWorker]["status"] = 0
sendLights("%s head 1" % currentWorker)
workersToData(workers)
print(workers[currentWorker]["status"])
time.sleep(0.3)
active.remove(currentWorker)
dead.append(currentWorker)
# for i in range(1,9):
# currentWorker = "worker%d" % i
# print(currentWorker)
# sendLights("head %s 1" % currentWorker)
# time.sleep(0.02)
# workers[currentWorker]["status"] = 1
# workersToData(workers)
# print(workers[currentWorker]["status"])
# time.sleep(0.3)
# time.sleep(8)
# for i in range(1,9):
# currentWorker = "worker%d" % i
# print(currentWorker)
# if currentWorker == "worker8":
# sendLights("%s head 1" % "worker1")
# time.sleep(0.2)
# workers["worker1"]["status"] = 1
# workersToData(workers)
# sendLights("%s head 1" % currentWorker)
# time.sleep(0.2)
# workers[currentWorker]["status"] = 0
# workersToData(workers)
# print(workers[currentWorker]["status"])
# time.sleep(0.3)
# for i in range(2,9):
# currentWorker = "worker%d" % i
# print(currentWorker)
# sendLights("head %s 1" % currentWorker)
# time.sleep(0.02)
# workers[currentWorker]["status"] = 1
# workersToData(workers)
# print(workers[currentWorker]["status"])
# time.sleep(0.3)
# time.sleep(8)
# for i in range(1,9):
# currentWorker = "worker%d" % i
# print(currentWorker)
# sendLights("%s head 1" % currentWorker)
# time.sleep(0.2)
# workers[currentWorker]["status"] = 0
# workersToData(workers)
# print(workers[currentWorker]["status"])
# time.sleep(0.3)
workers = {
"worker1": {"status":0,"time":0},
......
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