Skip to content
This repository has been archived by the owner on Mar 2, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:ZeusWPI/12urenloop
Browse files Browse the repository at this point in the history
  • Loading branch information
Procrat committed May 26, 2015
2 parents 3cba548 + 2a24a5d commit 080f38b
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 33 deletions.
5 changes: 0 additions & 5 deletions boxxy/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ app.put('/ping', basicAuth, function(req, res) {
});

app.put('/state', basicAuth, function(req, res) {
try {
req.body.teams['16'].name = "VRG";
req.body.teams['19'].name = "Urgent.fm & Schamper";
} catch(err) {
}
console.log('PUT /state');
boxxyState.putState(req.body);
res.send('OK');
Expand Down
3 changes: 3 additions & 0 deletions count-von-count/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
dist
log
*.db
.cabal-sandbox
cabal.sandbox.config
external_sources
8 changes: 4 additions & 4 deletions count-von-count/count-von-count.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
circuitLength: 380
maxSpeed: 12
circuitLength: 306
maxSpeed: 15

batonWatchdogLifespan: 30

Expand All @@ -9,10 +9,10 @@ ekgPort: 8001

log: log/count-von-count.log
replayLog: log/replay.log
protocol: csv
protocol: gyrid

boxxies:
- host: "127.0.0.1"
- host: "live.12urenloop.be"
port: 8080
path: ""
user: "count-von-count"
Expand Down
50 changes: 27 additions & 23 deletions count-von-count/scripts/teams2015.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@ main = do
db <- newDatabase "count-von-count.db"
deleteAll db

addStation db "gyrid4" "00:01:95:0b:ac:02" 300 -- Marked 113
addStation db "gyrid101" "00:24:01:eb:c2:68" 20
addStation db "gyrid102" "00:21:91:f1:f1:39" 70
addStation db "gyrid103" "00:21:91:f1:f1:33" 100
addStation db "gyrid104" "00:01:95:0b:ac:02" 150
addStation db "gyrid105" "00:01:95:0a:56:32" 290
addStation db "gyrid106" "00:21:91:f1:ea:11" 320

--addStation db "gyrid1" "00:1c:f0:f1:f8:25" 45
--addStation db "gyrid2" "00:24:01:eb:c2:68" 120
--addStation db "gyrid3" "00:1c:f0:6c:39:32" 190
--addStation db "gyrid4" "00:21:91:f1:f1:33" 300
--addStation db "gyrid6" "00:1c:f0:6c:39:3e" 280
--addStation db "gyrid5" "00:24:01:eb:c2:65" 370

t1 <- addTeam db "KVHV"
t2 <- addTeam db "Kofschipclubs"
t3 <- addTeam db "Wetenschappen & VLAK"
t4 <- addTeam db "Blandinia"
t1 <- addTeam db "HILOK"
t2 <- addTeam db "VGK"
t3 <- addTeam db "VDK"
t4 <- addTeam db "VBK"
t5 <- addTeam db "VEK"
t6 <- addTeam db "VLK"
t7 <- addTeam db "VTK"
t8 <- addTeam db "HILOK"
t9 <- addTeam db "VBK"
t10 <- addTeam db "VGK"
t6 <- addTeam db "Wetenschappen & VLAK"
t7 <- addTeam db "Veto, LILA, Hermes"
t8 <- addTeam db "Blandinia"
t9 <- addTeam db "VPPK"
t10 <- addTeam db "Moeder Lies"
t11 <- addTeam db "Politeia"
t12 <- addTeam db "VPPK"
t13 <- addTeam db "Veto, Moeder Lies, LILA & Hermes"
t14 <- addTeam db "VRG & Farma"
t15 <- addTeam db "SeniorenKonvent"
t16 <- addTeam db "Home Konvent"
t17 <- addTeam db "Urgent & Schamper"
t12 <- addTeam db "Kofschipclubs"
t13 <- addTeam db "SK"
t14 <- addTeam db "HK"
t15 <- addTeam db "KVHV"
t16 <- addTeam db "VRG & Farma"
t17 <- addTeam db "VTK"
t18 <- addTeam db "VLK"
t19 <- addTeam db "Schamper"

b1 <- addBaton db "20:13:01:24:11:15" "Baton A"
b2 <- addBaton db "20:13:01:30:03:69" "Baton B"
Expand Down Expand Up @@ -80,5 +80,9 @@ main = do
setTeamBaton db t15 $ Just b15
setTeamBaton db t16 $ Just b16
setTeamBaton db t17 $ Just b17
setTeamBaton db t18 $ Just b18
setTeamBaton db t19 $ Just b19


closeDatabase db

72 changes: 72 additions & 0 deletions tools/analyse_cvclog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

"""
Anylyse the CVC log to generate some plots. This should actually be
done with the database to be correct.
Argument: count-von-count.log
"""

import numpy as np
import matplotlib.pyplot as plt
import itertools
import sys
import collections

length = 380
start = 9 # o'clock
now = 60 * 60 * 12 # how many seconds after the start the given log was taken

def time_to_relative_secs(timestring):
hours, minutes, seconds = timestring.split(':')
return 60 * 60 * (int(hours) - start) + 60 * int(minutes) + int(seconds)

lapcounts = dict()

with open(sys.argv[1], 'r') as f:
for line in f:

line = line.strip()
team = line.split(':')[-2][1:]
if team not in lapcounts:
# New team, let's make a new array for their points
lapcounts[team] = []

if "Lap for" in line:
lapcounts[line.split('for ')[-1]].append(
time_to_relative_secs(line.split(']')[0][1:]))

# filtering non-teams
filteredcounts = dict()
for team, times in lapcounts.items():
if times: filteredcounts[team] = times

# prediction
for team, times in filteredcounts.items():
current = len(times)
y = list(abs(current - now / t * i))
for i, t in enumerate(times))
plt.plot(times, y, label=team)
plt.show()
plt.clf()

# laps in function of time
for team, times in sorted(filteredcounts.items(), key=lambda tup: -len(tup[1])):
times = np.array(times)
plt.plot(times, range(len(times)), label="{} ({})".format(team, len(times)), linestyle='solid')
plt.legend(loc='upper left')
plt.xlabel('time in seconds')
plt.ylabel('number of laps')
plt.show()
plt.clf()

# laptime in function of time
for team, times in sorted(filteredcounts.items(), key=lambda tup: -len(tup[1])):
if team != 'VBK': continue # too cluttered for all
times = np.array(times)
plt.scatter(times[1:], times[1:] - times[:-1], label=team)
plt.legend(loc='upper left')
plt.xlabel('time in seconds')
plt.ylabel('time per lap')
plt.show()
plt.clf()

2 changes: 1 addition & 1 deletion tools/boxxy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

send() {
curl -XPUT localhost:8080/state \
curl -XPUT live.12urenloop.be:8080/state \
-H 'Content-Type: application/json' \
-u 'count-von-count:tetten' \
-d "$1"
Expand Down

0 comments on commit 080f38b

Please sign in to comment.