Matthew Barth | 5c15b79 | 2017-03-01 11:17:00 -0600 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2017 IBM 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 | */ |
Matthew Barth | cd4f4d1 | 2017-02-17 17:48:56 -0600 | [diff] [blame] | 16 | #include <sdbusplus/exception.hpp> |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 17 | #include "tach_sensor.hpp" |
Matthew Barth | cd4f4d1 | 2017-02-17 17:48:56 -0600 | [diff] [blame] | 18 | #include "fan_enclosure.hpp" |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 19 | |
| 20 | |
| 21 | namespace phosphor |
| 22 | { |
| 23 | namespace fan |
| 24 | { |
| 25 | namespace presence |
| 26 | { |
| 27 | |
| 28 | bool TachSensor::isPresent() |
| 29 | { |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame] | 30 | return (tach != 0); |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 31 | } |
| 32 | |
Matthew Barth | f85dddc | 2017-06-02 11:31:06 -0500 | [diff] [blame] | 33 | void TachSensor::handleTachChange(sdbusplus::message::message& sdbpMsg) |
Matthew Barth | cd4f4d1 | 2017-02-17 17:48:56 -0600 | [diff] [blame] | 34 | { |
| 35 | std::string msgSensor; |
| 36 | std::map<std::string, sdbusplus::message::variant<int64_t>> msgData; |
| 37 | sdbpMsg.read(msgSensor, msgData); |
| 38 | |
Matthew Barth | f85dddc | 2017-06-02 11:31:06 -0500 | [diff] [blame] | 39 | // Find the 'Value' property containing tach |
| 40 | auto valPropMap = msgData.find("Value"); |
| 41 | if (valPropMap != msgData.end()) |
Matthew Barth | cd4f4d1 | 2017-02-17 17:48:56 -0600 | [diff] [blame] | 42 | { |
Matthew Barth | f85dddc | 2017-06-02 11:31:06 -0500 | [diff] [blame] | 43 | tach = sdbusplus::message::variant_ns::get<int64_t>( |
| 44 | valPropMap->second); |
Matthew Barth | cd4f4d1 | 2017-02-17 17:48:56 -0600 | [diff] [blame] | 45 | } |
| 46 | // Update inventory according to latest tach reported |
| 47 | fanEnc.updInventory(); |
| 48 | } |
| 49 | |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 50 | } // namespace presence |
| 51 | } // namespace fan |
| 52 | } // namespace phosphor |