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

📄 coderdlg.cpp

📁 This is project for code/decode date in residue number system
💻 CPP
字号:
// CoderDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Coder.h"
#include "CoderDlg.h"
#include "Math.h"
//#include "Function.h"

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

CFile Bazuss;
byte* array=new byte[1000];
byte* data;

const char bBDCLength=70;
const char bBDCShort=7;
char bNumber=0;

char* pBDCNumber1=new char [bBDCLength];
char* pBDCNumber2=new char [bBDCLength];
char* pNumber1=new char[bBDCLength];
char* pNumber2=new char[bBDCLength];
char* pBDCRo=new char [bBDCLength];
char* pBDCA=new char [bBDCLength];
char* pBDCData=new char [bBDCShort];
char* pBDCBazus[10];
char* pBDCModuls[10];

short ConvertToBDC(char* pBDCNum,int iNumber=0,char bLength=bBDCLength);
double ConvertToDecimalFromBDC(char* pBDCNumber);
short Sum(char* pNumber1, char* pNuber2, char* pResult, char bRang);
short Sub(char* pNumber1, char* pNuber2, char* pResult, char bRang);
short Mul(char* pNumber1, char* pNuber2, char* pResult, char bRang);
short Div(char* pNumber1, char* pNuber2, char* pResult, char* pZal, char bRang);
short CompareBDC(char* pNumber1, char* pNumber2,char bPosition1,char bPosition2);
short FindRo(char* pBDCRO);
short FindModuls();
short FindBazus();
short FindA(char* pBDCA);
int Print_To_File (char* pBinary);





BOOL bThreadStart=TRUE;
CEvent g_Thread_Ready;
CEvent g_Thread_Clear;
CEvent g_Thread_End;
CEvent g_Thread_Running;
CEvent g_Thread_Start;
CEvent g_Thread_Stop;
CWinThread* pThread;

unsigned int m_nTime=0;
unsigned int m_nTime_2=0;
unsigned long m_lSpeed=1;
unsigned long FileSize=0;
unsigned long length=0;

CString str_timerr, str_timerr_2;
CString* m_pFileIn;
CString* m_pFileOut;

float timerr=0;
int* pPointer=0;
//int m_nArray[15];
//unsigned long double bazu[10];
//unsigned long double ro=1;

//unsigned long double Ostacha(unsigned long double first, unsigned long double second);
//int Zalushok(unsigned long double num1, unsigned long num2);
char* Find_A(byte *data,unsigned long FileSize,char* pBinaryRo, char* pA,char** pBazus);
//int Size_A(unsigned long double A);
int Bazus (const char& bNumberOfKeys, char* pBinaryRo, char** pBazus, char** pKeys);


/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

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()

/////////////////////////////////////////////////////////////////////////////
// CCoderDlg dialog

CCoderDlg::CCoderDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CCoderDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CCoderDlg)
	m_nRadio_Coder = 0;
	m_dSpin = 2;
	m_nKey_1 = 0;
	m_nKey_2 = 0;
	m_nKey_3 = 0;
	m_nKey_4 = 0;
	m_nKey_5 = 0;
	m_nKey_6 = 0;
	m_nKey_7 = 0;
	m_nKey_8 = 0;
	m_nKey_9 = 0;
	m_nKey_10 = 0;
	m_strFileOutput = _T("");
	m_strFileInput = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CCoderDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCoderDlg)
	DDX_Text(pDX, IDC_EDIT_NUMBER_OF_KEYS, m_dSpin);
	DDV_MinMaxInt(pDX, m_dSpin, 0, 10);
	DDX_Radio(pDX, IDC_RADIO_CODER, m_nRadio_Coder);
	DDX_Text(pDX, IDC_EDIT_KEY_1, m_nKey_1);
	DDX_Text(pDX, IDC_EDIT_KEY_10, m_nKey_10);
	DDX_Text(pDX, IDC_EDIT_KEY_2, m_nKey_2);
	DDX_Text(pDX, IDC_EDIT_KEY_3, m_nKey_3);
	DDX_Text(pDX, IDC_EDIT_KEY_4, m_nKey_4);
	DDX_Text(pDX, IDC_EDIT_KEY_5, m_nKey_5);
	DDX_Text(pDX, IDC_EDIT_KEY_6, m_nKey_6);
	DDX_Text(pDX, IDC_EDIT_KEY_7, m_nKey_7);
	DDX_Text(pDX, IDC_EDIT_KEY_8, m_nKey_8);
	DDX_Text(pDX, IDC_EDIT_KEY_9, m_nKey_9);
	DDX_Text(pDX, IDC_OUTPUTFILEPATHE, m_strFileOutput);
	DDX_Text(pDX, IDC_INPUTFILEPATHE, m_strFileInput);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CCoderDlg, CDialog)
	//{{AFX_MSG_MAP(CCoderDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_DESTROY()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_INPUTDIR, OnInputdir)
	ON_BN_CLICKED(IDC_OUTPUTDIR, OnOutputdir)
	ON_WM_VSCROLL()
	ON_WM_TIMER()
	ON_BN_CLICKED(IDCLEAR, OnClear)
	ON_BN_CLICKED(IDEXIT, OnExit)
	ON_WM_CLOSE()
	ON_BN_CLICKED(IDC_OK, OnOk)
	ON_MESSAGE(WM_ENDTHREAD,OnEndThread)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCoderDlg message handlers

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

