问题描述
我想在高电平电压上设置触发抓取。 目前,所有输入电压都按预期到达采集器。触发设置如下:
//set triggering source
MdigControl(digitizer,M_GRAB_TRIGGER_SOURCE,M_AUX_IO0);
//enable triggering
MdigControl(digitizer,M_GRAB_TRIGGER_STATE,M_ENABLE);
//use high voltage to trigger
MdigControl(digitizer,M_GRAB_TRIGGER_ACTIVATION,M_LEVEL_HIGH);
还有两个这样连接的事件:
MdigHookFunction(digitizer,M_GRAB_FRAME_START,onStart,&hookData);
MdigHookFunction(digitizer,M_GRAB_FRAME_END,onEnd,&hookData);
如果事件被触发,onStart() 将简单地打印出“Start”,onEnd() 的行为类似。抓取逻辑如下:
MdigProcess(digitizer,&grabBufs[0][0],BUFFERING_SIZE_MAX * NUM_OF_GRAB_BUF,M_START,M_DEFAULT,ProcessingFunction,&UserHookData);
MosGetch();
/* Stop the processing. */
MdigProcess(digitizer,BUFFERING_SIZE_MAX,M_STOP,&UserHookData);
问题是在触发信号出现或消失后,onStart()/onEnd()/ProcessingFunction() 都没有给出任何输出消息。
你能告诉我让它正常工作吗?
我的完整代码:
#include <mil.h>
#include <memory>
#include <iostream>
#include <string>
//onpaged memory
#define BOARD_NAME M_SYstem_SOLIOS
/* Number of images in the buffering grab queue.
Generally,increasing this number gives better real-time grab.
*/
#define NUM_OF_GRAB_BUF 1
#define BUFFERING_SIZE_MAX 1 //BUFFERING_SIZE_MAX * H
const std::string &IMAGE_DIR = "image_dir";
const std::string &MACHINE_SN = "machine_sn";
/* User's processing function prototype. */
MIL_INT MFTYPE onStart(MIL_INT HookType,MIL_ID HookId,void *HookDataPtr);
MIL_INT MFTYPE onEnd(MIL_INT HookType,void *HookDataPtr);
MIL_INT MFTYPE processFunc(MIL_INT hookType,MIL_ID hookId,void *hookDataPtr);
/* User's processing function hook data structure. */
typedef struct {
MIL_INT processedCount;
MIL_ID display;
} HookDataStruct;
/* Main function. */
/* ---------------*/
int main(int argc,char **argv) {
MIL_ID app;
MIL_ID system;
MIL_ID display;
MIL_ID digitizer = 0;
MIL_ID dispBuf;
MIL_ID grabBufs[NUM_OF_GRAB_BUF][BUFFERING_SIZE_MAX];
MIL_ID bigBuf[NUM_OF_GRAB_BUF];
//MIL_ID parentID;
MIL_INT sizeX;
MIL_INT sizeY;
MIL_INT bandSize;
MIL_INT grabChildBufs = 0;
MIL_INT grabBufsIdx = 0;
MIL_INT ProcessFrameCount = 0;
MIL_DOUBLE ProcessFrameRate = 0;
HookDataStruct hookData;
/* Allocate defaults. */
MappAllocDefault(M_DEFAULT,&app,&system,&display,&digitizer,M_NULL);
MdigHookFunction(digitizer,&hookData);
MdigHookFunction(digitizer,&hookData);
//set triggering source
MdigControl(digitizer,M_AUX_IO0);
//enable triggering
MdigControl(digitizer,M_ENABLE);
//use high voltage to trigger
MdigControl(digitizer,M_LEVEL_HIGH);
sizeX = MdigInquire(digitizer,M_SIZE_X,M_NULL);
sizeY = MdigInquire(digitizer,M_SIZE_Y,M_NULL);
bandSize = MdigInquire(digitizer,M_SIZE_BAND,M_NULL);
MdigControl(digitizer,M_GRAB_TRIGGER_SOFTWARE,1);
MbufAllocColor(system,bandSize,sizeX,sizeY * (BUFFERING_SIZE_MAX),MdigInquire(digitizer,M_TYPE,M_NULL),M_IMAGE + M_GRAB + M_disP,&dispBuf);
MbufClear(dispBuf,0xFF);
MdispSelect(display,dispBuf);
/* Allocate the grab buffers and clear them. */
for (grabBufsIdx = 0; grabBufsIdx < NUM_OF_GRAB_BUF; grabBufsIdx++) {
MbufAllocColor(system,M_IMAGE + M_GRAB,&bigBuf[grabBufsIdx]);
MbufClear(bigBuf[grabBufsIdx],0xFF);
for (grabChildBufs = 0; grabChildBufs < BUFFERING_SIZE_MAX; grabChildBufs++) {
MbufChild2d(bigBuf[grabBufsIdx],sizeY * grabChildBufs,sizeY,&grabBufs[grabBufsIdx][grabChildBufs]);
}
}
/* Initialize the User's processing function data structure. */
hookData.processedCount = 0;
hookData.display = dispBuf;
/* Print a message. */
MosPrintf(MIL_TEXT("\nMULTIPLE BUFFERED PROCESSING.\n"));
MosPrintf(MIL_TEXT("-----------------------------\n\n"));
MosPrintf(MIL_TEXT("Press <Enter> to start.\n\n"));
MosGetch();
/* Print a message and wait for a key after a minimum number of frames. */
MosPrintf(MIL_TEXT("Press <Enter> to stop.\n\n"));
MdigProcess(digitizer,processFunc,&hookData);
/* NOTE: Now the main() is free to do other tasks while the processing is executing. */
/* --------------------------------------------------------------------------------- */
MosGetch();
/* Stop the processing. */
MdigProcess(digitizer,&hookData);
/* Print statistics. */
MdigInquire(digitizer,M_PROCESS_FRAME_COUNT,&ProcessFrameCount);
MdigInquire(digitizer,M_PROCESS_FRAME_RATE,&ProcessFrameRate);
MosPrintf(MIL_TEXT("\n\n%ld frames grabbed at %.1f frames/sec (%.1f ms/frame).\n"),ProcessFrameCount,ProcessFrameRate,1000.0 / ProcessFrameRate);
MosPrintf(MIL_TEXT("Press <Enter> to end.\n\n"));
MosGetch();
/* Free the grab buffers. */
for (grabBufsIdx = 0; grabBufsIdx < NUM_OF_GRAB_BUF; grabBufsIdx++) {
for (grabChildBufs = 0; grabChildBufs < BUFFERING_SIZE_MAX; grabChildBufs++) {
MbufFree(grabBufs[grabBufsIdx][grabChildBufs]);
}
MbufFree(bigBuf[grabBufsIdx]);
}
/* Release defaults. */
MappFreeDefault(app,system,display,digitizer,dispBuf);
return 0;
}
MIL_INT MFTYPE onEnd(MIL_INT HookType,void *HookDataPtr) {
std::cout << "End" << std::endl;
return 0;
}
MIL_INT MFTYPE onStart(MIL_INT HookType,void *HookDataPtr) {
std::cout << "Start" << std::endl;
return 0;
}
MIL_INT MFTYPE processFunc(MIL_INT hookType,void *hookDataPtr) {
std::cout << "Processing" << std::endl;
return 0;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)