#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();
|
}
|
|
void CConfiguration::setFilterMode(int mode)
|
{
|
WritePrivateProfileString(_T("Logcat"), _T("FilterMode"),
|
std::to_string(mode).c_str(), m_strFilepath);
|
}
|
|
int CConfiguration::getFilterMode()
|
{
|
return GetPrivateProfileInt(_T("Logcat"), _T("FilterMode"), 0, m_strFilepath);
|
}
|
|
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;
|
}
|
|
BOOL CConfiguration::setPortCassetteType(unsigned int index, int cassetteType)
|
{
|
if (index >= 4) return FALSE;
|
if (cassetteType < 1 || 3 < cassetteType) return FALSE;
|
|
static char* pszSection[] = { "Port1", "Port2", "Port3", "Port4" };
|
WritePrivateProfileString(pszSection[index], _T("CassetteType"), std::to_string(cassetteType).c_str(), m_strFilepath);
|
return true;
|
}
|
|
BOOL CConfiguration::setPortEnable(unsigned int index, BOOL bEnable)
|
{
|
if (index >= 4) return FALSE;
|
|
static char* pszSection[] = { "Port1", "Port2", "Port3", "Port4" };
|
WritePrivateProfileString(pszSection[index], _T("Enable"), std::to_string(bEnable ? 1 : 0).c_str(), m_strFilepath);
|
return true;
|
}
|
|
BOOL CConfiguration::isCompareMapsBeforeProceeding()
|
{
|
return GetPrivateProfileInt(_T("Master"), _T("CompareMapsBeforeProceeding"), 0, m_strFilepath);
|
}
|