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

📄 xmlgeneratedlg.cpp

📁 生成关于EPG的XML文档工具
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// XMLGENERATEDlg.cpp : implementation file
//

#include "stdafx.h"
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include "XmlEPG.h"
#include "XmlEncapsulate.h"
#include "XMLGENERATE.h"
#include "XMLGENERATEDlg.h"
#include "ChannelDlg.h"

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

// Global Variables
char PhyName[PHYSICAL_CHANNEL_ARRY_LENGTH][MAX_LENGTH]; // physical name array
char DigNameTag[DIGITAL_PROGRAM_ARRY_LENGTH][MAX_LENGTH]; // digital name array
char ProNameTag[EPG_PROGRAM_ARRY_LENGTH][MAX_LENGTH]; // program name array
char BookedTag[BOOKED_MAX][MAX_LENGTH]; // booked name array
NET_INFO pNetwork[NET_WORK_NUMBER];           // network info , this version only permit singgle network
PHYSICAL_CHANNAL pPhysicalChannel[PHYSICAL_CHANNEL_ARRY_LENGTH]; // physical channel array
DIGITAL_PGROGRAM pDigitalProgram[DIGITAL_PROGRAM_ARRY_LENGTH];  // digital program array
EPGPROGRAM pEPGProgram[EPG_PROGRAM_ARRY_LENGTH];  // digital program info
ProgramIndex prgInd[Max_Program_Type];    // FASTLIST table
Cur_Prg_Info CurPrg;  // Current program information
BOOKED_EVENT bookedEvt[BOOKED_MAX];  // booking record saving

const char* EpgFileName = "EPG.xml";   // Xml File name
HANDLE b;
int DigChanSum;
int ProgramSum;
int BookedSum;

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

/////////////////////////////////////////////////////////////////////////////
// CXMLGENERATEDlg dialog

CXMLGENERATEDlg::CXMLGENERATEDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CXMLGENERATEDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CXMLGENERATEDlg)
	m_strProgramNumber = _T("");
	m_strCurtype = _T("");
	m_strBroadcastNumber = _T("");
	m_strVideoNumber = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CXMLGENERATEDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CXMLGENERATEDlg)
	DDX_Control(pDX, IDC_COMBO_VideoNumber, m_ctrVideoNumber);
	DDX_Control(pDX, IDC_COMBO_BroadcastNumber, m_ctrBroadcastNumber);
	DDX_Control(pDX, IDC_BUTTON_Transfer, m_bntTansfer);
	DDX_Control(pDX, IDC_COMBO_ProgramNumber, m_ctrProgramNumber);
	DDX_Control(pDX, IDC_BUTTON_Channel, m_bntChannel);
	DDX_CBString(pDX, IDC_COMBO_ProgramNumber, m_strProgramNumber);
	DDX_Text(pDX, IDC_EDIT_CurType, m_strCurtype);
	DDX_CBString(pDX, IDC_COMBO_BroadcastNumber, m_strBroadcastNumber);
	DDX_CBString(pDX, IDC_COMBO_VideoNumber, m_strVideoNumber);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CXMLGENERATEDlg, CDialog)
	//{{AFX_MSG_MAP(CXMLGENERATEDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON_Channel, OnBUTTONChannel)
	ON_BN_CLICKED(IDC_BUTTON_LOAD, OnButtonLoad)
	ON_BN_CLICKED(IDC_BUTTON_Transfer, OnBUTTONTransfer)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CXMLGENERATEDlg message handlers

BOOL CXMLGENERATEDlg::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);
		}
	}

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

	for( int j = 2; j <= 20; j++ )
	{
		CString cj;
		int zero = 0;
		if( j < 10 )
		{
			cj.Format( "%d%d", zero, j );
		}
		else
		{
			cj.Format( "%d", j );
		}
		m_ctrVideoNumber.AddString( (LPCTSTR)cj );
	}

	for( int k = 2; k <= 10; k++ )
	{
		CString ck;
		int zero = 0;
		if( k < 10 )
		{
			ck.Format( "%d%d", zero, k );
		}
		else
		{
			ck.Format( "%d", k );
		}
		m_ctrBroadcastNumber.AddString( (LPCTSTR)ck );
	}
	
	for( int i = 4; i <= 12; i++ )
	{
		CString ci;
		int zero = 0;
		if( i < 10 )
		{
			ci.Format( "%d%d", zero, i );
		}
		else
		{
			ci.Format( "%d", i );
		}
		m_ctrProgramNumber.AddString( (LPCTSTR)ci );
	}

	m_ctrBroadcastNumber.SetCurSel( 3 );
    m_ctrVideoNumber.SetCurSel( 8 );
	m_ctrProgramNumber.SetCurSel( 4 );
	m_bntChannel.EnableWindow( FALSE );
	m_bntTansfer.EnableWindow( FALSE );

	return TRUE;  // return TRUE  unless you set the focus to a control
}

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

