LAPTOP-SNT8I5JK\Boounion
2025-06-26 838262ab61d580d7dd5eb3b181c61d8b4d3f54fe
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
#include "stdafx.h"
#include "Configuration.h"
 
 
CConfiguration::CConfiguration()
{
}
 
CConfiguration::CConfiguration(const char* pszFilepath)
{
    m_strFilepath = pszFilepath;
}
 
CConfiguration::~CConfiguration()
{
}
 
void CConfiguration::setFilepath(const char* pszFilepath)
{
    m_strFilepath = pszFilepath;
}
 
void CConfiguration::getUnitId(CString& strUnitId)
{
    char szTemp[256];
    GetPrivateProfileString("App", _T("UnitId"), _T(""), szTemp, 256, m_strFilepath);
    strUnitId = szTemp;
}
 
void CConfiguration::getBond1(CString& strIp, UINT& port, UINT& doorCount)
{
    char szTemp[256];
 
    // ¶ÁIPºÍ¶Ë¿Ú
    GetPrivateProfileString("Bond1", _T("IP"), _T(""), szTemp, 256, m_strFilepath);
    strIp = szTemp;
    port = GetPrivateProfileInt("Bond1", _T("Port"), 0, m_strFilepath);
    doorCount = GetPrivateProfileInt("Bond1", _T("DoorCount"), 0, m_strFilepath);
}
 
int CConfiguration::getLogcatLevel()
{
    return GetPrivateProfileInt(_T("Logcat"), _T("Level"), 0, m_strFilepath);
}
 
void CConfiguration::setLogcatLevel(int level)
{
    WritePrivateProfileString(_T("Logcat"), _T("Level"),
        std::to_string(level).c_str(), m_strFilepath);
}
 
int CConfiguration::setLogcatIncludeText(CString& strInclude)
{
    WritePrivateProfileString(_T("Logcat"), _T("IncludeText"),
        strInclude, m_strFilepath);
    return 0;
}
 
int CConfiguration::getLogcatIncludeText(CString& strInclude)
{
    char szTemp[256];
    GetPrivateProfileString("Logcat", _T("IncludeText"), _T(""), szTemp, 256, m_strFilepath);
    strInclude = szTemp;
    return 0;
}
 
void CConfiguration::setLogcatIncludeRegex(BOOL bRegex)
{
    WritePrivateProfileString(_T("Logcat"), _T("IncludeRegex"),
        bRegex ? "1" : "0", m_strFilepath);
}
 
BOOL CConfiguration::isLogcatIncludeRegex()
{
    return GetPrivateProfileInt(_T("Logcat"), _T("IncludeRegex"), 0, m_strFilepath);
}
 
int CConfiguration::getCustomLogcatIncludeTexts(std::vector<std::string>& texts)
{
    char szSection[256], szTemp[256];
 
    for (int i = 0; i < 10; i++) {
        sprintf_s(szSection, 256, "CustomInclude%d", i + 1);
        GetPrivateProfileString("Logcat", szSection, _T(""),
            szTemp, 256, m_strFilepath);
        std::string strInclude(szTemp);
        if (!strInclude.empty()) {
            texts.push_back(strInclude);
        }
    }
 
    return (int)texts.size();    
}
 
int CConfiguration::getP2RemoteEqReconnectInterval()
{
    return GetPrivateProfileInt(_T("P2"), _T("RemoteEqReconnectInterval"), 20, m_strFilepath);
}
 
void CConfiguration::setP2RemoteEqReconnectInterval(int second)
{
    WritePrivateProfileString(_T("P2"), _T("RemoteEqReconnectInterval"),
        std::to_string(second).c_str(), m_strFilepath);
}
 
BOOL CConfiguration::getPortParms(unsigned int index, BOOL& bEnable, int& type, int& mode,
    int& cassetteType, int& transferMode, BOOL& bAutoChangeEnable)
{
    if (index >= 4) return FALSE;
 
    static char* pszSection[] = {"Port1", "Port2", "Port3", "Port4"};
    bEnable = GetPrivateProfileInt(pszSection[index], _T("Enable"), 0, m_strFilepath) == 1;
    type = GetPrivateProfileInt(pszSection[index], _T("Type"), 0, m_strFilepath);
    mode = GetPrivateProfileInt(pszSection[index], _T("Mode"), 0, m_strFilepath);
    cassetteType = GetPrivateProfileInt(pszSection[index], _T("CassetteType"), 0, m_strFilepath);
    transferMode = GetPrivateProfileInt(pszSection[index], _T("TransferMode"), 0, m_strFilepath);
    bAutoChangeEnable = GetPrivateProfileInt(pszSection[index], _T("AutoChangeEnable"), 0, m_strFilepath) == 1;
 
    // type, mode, cassetteType, transferMode ·¶Î§¼ì²é
    type = max(1, min(type, 7));
    mode = max(0, min(mode, 5));
    cassetteType = max(1, min(cassetteType, 3));
    transferMode = max(1, min(transferMode, 3));
 
    return TRUE;
}