blob: e12da462180883070ee4945066b015dd316e93e7 [file] [log] [blame]
Tomáš Peckaddf04a32020-06-17 15:32:01 +02001/*
2 * Copyright (C) 2020 CESNET, https://photonics.cesnet.cz/
3 *
4 * Written by Tomáš Pecka <tomas.pecka@fit.cvut.cz>
5 *
6*/
7
8#include "callables.h"
9#include "outputs/LedSysfsDriver.h"
10
11namespace velia {
12
13LedOutputCallback::LedOutputCallback(std::shared_ptr<LedSysfsDriver> red, std::shared_ptr<LedSysfsDriver> green, std::shared_ptr<LedSysfsDriver> blue)
14 : m_redLed(std::move(red))
15 , m_greenLed(std::move(green))
16 , m_blueLed(std::move(blue))
17{
Tomáš Pecka7ff533b2020-07-17 15:01:16 +020018 reset();
19}
20
21LedOutputCallback::~LedOutputCallback()
22{
23 reset();
24}
25
26void LedOutputCallback::reset()
27{
Tomáš Peckaddf04a32020-06-17 15:32:01 +020028 m_redLed->set(0);
29 m_greenLed->set(0);
30 m_blueLed->set(0);
31}
32
33void LedOutputCallback::operator()(State state)
34{
35 switch (state) {
36 case State::ERROR:
37 m_redLed->set(255);
38 m_greenLed->set(0);
39 m_blueLed->set(0);
40 break;
41 case State::WARNING:
42 m_redLed->set(255);
43 m_greenLed->set(160);
44 m_blueLed->set(0);
45 break;
46 case State::OK:
47 m_redLed->set(0);
48 m_greenLed->set(255);
49 m_blueLed->set(0);
50 break;
51 }
52}
53}