Permalink
Browse files

working with occasional crashes

  • Loading branch information...
1 parent a7d5d6c commit 50e17a5a39e5cea6adba37b1fd9f67150b188dad Greg Borenstein committed Oct 26, 2011
Showing 703 changed files with 261,201 additions and 297 deletions.
View
@@ -0,0 +1 @@
+.DS_Store
View
@@ -21,6 +21,29 @@ class Skeletor {
Skeletor() {
}
+ String toJson() {
+ String result = "{\"project\" : \"skelestreamer\",";
+ result += "\"session\" : \"" + uuid + "\",";
+ result += "\"head\" : {\"x\":" + head.x + ", \"y\":" + head.y + ",\"z\":" + head.z + "},";
+ result += "\"neck\" : {\"x\":" + neck.x + ", \"y\":" + neck.y + ",\"z\":" + neck.z + "},";
+ result += "\"rightShoulder\" : {\"x\":" + rightShoulder.x + ", \"y\":" + rightShoulder.y + ",\"z\":" + rightShoulder.z + "},";
+ result += "\"rightElbow\" : {\"x\":" + rightElbow.x + ", \"y\":" + rightElbow.y + ",\"z\":" + rightElbow.z + "},";
+ result += "\"rightHand\" : {\"x\":" + rightHand.x + ", \"y\":" + rightHand.y + ",\"z\":" + rightHand.z + "},";
+ result += "\"leftShoulder\" : {\"x\":" + leftShoulder.x + ", \"y\":" + leftShoulder.y + ",\"z\":" + leftShoulder.z + "},";
+ result += "\"leftElbow\" : {\"x\":" + leftElbow.x + ", \"y\":" + leftElbow.y + ",\"z\":" + leftElbow.z + "},";
+ result += "\"leftHand\" : {\"x\":" + leftHand.x + ", \"y\":" + leftHand.y + ",\"z\":" + leftHand.z + "},";
+ result += "\"torso\" : {\"x\":" + torso.x + ", \"y\":" + torso.y + ",\"z\":" + torso.z + "},";
+ result += "\"rightHip\" : {\"x\":" + rightHip.x + ", \"y\":" + rightHip.y + ",\"z\":" + rightHip.z + "},";
+ result += "\"rightKnee\" : {\"x\":" + rightKnee.x + ", \"y\":" + rightKnee.y + ",\"z\":" + rightKnee.z + "},";
+ result += "\"rightFoot\" : {\"x\":" + rightFoot.x + ", \"y\":" + rightFoot.y + ",\"z\":" + rightFoot.z + "},";
+ result += "\"leftHip\" : {\"x\":" + leftHip.x + ", \"y\":" + leftHip.y + ",\"z\":" + leftHip.z + "},";
+ result += "\"leftKnee\" : {\"x\":" + leftKnee.x + ", \"y\":" + leftKnee.y + ",\"z\":" + leftKnee.z + "},";
+ result += "\"leftFoot\" : {\"x\":" + leftFoot.x + ", \"y\":" + leftFoot.y + ",\"z\":" + leftFoot.z + "}";
+
+ result += "}";
+ return result;
+ }
+
Skeletor(PVector _head, PVector _neck, PVector _rightShoulder, PVector _rightElbow, PVector _rightHand, PVector _leftShoulder, PVector _leftElbow, PVector _leftHand, PVector _torso, PVector _rightHip, PVector _rightKnee, PVector _rightFoot, PVector _leftHip, PVector _leftKnee, PVector _leftFoot) {
head = _head;
neck = _neck;
@@ -99,24 +122,35 @@ class Skeletor {
class CakeThread extends Thread {
- PostData pd;
+// PostData pd;
+ Client c;
+
boolean running;
- String url = "http://www.itpcakemix.com/add";
+ //String url = "http://www.itpcakemix.com/add";
ArrayList queue; // of skeletors
- CakeThread () {
+ CakeThread (PApplet p) {
running = false;
- pd = new PostData();
+ //pd = new PostData();
queue = new ArrayList();
+ c = new Client(p, "127.0.0.1", 1337);
+
}
- // TODO:
- // - send all enqueued data whenever available
+
void postData() {
- int queueSize = queue.size();
+
+ if(queue.size() > 0){
+ Skeletor toSend = (Skeletor)queue.get(0);
+ c.write(toSend.toJson());
+ c.write('\n');
+ queue.remove(0);
+ }
+
+ /* int queueSize = queue.size();
if (queueSize > 0) {
@@ -133,7 +167,7 @@ class CakeThread extends Thread {
vals[i] = toSend.toString();
//pd.post(url, toSend.vars(), toSend.vals());
}
-
+
println("var0: " + vars[0] + " val0: " + vals[0]);
String code = pd.post( url, vars, vals );
@@ -142,7 +176,7 @@ class CakeThread extends Thread {
for (int i = 0; i < queueSize; i++) {
queue.remove(0);
}
- }
+ }*/
}
// Overriding "start()"
@@ -155,7 +189,7 @@ class CakeThread extends Thread {
void run () {
while (running) {
try {
- //postData();
+ postData();
}
catch (Exception e) {
println("something went wrong with cakemix: " + e);
View
@@ -0,0 +1,72 @@
+/**
+ * jQuery.forEach
+ * generic forEach iterator for jQuery
+ * https://github.com/rosamez/jquery.forEach
+ * Licensed under the MIT license
+ */
+(function ($) {
+ var version = "1.1";
+
+ if ($.forEach || $.fn.forEach) {
+ alert("jQuery has its own forEach now?!");
+ return;
+ }
+
+ $.forEach = function (obj, func, scope, mirror) {//-{{{
+ var type = $.type, i = 0, n = 0, l;
+ if (typeof(obj) === "undefined" || obj === null) {
+ if (window.console && window.console.log) {
+ console.log("$.forEach: undefined or null param passed; please trace.")
+ }
+ } else if (type(obj.forEach) === "function") {
+ // native; core js 1.5 spec; tested with Opera10, FF35, recent
+ // Webkits; IE8 is still garbage
+ obj.forEach(func, scope);
+ } else if (type(obj) === "string") {
+ // since FF3.5 hates the while-way and has no native
+ // string iterator, it's better to have it this way
+ for (i = 0, l = obj.length; i < l; i++) {
+ func.call(scope, obj.charAt(i), i);
+ }
+ } else if (type(obj) === "array") {
+ // since FF has native forEach, the while speedup is useful here
+ // though the common while(l--) would do reverse iteration
+ l = obj.length;
+ while (!(i === l)) {
+ func.call(scope, obj[i], i++);
+ }
+ } else if (type(obj) === "object") {
+ if (obj.jquery && type(obj.each) === "function") {
+ // proxy for the jQuery internal "each"
+ obj.each(function (index, item) {
+ func.call(scope, item, index);
+ });
+ } else {
+ // plain old object
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ func.call(scope, obj[i], i, n++);
+ }
+ }
+ }
+ }
+ return mirror;
+ };//}}}
+
+ $.fn.extend({
+ forEach: function (func, scope) {
+ return $.forEach(this.toArray(), func, scope, this);
+ }
+ });
+
+ /*
+ // use $.makeArray()!
+ $.forEach.toArray = function (obj) {
+ return Array.prototype.slice.call(obj);
+ };
+ */
+
+ $.forEach.version = version;
+
+}(jQuery));
+// :wrap=none:collapseFolds=0:mode=javascript:tabSize=4:indentSize=4:folding=explicit:
View
@@ -0,0 +1,52 @@
+<html>
+ <head>
+ <title>Skelestreamer</title>
+ <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
+ <script src="for_each.js"></script>
+
+ <script src="http:///localhost:5000/socket.io/socket.io.js"></script>
+ <script>
+
+
+ //$(function(){
+ var socket = io.connect('http://localhost:5000');
+ socket.on('data', function (data) {
+ $.forEach(data, function(value, key, i){
+ //console.log($("#" + key));
+ if(key == "session"){
+ $("#" + key).html(value);
+ } else{
+ $("#" + key).html("x :" + value.x + " y: " + value.y + " z: " + value.z);
+ }
+ });
+ //console.log(eval(data));
+ });
+ //});
+ </script>
+ </head>
+ <body>
+ <h1>
+ Skelestreamer
+ </h1>
+ <h2>Data</h2>
+ <div><span class="label">uuid</span> <p id="session"></p></div>
+
+ <div><span class="label">head</span> <p id="head"></p>
+ </div><div><span class="label">neck</span> <p id="neck"></p>
+ </div><div><span class="label">rightShoulder</span> <p id="rightShoulder"></p>
+ </div><div><span class="label">rightElbow</span> <p id="rightElbow"></p>
+ </div><div><span class="label">rightHand</span> <p id="rightHand"></p>
+ </div><div><span class="label">leftShoulder</span> <p id="leftShoulder"></p>
+ </div><div><span class="label">leftElbow</span> <p id="leftElbow"></p>
+ </div><div><span class="label">leftHand</span> <p id="leftHand"></p>
+ </div><div><span class="label">torso</span> <p id="torso"></p>
+ </div><div><span class="label">rightHip</span> <p id="rightHip"></p>
+ </div><div><span class="label">rightKnee</span> <p id="rightKnee"></p>
+ </div><div><span class="label">rightFoot</span> <p id="rightFoot"></p>
+ </div><div><span class="label">leftHip</span> <p id="leftHip"></p>
+ </div><div><span class="label">leftKnee</span> <p id="leftKnee"></p>
+ </div><div><span class="label">leftFoot</span> <p id="leftFoot"></p>
+ </div>
+
+ </body>
+</html>
@@ -0,0 +1,7 @@
+.git*
+docs/
+examples/
+support/
+test/
+testing.js
+.DS_Store
Oops, something went wrong. Retry.

0 comments on commit 50e17a5

Please sign in to comment.