1 /* 2 // Copyright (c) 2018 Intel Corporation 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 */ 16 17 #pragma once 18 19 #include "dbushelper_interface.hpp" 20 #include "interfaces.hpp" 21 22 #include <cstdint> 23 #include <memory> 24 #include <string> 25 26 namespace pid_control 27 { 28 29 class DbusWritePercent : public WriteInterface 30 { 31 public: 32 static std::unique_ptr<WriteInterface> createDbusWrite( 33 const std::string& path, int64_t min, int64_t max, 34 std::unique_ptr<DbusHelperInterface> helper); 35 DbusWritePercent(const std::string & path,int64_t min,int64_t max,const std::string & connectionName)36 DbusWritePercent(const std::string& path, int64_t min, int64_t max, 37 const std::string& connectionName) : 38 WriteInterface(min, max), path(path), connectionName(connectionName) 39 {} 40 41 void write(double value) override; 42 void write(double value, bool force, int64_t* written) override; 43 44 private: 45 std::string path; 46 std::string connectionName; 47 int64_t oldValue = -1; 48 }; 49 50 class DbusWrite : public WriteInterface 51 { 52 public: 53 static std::unique_ptr<WriteInterface> createDbusWrite( 54 const std::string& path, int64_t min, int64_t max, 55 std::unique_ptr<DbusHelperInterface> helper); 56 DbusWrite(const std::string & path,int64_t min,int64_t max,const std::string & connectionName)57 DbusWrite(const std::string& path, int64_t min, int64_t max, 58 const std::string& connectionName) : 59 WriteInterface(min, max), path(path), connectionName(connectionName) 60 {} 61 62 void write(double value) override; 63 void write(double value, bool needRedundant, int64_t* rawWritten) override; 64 65 private: 66 std::string path; 67 std::string connectionName; 68 int64_t oldValue = -1; 69 }; 70 71 } // namespace pid_control 72