// DlgDomeUpdate.cpp : implementation file // #include "stdafx.h" #include "udpadmintool.h" #include "DlgDomeUpdate.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // DlgDomeUpdate dialog CDlgDomeUpdate::CDlgDomeUpdate(CWnd* pParent /*=NULL*/) : CDialog(CDlgDomeUpdate::IDD, pParent) { //{{AFX_DATA_INIT(DlgDomeUpdate) m_sEdSelectDevice = _T(""); m_richLog = _T(""); m_bChkSkip = FALSE; //}}AFX_DATA_INIT } void CDlgDomeUpdate::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(DlgDomeUpdate) DDX_Control(pDX, IDC_PROGRESS_UP, m_prUp); DDX_Text(pDX, IDC_EDIT_SELECT_IP, m_sEdSelectDevice); DDX_Text(pDX, IDC_RICHEDIT_LOG, m_richLog); DDX_Check(pDX, IDC_CHECK_SKIP, m_bChkSkip); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CDlgDomeUpdate, CDialog) //{{AFX_MSG_MAP(DlgDomeUpdate) ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse) ON_BN_CLICKED(IDC_BUTTON_UPDATE, OnButtonUpdate) ON_BN_CLICKED(IDC_BUTTON_CANCEL, OnButtonCancel) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // DlgDomeUpdate message handlers void CDlgDomeUpdate::OnButtonBrowse() { // TODO: Add your control notification handler code here // dome bin file CString path; GetDlgItem(IDC_STATIC_FILE)->GetWindowText(path); char szFilter[30]; sprintf(szFilter, "IMAGE File|*.bin||"); CFileDialog dlgOpen(TRUE, NULL, path, OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST, szFilter,this); // Open dialog dlgOpen.m_ofn.lpstrTitle = _T("Select file to burn"); // Select and add files if(IDOK == dlgOpen.DoModal()) { CString dlg_path = dlgOpen.GetPathName(); theApp.set_dome_path(dlg_path); GetDlgItem(IDC_STATIC_FILE)->SetWindowText(dlg_path); UpdateData(TRUE); } } #include "util_source/util_file.hpp" void CDlgDomeUpdate::OnButtonUpdate() { // TODO: Add your control notification handler code here CString msg; UpdateData(); // dome update CString ip; CString file; const int MAX_LOG = 102400; char log[MAX_LOG]; //GetDlgItem(IDC_EDIT_SELECT_IP)->GetWindowText(ip); ip = theApp.m_info.sIp; GetDlgItem(IDC_STATIC_FILE)->GetWindowText(file); memset(log, 0, MAX_LOG); // check dome file size - - cjy, 08_0303 11:36 DWORD size = get_file_size_from_path(file); if(size > 0x1e000) { msg.Format("Dome file size[%d] is more than max_size[%d]", size, 0x1e000); AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION); return; } // do // ¹Ýȯ °ªÀÌ ¾ç¼ö¸é ¼º°ø //int UpdateWithLog(char *ip, char *file, int type, char* log, int max); // dome update´Â 0x51 int hr; if(m_bChkSkip) { // Skip to enter boot mode //hr = UpdateWithLog(ip, file, 0x52, log, MAX_LOG); hr = UpGrade(ip, file, 0x52); } else { // general mode //hr = UpdateWithLog(ip, file, 0x51, log, MAX_LOG); hr = UpGrade(ip, file, 0x51); } // log show if(hr < 0) { switch(hr) { case -9: msg.Format("The device doesn't support dome update"); break; default: msg.Format("Failed to update dome with [Error code:%d]", hr); break; } AfxMessageBox(msg, MB_OK | MB_ICONEXCLAMATION); } else { // msg.Format("Completed to update dome"); msg.Format("Dome update completed");// - cjy, 07_0810 09:59 AfxMessageBox(msg, MB_OK | MB_ICONINFORMATION); } //m_richLog. return; } void CDlgDomeUpdate::OnButtonCancel() { // TODO: Add your control notification handler code here CDialog::OnCancel(); } BOOL CDlgDomeUpdate::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here UpdateData(); m_sEdSelectDevice = theApp.GetSelectDeviceName(); UpdateData(FALSE); m_prUp.SetPos(0); m_prUp.SetShowPercent(false); m_prUp.SetWindowText("Ready..."); // check what does this device is ipc series? /* int i, flag = 0; for(i = 0; i < 50; i++) { if(theApp.m_info.FirmwareVersion[i] == '.') { flag++; if(flag == 2) { char temp[5]; memset(temp, 0x00, sizeof(temp)); memcpy(temp, &theApp.m_info.FirmwareVersion[i+1], 3); if(atoi(temp) < 360) { AfxMessageBox("This firmware does not support \"ActiveX upload\" function."); OnOK(); } break; } } } if(i > 45) { AfxMessageBox("This firmware does not support \"ActiveX upload\" function."); OnOK(); } */ CString path = theApp.get_dome_path(); // registry GetDlgItem(IDC_STATIC_FILE)->SetWindowText(path); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }