Skip to content
Snippets Groups Projects
Commit 3631e65e authored by wactbprot's avatar wactbprot
Browse files

compl. add vol.

parent 5adc4a8e
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,20 @@ conf.mp = { server : "e73462.berlin.ptb.de"
, mpid : "mpd-se3-add_volume"
}
conf.url = {}
conf.url.pump_down = "http://"
+ conf.mp.server + ":"
+ conf.mp.port + "/"
+ conf.mp.mpid + "/0/ctrl";
conf.url.add_vol = "http://"
+ conf.mp.server + ":"
+ conf.mp.port + "/"
+ conf.mp.mpid + "/1/ctrl";
conf.profibus = { ip :"192.168.98.141"
, port: 502
, poll: 1000
......
......@@ -35,12 +35,11 @@ profibus.connect(conf.profibus.port, conf.profibus.ip, function() {
var hl = parseInt((screen.height /3 * 2) )
, wl = parseInt(screen.width / 3)
, proto = {
mouse: true,
border: "line",
items : item,
width : wl,
width : wl,
height : hl,
top:0,
style: {
......@@ -50,10 +49,10 @@ var hl = parseInt((screen.height /3 * 2) )
fg: "default",
bg: "default"
},
selected: {
bg: "green",
fg: "white"
}
selected: {
bg: "green",
fg: "white"
}
},
tags: true,
invertSelected: true
......@@ -100,54 +99,20 @@ box_pd.on("click", function(data){
screen.render();
var go = { method: "PUT",
port: conf.mp.port ,
host: conf.mp.server,
path: "/" + conf.mp.mpid + "/0/ctrl",
headers: {
"Content-Type" : "text/javascript"
}
}
var req = http.request(go);
req.write("run");
req.end();
port: conf.mp.port ,
host: conf.mp.server,
path: "/" + conf.mp.mpid + "/0/ctrl",
headers: {
"Content-Type" : "text/javascript"
}
}
var req = http.request(go);
req.write("run");
req.end();
});
setInterval( function(){
var url = "http://"
+ conf.mp.server + ":"
+ conf.mp.port + "/"
+ conf.mp.mpid + "/0/ctrl";
http.get(url, function(res) {
var body = "";
res.on("data", function(data){
body += data;
});
res.on("end", function() {
var nd = (new Date()).toTimeString().split(" ")[0]
, res = JSON.parse(body).result
, midstr = conf.ctrlstr[res];
midstr = midstr ? midstr : conf.changestr;
box_pd.setContent(conf.basestr_pd + "\n"
+ midstr+ "\n"
+ "{center}update: " + nd + "{/center}");
});
});
screen.title = conf.basestr_screen
+ " | profibus online: "
+ !profibus.destroyed // <-- request hält profibus (kunbus) wach
+ " | api server port: " + conf.api.port
screen.render();
}, conf.poll);
var box_av = blessed.box({
top: hl,
left: wb,
......@@ -160,6 +125,74 @@ var box_av = blessed.box({
}
});
box_av.on("click", function(data){
box_av.setContent("{center}start up ...{/center}")
screen.render();
var go = { method: "PUT",
port: conf.mp.port ,
host: conf.mp.server,
path: "/" + conf.mp.mpid + "/1/ctrl",
headers: {
"Content-Type" : "text/javascript"
}
}
var req = http.request(go);
req.write("run");
req.end();
});
setInterval( function(){
http.get(conf.url.pump_down, function(res) {
var body = "";
res.on("data", function(data){
body += data;
});
res.on("end", function() {
var nd = (new Date()).toTimeString().split(" ")[0]
, res = JSON.parse(body).result
, midstr = conf.ctrlstr[res];
midstr = midstr ? midstr : conf.changestr;
box_pd.setContent(conf.basestr_pd + "\n"
+ midstr+ "\n"
+ "{center}update: " + nd + "{/center}");
});
});
http.get(conf.url.add_vol, function(res) {
var body = "";
res.on("data", function(data){
body += data;
});
res.on("end", function() {
var nd = (new Date()).toTimeString().split(" ")[0]
, res = JSON.parse(body).result
, midstr = conf.ctrlstr[res];
midstr = midstr ? midstr : conf.changestr;
box_av.setContent(conf.basestr_av + "\n"
+ midstr+ "\n"
+ "{center}update: " + nd + "{/center}");
});
});
screen.title = conf.basestr_screen
+ " | profibus online: "
+ !profibus.destroyed // <-- request hält profibus (kunbus) wach
+ " | api server port: " + conf.api.port
screen.render();
}, conf.poll);
screen.append(box_pd);
screen.append(box_av);
......@@ -167,26 +200,26 @@ screen.render();
server.get("/pressure_max", function(req, res, next){
var a = conf.items[bla.selected];
var b = conf.items[blb.selected];
var c = conf.items[blc.selected];
var ret = {
"Pressure_max_dut_a": JSON.parse(JSON.stringify(
_.extend( { Caption: "Maximum pressure for branch dut-a",
Type: "dut_max_a"}, a.exchange)
)),
"Pressure_max_dut_b": JSON.parse(JSON.stringify(
_.extend({ Caption: "Maximum pressure for branch dut-b",
Type: "dut_max_b"}, b.exchange)
)),
"Pressure_max_dut_c": JSON.parse(JSON.stringify(
_.extend({ Caption: "Maximum pressure for branch dut-c",
Type: "dut_max_c"}, c.exchange)
))
}
res.send(ret);
next();
var a = conf.items[bla.selected];
var b = conf.items[blb.selected];
var c = conf.items[blc.selected];
var ret = {
"Pressure_max_dut_a": JSON.parse(JSON.stringify(
_.extend( { Caption: "Maximum pressure for branch dut-a",
Type: "dut_max_a"}, a.exchange)
)),
"Pressure_max_dut_b": JSON.parse(JSON.stringify(
_.extend({ Caption: "Maximum pressure for branch dut-b",
Type: "dut_max_b"}, b.exchange)
)),
"Pressure_max_dut_c": JSON.parse(JSON.stringify(
_.extend({ Caption: "Maximum pressure for branch dut-c",
Type: "dut_max_c"}, c.exchange)
))
}
res.send(ret);
next();
});
......@@ -198,5 +231,5 @@ server.listen(conf.api.port, function() {
// bind end key
screen.key(["escape", "q"], function(ch, key) {
return process.exit(0);
return process.exit(0);
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment