Skip to content

Commit

Permalink
Add scheduler events
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Westley committed Jan 27, 2018
1 parent 8a55d5f commit a2553f2
Show file tree
Hide file tree
Showing 97 changed files with 9,659 additions and 595 deletions.
11 changes: 11 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ XLIGHTS/NUTCRACKER RELEASE NOTES
-- enh (craig) Randomize only effect settings with a lock available.
-- enh (keith) Force xtimging import to round down timing mark times if they occur between frames
-- enh (keith) Add the ability to include multiple timings in a single xTiming file
-- enh (keith) Add event triggers to scheduler which trigger command execution. Triggers available:
- On a channel value in the running sequence
- On a channel in a received E131 packet
- On a channel in a received ArtNet packet
- On a channel in a received DMX packet from a serial connection
- On a channel in a received OpenDMX packet from a serial connection - this looks like it will be less reliable than DMXModel
- On a OSC message
- On a FPP event
-- enh (keith) Add ability to send a FPP Event in a playlist step
-- enh (keith) Add ability to send to a serial device in a playlist step
-- enh (keith) Rework FPP/OSC remote so it works correctly with new event model and add ARTNet timecode support
2018.3 Jan 21, 2018
-- enh (dkulp) Bunch of render optimizations, particularly for groups with large number of models
-- enh (dkulp) Bunch of startup optimizations - don't load rgbeffects.xml twice
Expand Down
18 changes: 18 additions & 0 deletions dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@ Version: ?
License: GPL2
Strategy: Windows: Source files are included in the xLights repository and it is compiled into xLights statically.

Library: wxMIDI
Usage: Talking to midi devices
Link: http://wxcode.sourceforge.net/docs/wxmidi/
Source: https://sourceforge.net/projects/wxcode/files/Components/wxMidi/
Last Pulled: Jan 2018
Version: 2.0
License: ?
Strategy: Windows: Source files are included in the xLights repository and it is compiled into xLights statically.

Library: PortMIDI
Usage: Underlying library used by wxMIDI
Link: http://portmedia.sourceforge.net/portmidi/
Source: https://sourceforge.net/projects/portmedia/files/portmidi/
Last Pulled: Jan 2018
Version: 217
License: ?
Strategy: Windows: Selected header files are included in the xLights repository along with precompiled libraries and DLLs.

Library: MIDI
Usage: MIDI file reading for Piano effect
Link: http://midifile.sapp.org/
Expand Down
20 changes: 20 additions & 0 deletions xLights/outputs/SerialOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,26 @@ std::list<std::string> SerialOutput::GetPossibleSerialPorts()
return res;
}

std::list<std::string> SerialOutput::GetPossibleBaudRates()
{
std::list<std::string> res;

res.push_back("9600");
res.push_back("19200");
res.push_back("38400");
res.push_back("57600");
res.push_back("115200");
res.push_back("128000");
res.push_back("250000");
res.push_back("256000");
res.push_back("500000");
res.push_back("512000");
res.push_back("1000000");
res.push_back("1024000");

return res;
}

std::list<std::string> SerialOutput::GetAvailableSerialPorts()
{
std::list<std::string> res;
Expand Down
1 change: 1 addition & 0 deletions xLights/outputs/SerialOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class SerialOutput : public Output
#pragma region Static Functions
static std::list<std::string> GetAvailableSerialPorts();
static std::list<std::string> GetPossibleSerialPorts();
static std::list<std::string> GetPossibleBaudRates();
#pragma endregion Static Functions

virtual wxXmlNode* Save() override;
Expand Down
2 changes: 2 additions & 0 deletions xLights/outputs/serial_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ int SerialPort::Close()
{
if (_fd != INVALID_HANDLE_VALUE)
{
//FlushFileBuffers(_fd);
CloseHandle(_ov.hEvent);
CloseHandle(_fd);
_fd = INVALID_HANDLE_VALUE;
Expand Down Expand Up @@ -276,6 +277,7 @@ int SerialPort::Write(char* buf, size_t len)
return -1;
}
}
//FlushFileBuffers(_fd);

return write;
}
Expand Down
2 changes: 1 addition & 1 deletion xSchedule/ConfigureOSC.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "ConfigureOSC.h"
#include "ScheduleOptions.h"
#include "../xLights/outputs/IPOutput.h"
#include "OSCPacket.h"

