instrument-com
Support many methods to communication with instrument through ethernet or usb
Now it only support GWINSTE's GDS2000E series
Example
You can direct use known port and ip to create a new instance
var dsoDriver = ; // create a new instance and bind to ethernet interface with ip:172.16.5.68 and port:3000var dsoCtrl=dsoDriver; // connect to instrument , connect must be done before any operation.dsoCtrl;
Or you can browse which one you want to
var dsoDriver = ;var dsoCtrl i len ; /* * .showNetDevice use mdsn to browse available device * @return (Array Object) [ { name, port, addr } , ...] */var deviceList = dsoDriver;len = deviceListlengthfor i = 0; i < len; i += 1 ifdeviceListiname === 'GDS2102E-01' dsoCtrl = deviceList; break; ifdsoCtrl === undefined console; process; dsoCtrl;
API
Show avaiable device
Find all instrument-dso service using mdns. When DSO socket server on, you can use showNetDevice() to count available DSO, and showNetDevice() will return an array object that store dso's name, port and ip like this
name:'GDS2102E-01'port:'3000' addr:'172.16.5.111' name:'GDS2102E-02'port:'3000' addr:'172.16.5.112'
Create new instance via Ethernet
Use DsoNet( port, address ) to create a new instance that contains many methods to control remote DSO via ethernet. Remote DSO has a port and ip address to identify it self, use unique port and ip address to pass to DsoNet() and DsoNet() will return an object to control that remote DSO
var dsoCtrl=dsoDriver;console;
Create new instance via USB
You can use one of DsoNet() or dsoUSB() to create a new instance but can't use both.
Methods
When dsoCtrl object was created, you can use many methods to control device.
- .connect( )
- .disconnect( )
- .syncConfig( )
- .enableCh( ch )
- .disableCh( ch )
- .getHorizontal( )
- .setHorizontal( hor )
- .getVertical( ch )
- .setVertical( ch )
- .getEdgeTrig( )
- .setEdgeTrig( )
- .getSnapshot( )
- .getRawdata( ch )
- .getMeas( mch )
- .supportedMeasType( )
- .setMeas( { mch, src1, src2, type } )
- .statisticOn( )
- .statisticOff( )
- .statisticWeight( weight )
- .run( )
- .stop( )
- .single( )
- .autoset( )
- .force( )
- .closeDev( )
.connect
Connect to device, create a connection to the device, if return with no error, the other methods can be useed
// create a new instance and bind to ethernet interface with ip:172.16.5.68 and port:3000var dsoCtrl=dsoDriver; // connect to instrument , connect must be done before any operation.dsoCtrl ;
.disconnect
Disconnect from device, if nothing else to do, disconnect from the device.
dsoCtrl;
.syncConfig
.enableCh
Turn remote DSO's channel on
//turn channel 1 ondsoCtrl ;
.disableCh
Turn remote DSO's channel off
//turn channel 1 offdsoCtrl ;
.getHorizontal
Return current remote DSO's horizontal system setting
dsoCtrl ;
Console displayed infomation
temp: 0 position: '0.000E+00' zposition: '0.000E+00' scale: '1.000000e-04' zscale: '1.000E-05' mode: 'MAIN' expand: 'CENTER' prop: get: Function set: Function
The meaning of the return object
- temp: never mind
- position: offset of the waveform trace in time axis
- scale: a waveform trace can be cut into 10 block, the scale is the time of a block
- zscale: never mind
- mode: nerver mind
- expand: never mind
- prop: never mind
.setHorizontal
setHorizontal( hor ), setup remote DSO's horizontal system, hor is an object that include position,zposition,scale,zscale,mode,expand. Those parameter have some limitation.
You can pass parameter only you care
dsoCtrl ;
We set the position to 200us and set the scale to 200us
.getVertical
Return current remote DSO's vertical system setting
dsoCtrl ;
Console displayed infomation
coupling: 'DC' impedance: '1E+6' invert: 'OFF' bandwidth: 'FULL' expand: 'GND' state: 'ON' scale: '1.000E-01' position: '0.000E+00' deskew: '0.000e+00' rawdata: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 60 00 00 03 01 00 00 00 78 00 00 03 01 00 00 00 90 00 00 03 01 00 00 00 01 00 00 00 00 00 00 00 ff ff ... > raw_state: '0' probe: unit: 'VOLTAGE' atten: '1.000000e+00' dataCount: 0 recCount: 0 id: 'ch1' prop: get: Function set: Function
.setVertical
Setup remote DSO's vertical system
.getEdgeTrig
Retrun current remote DSO's edge trigger setting
.setEdgeTrig
Setup remote DSO's edge trigger
.getSnaphot
Return an RLE buffer that store screen data displayed on remote DSO
dsoCtrl ;
.getRawdata
Return sampled value, each two int8 bytes encodes the vertical data of a data point, and store in big endian format
.getMeas
Return measurement value for selected measurement source
.supportedMeasType
Return suppoted measurement type
.setMeas
Setup measurement type for selected measurement source
.statisticOn
Turn statistic measure on for all measurement source
.statisticOff
Turn statistic measure off for all measurement source
.statisticWeight
Setup statistic weighting
.run
Turn remote DSO into run state
.stop
Turn remote DSO into stop state
.single
Turn remote DSO into single state
.autoset
Turn remote DSO into autoset state
.force
Turn remote DSO into force state
.closeDev
Close opened device
Error Message
You can use promise catch method to catch error message
dsoCtrl
Console displayed information
'-500' '\'-1e+7\' argument does not accept, set to near one -5.000E+01\n'
Array[0] show error type
- -100 : Parameter Error
- -200 : Execution Error
- -300 : Device-specific Error
- -400 : Query Error
- -500 : Parameter Not Accept
Array[1] show error message