int CXMLGENERATEDlg::TagInit()
{
	UpdateData( TRUE );
	DigChanSum = atoi( (LPCTSTR)m_strBroadcastNumber ) + atoi( (LPCTSTR)m_strVideoNumber );
	ProgramSum = DigChanSum * 7 * atoi( (LPCTSTR)m_strProgramNumber );
	BookedSum = 5;
	if( BookedSum > ProgramSum )
	{
		BookedSum = ProgramSum;
	}

	char temp1[5];
	for( int k = 1; k <= PHYSICAL_CHANNEL_ARRY_LENGTH; k++ )
	{
		char temp[20] = "Phy";
		_itoa( k, temp1, 10 );
	    strcat( temp, temp1 );
		strcpy( PhyName[k - 1], temp );
	}
	for( int i = 1; i <= DigChanSum; i++ )
	{
		char temp[20] = "Dig";
		_itoa( i, temp1, 10 );
	    strcat( temp, temp1 );
		strcpy( DigNameTag[i - 1], temp );
	}
	for( int j = 1; j <= ProgramSum; j++ )
	{
		char temp[20] = "Pro";
		_itoa( j, temp1, 10 );
	    strcat( temp, temp1 );
		strcpy( ProNameTag[j - 1], temp );
	}	
	for( int m = 1; m <= BookedSum; m++ )
	{
		char temp[20] = "Book";
		_itoa( m, temp1, 10 );
	    strcat( temp, temp1 );
		strcpy( BookedTag[m - 1], temp );
	}
	return TRUE;
}

void CXMLGENERATEDlg::StructInit()
{
	srand( (unsigned)time( NULL ) );

/**************************** NET_INFO ****************************/
	pNetwork[0].iNetId = 0x0011;
	const char* NetNameTemp = "NET";
	strcpy( pNetwork[0].acNetworkName, NetNameTemp );
	pNetwork[0].iPhyChannelNumber = 0x0002;
	pNetwork[0].iFirstPhyIndex = 0x0001;
	pNetwork[0].iPhyNumWhenSearch = 2;
	pNetwork[0].ucflag = '1';
	pNetwork[0].ucCrc = 123;

/************************* PHYSICAL_CHANNAL ***********************/

	pPhysicalChannel[0].iTsId = 0x0011;
	pPhysicalChannel[0].iNetInfoAddress = '0';
	pPhysicalChannel[0].dwFrequency = 1000;
	pPhysicalChannel[0].dwRateOfSym = 4;
	pPhysicalChannel[0].byQamStyle = '2';
	pPhysicalChannel[0].iProgramNum = '1';
	pPhysicalChannel[0].iNextChannel = 0x0002;	
	pPhysicalChannel[0].iFirstProIndex = 0x0001;
	pPhysicalChannel[0].iLastProIndex = 0x0001;
	pPhysicalChannel[0].iSerNumWhenSearch = 0x0001;
	pPhysicalChannel[0].ucFlag = '4';

	pPhysicalChannel[1].iTsId = 0x0012;
	pPhysicalChannel[1].iNetInfoAddress = '0';
	pPhysicalChannel[1].dwFrequency = 5000;
	pPhysicalChannel[1].dwRateOfSym = 2;
	pPhysicalChannel[1].byQamStyle = '2';
	pPhysicalChannel[1].iProgramNum = '3';
	pPhysicalChannel[1].iNextChannel = 0x0002;	
	pPhysicalChannel[1].iFirstProIndex = 0x0002;
	pPhysicalChannel[1].iLastProIndex = 0x0004;
	pPhysicalChannel[1].iSerNumWhenSearch = 0x0003;
	pPhysicalChannel[1].ucFlag = '3';

⌨️ 快捷键说明

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