util.cpp (8c051121ade815a46e39d5c669fee77302df2b6d) | util.cpp (31058fd3fcc5b8b2d09282d89cef64a18e20b5da) |
---|---|
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 --- 55 unchanged lines hidden (view full) --- 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 { | 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 --- 55 unchanged lines hidden (view full) --- 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"; | 72 std::cout << "\n\t\t\t" << input.name; 73 if (input.convertTempToMargin) 74 { 75 std::cout << "[" << input.convertMarginZero << "]"; 76 } 77 std::cout << ",\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"; --- 10 unchanged lines hidden (view full) --- 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 | 78 } 79 std::cout << "\t\t\t}\n"; 80 std::cout << "\t\t\t" << pidconf.second.setpoint << ",\n"; 81 std::cout << "\t\t\t{" << pidconf.second.pidInfo.ts << ",\n"; 82 std::cout << "\t\t\t" << pidconf.second.pidInfo.proportionalCoeff 83 << ",\n"; 84 std::cout << "\t\t\t" << pidconf.second.pidInfo.integralCoeff 85 << ",\n"; --- 10 unchanged lines hidden (view full) --- 96 std::cout << "\t\t\t" << pidconf.second.pidInfo.slewPos << ",\n"; 97 std::cout << "\t\t\t}\n\t\t}\n"; 98 } 99 std::cout << "\t},\n"; 100 } 101 std::cout << "}\n\n"; 102} 103 |
104std::vector<conf::SensorInput> 105 spliceInputs(const std::vector<std::string>& inputNames, 106 const std::vector<double>& inputTempToMargin) 107{ 108 std::vector<conf::SensorInput> results; 109 110 // Default to the TempToMargin feature disabled 111 for (const auto& inputName : inputNames) 112 { 113 conf::SensorInput newInput{ 114 inputName, std::numeric_limits<double>::quiet_NaN(), false}; 115 116 results.emplace_back(newInput); 117 } 118 119 size_t resultSize = results.size(); 120 size_t marginSize = inputTempToMargin.size(); 121 122 for (size_t index = 0; index < resultSize; ++index) 123 { 124 // If fewer doubles than strings, and vice versa, ignore remainder 125 if (index >= marginSize) 126 { 127 break; 128 } 129 130 // Both vectors have this index, combine both into SensorInput 131 results[index].convertMarginZero = inputTempToMargin[index]; 132 results[index].convertTempToMargin = true; 133 } 134 135 return results; 136} 137 138std::vector<std::string> 139 splitNames(const std::vector<conf::SensorInput>& sensorInputs) 140{ 141 std::vector<std::string> results; 142 143 for (const auto& sensorInput : sensorInputs) 144 { 145 results.emplace_back(sensorInput.name); 146 } 147 148 return results; 149} 150 |
|
99} // namespace pid_control | 151} // namespace pid_control |