Skip to content

Commit

Permalink
Fix timecode options need restart to take effect.
Browse files Browse the repository at this point in the history
  • Loading branch information
keithsw1111 committed Nov 29, 2024
1 parent fdc946d commit c495f1c
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 38 deletions.
7 changes: 5 additions & 2 deletions xSchedule/SyncArtNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ class ArtNetTimecodeThread : public wxThread {
}
};

SyncArtNet::SyncArtNet(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ListenerManager* listenerManager, const std::string& localIP) :
SyncBase(sm, rm, options) {
SyncArtNet::SyncArtNet(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ScheduleManager* schm, ListenerManager* listenerManager, const std::string& localIP) :
SyncBase(sm, rm, options, schm) {
static log4cpp::Category& logger_base = log4cpp::Category::getInstance(std::string("log_base"));

_supportsStepMMSSFormat = true;
Expand Down Expand Up @@ -249,6 +249,9 @@ void SyncArtNet::SendSync(uint32_t frameMS, uint32_t stepLengthMS, uint32_t step
break;
}

static log4cpp::Category& logger_base = log4cpp::Category::getInstance(std::string("log_base"));
logger_base.debug("ArtnetSync: %02d:%02d:%02d.%02d", buffer[17], buffer[16], buffer[15], buffer[14]);

_artnetSocket->SendTo(_remoteAddr, &buffer[0], buffer.size());
}

Expand Down
2 changes: 1 addition & 1 deletion xSchedule/SyncArtNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SyncArtNet : public SyncBase

public:

SyncArtNet(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ListenerManager* listenerManager, const std::string& localIP);
SyncArtNet(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ScheduleManager* schm, ListenerManager* listenerManager, const std::string& localIP);
SyncArtNet(SyncArtNet&& from) noexcept;
virtual ~SyncArtNet();
virtual void SendSync(uint32_t frameMS, uint32_t stepLengthMS, uint32_t stepMS, uint32_t playlistMS, const std::string& fseq, const std::string& media, const std::string& step, const std::string& timeItem, uint32_t stepno, int overridetimeSecs) const override;
Expand Down
16 changes: 8 additions & 8 deletions xSchedule/SyncFPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,8 @@ SyncMulticastFPP::~SyncMulticastFPP()
}
}

SyncBroadcastFPP::SyncBroadcastFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ListenerManager* listenerManager, const std::string& localIP) :
SyncFPP(sm, rm, options)
SyncBroadcastFPP::SyncBroadcastFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ScheduleManager* schm, ListenerManager* listenerManager, const std::string& localIP) :
SyncFPP(sm, rm, options, schm)
{
static log4cpp::Category &logger_base = log4cpp::Category::getInstance(std::string("log_base"));

Expand Down Expand Up @@ -489,8 +489,8 @@ SyncBroadcastFPP::SyncBroadcastFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOpt
}
}

SyncUnicastFPP::SyncUnicastFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ListenerManager* listenerManager, const std::string& localIP) :
SyncFPP(sm, rm, options)
SyncUnicastFPP::SyncUnicastFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ScheduleManager* schm, ListenerManager* listenerManager, const std::string& localIP) :
SyncFPP(sm, rm, options, schm)
{
static log4cpp::Category &logger_base = log4cpp::Category::getInstance(std::string("log_base"));

Expand Down Expand Up @@ -539,8 +539,8 @@ SyncUnicastFPP::SyncUnicastFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions
}
}

SyncUnicastCSVFPP::SyncUnicastCSVFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ListenerManager* listenerManager, const std::string& localIP) : SyncFPP(sm, rm, options)
{
SyncUnicastCSVFPP::SyncUnicastCSVFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ScheduleManager* schm, ListenerManager* listenerManager, const std::string& localIP) :
SyncFPP(sm, rm, options, schm) {
static log4cpp::Category& logger_base = log4cpp::Category::getInstance(std::string("log_base"));

if (sm == SYNCMODE::FPPUNICASTCSVMASTER)
Expand Down Expand Up @@ -588,8 +588,8 @@ SyncUnicastCSVFPP::SyncUnicastCSVFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleO
}
}

