1
0
Fork 0

consistent naming for raw values

This commit is contained in:
Kevin Matz 2023-05-21 10:36:39 -04:00
parent a15b0d90f7
commit 75c5e107ea
3 changed files with 39 additions and 44 deletions

View File

@ -169,7 +169,7 @@ enum Priority : uint8_t {
/// Set the communication behavior during ArtPoll
struct TalkToMe {
union {
uint8_t _raw = 0;
uint8_t value = 0;
struct {
bool depreciated : 1;
bool reply_on_change : 1; //!< Send ArtPollReply whenever Node conditions change.
@ -189,13 +189,8 @@ struct TalkToMe {
* Bit 15 high indicates extended features available.
*/
struct OEM {
/**
* @brief OEM
* @param value
*/
OEM(uint16_t value = oem_unknown) : word(value) {}
union {
uint16_t word;
uint16_t value = oem_unknown;
struct {
uint16_t manufacturer : 15;
bool extended_features : 1;
@ -242,7 +237,7 @@ enum FailoverMode : uint8_t {
*/
struct GeneralStatus {
union {
uint8_t _raw1 = 0;
uint8_t value1 = 0;
struct {
bool ubea_valid : 1; //!< UBEA present and not corrupt.
bool rdm_capable : 1; //!< Capable of Remote Device Management (RDM).
@ -253,7 +248,7 @@ struct GeneralStatus {
};
};
union {
uint8_t _raw2 = 0;
uint8_t value2 = 0;
struct {
bool web_config_available : 1; //!< supports web browser configuration.
bool DHCP_active : 1; //!< Nodes IP is DHCP configured.
@ -266,7 +261,7 @@ struct GeneralStatus {
};
};
union {
uint8_t _raw3 = 0;
uint8_t value3 = 0;
struct {
uint8_t reserved3 : 5; //!< Not used, set to zero
bool failover_capable : 1; //!< Node supports fail-over.
@ -298,7 +293,7 @@ enum KnownProtocols : uint8_t {
*/
struct PortTypes {
union {
uint8_t _raw = 0;
uint8_t value = 0;
struct {
KnownProtocols protocol : 6;
bool can_input : 1;
@ -315,7 +310,7 @@ struct PortTypes {
*/
struct GoodInput {
union {
uint8_t _raw = 0;
uint8_t value = 0;
struct {
uint8_t reserved : 2; //!< Unused and transmitted as zero.
bool rx_errors : 1; //!< Receive errors detected.
@ -336,7 +331,7 @@ struct GoodInput {
*/
struct GoodOutput {
union {
uint8_t _rawA = 0;
uint8_t valueA = 0;
struct {
bool sACN_enabled : 1; //!< Output is selected to transmit sACN.
bool merge_LTP : 1; //!< Merge Mode is LTP.
@ -349,7 +344,7 @@ struct GoodOutput {
};
};
union {
uint8_t _rawB = 0;
uint8_t valueB = 0;
struct {
uint8_t reserved : 6; //!< Not used, set to zero
bool output_continuous : 1; //!< oposite of changes-only
@ -366,7 +361,7 @@ struct GoodOutput {
*/
struct ActivityReport {
union {
uint8_t _raw = 0;
uint8_t value = 0;
struct {
bool active_1 : 1;
bool active_2 : 1;

View File

@ -37,7 +37,7 @@ void poll_data::iStream(std::shared_ptr<bufferstream> stream)
stream->get(); // 4
if (version < VERSION)
return stream->setstate(std::ios_base::failbit);
*stream >> talk_to_me._raw; // 5
*stream >> talk_to_me.value; // 5
diagnostic_level = static_cast<Priority>(stream->get()); // 6
}
@ -46,7 +46,7 @@ void poll_data::oStream(std::shared_ptr<bufferstream> stream) const
{ // Field #
stream->put(version >> 8); // 3
stream->put(version & 0xff); // 4
*stream << talk_to_me._raw; // 5
*stream << talk_to_me.value; // 5
*stream << diagnostic_level; // 6
}
@ -85,10 +85,10 @@ void pollreply_data::iStream(std::shared_ptr<bufferstream> stream)
stream->get(); // 6
net_sub_switch.value = stream->get() << 8 | // 7
stream->get() << 4; // 8
oem.word = stream->get() << 8 | // 9
stream->get(); // 10
oem.value = stream->get() << 8 | // 9
stream->get(); // 10
*stream >> ubea_version; // 11
*stream >> status._raw1; // 12
*stream >> status.value1; // 12
esta_manufacturer = stream->get() | // 13
stream->get() << 8; // 14
stream->readString(short_name, Short_Name_Length); // 15
@ -97,18 +97,18 @@ void pollreply_data::iStream(std::shared_ptr<bufferstream> stream)
num_ports = stream->get() << 8 | // 18
stream->get(); // 19
for( size_t i = 0; i < sizeof(port_types) / sizeof(PortTypes); i++)
*stream >> port_types[i]._raw; // 20
*stream >> port_types[i].value; // 20
for( size_t i = 0; i < sizeof(good_input) / sizeof(GoodInput); i++)
*stream >> good_input[i]._raw; // 21
*stream >> good_input[i].value; // 21
for( size_t i = 0; i < sizeof(good_output) / sizeof(GoodOutput); i++)
*stream >> good_output[i]._rawA; // 22
*stream >> good_output[i].valueA; // 22
for( size_t i = 0; i < sizeof(SwIn); i++)
SwIn[i] = stream->get() & 0x0f; // 23
for( size_t i = 0; i < sizeof(SwOut); i++)
SwOut[i] = stream->get() & 0x0f; // 24
*stream >> SwVideo; // 25
*stream >> SwMacro._raw; // 26
*stream >> SwRemote._raw; // 27
*stream >> SwMacro.value; // 26
*stream >> SwRemote.value; // 27
stream->get(); // 28
stream->get(); // 29
stream->get(); // 30
@ -117,9 +117,9 @@ void pollreply_data::iStream(std::shared_ptr<bufferstream> stream)
*stream >> mac_address[i-1]; // 32-37
*stream >> bind_ip; // 38
*stream >> bind_index; // 39
*stream >> status._raw2; // 40
*stream >> good_output->_rawB; // 41
*stream >> status._raw3; // 42
*stream >> status.value2; // 40
*stream >> good_output->valueB; // 41
*stream >> status.value3; // 42
for( size_t i = 0; i < _filler_length; i++)
stream->get(); // 43
}
@ -133,10 +133,10 @@ void pollreply_data::oStream(std::shared_ptr<bufferstream> stream) const
stream->put(version & 0xff); // 6
stream->put(net_sub_switch.value >> 8); // 7
stream->put(net_sub_switch.value >> 4 & 0x0f); // 8
stream->put(oem.word >> 8); // 9
stream->put(oem.word & 0xff); // 10
stream->put(oem.value >> 8); // 9
stream->put(oem.value & 0xff); // 10
*stream << ubea_version; // 11
*stream << status._raw1; // 12
*stream << status.value1; // 12
stream->put(esta_manufacturer & 0xff); // 13
stream->put(esta_manufacturer >> 8); // 14
stream->writeString(short_name, Short_Name_Length, true); // 15
@ -145,18 +145,18 @@ void pollreply_data::oStream(std::shared_ptr<bufferstream> stream) const
stream->put(num_ports >> 8); // 18
stream->put(num_ports & 0xff); // 19
for( size_t i = 0; i < sizeof(port_types) / sizeof(PortTypes); i++)
*stream << port_types[i]._raw; // 20
*stream << port_types[i].value; // 20
for( size_t i = 0; i < sizeof(good_input) / sizeof(GoodInput); i++)
*stream << good_input[i]._raw; // 21
*stream << good_input[i].value; // 21
for( size_t i = 0; i < sizeof(good_output) / sizeof(GoodOutput); i++)
*stream << good_output[i]._rawA; // 22
*stream << good_output[i].valueA; // 22
for( size_t i = 0; i < sizeof(SwIn); i++)
stream->put(SwIn[i] &0x0f); // 23
for( size_t i = 0; i < sizeof(SwOut); i++)
stream->put(SwOut[i] &0x0f); // 24
*stream << SwVideo; // 25
*stream << SwMacro._raw; // 26
*stream << SwRemote._raw; // 27
*stream << SwMacro.value; // 26
*stream << SwRemote.value; // 27
stream->put(0); // 28
stream->put(0); // 29
stream->put(0); // 30
@ -165,9 +165,9 @@ void pollreply_data::oStream(std::shared_ptr<bufferstream> stream) const
*stream << mac_address[i-1]; // 32-37
*stream << bind_ip; // 38
*stream << bind_index; // 39
*stream << status._raw2; // 40
*stream << good_output->_rawB; // 41
*stream << status._raw3; // 42
*stream << status.value2; // 40
*stream << good_output->valueB; // 41
*stream << status.value3; // 42
for( size_t i = 0; i < _filler_length; i++)
stream->put(0); // 43
}
@ -380,8 +380,8 @@ void trigger_data::iStream(std::shared_ptr<bufferstream> stream)
return stream->setstate(std::ios_base::failbit);
stream->get(); // 5
stream->get(); // 6
oem.word = stream->get() << 8 | // 7
stream->get(); // 8
oem.value = stream->get() << 8 | // 7
stream->get(); // 8
*stream >> key; // 9
*stream >> subkey; // 10
stream->read(data, sizeof(data)); // 11
@ -394,8 +394,8 @@ void trigger_data::oStream(std::shared_ptr<bufferstream> stream) const
stream->put(version & 0xff); // 4
stream->put(0); // 5
stream->put(0); // 6
stream->put(oem.word >> 8); // 7
stream->put(oem.word & 0xff); // 8
stream->put(oem.value >> 8); // 7
stream->put(oem.value & 0xff); // 8
*stream << key; // 9
*stream << subkey; // 10
stream->write(data, sizeof(data)); // 11

View File

@ -77,7 +77,7 @@ struct pollreply_data
{
pollreply_data()
: udp_port(UDP_PORT)
, oem(MY_ARTNET_MANUFACTUER_ID)
, oem({.manufacturer=MY_ARTNET_MANUFACTUER_ID})
, esta_manufacturer(MY_ESTA_MANUFACTURER_ID)
{};