pans
2016-12-15 87e3ee273b2f84081ac45926be9d8e5be3166eaa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/************************************************************************
 *        Copyright 2009-2011 Hikvision Digital Technology Co., Ltd.
 *        FileName                      :   formatdisk.cpp
 *        Description                   :   format disk 
 *        Modification History          :   none
 *        Version                       :   V1.0
 *        Time                          :   2009-11,12
 *        Author                        :   wanggongpu
 *        Descrp                        :   
*************************************************************************/
#include "formatdisk.h"
#include <QString>
#include <QMessageBox>
#include "common.h"
#include <unistd.h>
/************************************************************************
 *        Function            :  FormatDisk
 *        Description         :  instructor
 *        Input               :  none
 *        Output              :  none
 *        Return              :  none
*************************************************************************/
FormatDisk::FormatDisk(int *userid, QWidget *parent)
    : QDialog(parent)
{
    ui.setupUi(this);
    m_fduserid =userid;
    DWORD returnbytes =0;
    
    if (!NET_DVR_GetDVRConfig(*m_fduserid, NET_DVR_GET_HDCFG,\
        0xFFFFFFFF, &m_fdhdcfg, sizeof(NET_DVR_HDCFG),&returnbytes))
    {
        QMessageBox::information(this,tr("NET_DVR_GetDVRConfig failed"), \
            tr("SDK_Last_Error =%1").arg(NET_DVR_GetLastError()));
        return ;
    }
    QString all("All Disks");
    ui.comboBox->addItem(all);
    
    m_disknum[0]=0xff;
    int j=0;
    for (int i=0;i<m_fdhdcfg.dwHDCount;i++,j++)
    {   
        m_disknum[++j]=m_fdhdcfg.struHDInfo[i].dwHDNo;
        ui.comboBox->addItem(QString::number(m_fdhdcfg.struHDInfo[i].dwHDNo));
    }
    ui.horizontalSlider->setRange(0, 100);
    setUpdatesEnabled ( TRUE );
    update();
    repaint();
}
 
/************************************************************************
 *        Function            :  ~FormatDisk 
 *        Description         :  destructor 
 *        Input               :  none
 *        Output              :  none
 *        Return              :  none
*************************************************************************/
FormatDisk::~FormatDisk()
{
    for (int i=0;i<=m_indexnum;i++)
    {
        ui.comboBox->removeItem (i);
    }
     
}
 
/************************************************************************
 *        Function            :  
 *        Description         :   
 *        Input               :  none
 *        Output              :  none
 *        Return              :  none
*************************************************************************/
void FormatDisk::on_comboBox_currentIndexChanged ( int index)
{
    m_fdindex =index;
}
 
/************************************************************************
 *        Function            :  on_pushButton_format_clicked
 *        Description         :  format 
 *        Input               :  none
 *        Output              :  none
 *        Return              :  none
*************************************************************************/
void FormatDisk::on_pushButton_format_clicked()
{
    int format=0;
    if (m_fdindex!=0)
    {
        m_disknum[m_fdindex] = m_fdindex;
    }
 
    format = NET_DVR_FormatDisk(*m_fduserid, m_disknum[m_fdindex]);
    if (format < 0)
    {
        QMessageBox::information(this,tr("NET_DVR_FormatDisk failed"), \
            tr("SDK_Last_Error =%1").arg(NET_DVR_GetLastError()));
        return ;
    }
 
    LONG pos = 0;
    LONG pstatic = 0;
    while (pstatic != 1)
    {  
#if (defined(_WIN32))
#elif defined(__linux__)
        sleep(1);
#endif
        
        if (!NET_DVR_GetFormatProgress(format,&m_disknum[m_fdindex],&pos, &pstatic))
        {
            QMessageBox::information(this,tr("NET_DVR_GetFormatProgress failed"), \
                tr("SDK_Last_Error =%1").arg(NET_DVR_GetLastError()));
           //return ;
        }
 
        ui.horizontalSlider->setValue(pos++);
        if (pstatic !=0)
        {
            ui.horizontalSlider->setValue(100);
            break;
        }
    }
    NET_DVR_CloseFormatHandle(format);
    QMessageBox::information(this,tr("NET_DVR_GetFormatProgress"), \
            tr("FORMAT SUCCESS OVER format=%1 ").arg(format));
 
}
 
/************************************************************************
 *        Function            :  on_pushButton_exit_clicked
 *        Description         :  exit
 *        Input               :  none
 *        Output              :  none
 *        Return              :  none
*************************************************************************/
void FormatDisk::on_pushButton_exit_clicked()
{
    close();    
}