在好例子网,分享、交流、成长!
您当前所在位置:首页C/C++ 开发实例桌面应用界面/GUI → 尼康Z转接协议提取软件

尼康Z转接协议提取软件

桌面应用界面/GUI

下载此实例
  • 开发语言:C/C++
  • 实例大小:5.14M
  • 下载次数:9
  • 浏览次数:75
  • 发布时间:2021-07-30
  • 实例类别:桌面应用界面/GUI
  • 发 布 人:xuailianmei
  • 文件格式:.rar
  • 所需积分:5
 相关标签: 提取 软件 协议

实例介绍

【实例简介】:用于提取尼康Z相机原厂转接环协议

【实例截图】


from clipboard

【核心代码】

// FTZ1Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "FTZ1.h"
#include "FTZ1Dlg.h"
#include <Afxcoll.h>
#include <shlwapi.h> 
#include <Afxtempl.h>
////////////////////////////
#include "CRC16_ARC.h"
#include "CRC16_AUG_CCITT.h"
#include "CRC16_BUYPASS.h"
#include "CRC16_CCIT_ZERO.h"
#include "CRC16_CCITT_FALSE.h"
#include "CRC16_CDMA2000.h"
#include "CRC16_DDS_110.h"
#include "CRC16_DECT_R.h"
#include "CRC16_DECT_X.h"
#include "CRC16_DNP.h"
#include "CRC16_EN_13757.h"
#include "CRC16_GENIBUS.h"
#include "CRC16_KERMIT.h"
#include "CRC16_MAXIM.h"
#include "CRC16_MCRF4XX.h"
#include "CRC16_MODBUS.h"
#include "CRC16_T10_DIF.h"
#include "CRC16_TELEDISK.h"
#include "CRC16_USB.h"
#include "CRC16_X_25.h"
#include "CRC16_XMODEM.h"
/////////////////////////////
#pragma comment(lib, "shlwapi.lib") 

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
#define SHOW_TIPS      2001
#define SHOW_TIME      2002
#define SHOW_VERSION   2003
#define SHOW_ICON      2004

class CAboutDlg : public CDialog
{
public:
CAboutDlg();

// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFTZ1Dlg dialog

CFTZ1Dlg::CFTZ1Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CFTZ1Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFTZ1Dlg)
m_showlenorcam = 0;
m_radio_posorneg = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON1);
}

void CFTZ1Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFTZ1Dlg)
DDX_Control(pDX, IDC_STATIC_SHOWPROGRESS, m_showprogress);
DDX_Control(pDX, IDC_EDIT_FITVALUE, m_fitvalue);
DDX_Control(pDX, IDC_CHECK_CHECKALLPOSSIBLE, m_CheckAll);
DDX_Control(pDX, IDC_EDIT_CRCINPUT, m_CRCInput);
DDX_Control(pDX, IDC_CRCRESULT, m_CRCResult);
DDX_Control(pDX, IDC_COMBO_CRC, m_CombCRC);
DDX_Control(pDX, IDC_BTN_SHOWORHIDE, m_hideorshow);
DDX_Control(pDX, IDC_EDIT_CNT, m_CombCnt);
DDX_Control(pDX, IDC_PROGRESS1, m_Step);
DDX_Control(pDX, IDC_STATIC_TIP1, m_tip1);
DDX_Control(pDX, IDC_COMBO, m_Comb);
DDX_Control(pDX, IDC_EDIT_TIP, m_tip);
DDX_Radio(pDX, IDC_RADIO_LEN, m_showlenorcam);
DDX_Radio(pDX, IDC_RADIO_POSI, m_radio_posorneg);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CFTZ1Dlg, CDialog)
//{{AFX_MSG_MAP(CFTZ1Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_CBN_SELCHANGE(IDC_COMBO, OnSelchangeCombo)
ON_WM_TIMER()
ON_WM_NCHITTEST()
ON_BN_CLICKED(IDC_BTN_SHOWORHIDE, OnBtnShoworhide)
ON_BN_CLICKED(IDC_BTN_CALC, OnBtnCalc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFTZ1Dlg message handlers

BOOL CFTZ1Dlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
////////////////////////////////////////////////////
BOOL bRet=m_StatusBar.Create(this);
UINT nIDS[4]={SHOW_TIPS,SHOW_TIME,SHOW_VERSION,SHOW_ICON};
bRet=m_StatusBar.SetIndicators(nIDS,4);



    m_StatusBar.SetPaneInfo(0,nIDS[0],SBPS_NORMAL,200);
m_StatusBar.SetPaneInfo(1,nIDS[1],SBPS_NORMAL,200);
m_StatusBar.SetPaneInfo(2,nIDS[2],SBPS_NORMAL,200);
m_StatusBar.SetPaneInfo(3,nIDS[3],SBPS_NORMAL,32656);
    m_StatusBar.SetPaneText(0,"状态指示:");
    m_StatusBar.SetPaneText(2,"Version 0.1");
m_StatusBar.GetStatusBarCtrl().SetIcon(3,AfxGetApp()->LoadIcon(IDI_SMILE));
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);
// Set the icon for this dialog.  The framework does this automatically
//  when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here
m_Step.SetRange(0,100);
SetTimer(2,1000,NULL);
return TRUE;  // return TRUE  unless you set the focus to a control
}

void CFTZ1Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.
CRect rect;
void CFTZ1Dlg::OnPaint() 
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);

