⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rewview.cpp

📁 可将华为设备信令跟踪二进制文件进行解码并输出文本文件。
💻 CPP
字号:
// REWView.cpp : implementation of the CREWView class
//

#include "stdafx.h"
#include "REW.h"

#include "REWDoc.h"
#include "REWView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CREWView

IMPLEMENT_DYNCREATE(CREWView, CFormView)

BEGIN_MESSAGE_MAP(CREWView, CFormView)
	//{{AFX_MSG_MAP(CREWView)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CREWView construction/destruction

CREWView::CREWView()
	: CFormView(CREWView::IDD)
{
	//{{AFX_DATA_INIT(CREWView)
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CREWView::~CREWView()
{
}

void CREWView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CREWView)
	DDX_Control(pDX, IDC_EDIT1, m_edit);
	DDX_Control(pDX, IDC_PROGRESS1, m_progress);
	//}}AFX_DATA_MAP
}

BOOL CREWView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CFormView::PreCreateWindow(cs);
}

void CREWView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();

}

/////////////////////////////////////////////////////////////////////////////
// CREWView printing

BOOL CREWView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CREWView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CREWView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

void CREWView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
	// TODO: add customized printing code here
}

/////////////////////////////////////////////////////////////////////////////
// CREWView diagnostics

#ifdef _DEBUG
void CREWView::AssertValid() const
{
	CFormView::AssertValid();
}

void CREWView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}

CREWDoc* CREWView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CREWDoc)));
	return (CREWDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CREWView message handlers

void CREWView::OnButton1() 
{
	// TODO: Add your control notification handler code here

	CStdioFile* m_read;
	CStdioFile* m_write;
	CString string,opc,dpc,called,calling;
	CString temp,path;
	int length,time,odd,cursor;
	int length_t,progress,percent;
	long cursor_t=0;

	

	percent=0;

	CFileDialog dlg(TRUE,NULL,"",OFN_HIDEREADONLY,"文本文件(*.txt)|*.txt",NULL);
	dlg.m_ofn.lpstrInitialDir= "d:\\";
	if(dlg.DoModal()==IDOK)
	{
	path=dlg.GetPathName();
	}
	else
		return;
		
	CREWView::RedrawWindow();
	m_read= new CStdioFile(path , CFile::modeRead | CFile::typeText);
	if (!m_read)	{
			AfxMessageBox("该文件打开错");
			return ;}	




	m_write	= new CStdioFile("D:\\output.txt",CFile::modeCreate | CFile::modeWrite | CFile::typeText);
	if (!m_write)	{
			AfxMessageBox("临时文件打开错");
			return ;}	

	m_read->Seek(0,CFile::begin);
	m_read->ReadString(string);



//***********************  TUP  ***************************

	if(string.GetAt(1)=='T')
	{
	
	m_read->Seek(0,CFile::begin);
	length_t=m_read->GetLength();
	
	while(length_t>cursor_t)
	{

	called="";
	calling="";
	m_read->ReadString(string);

	opc=string.Mid(48,6);
	dpc=string.Mid(56,6);


	//***************************called****************************

	length=string.GetAt(70);
	if(length>=65)
		length=length-55;
	else
		length=length-48;

	if(length % 2 ==0)
	{
		time = length /2;
		odd=0;
	}
	else
	{
		time = (length + 1) /2;
		odd=1;
	}

	for(int i=0;i<time-1;i++)
	
		called = called +  string.Mid(74+3*i,1) + string.Mid(73+3*i,1);

	if(odd==1)

		called = called +  string.Mid(74+3*i,1);

	else

		called = called +  string.Mid(74+3*i,1) + string.Mid(73+3*i,1);

	//***************************calling****************************

	cursor=73+3*(time+1);

	length=string.GetAt(cursor);

	if(length>=65)
		length=length-55;
	else
		length=length-48;


	if(length % 2 ==0)
	{
		time = length /2;
		odd=0;
	}
	else
	{
		time = (length + 1) /2;
		odd=1;
	}

	for(i=0;i<time-1;i++)
	
		calling = calling +  string.Mid(4+3*i+cursor,1) + string.Mid(4+3*i+cursor-1,1);

	if(odd==1)

		calling = calling +  string.Mid(4+3*i+cursor,1);

	else

		calling = calling +  string.Mid(4+3*i+cursor,1) + string.Mid(4+3*i+cursor-1,1);

	length=calling.GetLength();
	if(calling.GetAt(length-1)=='F')
		calling.SetAt(length-1,0);


	CString temp1;
	temp1=opc+" "+dpc+" "+called+" "+calling;

	m_write->WriteString(temp1);	
	m_write->WriteString("\n");

	cursor_t=m_read->GetPosition();
	progress=cursor_t*100/length_t;
	CString t1;


	if(progress>=percent)
	{
	m_progress.SetPos(progress);
	m_edit.SetSel(0,6,FALSE);
	t1.Format("%i%",progress);
	m_edit.ReplaceSel(t1,FALSE);	
	++percent;
	}


	

	}

	}

	//****************************** ISUP ******************************

	else
	{

	m_read->Seek(0,CFile::begin);
	length_t=m_read->GetLength();
	
	while(length_t>cursor_t)
	{

	called="";
	calling="";
	m_read->ReadString(string);

	opc=string.Mid(48,6);
	dpc=string.Mid(56,6);


	//***************************called****************************

	length=string.GetAt(86);
	if(length>=65)
		length=length-55;
	else
		length=length-48;

	if(string.GetAt(88)>=8)
		odd=1;
	else
		odd=0;

	for(int i=0;i<length-2;i++)
	
		called = called +  string.Mid(95+3*i,1) + string.Mid(94+3*i,1);

	if(odd==1)

		called.SetAt(called.GetLength()-1,32);


	//***************************calling****************************


	i=0;

	while(string.Mid(86+3*length+1+3*i,3)!=" 0A")
		++i;

	cursor=86+3*length+1+3*i+5;

	length=string.GetAt(cursor);
	

	if(length>=65)
		length=length-55;
	else
		length=length-48;


	if(string.GetAt(cursor+2)>=8)
		odd=1;
	else
		odd=0;


	for(i=0;i<length-2;i++)
	
		calling = calling +  string.Mid(cursor+9+3*i,1) + string.Mid(cursor+8+3*i,1);

	if(odd==1)

		calling.SetAt(calling.GetLength()-1,0);



	CString temp1;
	temp1=opc+" "+dpc+" "+called+" "+calling;
	

	m_write->WriteString(temp1);
	m_write->WriteString("\n");

	cursor_t=m_read->GetPosition();
	progress=cursor_t*100/length_t;
	CString t1;


	if(progress>=percent)
	{
	m_progress.SetPos(progress);
	m_edit.SetSel(0,6,FALSE);
	t1.Format("%i%",progress);
	m_edit.ReplaceSel(t1,FALSE);	
	++percent;
	}

	}


}



	m_read->Close();
	m_write->Close();
	AfxMessageBox("完成!");

	

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -