pflib v3.9.4-12-gf8bd325
Pretty Fine HGCROC Interaction Library
Loading...
Searching...
No Matches
get_lpgbt_temps.h
1#pragma once
2
3#include <sys/stat.h>
4#include <yaml-cpp/yaml.h>
5
6#include <cmath>
7#include <fstream>
8#include <sstream>
9#include <vector>
10
11#include "../pftool.h"
12#include "pflib/zcu/lpGBT_ICEC_ZCU_Simple.h"
13
14inline std::vector<std::string> split_csv(const std::string& line) {
16 std::stringstream ss(line);
17 std::string item;
18
19 while (std::getline(ss, item, ',')) {
20 out.push_back(item);
21 }
22 return out;
23}
24
25inline bool file_exists(const std::string& name) {
26 struct stat buffer;
27 return (stat(name.c_str(), &buffer) == 0);
28}
29
30// Assumes a PT1000 sensor by default (r0=1000)
31inline double rtd_resistance_to_celsius(double resistance_ohms,
32 double r0 = 1000.0,
33 double alpha = 0.00385) {
34 // Not a physical value
35 if (resistance_ohms < 0.0) return std::numeric_limits<double>::quiet_NaN();
36
37 double temperature = (resistance_ohms / r0 - 1.0) / alpha;
38
39 return temperature;
40}
41
42inline bool yaml_has_chipid(const std::string& yaml_file, std::string& chipid) {
43 if (!file_exists(yaml_file)) return false;
44 YAML::Node results = YAML::LoadFile(yaml_file);
45 if (!results[chipid]) return false;
46 YAML::Node entry = results[chipid];
47 YAML::Node cal = entry["calib_constants"];
48
49 return cal["CHIPID"].as<std::string>() == chipid;
50}
51
52void get_lpgbt_temps(Target* tgt);
T c_str(T... args)
encapulating a given setup's access rules
Definition Target.h:24
T getline(T... args)
Shared declarations for all pftool menu commands.
T push_back(T... args)
T quiet_NaN(T... args)