Permalink
Browse files

Graph, js, etc...

  • Loading branch information...
hugokernel committed Sep 25, 2013
1 parent 21a8e58 commit 823f96e5511eabfee5c66d9bc2ce26e69af331c8
Showing with 44,071 additions and 758 deletions.
  1. +8 −2 src/BleuettePi/Python/lib/BleuettePi.py
  2. +7 −4 src/BleuettePi/Python/lib/Fake.py
  3. +16 −5 src/BleuettePi/Python/lib/Sequencer.py
  4. +81 −21 src/BleuettePi/Python/lib/Servo.py
  5. +80 −70 src/BleuettePi/Python/ws.py
  6. 0 src/BleuettePi/Python/www/OrbitControls.js
  7. +437 −0 src/BleuettePi/Python/www/bleuette.js
  8. +368 −0 src/BleuettePi/Python/www/curvedLines.js
  9. +0 −2 src/BleuettePi/Python/www/dygraph-combined.js
  10. +1,464 −0 src/BleuettePi/Python/www/flot/API.md
  11. +99 −0 src/BleuettePi/Python/www/flot/CONTRIBUTING.md
  12. +75 −0 src/BleuettePi/Python/www/flot/FAQ.md
  13. +22 −0 src/BleuettePi/Python/www/flot/LICENSE.txt
  14. +12 −0 src/BleuettePi/Python/www/flot/Makefile
  15. +893 −0 src/BleuettePi/Python/www/flot/NEWS.md
  16. +143 −0 src/BleuettePi/Python/www/flot/PLUGINS.md
  17. +110 −0 src/BleuettePi/Python/www/flot/README.md
  18. 0 src/BleuettePi/Python/www/flot/build.log
  19. +4 −0 src/BleuettePi/Python/www/flot/examples/ajax/data-eu-gdp-growth-1.json
  20. +4 −0 src/BleuettePi/Python/www/flot/examples/ajax/data-eu-gdp-growth-2.json
  21. +4 −0 src/BleuettePi/Python/www/flot/examples/ajax/data-eu-gdp-growth-3.json
  22. +4 −0 src/BleuettePi/Python/www/flot/examples/ajax/data-eu-gdp-growth-4.json
  23. +4 −0 src/BleuettePi/Python/www/flot/examples/ajax/data-eu-gdp-growth-5.json
  24. +4 −0 src/BleuettePi/Python/www/flot/examples/ajax/data-eu-gdp-growth.json
  25. +4 −0 src/BleuettePi/Python/www/flot/examples/ajax/data-japan-gdp-growth.json
  26. +4 −0 src/BleuettePi/Python/www/flot/examples/ajax/data-usa-gdp-growth.json
  27. +173 −0 src/BleuettePi/Python/www/flot/examples/ajax/index.html
  28. +87 −0 src/BleuettePi/Python/www/flot/examples/annotating/index.html
  29. +97 −0 src/BleuettePi/Python/www/flot/examples/axes-interacting/index.html
  30. +77 −0 src/BleuettePi/Python/www/flot/examples/axes-multiple/index.html
  31. +893 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/date.js
  32. +114 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/index.html
  33. +1,181 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/africa
  34. +413 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/antarctica
  35. +2,717 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/asia
  36. +1,719 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/australasia
  37. +117 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/backward
  38. +81 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/etcetera
  39. +2,856 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/europe
  40. +10 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/factory
  41. +276 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/iso3166.tab
  42. +100 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/leapseconds
  43. +3,235 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/northamerica
  44. +28 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/pacificnew
  45. +390 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/solar87
  46. +390 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/solar88
  47. +395 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/solar89
  48. +1,711 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/southamerica
  49. +38 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/systemv
  50. +38 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/yearistype.sh
  51. +441 −0 src/BleuettePi/Python/www/flot/examples/axes-time-zones/tz/zone.tab
  52. +137 −0 src/BleuettePi/Python/www/flot/examples/axes-time/index.html
  53. BIN src/BleuettePi/Python/www/flot/examples/background.png
  54. +91 −0 src/BleuettePi/Python/www/flot/examples/basic-options/index.html
  55. +57 −0 src/BleuettePi/Python/www/flot/examples/basic-usage/index.html
  56. +75 −0 src/BleuettePi/Python/www/flot/examples/canvas/index.html
  57. +64 −0 src/BleuettePi/Python/www/flot/examples/categories/index.html
  58. +97 −0 src/BleuettePi/Python/www/flot/examples/examples.css
  59. BIN src/BleuettePi/Python/www/flot/examples/image/hs-2004-27-a-large-web.jpg
  60. +69 −0 src/BleuettePi/Python/www/flot/examples/image/index.html
  61. +80 −0 src/BleuettePi/Python/www/flot/examples/index.html
  62. +130 −0 src/BleuettePi/Python/www/flot/examples/interacting/index.html
  63. BIN src/BleuettePi/Python/www/flot/examples/navigate/arrow-down.gif
  64. BIN src/BleuettePi/Python/www/flot/examples/navigate/arrow-left.gif
  65. BIN src/BleuettePi/Python/www/flot/examples/navigate/arrow-right.gif
  66. BIN src/BleuettePi/Python/www/flot/examples/navigate/arrow-up.gif
  67. +153 −0 src/BleuettePi/Python/www/flot/examples/navigate/index.html
  68. +79 −0 src/BleuettePi/Python/www/flot/examples/percentiles/index.html
  69. +122 −0 src/BleuettePi/Python/www/flot/examples/realtime/index.html
  70. +76 −0 src/BleuettePi/Python/www/flot/examples/resize/index.html
  71. +141 −0 src/BleuettePi/Python/www/flot/examples/selection/index.html
  72. +150 −0 src/BleuettePi/Python/www/flot/examples/series-errorbars/index.html
  73. +818 −0 src/BleuettePi/Python/www/flot/examples/series-pie/index.html
  74. +121 −0 src/BleuettePi/Python/www/flot/examples/series-toggle/index.html
  75. +90 −0 src/BleuettePi/Python/www/flot/examples/series-types/index.html
  76. +6 −0 src/BleuettePi/Python/www/flot/examples/shared/jquery-ui/jquery-ui.min.css
  77. +6 −0 src/BleuettePi/Python/www/flot/examples/shared/jquery-ui/jquery-ui.min.js
  78. +107 −0 src/BleuettePi/Python/www/flot/examples/stacking/index.html
  79. +76 −0 src/BleuettePi/Python/www/flot/examples/symbols/index.html
  80. +76 −0 src/BleuettePi/Python/www/flot/examples/threshold/index.html
  81. +135 −0 src/BleuettePi/Python/www/flot/examples/tracking/index.html
  82. +146 −0 src/BleuettePi/Python/www/flot/examples/visitors/index.html
  83. +144 −0 src/BleuettePi/Python/www/flot/examples/zooming/index.html
  84. +1,428 −0 src/BleuettePi/Python/www/flot/excanvas.js
  85. +1 −0 src/BleuettePi/Python/www/flot/excanvas.min.js
  86. +179 −0 src/BleuettePi/Python/www/flot/jquery.colorhelpers.js
  87. +21 −0 src/BleuettePi/Python/www/flot/jquery.colorhelpers.min.js
  88. +345 −0 src/BleuettePi/Python/www/flot/jquery.flot.canvas.js
  89. +28 −0 src/BleuettePi/Python/www/flot/jquery.flot.canvas.min.js
  90. +190 −0 src/BleuettePi/Python/www/flot/jquery.flot.categories.js
  91. +44 −0 src/BleuettePi/Python/www/flot/jquery.flot.categories.min.js
  92. +176 −0 src/BleuettePi/Python/www/flot/jquery.flot.crosshair.js
  93. +59 −0 src/BleuettePi/Python/www/flot/jquery.flot.crosshair.min.js
  94. +353 −0 src/BleuettePi/Python/www/flot/jquery.flot.errorbars.js
  95. +63 −0 src/BleuettePi/Python/www/flot/jquery.flot.errorbars.min.js
  96. +226 −0 src/BleuettePi/Python/www/flot/jquery.flot.fillbetween.js
  97. +30 −0 src/BleuettePi/Python/www/flot/jquery.flot.fillbetween.min.js
  98. +241 −0 src/BleuettePi/Python/www/flot/jquery.flot.image.js
  99. +53 −0 src/BleuettePi/Python/www/flot/jquery.flot.image.min.js
  100. +3,061 −0 src/BleuettePi/Python/www/flot/jquery.flot.js
  101. +29 −0 src/BleuettePi/Python/www/flot/jquery.flot.min.js
  102. +346 −0 src/BleuettePi/Python/www/flot/jquery.flot.navigate.js
  103. +86 −0 src/BleuettePi/Python/www/flot/jquery.flot.navigate.min.js
  104. +817 −0 src/BleuettePi/Python/www/flot/jquery.flot.pie.js
  105. +56 −0 src/BleuettePi/Python/www/flot/jquery.flot.pie.min.js
  106. +60 −0 src/BleuettePi/Python/www/flot/jquery.flot.resize.js
  107. +19 −0 src/BleuettePi/Python/www/flot/jquery.flot.resize.min.js
  108. +360 −0 src/BleuettePi/Python/www/flot/jquery.flot.selection.js
  109. +79 −0 src/BleuettePi/Python/www/flot/jquery.flot.selection.min.js
  110. +188 −0 src/BleuettePi/Python/www/flot/jquery.flot.stack.js
  111. +36 −0 src/BleuettePi/Python/www/flot/jquery.flot.stack.min.js
  112. +71 −0 src/BleuettePi/Python/www/flot/jquery.flot.symbol.js
  113. +14 −0 src/BleuettePi/Python/www/flot/jquery.flot.symbol.min.js
  114. +142 −0 src/BleuettePi/Python/www/flot/jquery.flot.threshold.js
  115. +43 −0 src/BleuettePi/Python/www/flot/jquery.flot.threshold.min.js
  116. +431 −0 src/BleuettePi/Python/www/flot/jquery.flot.time.js
  117. +9 −0 src/BleuettePi/Python/www/flot/jquery.flot.time.min.js
  118. +9,472 −0 src/BleuettePi/Python/www/flot/jquery.js
  119. +2 −0 src/BleuettePi/Python/www/flot/jquery.min.js
  120. +101 −82 src/BleuettePi/Python/www/index.html
  121. +82 −0 src/BleuettePi/Python/www/smokesignals.js
  122. 0 src/BleuettePi/Python/www/three.min.js
  123. +460 −572 src/BleuettePi/Python/www/ws.js
