Skip to content
Snippets Groups Projects
Commit 308c6711 authored by Thomas's avatar Thomas
Browse files

http api: max_dut

parent bfe7dfc3
Branches
No related tags found
No related merge requests found
var blessed = require("blessed") var blessed = require("blessed")
, _ = require("underscore") , _ = require("underscore")
, restify = require("restify")
, pj = require("./package.json") , pj = require("./package.json")
, screen = blessed.screen({ , screen = blessed.screen({
smartCSR: true smartCSR: true
}) })
, item = [ , items = [
"empty" {"display": "empty" ,"exchange":{"Value":null, "Unit":"mbar"}}
, "SRG" , {"display":"SRG" ,"exchange":{"Value":2e-2, "Unit":"mbar"}}
, "0.1T CDG" , {"display":"0.1T CDG" ,"exchange":{"Value":0.133, "Unit":"mbar"}}
, "0.25T CDG" , {"display":"0.25T CDG" ,"exchange":{"Value":0.333, "Unit":"mbar"}}
, "1T CDG" , {"display":"1T CDG" ,"exchange":{"Value":1.333, "Unit":"mbar"}}
, "10T CDG" , {"display":"10T CDG" ,"exchange":{"Value":13.33, "Unit":"mbar"}}
, "100T CDG" , {"display":"100T CDG" ,"exchange":{"Value":133.3, "Unit":"mbar"}}
, "1000T CDG" , {"display":"1000T CDG" ,"exchange":{"Value":1333.2, "Unit":"mbar"}}
, "0.1mbar CDG" , {"display":"0.1mbar CDG" ,"exchange":{"Value":0.1, "Unit":"mbar"}}
, "1mbar CDG" , {"display":"1mbar CDG" ,"exchange":{"Value":1, "Unit":"mbar"}}
, "10mbar CDG" , {"display":"10mbar CDG" ,"exchange":{"Value":10, "Unit":"mbar"}}
, "100mbar CDG" , {"display":"100mbar CDG" ,"exchange":{"Value":100, "Unit":"mbar"}}
, "1000mbar CDG" , {"display":"1000mbar CDG" ,"exchange":{"Value":1000, "Unit":"mbar"}}
] ]
, item = [];
for ( var k=0; k < items.length; k++) {
item.push(items[k].display)
}
screen.title = pj.name +" version: " + pj.version + " (q: quit)"; screen.title = pj.name +" version: " + pj.version + " (q: quit)";
var server = restify.createServer({name: "dut_branches"})
server.pre(restify.pre.sanitizePath());
server.use(restify.queryParser());
server.use(restify.bodyParser());
server.use(function crossOrigin(req,res,next){
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
return next();
});
server.get("/max_dut", function(req, res, next){
var a = items[bla.selected];
var b = items[blb.selected];
var c = items[blc.selected];
var ret = { "Dut_A":a.exchange
, "Dut_B":b.exchange
, "Dut_C":c.exchange
}
res.send(ret);
next();
});
var hl = parseInt((screen.height /3 * 2) )
, wl = parseInt(screen.width / 3)
, hb = parseInt((screen.height /3 ) )
, wb = parseInt(screen.width / 2)
var proto = { var proto = {
mouse: true, mouse: true,
border: 'line', border: 'line',
items : item, items : item,
width : parseInt(screen.width / 3), width : wl,
height : parseInt((screen.height) ), height : hl,
top:0, top:0,
style: { style: {
fg: 'green', fg: 'green',
...@@ -41,9 +75,8 @@ var proto = { ...@@ -41,9 +75,8 @@ var proto = {
fg: 'white' fg: 'white'
} }
}, },
tags: true, tags: true,
invertSelected: false invertSelected: true
} }
...@@ -51,31 +84,66 @@ var proto = { ...@@ -51,31 +84,66 @@ var proto = {
var lsta = JSON.parse(JSON.stringify(proto)); var lsta = JSON.parse(JSON.stringify(proto));
lsta.label = ' dut-a ', lsta.label = ' dut-a ',
lsta.left = 0 * proto.width; lsta.left = 0 * proto.width;
screen.append(blessed.list(lsta));
var bla = blessed.list(lsta)
screen.append(bla);
var lstb = JSON.parse(JSON.stringify(proto)); var lstb = JSON.parse(JSON.stringify(proto));
lstb.label = ' dut-b ', lstb.label = ' dut-b ',
lstb.left = 1 * proto.width; lstb.left = 1 * proto.width;
screen.append(blessed.list(lstb));
var blb = blessed.list(lstb)
screen.append(blb);
var lstc = JSON.parse(JSON.stringify(proto)); var lstc = JSON.parse(JSON.stringify(proto));
lstc.label = ' dut-c ', lstc.label = ' dut-c ',
lstc.left = 2 * proto.width; lstc.left = 2 * proto.width;
screen.append(blessed.list(lstc)); var blc = blessed.list(lstc)
screen.append(blc);
// var lst2 = JSON.parse(JSON.stringify(protolst)) var box_pd = blessed.box({
// lst1.left = 1 * protolst.width; top: hl,
// left: 0,
// var lst3 = JSON.parse(JSON.stringify(protolst)) width: wb,
// lst1.left = 2 * protolst.width; height: hb,
// content: '{center}pump down{/center}',
tags: true,
border: {
type: 'line'
}
});
var box_av = blessed.box({
top: hl,
left: wb,
width: wb,
height: hb,
content: '{center}measure aditional volume{/center}',
tags: true,
border: {
type: 'line'
}
});
// screen.append(lst2); screen.append(box_pd);
// screen.append(lst3); screen.append(box_av);
//
screen.render(); screen.render();
// bind end key // bind end key
screen.key(["escape", "q"], function(ch, key) { screen.key(["escape", "q"], function(ch, key) {
return process.exit(0); return process.exit(0);
}); });
server.listen(9002, function() {
screen.title = pj.name +" version: " + pj.version + " (q: quit)| server running @port 9002";
screen.render();
});
\ No newline at end of file
{ {
"name": "bc", "name": "bc",
"version": "1.0.0", "version": "1.1.0",
"description": "dut (device under test) branches config by touch screen", "description": "dut (device under test) branches config by touch screen",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"dependencies":{ "dependencies": {
"blessed": ">=0.1.81", "blessed": ">=0.1.81",
"underscore": ">=1.8.3", "request": ">=2.81.0",
"request": ">=2.81.0" "restify": "^4.3.0",
"underscore": ">=1.8.3"
}, },
"author": "wactbprot@gmail.com", "author": "wactbprot@gmail.com",
"license": "BSD" "license": "BSD"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment