void CBatchSNDlg::OnNMClickList_Input(NMHDR *pNMHDR, LRESULT *pResult){
    LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);

    CString temp_cstring;
    long lRow,lCol;
    m_products_list.Set_Edit(true);
    DWORD dwPos=GetMessagePos();//Get which line is click by user.Set the check box, when user enter Insert it will jump to program dialog
    CPoint point( LOWORD(dwPos), HIWORD(dwPos));
    m_products_list.ScreenToClient(&point);
    LVHITTESTINFO lvinfo;
    lvinfo.pt=point;
    lvinfo.flags=LVHT_ABOVE;
    int nItem=m_products_list.SubItemHitTest(&lvinfo);
    BOOL Is_Range = FALSE;
    int Range_Address = -1;
    int Value_Address = -1;
    int Value_Length = 0;
    lRow = lvinfo.iItem;
    lCol = lvinfo.iSubItem;

    if(lRow>m_products_list.GetItemCount()) //如果点击区超过最大行号,则点击是无效的
        return;
    if(lRow<0)
        return;
    int IntSN=GetNewSerialNumber();
     //
    write_one(m_modbus_IDs.at(lRow).ModbusID,2026,123,5);
    int ret=write_one(m_modbus_IDs.at(lRow).ModbusID,2027,IntSN,5);
    if (ret>0)
    {
        WriteSerialNumber(IntSN);
        m_modbus_IDs.at(lRow).SN = IntSN;
        m_modbus_IDs.at(lRow).Result = TRUE;
    } 
    else
    {    
        m_modbus_IDs.at(lRow).SN = -1;
        m_modbus_IDs.at(lRow).Result = FALSE;
    } 
    PostMessage(WM_REFRESH_BAC_INPUT_LIST,0,0);
}
Пример #2
0
void
IMI::WriteHeader(const TDeclaration &decl, IMIBYTE tampered, FILE *file)
{
  fputs("AIMI", file);
  WriteSerialNumber(decl.header.sn, file);
  fputs("\r\n", file);

  BrokenDate start_date = ConvertToDateTime(decl.header.recStartDateTime);
  fprintf(file, "HFDTE%02d%02d%02d\r\n",
          start_date.day, start_date.month, start_date.year % 100);

  fputs("HFFXA010\r\n", file);

  fputs("HFPLTPILOT:", file);
  WriteString(decl.header.plt, sizeof(decl.header.plt), file);
  fputs("\r\n", file);

  if (decl.header.db1Day != 0)
    fprintf(file, "HFDB1PILOTBIRTHDATE:%02d%02d%02d\r\n",
            decl.header.db1Day + 1, decl.header.db1Month + 1,
            decl.header.db1Year % 100);

  fputs("HFGTYGLIDERTYPE:", file);
  WriteString(decl.header.gty, sizeof(decl.header.gty), file);
  fputs("\r\n", file);

  fputs("HFGIDGLIDERID:", file);
  WriteString(decl.header.gid, sizeof(decl.header.gid), file);
  fputs("\r\n", file);

  fputs("HFDTM100DATUM:WGS-1984\r\n", file);

  fprintf(file, "HFRFWFIRMWAREVERSION:%d.%d\r\n",
          (unsigned)(decl.header.swVersion >> 4),
          (unsigned)(decl.header.swVersion & 0x0F));

  fprintf(file, "HFRHWHARDWAREVERSION:%d.%d\r\n",
          (unsigned)(decl.header.hwVersion >> 4),
          (unsigned)(decl.header.hwVersion & 0x0F));

  fprintf(file, "HFFTYFRTYPE:IMI Gliding, %s\r\n",
          GetDeviceName(decl.header.device));

  fprintf(file, "HFGPSGPS:%s\r\n",
          GetGPSName(decl.header.gps));

  fprintf(file, "HFPRSPRESSALTSENSOR:%s\r\n",
          GetSensorName(decl.header.sensor));

  if (tampered)
    fputs("HFFRSSECURITYSUSPECTUSEVALIPROGRAM:Tamper detected, FR needs to be reset", file);

  if (decl.header.cid[0] != 0) {
    fputs("HFCIDCOMPETITIONID:", file);
    WriteString(decl.header.cid, sizeof(decl.header.cid), file);
    fputs("\r\n", file);
  }

  // This seems to be a bug in the original implementation
  // When the competition class line is missing the integrity check will fail!
  if (decl.header.cid[0] != 0) {
    fputs("HFCCLCOMPETITIONCLASS:", file);
    if (decl.header.ccl[0] != 0)
      WriteString(decl.header.ccl, sizeof(decl.header.ccl), file);
    fputs("\r\n", file);
  }

  if (decl.header.cm2[0] != '\0') {
    fputs("HFCM2SECONDCREW:", file);
    WriteString(decl.header.cm2, sizeof(decl.header.cm2), file);
    fputs("\r\n", file);

    if (decl.header.db2Day != 0)
      fprintf(file, "HFDB1SECONDCREWBIRTHDATE:%02d%02d%02d\r\n",
              decl.header.db2Day + 1, decl.header.db2Month + 1,
              decl.header.db2Year % 100);
  }

  if (decl.header.clb[0] != '\0') {
    fputs("HFCLBCLUB:", file);
    WriteString(decl.header.clb, sizeof(decl.header.clb), file);
    fputs("\r\n", file);
  }

  if (decl.header.sit[0] != '\0') {
    fputs("HFCLBSITE:", file);
    WriteString(decl.header.sit, sizeof(decl.header.sit), file);
    fputs("\r\n", file);
  }

  if ((decl.header.sensor & IMINO_ENL_MASK) != 0)
    fputs("I033638FXA3940SIU\r\n", file);
  else
    fputs("I033638FXA3940SIU4143ENL\r\n", file);

  fputs("J020810HDT1113GSP\r\n", file);

  unsigned count = CountWaypoints(decl.wp);
  if (count >= 2) {
    BrokenDateTime decl_date = ConvertToDateTime(decl.header.date);
    fprintf(file, "C%02d%02d%02d", decl_date.day, decl_date.month,
            decl_date.year % 100);
    fprintf(file, "%02d%02d%02d", decl_date.hour, decl_date.minute,
            decl_date.second);

    if (decl.header.tskYear != 0)
      fprintf(file, "%02d%02d%02d", decl.header.tskDay + 1,
              decl.header.tskMonth + 1, decl.header.tskYear % 100);
    else
      fputs("000000", file);

    fprintf(file, "%04d%02d", decl.header.tskNumber, count - 2);
    WriteString(decl.header.tskName, sizeof(decl.header.tskName), file);
    fputs("\r\n", file);

    const IMI::TWaypoint *wp = decl.wp;
    for (unsigned i = 0; i < count + 2; i++, wp++) {
      AngleConverter l;
      l.value = wp->lat;
      fprintf(file, "C%02d%05d%c", l.degrees, l.milliminutes,
              (l.sign ? 'S' : 'N'));

      l.value = wp->lon;
      fprintf(file, "%03d%05d%c", l.degrees, l.milliminutes,
              (l.sign ? 'W' : 'E'));

      WriteString(wp->name, sizeof(wp->name), file);
      fputs("\r\n", file);
    }
  }

  fputs("LIMIFLIGHTOFDAY:", file);
  fprintf(file, "%03d", decl.header.flightOfDay);
  fputs("\r\n", file);

  //first fix must be full
  fixBLastFull.id = 0;
}