blob: 4ecd8ce807aa093d4e6a31d8cca7153193e11842 [file] [log] [blame]
Patrick Venture39199b42020-10-08 14:40:29 -07001/*
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#include "util.hpp"
17
18#include "conf.hpp"
19
20#include <cstdint>
21#include <iostream>
22#include <map>
23#include <string>
24
25namespace pid_control
26{
27
28void debugPrint(const std::map<std::string, conf::SensorConfig>& sensorConfig,
29 const std::map<int64_t, conf::PIDConf>& zoneConfig,
30 const std::map<int64_t, conf::ZoneConfig>& zoneDetailsConfig)
31{
32 if constexpr (!conf::DEBUG)
33 {
34 return;
35 }
36 // print sensor config
37 std::cout << "sensor config:\n";
38 std::cout << "{\n";
39 for (const auto& pair : sensorConfig)
40 {
41
42 std::cout << "\t{" << pair.first << ",\n\t\t{";
43 std::cout << pair.second.type << ", ";
44 std::cout << pair.second.readPath << ", ";
45 std::cout << pair.second.writePath << ", ";
46 std::cout << pair.second.min << ", ";
47 std::cout << pair.second.max << ", ";
48 std::cout << pair.second.timeout << "},\n\t},\n";
49 }
50 std::cout << "}\n\n";
51 std::cout << "ZoneDetailsConfig\n";
52 std::cout << "{\n";
53 for (const auto& zone : zoneDetailsConfig)
54 {
55 std::cout << "\t{" << zone.first << ",\n";
56 std::cout << "\t\t{" << zone.second.minThermalOutput << ", ";
57 std::cout << zone.second.failsafePercent << "}\n\t},\n";
58 }
59 std::cout << "}\n\n";
60 std::cout << "ZoneConfig\n";
61 std::cout << "{\n";
62 for (const auto& zone : zoneConfig)
63 {
64 std::cout << "\t{" << zone.first << "\n";
65 for (const auto& pidconf : zone.second)
66 {
67 std::cout << "\t\t{" << pidconf.first << ",\n";
68 std::cout << "\t\t\t{" << pidconf.second.type << ",\n";
69 std::cout << "\t\t\t{";
70 for (const auto& input : pidconf.second.inputs)
71 {
72 std::cout << "\n\t\t\t" << input << ",\n";
73 }
74 std::cout << "\t\t\t}\n";
75 std::cout << "\t\t\t" << pidconf.second.setpoint << ",\n";
76 std::cout << "\t\t\t{" << pidconf.second.pidInfo.ts << ",\n";
77 std::cout << "\t\t\t" << pidconf.second.pidInfo.proportionalCoeff
78 << ",\n";
79 std::cout << "\t\t\t" << pidconf.second.pidInfo.integralCoeff
80 << ",\n";
81 std::cout << "\t\t\t" << pidconf.second.pidInfo.feedFwdOffset
82 << ",\n";
83 std::cout << "\t\t\t" << pidconf.second.pidInfo.feedFwdGain
84 << ",\n";
85 std::cout << "\t\t\t{" << pidconf.second.pidInfo.integralLimit.min
86 << "," << pidconf.second.pidInfo.integralLimit.max
87 << "},\n";
88 std::cout << "\t\t\t{" << pidconf.second.pidInfo.outLim.min << ","
89 << pidconf.second.pidInfo.outLim.max << "},\n";
90 std::cout << "\t\t\t" << pidconf.second.pidInfo.slewNeg << ",\n";
91 std::cout << "\t\t\t" << pidconf.second.pidInfo.slewPos << ",\n";
92 std::cout << "\t\t\t}\n\t\t}\n";
93 }
94 std::cout << "\t},\n";
95 }
96 std::cout << "}\n\n";
97}
98
99} // namespace pid_control