| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * This file is part of the Falcon Player (FPP) and is Copyright (C) | ||
| 4 | * 2013-2022 by the Falcon Player Developers. | ||
| 5 | * | ||
| 6 | * The Falcon Player (FPP) is free software, and is covered under | ||
| 7 | * multiple Open Source licenses. Please see the included 'LICENSES' | ||
| 8 | * file for descriptions of what files are covered by each license. | ||
| 9 | * | ||
| 10 | * This source file is covered under the LGPL v2.1 as described in the | ||
| 11 | * included LICENSE.LGPL file. | ||
| 12 | */ | ||
| 13 | |||
| 14 | // PLUGIN API: native plugins compile against this header and are loaded with | ||
| 15 | // dlopen(). | ||
| 16 | // - Plugins call Sensors::INSTANCE.reportSensors() by symbol. | ||
| 17 | // Data layout here is NOT plugin ABI, so members can change freely. Changing | ||
| 18 | // or removing a signature a plugin calls is: keep the old one as an overload | ||
| 19 | // (as Timers::addPeriodicTimer does) or bump FPP_PLUGIN_API_VERSION in | ||
| 20 | // Plugin.h. See .claude/PLUGIN-ABI.md for which plugins use what. | ||
| 21 | |||
| 22 | #include <functional> | ||
| 23 | #include "fpp-json-fwd.h" | ||
| 24 | #include <list> | ||
| 25 | #include <map> | ||
| 26 | #include <string> | ||
| 27 | |||
| 28 | class Sensor; | ||
| 29 | class SensorSource { | ||
| 30 | public: | ||
| 31 | SensorSource(Json::Value& config); | ||
| 32 | 16 | virtual ~SensorSource() {} | |
| 33 | |||
| 34 | 1 | virtual void Init(std::map<int, std::function<bool(int)>>& callbacks) {} | |
| 35 | ✗ | virtual void enable(int id) {} | |
| 36 | |||
| 37 | virtual void update(bool forceInstant = false) = 0; | ||
| 38 | virtual int32_t getValue(int id) = 0; | ||
| 39 | |||
| 40 | 39 | virtual const std::string& getID() const { return _id; } | |
| 41 | ✗ | virtual void lockToGroup(int i){}; | |
| 42 | |||
| 43 | 1 | virtual bool isOK() const { return true; } | |
| 44 | |||
| 45 | protected: | ||
| 46 | std::string _id; | ||
| 47 | }; | ||
| 48 | |||
| 49 | class Sensors { | ||
| 50 | public: | ||
| 51 | static Sensors INSTANCE; | ||
| 52 | Sensors(); | ||
| 53 | ~Sensors(); | ||
| 54 | |||
| 55 | void Init(std::map<int, std::function<bool(int)>>& callbacks); | ||
| 56 | void Close(); | ||
| 57 | |||
| 58 | void DetectHWSensors(); | ||
| 59 | void DetectFanSensors(); | ||
| 60 | void addSensors(Json::Value& config); | ||
| 61 | void reportSensors(Json::Value& root); | ||
| 62 | |||
| 63 | void addSensorSources(Json::Value& config); | ||
| 64 | |||
| 65 | void lockToGroup(int i); | ||
| 66 | void updateSensorSources(bool forceInstant = false); | ||
| 67 | SensorSource* getSensorSource(const std::string& name); | ||
| 68 | |||
| 69 | private: | ||
| 70 | Sensor* createSensor(Json::Value& s); | ||
| 71 | std::list<Sensor*> sensors; | ||
| 72 | std::list<SensorSource*> sensorSources; | ||
| 73 | }; | ||
| 74 |