利用cwinstr.ocx操作GPIB设备

By admin at 16 天前 • 0人收藏 • 114人看过

image.png

import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=434;bottom=234)
winform.add(
button={cls="button";text="about";left=6;top=207;right=88;bottom=233;z=1}
)
/*}}*/

import console
console.open()

/* 一些常量
CWParsePatternType={
	cwNumberParser=0;
	cwUserDefined=1
};

CWGPIBTimeoutValues={
	cwGPIBTimeoutTNone=0;
	cwGPIBTimeoutT30ms=8;
	cwGPIBTimeoutT30us=2;
	cwGPIBTimeoutT10ms=7;
	cwGPIBTimeoutT10us=1;
	cwGPIBTimeoutT300ms=10;
	cwGPIBTimeoutT300us=4;
	cwGPIBTimeoutT3ms=6;
	cwGPIBTimeoutT100s=15;
	cwGPIBTimeoutT100us=3;
	cwGPIBTimeoutT1ms=5;
	cwGPIBTimeoutT100ms=9;
	cwGPIBTimeoutT3s=12;
	cwGPIBTimeoutT10s=13;
	cwGPIBTimeoutT1s=11;
	cwGPIBTimeoutT30s=14
};

CWGPIBNotifyMask={
	cwGPIBCMPL=256;
	cwGPIBEND=8192;
	cwGPIBTIMO=16384;
	cwGPIBNone=0;
	cwGPIBRQS=2048
};

*/


var gpibObj = com.CreateObject("CWInstrumentControlLib.CWGPIB.1");
//只读
console.log( gpibObj.DeviceID );
//
gpibObj.Reset();
//gpibObj.Stop();
//gpibObj.Trigger();
//console.log( gpibObj.Wait(0) );
//gpibObj.Write( "*IDN?" );
//gpibObj.WriteAsync( "*IDN?" );
//gpibObj.WriteFromFile( "C:\Users\Administrator\Desktop\gpib\demo.txt" );
console.log( gpibObj.Unaddressing );
gpibObj.setTimeoutValue(11);
console.dump( gpibObj.Tasks );
console.log( gpibObj.SwapBytes );
gpibObj.setSwapBytes(true);
//console.log( gpibObj.SerialPoll() );
//gpibObj.ReadToFile("C:\Users\Administrator\Desktop\gpib\cc.txt");
//console.log( gpibObj.ReadAsync(100) );//同步读
//console.log( gpibObj.Read(100) ); 
gpibObj.setPrimaryAddress(1);
console.log( gpibObj.PrimaryAddress );
console.log( gpibObj.SecondaryAddress );
 
//gpibObj.ParallelPollConfig(5); 
//console.log( gpibObj.ParallelPoll() );
gpibObj.setNotifyMask(0);
console.log( gpibObj.getNotifyMask() );
//gpibObj.Notify()
//gpibObj.GotoLocal();
//console.log( gpibObj.IsOnline() )
//gpibObj.ExportStyle("C:\Users\Administrator\Desktop\gpib\aa.txt");
//gpibObj.ImportStyle("C:\Users\Administrator\Desktop\gpib\aa.txt"); 
gpibObj.setExceptionOnError(true);
gpibObj.setEOTMode(true);
gpibObj.setEOSEndsRead(true);
gpibObj.setEOSChar('\r\n');
gpibObj.setEOIWithEOS(true);
gpibObj.setDefaultBufferSize(5000);
console.log( gpibObj.DefaultBufferSize );
gpibObj.setDataAsString(true);
console.log(gpibObj.DataAsString)
//gpibObj.setBoardNumber(1);
//gpibObj.Configure()
gpibObj.setCompare8Bits(false);
console.log(gpibObj.Compare8Bits)
//gpibObj.Clear();

console.log( gpibObj.BytesWritten ); 
//gpibObj.ChangePrimaryAddress(0);
//gpibObj.ChangeSecondaryAddress(1);

winform.button.oncommand = function(id,event){
	gpibObj.AboutBox()
}

winform.show();
win.loopMessage();

以上, 被//注释掉的, 都是需要你电脑上有GPIB设备的情况下才能调用的.

cwinstr.zip


可能会用到的一些系统dll和H头文件

gpib-32.zip


登录后方可回帖

登 录
信息栏
本站永久域名:HtmLayout.Cn
纯私人站,当笔记本用的,学到哪写到哪,目前正在学aardio+halcon机器视觉.
Sciter中文在线文档Sciter在线学习文档
本 站 主 站:Stm32cube中文网
Aardio 官方站:Aardio官方
Aardio最新功能:Aardio官方更新日志
aardio在线手册Aardio在线手册
C大Aardio论坛:Aar爱好者论坛
简码教程网:简码编程
AARDIO语言QQ群:70517368
赞助商:才仁机械
下载站:非凡软件站
Loading...