gtouchable
Loading...
Searching...
No Matches
gelectronic.cc
Go to the documentation of this file.
1// gtouchable
2#include "gelectronic.h"
3
4// for UNINITIALIZEDNUMBERQUANTITY
5#include "gutsConventions.h"
6
7// See header for API docs.
8
9// Constructor initializing GElectronic with specified address and mode.
10GElectronic::GElectronic(int c, int s, int ch, int m) : crate(c), slot(s), channel(ch), mode(m) {
11}
12
13// Default constructor initializing GElectronic with uninitialized values.
17
18
19// Sets the hardware address.
20void GElectronic::setHAddress(int c, int s, int ch) {
21 crate = c;
22 slot = s;
23 channel = ch;
24}
25
26// Returns the hardware address as a vector.
27std::vector<int> GElectronic::getHAddress() {
28 return {crate, slot, channel};
29}
30
31// Equality operator comparing based on the mode.
32bool GElectronic::operator==(const GElectronic& ge) const {
33 if (this->mode == 0) {
34 return this->crate == ge.crate;
35 }
36 else if (this->mode == 1) {
37 return this->crate == ge.crate && this->slot == ge.slot;
38 }
39 else if (this->mode == 2) {
40 return this->crate == ge.crate && this->slot == ge.slot && this->channel == ge.channel;
41 }
42 return false;
43}
44
45// Overloaded output stream operator for GElectronic.
46std::ostream& operator<<(std::ostream& stream, const GElectronic& ge) {
47 stream << " Crate: " << ge.crate;
48 stream << " Slot: " << ge.slot;
49 stream << " Channel: " << ge.channel;
50
51 return stream;
52}
std::ostream & operator<<(std::ostream &stream, const GElectronic &ge)
Defines GElectronic, a compact hardware address used by digitization and translation tables.
#define UNINITIALIZEDNUMBERQUANTITY
Represents an electronic module address (crate/slot/channel) with configurable comparison granularity...
Definition gelectronic.h:33
std::vector< int > getHAddress()
Returns the hardware address as a vector of three integers.
GElectronic()
Default constructor.
void setHAddress(int c, int s, int ch)
Sets the hardware address fields (crate/slot/channel).