//===-- apps/ccam/ccam.cpp --------------------------------------*- C++ -*-===//
//
//                 The RoSA Framework -- Application CCAM
//
//===----------------------------------------------------------------------===//
///
/// \file apps/ccam/ccam.cpp
///
/// \author Maximilian Goetzinger (maximilian.goetzinger@tuwien.ac.at)
///
/// \date 2019
///
/// \brief The application CCAM implements the case study from the paper:
/// M. Goetzinger, N. TaheriNejad, H. A. Kholerdi, A. Jantsch, E. Willegger,
/// T. Glatzl, A.M. Rahmani, T.Sauter, P. Liljeberg: Model - Free Condition
/// Monitoring with Confidence
//===----------------------------------------------------------------------===//

#include "rosa/agent/FunctionAbstractions.hpp"
#include "rosa/agent/SignalStateDetector.hpp"

#include <iostream>

using namespace rosa::agent;

int main(void) {

  /*
// Just some tests :D
std::vector vec = {7, 3, 5, 1, 9};

std::sort(vec.rbegin(), vec.rend());
// std::reverse(vec.begin(), vec.end());

for (auto it = vec.cbegin(); it != vec.cend(); ++it) {
  std::cout << *it << ' ';
}
 */

  std::shared_ptr<PartialFunction<float, float>> PartFunc(
      new PartialFunction<float, float>(
          {
              {{0.f, 3.f},
               std::make_shared<LinearFunction<float, float>>(0.f, 1.f / 3)},
              {{3.f, 6.f},
               std::make_shared<LinearFunction<float, float>>(1.f, 0.f)},
              {{6.f, 9.f},
               std::make_shared<LinearFunction<float, float>>(3.f, -1.f / 3)},
          },
          0));

  std::shared_ptr<StepFunction<float, float>> StepFunc(
      new StepFunction<float, float>(1 / 10));

  SignalStateDetector<float, float, float, HistoryPolicy::SRWF> TestSigSD(
      10000, PartFunc, PartFunc, StepFunc, StepFunc, PartFunc, PartFunc, 10, 5,
      1000);

  unsigned int i;

  for (i = 1; i <= 30; i++) {
    TestSigSD.detectSignalState(50.3f);
    // std::cout << "test";
  }

  for (; i <= 60; i++) {
    TestSigSD.detectSignalState(100.6f);
  }

  return 0;
}
