2021-10-18 10:54:01 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "cycle_t.h"
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
|
2021-10-18 16:19:28 +00:00
|
|
|
cycle_t::action_t cycle_t::to_action(std::string value) noexcept {
|
2021-10-18 10:54:01 +00:00
|
|
|
if (value == "read")
|
|
|
|
return action_t::read;
|
|
|
|
if (value == "write")
|
|
|
|
return action_t::write;
|
2021-10-18 16:19:28 +00:00
|
|
|
return action_t::unknown;
|
2021-10-18 10:54:01 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 16:19:28 +00:00
|
|
|
std::string cycle_t::to_string(action_t value) noexcept {
|
2021-10-18 10:54:01 +00:00
|
|
|
if (value == action_t::read)
|
|
|
|
return "read";
|
|
|
|
if (value == action_t::write)
|
|
|
|
return "write";
|
2021-10-18 16:19:28 +00:00
|
|
|
return "unknown";
|
2021-10-18 10:54:01 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 16:19:28 +00:00
|
|
|
cycle_t::cycle_t(uint16_t address, uint8_t value, action_t action) noexcept
|
2021-10-18 10:54:01 +00:00
|
|
|
: m_address(address),
|
|
|
|
m_value(value),
|
|
|
|
m_action(action) {}
|
|
|
|
|
2021-10-18 16:19:28 +00:00
|
|
|
cycle_t::cycle_t(simdjson::dom::element input) noexcept
|
2021-10-18 10:54:01 +00:00
|
|
|
: cycle_t(input.get_array()) {}
|
|
|
|
|
2021-10-20 20:05:43 +00:00
|
|
|
cycle_t::cycle_t(simdjson::dom::array input) noexcept {
|
|
|
|
assert(input.size() == 3);
|
|
|
|
auto iterator = input.begin();
|
|
|
|
m_address = (uint16_t)(int64_t)*iterator;
|
|
|
|
m_value = (uint8_t)(int64_t)*++iterator;
|
|
|
|
m_action = to_action((std::string)*++iterator);
|
|
|
|
}
|