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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
 
#include <QMessageBox>
#include "czonedst.h"
#include "publicfuc.h"
#include "DemoPublic.h"
 
CZoneDst::CZoneDst(QWidget *parent)
    : QDialog(parent)
{
    ui.setupUi(this);
 
    m_lUserID = -1;
    m_lChannel = -1;
 
    QStringList strings;
    strings<<"Disable"<<"Enable";
    ui.comboEnableDST->addItems(strings);
 
    strings.clear();
    strings<<"30min"<<"60min"<<"90min"<<"120min";
    ui.comboSTBias->addItems(strings);
 
    strings.clear();
    strings<<"1"<<"2"<<"3"<<"4"<<"5"<<"6"<<"7"<<"8"<<"9"<<"10"<<"11"<<"12";
    ui.comboMonthBegin->addItems(strings);
    ui.comboMonthEnd->addItems(strings);
 
    strings.clear();
    strings<<"First"<<"Second"<<"Third"<<"Fourth"<<"Last";
    ui.comboWeekNoBegin->addItems(strings);
    ui.comboWeekNoEnd->addItems(strings);
 
    strings.clear();
    strings<<"Sunday"<<"Monday"<<"Tuesday"<<"Wednesday"<<"Thursday"<<"Friday"<<"Saturday";
    ui.comboWeekDateBegin->addItems(strings);
    ui.comboWeekDateEnd->addItems(strings);
 
    strings.clear();
    strings<<"0"<<"1"<<"2"<<"3"<<"4"<<"5"<<"6"<<"7"<<"8"<<"9"<<"10"<<"11"<<"12"<<"13"<<"14"<<"15"<<"16"<<"17"<<"18"<<"19"<<"20"<<"21"<<"22"<<"23";
    ui.comboHourBegin->addItems(strings);
    ui.comboHourEnd->addItems(strings);
 
    strings.clear();
    strings<<"1"<<"2"<<"3"<<"4"<<"5"<<"6"<<"7"<<"8"<<"9"<<"10"<<"11"<<"12"<<"13"<<"14"<<"15"<<"16"<<"17"<<"18"<<"19"<<"20"<<"21"<<"22"<<"23";
    ui.comboMinuteBegin->addItems(strings);
    ui.comboMinuteEnd->addItems(strings);
 
    connect(ui.btnSave,  SIGNAL(clicked()), this, SLOT(clickSave()));
    connect(ui.btnRefresh,  SIGNAL(clicked()), this, SLOT(clickRefresh()));
}
 
CZoneDst::~CZoneDst()
{
 
}
 
int CZoneDst::getZoneDstInfo()
{
    NET_DVR_ZONEANDDST  struZoneAndDst;
    DWORD uiParamsLen;
    int iRet;
 
    iRet = NET_DVR_GetDVRConfig(m_lUserID, NET_DVR_GET_ZONEANDDST, m_lChannel, &struZoneAndDst, sizeof(NET_DVR_ZONEANDDST), &uiParamsLen);
    if(iRet == 0)
    {
        //µ÷ÓôíÎóÐÅÏ¢º¯ÊýÍê³É
        KIT_DisplayErrorInfo("Get Zone information", KIT_ERRPR_DIS_TYPE);
        return HPR_ERROR;
    }
    ui.comboEnableDST->setCurrentIndex(int(struZoneAndDst.dwEnableDST));
    ui.comboSTBias->setCurrentIndex(((int)(struZoneAndDst.byDSTBias))/30 - 1);
 
    //month
    ui.comboMonthBegin->setCurrentIndex(int(struZoneAndDst.struBeginPoint.dwMonth));
    ui.comboMonthEnd->setCurrentIndex(int(struZoneAndDst.struEndPoint.dwMonth));
    //weekno
    ui.comboWeekNoBegin->setCurrentIndex(int(struZoneAndDst.struBeginPoint.dwWeekNo));
    ui.comboWeekNoEnd->setCurrentIndex(int(struZoneAndDst.struEndPoint.dwWeekNo));
    //week data
    ui.comboWeekDateBegin->setCurrentIndex(int(struZoneAndDst.struBeginPoint.dwWeekDate));
    ui.comboWeekDateEnd->setCurrentIndex(int(struZoneAndDst.struEndPoint.dwWeekDate));
    //hour
    ui.comboHourBegin->setCurrentIndex(int(struZoneAndDst.struBeginPoint.dwHour));
    ui.comboHourEnd->setCurrentIndex(int(struZoneAndDst.struEndPoint.dwHour));
    //minute
    ui.comboMinuteBegin->setCurrentIndex(int(struZoneAndDst.struBeginPoint.dwMin));
    ui.comboMinuteEnd->setCurrentIndex(int(struZoneAndDst.struEndPoint.dwMin));
 
    return HPR_OK;
}
 
