Browse Source

Fixed inappropriate bool operation in interval timer ! not ~

master
Pete McNeil 4 years ago
parent
commit
2f5cd98bfb
1 changed files with 39 additions and 39 deletions
  1. 39
    39
      snfLOGmgr.cpp

+ 39
- 39
snfLOGmgr.cpp View File

@@ -8,8 +8,8 @@
#include "snfLOGmgr.hpp"
#include "../CodeDweller/threading.hpp"
#include "../CodeDweller/timing.hpp"
#include <unistd.h>
#include <sstream>
#include <unistd.h>
#include <sstream>
#include <iomanip>

using namespace std;
@@ -94,7 +94,7 @@ void DiscLogger::myTask() {

snfScanData::snfScanData(int ScanHorizon) : // How to create.
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.
}

@@ -210,7 +210,7 @@ Timer& IntervalTimer::Inactive() {

msclock IntervalTimer::hack() { // Chop off a new interval & return it.
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.
}

@@ -227,14 +227,14 @@ msclock IntervalTimer::Elapsed() {
const ThreadType snfLOGmgr::Type("snfLOGmgr"); // The thread's type.

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.
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.
MinuteStatusLogger("Minute Status Logger"), // Lazy writer for Minute status.
HourStatusLogger("Hour Status Logger"), // Lazy writer for Hour status.
@@ -1018,13 +1018,13 @@ void snfLOGmgr::doXHDRs(snfCFGData& CFGData, snfScanData& ScanData) {
}
}

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

if(
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
!CFGData.TrainingWhiteRuleHandler.isListed( // it is not found in the training
ScanData.CompositeFinalResult) // white list then...
@@ -1739,23 +1739,23 @@ time_t snfLOGmgr::Timestamp() {
}

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;
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.
}

@@ -1839,17 +1839,17 @@ void snfLOGPersistentState::restore(string& FileNameToRestore) {
}
}
}
// 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.
Status.LastSyncTime = Timestamp(); // Set the Sync time.
Status.LastSyncTime = Timestamp(); // Set the Sync time.
if(Configured) Status.store(PersistentFileName); // Store our persistent data.
}

@@ -1870,7 +1870,7 @@ void snfLOGmgr::RecordCondenseEvent() {
}

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.

Loading…
Cancel
Save