Initial
This commit is contained in:
142
aladin/hold/appreg.cpp
Normal file
142
aladin/hold/appreg.cpp
Normal file
@@ -0,0 +1,142 @@
|
||||
#include <aladin/appreg.hpp>
|
||||
#include <commctrl/commctrl.hpp>
|
||||
|
||||
AppReg::AppReg(void)
|
||||
: mAladinKeyName(STRING_ALADINKEYNAME),
|
||||
mSerialKeyName(STRING_SERIALKEYNAME),
|
||||
mSettingsEMAIL(STRING_SETTINGSEMAIL),
|
||||
mSerialPort(STRING_SERIALPORT),
|
||||
mSerialBaud(STRING_SERIALBAUD),
|
||||
mSerialData(STRING_SERIALDATA),
|
||||
mSerialParity(STRING_SERIALPARITY),
|
||||
mSerialStop(STRING_SERIALSTOP),
|
||||
mRegKeySerial(RegKey::CurrentUser)
|
||||
{
|
||||
guarantee();
|
||||
}
|
||||
|
||||
AppReg::AppReg(const AppReg &someAppReg)
|
||||
: mAladinKeyName(STRING_ALADINKEYNAME),
|
||||
mSerialKeyName(STRING_SERIALKEYNAME),
|
||||
mSettingsEMAIL(STRING_SETTINGSEMAIL),
|
||||
mSerialPort(STRING_SERIALPORT),
|
||||
mSerialBaud(STRING_SERIALBAUD),
|
||||
mSerialData(STRING_SERIALDATA),
|
||||
mSerialParity(STRING_SERIALPARITY),
|
||||
mSerialStop(STRING_SERIALSTOP),
|
||||
mRegKeySerial(RegKey::CurrentUser)
|
||||
{
|
||||
*this=someAppReg;
|
||||
}
|
||||
|
||||
AppReg::~AppReg()
|
||||
{
|
||||
}
|
||||
|
||||
AppReg &AppReg::operator=(const AppReg &/*someAppReg*/)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool AppReg::setBaud(const String &strBaud)
|
||||
{
|
||||
return mRegKeySerial.setValue(mSerialBaud,strBaud);
|
||||
}
|
||||
|
||||
String AppReg::getBaud(void)
|
||||
{
|
||||
String strBaud;
|
||||
mRegKeySerial.queryValue(mSerialBaud,strBaud);
|
||||
return strBaud;
|
||||
}
|
||||
|
||||
bool AppReg::setParity(const String &strParity)
|
||||
{
|
||||
return mRegKeySerial.setValue(mSerialParity,strParity);
|
||||
}
|
||||
|
||||
String AppReg::getParity(void)
|
||||
{
|
||||
String strParity;
|
||||
mRegKeySerial.queryValue(mSerialParity,strParity);
|
||||
return strParity;
|
||||
}
|
||||
|
||||
bool AppReg::setDataBits(const String &strDataBits)
|
||||
{
|
||||
return mRegKeySerial.setValue(mSerialData,strDataBits);
|
||||
}
|
||||
|
||||
String AppReg::getDataBits(void)
|
||||
{
|
||||
String strData;
|
||||
mRegKeySerial.queryValue(mSerialData,strData);
|
||||
return strData;
|
||||
}
|
||||
|
||||
bool AppReg::setStopBits(const String &stopBits)
|
||||
{
|
||||
return mRegKeySerial.setValue(mSerialStop,stopBits);
|
||||
}
|
||||
|
||||
String AppReg::getStopBits(void)
|
||||
{
|
||||
String strStop;
|
||||
|
||||
mRegKeySerial.queryValue(mSerialStop,strStop);
|
||||
return strStop;
|
||||
}
|
||||
|
||||
bool AppReg::setPort(const String &strPort)
|
||||
{
|
||||
return mRegKeySerial.setValue(mSerialPort,strPort);
|
||||
}
|
||||
|
||||
String AppReg::getPort(void)
|
||||
{
|
||||
String strPort;
|
||||
mRegKeySerial.queryValue(mSerialPort,strPort);
|
||||
return strPort;
|
||||
}
|
||||
|
||||
String AppReg::getSerialSettings(void)
|
||||
{
|
||||
String serialSettings;
|
||||
|
||||
serialSettings+="baud=";
|
||||
serialSettings+=getBaud();
|
||||
serialSettings+=" ";
|
||||
serialSettings+="parity=";
|
||||
serialSettings+=getParity();
|
||||
serialSettings+=" ";
|
||||
serialSettings+="data=";
|
||||
serialSettings+=getDataBits();
|
||||
serialSettings+=" ";
|
||||
serialSettings+="stop=";
|
||||
serialSettings+=getStopBits();
|
||||
return serialSettings;
|
||||
}
|
||||
|
||||
void AppReg::guarantee(void)
|
||||
{
|
||||
if(!mRegKeySerial.openKey(mSerialKeyName))
|
||||
{
|
||||
CommControl commControl;
|
||||
Block<String> deviceList;
|
||||
|
||||
commControl.enumerateDevices(deviceList);
|
||||
mRegKeySerial.createKey(mSerialKeyName,"");
|
||||
mRegKeySerial.openKey(mSerialKeyName);
|
||||
setBaud("19200");
|
||||
setParity("N");
|
||||
setDataBits("8");
|
||||
setStopBits("1");
|
||||
setPort(deviceList.size()?deviceList[0]:"COM1");
|
||||
}
|
||||
}
|
||||
|
||||
BOOL AppReg::isOkay(void)const
|
||||
{
|
||||
return mRegKeySerial.isOkay();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user