-
Notifications
You must be signed in to change notification settings - Fork 2
/
NHRData-Retrieval.py
79 lines (64 loc) · 2.29 KB
/
NHRData-Retrieval.py
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
import ctypes
# Load DLL
D2Result = ctypes.CDLL('D2Result.dll')
# Retrieve the functions within the DLL
GetSingleResult = D2Result['D2R_GetSingleResult']
GetMultipleResults = D2Result['D2R_GetMultipleResult']
#
# Get Single Results
# Arguments
#
# pszDOE2Dir: path to DOE-2 directory
# pszFileName: path to project (do not include any extension)
# iEntryID: id from NHRList.txt corresponding to the value to retrieve
# pfData: sample array to store the retrieved value
# iMaxValues: number of items to retrieve (NI in NHRList.txt); should always be 1 when GetSingleResult is called
# pszReportKey: to use when NI > 0 and when value to retrieve refers to a particular BDL component; '\0' if not valid
# pszRowKey: to use when KT > 0 and when a report has multiple row; '\0' if not valid
#
pszDOE2Dir =
pszFileName =
iEntryID =
iMaxValues =
pfData = (ctypes.c_float*iMaxValues)()
pszReportKey =
pszRowKey =
#
# Get Multiple Result
# Arguments
#
# pszDOE2Dir: path to DOE-2 directory
# pszFileName: path to project (do not include any extension)
# iFileType: 0 for Loads results, 1 for HVAC, 2 for Utility Rate; in general first digit of NHRlist ID minus 1
# pfData: sample array to store the retrieved value
# iMaxValues: number of items to retrieve (NI in NHRList.txt); should always be 1 when GetSingleResult is called
# iNumMRTs: number of values in one set of results
# pMRTs: number of set of results to retrieve (max=12)
#
pszDOE2Dir =
pszFileName =
iFileType =
iMaxValues =
pfData = (ctypes.c_float*iMaxValues)()
iNumMRTs =
# Define a 'Structue' that contains information about the data to retrieve
class MRTarray(ctypes.Structure):
_fields_ = [("iEntryID", ctypes.c_int),
("iReturnValue", ctypes.c_int),
("pszReportKey", ctypes.c_char * 34 ),
("pszRowKey",ctypes.c_char * 34)]
MRT = MRTarray()
MRTS = (MRTarray * iNumMRTs)()
# Below, i is an index from 0 to iNumMRTs
MRTS[i].iEntryID =
MRTS[i].pszReportKey =
MRTS[i].pszRowKey =
pMRTs = MRTS
# Retrieve and print the data
GetSingleResult(pszDOE2Dir,pszFileName,iEntryID,pfData,iMaxValues,pszReportKey,pszRowKey)
print "GetSingleResult:"
print pfData[0]
GetMultipleResults(pszDOE2Dir,pszFileName,iFileType,pfData,iMaxValues,iNumMRTs,pMRTs)
print "GetMultipleResults:"
for i in range(0,len(pfData)):
print pfData[i]