?? milapp.cpp
字號:
#include "stdafx.h"
#include "MilApp.h"
#include "mil.h"
MIL_ID MilApplication;
MIL_ID MilSystem;
MIL_ID MilDigitizer;
MIL_ID MilDisplay;
MIL_ID MilImage;
char *ReadBuffer=NULL;
long ReadSize;
bool MilCreate()
{
MappAllocDefault(M_SETUP,&MilApplication,&MilSystem,&MilDisplay,&MilDigitizer,M_NULL);
long g_BufSizeX= (unsigned int) MdigInquire(MilDigitizer, M_SIZE_X, M_NULL);
long g_BufSizeY= (unsigned int) MdigInquire(MilDigitizer, M_SIZE_Y, M_NULL);
MbufAlloc2d(MilSystem,
g_BufSizeX,
g_BufSizeY,
8+M_UNSIGNED,
M_IMAGE+M_DISP+M_GRAB+M_PROC,
&MilImage);
MbufClear(MilImage, 0);
//與例子的不同在于我直接設置了數,而例子是宏定義變量
MsysControl(MilSystem,M_UART_DATA_LENGTH,8);//定義數據長度
MsysControl(MilSystem,M_UART_PARITY,M_DISABLE);//定義校驗位
MsysControl(MilSystem,M_UART_SPEED,9600);//波特率,該參數應該需要改變,現在可能與相機的不符
MsysControl(MilSystem,M_UART_STOP_BITS,1);//停止位
MsysControl(MilSystem,M_UART_WRITE_STRING_LENGTH,M_DEFAULT);//設置寫入的字符串長度,以'0'為界
MsysControl(MilSystem,M_UART_TIMEOUT,10000);//設置字符間等待時間
MsysControl(MilSystem,M_UART_STRING_DELIMITER,M_DEFAULT);//設置字符串分界符為默認的'0'
MsysControl(MilSystem,M_UART_READ_STRING_LENGTH,M_DEFAULT);//讀入的字符串長度,以默認的分界符確定
//設置接收緩存大小
ReadSize=0x00FF;
ReadBuffer=(char*)malloc(ReadSize+1);
MsysControl(MilSystem,M_UART_READ_STRING_MAXIMUM_LENGTH,ReadSize);
return true;
}
bool MilDestroy()
{
MbufFree(MilImage);
MappFreeDefault(MilApplication,MilSystem,MilDisplay,MilDigitizer,M_NULL);
return true;
}
//下面的函數可能有問題
CString SendCLCommand(char *a)
{
long i;
MsysControl(MilSystem,M_UART_WRITE_STRING,(long)a);//此處是不是得換成&a[0]???此處有問題,參數的說明是
//指定要發送的字符數組(字符串)。可以詳細比較
//MsysControl()與MdigControl()的第三個參數。
for(i=0;i<=ReadSize;i++)
ReadBuffer[i]='\0';//字符指針重元素的初始化。可以把此處的初始化改變或許能夠進行測試!!
Sleep(1000);
MsysControl(MilSystem,M_UART_READ_STRING,(long )ReadBuffer);
CString str(ReadBuffer);
return str;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -