Home > Software engineering >  MFC display data data show only the last set of data, rather than dynamic updates
MFC display data data show only the last set of data, rather than dynamic updates

Time:10-11

The following is the core code; Will display card for a while, and then display only received one last set of data, rather than repeatedly updated according to
Void CTEST_MFCApplication1Dlg: : OnBnClickedButtonOpen ()
{
//TODO: add the control notification handler code
//the UpdateData (true);
RT_CAN can;
RT_COM com;
CAN_msg MSG.
MSG. Id=0 x01223211;//configuration message ID
MSG. Len=8;//configuration message length
MSG. The format=EXTENDED_FORMAT;//configuration message format
MSG. Type=REMOTE_FRAME;//configuration message type
If (can Open (3, 115200))
{
//open the virtual serial port successful operation
For (int j=1; j <10; J++)
{

The UpdateData (true);
For (int I=1; i <=15; I++)
{
Can. RecvCANMessage (& amp; MSG);
Int temp=(MSG) data [1] <8) | MSG. Data [2];
The switch (MSG) data [0])
{
Case 0 x00: m_V0=temp;
break;
Case 0 x01: m_V1=temp;
break;
Case 0 x02: m_V2=temp;
break;
Case 0 x03: m_V3=temp;
break;
Case 0 x04: m_V4=temp;
break;
Case 0 x05: m_V5=temp;
break;
Case 0 x06: m_V6=temp;
break;
Case 0 x07: m_V7=temp;
break;
Case 0 x08: m_I0=temp;
break;
Case 0 x09: m_I1=temp;
break;
Case 0 x0a: m_I2=temp;
break;
Case 0 x0b: m_I3=temp;
break;
Case 0 x0c: m_P0=temp;
break;
Case 0 x0d: m_P1=temp;
break;
Case 0 x0e: m_P2=temp;
break;
Case 0 x0f: m_P3=temp;
break;
Case 0 x10: m_POSITION_X=temp;
break;
Case 0 x11: m_POSITION_Y=temp;
break;
Case 0 x12: m_POSITION_Z=temp;
break;
Case 0 x13: m_T=temp;
break;
Case 0 x14: m_T0=temp;
break;
Case 0 x15: m_T1=temp;
break;
Case 0 x16: m_T2=temp;
break;
Default: m_T3=temp;
}
}
The UpdateData (false);
}
}
The else
{
MessageBox (_T (" open the equipment failure!" ));
return;
}

}

CodePudding user response:

Message loop is added in the loop:
 MSG MSG. 
If (GetMessage (& amp; MSG, NULL, 0, 0)) {
TranslateMessage (& amp; MSG);
DispatchMessage (& amp; MSG);
}

CodePudding user response:

Strong!!!!!! To solve the

CodePudding user response:

refer to the second floor qq_34476017 response:
is very strong!!!!!! Solve the

Ha ha!
Old blind and hit a dead  !

CodePudding user response:

reference 1st floor zhao4zhong1 response:
message loop is added in the loop:
 MSG MSG. 
If (GetMessage (& amp; MSG, NULL, 0, 0)) {
TranslateMessage (& amp; MSG);
DispatchMessage (& amp; MSG);
}

In the later; I found a packet loss occurs, how to do? Such as the first variable should always have a value; But now update some changes;

CodePudding user response:

Authentic way is not in the void CTEST_MFCApplication1Dlg: : OnBnClickedButtonOpen () inside of circulation message loop is added; But
Will void CTEST_MFCApplication1Dlg: : OnBnClickedButtonOpen () inside the loop into
Using CTEST_MFCApplication1Dlg
A member variable for loop control variable,
Another state variable difference is in the loop,
The SetTimer starts a timer,
CTEST_MFCApplication1Dlg: : OnTimer according to processing cycle control variables and state variables in each cycle,
  • Related