-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatapacket.h
109 lines (78 loc) · 2.97 KB
/
datapacket.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#pragma once
#ifndef DATAPACKET_H_INCLUDED
#define DATAPACKET_H_INCLUDED
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <sstream>
#include <string>
/* This file contains structs describing the "packets" generated in response to events.
In particular, you may be interested in:
- DigitalPacket: changes in any of the digital inputs (parallel port + SMA connectors)
- SpikePacket: timestamp, channel, online sort, and waveform of a spike
- StimPacket: timestamp, channel, and waveform of a microstimulation pulse.
NOTES:
- These could be classes, but there's no point in wrapping everything up with accessors.
There are destructors and stuff so memory is somewhat managed, but since everything
is public, feel free to shoot your own foot if you'd like....
- Waveforms are all in BYTES. See the NEVFile headers to determine how to assemble them
into arbitrary units (1, 2, or 3 bytes per sample) and then physical units (e.g., volts)
- Some (untested) code reassembles the continuation packets and appends them.
*/
struct Packet {
std::uint32_t timestamp;
virtual ~Packet() { }
};
struct WavePacket : Packet {
char* waveform;
std::size_t len;
std::uint16_t electrodeID;
WavePacket();
WavePacket(const WavePacket& rhs);
WavePacket(WavePacket&& rhs);
WavePacket& operator=(const WavePacket& rhs);
WavePacket& operator=(WavePacket&& rhs) noexcept;
~WavePacket();
private:
};
struct SpikePacket : WavePacket {
std::uint8_t unit;
SpikePacket();
SpikePacket(const SpikePacket& rhs);
SpikePacket(SpikePacket&& rhs);
SpikePacket& operator=(const SpikePacket &rhs);
SpikePacket& operator=(SpikePacket &&rhs);
friend std::ostream& operator<<(std::ostream& out, const SpikePacket &p);
};
struct StimPacket : WavePacket {
StimPacket();
StimPacket(const StimPacket& rhs);
StimPacket(StimPacket&& rhs);
StimPacket& operator=(const StimPacket &rhs);
StimPacket& operator=(StimPacket&& rhs);
friend std::ostream& operator<<(std::ostream& out, const StimPacket &p);
};
/***********************************************************************
DIGITAL I/O Packets and Types
***********************************************************************/
enum DigitalReason : std::uint8_t {
PARALLEL = 1, // Parallel port changed *or* serial was strobed
SMA1 = 2, // SMA 1 changed
SMA2 = 4, // SMA 2 changed
SMA3 = 8, // SMA 3 changed
SMA4 = 16, // SMA 4 changed
// Per the spec, there is no bit five.
PERIODIC = 64, // A periodic sampling event occured
SERIAL = 128 // Serial channel changed (see bit 0)
};
struct DigitalPacket : Packet {
DigitalReason reason;
std::uint16_t parallel;
std::int16_t SMA1;
std::int16_t SMA2;
std::int16_t SMA3;
std::int16_t SMA4;
~DigitalPacket() { }; //Nothing to do
friend std::ostream& operator<<(std::ostream &out, const DigitalPacket &p);
};
#endif