📄 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 + -