-
Notifications
You must be signed in to change notification settings - Fork 0
/
temperature.cpp
51 lines (46 loc) · 1.7 KB
/
temperature.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <benri/si/temperature.h>
#include <iostream>
// sensor functions
inline auto get_outdoor_temperature()
{
using namespace benri::si::temperature;
// return fake data
return 10_degree_celsius;
}
inline auto get_indoor_temperature()
{
using namespace benri::si::temperature;
// return fake data
return 18_degree_celsius;
}
int main()
{
using namespace benri::si;
using namespace benri::si::temperature;
using namespace benri::casts;
// get sensor data
auto indoor = get_indoor_temperature();
auto outdoor = get_outdoor_temperature();
// calculate difference
auto difference = outdoor - indoor;
// print data in celsius
std::wcout << "-------------------------\n"
<< "outside: " << outdoor.value() << L"°C\n"
<< "inside: " << indoor.value() << L"°C\n"
<< "delta: " << difference.value() << "C\n"
<< std::flush;
// print data in kelvin
std::wcout << "-------------------------\n"
<< "outside: " << simple_cast<degree_kelvin_t>(outdoor).value() << L"°K\n"
<< "inside: " << simple_cast<degree_kelvin_t>(indoor).value() << L"°K\n"
<< "delta: " << simple_cast<kelvin_t>(difference).value() << "K\n"
<< std::flush;
// print data in fahrenheit
std::wcout << "-------------------------\n"
<< "outside: " << simple_cast<degree_fahrenheit_t>(outdoor).value()
<< L"°F\n"
<< "inside: " << simple_cast<degree_fahrenheit_t>(indoor).value()
<< L"°F\n"
<< "delta: " << simple_cast<fahrenheit_t>(difference).value() << "F\n"
<< std::flush;
}