Tomáš Pecka | ddf04a3 | 2020-06-17 15:32:01 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
| 11 | namespace velia { |
| 12 | |
| 13 | LedOutputCallback::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 | { |
| 18 | m_redLed->set(0); |
| 19 | m_greenLed->set(0); |
| 20 | m_blueLed->set(0); |
| 21 | } |
| 22 | |
| 23 | void LedOutputCallback::operator()(State state) |
| 24 | { |
| 25 | switch (state) { |
| 26 | case State::ERROR: |
| 27 | m_redLed->set(255); |
| 28 | m_greenLed->set(0); |
| 29 | m_blueLed->set(0); |
| 30 | break; |
| 31 | case State::WARNING: |
| 32 | m_redLed->set(255); |
| 33 | m_greenLed->set(160); |
| 34 | m_blueLed->set(0); |
| 35 | break; |
| 36 | case State::OK: |
| 37 | m_redLed->set(0); |
| 38 | m_greenLed->set(255); |
| 39 | m_blueLed->set(0); |
| 40 | break; |
| 41 | } |
| 42 | } |
| 43 | } |