@@ -18,6 +18,8 @@
from drivers.Adafruit_MCP230xx import Adafruit_MCP230XX as MCP230XX
from Analog import Analog
logger = logging.getLogger('BleuettePi')
class BleuettePi_Compass:
# Declination, ~Paris : 0.7
@@ -28,8 +30,11 @@ class BleuettePi_Compass:
ADDRESS = 0x1E
def get(self):
compass = hmc5883l(port = self.PORT, address = self.ADDRESS, gauss = 4.7, declination = self.DECLINATION)
return [ compass.axes(), compass.degrees(compass.heading()) ]
try:
compass = hmc5883l(port = self.PORT, address = self.ADDRESS, gauss = 4.7, declination = self.DECLINATION)
return [ compass.axes(), compass.degrees(compass.heading()) ]
except Exception, e:
logger.critical("Exception ! " + str(e));
def realTime(self):
compass = hmc5883l(port = self.PORT, address = self.ADDRESS, gauss = 4.7, declination = self.DECLINATION)
@@ -115,6 +120,7 @@ def __init__(self, mixed):
self.Servo = Servo.Servo(self.serial, fakemode = Config.FAKE_MODE)
self.Servo.init()
Servo.Servo_Trim.values = Data.Instance().get(['servo', 'trims'])
Servo.Servo_Limit.values = Data.Instance().get(['servo', 'limits'])
@@ -26,10 +26,10 @@ def __init__(self, port=1, address=0x1E, gauss=1.3, declination=(0,0)):
pass
def axes(self):
return (0, 0, 0)
return (randint(0, 10), randint(0, 10), randint(0, 10))
def heading(self):
return (0, 0)
return (randint(0, 260), randint(0, 260))
def degrees(self, (degrees, minutes)):
return ""
@@ -46,7 +46,7 @@ def quickCalibrate(self):
pass
def readAccelCal(self):
return (0, 0, 0)
return (randint(0, 10), randint(0, 10), randint(0, 10))
class MCP230XX:
@@ -75,5 +75,8 @@ def __init__(self, a):
pass
def getCurrent(self):
return 0
return 1 + 0.1 * randint(0, 5)
def read(self, index):
return 11 + 0.1 * randint(0, 1)
@@ -2,6 +2,8 @@
import threading, time
import Sequences
import Define
import Servo
#from Define import __, PAUSE, FRONT, BACK, DOWN, UP, MID, DELAY_MIN
HMIN = 85
@@ -61,7 +63,7 @@ def run(self):
self._stopevent.wait(0.5)
print "le thread s'est termine proprement"
print "End of Thread"
def stop(self):
self._stopevent.set()
@@ -119,6 +121,8 @@ def forward(self, count = 1):
class Sequencer:
Servo = None
ServoSeq = None
Buffer = None
Thread = None
@@ -131,6 +135,10 @@ def __init__(self, servo):
self.Buffer = Sequencer_Buffer(self)
self.Thread = Sequencer_Thread(self)
self.ServoSeq = Servo.Servo_Sequencer(self.Servo)
self.ServoSeq.daemon = True;
self.ServoSeq.start()
# def test(self):
# self.Thread = Sequencer_Thread(self)
@@ -193,11 +201,14 @@ def reverse(self, seq, count = 1, start_at = 0, callback = None):
c(s, seq.sequence)
def play(self, seq):
for i in range(0, len(seq[1])):
if seq[1][i] != Define.__:
self.Servo.setValue(i, self.getValue(i, seq[1][i]))
self.Servo.sendValues()
with self.ServoSeq as servoSeq:
for i in range(0, len(seq[1])):
if seq[1][i] != Define.__:
servoSeq.setPosition(i, self.getValue(i, seq[1][i]))
#self.Servo.setValue(i, self.getValue(i, seq[1][i]))
#self.Servo.sendValues()
if seq[2]:
seq[2]()
@@ -1,7 +1,7 @@
import serial, types, time, copy, logging, threading
from Serial import Serial
from Define import BPi_Cmd
import serial, types, time, copy, logging
from array import array
from Data import Data
from Singleton import Singleton
@@ -37,6 +37,69 @@ def wrapper(*args, **kwargs):
return fn(*args)
return wrapper
# Run in background and send target value when possible
class Servo_Sequencer(threading.Thread):
BUFFER_SIZE = 100
event = None
__servo = None
__values = []
__buffer = []
__contextManagerMode = False
def __init__(self, servo):
self.__servo = servo
threading.Thread.__init__(self)
self.event = threading.Event()
self.logger = logging.getLogger('Servo sequencer')
def run(self):
i = 0
while True: #not self.__pause:
if len(self.__buffer):
v = self.__buffer.pop()
if v:
if len(v) == 2:
#self.logger.debug('Standard value')
self.__servo.setValue(v[0], v[1])
self.__servo.sendValues()
else:
#self.logger.debug('Transaction')
for i in range(0, len(v)):
self.__servo.setValue(i, v[i])
self.__servo.sendValues()
self.event.wait(0.005)
def __enter__(self):
self.__contextManagerMode = True
self.__values = self.__servo.getValues()
return self
def __exit__(self, exception_type, exception_value, traceback):
self.__contextManagerMode = False
self.__buffer.append(self.__values);
def setPosition(self, index, value):
if len(self.__buffer) <= self.BUFFER_SIZE:
if self.__contextManagerMode:
self.__values[index] = value
else:
self.__buffer.append([ index, value ]);
else:
self.logger.error('Buffer full : Skip value !')
#def stop(self):
# self._stopevent.set()
LOCK = False
class Servo(Serial):
@@ -63,11 +126,8 @@ class Servo(Serial):
last_status_code = ''
#values = array('c', [chr(0)] * COUNT)
#sent_values = array('c', [chr(0)] * COUNT)
values = array('h', [0] * COUNT)
sent_values = array('h', [0] * COUNT)
__values = array('h', [0] * COUNT)
__sent_values = array('h', [0] * COUNT)
__callback = []
@@ -96,7 +156,6 @@ def sendValues(self):
retry = self.MAX_RETRY
if LOCK:
self.logger.critical('Lock error !')
raise ServoException('Lock error !')
LOCK = True
@@ -109,8 +168,7 @@ def sendValues(self):
control = 0
for i in range(0, self.COUNT):
#self.serial.write(chr(value))
value = self.writeValue(i, self.values[i])
value = self.writeValue(i, self.__values[i])
values.append(value)
control += value
@@ -121,10 +179,10 @@ def sendValues(self):
self.last_status_code = self.getResponse()
if (self.last_status_code == self.ACK):
if self.last_status_code == self.ACK or self.fakemode:
if self.DEBUG:
self.logger.debug('Ack OK !')
self.sent_values = copy.copy(self.values)
self.__sent_values = copy.copy(self.__values)
break
else:
self.logger.warning("Ack KO !")
@@ -141,26 +199,26 @@ def sendValues(self):
return self.getLastStatus()
def init(self):
return self.command(BPi_Cmd.INIT)
return self.serial.command(BPi_Cmd.INIT)
# Pause
def pause(self):
return self.command(BPi_Cmd.PAUSE)
return self.serial.command(BPi_Cmd.PAUSE)
# Resume
def resume(self):
return self.command(BPi_Cmd.RESUME)
return self.serial.command(BPi_Cmd.RESUME)
# Set to 0 all consigne
def clear(self):
if self.command(BPi_Cmd.CLEAR) == self.ACK:
for i in xrange(0, self.COUNT):
self.sent_values[i] = 0
self.__sent_values[i] = 0
def setValue(self, index, value):
#if type(value) == types.IntType:
# value = chr(value)
self.values[index] = value
self.__values[index] = value
def setValues(self, servos, values):
v = 0
@@ -169,9 +227,11 @@ def setValues(self, servos, values):
self.setValue(i, values[v])
v += 1
def dump(self):
self.logger.debug('Buff values: %s' % self.values)
self.logger.debug('Sent values: %s' % self.sent_values)
#print 'Buff values:', self.values
#print 'Sent values:', self.sent_values
def getValues(self):
return self.__sent_values
def dump(self, allval = False):
self.logger.debug('Sent values: %s' % self.__sent_values)
if allval:
self.logger.debug('Buff values: %s' % self.__values)
Oops, something went wrong.

0 comments on commit 823f96e

Please sign in to comment.