void CCoderDlg::OnDestroy()
{
	WinHelp(0L, HELP_QUIT);
	CDialog::OnDestroy();
}

// 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.

void CCoderDlg::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);
		CRect rect;
		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 CCoderDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CCoderDlg::OnInputdir() 
{
	CFileDialog dlg(TRUE, "", "*.*");	
	if (dlg.DoModal() == IDOK) 
	{
		CFile file;
		SetDlgItemText(IDC_INPUTFILEPATHE, dlg.GetPathName());
	}
}

void CCoderDlg::OnOutputdir() 
{
	CFileDialog dlg(FALSE, "", "*.*");	
	if (dlg.DoModal() == IDOK) 
	{
		CFile file;
		SetDlgItemText(IDC_OUTPUTFILEPATHE, dlg.GetPathName());
	}
}

void CCoderDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	if(nSBCode==SB_ENDSCROLL)
	{
		return;
	}
	if(pScrollBar->GetDlgCtrlID()==IDC_SPIN_NUMBER_OF_KEYS)
	{
		CString strValue;
		if(nPos<2)
		{
			nPos=2;
		}
		strValue.Format("%d",nPos);
		((CSpinButtonCtrl*)pScrollBar)->GetBuddy()->SetWindowText(strValue);
		CEdit* edit;
		if(m_nFlag <= nPos)
		{
			edit=(CEdit*)GetDlgItem(nPos+1018);
			edit->EnableWindow(TRUE);
			m_nFlag=nPos;
		}
		else
		{
			if(m_nFlag!=2)
			{
				edit=(CEdit*)GetDlgItem(m_nFlag+1018);
				edit->SetWindowText("0");
				edit->EnableWindow(FALSE);
				m_nFlag=nPos;
			}
		}
	}
}


UINT ProcThreadProc(LPVOID pParam)
{
	::WaitForSingleObject(g_Thread_Start,INFINITE);
	g_Thread_Running.SetEvent();
	g_Thread_Ready.ResetEvent();
	int m_IDC[18]={1000,1001,1002,1003,1004,1005,1008,1009,1010,
					1020,1021,1022,1023,1024,1025,1026,1027,1028};
	length=0;
	long index=0;
//	byte* array=0;
//	array=new byte[100000];
	int cycl=0, choise=0;
	int* p=0;
	long double temp=0;
	p=pPointer;

	for(int j=0;j<18;j++)
	{
		::EnableWindow(::GetDlgItem((HWND)pParam,m_IDC[j]),FALSE);
	}

	HANDLE hFile = ::CreateFile((CString)*(m_pFileIn), GENERIC_READ,	
		FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	ASSERT(hFile!=NULL);
	HANDLE hMap = ::CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
	ASSERT(hMap!=NULL);
	LPVOID lpvFile = ::MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0); // 耧痤弼桊钼囹

⌨️ 快捷键说明

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