started updates

This commit is contained in:
john30
2015-06-07 19:14:27 +02:00
parent 591b839358
commit 47322dcd25
2 changed files with 24 additions and 17 deletions
+10 -3
View File
@@ -116,7 +116,7 @@ jsPlumb.ready(function() {
connection.getOverlay("label").setLabel(connection.endpoints[0].getParameter('name')); connection.getOverlay("label").setLabel(connection.endpoints[0].getParameter('name'));
}; };
var addEndpoints = function(divId, anchors, needConnections) { var addEndpoints = function(divId, anchors, needConnections, needUpdates) {
for (var i = 0; i < anchors.length; i++) { for (var i = 0; i < anchors.length; i++) {
var anchor = anchors[i]; var anchor = anchors[i];
var anchUUID = divId + anchor.name; var anchUUID = divId + anchor.name;
@@ -136,10 +136,15 @@ jsPlumb.ready(function() {
if (anchor.hasOwnProperty('connectWith') && needConnections) { if (anchor.hasOwnProperty('connectWith') && needConnections) {
needConnections.push(new Array(anchUUID).concat(anchor.connectWith)); // to-circuit, to-endpoint[, item-circuit, item-name[, item-parts]] needConnections.push(new Array(anchUUID).concat(anchor.connectWith)); // to-circuit, to-endpoint[, item-circuit, item-name[, item-parts]]
} }
instance.addEndpoint(divId, endpoint, { var endp = instance.addEndpoint(divId, endpoint, {
anchor: anchor.anchor, uuid: anchUUID, anchor: anchor.anchor, uuid: anchUUID,
parameters:{name:anchor.name, priority:anchor.priority} parameters:{name:anchor.name, priority:anchor.priority}
}); });
if (anchor.hasOwnProperty('update') && needUpdates) {
var update = anchor.update;
update.endpoint = endp;
needUpdates.push(update);
}
} }
}; };
@@ -399,8 +404,9 @@ jsPlumb.ready(function() {
} }
// add endpoints // add endpoints
var needConnections = new Array(); var needConnections = new Array();
var needUpdates = new Array();
for (var i=0; i<needEndpoints.length; i++) { for (var i=0; i<needEndpoints.length; i++) {
addEndpoints(needEndpoints[i].name, needEndpoints[i].endpoints, needConnections); addEndpoints(needEndpoints[i].name, needEndpoints[i].endpoints, needConnections, needUpdates);
} }
// establish connections // establish connections
var connectionItems = new Array(); var connectionItems = new Array();
@@ -454,6 +460,7 @@ jsPlumb.ready(function() {
} }
} }
} }
// TODO needUpdates
// request all shown values and enable automatic polling // request all shown values and enable automatic polling
for (var i=0; i<needUris.length; i++) { for (var i=0; i<needUris.length; i++) {
new Ajax.Request('/data/'+needUris[i]+'?exact&poll=2',{ new Ajax.Request('/data/'+needUris[i]+'?exact&poll=2',{
+14 -14
View File
@@ -20,12 +20,12 @@
"image": "valve.svg", "image": "valve.svg",
"endpoints": [ "endpoints": [
{"name": "Flow", "anchor": "Top", "target": true, "connectWith": ["ehp", "HcFlow", "ehp", "FlowTemp", "0"]}, {"name": "Flow", "anchor": "Top", "target": true, "connectWith": ["ehp", "HcFlow", "ehp", "FlowTemp", "0"]},
{"name": "HwcFlow", "anchor": "Right", "connectWith": ["storage", "HwcInput"], "updates": [ {"name": "HwcFlow", "anchor": "Right", "connectWith": ["storage", "HwcInput"], "update":
{"type": ["hot", "off"], "condition": [["ehp", "Hc1Pump", "on"], ["ehp", "HwcHcValve", "on"]]} {"type": ["hot", "off"], "condition": [["ehp", "Hc1Pump", "on"], ["ehp", "HwcHcValve", "on"]]}
]}, },
{"name": "HcFlow", "anchor": "Left", "connectWith": ["storage", "HcInput", "ehp", "HcFlowTemp", "0"], "updates": [ {"name": "HcFlow", "anchor": "Left", "connectWith": ["storage", "HcInput", "ehp", "HcFlowTemp", "0"], "update":
{"type": ["cold", "off"], "condition": [["ehp", "Hc1Pump", "on"], ["ehp", "HwcHcValve", "off"]]} {"type": ["cold", "off"], "condition": [["ehp", "Hc1Pump", "on"], ["ehp", "HwcHcValve", "off"]]}
]} }
], ],
"items": [ "items": [
{"circuit": "ehp", "name": "HwcHcValve", "topc": 0.5, "leftc": 0.5} {"circuit": "ehp", "name": "HwcHcValve", "topc": 0.5, "leftc": 0.5}
@@ -88,21 +88,21 @@
} }
], ],
"endpoints": [ "endpoints": [
{"name": "SourceOutput", "anchor": [0.12, 0, 0, -1], "label": "Source", "updates": [ {"name": "SourceOutput", "anchor": [0.12, 0, 0, -1], "label": "Source", "update":
{"type": ["cold", "off"], "condition": [["ehp", "Source", "on"]]} {"type": ["cold", "off"], "condition": [["ehp", "Source", "on"]]}
]}, },
{"name": "SourceInput", "anchor": [0.22, 0, 0, -1], "target": true, "label": "Source", "distance": [0,60], "updates": [ {"name": "SourceInput", "anchor": [0.22, 0, 0, -1], "target": true, "label": "Source", "distance": [0,60], "update":
{"type": ["hot", "off"], "condition": [["ehp", "Source", "on"]]} {"type": ["hot", "off"], "condition": [["ehp", "Source", "on"]]}
]}, },
{"name": "HwcReturn", "anchor": [0.53, 0, 0, -1], "target": true, "distance": [0,80,0.3], "connectWith": ["storage", "HwcOutput"], "updates": [ {"name": "HwcReturn", "anchor": [0.53, 0, 0, -1], "target": true, "distance": [0,80,0.3], "connectWith": ["storage", "HwcOutput"], "update":
{"type": ["hot", "off"], "condition": [["ehp", "Hc1Pump", "on"], ["ehp", "HwcHcValve", "on"]]} {"type": ["hot", "off"], "condition": [["ehp", "Hc1Pump", "on"], ["ehp", "HwcHcValve", "on"]]}
]}, },
{"name": "HcReturn", "anchor": [0.78, 0, 0, -1], "target": true, "distance": [0,60,0.42], "connectWith": ["storage", "HcOutput", "ehp", "HcReturnTemp", "0"], "updates": [ {"name": "HcReturn", "anchor": [0.78, 0, 0, -1], "target": true, "distance": [0,60,0.42], "connectWith": ["storage", "HcOutput", "ehp", "HcReturnTemp", "0"], "update":
{"type": ["cold", "off"], "condition": [["ehp", "Hc1Pump", "on"], ["ehp", "HwcHcValve", "off"]]} {"type": ["cold", "off"], "condition": [["ehp", "Hc1Pump", "on"], ["ehp", "HwcHcValve", "off"]]}
]}, },
{"name": "HcFlow", "anchor": [0.88, 0, 0, -1], "priority": 1, "updates": [ {"name": "HcFlow", "anchor": [0.88, 0, 0, -1], "priority": 1, "update":
{"type": ["hot", "off"], "condition": [["ehp", "Hc1Pump", "on"]]} {"type": ["hot", "off"], "condition": [["ehp", "Hc1Pump", "on"]]}
]} }
], ],
"items": [ "items": [
{"name": "SourcePress", "parts": "0", "topc": 0.2, "left": 0.01}, {"name": "SourcePress", "parts": "0", "topc": 0.2, "left": 0.01},