13 CBasicLog::CBasicLog(Dasher::CEventHandler
*pEventHandler
, CSettingsStore
*pSettingsStore
) : CUserLogBase(pEventHandler
, pSettingsStore
) {
18 CBasicLog::~CBasicLog() {
22 void CBasicLog::StartWriting() {
29 void CBasicLog::StopWriting(float dNats
) {
30 m_dBits
+= dNats
/ log(2.0);
33 void CBasicLog::AddSymbols(Dasher::VECTOR_SYMBOL_PROB
* pVectorNewSymbolProbs
, eUserLogEventType iEvent
) {
34 m_iSymbolCount
+= pVectorNewSymbolProbs
->size();
37 void CBasicLog::DeleteSymbols(int iNumToDelete
, eUserLogEventType iEvent
) {
38 m_iSymbolCount
-= iNumToDelete
;
41 void CBasicLog::NewTrial() {
45 void CBasicLog::KeyDown(int iId
, int iType
, int iEffect
) {
49 void CBasicLog::StartTrial() {
53 m_strStartDate
= GetDateStamp();
54 m_iInitialRate
= GetLongParameter(LP_MAX_BITRATE
);
57 void CBasicLog::EndTrial() {
61 std::string
strFileName(GetStringParameter(SP_USER_LOC
));
62 strFileName
.append("dasher_basic.log");
65 oFile
.open(strFileName
.c_str(), ios::out
| ios::app
);
67 oFile
<< "\"" << m_strStartDate
<< "\":\"" << GetDateStamp() << "\":" << m_iSymbolCount
<< ":" << m_dBits
<< ":" << m_iKeyCount
<< ":" << m_iInitialRate
/ 100.0 << ":" << GetLongParameter(LP_MAX_BITRATE
) / 100.0 << ":\"" << GetStringParameter(SP_INPUT_FILTER
) << "\":\"" << GetStringParameter(SP_ALPHABET_ID
) << "\"" << std::endl
;
74 std::string
CBasicLog::GetDateStamp() {
75 std::string strDateStamp
= "";
78 struct timeb sTimeBuffer
;
80 struct timeval sTimeBuffer
;
81 struct timezone sTimezoneBuffer
;
83 char* szTimeLine
= NULL
;
87 szTimeLine
= ctime(&(sTimeBuffer
.time
));
89 gettimeofday(&sTimeBuffer
, &sTimezoneBuffer
);
90 szTimeLine
= ctime(&(sTimeBuffer
.tv_sec
));
93 return std::string(szTimeLine
).substr(0, 24);