| #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_SENSORS_NIC_SENSOR_H_ |
| #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_SENSORS_NIC_SENSOR_H_ |
| |
| #include <memory> |
| #include <optional> |
| |
| #include "absl/status/statusor.h" |
| #include "boost/asio.hpp" //NOLINT: boost::asio is commonly used in BMC |
| #include "nic_telemetry_config.pb.h" |
| #include "sensor_instance_properties.pb.h" |
| #include "tlbmc/hal/nic_veeprom/interface.h" |
| #include "sensor.pb.h" |
| #include "tlbmc/sensors/sync_polling_sensor.h" |
| |
| namespace milotic_tlbmc { |
| |
| class NicSensor : public SyncPollingSensor { |
| private: |
| class Token; |
| |
| public: |
| static absl::StatusOr<std::shared_ptr<NicSensor>> Create( |
| const NicTelemetryInstance& instance_config, |
| const EntityCommonConfig& entity_common_config, |
| const std::shared_ptr<boost::asio::io_context>& io_context, |
| const nic_veeprom::Accessor& accessor, |
| std::optional<NotificationCb> on_batch_notify = std::nullopt); |
| |
| NicSensor(Token token, nic_veeprom::NicTelemetryName telemetry_name, |
| const EntityCommonConfig& entity_common_config, |
| const SensorInstanceProperties& sensor_instance_properties, |
| const std::shared_ptr<boost::asio::io_context>& io_context, |
| const nic_veeprom::Accessor& accessor, |
| std::optional<NotificationCb> on_batch_notify = std::nullopt); |
| |
| ~NicSensor() override = default; |
| |
| protected: |
| absl::StatusOr<SensorValue> ReadSensorData() override; |
| |
| private: |
| class Token { |
| private: |
| explicit Token() = default; |
| friend NicSensor; |
| }; |
| |
| const nic_veeprom::NicTelemetryName telemetry_name_; |
| |
| const nic_veeprom::Accessor& accessor_; |
| }; |
| |
| } // namespace milotic_tlbmc |
| |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_SENSORS_NIC_SENSOR_H_ |