forked from 7m4mon/visa32test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (30 loc) · 865 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/************************************************************
NODE.JS INTERACTIVE IO
This is WEB interface for visa32test.js.
Author : 7M4MON
Date : 2015/04/24
Licence : MIT
************************************************************/
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var visa32test = require('./nisa32.js');
// visa32test.Visa32TestQuery('GPIB0::12::INSTR','*IDN?');
app.get('/',function(req,res){
res.sendFile('index.html');
});
var rcvMsg;
io.on('connection',function(socket){
socket.on('sendmsg',function(msg){
rcvMsg = visa32test.query(msg.addr,msg.cmd, function(err, result) {
if (err)
io.emit('recvmsg', err);
else
io.emit('recvmsg', result);
}
);
});
});
http.listen(3000,function(){
console.log('listen 3000 port');
});