SyncMulticastFPP::SyncMulticastFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ListenerManager* listenerManager, const std::string& localIP) : SyncFPP(sm, rm, options)
{
SyncMulticastFPP::SyncMulticastFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ScheduleManager* schm, ListenerManager* listenerManager, const std::string& localIP) :
SyncFPP(sm, rm, options, schm) {
static log4cpp::Category& logger_base = log4cpp::Category::getInstance(std::string("log_base"));

if (sm == SYNCMODE::FPPMULTICASTMASTER)
Expand Down
12 changes: 6 additions & 6 deletions xSchedule/SyncFPP.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class SyncFPP : public SyncBase {
public:
static void Ping(bool remote, const std::string& localIP);

SyncFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options) :
SyncBase(sm, rm, options) {
SyncFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ScheduleManager* schm) :
SyncBase(sm, rm, options, schm) {
}
virtual void SendSync(uint32_t frameMS, uint32_t stepLengthMS, uint32_t stepMS, uint32_t playlistMS, const std::string& fseq, const std::string& media, const std::string& step, const std::string& timeItem, uint32_t stepno, int overridetimeSecs) const override;
virtual void SendStop() const override;
Expand All @@ -36,7 +36,7 @@ class SyncBroadcastFPP : public SyncFPP {
virtual void SendFPPSync(const std::string& item, uint32_t stepMS, uint32_t frameMS) const override;

public:
SyncBroadcastFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ListenerManager* listenerManager, const std::string& localIP);
SyncBroadcastFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ScheduleManager* schm, ListenerManager* listenerManager, const std::string& localIP);
SyncBroadcastFPP(SyncBroadcastFPP&& from) noexcept;
virtual ~SyncBroadcastFPP();
virtual std::string GetType() const override {
Expand All @@ -52,7 +52,7 @@ class SyncUnicastFPP : public SyncFPP {
virtual void SendFPPSync(const std::string& item, uint32_t stepMS, uint32_t frameMS) const override;

public:
SyncUnicastFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ListenerManager* listenerManager, const std::string& localIP);
SyncUnicastFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ScheduleManager* schm, ListenerManager* listenerManager, const std::string& localIP);
SyncUnicastFPP(SyncUnicastFPP&& from) noexcept;
virtual ~SyncUnicastFPP();
virtual std::string GetType() const override {
Expand All @@ -68,7 +68,7 @@ class SyncUnicastCSVFPP : public SyncFPP {
virtual void SendFPPSync(const std::string& item, uint32_t stepMS, uint32_t frameMS) const override;

public:
SyncUnicastCSVFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ListenerManager* listenerManager, const std::string& localIP);
SyncUnicastCSVFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ScheduleManager* schm, ListenerManager* listenerManager, const std::string& localIP);
SyncUnicastCSVFPP(SyncUnicastCSVFPP&& from) noexcept;
virtual ~SyncUnicastCSVFPP();
virtual std::string GetType() const override {
Expand All @@ -83,7 +83,7 @@ class SyncMulticastFPP : public SyncFPP {
virtual void SendFPPSync(const std::string& item, uint32_t stepMS, uint32_t frameMS) const override;

public:
SyncMulticastFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ListenerManager* listenerManager, const std::string& localIP);
SyncMulticastFPP(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ScheduleManager* schm, ListenerManager* listenerManager, const std::string& localIP);
SyncMulticastFPP(SyncMulticastFPP&& from) noexcept;
virtual ~SyncMulticastFPP();
virtual std::string GetType() const override {
Expand Down
4 changes: 2 additions & 2 deletions xSchedule/SyncMIDI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ class MIDIClockThread : public wxThread {
};
#endif

SyncMIDI::SyncMIDI(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ListenerManager* listenerManager) :
SyncBase(sm, rm, options) {
SyncMIDI::SyncMIDI(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ScheduleManager* schm, ListenerManager* listenerManager) :
SyncBase(sm, rm, options, schm) {
static log4cpp::Category& logger_base = log4cpp::Category::getInstance(std::string("log_base"));

_supportsStepMMSSFormat = true;
Expand Down
2 changes: 1 addition & 1 deletion xSchedule/SyncMIDI.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SyncMIDI : public SyncBase

public:

SyncMIDI(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ListenerManager* listenerManager);
SyncMIDI(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ScheduleManager* schm, ListenerManager* listenerManager);
SyncMIDI(SyncMIDI&& from);
virtual ~SyncMIDI();
virtual void SendSync(uint32_t frameMS, uint32_t stepLengthMS, uint32_t stepMS, uint32_t playlistMS, const std::string& fseq, const std::string& media, const std::string& step, const std::string& timeItem, uint32_t stepno, int overridetimeSecs) const override;
Expand Down
38 changes: 26 additions & 12 deletions xSchedule/SyncManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@
std::unique_ptr<SyncBase> SyncManager::CreateSync(SYNCMODE sm, REMOTEMODE rm) const {
wxASSERT(_scheduleManager != nullptr);
if (sm == SYNCMODE::OSCMASTER || rm == REMOTEMODE::OSCSLAVE) {
return std::make_unique<SyncOSC>(SyncOSC(sm, rm, *_scheduleManager->GetOptions(), _scheduleManager->GetListenerManager(), _scheduleManager->GetForceLocalIP()));
return std::make_unique<SyncOSC>(SyncOSC(sm, rm, *_scheduleManager->GetOptions(), _scheduleManager, _scheduleManager->GetListenerManager(), _scheduleManager->GetForceLocalIP()));
} else if (sm == SYNCMODE::ARTNETMASTER || rm == REMOTEMODE::ARTNETSLAVE) {
return std::make_unique<SyncArtNet>(SyncArtNet(sm, rm, *_scheduleManager->GetOptions(), _scheduleManager->GetListenerManager(), _scheduleManager->GetForceLocalIP()));
return std::make_unique<SyncArtNet>(SyncArtNet(sm, rm, *_scheduleManager->GetOptions(), _scheduleManager, _scheduleManager->GetListenerManager(), _scheduleManager->GetForceLocalIP()));
} else if (sm == SYNCMODE::FPPBROADCASTMASTER) {
return std::make_unique<SyncBroadcastFPP>(SyncBroadcastFPP(sm, rm, *_scheduleManager->GetOptions(), _scheduleManager->GetListenerManager(), _scheduleManager->GetForceLocalIP()));
return std::make_unique<SyncBroadcastFPP>(SyncBroadcastFPP(sm, rm, *_scheduleManager->GetOptions(), _scheduleManager, _scheduleManager->GetListenerManager(), _scheduleManager->GetForceLocalIP()));
} else if (sm == SYNCMODE::FPPUNICASTMASTER) {
return std::make_unique<SyncUnicastFPP>(SyncUnicastFPP(sm, rm, *_scheduleManager->GetOptions(), _scheduleManager->GetListenerManager(), _scheduleManager->GetForceLocalIP()));
return std::make_unique<SyncUnicastFPP>(SyncUnicastFPP(sm, rm, *_scheduleManager->GetOptions(), _scheduleManager, _scheduleManager->GetListenerManager(), _scheduleManager->GetForceLocalIP()));
} else if (sm == SYNCMODE::FPPUNICASTCSVMASTER || rm == REMOTEMODE::FPPCSVSLAVE) {
return std::make_unique<SyncUnicastCSVFPP>(SyncUnicastCSVFPP(sm, rm, *_scheduleManager->GetOptions(), _scheduleManager->GetListenerManager(), _scheduleManager->GetForceLocalIP()));
return std::make_unique<SyncUnicastCSVFPP>(SyncUnicastCSVFPP(sm, rm, *_scheduleManager->GetOptions(), _scheduleManager, _scheduleManager->GetListenerManager(), _scheduleManager->GetForceLocalIP()));
} else if (sm == SYNCMODE::FPPMULTICASTMASTER) {
return std::make_unique<SyncMulticastFPP>(SyncMulticastFPP(sm, rm, *_scheduleManager->GetOptions(), _scheduleManager->GetListenerManager(), _scheduleManager->GetForceLocalIP()));
return std::make_unique<SyncMulticastFPP>(SyncMulticastFPP(sm, rm, *_scheduleManager->GetOptions(), _scheduleManager, _scheduleManager->GetListenerManager(), _scheduleManager->GetForceLocalIP()));
} else if (rm == REMOTEMODE::FPPSLAVE || rm == REMOTEMODE::FPPBROADCASTSLAVE || rm == REMOTEMODE::FPPUNICASTSLAVE) {
// really doesnt matter which FPP I create
return std::make_unique<SyncMulticastFPP>(SyncMulticastFPP(sm, REMOTEMODE::FPPSLAVE, *_scheduleManager->GetOptions(), _scheduleManager->GetListenerManager(), _scheduleManager->GetForceLocalIP()));
return std::make_unique<SyncMulticastFPP>(SyncMulticastFPP(sm, REMOTEMODE::FPPSLAVE, *_scheduleManager->GetOptions(), _scheduleManager, _scheduleManager->GetListenerManager(), _scheduleManager->GetForceLocalIP()));
} else if (sm == SYNCMODE::MIDIMASTER || rm == REMOTEMODE::MIDISLAVE) {
return std::make_unique<SyncMIDI>(SyncMIDI(sm, rm, *_scheduleManager->GetOptions(), _scheduleManager->GetListenerManager()));
return std::make_unique<SyncMIDI>(SyncMIDI(sm, rm, *_scheduleManager->GetOptions(), _scheduleManager, _scheduleManager->GetListenerManager()));
} else if (rm == REMOTEMODE::SMPTESLAVE) {
return std::make_unique<SyncSMPTE>(SyncSMPTE(sm, rm, *_scheduleManager->GetOptions(), _scheduleManager->GetListenerManager()));
return std::make_unique<SyncSMPTE>(SyncSMPTE(sm, rm, *_scheduleManager->GetOptions(), _scheduleManager, _scheduleManager->GetListenerManager()));
} else if (rm == REMOTEMODE::DISABLED) {
return nullptr;
} else {
Expand Down Expand Up @@ -205,7 +205,21 @@ void SyncManager::SendStop() const {
}
}

SyncBase::SyncBase(SYNCMODE mode, REMOTEMODE remoteMode, const ScheduleOptions& options) :
_mode(mode), _remoteMode(remoteMode) {
_useStepMMSSFormat = options.IsUseStepMMSSTimecodeFormat();
void SyncManager::ReloadOptions() const {
for (auto& it : _masters) {
it->ReloadOptions();
}
if (_remote != nullptr) {
_remote->ReloadOptions();
}
}

SyncBase::SyncBase(SYNCMODE mode, REMOTEMODE remoteMode, const ScheduleOptions& options, ScheduleManager* sm) :
_mode(mode), _remoteMode(remoteMode), _scheduleManager(sm) {
ReloadOptions();
}

void SyncBase::ReloadOptions()
{
_useStepMMSSFormat = _scheduleManager->GetOptions()->IsUseStepMMSSTimecodeFormat();
}
5 changes: 4 additions & 1 deletion xSchedule/SyncManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class SyncBase {
SYNCMODE _mode = SYNCMODE::STANDALONE;
REMOTEMODE _remoteMode = REMOTEMODE::DISABLED;
bool _useStepMMSSFormat = false;
ScheduleManager* _scheduleManager = nullptr;

uint32_t GetHours(uint32_t ms, uint32_t step, int overrideBaseTime) const {
if (overrideBaseTime < 0 && _useStepMMSSFormat && _supportsStepMMSSFormat) {
Expand All @@ -72,7 +73,7 @@ class SyncBase {
}

public:
SyncBase(SYNCMODE mode, REMOTEMODE remoteMode, const ScheduleOptions& options);
SyncBase(SYNCMODE mode, REMOTEMODE remoteMode, const ScheduleOptions& options, ScheduleManager* sm);
virtual ~SyncBase() {
}
virtual void SendSync(uint32_t frameMS, uint32_t stepLengthMS, uint32_t stepMS, uint32_t playlistMS, const std::string& fseq, const std::string& media, const std::string& step, const std::string& timeItem, uint32_t stepno, int overridetimeSecs) const = 0;
Expand All @@ -93,6 +94,7 @@ class SyncBase {
virtual bool IsReactive() const {
return true;
}
void ReloadOptions();
};

class SyncManager {
Expand Down Expand Up @@ -124,4 +126,5 @@ class SyncManager {
bool IsFPPRemoteOrMaster() const;
bool IsMaster(SYNCMODE mode) const;
void SendStop() const;
void ReloadOptions() const;
};
4 changes: 2 additions & 2 deletions xSchedule/SyncOSC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include "../xLights/UtilFunctions.h"
#include <log4cpp/Category.hh>

SyncOSC::SyncOSC(SYNCMODE mode, REMOTEMODE remoteMode, const ScheduleOptions& options, ListenerManager* listenerManager, const std::string& localIP) :
SyncBase(mode, remoteMode, options) {
SyncOSC::SyncOSC(SYNCMODE mode, REMOTEMODE remoteMode, const ScheduleOptions& options, ScheduleManager* schm, ListenerManager* listenerManager, const std::string& localIP) :
SyncBase(mode, remoteMode, options, schm) {
static log4cpp::Category& logger_base = log4cpp::Category::getInstance(std::string("log_base"));

if (mode == SYNCMODE::OSCMASTER) {
Expand Down
2 changes: 1 addition & 1 deletion xSchedule/SyncOSC.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SyncOSC : public SyncBase

public:

SyncOSC(SYNCMODE mode, REMOTEMODE remoteMode, const ScheduleOptions& options, ListenerManager* listenerManager, const std::string& localIP);
SyncOSC(SYNCMODE mode, REMOTEMODE remoteMode, const ScheduleOptions& options, ScheduleManager* schm, ListenerManager* listenerManager, const std::string& localIP);
SyncOSC(SyncOSC&& from);
virtual ~SyncOSC();
virtual void SendSync(uint32_t frameMS, uint32_t stepLengthMS, uint32_t stepMS, uint32_t playlistMS, const std::string& fseq, const std::string& media, const std::string& step, const std::string& timeItem, uint32_t stepno, int overridetimeSecs) const override;
Expand Down
2 changes: 1 addition & 1 deletion xSchedule/SyncSMPTE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <log4cpp/Category.hh>
#include "../xLights/UtilFunctions.h"

SyncSMPTE::SyncSMPTE(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ListenerManager* listenerManager) : SyncBase(sm, rm, options)
SyncSMPTE::SyncSMPTE(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ScheduleManager* schm, ListenerManager* listenerManager) : SyncBase(sm, rm, options, schm)
{
static log4cpp::Category &logger_base = log4cpp::Category::getInstance(std::string("log_base"));

Expand Down
2 changes: 1 addition & 1 deletion xSchedule/SyncSMPTE.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SyncSMPTE : public SyncBase

public:

SyncSMPTE(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ListenerManager* listenerManager);
SyncSMPTE(SYNCMODE sm, REMOTEMODE rm, const ScheduleOptions& options, ScheduleManager* schm, ListenerManager* listenerManager);
SyncSMPTE(SyncSMPTE&& from);
virtual ~SyncSMPTE();
virtual void SendSync(uint32_t frameMS, uint32_t stepLengthMS, uint32_t stepMS, uint32_t playlistMS, const std::string& fseq, const std::string& media, const std::string& step, const std::string& timeItem, uint32_t stepno, int overridetimeSecs) const override;
Expand Down
2 changes: 2 additions & 0 deletions xSchedule/xScheduleMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1768,6 +1768,8 @@ void xScheduleFrame::OnMenuItem_OptionsSelected(wxCommandEvent& event)
c->TempDisable(false);
}

__schedule->GetSyncManager()->ReloadOptions();

Schedule::SetCity(__schedule->GetOptions()->GetCity());
__schedule->GetOutputManager()->SetParallelTransmission(__schedule->GetOptions()->IsParallelTransmission());
OutputManager::SetRetryOpen(__schedule->GetOptions()->IsRetryOpen());
Expand Down

0 comments on commit c495f1c

Please sign in to comment.