int CZoneDst::setZoneDsfInfo()
{
    NET_DVR_ZONEANDDST  struZoneAndDst;
    DWORD uiParamsLen;
    int iRet;
 
    iRet = NET_DVR_GetDVRConfig(m_lUserID, NET_DVR_GET_ZONEANDDST, m_lChannel, &struZoneAndDst, sizeof(NET_DVR_ZONEANDDST), &uiParamsLen);
    if(iRet == 0)
    {
        QMessageBox::information(this, tr("Please check!"), tr(".Get Zone information unsuccessfully!"));
        return HPR_ERROR;
    }
    struZoneAndDst.dwEnableDST = ui.comboEnableDST->currentIndex();
    struZoneAndDst.byDSTBias = 30*(ui.comboSTBias->currentIndex() + 1);
 
    //month
    struZoneAndDst.struBeginPoint.dwMonth = ui.comboMonthBegin->currentIndex();
    struZoneAndDst.struEndPoint.dwMonth = ui.comboMonthEnd->currentIndex();
 
    //weekno
    struZoneAndDst.struBeginPoint.dwWeekNo = ui.comboWeekNoBegin->currentIndex();
    struZoneAndDst.struEndPoint.dwWeekNo = ui.comboWeekNoEnd->currentIndex();
 
    //week data
    struZoneAndDst.struBeginPoint.dwWeekDate = ui.comboWeekDateBegin->currentIndex();
    struZoneAndDst.struEndPoint.dwWeekDate = ui.comboWeekDateEnd->currentIndex();
 
    //hour
    struZoneAndDst.struBeginPoint.dwHour =  ui.comboHourBegin->currentIndex();
    struZoneAndDst.struEndPoint.dwHour = ui.comboHourEnd->currentIndex();
 
    //minute
    struZoneAndDst.struBeginPoint.dwMin = ui.comboMinuteBegin->currentIndex();
    struZoneAndDst.struEndPoint.dwMin = ui.comboMinuteEnd->currentIndex();
 
    iRet = NET_DVR_SetDVRConfig(m_lUserID, NET_DVR_SET_ZONEANDDST, m_lChannel,  &struZoneAndDst, sizeof(NET_DVR_ZONEANDDST));
    if(iRet == 0)
    {
            iRet = NET_DVR_GetLastError();
         QMessageBox::information(this, tr("Set Zone fail!"), tr("Set Zone fail. \"%1\"").arg(iRet));
         return HPR_ERROR;
     }
 
    return HPR_OK;
}
 
void  CZoneDst::clickSave()
{
    if(m_lUserID < 0)
    {
        return;
    }
    setZoneDsfInfo();
 
}
void  CZoneDst::clickRefresh()
{
    if(m_lUserID < 0)
    {
        return;
    }
    getZoneDstInfo();
 
}
 
 
void CZoneDst::on_btnExit_clicked()
{
    close();
}
 
 
void CZoneDst::showEvent ( QShowEvent * event )
{
    //disable warning
    if(event == NULL)
    {
    }
    if(m_lUserID < 0)
    {
        //QMessageBox::information(this, tr("Please login firstly!"), tr("Please login firstly!."));
        return;
    }
    else
    {
        getZoneDstInfo();
    }
}
 
 
 
int CZoneDst::setUserIDAndChannel(long lUserID, long lChannel)
{
    m_lUserID = lUserID;
    m_lChannel = lChannel;
 
    return HPR_OK;
}