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

📄 fits_mfcdlg.cpp

📁 本源码是一个用于卫星数据处理的程序
💻 CPP
字号:
// Fits_mfcDlg.cpp : implementation file
//

#include <stdio.h>
#include "stdafx.h"
#include <string>
#include "Fits_mfc.h"
#include "Fits_mfcDlg.h"
#include "Fits.h"
#include "root.h"

#include "ccsds_pro.h"
#include "ccsds.h"
#include "hxmt_file.h"


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

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

std::string product_dest_dir;
std::string data_move_dest_dir;
std::string data_resource_dir;
time_t		global_time_offset;
std::string archfile;
FILE *		arch_filep;

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

/////////////////////////////////////////////////////////////////////////////
// CFits_mfcDlg dialog

CFits_mfcDlg::CFits_mfcDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CFits_mfcDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFits_mfcDlg)
	m_strFolder = _T("");
	m_strFolderGds = _T("");
	m_strFolderSci = _T("");
	m_strFolderFz = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CFits_mfcDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFits_mfcDlg)
	DDX_Text(pDX, IDC_EDIT4, m_strFolder);
	DDX_Text(pDX, IDC_EDIT6, m_strFolderGds);
	DDX_Text(pDX, IDC_EDIT8, m_strFolderSci);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CFits_mfcDlg, CDialog)
	//{{AFX_MSG_MAP(CFits_mfcDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_BN_CLICKED(IDC_BTN_CCSDC_PRO, OnBtnCcsdcPro)
	ON_BN_CLICKED(IDC_BTN_SCI, OnBtnSci)
	ON_BN_CLICKED(IDC_BTN_NSD, OnBtnNsd)
	ON_BN_CLICKED(IDC_BTN_R1, OnBtnR1)
	ON_BN_CLICKED(IDC_BTN_EXIT, OnBtnExit)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFits_mfcDlg message handlers

BOOL CFits_mfcDlg::OnInitDialog()
{

//	struct tm time;
//	memset(&time, 0, sizeof(time));
//	time.tm_year = 110;
//	time.tm_mday = 1;
//	time_t t = mktime(&time);
	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);
		}
	}

	// 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_strFolder="E:\\";
	m_strFolderSci="E:\\intern6\\";
	m_strFolderGds = "E:\\intern5\\";
//	m_strFolder="Z:\\level1\\";
//	m_strFolderSci="Z:\\TEMP\\";
//	m_strFolderGds = "Z:\\intern5\\";

	UpdateData(FALSE);
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CFits_mfcDlg::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.

void CFits_mfcDlg::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();
	}
}

/*************************************************************************
                       以下是对路径的设置
**************************************************************************/
void CFits_mfcDlg::OnBtnR1() //设置1级产品存放根路径
{
	if(g_fSelectFolderDlg(&m_strFolder, m_strFolder, false))
	{
		UpdateData(false);
	}
	
}

void CFits_mfcDlg::OnBtnSci() //设置待处理的科学数据文件存放路径
{
	if(g_fSelectFolderDlg(&m_strFolderSci, m_strFolderSci, false))
	{
		UpdateData(false);
	}
	
}


void CFits_mfcDlg::OnBtnNsd() //设置科学数据文件归档路径
{
	if(g_fSelectFolderDlg(&m_strFolderGds, m_strFolderGds, false))
	{
		UpdateData(false);
	}
	
}

//////////////////////////////////////////////////////////////////////////
void CFits_mfcDlg::OnBtnExit()  //退出应用程序
{
	if ( AfxMessageBox("确定要退出程序吗?",MB_YESNO) == IDNO )
    return; 
	CDialog::OnCancel();
}


void CFits_mfcDlg::OnBtnCcsdcPro() 
{
	UpdateData();//false initial,ture retrieve
	product_dest_dir = (LPCSTR)m_strFolder;
	data_move_dest_dir = (LPCSTR)m_strFolderGds;
	data_resource_dir = (LPCSTR)m_strFolderSci;

	if( product_dest_dir.length() < 2 ) {
		AfxMessageBox( "产品保存目录错误!!!" );
		return;
	}
	if( data_move_dest_dir.length() < 2 ) {
		AfxMessageBox( "搬移目录错误 !!" );
		return;
	}
	if(!FileExist(data_resource_dir.c_str()))
	{
		AfxMessageBox("待处理数据文件所在目录错误!");
		return;
	}



/********************设置时间零点global_time_offset******************/
	char T0filename[128];
	char t0fromfile[32];
	CStdioFile t0file;
	int nYear, nMonth, nDay, nHour, nMin, nSec;
	strcpy(T0filename, "TWt0.txt");
	if(!t0file.Open(T0filename, CFile::modeRead))
	   return;
	int lread=t0file.Read(t0fromfile, 32);
	t0fromfile[lread]='\0';
	CString strt0 = t0fromfile;
	sscanf(strt0, "%d-%d-%d.%d:%d:%d", &nYear, &nMonth, &nDay, &nHour, &nMin, &nSec);
//	CTime t0(nYear, nMonth, nDay, nHour, nMin, nSec);
	t0file.Close();
//	time_t t = t0.GetTime();
	global_time_offset = 0;
	
//	if( !CreateFilePath((LPCSTR)product_dest_dir.c_str()) ) {
//		AfxMessageBox("一级产品保存根目录错误");
//		return;
//	}
	CreateFilePath((LPCSTR)product_dest_dir.c_str());//(LPCSTR == const char *)
	GetDlgItem(IDC_BTN_CCSDC_PRO)->EnableWindow( FALSE );
	GetDlgItem(IDC_BTN_EXIT)->EnableWindow(FALSE);

	archfile = product_dest_dir + "arch.id";
	if( !CreateFilePath(archfile.c_str()) || (arch_filep = fopen(archfile.c_str(),"a+")) == NULL) {
		archfile += " Create Failed!!";
		AfxMessageBox( archfile.c_str() );
		return;
	}

	if( 0 != load_hxmt_files(m_strFolderSci) )	{
		AfxMessageBox("缺少源文件,不能生成fits文件!");
	}

	fclose(arch_filep);
	
	GetDlgItem(IDC_BTN_CCSDC_PRO)->EnableWindow( TRUE );
	GetDlgItem(IDC_BTN_EXIT)->EnableWindow(TRUE);
	
		
	return;

}

⌨️ 快捷键说明

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