全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:3045
推到 Plurk!
推到 Facebook!

BCB寫儀器介面 支援API函式

尚未結案
zxcvb8057
一般會員


發表:6
回覆:3
積分:1
註冊:2011-09-12

發送簡訊給我
#1 引用回覆 回覆 發表時間:2012-01-04 16:47:59 IP:163.21.xxx.xxx 訂閱

各位高手前輩 我有個震動分析儀器 需要使用BCB 寫介面
廠商說有支援 API 函式庫 給我範例 範例如下

我是使用BCB2007 我一樣在 檔案> 選 VCL Forms Application C builder 開始嗎?
然後 將這些語法PO在宣告那嗎?
我是知道 要把宣告物件 增加進來 都擺到同資料夾
但是都會出現 BUG 請問是我操作哪步驟不對了
拜託大家 指導指導 感謝

#include
#ifdef _WIN32
#include
#include
#else
#include
#include
#endif
#include "siosifmdll.h"

#ifndef _WIN32
// in Linux there is no kbhit() function, we create one
int kbhit(void) {
struct termios term, oterm;
int fd = 0;
int c = 0;
tcgetattr(fd, &oterm);
memcpy(&term, &oterm, sizeof(term));
term.c_lflag = term.c_lflag & (!ICANON);
term.c_cc[VMIN] = 0;
term.c_cc[VTIME] = 1;
tcsetattr(fd, TCSANOW, &term);
c = getchar();
tcsetattr(fd, TCSANOW, &oterm);
if (c != -1)
ungetc(c, stdin);
return ((c != -1) ? 1 : 0);
}
#endif
int main(int argc, char *argv[])
{
int error=0;
// before IfmInit; make some settings
// IFM_OPTION_DEBUGFILES let the DLL create files with information for debug purposes
IfmSetOption(IFM_OPTION_DEBUGFILES, false);

// first initialize the DLL
error=IfmInit();
if(error){
printf("Error %d during IfmInit\n",error);
return(1);
}
// search for connected devices; returns the number of via USB connected devices
int cnt;
cnt=IfmSearchUSBDevices();
if(cnt<=0){
printf("A SIOS interferometer could not be found\n");
IfmClose();
return(0);
}
// now let us show the connected devices
// in a GUI this can be used to fill a comboBox for selecting the device
printf("\nThe following RE-10 cards are connected to the PC:\n");
int i;
for(i=0;i printf("card no. %d with serial %6.6d\n",i,IfmUSBDeviceSerial(i));
}
printf("\n");
int devNo;
// we open the first device;
// IfmUSBDeviceSerial and IfmOpenUSB takes a parameter for selecting the
// device from 0 to cnt-1
printf("Open device with serial number %d\n",IfmUSBDeviceSerial(0));
devNo=IfmOpenUSB(0);
if(devNo>0){
printf("Error during opening the device.\n");
IfmClose();
return(0);
}
// Alternatively, if the COM-Interface is known the device can also be opened directly
// Windows: devNo=IfmOpenCom(1); for COM1
// Unix: devNo=IfmOpenCom("/dev/ttyACM0"); for the first device
// IfmOpenUSB has returned a number (devNo) which describes the device in further calls
// to the DLL.
// now we configure the measurement, at least with SetMeasurement
// we want the length values of the first channel with 0.5 Hz output rate
// IFM_MEAS_FILTER_DEFAULT will create an internal filter which removes the
// vibration of the reference mirror from the signal
// in some applications IFM_MEAS_FILTER_NONE may be required for unfiltered output
// changed: 3 channels samplecounter
error=IfmSetMeasurement(devNo,IFM_MEAS_THREECHANNEL|IFM_MEAS_LENGTH|IFM_MEAS_FILTER_DEFAULT|IFM_MEAS_SAMPLECOUNT,0.5);
if(error>0){
printf("Error during opening the device.\n");
IfmClose();
return(0);
}
// Set the length values to zero; assuming the measurement mirror is at the reference/zero position
// error=IfmSetToZero(devNo,0x0F);
printf("Printing length data until a key is pressed\n\n");
// begin with the output of data
error=IfmStart(devNo);
if(error>0){
printf("Error during start output.\n");
IfmClose();
return(0);
}
while(!kbhit()){
// are new values available?
if(IfmValueCount(devNo)){
// put the value in an internal buffer for access via IfmLengthValue
// this is necessary to access the same syncronuously sampled values (e.g. different channels) at different times
// IfmValueCount is decremented
IfmGetValues(devNo);
// get the value together with environmental values
printf(".0lf nm .0lf nm .0lf nm - %.2f C %.0f Pa - sample %d \r",
IfmLengthValue(devNo,0),IfmLengthValue(devNo,1),IfmLengthValue(devNo,2),
IfmTemperature(devNo,0),IfmAirPressure(devNo,0),IfmAuxValue(devNo,0,IFM_VALUETYPE_SAMPLECOUNT));
}
}
//deinitialize
// stop the output of data
IfmStop(devNo);
// close the device; devNo will be no longer valid
IfmCloseDevice(devNo);
// close the DLL
IfmClose();
}
附加檔案:4f04123fad0a5_siosifm.pdf
系統時間:2024-03-28 23:19:54
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!