Skip to content

Commit

Permalink
Remove obsolete code lines and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gordonb3 committed Nov 17, 2016
1 parent fb80124 commit fb6509d
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 326 deletions.
2 changes: 0 additions & 2 deletions hardware/EcoDevices.cpp
Expand Up @@ -145,8 +145,6 @@ void CEcoDevices::GetMeterDetails()
//Send Electra if value changed, or at least every 5 minutes
if (
(m_p1power.usagecurrent != m_lastelectrausage) ||
//GB3: Unsafe to assume time_t format is seconds
// (atime - m_lastSharedSendElectra >= 300)
(difftime(atime,m_lastSharedSendElectra) >= 300)
)
{
Expand Down
2 changes: 0 additions & 2 deletions hardware/HardwareMonitor.cpp
Expand Up @@ -587,8 +587,6 @@ void CHardwareMonitor::RunWMIQuery(const char* qTable, const std::string &qType)
if (ret==4)
{
long long t = (actload1+actload2+actload3)-m_lastloadcpu;
//GB3: Unsafe to assume time_t format is seconds
// double cpuper=((t / ((acttime-m_lastquerytime) * HZ)) * 100)/double(m_totcpu);
double cpuper=((t / (difftime(acttime,m_lastquerytime) * HZ)) * 100)/double(m_totcpu);
if (cpuper>0)
{
Expand Down
3 changes: 0 additions & 3 deletions hardware/Netatmo.cpp
Expand Up @@ -733,9 +733,6 @@ void CNetatmo::SetSetpoint(const int idx, const float temp)
tempDest = (tempDest - 32.0f) / 1.8f;
}

//GB3: Unsafe to assume time_t format is seconds
// time_t end_time = time(NULL);
// end_time += 3600; //One hour
time_t now = mytime(NULL);
struct tm etime;
localtime_r(&now, &etime);
Expand Down
4 changes: 0 additions & 4 deletions hardware/P1MeterBase.cpp
Expand Up @@ -172,8 +172,6 @@ bool P1MeterBase::MatchLine()
if (l_exclmarkfound) {
time_t atime=mytime(NULL);
sDecodeRXMessage(this, (const unsigned char *)&m_p1power, "Power", 255);
//GB3: Unsafe to assume time_t format is seconds
// bool bSend2Shared=(atime-m_lastSharedSendElectra>59);
bool bSend2Shared=(difftime(atime,m_lastSharedSendElectra)>59);
if (std::abs(double(m_lastelectrausage)-double(m_p1power.usagecurrent))>40)
bSend2Shared=true;
Expand All @@ -184,8 +182,6 @@ bool P1MeterBase::MatchLine()
}
if (
(m_p1gas.gasusage!=m_lastgasusage)||
//GB3: Unsafe to assume time_t format is seconds
// (atime-m_lastSharedSendGas>=300)
(difftime(atime,m_lastSharedSendGas)>=300)
)
{
Expand Down
2 changes: 0 additions & 2 deletions hardware/Pinger.cpp
Expand Up @@ -358,8 +358,6 @@ void CPinger::UpdateNodeStatus(const PingNode &Node, const bool bPingOK)
}
else
{
//GB3: Unsafe to assume time_t format is seconds
// if (atime - itt->LastOK >= Node.SensorTimeoutSec)
if (difftime(atime,itt->LastOK) >= Node.SensorTimeoutSec)
{
itt->LastOK = atime;
Expand Down
8 changes: 0 additions & 8 deletions hardware/RFLinkBase.cpp
Expand Up @@ -289,8 +289,6 @@ bool CRFLinkBase::WriteToHardware(const char *pdata, const unsigned char length)

// Wait for an OK response from RFLink to make sure the command was executed
while (m_bTXokay == false) {
//GB3: Unsafe to assume time_t format is seconds
// if (btime-atime > 4) {
if (difftime(btime,atime) > 4) {
_log.Log(LOG_ERROR, "RFLink: TX time out...");
return false;
Expand Down Expand Up @@ -399,8 +397,6 @@ bool CRFLinkBase::WriteToHardware(const char *pdata, const unsigned char length)

// Wait for an OK response from RFLink to make sure the command was executed
while (m_bTXokay == false) {
//GB3: Unsafe to assume time_t format is seconds
// if (btime - atime > 4) {
if (difftime(btime,atime) > 4) {
_log.Log(LOG_ERROR, "RFLink: TX time out...");
return false;
Expand All @@ -426,8 +422,6 @@ bool CRFLinkBase::WriteToHardware(const char *pdata, const unsigned char length)

// Wait for an OK response from RFLink to make sure the command was executed
while (m_bTXokay == false) {
//GB3: Unsafe to assume time_t format is seconds
// if (btime - atime > 4) {
if (difftime(btime,atime) > 4) {
_log.Log(LOG_ERROR, "RFLink: TX time out...");
return false;
Expand Down Expand Up @@ -1033,8 +1027,6 @@ namespace http {

// Wait for an OK response from RFLink to make sure the command was executed
while (pRFLINK->m_bTXokay == false) {
//GB3: Unsafe to assume time_t format is seconds
// if (btime - atime > 4) {
if (difftime(btime,atime) > 4) {
_log.Log(LOG_ERROR, "RFLink: TX time out...");
bCreated = false;
Expand Down
4 changes: 0 additions & 4 deletions hardware/RFLinkSerial.cpp
Expand Up @@ -96,17 +96,13 @@ void CRFLinkSerial::Do_Work()
time_t atime = mytime(NULL);
//Send ping (keep alive)
//_log.Log(LOG_STATUS, "RFLink: t1=%d t3=%d", atime, m_LastReceivedTime);
//GB3: Unsafe to assume time_t format is seconds
// if (atime - m_LastReceivedTime > 50) {
if (difftime(atime,m_LastReceivedTime) > 50) {
//Receive Timeout
//_log.Log(LOG_STATUS, "RFLink: ping50...");
write("10;PING;\n");
m_retrycntr = 0;
m_LastReceivedTime = atime;
} else {
//GB3: Unsafe to assume time_t format is seconds
// if (atime - m_LastReceivedTime > 25) {
if (difftime(atime,m_LastReceivedTime) > 25) {
//_log.Log(LOG_STATUS, "RFLink: ping25...");
write("10;PING;\n");
Expand Down
6 changes: 0 additions & 6 deletions hardware/Rego6XXSerial.cpp
Expand Up @@ -384,8 +384,6 @@ bool CRego6XXSerial::ParseData()
m_Rego6XXTemp.temperature = (float)(data * 0.1);
if((m_Rego6XXTemp.temperature >= -48.2) && // -48.3 means no sensor.
((fabs(m_Rego6XXTemp.temperature - g_allRegisters[m_pollcntr].lastTemp) > 0.09) || // Only send changes.
//GB3: Unsafe to assume time_t format is seconds
// (atime - g_allRegisters[m_pollcntr].lastSent >= 300))) // Send at least every 5 minutes
(difftime(atime,g_allRegisters[m_pollcntr].lastSent) >= 300))) // Send at least every 5 minutes
{
g_allRegisters[m_pollcntr].lastSent = atime;
Expand All @@ -399,8 +397,6 @@ bool CRego6XXSerial::ParseData()
m_Rego6XXValue.value = data;
m_Rego6XXValue.subtype=sTypeRego6XXStatus;
if((m_Rego6XXValue.value != g_allRegisters[m_pollcntr].lastValue) || // Only send changes.
//GB3: Unsafe to assume time_t format is seconds
// (atime - g_allRegisters[m_pollcntr].lastSent >= (3600 * 23))) // Send at least every 23 hours
(difftime(atime,g_allRegisters[m_pollcntr].lastSent) >= (3600 * 23))) // Send at least every 23 hours
{
g_allRegisters[m_pollcntr].lastSent = atime;
Expand All @@ -414,8 +410,6 @@ bool CRego6XXSerial::ParseData()
m_Rego6XXValue.value = data;
m_Rego6XXValue.subtype=sTypeRego6XXCounter;
if((m_Rego6XXValue.value != g_allRegisters[m_pollcntr].lastValue) || // Only send changes.
//GB3: Unsafe to assume time_t format is seconds
// (atime - g_allRegisters[m_pollcntr].lastSent >= 3000)) // Send at least every 50 minutes
(difftime(atime,g_allRegisters[m_pollcntr].lastSent) >= 3000)) // Send at least every 50 minutes
{
g_allRegisters[m_pollcntr].lastSent = atime;
Expand Down
3 changes: 0 additions & 3 deletions hardware/SolarEdgeAPI.cpp
Expand Up @@ -170,10 +170,7 @@ void SolarEdgeAPI::GetMeterDetails()
if (ActHourMin - 60 > sunSet)
return;

//GB3: Unsafe to assume time_t format is seconds
// time_t atime_min5 = atime - 600; //minus 10 minutes
struct tm ltime_min5;
// localtime_r(&atime_min5, &ltime_min5);
time_t atime_min5;
int isdst = ltime.tm_isdst;
bool goodtime = false;
Expand Down
4 changes: 0 additions & 4 deletions hardware/ToonThermostat.cpp
Expand Up @@ -737,8 +737,6 @@ bool CToonThermostat::ParsePowerUsage(const Json::Value &root)
if (
(m_p1power.usagecurrent != m_lastelectrausage) ||
(m_p1power.delivcurrent != m_lastelectradeliv) ||
//GB3: Unsafe to assume time_t format is seconds
// (atime - m_lastSharedSendElectra >= 300)
(difftime(atime,m_lastSharedSendElectra) >= 300)
)
{
Expand All @@ -764,8 +762,6 @@ bool CToonThermostat::ParseGasUsage(const Json::Value &root)
//Send GAS if the value changed, or at least every 5 minutes
if (
(m_p1gas.gasusage != m_lastgasusage) ||
//GB3: Unsafe to assume time_t format is seconds
// (atime - m_lastSharedSendGas >= 300)
(difftime(atime,m_lastSharedSendGas) >= 300)
)
{
Expand Down
2 changes: 0 additions & 2 deletions hardware/ZWaveBase.cpp
Expand Up @@ -108,8 +108,6 @@ void ZWaveBase::Do_Work()
if (m_bControllerCommandInProgress==true)
{
time_t atime=mytime(NULL);
//GB3: Unsafe to assume time_t format is seconds
// time_t tdiff=atime-m_ControllerCommandStartTime;
time_t tdiff=difftime(atime,m_ControllerCommandStartTime);
if (tdiff>=CONTROLLER_COMMAND_TIMEOUT)
{
Expand Down
7 changes: 3 additions & 4 deletions main/EventSystem.cpp
Expand Up @@ -2196,8 +2196,9 @@ void CEventSystem::EvaluatePython(const std::string &reason, const std::string &
time_t now = time(0);
struct tm ltime;
localtime_r(&now, &ltime);
//GB3: No - must determine the actual time
// int minutesSinceMidnight = (ltime.tm_hour * 60) + ltime.tm_min;
//GB3: number of hours since midnight may be different from ltime.tm_hour
// determine the correct time_t value for midnight and use difftime()
// to find the correct number of minutes since midnight.
struct tm mtime;
time_t tmidnight;
int isdst = ltime.tm_isdst;
Expand Down Expand Up @@ -2373,8 +2374,6 @@ void CEventSystem::EvaluateLua(const std::string &reason, const std::string &fil
time_t now = time(0);
struct tm ltime;
localtime_r(&now, &ltime);
//GB3: No - must determine the actual time
// int minutesSinceMidnight = (ltime.tm_hour * 60) + ltime.tm_min;
struct tm mtime;
time_t tmidnight;
int isdst = ltime.tm_isdst;
Expand Down

0 comments on commit fb6509d

Please sign in to comment.