在VC++6.0环境下实现小区车辆出入信息采集系统上位机的开发.此系统能接受到出入小区车辆的信息,主要包括出入时间,出入状态,车型,车牌号,车主代码.如果不是小区车辆还能实现报警功能.
我是用CSerialPort类来进行串行通信的.
加入函数OnComm()的实现,并在其中完成对接受到字符的处理,"时间"是在 LONG CCarMSDlg::OnComm(WPARAM ch, LPARAM port){}一触发后显示当前系统的时间.其余:状态,车型,车牌号,车主代码是接受硬件的数据,然后对应显示在相应的框内:以下是小妹自己写的,请高手指教
状态一个字节(如1),车型2位数(如A1),车牌号7位数(如粤A25263)车主代码12(198402260012)
LONG CCarMSDlg::OnComm(WPARAM ch, LPARAM port)
{
VARIANT m_input1;
ColeSafeArray m_input2;
Long length,i;
BYTE data[1024];
Cstring str;
int b;
if(m_Comm.GetCommEvent()= =2)//接收缓冲区内有字符
{
m_input1=m_Comm.Getinput();//读取缓冲区内的数据
m_input2=m_input1;//将VARIANT型变量转换为ColeSafeArray型变量
length=m_input2.GetOneDimSize();//确定数据长度
for(i=0;i<length;++)
m_input2.GetElement(&i,data+i);//将数据转换为BYTE型数组
for(i=0;i<length;i++)//将数组转换为Cstring型变量
{
char a=* (char *)(data+i);
str.Format("%c",a);
count=m_comm.GetInBufferCount( );
m_comm.SetInputLen(count); //利用Input接收字符数为count
temp=m_comm.GetInput( ); //接收字符
b=count;
for(b=1;b<count;b++)
{
if(b=1)
{
m_state.Empty( );
m_state+=temp.bsteVal;//赋值给到"状态"编辑框
}
if(b=2)
{
m_cartype.Empty( );
m_cartype+=temp.bsteVal;//赋值给到"车型"编辑框
}
if(b=4)
{
m_carnum.Empty( );
m_carnum+=temp.bsteVal;//赋值给到"车牌号"编辑框
}
if(b=12)
{
m_usernum.Empty( );
m_usernum+=temp.bsteVal;//赋值给到"车主代码"编辑框
}
}
}
UpdataData(FALSE);//更新编辑框内容
return 0;
}
获取系统时间的不知道怎么写?希望指教,多谢多谢!!!!!
我是用CSerialPort类来进行串行通信的.
加入函数OnComm()的实现,并在其中完成对接受到字符的处理,"时间"是在 LONG CCarMSDlg::OnComm(WPARAM ch, LPARAM port){}一触发后显示当前系统的时间.其余:状态,车型,车牌号,车主代码是接受硬件的数据,然后对应显示在相应的框内:以下是小妹自己写的,请高手指教
状态一个字节(如1),车型2位数(如A1),车牌号7位数(如粤A25263)车主代码12(198402260012)
LONG CCarMSDlg::OnComm(WPARAM ch, LPARAM port)
{
VARIANT m_input1;
ColeSafeArray m_input2;
Long length,i;
BYTE data[1024];
Cstring str;
int b;
if(m_Comm.GetCommEvent()= =2)//接收缓冲区内有字符
{
m_input1=m_Comm.Getinput();//读取缓冲区内的数据
m_input2=m_input1;//将VARIANT型变量转换为ColeSafeArray型变量
length=m_input2.GetOneDimSize();//确定数据长度
for(i=0;i<length;++)
m_input2.GetElement(&i,data+i);//将数据转换为BYTE型数组
for(i=0;i<length;i++)//将数组转换为Cstring型变量
{
char a=* (char *)(data+i);
str.Format("%c",a);
count=m_comm.GetInBufferCount( );
m_comm.SetInputLen(count); //利用Input接收字符数为count
temp=m_comm.GetInput( ); //接收字符
b=count;
for(b=1;b<count;b++)
{
if(b=1)
{
m_state.Empty( );
m_state+=temp.bsteVal;//赋值给到"状态"编辑框
}
if(b=2)
{
m_cartype.Empty( );
m_cartype+=temp.bsteVal;//赋值给到"车型"编辑框
}
if(b=4)
{
m_carnum.Empty( );
m_carnum+=temp.bsteVal;//赋值给到"车牌号"编辑框
}
if(b=12)
{
m_usernum.Empty( );
m_usernum+=temp.bsteVal;//赋值给到"车主代码"编辑框
}
}
}
UpdataData(FALSE);//更新编辑框内容
return 0;
}
获取系统时间的不知道怎么写?希望指教,多谢多谢!!!!!
串口部分没什么问题。
问题二:数据库操作,搜索一下ado或者odbc,论坛中已经有很多了。
LONG CCarMSDlg::OnComm(WPARAM ch, LPARAM port)
{
}
内编译时出现好多问题,不知从何改
D:\CarMS\CarMSDlg.cpp(190) : error C2065: 'ColeSafeArray' : undeclared identifier
D:\CarMS\CarMSDlg.cpp(190) : error C2146: syntax error : missing ';' before identifier 'm_input2'
D:\CarMS\CarMSDlg.cpp(190) : error C2065: 'm_input2' : undeclared identifier
D:\CarMS\CarMSDlg.cpp(191) : error C2065: 'Long' : undeclared identifier
D:\CarMS\CarMSDlg.cpp(191) : error C2146: syntax error : missing ';' before identifier 'length'
D:\CarMS\CarMSDlg.cpp(191) : error C2065: 'length' : undeclared identifier
D:\CarMS\CarMSDlg.cpp(191) : error C2065: 'i' : undeclared identifier
D:\CarMS\CarMSDlg.cpp(193) : error C2065: 'Cstring' : undeclared identifier
D:\CarMS\CarMSDlg.cpp(193) : error C2146: syntax error : missing ';' before identifier 'str'
D:\CarMS\CarMSDlg.cpp(193) : error C2065: 'str' : undeclared identifier
D:\CarMS\CarMSDlg.cpp(195) : error C2065: 'm_Comm' : undeclared identifier
D:\CarMS\CarMSDlg.cpp(195) : error C2228: left of '.GetCommEvent' must have class/struct/union type
D:\CarMS\CarMSDlg.cpp(195) : error C2059: syntax error : '='
D:\CarMS\CarMSDlg.cpp(196) : error C2143: syntax error : missing ';' before '{'
D:\CarMS\CarMSDlg.cpp(197) : error C2228: left of '.Getinput' must have class/struct/union type
D:\CarMS\CarMSDlg.cpp(198) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct tagVARIANT' (or there is no acceptable conversion)
D:\CarMS\CarMSDlg.cpp(199) : error C2228: left of '.GetOneDimSize' must have class/struct/union type
D:\CarMS\CarMSDlg.cpp(200) : error C2059: syntax error : ')'
D:\CarMS\CarMSDlg.cpp(205) : error C2228: left of '.Format' must have class/struct/union type
D:\CarMS\CarMSDlg.cpp(206) : error C2065: 'count' : undeclared identifier
D:\CarMS\CarMSDlg.cpp(206) : error C2065: 'm_comm' : undeclared identifier
D:\CarMS\CarMSDlg.cpp(206) : error C2228: left of '.GetInBufferCount' must have class/struct/union type
D:\CarMS\CarMSDlg.cpp(207) : error C2228: left of '.SetInputLen' must have class/struct/union type
D:\CarMS\CarMSDlg.cpp(208) : error C2065: 'temp' : undeclared identifier
D:\CarMS\CarMSDlg.cpp(208) : error C2228: left of '.GetInput' must have class/struct/union type
D:\CarMS\CarMSDlg.cpp(215) : error C2228: left of '.bsteVal' must have class/struct/union type
D:\CarMS\CarMSDlg.cpp(220) : error C2228: left of '.bsteVal' must have class/struct/union type
D:\CarMS\CarMSDlg.cpp(225) : error C2228: left of '.bsteVal' must have class/struct/union type
D:\CarMS\CarMSDlg.cpp(230) : error C2228: left of '.bsteVal' must have class/struct/union type
D:\CarMS\CarMSDlg.cpp(234) : error C2065: 'UpdataData' : undeclared identifier
D:\CarMS\CarMSDlg.cpp(239) : error C2601: 'OnButtonOpen' : local function definitions are illegal
D:\CarMS\CarMSDlg.cpp(257) : error C2601: 'OnButtonClose' : local function definitions are illegal
D:\CarMS\CarMSDlg.cpp(264) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
ColeSafeArray ---> COleSafeArray, Long ---> long, Cstring ---> CString,
UpdataData ---> UpdateData
m_Comm 或者 m_comm的定义在哪里?