1863b9246SPatrick Venture /**
2863b9246SPatrick Venture  * Copyright 2017 Google Inc.
3863b9246SPatrick Venture  *
4863b9246SPatrick Venture  * Licensed under the Apache License, Version 2.0 (the "License");
5863b9246SPatrick Venture  * you may not use this file except in compliance with the License.
6863b9246SPatrick Venture  * You may obtain a copy of the License at
7863b9246SPatrick Venture  *
8863b9246SPatrick Venture  *     http://www.apache.org/licenses/LICENSE-2.0
9863b9246SPatrick Venture  *
10863b9246SPatrick Venture  * Unless required by applicable law or agreed to in writing, software
11863b9246SPatrick Venture  * distributed under the License is distributed on an "AS IS" BASIS,
12863b9246SPatrick Venture  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13863b9246SPatrick Venture  * See the License for the specific language governing permissions and
14863b9246SPatrick Venture  * limitations under the License.
15863b9246SPatrick Venture  */
16863b9246SPatrick Venture 
17da4a5dd1SPatrick Venture #include "sysfs/sysfsread.hpp"
18da4a5dd1SPatrick Venture 
19863b9246SPatrick Venture #include <chrono>
20863b9246SPatrick Venture #include <fstream>
21863b9246SPatrick Venture #include <iostream>
22863b9246SPatrick Venture 
23a076487aSPatrick Venture namespace pid_control
24a076487aSPatrick Venture {
25a076487aSPatrick Venture 
read(void)26863b9246SPatrick Venture ReadReturn SysFsRead::read(void)
27863b9246SPatrick Venture {
28863b9246SPatrick Venture     int64_t value;
29863b9246SPatrick Venture     std::ifstream ifs;
30863b9246SPatrick Venture 
31863b9246SPatrick Venture     ifs.open(_path);
32863b9246SPatrick Venture     ifs >> value;
33863b9246SPatrick Venture     ifs.close();
34863b9246SPatrick Venture 
35*1df9e879SPatrick Venture     ReadReturn r = {static_cast<double>(value),
36da4a5dd1SPatrick Venture                     std::chrono::high_resolution_clock::now()};
37863b9246SPatrick Venture 
38863b9246SPatrick Venture     return r;
39863b9246SPatrick Venture }
40a076487aSPatrick Venture 
41a076487aSPatrick Venture } // namespace pid_control
42