20 #include "eformat/HeaderMarker.h"
22 #include "eformat/Status.h"
23 #include "eformat/Issue.h"
24 #include "eformat/checksum.h"
28 static const unsigned int ROB_HEADER = 0;
29 static const unsigned int ROB_STATUS = 1;
30 static const unsigned int ROB_CHECKSUM_TYPE = 2;
31 static const unsigned int ROD_HEADER = 3;
32 static const unsigned int ROD_STATUS = 4;
33 static const unsigned int ROD_DATA = 5;
34 static const unsigned int ROD_TRAILER = 6;
35 static const unsigned int ROB_CHECKSUM = 7;
43 eformat::helper::Version
version(0, eformat::MAJOR_V40_VERSION);
63 set(
m_node[ROB_STATUS], &eformat::DEFAULT_STATUS, 1,
64 &
m_node[ROB_CHECKSUM_TYPE]);
68 set(
m_node[ROD_STATUS], &eformat::DEFAULT_STATUS, 1, &
m_node[ROD_DATA]);
74 set(
m_node[ROD_STATUS], &eformat::DEFAULT_STATUS, 1, &
m_node[ROD_TRAILER]);
94 rob_source_id(source_id);
95 rod_source_id(source_id);
99 rod_lvl1_type(lvl1_type);
100 rod_detev_type(detev_type);
103 this->status_position(status_position);
104 status(1, &eformat::DEFAULT_STATUS);
105 rod_data(ndata,
data);
119 this->rob_source_id(rob_source_id);
120 this->rod_source_id(rod_source_id);
122 rod_lvl1_id(lvl1_id);
124 rod_lvl1_type(lvl1_type);
125 rod_detev_type(detev_type);
128 this->status_position(status_position);
129 status(1, &eformat::DEFAULT_STATUS);
130 rod_data(ndata,
data);
148 status(1, &eformat::DEFAULT_STATUS);
150 status_position(
rod[size_word-1]);
151 rod_data(
rod[size_word-2],
152 status_position()?&
rod[9]:&
rod[9+
rod[size_word-3]]);
153 rod_status(
rod[size_word-3],
154 status_position()?&
rod[9+
rod[size_word-2]]:&
rod[9]);
156 m_rod_header[2] = eformat::DEFAULT_ROD_VERSION | (0xffff & m_rod_header[2]);
158 rob_source_id(rod_source_id());
169 if (
read.check_rod_noex()) {
171 rod_data(
read.rod_ndata(),
tmp);
173 else if (
read.payload_size_word() >= 9) {
175 rod_data(
read.payload_size_word()-9,
tmp+9);
191 rod_data(
other.rod_ndata(),
other.rod_data());
197 if (!
read.check_rob_noex()) {
198 throw EFORMAT_UNSUPPORTED_OPERATION(
"operate on corrupted", eformat::ROB);
200 eformat::helper::Version robver(
read.version());
201 minor_version(robver.minor_version());
202 rob_source_id(
read.source_id());
216 memcpy(m_rod_header,
rod, rod_size*
sizeof(
uint32_t));
217 if (m_parent) m_parent->size_change(m_node[ROB_HEADER].
base[1],
218 m_node[ROB_HEADER].
base[1] - size_diff);
219 m_node[ROD_HEADER].size_word = rod_size;
220 m_node[ROB_HEADER].base[1] -= size_diff;
223 if (
read.check_rod_noex()) {
224 status_position(
read.rod_status_position());
226 rod_status(
read.rod_nstatus(),
tmp);
232 m_node[ROD_TRAILER].size_word = 0;
234 if (m_parent) m_parent->size_change(m_node[ROB_HEADER].
base[1],
235 m_node[ROB_HEADER].
base[1] - size_diff);
236 m_node[ROB_HEADER].base[1] -= size_diff;
238 checksum_type(
read.checksum_type());
244 minor_version(
other.minor_version());
245 rob_source_id(
other.source_id());
246 memcpy(
reinterpret_cast<void*
>(m_rod_header),
247 reinterpret_cast<const void*
>(
other.m_rod_header), 9*
sizeof(
uint32_t));
249 if (
other.m_node[ROD_HEADER].size_word != 9) {
253 m_node[ROD_HEADER].size_word =
other.m_node[ROD_HEADER].size_word;
254 if (m_parent) m_parent->size_change(m_node[ROB_HEADER].
base[1],
255 m_node[ROB_HEADER].
base[1] - size_diff);
256 m_node[ROB_HEADER].base[1] -= size_diff;
260 status_position(
other.status_position());
261 rod_status(
other.rod_nstatus(),
other.rod_status());
263 if (
other.m_node[ROD_TRAILER].size_word != 3) {
265 uint32_t size_diff = 3 -
other.m_node[ROD_TRAILER].size_word;
266 m_node[ROD_TRAILER].size_word =
other.m_node[ROD_TRAILER].size_word;
267 if (m_parent) m_parent->size_change(m_node[ROB_HEADER].
base[1],
268 m_node[ROB_HEADER].
base[1] - size_diff);
269 m_node[ROB_HEADER].base[1] -= size_diff;
271 checksum_type(
other.checksum_type());
276 if (m_parent) m_parent->size_change(m_node[ROB_HEADER].
base[1],
277 m_node[ROB_HEADER].
base[1]-m_node[ROB_HEADER].
base[5]+
n);
278 m_node[ROB_HEADER].base[1] -= m_node[ROB_HEADER].base[5];
279 m_node[ROB_HEADER].base[2] -= m_node[ROB_HEADER].base[5];
280 m_node[ROB_STATUS].size_word = m_node[ROB_HEADER].base[5] =
n;
281 m_node[ROB_HEADER].base[1] +=
n;
282 m_node[ROB_HEADER].base[2] +=
n;
286 m_node[ROB_STATUS].base = status_nc;
292 if (m_parent) m_parent->size_change(m_node[ROB_HEADER].
base[1],
293 m_node[ROB_HEADER].
base[1]-m_node[ROD_TRAILER].
base[0]+
n);
294 m_node[ROB_HEADER].base[1] -= m_node[ROD_TRAILER].base[0];
295 m_node[ROD_STATUS].size_word = m_node[ROD_TRAILER].base[0] =
n;
296 m_node[ROB_HEADER].base[1] +=
n;
300 m_node[ROD_STATUS].base = status_nc;
305 if (
v == m_node[ROD_TRAILER].
base[2])
return;
306 m_node[ROD_TRAILER].base[2] =
v;
307 if (m_node[ROD_TRAILER].
base[2] == eformat::STATUS_FRONT) {
308 m_node[ROD_HEADER].next = &m_node[ROD_STATUS];
309 m_node[ROD_STATUS].next = &m_node[ROD_DATA];
310 m_node[ROD_DATA].next = &m_node[ROD_TRAILER];
313 m_node[ROD_HEADER].next = &m_node[ROD_DATA];
314 m_node[ROD_DATA].next = &m_node[ROD_STATUS];
315 m_node[ROD_STATUS].next = &m_node[ROD_TRAILER];
321 if (m_parent) m_parent->size_change(m_node[ROB_HEADER].
base[1],
322 m_node[ROB_HEADER].
base[1]-m_node[ROD_TRAILER].
base[1]+
n);
325 m_node[ROB_HEADER].base[1] -= m_node[ROD_TRAILER].base[1];
326 m_node[ROD_DATA].size_word = m_node[ROD_TRAILER].base[1] =
n;
327 m_node[ROB_HEADER].base[1] +=
n;
331 m_node[ROD_DATA].base = data_nc;
336 if (m_node[ROB_CHECKSUM_TYPE].
base[0] == eformat::NO_CHECKSUM &&
s != eformat::NO_CHECKSUM) {
339 m_parent->size_change(m_node[ROB_HEADER].
base[1], m_node[ROB_HEADER].
base[1]+1);
340 m_node[ROB_HEADER].base[1] += 1;
342 else if (m_node[ROB_CHECKSUM_TYPE].
base[0] != eformat::NO_CHECKSUM &&
343 s == eformat::NO_CHECKSUM) {
346 m_parent->size_change(m_node[ROB_HEADER].
base[1], m_node[ROB_HEADER].
base[1]-1);
347 m_node[ROB_HEADER].base[1] -= 1;
349 m_header[6] = m_node[ROB_CHECKSUM_TYPE].base[0] =
s;
354 m_node[ROD_TRAILER].next = 0;
355 return &m_node[ROD_HEADER];
360 m_node[ROD_TRAILER].next = 0;
361 m_node[ROB_CHECKSUM].next = 0;
362 if (checksum_type() != eformat::NO_CHECKSUM) {
363 m_checksum = eformat::write::checksum(checksum_type(), rod_bind());
364 m_node[ROD_TRAILER].next = &m_node[ROB_CHECKSUM];