tx_view代碼

void CSetting::tx_view(int len, char *ptr)

 char StrData[10];
 char str[1010];
 char *pPsrData = NULL;
 char SignFlag = '+';
 int i = 0; 
 double data;         //每個通道轉換後的數值
 int ChannelNo = 0;   //要顯示的通道號

 memset(StrData, 0, sizeof(StrData));
 memset(str,     0, sizeof(str));
 
 // test begin
 // 開始進行處理
 if(strlen(ptr) < sizeof(str))
 {
  strcpy(str,ptr);
 }
 else
 {
  return;
 }
 int n = strlen(str);

 for(i = 0; i < n; i++)
 {
  memset(StrData, 0, sizeof(StrData));
  if((str[i] >='a') && (str[i] <= 'j'))
  {
   Digital_Copy(&str[i+2],StrData);
   // 讀過來的數據有小於7的可能,這時顯示上次讀取的數值
   if (strlen(StrData) < 7)
   {
    continue;
   }
   if(str[i+1] == '-')
   {   
    data = 0- atof(StrData);
   }
   else
   {    
    data = atof(StrData);
   } 
   ChannelNo = str[i] - 'a';
   lx_frame_float[ChannelNo] = data;   
   i++; //指向數字 
  }
 } 

 // 格式化字符串,傳遞給CcurDate的窗口
 memset(aSendBuffer, 0, sizeof(aSendBuffer));
 memcpy(aSendBuffer, lx_frame_float, sizeof(lx_frame_float));

 pCurDataDlg->PostMessage(WM_S2C, (WPARAM)aSendBuffer, (LPARAM)0);
 pChartDlg->PostMessage(WM_C2C,   (WPARAM)1, (LPARAM)1);

 // 採集時間間隔
//  int RequestDelayInterval = 0;
//  RequestDelayInterval = GetDlgItemInt(IDC_COMSettingInterval);
//  if((RequestDelayInterval > 100 )&& (RequestDelayInterval < 5000))
//  {
//   SetTimer(2, RequestDelayInterval, NULL); //啓動定時器,進行超時檢測
//  }
}

 

//open函數中加入不能爲空的判斷

 if (PortNUm.GetLength() == 0 || sInterval.GetLength() == 0 || sBaud.GetLength() == 0 || sChannelID.GetLength() == 0)
 {
  AfxMessageBox("配置信息不能爲空!!!");
  return;
 }

 

 

OnTimer()中case5,刪除對bool類型的判斷

發佈了44 篇原創文章 · 獲贊 40 · 訪問量 27萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章