//(*InternalHeaders(ConfigureOSC)
#include <wx/intl.h>
#include <wx/string.h>
#include "OSCPacket.h"
//*)

//(*IdInit(ConfigureOSC)
Expand Down
3 changes: 3 additions & 0 deletions xSchedule/Control.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

PACK( typedef struct { char fppd[4]; uint8_t pktType; uint16_t extraDataLen; } ControlPkt);

#define CTRL_PKT_SYNC 1
#define CTRL_PKT_EVENT 2

#define SYNC_PKT_START 0
#define SYNC_PKT_STOP 1
#define SYNC_PKT_SYNC 2
Expand Down
94 changes: 94 additions & 0 deletions xSchedule/EventARTNetPanel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#include "EventARTNetPanel.h"
#include "events/EventARTNet.h"

//(*InternalHeaders(EventARTNetPanel)
#include <wx/intl.h>
#include <wx/string.h>
//*)

//(*IdInit(EventARTNetPanel)
const long EventARTNetPanel::ID_STATICTEXT1 = wxNewId();
const long EventARTNetPanel::ID_SPINCTRL1 = wxNewId();
const long EventARTNetPanel::ID_STATICTEXT2 = wxNewId();
const long EventARTNetPanel::ID_SPINCTRL2 = wxNewId();
const long EventARTNetPanel::ID_STATICTEXT4 = wxNewId();
const long EventARTNetPanel::ID_CHOICE2 = wxNewId();
const long EventARTNetPanel::ID_STATICTEXT3 = wxNewId();
const long EventARTNetPanel::ID_SPINCTRL3 = wxNewId();
//*)

BEGIN_EVENT_TABLE(EventARTNetPanel,wxPanel)
//(*EventTable(EventARTNetPanel)
//*)
END_EVENT_TABLE()

