-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProtectData.cpp
More file actions
117 lines (111 loc) · 2.33 KB
/
ProtectData.cpp
File metadata and controls
117 lines (111 loc) · 2.33 KB
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
// ProtectData.cpp: implementation of the CProtectData class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "SID_2FY.h"
#include "ProtectData.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CProtectData::CProtectData()
{
m_pFilePos = NULL;
m_pProPara = NULL;
m_nParaCount = 0;
m_nParaAreaNum = 0xFF;
m_nDataTypeCode = PROTECT_PARA_TYPE;
}
CProtectData::~CProtectData()
{
Release();
}
BOOL CProtectData::InitSubItemData(BYTE *pFile, UINT nSubSize,
UINT nFilePos,WaveInfo waveInfo)
{
ASSERT(m_pFilePos == NULL);
m_nFilePos = nFilePos;
m_pFilePos = pFile+nFilePos;
ASSERT(m_pFilePos[0] == m_nDataTypeCode);
m_nParaAreaNum = m_pFilePos[1]; //定值区号
m_nParaCount = *((unsigned short *)(m_pFilePos+2)); //定值数目(NBHDZ)
UINT i,nTemp,nTempSubSize,nCurPos;
nTempSubSize = (UINT)72*m_nParaCount + 4;
if(nTempSubSize != nSubSize)
{
return FALSE;
}
if(m_pProPara != NULL)
{
return FALSE;
}
m_pProPara = new ProtectPara[m_nParaCount];
if(m_pProPara == NULL)
{
m_nParaCount = 0;
return FALSE;
}
nCurPos = 4;
for(i=0;i<m_nParaCount;i++)
{
nTemp = sizeof(m_pProPara[i].strParaType)-1;
memcpy(m_pProPara[i].strParaType,m_pFilePos+nCurPos,nTemp);
nCurPos+=nTemp;
nTemp = sizeof(m_pProPara[i].strParaName)-1;
memcpy(m_pProPara[i].strParaName,m_pFilePos+nCurPos,nTemp);
nCurPos+=nTemp;
nTemp = sizeof(m_pProPara[i].strParaValue)-1;
memcpy(m_pProPara[i].strParaValue,m_pFilePos+nCurPos,nTemp);
nCurPos+=nTemp;
}
return TRUE;
}
void CProtectData::Release()
{
m_pFilePos = NULL;
m_nParaAreaNum = 0xFF;
if(m_pProPara !=NULL)
{
delete [m_nParaCount] m_pProPara;
m_nParaCount = 0;
m_pProPara = NULL;
}
}
//这里是获取保护定值的定值区
int CProtectData::GetAppointCount()
{
if(m_pProPara != NULL)
{
return (int)m_nParaAreaNum;
}
else
{
return -1;
}
}
int CProtectData::GetChannelCount()
{
if(m_pProPara != NULL)
{
return m_nParaCount;
}
else
{
return -1;
}
}
DWORD CProtectData::GetChannelData(int index)
{
if(index >= 0 && index <m_nParaCount)
{
return (DWORD)&m_pProPara[index];
}
else
{
return NULL;
}
}