Solar Array and home energy dashboard.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

49 lines
1.2 KiB

  1. // Interface for testing, provides testing data, and dynamic updates, etc.
  2. //jquery
  3. #include "jquery.js"
  4. //highcharts
  5. #include "highcharts.js"
  6. // WebSocket emulation class for testing
  7. function WebSocketTest(actions) {
  8. this.actions = actions.slice(); // copy
  9. this.actions.reverse()
  10. this.processNextItem()
  11. }
  12. // WebSocketTest.prototype.send = function ()
  13. // WebSocketTest.prototype.close = function ()
  14. // Internal
  15. WebSocketTest.prototype.processNextItem = function () {
  16. var item = this.actions.pop()
  17. var wst = this;
  18. setTimeout(function() {
  19. item[1](wst);
  20. wst.processNextItem();
  21. }, item[0]);
  22. return this;
  23. }
  24. // Setup the socket that will be used
  25. var socket = new WebSocketTest([
  26. [ 10, function(a) { a.onopen(new Object()) } ],
  27. [ 10, function(a) { a.onmessage(new MessageEvent('websockettest', {
  28. data : 'p .123'
  29. })) } ],
  30. [ 10, function(a) { a.onmessage(new MessageEvent('websockettest', {
  31. data : 'ng .758'
  32. })) } ],
  33. [ 2000, function(a) { a.onmessage(new MessageEvent('websockettest', {
  34. data : 'p .234'
  35. })) } ],
  36. [ 10, function(a) { a.onmessage(new MessageEvent('websockettest', {
  37. data : 'ng .584'
  38. })) } ],
  39. ]);
  40. #include "solardash.base.js"