The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

SmoothingOperator.cpp 2.7 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//================================================================================
// Name        : SmoothingOperator.cpp
// Author      : Alessio Netti
// Contact     : info@dcdb.it
// Copyright   : Leibniz Supercomputing Centre
// Description :
//================================================================================

//================================================================================
// This file is part of DCDB (DataCenter DataBase)
// Copyright (C) 2019-2019 Leibniz Supercomputing Centre
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//================================================================================

#include "SmoothingOperator.h"

SmoothingOperator::SmoothingOperator(const std::string& name) : OperatorTemplate(name) {
31
    _separator = "-";
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    _exclude = "";
}

SmoothingOperator::SmoothingOperator(const SmoothingOperator &other) : OperatorTemplate(other) {
    _separator = other._separator;
    _exclude = "";
}

SmoothingOperator::~SmoothingOperator() {}

void SmoothingOperator::printConfig(LOG_LEVEL ll) {
    OperatorTemplate<SmoothingSensorBase>::printConfig(ll);
}

void SmoothingOperator::compute(U_Ptr unit) {
    // Clearing the buffer
    _buffer.clear();
    SmoothingSBPtr sIn=unit->getInputs()[0], sOut=unit->getOutputs()[0];
    uint64_t startTs = sOut->getTimestamp() ? getTimestamp()-sOut->getTimestamp() : 0;
51
52

    // Throwing an error does not make sense here - the query will often fail depending on insert batching
53
    if(!_queryEngine.querySensor(sIn->getName(), startTs, 0, _buffer, true))
54
        return;
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
    
    for(const auto& v : _buffer) {
        if (v.timestamp > sOut->getTimestamp()) {
            for(const auto& s : unit->getOutputs())
                s->smoothAndStore(v);
        } else {
            continue;
        }
    }
}

bool SmoothingOperator::execOnStart() {
    // Setting the reference initial timestamp
    for(const auto& u : _units)
        for(const auto& s : u->getOutputs()) {
            s->setTimestamp(0);
            s->setValue(0.0);
        }
        
    return true;
}