1 #include "newpacket.hpp"
2 #include "timeparse.hpp"
13 int real_main(int argc
, char** argv
)
15 std::map
<std::string
, uint16_t> channel_assignments
;
16 std::vector
<struct channel
> chans
;
17 uint16_t dummy_channel
= 0;
19 std::cerr
<< "syntax: muxdump.exe <input> <start> <end> <output>" << std::endl
;
23 read_channel
rchan(argv
[1]);
24 write_channel
wchan(argv
[4]);
25 uint64_t low
= parse_timespec(argv
[2]);
26 uint64_t high
= parse_timespec(argv
[3]);
28 std::cerr
<< "Start of region must be before end." << std::endl
;
32 //Create dummy channel.
33 channel_assignments
["<DUMMY>"] = dummy_channel
= (uint16_t)chans
.size();
35 c
.c_channel
= (uint16_t)chans
.size();
37 c
.c_channel_name
= "<DUMMY>";
39 wchan
.start_segment(chans
);
42 while((p
= rchan
.read())) {
43 if(p
->rp_timestamp
< low
|| p
->rp_timestamp
> high
)
45 if(!channel_assignments
.count(p
->rp_channel_name
)) {
46 //No channel yet, create.
47 channel_assignments
[p
->rp_channel_name
] = (uint16_t)chans
.size();
49 c
.c_channel
= (uint16_t)chans
.size();
50 c
.c_type
= p
->rp_major
;
51 c
.c_channel_name
= p
->rp_channel_name
;
53 wchan
.start_segment(chans
);
55 uint16_t chan
= channel_assignments
[p
->rp_channel_name
];
56 if(chans
[chan
].c_type
!= p
->rp_major
) {
58 chans
[chan
].c_type
= p
->rp_major
;
59 wchan
.start_segment(chans
);
62 p
->rp_timestamp
-= low
;
68 p2
.rp_channel
= dummy_channel
;
69 p2
.rp_timestamp
= high
- low
;