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类型的判断

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
x_train, t_train, x_test, t_test = load_data('F:\\2023\\archive\\train') network = DeepConvNet() network.load_params("deep_convnet_params.pkl") print("calculating test accuracy ... ") sampled = 1000 x_test = x_test[:sampled] t_test = t_test[:sampled] prediect_result = [] for i in x_test: i = np.expand_dims(i, 0) y = network.predict(i) _result = network.predict(i) _result = softmax(_result) result = np.argmax(_result) prediect_result.append(int(result)) acc_number = 0 err_number = 0 for i in range(len(prediect_result)): if prediect_result[i] == t_test[i]: acc_number += 1 else: err_number += 1 print("预测正确数:", acc_number) print("预测错误数:", err_number) print("预测总数:", x_test.shape[0]) print("预测正确率:", acc_number / x_test.shape[0]) classified_ids = [] acc = 0.0 batch_size = 100 for i in range(int(x_test.shape[0] / batch_size)): tx = x_test[i * batch_size:(i + 1) * batch_size] tt = t_test[i * batch_size:(i + 1) * batch_size] y = network.predict(tx, train_flg=False) y = np.argmax(y, axis=1) classified_ids.append(y) acc += np.sum(y == tt) acc = acc / x_test.shape[0] classified_ids = np.array(classified_ids) classified_ids = classified_ids.flatten() max_view = 20 current_view = 1 fig = plt.figure() fig.subplots_adjust(left=0, right=1, bottom=0, top=1, hspace=0.2, wspace=0.2) mis_pairs = {} for i, val in enumerate(classified_ids == t_test): if not val: ax = fig.add_subplot(4, 5, current_view, xticks=[], yticks=[]) ax.imshow(x_test[i].reshape(28, 28), cmap=plt.cm.gray_r, interpolation='nearest') mis_pairs[current_view] = (t_test[i], classified_ids[i]) current_view += 1 if current_view > max_view: break print("======= 错误预测结果展示 =======") print("{view index: (label, inference), ...}") print(mis_pairs) plt.show()
最新发布
06-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值