GetClientRect(&rect);
int x = (rect.Width() - cxIcon 1) / 2;
int y = (rect.Height() - cyIcon 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CFTZ1Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

void CFTZ1Dlg::OnCancel() 
{
// TODO: Add extra cleanup here

CDialog::OnCancel();
}

void CFTZ1Dlg::OnOK() 
{
// TODO: Add extra validation here
CString strPath1,strPath2,strPath3;
char path_buffer[_MAX_PATH]={0};
ClearFile();
GetCurrentDirectory(sizeof(path_buffer),path_buffer);
strPath1=strPath2=strPath3=path_buffer;
strPath1 ="\\MISO AND MOSI.txt";
strPath2 ="\\CAMMSG.txt";
strPath3 ="\\LENMSG.txt";
//////////////////////////
CStdioFile file1,file2,file3;
if(!file1.Open(strPath1,CFile::modeRead|CFile::typeBinary))
{
AfxMessageBox(_T("fMISO AND MOSI.txt.txt!打开失败"));
return ;
}
file1.SeekToBegin();
//////////////////////////////
if(!file2.Open(strPath2,CFile::modeWrite|CFile::typeBinary))
{
AfxMessageBox(_T("CAMMSG.txt!打开失败"));
return ;
}
file2.SetLength(0);
file2.SeekToBegin();
////////////////////////////////
if(!file3.Open(strPath3,CFile::modeWrite|CFile::typeBinary))
{
AfxMessageBox(_T("LENMSG.txt!打开失败"));
return ;
}
file3.SetLength(0);
file3.SeekToBegin();
m_tip1.SetWindowText("正在提取文件!");
m_Step.SetPos(0);
m_showprogress.SetWindowText("0");
Sleep(300);
//////////////////////////////////
CString strfile,str1;
CString strCam,strLen;
unsigned int nLength=0;
int index=-1;
strfile.Empty();
str1.Empty();
strCam.Empty();
strLen.Empty();
unsigned int CurIndex=0;
unsigned int BkIndex=0;
while(file1.ReadString(strfile))
{
strfile.TrimRight();
if("Time [s],Packet ID,MOSI,MISO"==strfile)
{
continue;
}
////////////////////////////////////////////////////
index=strfile.Find(',');
nLength=strfile.GetLength();
if(index!=-1)
{
strfile=strfile.Mid(index 1,nLength-index-1);
index=strfile.Find(',');
str1=strfile.Mid(0,index);
CurIndex=_tcstoul(str1,0,10);
nLength=strfile.GetLength();
strfile=strfile.Mid(index 1,nLength-index-1);
if(BkIndex!=CurIndex)
{
BkIndex=CurIndex;
strCam ="\r\n";
strLen ="\r\n";
file2.WriteString(strCam);
file3.WriteString(strLen);
strCam=strfile.Mid(5,4);
strLen=strfile.Mid(0,4);
strCam =" ";
strLen =" ";
}
else//
{
strCam =strfile.Mid(5,4);
strCam =" ";
strLen =strfile.Mid(0,4);
strLen =" ";
}
}
}
/////////////////////////////////
strCam ="\r\n";
strLen ="\r\n";
file2.WriteString(strCam);
file3.WriteString(strLen);
m_Step.SetPos(10);
m_showprogress.SetWindowText("10");
/////////////////////////////////
file1.Close();
file2.Close();
file3.Close();
Sleep(300);
PickupCamAndLen();
m_Step.SetPos(40);
m_showprogress.SetWindowText("40");
PickupCamAndLen1();
m_Step.SetPos(60);
m_showprogress.SetWindowText("60");
SortCamCmd();
m_Step.SetPos(70);
m_showprogress.SetWindowText("70");
SortCamCmd1();
m_Step.SetPos(85);
m_showprogress.SetWindowText("85");
SortCamCmd2();
m_tip1.SetWindowText("提取完成!");
m_showprogress.SetWindowText("100");
m_Step.SetPos(100);
///////////////////////////////////
}
void CFTZ1Dlg::PickupCamAndLen()
{
CString strPath1,strPath2,strPath3;
char path_buffer[_MAX_PATH]={0};
GetCurrentDirectory(sizeof(path_buffer),path_buffer);
strPath1=strPath2=strPath3=path_buffer;
strPath1 ="\\CAMMSG.txt";
strPath2 ="\\LENMSG.txt";
strPath3 ="\\CAMANDLENMSG.txt";
//////////////////////////
CStdioFile file1,file2,file3;
if(!file1.Open(strPath1,CFile::modeRead|CFile::typeBinary))
{
AfxMessageBox(_T("CAMMSG.txt!打开失败"));
return ;
}
file1.SeekToBegin();
///////////////////////////////
//////////////////////////////
if(!file2.Open(strPath2,CFile::modeRead|CFile::typeBinary))
{
AfxMessageBox(_T("LENMSG.txt!打开失败"));
return ;
}
file2.SeekToBegin();
////////////////////////////////
////////////////////////////////
    if(!file3.Open(strPath3,CFile::modeWrite|CFile::typeBinary))
{
AfxMessageBox(_T("CAMANDLENMSG.txt!打开失败"));
return ;
}
file3.SetLength(0);
file3.SeekToBegin();
/////////////////////////////////
////////////////////////////////
CString strfile1,strfile2,strtmp,strtmp1;
unsigned int nLength=0;
unsigned char CmdIndex=0;
unsigned char tmp=0;
unsigned int  LineIndex=0;
unsigned char bFirstLength39Flag=0;//第一个39命令
unsigned int CmdLength=0;
unsigned int CmdL1=0;
unsigned int CmdL2=0;
while(file1.ReadString(strfile1))
{
strfile1.TrimRight();
nLength=strfile1.GetLength();
if(nLength!=39)//如果长度不是39,那肯定不是命令,先找到第一条命令
{
LineIndex ;
continue;
}
else//如果是39
{
if(0==bFirstLength39Flag)
{
strtmp=strfile1.Mid(5,4);
CmdIndex=_tcstoul(strtmp,0,16);//找到第一个疑似命令的索引
//////////////////////////////////////////
strtmp=strfile1.Mid(25,4);
strtmp1=strfile1.Mid(30,4);
CmdL1=_tcstoul(strtmp,0,16);
CmdL2=_tcstoul(strtmp1,0,16);
CmdLength=(CmdL1 CmdL2*256)*2 2;
file1.ReadString(strfile1);
strfile1.TrimRight();
nLength=strfile1.GetLength();
LineIndex ;
if(nLength==(CmdLength*5-1))//确实是命令
{
break;//退出
}
else
{
continue;//继续寻找
}
}
}
}
// CString strtip;
// strtip.Format("%d",LineIndex);
// m_tip.SetWindowText(strtip);
//////////////////////////////
CArray<int,int> hexdata;
unsigned int LineIndex1=0;
unsigned char CmdIndexCur=0;//当前命令的行数
unsigned char CmdIndexBk=0;//上一次命令的行数
hexdata.RemoveAll();
file1.SeekToBegin();//重新定位到文件开头
hexdata.Add(LineIndex);
CmdIndexBk=CmdIndex;
while(file1.ReadString(strfile1))
{
strfile1.TrimRight();
LineIndex1 ;
if(LineIndex1<=LineIndex)
{
continue;
}
///////////////////
nLength=strfile1.GetLength();
if(39==nLength)
{
strtmp=strfile1.Mid(5,4);
CmdIndex=_tcstoul(strtmp,0,16);//找到第一个疑似命令的索引
if(CmdIndex==((CmdIndexBk 1)&0xff)) //索引加1
{
CmdIndexBk=CmdIndex;
hexdata.Add(LineIndex1);
}
}
}
///////////////////////////////////
    unsigned int i=0;
unsigned int j=0;
CString strtip1;
j=hexdata.GetSize();
// strtip.Empty();
// for(i=0;i<j;i )
// {
// strtip1.Format("%d",hexdata.GetAt(i));
// strtip =strtip1;
// strtip =" ";
// }
// m_tip.SetWindowText(strtip);
//////////////////////////////////
    file1.SeekToBegin();//重新定位到文件开头
file2.SeekToBegin();
j=hexdata.GetSize();
unsigned int indexofcmdtmp=0;
    unsigned int k=0;
unsigned int indexofcmdtmp1=0;
unsigned int indexofcmdtmp2=0;
unsigned int indexofcmdtmp3=0;
for(i=0;i<j-1;i )//读取J次
{
indexofcmdtmp=hexdata.GetAt(i);//第i条命令所在的行,1为开头行
indexofcmdtmp2=hexdata.GetAt(i 1);//第i 1条命令所在的行
while(file1.ReadString(strfile1))
{
strfile1.TrimRight();
indexofcmdtmp1 ;
if(indexofcmdtmp1==indexofcmdtmp)//找到相应的行
{
strfile1="相机:" strfile1;
strfile1 ="\r\n";
file3.WriteString(strfile1);//先写相机命令
while(file2.ReadString(strfile2))
{
strfile2.TrimRight();
indexofcmdtmp3 ;
if((indexofcmdtmp3>indexofcmdtmp)&&(indexofcmdtmp3<indexofcmdtmp2))
{
strfile2="镜头:" strfile2;
strfile2 ="\r\n";
file3.WriteString(strfile2);//先写相机命令
if(indexofcmdtmp3==(indexofcmdtmp2-1))
{
goto loop1;
}
}

}
}
loop1:   
file3.WriteString("\r\n");//每次写完一组加空行
file1.SeekToBegin();//重新回到文件开头
file2.SeekToBegin();//
indexofcmdtmp1=0;
indexofcmdtmp3=0;
}
//////////////////////////////////
file1.Close();
file2.Close();
file3.Close();
}

void CFTZ1Dlg::PickupCamAndLen1()
{
CString strPath1,strPath2,strPath3;
char path_buffer[_MAX_PATH]={0};
GetCurrentDirectory(sizeof(path_buffer),path_buffer);
strPath1=strPath2=strPath3=path_buffer;
strPath1 ="\\CAMANDLENMSG.txt";
strPath2 ="\\CAMANDLENMSG_1.txt";
strPath3 ="\\CAMANDLENMSG_2.txt";
//////////////////////////
CStdioFile file1,file2,file3;
if(!file1.Open(strPath1,CFile::modeRead|CFile::typeBinary))
{
AfxMessageBox(_T("CAMANDLENMSG.txt!打开失败"));
return ;
}
file1.SeekToBegin();
///////////////////////////////////////////////////////////
if(!file2.Open(strPath2,CFile::modeReadWrite|CFile::typeBinary))
{
AfxMessageBox(_T("CAMANDLENMSG_1.txt!打开失败"));
return ;
}
file2.SetLength(0);
file2.SeekToBegin();
////////////////////////////////////////////////////////////
if(!file3.Open(strPath3,CFile::modeWrite|CFile::typeBinary))
{
AfxMessageBox(_T("CAMANDLENMSG_2.txt!打开失败"));
return ;
}
file3.SetLength(0);
file3.SeekToBegin();
/////////////////////////////////////////////////////////////
CString strfile1,strfile2,strfile3;
CString strtmp;
CString strComb;
unsigned int nLength=0;
unsigned char bFirstTimeFlag=0;//
unsigned int  nCombCnt=0;//当前comb中包含的item数目
unsigned int  i=0;
m_Comb.ResetContent();//先清空一次
while(file1.ReadString(strfile1))//先找到指令的类型
{
strtmp=strfile1.Mid(0,4);
if(strtmp=="相机")
{
if(0==bFirstTimeFlag)
{
bFirstTimeFlag=1;
strtmp=strfile1.Mid(20,9);
m_Comb.AddString(strtmp);
}
else
{
strtmp=strfile1.Mid(20,9);
nCombCnt=m_Comb.GetCount();
for(i=0;i<nCombCnt;i )
{
m_Comb.GetLBText(i,strComb);
if(strComb==strtmp)
{
break;//退出
}
}
///////////////
if(i==nCombCnt)
{
m_Comb.AddString(strtmp);
i=0;
}
}
}
else
{
continue;
}
}
////////////////////////
unsigned char bFirstTimeFlag_1=0;
bFirstTimeFlag=0;
    file1.SeekToBegin();//重新定位到文件开头
nCombCnt=m_Comb.GetCount();
////////////////////////////////
CString strCombCnt;
strCombCnt.Format("%d",nCombCnt);
m_CombCnt.SetWindowText(strCombCnt);
////////////////////////////////
CString strnoack;
for(i=0;i<nCombCnt;i )
{
m_Comb.GetLBText(i,strComb);//获取第一条指令,存放于strComb
        while(file1.ReadString(strfile1))
{
strfile1.TrimRight();
strtmp=strfile1.Mid(0,4);
if(strtmp=="相机")
{
strtmp=strfile1.Mid(20,9);
if(strtmp==strComb)//如果搜索到相同的命令
{
if(0==bFirstTimeFlag)//如果是第一次
{
strfile1.TrimRight();
strfile1 ="\r\n";
file2.WriteString(strfile1);//写入命令
bFirstTimeFlag=1;
loopread:             file1.ReadString(strfile1);
strfile1.TrimRight();
if(strfile1!="")
{
bFirstTimeFlag_1=1;
strfile1 ="\r\n";
file2.WriteString(strfile1);//写入响应数据
goto loopread;
}
else//遇到空行
{
if(0==bFirstTimeFlag_1)
{
bFirstTimeFlag_1=1;
strnoack =strComb;
strnoack ="__";
m_tip1.SetWindowText(strnoack);
}
continue;
}
}
else//其他时间
{
loopread1:            file1.ReadString(strfile1);
  strfile1.TrimRight();
  if(strfile1!="")
  {
  strfile1 ="\r\n"; 
  file2.WriteString(strfile1);//写入响应数据
  goto loopread1;
  }
  else
  {
  continue;
  }
}
}
}
}
//////////////////////////////
file2.WriteString("\r\n");
file1.SeekToBegin();
bFirstTimeFlag=0;
bFirstTimeFlag_1=0;
}
////////////////////////
    file2.SeekToBegin();//定位到文件开头
unsigned int nLensCnt1=0;
unsigned int nLensCnt2=0;
unsigned int nLength1=0;
CString strfile4;
unsigned char bFirstTimeFlag_2=0;
while(file2.ReadString(strfile2))
{
strfile2.TrimRight();
strtmp=strfile2.Mid(0,4);
nLength=strfile2.GetLength();
if(strtmp=="相机")
{
if(0==bFirstTimeFlag_2)
{
strfile2 ="\r\n";
file3.WriteString(strfile2);// 命令直接写入
bFirstTimeFlag_2=1;
}
else
{   
file3.WriteString("\r\n");
strfile2 ="\r\n";
file3.WriteString(strfile2);// 命令直接写入
}
}
else if(strtmp=="镜头")//连续读两条信息
{
file2.ReadString(strfile3);
strfile3.TrimRight();
nLength1=strfile3.GetLength();
if(0==nLength1)//如果遇到空行
{
strfile2 ="\r\n";
file3.WriteString(strfile2);
file3.WriteString("\r\n");
}
else
{
strfile4=strfile2;
strfile4 ="  ";
strfile4 =strfile3;
strfile4 ="\r\n";
file3.WriteString(strfile4);
}
}
else
{
if(0==nLength)//如果是空行
{
strfile2 ="\r\n";
file3.WriteString(strfile2);
}
}
}
////////////////////////
file1.Close();
file2.Close();
file3.Close();
}

void CFTZ1Dlg::SortCamCmd()
{
CString strPath1,strPath2;
char path_buffer[_MAX_PATH]={0};
GetCurrentDirectory(sizeof(path_buffer),path_buffer);
strPath1=strPath2=path_buffer;
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
strPath1 ="\\CAMMSG.txt";
strPath2 ="\\CAMSORT.txt";
CStdioFile file1,file2;
if(!file1.Open(strPath1,CFile::modeRead|CFile::typeBinary))
{
AfxMessageBox(_T("CAMMSG.txt!打开失败"));
return ;
}
file1.SeekToBegin();
/////////////////////////////////
if(!file2.Open(strPath2,CFile::modeReadWrite|CFile::typeBinary))
{
AfxMessageBox(_T("CAMSORT.txt!打开失败"));
return ;
}
file2.SetLength(0);
file2.SeekToBegin();
CString strfile1,strfile2,strtmp,strtmp1;
unsigned int  nLength=0;
unsigned int  LineIndex=0;
unsigned char CmdIndex=0;
unsigned char bFirstLength39Flag=0;//第一个39命令
unsigned int CmdL1=0;
unsigned int CmdL2=0;
unsigned int CmdLength=0;
while(file1.ReadString(strfile1))
{
strfile1.TrimRight();
nLength=strfile1.GetLength();
////////////////////////////////////
////////////////////////////////////
if(nLength!=39)//如果长度不是39,那肯定不是命令,先找到第一条命令
{
LineIndex ;
continue;

else
{
if(0==bFirstLength39Flag)
{
strtmp=strfile1.Mid(5,4);
CmdIndex=_tcstoul(strtmp,0,16);//找到第一个疑似命令的索引
////////////////////////////////////////////////////////////////////
strtmp=strfile1.Mid(25,4);
strtmp1=strfile1.Mid(30,4);
CmdL1=_tcstoul(strtmp,0,16);
CmdL2=_tcstoul(strtmp1,0,16);
CmdLength=(CmdL1 CmdL2*256)*2 2;
file1.ReadString(strfile1);
strfile1.TrimRight();
nLength=strfile1.GetLength();
LineIndex ;
if((nLength==(CmdLength*5-1))&&(CmdLength<=100))//确实是命令
{
break;//退出
}
else
{
continue;//继续寻找
}
}
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
    CArray<int,int> hexdata;
unsigned int LineIndex1=0;
unsigned char CmdIndexCur=0;//当前命令的行数
unsigned char CmdIndexBk=0;//上一次命令的行数
    hexdata.RemoveAll();
file1.SeekToBegin();//重新定位到文件开头
hexdata.Add(LineIndex);
CmdIndexBk=CmdIndex;
while(file1.ReadString(strfile1))
{
        strfile1.TrimRight();
LineIndex1 ;
if(LineIndex1<=LineIndex)
{
continue;
}
nLength=strfile1.GetLength();
if(39==nLength)
{
strtmp=strfile1.Mid(5,4);
CmdIndex=_tcstoul(strtmp,0,16);//找到第一个疑似命令的索引
if(CmdIndex==((CmdIndexBk 1)&0xff)) //索引加1
{
CmdIndexBk=CmdIndex;
hexdata.Add(LineIndex1);
}
}
}
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
    unsigned int i=0;
unsigned int j=0;
    file1.SeekToBegin();//重新定位到文件开头
file2.SeekToBegin();
    j=hexdata.GetSize();
////////////////////////////////////////
////////////////////////////////////////
unsigned int indexofcmdtmp=0;
unsigned int indexofcmdtmp1=0;
unsigned int indexofcmdtmp2=0;
unsigned int indexofcmdtmp3=0;
    ////////////////////////////////////////
////////////////////////////////////////
for(i=0;i<j-1;i )
{
indexofcmdtmp=hexdata.GetAt(i);//第i条命令所在的行,1为开头行
indexofcmdtmp2=hexdata.GetAt(i 1);//第i 1条命令所在的行
////////////////////////////////////////////////////
while(file1.ReadString(strfile1))
{
strfile1.TrimRight();
indexofcmdtmp1 ;
if((indexofcmdtmp1>=indexofcmdtmp)&&(indexofcmdtmp1<indexofcmdtmp2))//
{
if(indexofcmdtmp1==indexofcmdtmp)
{
strfile1="相机:" strfile1;
}
strfile1 ="\r\n";
file2.WriteString(strfile1);
}
if(indexofcmdtmp1==indexofcmdtmp2)
{
file2.WriteString("\r\n");//每次写完一组加空行
file1.SeekToBegin();
indexofcmdtmp1=0;
break;
}
}
}
    //////////////////////////////////
file1.Close();
file2.Close();
}

void CFTZ1Dlg::SortCamCmd1()
{
CString strPath1,strPath2;
char path_buffer[_MAX_PATH]={0};
GetCurrentDirectory(sizeof(path_buffer),path_buffer);
strPath1=strPath2=path_buffer;
strPath1 ="\\CAMSORT.txt";
strPath2 ="\\CAMSORT1.txt";
////////////////////////////////
CStdioFile file1,file2;
if(!file1.Open(strPath1,CFile::modeRead|CFile::typeBinary))
{
AfxMessageBox(_T("CAMSORT.txt!打开失败"));
return ;
}
file1.SeekToBegin();
if(!file2.Open(strPath2,CFile::modeWrite|CFile::typeBinary))
{
AfxMessageBox(_T("CAMSORT1.txt!打开失败"));
return ;
}
file2.SetLength(0);
file2.SeekToBegin();
///////////////////////////////////
///////////////////////////////////
///////////////////////////////////
CString strfile1,strfile2;
CString strtmp;
unsigned int  nCombCnt=0;//当前comb中包含的item数目
CString strComb;
unsigned char i=0;
unsigned char j=0;
unsigned int  nLength=0;
unsigned char bSinglePost=0;
nCombCnt=m_Comb.GetCount();
//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////
    for(i=0;i<nCombCnt;i )
{
m_Comb.GetLBText(i,strComb);
loop1: while(file1.ReadString(strfile1))
{
strfile1.TrimRight();
strtmp=strfile1.Mid(0,4);
if(strtmp=="相机")//如果是相机
{
strtmp=strfile1.Mid(20,9);
if(strtmp==strComb)//找到匹配的命令
{
if(0==bSinglePost)
{
strfile1 ="\r\n";
file2.WriteString(strfile1);//写入相机命令
bSinglePost=1;
}
while(file1.ReadString(strfile1))
{
strfile1.TrimRight();
nLength=strfile1.GetLength();
strtmp=strfile1.Mid(0,4);
if((nLength!=0)&&(strtmp!="相机"))
{
strfile1 ="\r\n";
file2.WriteString(strfile1);
}
///////////////////////////////////////
                        if(nLength==0)//如果是空行
{
goto loop1;
}
}
}
}
}
///////////////////////////////////////////////
file2.WriteString("\r\n");
file1.SeekToBegin();
bSinglePost=0;
}
file1.Close();
file2.Close();
}

void CFTZ1Dlg::SortCamCmd2()
{
CString strPath1,strPath2;
char path_buffer[_MAX_PATH]={0};
GetCurrentDirectory(sizeof(path_buffer),path_buffer);
strPath1=strPath2=path_buffer;
strPath1 ="\\CAMSORT1.txt";
strPath2 ="\\CAMSORT2.txt";
///////////////////////////////////////
CStdioFile file1,file2,file3;
if(!file1.Open(strPath1,CFile::modeRead|CFile::typeBinary))
{
AfxMessageBox(_T("CAMSORT1.txt!打开失败"));
return ;
}
file1.SeekToBegin();
///////////////////////////////////////////////////////////
if(!file2.Open(strPath2,CFile::modeReadWrite|CFile::typeBinary))
{
AfxMessageBox(_T("CAMSORT2.txt!打开失败"));
return ;
}
file2.SetLength(0);
file2.SeekToBegin();
CString strfile1,strfile2,strfile3;
CString strtmp;
unsigned int nLength=0;
unsigned int nLength1=0;
unsigned char bFirstTimeFlag_2=0;
while(file1.ReadString(strfile1))
{
strfile1.TrimRight();
nLength=strfile1.GetLength();
strtmp=strfile1.Mid(0,4);
if(strtmp=="相机")
{
if(0==bFirstTimeFlag_2)
{
strfile2=strfile1;
strfile2 ="\r\n";
file2.WriteString(strfile2);
bFirstTimeFlag_2=1;
}
else
{
file2.WriteString("\r\n");
strfile2=strfile1;
strfile2 ="\r\n";
file2.WriteString(strfile2);
}

}
else if(nLength!=0)//连续读两条
{
file1.ReadString(strfile3);
strfile3.TrimRight();
nLength1=strfile3.GetLength();
if(0==nLength1)
{
strfile2=strfile1;
strfile2 ="\r\n";
file2.WriteString(strfile2);
//file2.WriteString("\r\n");
}
else
{
strfile2=strfile1;
strfile2 ="  ";
strfile2 =strfile3;
strfile2 ="\r\n";
file2.WriteString(strfile2);
}
}
else //如果是空行
{
// strfile2="\r\n";
// file2.WriteString(strfile2);
}
}
file1.Close();
file2.Close();
}
void CFTZ1Dlg::OnSelchangeCombo() 
{
// TODO: Add your control notification handler code here
CString strPath1;
unsigned int  nCombCnt=0;//当前comb中包含的item数目
unsigned int nCursel=0;
CString  CurCmd;
char path_buffer[_MAX_PATH]={0};
CStdioFile file1;
CString strfile1;
CString strtip;
CString strtmp;
unsigned int nLength=0;
GetCurrentDirectory(sizeof(path_buffer),path_buffer);
strPath1=path_buffer;
UpdateData(TRUE);
//////////////////////////
if(0==m_showlenorcam)
{
strPath1 ="\\CAMANDLENMSG_2.txt";
}
else
{
strPath1 ="\\CAMSORT2.txt";
}
nCombCnt=m_Comb.GetCount();
if(!file1.Open(strPath1,CFile::modeRead|CFile::typeBinary))
{
if(0==m_showlenorcam)
{
AfxMessageBox(_T("CAMANDLENMSG_2.txt!打开失败"));
}
else
{
AfxMessageBox(_T("CAMSORT2.txt!打开失败"));
}
return ;
}
file1.SeekToBegin();


/////////////////////////////
if(0!=nCombCnt)
{
nCursel=m_Comb.GetCurSel();
m_Comb.GetLBText(nCursel,CurCmd);
while(file1.ReadString(strfile1))
{
strtmp=strfile1.Mid(0,4);
if(strtmp=="相机")
{
strfile1.TrimRight();
strtmp=strfile1.Mid(20,9);
if(strtmp==CurCmd)//如果找到了对应的指令
{
break;
}
}

}
}
///////////////////////////
strtip=strfile1;
strtip ="\r\n";
while(file1.ReadString(strfile1))
{
strfile1.TrimRight();
nLength=strfile1.GetLength();
if(nLength!=0)
{
strtip =strfile1;
strtip ="\r\n";
}
else
{
m_tip.SetSel(0,-1);
m_tip.ReplaceSel(strtip);
break;
}
}

////////////////////////////
file1.Close();
}

void CFTZ1Dlg::OnTimer(UINT nIDEvent) 
{
// TODO: Add your message handler code here and/or call default
if(2==nIDEvent)
{
//更新系统时间
CTime tm=CTime::GetCurrentTime();
CString strTime;
strTime.Format("%02d:%02d:%02d",tm.GetHour(),tm.GetMinute(),tm.GetSecond());
m_StatusBar.SetPaneText(1,strTime,TRUE);
}
CDialog::OnTimer(nIDEvent);
}

UINT CFTZ1Dlg::OnNcHitTest(CPoint point) 
{
// TODO: Add your message handler code here and/or call default
UINT nHitTest=CDialog::OnNcHitTest(point);
return (nHitTest==HTCLIENT)?HTCAPTION:nHitTest;
}

void CFTZ1Dlg::OnBtnShoworhide() 
{
// TODO: Add your control notification handler code here
CRect rect1;
CString str;
str.Empty();
    m_hideorshow.GetWindowText(str);
str=str.Mid(0,2);
m_hideorshow.GetWindowRect(rect1);
if(">>"==str)
{
SetWindowPos(NULL,0,0,rect.Width(),rect.Height(),SWP_NOZORDER|SWP_NOMOVE);
m_hideorshow.SetWindowText("<<");
}
else
{
///////////////////////////////////
this->GetWindowRect(&rect);
        SetWindowPos(NULL,0,0,rect1.right-rect.left,rect.Height(),SWP_NOZORDER|SWP_NOMOVE);
m_hideorshow.SetWindowText(">>");
}
}
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
#define CRC16_ARC                0
#define CRC16_AUG_CCITT          1
#define CRC16_BUYPASS            2
#define CRC16_CCIT_ZERO          3
#define CRC16_CCITT_FALSE        4
#define CRC16_CDMA2000           5
#define CRC16_DDS_110            6
#define CRC16_DECT_R             7
#define CRC16_DECT_X             8
#define CRC16_DNP                9
#define CRC16_EN_13757           10
#define CRC16_GENIBUS            11
#define CRC16_KERMIT             12
#define CRC16_MAXIM              13
#define CRC16_MCRF4XX            14
#define CRC16_MODBUS             15
#define CRC16_T10_DIF            16
#define CRC16_TELEDISK           17
#define CRC16_USB                18
#define CRC16_X_25               19
#define CRC16_XMODEM             20
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
void CFTZ1Dlg::OnBtnCalc() 
{
// TODO: Add your control notification handler code here
unsigned int nCombCnt=0;
int nCurSel=-1;
unsigned int  i=0;
unsigned char bufCnt=0;
unsigned char buf[100]={0x00};
CString strcrcinput,strtmp,strres;
    unsigned int nLength=0;
m_CRCResult.SetWindowText("");
nCombCnt=m_CombCRC.GetCount();
nCurSel=m_CombCRC.GetCurSel();
m_CRCInput.GetWindowText(strcrcinput);
nLength=strcrcinput.GetLength();
m_Step.SetPos(0);
m_showprogress.SetWindowText("0");
UpdateData(TRUE);
if(nLength<2)
{
return;
}
bufCnt=(nLength 1)/3;//数组个数
for(i=0;i<bufCnt;i )
{
strtmp=strcrcinput.Mid(0,2);
buf[i]=_tcstoul(strtmp,0,16);
nLength=strcrcinput.GetLength();
if(i!=(bufCnt-1))
{
strcrcinput=strcrcinput.Mid(3,nLength-3);
}
}
unsigned short showhexvalue=0;
    unsigned short showhexvalue1=0;
unsigned short showhexvalue2=0;
unsigned short showhexvalue3=0;
unsigned short showhexvalue4=0;
unsigned short showhexvalue5=0;
unsigned int  j=0;
unsigned int  k=0;
unsigned int  nInitValue=0;
unsigned char m_ModeSel=0;
unsigned short Fitvalue=0;
CString  strfitvalue;
CString  strshow;
unsigned int textLength=0;

unsigned char buf1[100]={0x24,0x3C,0x08,0x00,0xB8,0x13,0x00,0x00,0x00,0x00,0xD6,0xBE};
unsigned char buf2[100]={0x24,0x3C,0x08,0x00,0xB8,0x13,0x00,0x00,0x00,0x00,0xD5,0xBE};
unsigned char buf3[100]={0x24,0x3C,0x08,0x00,0xB8,0x13,0x00,0x00,0x00,0x00,0xD4,0xBE};
unsigned char buf4[100]={0x24,0x3C,0x08,0x00,0xB8,0x13,0x00,0x00,0x00,0x00,0xD3,0xBE};
unsigned char buf5[100]={0x24,0x3C,0x08,0x00,0xB8,0x13,0x00,0x00,0x00,0x00,0xD2,0xBE};
m_fitvalue.GetWindowText(strfitvalue);
Fitvalue=_tcstoul(strfitvalue,0,16);

unsigned short Fitvalue1=0xEAB3;
unsigned short Fitvalue2=0xB9E6;
unsigned short Fitvalue3=0x88D5;
unsigned short Fitvalue4=0x1F4C;
unsigned short Fitvalue5=0x2E7F;
if(m_CheckAll.GetCheck())
{
nCurSel=0;
for(j=0;j<nCombCnt;j )
{
switch(nCurSel)
{
case CRC16_ARC://0
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_arc(nInitValue,buf,bufCnt);
showhexvalue1=crc16_arc(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_arc(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_arc(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_arc(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_arc(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(2);
m_showprogress.SetWindowText("2");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_arc_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_arc_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_arc_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_arc_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_arc_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_arc_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(5);
m_showprogress.SetWindowText("5");
goto LOOP1;
}
else
{
k ;
}
}
}
break; 
case CRC16_AUG_CCITT://1
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_aug_ccitt(nInitValue,buf,bufCnt);
showhexvalue1=crc16_aug_ccitt(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_aug_ccitt(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_aug_ccitt(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_aug_ccitt(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_aug_ccitt(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(7);
m_showprogress.SetWindowText("7");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_aug_ccitt_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_aug_ccitt_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_aug_ccitt_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_aug_ccitt_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_aug_ccitt_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_aug_ccitt_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(10);
m_showprogress.SetWindowText("10");
goto LOOP1;
}
else
{
k ;
}
}
}
break;

case CRC16_BUYPASS://2
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_buypass(nInitValue,buf,bufCnt);
showhexvalue1=crc16_buypass(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_buypass(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_buypass(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_buypass(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_buypass(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(12);
m_showprogress.SetWindowText("12");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_buypass_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_buypass_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_buypass_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_buypass_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_buypass_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_buypass_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(15);
m_showprogress.SetWindowText("15");
goto LOOP1;
}
else
{
k ;
}
}
}

break;

case CRC16_CCIT_ZERO://3
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_ccit_zero(nInitValue,buf,bufCnt);
showhexvalue1=crc16_ccit_zero(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_ccit_zero(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_ccit_zero(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_ccit_zero(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_ccit_zero(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(17);
m_showprogress.SetWindowText("17");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_ccit_zero_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_ccit_zero_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_ccit_zero_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_ccit_zero_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_ccit_zero_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_ccit_zero_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(20);
m_showprogress.SetWindowText("20");
goto LOOP1;
}
else
{
k ;
}
}
}

break;

case CRC16_CCITT_FALSE://4
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_ccitt_false(nInitValue,buf,bufCnt);
showhexvalue1=crc16_ccitt_false(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_ccitt_false(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_ccitt_false(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_ccitt_false(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_ccitt_false(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(22);
m_showprogress.SetWindowText("22");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_ccitt_false_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_ccitt_false_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_ccitt_false_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_ccitt_false_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_ccitt_false_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_ccitt_false_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(25);
m_showprogress.SetWindowText("25");
goto LOOP1;
}
else
{
k ;
}
}
}

break;
///////////////////////////////////////////////////
case CRC16_CDMA2000://5
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_cdma2000(nInitValue,buf,bufCnt);
showhexvalue1=crc16_cdma2000(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_cdma2000(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_cdma2000(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_cdma2000(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_cdma2000(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(27);
m_showprogress.SetWindowText("27");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_cdma2000_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_cdma2000_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_cdma2000_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_cdma2000_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_cdma2000_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_cdma2000_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(30);
m_showprogress.SetWindowText("30");
goto LOOP1;
}
else
{
k ;
}
}
}

break;
case CRC16_DDS_110://6
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_dds_110(nInitValue,buf,bufCnt);
showhexvalue1=crc16_dds_110(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_dds_110(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_dds_110(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_dds_110(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_dds_110(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(32);
m_showprogress.SetWindowText("32");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_dds_110_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_dds_110_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_dds_110_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_dds_110_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_dds_110_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_dds_110_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(35);
m_showprogress.SetWindowText("35");
goto LOOP1;
}
else
{
k ;
}
}
}

break;
case CRC16_DECT_R://7
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_dect_r(nInitValue,buf,bufCnt);
showhexvalue1=crc16_dect_r(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_dect_r(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_dect_r(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_dect_r(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_dect_r(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(37);
m_showprogress.SetWindowText("37");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_dect_r_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_dect_r_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_dect_r_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_dect_r_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_dect_r_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_dect_r_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(40);
m_showprogress.SetWindowText("40");
goto LOOP1;
}
else
{
k ;
}
}
}

break;
case CRC16_DECT_X://8
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_dect_x(nInitValue,buf,bufCnt);
showhexvalue1=crc16_dect_x(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_dect_x(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_dect_x(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_dect_x(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_dect_x(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(42);
m_showprogress.SetWindowText("42");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_dect_x_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_dect_x_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_dect_x_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_dect_x_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_dect_x_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_dect_x_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(45);
m_showprogress.SetWindowText("45");
goto LOOP1;
}
else
{
k ;
}
}
}

break;
case CRC16_DNP://9
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_dnp(nInitValue,buf,bufCnt);
showhexvalue1=crc16_dnp(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_dnp(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_dnp(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_dnp(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_dnp(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(47);
m_showprogress.SetWindowText("47");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_dnp_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_dnp_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_dnp_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_dnp_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_dnp_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_dnp_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(50);
m_showprogress.SetWindowText("50");
goto LOOP1;
}
else
{
k ;
}
}
}

break;
case CRC16_EN_13757://10
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_en_13757(nInitValue,buf,bufCnt);
showhexvalue1=crc16_en_13757(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_en_13757(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_en_13757(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_en_13757(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_en_13757(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(52);
m_showprogress.SetWindowText("52");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_en_13757_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_en_13757_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_en_13757_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_en_13757_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_en_13757_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_en_13757_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(55);
m_showprogress.SetWindowText("55");
goto LOOP1;
}
else
{
k ;
}
}
}

break;
case CRC16_GENIBUS://11
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_genibus(nInitValue,buf,bufCnt);
showhexvalue1=crc16_genibus(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_genibus(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_genibus(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_genibus(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_genibus(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(57);
m_showprogress.SetWindowText("57");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_genibus_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_genibus_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_genibus_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_genibus_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_genibus_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_genibus_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(60);
m_showprogress.SetWindowText("60");
goto LOOP1;
}
else
{
k ;
}
}
}

break;
case CRC16_KERMIT://12
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_kermit(nInitValue,buf,bufCnt);
showhexvalue1=crc16_kermit(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_kermit(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_kermit(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_kermit(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_kermit(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(62);
m_showprogress.SetWindowText("62");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_kermit_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_kermit_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_kermit_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_kermit_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_kermit_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_kermit_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(65);
m_showprogress.SetWindowText("65");
goto LOOP1;
}
else
{
k ;
}
}
}

break;
case CRC16_MAXIM://13
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_maxim(nInitValue,buf,bufCnt);
showhexvalue1=crc16_maxim(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_maxim(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_maxim(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_maxim(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_maxim(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(67);
m_showprogress.SetWindowText("67");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_maxim_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_maxim_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_maxim_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_maxim_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_maxim_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_maxim_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(70);
m_showprogress.SetWindowText("70");
goto LOOP1;
}
else
{
k ;
}
}
}

break;
case CRC16_MCRF4XX://14
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_mcrf4xx(nInitValue,buf,bufCnt);
showhexvalue1=crc16_mcrf4xx(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_mcrf4xx(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_mcrf4xx(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_mcrf4xx(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_mcrf4xx(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(72);
m_showprogress.SetWindowText("72");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_mcrf4xx_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_mcrf4xx_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_mcrf4xx_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_mcrf4xx_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_mcrf4xx_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_mcrf4xx_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(75);
m_showprogress.SetWindowText("75");
goto LOOP1;
}
else
{
k ;
}
}
}

break;
case CRC16_MODBUS://15
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_modbus(nInitValue,buf,bufCnt);
showhexvalue1=crc16_modbus(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_modbus(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_modbus(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_modbus(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_modbus(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(77);
m_showprogress.SetWindowText("77");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_modbus_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_modbus_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_modbus_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_modbus_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_modbus_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_modbus_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(80);
m_showprogress.SetWindowText("80");
goto LOOP1;
}
else
{
k ;
}
}
}

break;
case CRC16_T10_DIF://16
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_t10_dif(nInitValue,buf,bufCnt);
showhexvalue1=crc16_t10_dif(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_t10_dif(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_t10_dif(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_t10_dif(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_t10_dif(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(82);
m_showprogress.SetWindowText("82");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_t10_dif_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_t10_dif_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_t10_dif_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_t10_dif_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_t10_dif_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_t10_dif_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(85);
m_showprogress.SetWindowText("85");
goto LOOP1;
}
else
{
k ;
}
}
}

break;
case CRC16_TELEDISK://17
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_teledisk(nInitValue,buf,bufCnt);
showhexvalue1=crc16_teledisk(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_teledisk(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_teledisk(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_teledisk(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_teledisk(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(87);
m_showprogress.SetWindowText("87");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_teledisk_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_teledisk_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_teledisk_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_teledisk_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_teledisk_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_teledisk_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(90);
m_showprogress.SetWindowText("90");
goto LOOP1;
}
else
{
k ;
}
}
}

break;
case CRC16_USB://18
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_usb(nInitValue,buf,bufCnt);
showhexvalue1=crc16_usb(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_usb(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_usb(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_usb(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_usb(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(92);
m_showprogress.SetWindowText("92");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_usb_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_usb_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_usb_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_usb_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_usb_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_usb_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(95);
m_showprogress.SetWindowText("95");
goto LOOP1;
}
else
{
k ;
}
}
}

break;
case CRC16_X_25://19
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_x_25(nInitValue,buf,bufCnt);
showhexvalue1=crc16_x_25(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_x_25(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_x_25(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_x_25(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_x_25(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
m_Step.SetPos(97);
m_showprogress.SetWindowText("97");
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_x_25_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_x_25_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_x_25_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_x_25_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_x_25_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_x_25_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
m_Step.SetPos(100);
m_showprogress.SetWindowText("100");
goto LOOP1;
}
else
{
k ;
}
}
}

break;
case CRC16_XMODEM://20
for(k=0;k<=65535;)
{
nInitValue=k;
                    if(0==m_ModeSel)
{
showhexvalue=crc16_xmodem(nInitValue,buf,bufCnt);
showhexvalue1=crc16_xmodem(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_xmodem(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_xmodem(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_xmodem(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_xmodem(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=1;
k=0;
nInitValue=0;
}
else
{
k ;
}
}
else
{
nInitValue=k;
showhexvalue=crc16_xmodem_1(nInitValue,buf,bufCnt);
showhexvalue1=crc16_xmodem_1(nInitValue,buf1,bufCnt);
showhexvalue2=crc16_xmodem_1(nInitValue,buf2,bufCnt);
showhexvalue3=crc16_xmodem_1(nInitValue,buf3,bufCnt);
showhexvalue4=crc16_xmodem_1(nInitValue,buf4,bufCnt);
showhexvalue5=crc16_xmodem_1(nInitValue,buf5,bufCnt);
if((showhexvalue==Fitvalue)&&(showhexvalue1==Fitvalue1)&&(showhexvalue2==Fitvalue2)&&(showhexvalue3==Fitvalue3)&&(showhexvalue4==Fitvalue4)&&(showhexvalue5==Fitvalue5))
{
strres.Format("初始值为%d,第%d种校验,模式=%d",k,nCurSel,m_ModeSel);
textLength=m_CRCResult.GetWindowTextLength();
m_CRCResult.SetSel(textLength,textLength,FALSE);
m_CRCResult.ReplaceSel(strres);
return;
}
if(k==65535)
{
m_ModeSel=0;
goto LOOP1;
}
else
{
k ;
}
}
}

break;
}
LOOP1:
nCurSel ;
nInitValue=0;
}
m_CRCResult.SetWindowText("没有找到合适的值!");
}
else
{
switch(nCurSel)
{
case CRC16_ARC://0
if(m_radio_posorneg) //
{
showhexvalue=crc16_arc(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_arc_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_AUG_CCITT://1
if(m_radio_posorneg) //
{
showhexvalue=crc16_aug_ccitt(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_aug_ccitt_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_BUYPASS://2
if(m_radio_posorneg) //
{
showhexvalue=crc16_buypass(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_buypass_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_CCIT_ZERO://3
if(m_radio_posorneg) //
{
showhexvalue=crc16_ccit_zero(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_ccit_zero_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_CCITT_FALSE://4
if(m_radio_posorneg) //
{
showhexvalue=crc16_ccitt_false(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_ccitt_false_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_CDMA2000://5
if(m_radio_posorneg) //
{
showhexvalue=crc16_cdma2000(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_cdma2000_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_DDS_110://6
if(m_radio_posorneg) //
{
showhexvalue=crc16_dds_110(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_dds_110_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_DECT_R://7
if(m_radio_posorneg) //
{
showhexvalue=crc16_dect_r(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_dect_r_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_DECT_X://8
if(m_radio_posorneg) //
{
showhexvalue=crc16_dect_x(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_dect_x_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_DNP://9
if(m_radio_posorneg) //
{
showhexvalue=crc16_dnp(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_dnp_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_EN_13757://10
if(m_radio_posorneg) //
{
showhexvalue=crc16_en_13757(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_en_13757_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_GENIBUS://11
if(m_radio_posorneg) //
{
showhexvalue=crc16_genibus(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_genibus_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_KERMIT://12
if(m_radio_posorneg) //
{
showhexvalue=crc16_kermit(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_kermit_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_MAXIM://13
if(m_radio_posorneg) //
{
showhexvalue=crc16_maxim(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_maxim_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_MCRF4XX://14
if(m_radio_posorneg) //
{
showhexvalue=crc16_mcrf4xx(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_mcrf4xx_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_MODBUS://15
if(m_radio_posorneg) //
{
showhexvalue=crc16_modbus(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_modbus_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_T10_DIF://16
if(m_radio_posorneg) //
{
showhexvalue=crc16_t10_dif(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_t10_dif_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_TELEDISK://17
if(m_radio_posorneg) //
{
showhexvalue=crc16_teledisk(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_teledisk_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_USB://18
if(m_radio_posorneg) //
{
showhexvalue=crc16_usb(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_usb_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_X_25://19
if(m_radio_posorneg) //
{
showhexvalue=crc16_x_25(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_x_25_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

case CRC16_XMODEM://20
if(m_radio_posorneg) //
{
showhexvalue=crc16_xmodem(0,buf,bufCnt);

}
else
{
showhexvalue=crc16_xmodem_1(0,buf,bufCnt);
}
strres.Format("%04x",showhexvalue);
m_CRCResult.SetWindowText(strres);
break;

default:break;  
}
}
}

void CFTZ1Dlg::ClearFile()
{
CString strPath1,strPath2,strPath3,strPath4,strPath5,strPath6,strPath7,strPath8;
char path_buffer[_MAX_PATH]={0};
GetCurrentDirectory(sizeof(path_buffer),path_buffer);
strPath1=strPath2=path_buffer;
strPath3=strPath4=path_buffer;
strPath5=strPath6=path_buffer;
strPath7=strPath8=path_buffer;
/////////////////////////
strPath1 ="\\CAMANDLENMSG.txt";
strPath2 ="\\CAMANDLENMSG_1.txt";
strPath3 ="\\CAMANDLENMSG_2.txt";
strPath4 ="\\CAMMSG.txt";
strPath5 ="\\CAMSORT.txt";
strPath6 ="\\CAMSORT1.txt";
strPath7 ="\\CAMSORT2.txt";
strPath8 ="\\LENMSG.txt";

CStdioFile file1,file2,file3,file4,file5,file6,file7,file8;
if(!file1.Open(strPath1,CFile::modeReadWrite|CFile::typeBinary))
{
AfxMessageBox(_T("CAMANDLENMSG.txt!打开失败"));
return ;
}
file1.SetLength(0);
///////////////////////////////
if(!file2.Open(strPath2,CFile::modeReadWrite|CFile::typeBinary))
{
AfxMessageBox(_T("CAMANDLENMSG_1.txt!打开失败"));
return ;
}
file2.SetLength(0);
/////////////////////////////////////
if(!file3.Open(strPath3,CFile::modeReadWrite|CFile::typeBinary))
{
AfxMessageBox(_T("CAMANDLENMSG_2.txt!打开失败"));
return ;
}
file3.SetLength(0);
//////////////////////////////////////
if(!file4.Open(strPath4,CFile::modeReadWrite|CFile::typeBinary))
{
AfxMessageBox(_T("CAMMSG.txt!打开失败"));
return ;
}
file4.SetLength(0);
//////////////////////////////////////
if(!file5.Open(strPath5,CFile::modeReadWrite|CFile::typeBinary))
{
AfxMessageBox(_T("CAMSORT.txt!打开失败"));
return ;
}
file5.SetLength(0);
////////////////////////////////////////
if(!file6.Open(strPath6,CFile::modeReadWrite|CFile::typeBinary))
{
AfxMessageBox(_T("CAMSORT1.txt!打开失败"));
return ;
}
file6.SetLength(0);
//////////////////////////////
if(!file7.Open(strPath7,CFile::modeReadWrite|CFile::typeBinary))
{
AfxMessageBox(_T("CAMSORT2.txt!打开失败"));
return ;
}
file7.SetLength(0);
////////////////////////////////
if(!file8.Open(strPath8,CFile::modeReadWrite|CFile::typeBinary))
{
AfxMessageBox(_T("LENMSG.txt!打开失败"));
return ;
}
file8.SetLength(0);

file1.Close();
file2.Close();
file3.Close();
file4.Close();
file5.Close();
file6.Close();
file7.Close();
file8.Close();
}



标签: 提取 软件 协议

实例下载地址

尼康Z转接协议提取软件

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警