8000 Major refactoring · vanvught/rpidmx512@52856cd · GitHub
[go: up one dir, main page]

Skip to content

Commit 52856cd

Browse files
committed
Major refactoring
- Code cleanup
1 parent 0dace99 commit 52856cd

File tree

267 files changed

+57931
-2251
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

267 files changed

+57931
-2251
lines changed

lib-artnet/include/artnetnode.h

Lines changed: 95 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,100 @@ class ArtNetNode {
182182
public:
183183
ArtNetNode();
184184

185+
void SetOutput(LightSet *pLightSet) {
186+
m_pLightSet = pLightSet;
187+
#if (ARTNET_VERSION >= 4)
188+
E131Bridge::SetOutput(pLightSet);
189+
#endif
190+
}
191+
LightSet *GetOutput() const {
192+
return m_pLightSet;
193+
}
194+
195+
void SetDisableMergeTimeout(const bool bDisable) {
196+
m_State.bDisableMergeTimeout = bDisable;
197+
#if (ARTNET_VERSION >= 4)
198+
E131Bridge::SetDisableMergeTimeout(bDisable);
199+
#endif
200+
}
201+
bool GetDisableMergeTimeout() const {
202+
return m_State.bDisableMergeTimeout;
203+
}
204+
205+
void SetFailSafe(const artnetnode::FailSafe failsafe); /// TODO Subject for deletion
206+
void SetFailSafe(const lightset::FailSafe failsafe);
207+
lightset::FailSafe GetFailSafe();
208+
209+
void SetUniverse(const uint32_t nPortIndex, const lightset::PortDir dir, const uint16_t nUniverse);
210+
bool GetUniverse(const uint32_t nPortIndex, uint16_t &nUniverse, const lightset::PortDir portDirection) {
211+
if (m_Node.Port[nPortIndex].protocol == artnet::PortProtocol::ARTNET) {
212+
return ArtNetNode::GetPortAddress(nPortIndex, nUniverse, portDirection);
213+
}
214+
#if (ARTNET_VERSION >= 4)
215+
if (m_Node.Port[nPortIndex].protocol == artnet::PortProtocol::SACN) {
216+
return E131Bridge::GetUniverse(nPortIndex, nUniverse, portDirection);
217+
}
218+
#endif
219+
return false;
220+
}
221+
222+
void SetMergeMode(const uint32_t nPortIndex, const lightset::MergeMode mergeMode);
223+
lightset::MergeMode GetMergeMode(const uint32_t nPortIndex) const {
224+
assert(nPortIndex < artnetnode::MAX_PORTS);
225+
if ((m_OutputPort[nPortIndex].GoodOutput & artnet::GoodOutput::MERGE_MODE_LTP) == artnet::GoodOutput::MERGE_MODE_LTP) {
226+
return lightset::MergeMode::LTP;
227+
}
228+
return lightset::MergeMode::HTP;
229+
}
230+
231+
#if defined (OUTPUT_HAVE_STYLESWITCH)
232+
void SetOutputStyle(const uint32_t nPortIndex, lightset::OutputStyle outputStyle);
233+
lightset::OutputStyle GetOutputStyle(const uint32_t nPortIndex) const;
234+
#endif
235+
236+
void SetRdm(const bool doEnable);
237+
bool GetRdm() const {
238+
return m_State.rdm.IsEnabled;
239+
}
240+
241+
void SetRdm(const uint32_t nPortIndex, const bool bEnable);
242+
bool GetRdm(const uint32_t nPortIndex) const {
243+
assert(nPortIndex < artnetnode::MAX_PORTS);
244+
return !((m_OutputPort[nPortIndex].GoodOutputB & artnet::GoodOutputB::RDM_DISABLED) == artnet::GoodOutputB::RDM_DISABLED);
245+
}
246+
247+
#if (ARTNET_VERSION >= 4)
248+
void SetPortProtocol4(const uint32_t nPortIndex, const artnet::PortProtocol portProtocol);
249+
artnet::PortProtocol GetPortProtocol4(const uint32_t nPortIndex) const {
250+
assert(nPortIndex < artnetnode::MAX_PORTS);
251+
return m_Node.Port[nPortIndex].protocol;
252+
}
253+
254+
void SetMapUniverse0(const bool bMapUniverse0 = false) {
255+
m_Node.bMapUniverse0 = bMapUniverse0;
256+
}
257+
bool IsMapUniverse0() const {
258+
return m_Node.bMapUniverse0;
259+
}
260+
261+
void SetPriority4(const uint32_t nPriority) {
262+
m_ArtPollReply.AcnPriority = static_cast<uint8_t>(nPriority);
263+
264+
for (uint32_t nPortIndex = 0; nPortIndex < e131bridge::MAX_PORTS; nPortIndex++) {
265+
E131Bridge::SetPriority(nPortIndex, static_cast<uint8_t>(nPriority));
266+
}
267+
}
268+
269+
void SetPriority(const uint32_t nPortIndex, const uint8_t nPriority) {
270+
E131Bridge::SetPriority(nPortIndex, nPriority);
271+
}
272+
uint8_t GetPriority(const uint32_t nPortIndex) const {
273+
return E131Bridge::GetPriority(nPortIndex);
274+
}
275+
#endif
276+
277+
void Print();
278+
185279
void Start();
186280
void Stop();
187281

@@ -252,47 +346,6 @@ class ArtNetNode {
252346
return artnet::VERSION;
253347
}
254348

255-
void SetOutputStyle(const uint32_t nPortIndex, lightset::OutputStyle outputStyle);
256-
lightset::OutputStyle GetOutputStyle(const uint32_t nPortIndex) const;
257-
258-
void SetFailSafe(const artnetnode::FailSafe failsafe);
259-
260-
artnetnode::FailSafe GetFailSafe() {
261-
const auto networkloss = (m_ArtPollReply.Status3 & artnet::Status3::NETWORKLOSS_MASK);
262-
switch (networkloss) {
263-
case artnet::Status3::NETWORKLOSS_LAST_STATE:
264-
return artnetnode::FailSafe::LAST;
265-< 442 div class="diff-text-inner"> break;
266-
case artnet::Status3::NETWORKLOSS_OFF_STATE:
267-
return artnetnode::FailSafe::OFF;
268-
break;
269-
case artnet::Status3::NETWORKLOSS_ON_STATE:
270-
return artnetnode::FailSafe::ON;
271-
break;
272-
case artnet::Status3::NETWORKLOSS_PLAYBACK:
273-
return artnetnode::FailSafe::PLAYBACK;
274-
break;
275-
default:
276-
assert(0);
277-
__builtin_unreachable();
278-
break;
279-
}
280-
281-
__builtin_unreachable();
282-
return artnetnode::FailSafe::OFF;
283-
}
284-
285-
void SetOutput(LightSet *pLightSet) {
286-
m_pLightSet = pLightSet;
287-
#if (ARTNET_VERSION >= 4)
288-
E131Bridge::SetOutput(pLightSet);
289-
#endif
290-
}
291-
292-
LightSet *GetOutput() const {
293-
return m_pLightSet;
294-
}
295-
296349
uint32_t GetActiveInputPorts() const {
297350
return m_State.nEnabledInputPorts;
298351
}
@@ -314,8 +367,6 @@ class ArtNetNode {
314367

315368
void GetLongNameDefault(char *);
316369

317-
void SetUniverse(const uint32_t nPortIndex, const lightset::PortDir dir, const uint16_t nUniverse);
318-
319370
lightset::PortDir GetPortDirection(const uint32_t nPortIndex) const {
320371
assert(nPortIndex < artnetnode::MAX_PORTS);
321372
return m_Node.Port[nPortIndex].direction;
@@ -355,26 +406,6 @@ class ArtNetNode {
355406
return false;
356407
}
357408

358-
void SetMergeMode(const uint32_t nPortIndex, const lightset::MergeMode mergeMode);
359-
lightset::MergeMode GetMergeMode(const uint32_t nPortIndex) const {
360-
assert(nPortIndex < artnetnode::MAX_PORTS);
361-
if ((m_OutputPort[nPortIndex].GoodOutput & artnet::GoodOutput::MERGE_MODE_LTP) == artnet::GoodOutput::MERGE_MODE_LTP) {
362-
return lightset::MergeMode::LTP;
363-
}
364-
return lightset::MergeMode::HTP;
365-
}
366-
367-
void SetRdm(const bool doEnable);
368-
bool GetRdm() const {
369-
return m_State.rdm.IsEnabled;
370-
}
371-
372-
void SetRdm(const uint32_t nPortIndex, const bool bEnable);
373-
bool GetRdm(const uint32_t nPortIndex) const {
374-
assert(nPortIndex < artnetnode::MAX_PORTS);
375-
return !((m_OutputPort[nPortIndex].GoodOutputB & artnet::GoodOutputB::RDM_DISABLED) == artnet::GoodOutputB::RDM_DISABLED);
376-
}
377-
378409
void SetRdmDiscovery(const uint32_t nPortIndex, const bool bEnable);
379410
bool GetRdmDiscovery(const uint32_t nPortIndex) const {
380411
assert(nPortIndex < artnetnode::MAX_PORTS);
@@ -427,17 +458,6 @@ class ArtNetNode {
427458
void SetRdmResponder(ArtNetRdmResponder *pArtNetRdmResponder, const bool doEnable = true);
428459
#endif
429460

430-
void SetDisableMergeTimeout(bool bDisable) {
431-
m_State.bDisableMergeTimeout = bDisable;
432-
#if (ARTNET_VERSION >= 4)
433-
E131Bridge::SetDisableMergeTimeout(bDisable);
434-
#endif
435-
}
436-
437-
bool GetDisableMergeTimeout() const {
438-
return m_State.bDisableMergeTimeout;
439-
}
440-
441461
#if defined (ARTNET_HAVE_TIMECODE)
442462
void SendTimeCode(const struct artnet::TimeCode *pArtNetTimeCode) {
443463
assert(pArtNetTimeCode != nullptr);
@@ -488,8 +508,6 @@ class ArtNetNode {
488508
}
489509
}
490510

491-
void Print();
492-
493511
static ArtNetNode* Get() {
494512
return s_pThis;
495513
}
@@ -505,37 +523,6 @@ class ArtNetNode {
505523
/**
506524
* Art-Net 4
507525
*/
508-
void SetMapUniverse0(const bool bMapUniverse0 = false) {
509-
m_Node.bMapUniverse0 = bMapUniverse0;
510-
}
511-
bool IsMapUniverse0() const {
512-
return m_Node.bMapUniverse0;
513-
}
514-
515-
void SetPriority4(const uint32_t nPriority) {
516-
m_ArtPollReply.AcnPriority = static_cast<uint8_t>(nPriority);
517-
518-
for (uint32_t nPortIndex = 0; nPortIndex < e131bridge::MAX_PORTS; nPortIndex++) {
519-
E131Bridge::SetPriority(nPortIndex, static_cast<uint8_t>(nPriority));
520-
}
521-
}
522-
523-
void SetPortProtocol4(const uint32_t nPortIndex, const artnet::PortProtocol portProtocol);
524-
artnet::PortProtocol GetPortProtocol4(const uint32_t nPortIndex) const {
525-
assert(nPortIndex < artnetnode::MAX_PORTS);
526-
return m_Node.Port[nPortIndex].protocol;
527-
}
528-
529-
/**
530-
* sACN E1.131
531-
*/
532-
void SetPriority4(uint32_t nPortIndex, uint8_t nPriority) {
533-
E131Bridge::SetPriority(nPortIndex, nPriority);
534-
}
535-
uint8_t GetPriority4(uint32_t nPortIndex) const {
536-
return E131Bridge::GetPriority(nPortIndex);
537-
}
538-
539526
bool GetUniverse4(uint32_t nPortIndex, uint16_t &nUniverse, lightset::PortDir portDir) const {
540527
return E131Bridge::GetUniverse(nPortIndex, nUniverse, portDir);
541528
}
@@ -553,7 +540,6 @@ class ArtNetNode {
553540
void SetUniverseSwitch(const uint32_t nPortIndex, const lightset::PortDir dir, const uint8_t nAddress);
554541
void SetNetSwitch(const uint32_t nPortIndex, const uint8_t nNetSwitch);
555542
void SetSubnetSwitch(const uint32_t nPortIndex, const uint8_t nSubnetSwitch);
556-
557543
void SendDiag([[maybe_unused]] const artnet::PriorityCodes priorityCode, [[maybe_unused]] const char *format, ...) {
558544
#if defined (ARTNET_ENABLE_SENDDIAG)
559545
if (!m_State.SendArtDiagData) {
@@ -635,7 +621,7 @@ class ArtNetNode {
635621
}
636622
}
637623

638-
void static staticCallbackFunctionLedPanelOff([[maybe_unused]] TimerHandle_t timerHandle) {
624+
void static StaticCallbackFunctionLedPanelOff([[maybe_unused]] TimerHandle_t timerHandle) {
639625
s_pThis->LedPanelOff();
640626
}
641627

lib-artnet/include/artnetparams.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class ArtNetParams {
163163
return lightset::PortDir::DISABLE;
164164
}
165165

166-
static void staticCallbackFunction(void *p, const char *s);
166+
static void StaticCallbackFunction(void *p, const char *s);
167167

168168
private:
169169
lightset::PortDir portdir_get(const uint32_t nPortIndex) const {

lib-artnet/src/node/4/artnetnode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* Art-Net Designed by and Copyright Artistic Licence Holdings Ltd.
77
*/
8-
/* Copyright (C) 2023-2024 by Arjan van Vught mailto:info@orangepi-dmx.nl
8+
/* Copyright (C) 2023-2025 by Arjan van Vught mailto:info@orangepi-dmx.nl
99
*
1010
* Permission is hereby granted, free of charge, to any person obtaining a copy
1111
* of this software and associated documentation files (the "Software"), to deal

lib-artnet/src/node/artnetnode.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
*/
55

6-
/* Copyright (C) 2016-2024 by Arjan van Vught mailto:info@gd32-dmx.org
6+
/* Copyright (C) 2016-2025 by Arjan van Vught mailto:info@gd32-dmx.org
77
*
88
* Permission is hereby granted, free of charge, to any person obtaining a copy
99
* of this software and associated documentation files (the "Software"), to deal
@@ -182,7 +182,7 @@ void ArtNetNode::Start() {
182182
/*
183183
* Status 3
184184
*/
185-
m_ArtPollReply.Status3 = artnet::Status3::NETWORKLOSS_LAST_STATE | artnet::Status3::FAILSAFE_CONTROL | artnet::Status3::SUPPORTS_BACKGROUNDDISCOVERY;
185+
m_ArtPollReply.Status3 |= artnet::Status3::FAILSAFE_CONTROL | artnet::Status3::SUPPORTS_BACKGROUNDDISCOVERY;
186186
#if defined (ARTNET_HAVE_DMXIN)
187187
m_ArtPollReply.Status3 |= artnet::Status3::OUTPUT_SWITCH;
188188
#endif
@@ -230,7 +230,7 @@ void ArtNetNode::Start() {
230230
E131Bridge::Start();
231231
#endif
232232

233-
SoftwareTimerAdd(200, staticCallbackFunctionLedPanelOff);
233+
SoftwareTimerAdd(200, StaticCallbackFunctionLedPanelOff);
234234

235235
m_State.status = artnet::Status::ON;
236236
Hardware::Get()->SetMode(hardware::ledblink::Mode::NORMAL);

lib-artnet/src/node/artnetnodehandleaddress.cpp

Lines changed: 55 additions & 2 deletions
317
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ void ArtNetNode::SetLocalMerging() {
6565
(m_Node.Port[nInputPortIndex].PortAddress == m_Node.Port[nOutputPortIndex].PortAddress)) {
6666

6767
if (!m_Node.Port[nOutputPortIndex].bLocalMerge) {
68-
m_OutputPort[nOutputPortIndex].SourceA.nIp = network::IPADDR_LOOPBACK;
68+
m_OutputPort[nOutputPortIndex].SourceA.nIp = net::IPADDR_LOOPBACK;
6969
DEBUG_PUTS("Local merge Source A");
7070
} else {
71-
m_OutputPort[nOutputPortIndex].SourceB.nIp = network::IPADDR_LOOPBACK;
71+
m_OutputPort[nOutputPortIndex].SourceB.nIp = net::IPADDR_LOOPBACK;
7272
DEBUG_PUTS("Local merge Source B");
7373
}
7474

@@ -216,6 +216,34 @@ void ArtNetNode::SetMergeMode(const uint32_t nPortIndex, const lightset::MergeMo
216216
}
217217
}
218218

219+
void ArtNetNode::SetFailSafe(const lightset::FailSafe lightset_failsafe) {
220+
artnetnode::FailSafe failsafe;
221+
222+
switch (lightset_failsafe) {
223+
case lightset::FailSafe::HOLD:
224+
failsafe = artnetnode::FailSafe::LAST;
225+
break;
226+
case lightset::FailSafe::OFF:
227+
failsafe = artnetnode::FailSafe::OFF;
228+
break;
229+
case lightset::FailSafe::ON:
230+
failsafe = artnetnode::FailSafe::ON;
231+
break;
232+
case lightset::FailSafe::PLAYBACK:
233+
failsafe = artnetnode::FailSafe::PLAYBACK;
234+
break;
235+
case lightset::FailSafe::RECORD:
236+
failsafe = artnetnode::FailSafe::RECORD;
237+
break;
238+
default:
239+
assert(0);
240+
__builtin_unreachable();
241+
break;
242+
}
243+
244+
SetFailSafe(failsafe);
245+
}
246+
219247
void ArtNetNode::SetFailSafe(const artnetnode::FailSafe failsafe) {
220248
DEBUG_PRINTF("failsafe=%u", static_cast<uint32_t>(failsafe));
221249

@@ -273,6 +301,31 @@ void ArtNetNode::SetFailSafe(const artnetnode::FailSafe failsafe) {
273301
DEBUG_EXIT
274302
}
275303

304+
lightset::FailSafe ArtNetNode::GetFailSafe() {
305+
const auto networkloss = (m_ArtPollReply.Status3 & artnet::Status3::NETWORKLOSS_MASK);
306+
switch (networkloss) {
307+
case artnet::Status3::NETWORKLOSS_LAST_STATE:
308+
return lightset::FailSafe::HOLD;
309+
break;
310+
case artnet::Status3::NETWORKLOSS_OFF_STATE:
311+
return lightset::FailSafe::OFF;
312+
break;
313+
case artnet::Status3::NETWORKLOSS_ON_STATE:
314+
return lightset::FailSafe::ON;
315+
break;
316+
case artnet::Status3::NETWORKLOSS_PLAYBACK:
+
return lightset::FailSafe::PLAYBACK;
318+
break;
319+
default:
320+
assert(0);
321+
__builtin_unreachable();
322+
break;
323+
}
324+
325+
__builtin_unreachable();
326+
return lightset::FailSafe::OFF;
327+
}
328+
276329
void ArtNetNode::HandleAddress() {
277330
const auto *const pArtAddress = reinterpret_cast<artnet::ArtAddress *>(m_pReceiveBuffer);
278331
m_State.reportCode = artnet::ReportCode::RCPOWEROK;

0 commit comments

Comments
 (0)
0