78 lines
2.3 KiB
C++
78 lines
2.3 KiB
C++
#include <list>
|
|
#include <print>
|
|
|
|
#include "mcc_netserver_proto.h"
|
|
|
|
int main()
|
|
{
|
|
using msg1_t = mcc::network::MccNetMessage<std::string_view>;
|
|
using msg2_t = mcc::network::MccNetMessage<std::string>;
|
|
|
|
mcc::network::MccNetMessage msg3("ACK");
|
|
|
|
std::string_view sv{"TARGET 11:22:33.212; -0.23876984; RADEC "};
|
|
std::vector<char> arr{sv.begin(), sv.end()};
|
|
|
|
msg1_t msg1;
|
|
|
|
msg1.fromCharRange(arr);
|
|
|
|
std::println("msg.key = <{}>", msg1.keyword());
|
|
std::println("msg.par[1] = <{}>", msg1.param(1));
|
|
|
|
std::vector<double> vd{1.1, 2.2, 3.3};
|
|
msg2_t msg2("ACK", 12.43298042, "EEE", std::chrono::seconds(10), vd);
|
|
// msg2_t msg2("ACK");
|
|
|
|
std::println("msg.bytes = <{}>", msg2.byteRepr());
|
|
std::println("msg.key = <{}>", msg2.keyword());
|
|
std::println("msg.par[1] = <{}>", msg2.param(1));
|
|
std::println("msg.par[2] = <{}>", msg2.param(2));
|
|
|
|
|
|
auto p2 = msg2.paramValue<std::chrono::seconds>(2);
|
|
std::println("msg.parvalue[2] = <{}>", p2.value_or(std::chrono::seconds{}));
|
|
|
|
|
|
std::print("msg.parvalue[3] = <");
|
|
auto p3 = msg2.paramValue<decltype(vd)>(3);
|
|
if (p3.has_value()) {
|
|
for (auto const& el : p3.value()) {
|
|
std::print("{} ", el);
|
|
}
|
|
}
|
|
std::println(">");
|
|
|
|
|
|
std::println("msg.par[1-2] joined = <{}>", msg2.params(1, 2));
|
|
|
|
auto vv = msg2.params<std::list<std::string_view>>(1, 3);
|
|
std::print("msg.par[1-3] array = <");
|
|
for (auto const& el : vv) {
|
|
std::print("{} ", el);
|
|
}
|
|
std::println(">");
|
|
|
|
|
|
std::println("\n\n");
|
|
|
|
mcc::impl::MccSkyPoint spt(mcc::impl::MccSkyRADEC_APP{"10:00:00.0"_hms, 12.098687_degs});
|
|
|
|
msg2.construct("ACK", "MOUNT", mcc::MccSerializedAngleFormatPrec{3, 2}, spt);
|
|
std::println("msg2.bytes = <{}>", msg2.byteRepr());
|
|
|
|
auto spt_d = msg2.paramValue<mcc::impl::MccSkyPoint>(1);
|
|
|
|
if (spt_d) {
|
|
std::println("msg2.parvalue(1).pairKind() = {}", MccCoordPairKindToStr(spt_d->pairKind()));
|
|
std::println("msg2.parvalue(1).epoch() = {}", spt_d->epoch().MJD() + mcc::MCC_MJD_ZERO);
|
|
} else {
|
|
std::println("cannot deserialize MccSkyPoint value!");
|
|
}
|
|
|
|
msg2.construct("ACK", "MOUNT", mcc::MccSerializedCoordPairFormat::MCC_SERIALIZED_FORMAT_DEGREES, spt);
|
|
std::println("msg2.bytes = <{}>", msg2.byteRepr());
|
|
|
|
return 0;
|
|
}
|