EventARTNetPanel::EventARTNetPanel(wxWindow* parent,wxWindowID id,const wxPoint& pos,const wxSize& size)
{
//(*Initialize(EventARTNetPanel)
wxFlexGridSizer* FlexGridSizer1;

Create(parent, id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("id"));
FlexGridSizer1 = new wxFlexGridSizer(0, 2, 0, 0);
FlexGridSizer1->AddGrowableCol(1);
StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Universe:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
FlexGridSizer1->Add(StaticText1, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
SpinCtrl_Universe = new wxSpinCtrl(this, ID_SPINCTRL1, _T("1"), wxDefaultPosition, wxDefaultSize, 0, 1, 64000, 1, _T("ID_SPINCTRL1"));
SpinCtrl_Universe->SetValue(_T("1"));
FlexGridSizer1->Add(SpinCtrl_Universe, 1, wxALL|wxEXPAND, 5);
StaticText2 = new wxStaticText(this, ID_STATICTEXT2, _("Channel:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
FlexGridSizer1->Add(StaticText2, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
SpinCtrl_Channel = new wxSpinCtrl(this, ID_SPINCTRL2, _T("1"), wxDefaultPosition, wxDefaultSize, 0, 1, 512, 1, _T("ID_SPINCTRL2"));
SpinCtrl_Channel->SetValue(_T("1"));
FlexGridSizer1->Add(SpinCtrl_Channel, 1, wxALL|wxEXPAND, 5);
StaticText4 = new wxStaticText(this, ID_STATICTEXT4, _("Test:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT4"));
FlexGridSizer1->Add(StaticText4, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
Choice_Test = new wxChoice(this, ID_CHOICE2, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE2"));
Choice_Test->SetSelection( Choice_Test->Append(_("Equals")) );
Choice_Test->Append(_("Less Than"));
Choice_Test->Append(_("Less Than or Equals"));
Choice_Test->Append(_("Greater Than"));
Choice_Test->Append(_("Greater Than or Equals"));
Choice_Test->Append(_("Not Equals"));
Choice_Test->Append(_("Continuous"));
Choice_Test->Append(_("On Change"));
FlexGridSizer1->Add(Choice_Test, 1, wxALL|wxEXPAND, 5);
StaticText3 = new wxStaticText(this, ID_STATICTEXT3, _("Value:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3"));
FlexGridSizer1->Add(StaticText3, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
SpinCtrl_Value = new wxSpinCtrl(this, ID_SPINCTRL3, _T("255"), wxDefaultPosition, wxDefaultSize, 0, 0, 255, 255, _T("ID_SPINCTRL3"));
SpinCtrl_Value->SetValue(_T("255"));
FlexGridSizer1->Add(SpinCtrl_Value, 1, wxALL|wxEXPAND, 5);
SetSizer(FlexGridSizer1);
FlexGridSizer1->Fit(this);
FlexGridSizer1->SetSizeHints(this);
//*)
}

EventARTNetPanel::~EventARTNetPanel()
{
//(*Destroy(EventARTNetPanel)
//*)
}

bool EventARTNetPanel::ValidateWindow()
{
return true;
}

void EventARTNetPanel::Save(EventBase* event)
{
EventARTNet* e = (EventARTNet*)event;
e->SetUniverse(SpinCtrl_Universe->GetValue());
e->SetChannel(SpinCtrl_Channel->GetValue());
e->SetCondition(Choice_Test->GetStringSelection().ToStdString());
e->SetThreshold(SpinCtrl_Value->GetValue());
}

void EventARTNetPanel::Load(EventBase* event)
{
EventARTNet* e = (EventARTNet*)event;
SpinCtrl_Universe->SetValue(e->GetUniverse());
SpinCtrl_Channel->SetValue(e->GetChannel());
Choice_Test->SetStringSelection(e->GetCondition());
SpinCtrl_Value->SetValue(e->GetThreshold());
}

56 changes: 56 additions & 0 deletions xSchedule/EventARTNetPanel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#ifndef EVENTARTNETPANEL_H
#define EVENTARTNETPANEL_H

#include "EventPanel.h"

//(*Headers(EventARTNetPanel)
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/spinctrl.h>
#include <wx/panel.h>
#include <wx/choice.h>
//*)

class EventARTNetPanel: public EventPanel
{
public:

EventARTNetPanel(wxWindow* parent,wxWindowID id=wxID_ANY,const wxPoint& pos=wxDefaultPosition,const wxSize& size=wxDefaultSize);
virtual ~EventARTNetPanel();
virtual bool ValidateWindow() override;
virtual void Save(EventBase* event) override;
virtual void Load(EventBase* event) override;

//(*Declarations(EventARTNetPanel)
wxChoice* Choice_Test;
wxSpinCtrl* SpinCtrl_Channel;
wxStaticText* StaticText2;
wxSpinCtrl* SpinCtrl_Universe;
wxStaticText* StaticText1;
wxStaticText* StaticText3;
wxSpinCtrl* SpinCtrl_Value;
wxStaticText* StaticText4;
//*)

protected:

//(*Identifiers(EventARTNetPanel)
static const long ID_STATICTEXT1;
static const long ID_SPINCTRL1;
static const long ID_STATICTEXT2;
static const long ID_SPINCTRL2;
static const long ID_STATICTEXT4;
static const long ID_CHOICE2;
static const long ID_STATICTEXT3;
static const long ID_SPINCTRL3;
//*)

private:

//(*Handlers(EventARTNetPanel)
//*)

DECLARE_EVENT_TABLE()
};

#endif
121 changes: 121 additions & 0 deletions xSchedule/EventDataPanel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#include "EventDataPanel.h"
#include "EventDialog.h"
#include "events/EventData.h"
#include "xScheduleMain.h"
#include "ScheduleManager.h"
#include "../xLights/outputs/OutputManager.h"

//(*InternalHeaders(EventDataPanel)
#include <wx/intl.h>
#include <wx/string.h>
//*)

//(*IdInit(EventDataPanel)
const long EventDataPanel::ID_STATICTEXT1 = wxNewId();
const long EventDataPanel::ID_TEXTCTRL1 = wxNewId();
const long EventDataPanel::ID_STATICTEXT4 = wxNewId();
const long EventDataPanel::ID_STATICTEXT2 = wxNewId();
const long EventDataPanel::ID_CHOICE2 = wxNewId();
const long EventDataPanel::ID_STATICTEXT3 = wxNewId();
const long EventDataPanel::ID_SPINCTRL3 = wxNewId();
//*)

BEGIN_EVENT_TABLE(EventDataPanel,wxPanel)
//(*EventTable(EventDataPanel)
//*)
END_EVENT_TABLE()

EventDataPanel::EventDataPanel(wxWindow* parent,wxWindowID id,const wxPoint& pos,const wxSize& size)
{
//(*Initialize(EventDataPanel)
wxFlexGridSizer* FlexGridSizer2;
wxFlexGridSizer* FlexGridSizer1;

Create(parent, id, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("id"));
FlexGridSizer1 = new wxFlexGridSizer(0, 2, 0, 0);
FlexGridSizer1->AddGrowableCol(1);
StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Channel:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
FlexGridSizer1->Add(StaticText1, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer2 = new wxFlexGridSizer(0, 2, 0, 0);
FlexGridSizer2->AddGrowableCol(0);
TextCtrl_Channel = new wxTextCtrl(this, ID_TEXTCTRL1, _("1"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
FlexGridSizer2->Add(TextCtrl_Channel, 1, wxALL|wxEXPAND, 5);
StaticText4 = new wxStaticText(this, ID_STATICTEXT4, _("1"), wxDefaultPosition, wxSize(60,-1), 0, _T("ID_STATICTEXT4"));
FlexGridSizer2->Add(StaticText4, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer1->Add(FlexGridSizer2, 1, wxALL|wxEXPAND, 5);
StaticText2 = new wxStaticText(this, ID_STATICTEXT2, _("Test:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
FlexGridSizer1->Add(StaticText2, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
Choice_Test = new wxChoice(this, ID_CHOICE2, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_CHOICE2"));
Choice_Test->SetSelection( Choice_Test->Append(_("Equals")) );
Choice_Test->Append(_("Less Than"));
Choice_Test->Append(_("Less Than or Equals"));
Choice_Test->Append(_("Greater Than"));
Choice_Test->Append(_("Greater Than or Equals"));
Choice_Test->Append(_("Not Equals"));
Choice_Test->Append(_("Continuous"));
Choice_Test->Append(_("On Change"));
FlexGridSizer1->Add(Choice_Test, 1, wxALL|wxEXPAND, 5);
StaticText3 = new wxStaticText(this, ID_STATICTEXT3, _("Value:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3"));
FlexGridSizer1->Add(StaticText3, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
SpinCtrl_Value = new wxSpinCtrl(this, ID_SPINCTRL3, _T("255"), wxDefaultPosition, wxDefaultSize, 0, 0, 255, 255, _T("ID_SPINCTRL3"));
SpinCtrl_Value->SetValue(_T("255"));
FlexGridSizer1->Add(SpinCtrl_Value, 1, wxALL|wxEXPAND, 5);
SetSizer(FlexGridSizer1);
FlexGridSizer1->Fit(this);
FlexGridSizer1->SetSizeHints(this);

Connect(ID_TEXTCTRL1,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&EventDataPanel::OnTextCtrl_ChannelText);
//*)
}

EventDataPanel::~EventDataPanel()
{
//(*Destroy(EventDataPanel)
//*)
}

bool EventDataPanel::ValidateWindow()
{
if (Choice_Test->GetStringSelection() == "Continuous" || Choice_Test->GetStringSelection() == "On Change")
{
SpinCtrl_Value->Enable(false);
}
else
{
SpinCtrl_Value->Enable();
}

return true;
}

void EventDataPanel::Save(EventBase* event)
{
EventData* e = (EventData*)event;
e->SetChannel(TextCtrl_Channel->GetValue().ToStdString());
e->SetCondition(Choice_Test->GetStringSelection().ToStdString());
e->SetThreshold(SpinCtrl_Value->GetValue());
}

void EventDataPanel::Load(EventBase* event)
{
EventData* e = (EventData*)event;
TextCtrl_Channel->SetValue(e->GetChannel());
Choice_Test->SetStringSelection(e->GetCondition());
SpinCtrl_Value->SetValue(e->GetThreshold());
}


void EventDataPanel::OnTextCtrl_ChannelText(wxCommandEvent& event)
{
OutputManager* outputManager = xScheduleFrame::GetScheduleManager()->GetOutputManager();
long sc = outputManager->DecodeStartChannel(TextCtrl_Channel->GetValue().ToStdString());
if (sc == 0 || sc > xScheduleFrame::GetScheduleManager()->GetTotalChannels())
{
StaticText4->SetLabel("Invalid");
}
else
{
StaticText4->SetLabel(wxString::Format("%ld", (long)sc));
}
((EventDialog*)GetParent()->GetParent()->GetParent()->GetParent())->ValidateWindow();
}
Loading

0 comments on commit a2553f2

Please sign in to comment.