25 #include <boost/units/systems/si/prefixes.hpp>
26 #include <boost/units/base_units/metric/bar.hpp>
27 #include <boost/units/physical_dimensions/pressure.hpp>
28 #include <boost/units/io.hpp>
29 #include <boost/units/systems/temperature/celsius.hpp>
30 #include <boost/units/systems/temperature/fahrenheit.hpp>
31 #include <boost/units/systems/si/velocity.hpp>
32 #include <boost/units/systems/si.hpp>
33 #include <boost/units/systems/si/dimensionless.hpp>
35 #include "auv_status.pb.h"
37 #include <boost/units/base_units/metric/nautical_mile.hpp>
41 CTDTestMessage test_msg;
43 using namespace boost::units;
44 using boost::units::metric::bar_base_unit;
45 using boost::units::si::deci;
47 typedef bar_base_unit::unit_type Bar;
51 quantity<Bar> pressure(150.123456789*si::deci*bar);
53 test_msg.set_pressure_with_units(pressure);
55 typedef boost::units::unit<boost::units::temperature_dimension,boost::units::si::system> Kelvin;
56 quantity<absolute<Kelvin> > temp(15*absolute<celsius::temperature>());
57 std::cout << temp << std::endl;
59 double temp_d = (temp - quantity<absolute<Kelvin> >(0*absolute<Kelvin>()))/Kelvin();
60 std::cout << temp_d << std::endl;
62 test_msg.set_temperature_with_units(15*absolute<fahrenheit::temperature>());
63 test_msg.set_micro_temp_with_units(15*Kelvin());
64 test_msg.set_salinity(35.2);
65 test_msg.set_sound_speed(1500);
67 quantity<si::velocity> c(1500*si::meters_per_second);
68 test_msg.set_sound_speed_with_units(c);
69 test_msg.set_depth_with_units(100*si::meters);
70 quantity<si::velocity> auv_spd(2.5*si::meters_per_second);
71 test_msg.set_auv_speed_with_units(auv_spd);
72 std::cout <<
"auv_spd: " <<auv_spd <<std::endl;
74 test_msg.set_salinity_with_units(38.9*si::dimensionless());
77 std::cout << test_msg.DebugString() << std::endl;
78 std::cout <<
"Temperature: " << test_msg.temperature_with_units() << std::endl;
79 std::cout <<
"Micro temperature: " << test_msg.micro_temp_with_units() << std::endl;
80 std::cout <<std::setprecision(10) <<
"Pressure: " << test_msg.pressure_with_units() << std::endl;
81 std::cout <<
"Pressure (as bars): " << quantity<Bar>(test_msg.pressure_with_units()) << std::endl;
82 std::cout <<
"Sound speed: " << test_msg.sound_speed_with_units() << std::endl;
83 std::cout <<
"AUV speed: " << test_msg.auv_speed_with_units() << std::endl;
84 std::cout <<
"Salinity: " << test_msg.salinity_with_units() << std::endl;
87 status.set_x_with_units(1000*si::meters);
88 status.set_y_with_units(500*si::meters);
89 status.set_heading_with_units(3.1415926535/2*si::radians);
91 typedef metric::nautical_mile_base_unit::unit_type NauticalMile;
92 quantity<NauticalMile> x_nm(status.x_with_units());
93 quantity<NauticalMile> y_nm(status.y_with_units());
95 std::cout << status.DebugString() << std::endl;
96 std::cout << x_nm << std::endl;
97 std::cout << y_nm << std::endl;
98 std::cout << status.heading_with_units() << std::endl;
102 p.set_mass_with_units(2*si::kilograms);
103 p.set_si_mass_with_units(10*si::kilograms);
104 p.mutable_child()->set_length_with_units(5*si::meters);
106 assert(p.mass() == 2000);
107 assert(p.si_mass() == 10);
108 assert(p.child().length() == 500);
110 std::cout <<
"all tests passed" << std::endl;