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
TomNaessens committed Apr 29, 2014
2 parents 7e79118 + d3d008f commit e5cc040
Show file tree
Hide file tree
Showing 54 changed files with 3,503 additions and 142 deletions.
77 changes: 61 additions & 16 deletions boxxy/src/boxxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ function Boxxy() {

/* State */
this.frozen = false;
this.frozenLaps = null;
this.frozenTeams = null;
this.notification = null;
this.circuitLength = 0;
this.startTime = null;
Expand All @@ -18,13 +20,60 @@ function Boxxy() {
this.onUpdatePosition = function(position) {};
this.onUpdate = function() {};
}
function clone(obj) {
// Handle the 3 simple types, and null or undefined
if (null == obj || "object" != typeof obj) return obj;

// Handle Date
if (obj instanceof Date) {
var copy = new Date();
copy.setTime(obj.getTime());
return copy;
}

// Handle Array
if (obj instanceof Array) {
var copy = [];
for (var i = 0, len = obj.length; i < len; i++) {
copy[i] = clone(obj[i]);
}
return copy;
}

// Handle Object
if (obj instanceof Object) {
var copy = {};
for (var attr in obj) {
if (obj.hasOwnProperty(attr)) copy[attr] = clone(obj[attr]);
}
return copy;
}

throw new Error("Unable to copy obj! Its type isn't supported.");
}

Boxxy.prototype.putState = function(stateDelta) {
if(stateDelta.frozen != null) this.frozen = stateDelta.frozen;
if(stateDelta.notification != null) this.notification = stateDelta.notification;
if(stateDelta.circuitLength != null) this.circuitLength = stateDelta.circuitLength;
if(stateDelta.startTime != null) this.startTime = stateDelta.startTime;
if(stateDelta.stations != null) this.stations = stateDelta.stations;

// This signifies the change melted -> frozen
if(stateDelta.frozen != null && stateDelta.frozen && !this.frozen) {
if(stateDelta.laps && stateDelta.teams) {
this.laps = stateDelta.laps;
this.teams = stateDelta.teams;
}
this.frozenLaps = clone(this.laps);
this.frozenTeams = clone(this.teams);
this.frozen = true;
}

// This signifies the change frozen -> melted
if(stateDelta.frozen != null && !stateDelta.frozen && this.frozen) {
this.frozen = false;
}

if(!this.frozen && stateDelta.teams) this.teams = stateDelta.teams;
if(!this.frozen && stateDelta.laps) this.laps = stateDelta.laps;

Expand All @@ -33,26 +82,22 @@ Boxxy.prototype.putState = function(stateDelta) {
}

Boxxy.prototype.addLap = function(lap) {
if(!this.frozen) {
if(this.laps.length >= this.maxLaps) this.laps.pop();
this.laps = [lap].concat(this.laps);
if(this.laps.length >= this.maxLaps) this.laps.pop();
this.laps = [lap].concat(this.laps);

/* Just copy the total laps instead of calculating it, more robust. */
this.teams[lap.team].laps = lap.total;
this.teams[lap.team].updated = lap.timestamp;
/* Just copy the total laps instead of calculating it, more robust. */
this.teams[lap.team].laps = lap.total;
this.teams[lap.team].updated = lap.timestamp;

this.onAddLap(lap);
this.onUpdate();
}
this.onAddLap(lap);
this.onUpdate();
}

Boxxy.prototype.updatePosition = function(position) {
if(!this.frozen) {
this.teams[position.team].station = position.station;
this.teams[position.team].updated = position.timestamp;
this.onUpdatePosition(position);
this.onUpdate();
}
this.teams[position.team].station = position.station;
this.teams[position.team].updated = position.timestamp;
this.onUpdatePosition(position);
this.onUpdate();
}

Boxxy.prototype.teamsByScore = function() {
Expand Down
26 changes: 22 additions & 4 deletions boxxy/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,37 @@ app.use(express.static('public')); // Serve the public dir as-is
var boxxyState = boxxy.initialize();

io.sockets.on('connection', function(socket) {
socket.emit('/state', boxxyState);
if (boxxyState.frozen) {
state = {};
state.circuitLength = boxxyState.circuitLength;
state.startTime = boxxyState.startTime;
state.stopTime = boxxyState.stopTime;
state.stations = boxxyState.stations;
state.laps = boxxyState.frozenLaps;
state.teams = boxxyState.frozenTeams;
state.frozen = true;
socket.emit('/state', state);
} else {
socket.emit('/state', boxxyState);
}
});

boxxyState.onPutState = function(stateDelta) {
io.sockets.emit('/state', stateDelta);
if (!boxxyState.frozen) {
io.sockets.emit('/state', stateDelta);
}
}

boxxyState.onAddLap = function(lap) {
io.sockets.emit('/lap', lap);
if (!boxxyState.frozen) {
io.sockets.emit('/lap', lap);
}
}

boxxyState.onUpdatePosition = function(position) {
io.sockets.emit('/position', position);
if (!boxxyState.frozen) {
io.sockets.emit('/position', position);
}
}

// count-von-count facing API
Expand Down
81 changes: 81 additions & 0 deletions config/gyrid.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Gyrid configuration file
[Gyrid]

# The buffer length in seconds. This is the amount of time a device may
# disappear and appear again without it being noticed. This option also
# influences the inquiry time, which is defined as ceil(buffer_size/1.28).
# Values:
# 10.24 - (default) Buffer size to match the inquiry time of 8*1.28s.
buffer_size = 10.24

# Support for flashing LEDs on ALIX boards.
# Values:
# False - Disable support.
# True - (default) Enable support.
alix_led_support = True

# The time format to use in the logfile. This string is passed to the
# time.strftime() function. Hint: don't use %z, it doesn't work.
# Values:
# %Y%m%d-%H%M%S-%Z - (default) Use the YYYYMMDD-HHMMSS-TZ format.
time_format = %Y%m%d-%H%M%S%Q-%Z

# Enable logging of received RSSI data.
# Values:
# False - Disable RSSI logging.
# True - (default) Enable RSSI logging.
enable_rssi_log = True

# Enable logging of Bluetooth inquiries. This includes the starttime of each
# inquiry and enables to determine when each sensor was active scanning.
# Values:
# False - Disable inquiry logging.
# True - (default) Enable inquiry logging.
enable_inquiry_log = True

# The minimum RSSI value for a detection to be recorded. None to record all
# detections. This is a potentially dangerous option as it can greatly reduce
# the amount of data recorded. Use with care.
minimum_rssi = None

# A list of HCI device-ID's to exclude from scanning. For example: 0 to
# exclude hci0, None to enable all devices.
excluded_devices = None

# Path to the blacklist file containing Bluetooth MAC-addresses excluded from
# registration.
blacklist_file = /etc/gyrid/blacklist.conf

# The network host of the server to talk to. This can be an IP-address or a
# domain name. Disable networking support when None.
network_server_host = 10.1.2.249

# The TCP port to be used on the server.
network_server_port = 2583

# Path to the SSL client certificate. None to disable SSL.
network_ssl_client_crt = None

# Path to the SSL client key. None to disable SSL.
network_ssl_client_key = None

# Maximum size of the network cache file in megabytes (MB). Defaults to 250
# MB. When this maximum size is reached, caching is suspended.
network_cache_limit = 250

# Path to the Arduino rotating platform configuration file. This should be in
# CSV format, containing the following fields: MAC-address of the scanning
# device, filename of the device node of the corresponding Arduino (without
# /dev/), turning resolution (i.e. in how many parts the 180 degree arc is
# divided).
arduino_conffile = /etc/gyrid/arduino.conf

# Enable hashing of privacy sensitive data.
# Values:
# False - Disable hashing.
# True - (default) Enable hashing.
enable_hashing = False

# Salt to use when hashing. This is parsed by strftime to enable time-based
# salting.
hash_salt = kO25szOW54jM
108 changes: 52 additions & 56 deletions count-von-count/count-von-count.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,32 @@ Executable count-von-count
CountVonCount.Web.Views.Util

Build-depends:
aeson >= 0.5 && < 0.7,
attoparsec >= 0.9 && < 0.11,
attoparsec-enumerator >= 0.2 && < 0.4,
base >= 4 && < 5,
blaze-html >= 0.5 && < 0.7,
blaze-markup >= 0.5 && < 0.6,
bytestring >= 0.9 && < 0.11,
conduit >= 1.0 && < 1.1,
containers >= 0.3 && < 0.6,
digestive-functors >= 0.4.1 && < 0.7,
digestive-functors-blaze >= 0.4 && < 0.7,
digestive-functors-snap >= 0.4 && < 0.7,
ekg >= 0.3 && < 0.4,
enumerator >= 0.4 && < 0.5,
http-conduit >= 1.4 && < 1.10,
mtl >= 2.0 && < 2.2,
network >= 2.3 && < 2.5,
network-enumerator >= 0.1 && < 0.2,
old-locale >= 1.0 && < 1.1,
snap-blaze >= 0.2 && < 0.3,
snap-core >= 0.8 && < 0.10,
snap-server >= 0.8 && < 0.10,
sqlite-simple >= 0.4 && < 0.5,
text >= 0.10 && < 0.12,
time >= 1.2 && < 1.5,
websockets >= 0.6 && < 0.8,
websockets-snap >= 0.6 && < 0.8,
yaml >= 0.7 && < 0.9
aeson >= 0.5 && < 0.8,
base >= 4 && < 5,
blaze-html >= 0.5 && < 0.7,
blaze-markup >= 0.5 && < 0.6,
bytestring >= 0.10.2 && <= 0.10.4.0,
conduit >= 1.0 && < 1.1,
containers >= 0.3 && < 0.6,
digestive-functors >= 0.4.1 && < 0.8,
digestive-functors-blaze >= 0.4 && < 0.7,
digestive-functors-snap >= 0.4 && < 0.7,
ekg >= 0.3 && < 0.4,
io-streams >= 1.1.4.2 && < 1.2,
http-conduit >= 1.4 && < 1.10,
mtl >= 2.0 && < 2.2,
network >= 2.3 && < 2.5,
old-locale >= 1.0 && < 1.1,
protocol-buffers >= 2.0.14 && < 2.1,
snap-blaze >= 0.2 && < 0.3,
snap-core >= 0.8 && < 0.10,
snap-server >= 0.8 && < 0.10,
sqlite-simple >= 0.4 && < 0.5,
text >= 0.10 && < 1.2,
time >= 1.2 && < 1.5,
websockets >= 0.6 && < 0.8,
websockets-snap >= 0.6 && < 0.8,
yaml >= 0.7 && < 0.9

Executable count-von-count-simulation
Hs-source-dirs: src
Expand Down Expand Up @@ -93,31 +91,29 @@ Test-suite count-von-count-tests
test-framework >= 0.4 && < 0.9,
test-framework-hunit >= 0.2 && < 0.4,
-- Copied from regular dependencies...
aeson >= 0.5 && < 0.7,
attoparsec >= 0.9 && < 0.11,
attoparsec-enumerator >= 0.2 && < 0.4,
base >= 4 && < 5,
blaze-html >= 0.5 && < 0.7,
blaze-markup >= 0.5 && < 0.6,
bytestring >= 0.9 && < 0.11,
conduit >= 1.0 && < 1.1,
containers >= 0.3 && < 0.6,
digestive-functors >= 0.4.1 && < 0.7,
digestive-functors-blaze >= 0.4 && < 0.7,
digestive-functors-snap >= 0.4 && < 0.7,
ekg >= 0.3 && < 0.4,
enumerator >= 0.4 && < 0.5,
http-conduit >= 1.4 && < 1.10,
mtl >= 2.0 && < 2.2,
network >= 2.3 && < 2.5,
network-enumerator >= 0.1 && < 0.2,
old-locale >= 1.0 && < 1.1,
snap-blaze >= 0.2 && < 0.3,
snap-core >= 0.8 && < 0.10,
snap-server >= 0.8 && < 0.10,
sqlite-simple >= 0.4 && < 0.5,
text >= 0.10 && < 0.12,
time >= 1.2 && < 1.5,
websockets >= 0.6 && < 0.8,
websockets-snap >= 0.6 && < 0.8,
yaml >= 0.7 && < 0.9
aeson >= 0.5 && < 0.8,
base >= 4 && < 5,
blaze-html >= 0.5 && < 0.7,
blaze-markup >= 0.5 && < 0.6,
bytestring >= 0.10.2 && <= 0.10.4.0,
conduit >= 1.0 && < 1.1,
containers >= 0.3 && < 0.6,
digestive-functors >= 0.4.1 && < 0.8,
digestive-functors-blaze >= 0.4 && < 0.7,
digestive-functors-snap >= 0.4 && < 0.7,
ekg >= 0.3 && < 0.4,
io-streams >= 1.1.4.2 && < 1.2,
http-conduit >= 1.4 && < 1.10,
mtl >= 2.0 && < 2.2,
network >= 2.3 && < 2.5,
old-locale >= 1.0 && < 1.1,
protocol-buffers >= 2.0.14 && < 2.1,
snap-blaze >= 0.2 && < 0.3,
snap-core >= 0.8 && < 0.10,
snap-server >= 0.8 && < 0.10,
sqlite-simple >= 0.4 && < 0.5,
text >= 0.10 && < 1.2,
time >= 1.2 && < 1.5,
websockets >= 0.6 && < 0.8,
websockets-snap >= 0.6 && < 0.8,
yaml >= 0.7 && < 0.9
Loading

0 comments on commit e5cc040

Please sign in to comment.