ソースを参照

Fixed inappropriate bool operation in interval timer ! not ~

master
Pete McNeil 4年前
コミット
2f5cd98bfb
1個のファイルの変更39行の追加39行の削除
  1. 39
    39
      snfLOGmgr.cpp

+ 39
- 39
snfLOGmgr.cpp ファイルの表示

#include "snfLOGmgr.hpp" #include "snfLOGmgr.hpp"
#include "../CodeDweller/threading.hpp" #include "../CodeDweller/threading.hpp"
#include "../CodeDweller/timing.hpp" #include "../CodeDweller/timing.hpp"
#include <unistd.h>
#include <sstream>
#include <unistd.h>
#include <sstream>
#include <iomanip> #include <iomanip>


using namespace std; using namespace std;


snfScanData::snfScanData(int ScanHorizon) : // How to create. snfScanData::snfScanData(int ScanHorizon) : // How to create.
ReadyToClear(true), // Make sure initial clear will happen. ReadyToClear(true), // Make sure initial clear will happen.
FilteredData(ScanHorizon, 0) { // Allocate the Filtered Data buffer.
FilteredData(ScanHorizon, 0) { // Allocate the Filtered Data buffer.
clear(); // Start with no data. clear(); // Start with no data.
} }




msclock IntervalTimer::hack() { // Chop off a new interval & return it. msclock IntervalTimer::hack() { // Chop off a new interval & return it.
Inactive().start(Active().stop()); // Stop the active clock and reference Inactive().start(Active().stop()); // Stop the active clock and reference
ANotB = ~ANotB; // it to start the new Active clock.
ANotB = !ANotB; // it to start the new Active clock.
return Interval(); // Flip the bit and return the Interval. return Interval(); // Flip the bit and return the Interval.
} }


const ThreadType snfLOGmgr::Type("snfLOGmgr"); // The thread's type. const ThreadType snfLOGmgr::Type("snfLOGmgr"); // The thread's type.


snfLOGmgr::snfLOGmgr() : // Constructor for the LOG manager snfLOGmgr::snfLOGmgr() : // Constructor for the LOG manager
Thread(snfLOGmgr::Type, "Log Manager"), // snfLOGmgr Type and Name.
Thread(snfLOGmgr::Type, "Log Manager"), // snfLOGmgr Type and Name.
Configured(false), // Not yet configured. Configured(false), // Not yet configured.
TimeToDie(false), // Not yet time to die.
PeekEnableCounter(0), // No peeking yet.
SampleEnableCounter(0), // No sampling yet.
myNETmgr(NULL), // No NET mgr yet.
myGBUdb(NULL), // No GBUdb yet.
NewerRulebaseIsAvailable(false), // No newer rulebase yet.
TimeToDie(false), // Not yet time to die.
PeekEnableCounter(0), // No peeking yet.
SampleEnableCounter(0), // No sampling yet.
myNETmgr(NULL), // No NET mgr yet.
myGBUdb(NULL), // No GBUdb yet.
NewerRulebaseIsAvailable(false), // No newer rulebase yet.
SecondStatusLogger("Second Status Logger"), // Lazy writer for Second status. SecondStatusLogger("Second Status Logger"), // Lazy writer for Second status.
MinuteStatusLogger("Minute Status Logger"), // Lazy writer for Minute status. MinuteStatusLogger("Minute Status Logger"), // Lazy writer for Minute status.
HourStatusLogger("Hour Status Logger"), // Lazy writer for Hour status. HourStatusLogger("Hour Status Logger"), // Lazy writer for Hour status.
} }
} }


// Black header
// Black header
const int AboveBandRange = 64; const int AboveBandRange = 64;


