17136a5aeSJames Feist /* 27136a5aeSJames Feist // Copyright (c) 2018 Intel Corporation 37136a5aeSJames Feist // 47136a5aeSJames Feist // Licensed under the Apache License, Version 2.0 (the "License"); 57136a5aeSJames Feist // you may not use this file except in compliance with the License. 67136a5aeSJames Feist // You may obtain a copy of the License at 77136a5aeSJames Feist // 87136a5aeSJames Feist // http://www.apache.org/licenses/LICENSE-2.0 97136a5aeSJames Feist // 107136a5aeSJames Feist // Unless required by applicable law or agreed to in writing, software 117136a5aeSJames Feist // distributed under the License is distributed on an "AS IS" BASIS, 127136a5aeSJames Feist // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 137136a5aeSJames Feist // See the License for the specific language governing permissions and 147136a5aeSJames Feist // limitations under the License. 157136a5aeSJames Feist */ 167136a5aeSJames Feist 177136a5aeSJames Feist #pragma once 187136a5aeSJames Feist 19aadb30ddSPatrick Venture #include "dbushelper_interface.hpp" 20da4a5dd1SPatrick Venture #include "interfaces.hpp" 210c8223b5SJames Feist #include "util.hpp" 227136a5aeSJames Feist 237136a5aeSJames Feist #include <sdbusplus/bus.hpp> 24a83a3eccSPatrick Venture 25a83a3eccSPatrick Venture #include <memory> 26da4a5dd1SPatrick Venture #include <string> 277136a5aeSJames Feist 28a076487aSPatrick Venture namespace pid_control 29a076487aSPatrick Venture { 30a076487aSPatrick Venture 317136a5aeSJames Feist class DbusWritePercent : public WriteInterface 327136a5aeSJames Feist { 337136a5aeSJames Feist public: 34f5e770b3SPatrick Venture static std::unique_ptr<WriteInterface> 35f5e770b3SPatrick Venture createDbusWrite(const std::string& path, int64_t min, int64_t max, 368729eb98SPatrick Venture std::unique_ptr<DbusHelperInterface> helper); 37f5e770b3SPatrick Venture DbusWritePercent(const std::string & path,int64_t min,int64_t max,const std::string & connectionName)387136a5aeSJames Feist DbusWritePercent(const std::string& path, int64_t min, int64_t max, 39f5e770b3SPatrick Venture const std::string& connectionName) : 40*bd63bcacSPatrick Williams WriteInterface(min, max), path(path), connectionName(connectionName) 41a83a3eccSPatrick Venture {} 427136a5aeSJames Feist 437136a5aeSJames Feist void write(double value) override; 442400ce43SJosh Lehan void write(double value, bool force, int64_t* written) override; 457136a5aeSJames Feist 467136a5aeSJames Feist private: 477136a5aeSJames Feist std::string path; 487136a5aeSJames Feist std::string connectionName; 49cd9e109fSJames Feist int64_t oldValue = -1; 507136a5aeSJames Feist }; 517136a5aeSJames Feist 527136a5aeSJames Feist class DbusWrite : public WriteInterface 537136a5aeSJames Feist { 547136a5aeSJames Feist public: 55f5e770b3SPatrick Venture static std::unique_ptr<WriteInterface> 56f5e770b3SPatrick Venture createDbusWrite(const std::string& path, int64_t min, int64_t max, 578729eb98SPatrick Venture std::unique_ptr<DbusHelperInterface> helper); 58f5e770b3SPatrick Venture DbusWrite(const std::string & path,int64_t min,int64_t max,const std::string & connectionName)597136a5aeSJames Feist DbusWrite(const std::string& path, int64_t min, int64_t max, 60f5e770b3SPatrick Venture const std::string& connectionName) : 61*bd63bcacSPatrick Williams WriteInterface(min, max), path(path), connectionName(connectionName) 62a83a3eccSPatrick Venture {} 637136a5aeSJames Feist 647136a5aeSJames Feist void write(double value) override; 652400ce43SJosh Lehan void write(double value, bool needRedundant, int64_t* rawWritten) override; 667136a5aeSJames Feist 677136a5aeSJames Feist private: 687136a5aeSJames Feist std::string path; 697136a5aeSJames Feist std::string connectionName; 70cd9e109fSJames Feist int64_t oldValue = -1; 717136a5aeSJames Feist }; 72a076487aSPatrick Venture 73a076487aSPatrick Venture } // namespace pid_control 74