if( if(
CFGData.XHDRBlack_OnOff && // If the Black XHDR is on and CFGData.XHDRBlack_OnOff && // If the Black XHDR is on and
0 < ScanData.CompositeFinalResult && // We have a nonzero result and
0 < ScanData.CompositeFinalResult && // We have a nonzero result and
AboveBandRange > ScanData.CompositeFinalResult && // it is not an above-band code and AboveBandRange > ScanData.CompositeFinalResult && // it is not an above-band code and
!CFGData.TrainingWhiteRuleHandler.isListed( // it is not found in the training !CFGData.TrainingWhiteRuleHandler.isListed( // it is not found in the training
ScanData.CompositeFinalResult) // white list then... ScanData.CompositeFinalResult) // white list then...
} }


string snfLOGmgr::Timestamp(time_t t) { // Convert time_t to a timestamp s. string snfLOGmgr::Timestamp(time_t t) { // Convert time_t to a timestamp s.
stringstream TimestampBfr;
const string EmptyTimestamp = "00000000000000";
stringstream TimestampBfr;
const string EmptyTimestamp = "00000000000000";
string theTimeStamp = EmptyTimestamp; string theTimeStamp = EmptyTimestamp;
tm* gmt; // Get a ptr to a tm structure. tm* gmt; // Get a ptr to a tm structure.
gmt = gmtime(&t); // Fill it with UTC.
bool isValidGMT = (0 != gmt);
if(isValidGMT) {
TimestampBfr
<< setw(4) << (gmt->tm_year+1900)
<< setw(2) << setfill('0') << (gmt->tm_mon+1)
<< setw(2) << setfill('0') << (gmt->tm_mday)
<< setw(2) << setfill('0') << (gmt->tm_hour)
<< setw(2) << setfill('0') << (gmt->tm_min)
<< setw(2) << setfill('0') << (gmt->tm_sec)
;
theTimeStamp = TimestampBfr.str();
}
gmt = gmtime(&t); // Fill it with UTC.
bool isValidGMT = (0 != gmt);
if(isValidGMT) {
TimestampBfr
<< setw(4) << (gmt->tm_year+1900)
<< setw(2) << setfill('0') << (gmt->tm_mon+1)
<< setw(2) << setfill('0') << (gmt->tm_mday)
<< setw(2) << setfill('0') << (gmt->tm_hour)
<< setw(2) << setfill('0') << (gmt->tm_min)
<< setw(2) << setfill('0') << (gmt->tm_sec)
;
theTimeStamp = TimestampBfr.str();
}
return theTimeStamp; // Return a string. return theTimeStamp; // Return a string.
} }


} }
} }
} }
// 20090730_M - Moved persistent state aux saves to RecordSyncEvent. It makes
// sense for the persistent state to match the latext external record of state
// info. If SNFServer dies uncerimoneusly that is what we will remember.
int snfLOGmgr::SecsSinceStartup() {
return (int) difftime(Timestamp(), StartupTime);
}
// 20090730_M - Moved persistent state aux saves to RecordSyncEvent. It makes
// sense for the persistent state to match the latext external record of state
// info. If SNFServer dies uncerimoneusly that is what we will remember.
int snfLOGmgr::SecsSinceStartup() {
return (int) difftime(Timestamp(), StartupTime);
}


void snfLOGmgr::RecordSyncEvent() { // Sets timestamp of latest Sync. void snfLOGmgr::RecordSyncEvent() { // Sets timestamp of latest Sync.
Status.LastSyncTime = Timestamp(); // Set the Sync time.
Status.LastSyncTime = Timestamp(); // Set the Sync time.
if(Configured) Status.store(PersistentFileName); // Store our persistent data. if(Configured) Status.store(PersistentFileName); // Store our persistent data.
} }


} }


int snfLOGmgr::SecsSinceLastCondense() { // Gets seconds since latest Condense. int snfLOGmgr::SecsSinceLastCondense() { // Gets seconds since latest Condense.
return (int) difftime(Timestamp(), Status.LastCondenseTime);
return (int) difftime(Timestamp(), Status.LastCondenseTime);
} }


// Data in the multi-range sliding window is tracked in circular buffers. // Data in the multi-range sliding window is tracked in circular buffers.

読み込み中…
キャンセル
保存