-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
683 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Library General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* GenericDevice.cpp | ||
* A Generic device that creates a single port. | ||
* Copyright (C) 2014 Simon Newton | ||
*/ | ||
|
||
#include "plugins/usbdmx/GenericDevice.h" | ||
|
||
#include <string> | ||
#include "plugins/usbdmx/Widget.h" | ||
#include "plugins/usbdmx/GenericOutputPort.h" | ||
|
||
namespace ola { | ||
namespace plugin { | ||
namespace usbdmx { | ||
|
||
GenericDevice::GenericDevice(ola::AbstractPlugin *owner, | ||
Widget *widget, | ||
const std::string &device_name, | ||
const std::string &device_id) | ||
: Device(owner, device_name), | ||
m_device_id(device_id), | ||
m_port(new GenericOutputPort(this, 0, widget)) { | ||
} | ||
|
||
bool GenericDevice::StartHook() { | ||
AddPort(m_port.release()); | ||
return true; | ||
} | ||
} // namespace usbdmx | ||
} // namespace plugin | ||
} // namespace ola |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Library General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* GenericDevice.h | ||
* A Generic device that creates a single port. | ||
* Copyright (C) 2014 Simon Newton | ||
*/ | ||
|
||
#ifndef PLUGINS_USBDMX_GENERICDEVICE_H_ | ||
#define PLUGINS_USBDMX_GENERICDEVICE_H_ | ||
|
||
#include <memory> | ||
#include <string> | ||
#include "ola/base/Macro.h" | ||
#include "olad/Device.h" | ||
|
||
namespace ola { | ||
namespace plugin { | ||
namespace usbdmx { | ||
|
||
/** | ||
* @brief An Generic device. | ||
* | ||
* This simple generic device creates a single output port around a Widget. | ||
*/ | ||
class GenericDevice: public Device { | ||
public: | ||
/** | ||
* @brief Create a new GenericDevice. | ||
* @param owner The plugin this device belongs to | ||
* @param widget The widget to use for this device. | ||
* @param device_name The name of the device. | ||
* @param device_id The id of the device. | ||
*/ | ||
GenericDevice(ola::AbstractPlugin *owner, | ||
class Widget *widget, | ||
const std::string &device_name, | ||
const std::string &device_id); | ||
|
||
std::string DeviceId() const { | ||
return m_device_id; | ||
} | ||
|
||
protected: | ||
bool StartHook(); | ||
|
||
private: | ||
const std::string m_device_id; | ||
std::auto_ptr<class GenericOutputPort> m_port; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(GenericDevice); | ||
}; | ||
} // namespace usbdmx | ||
} // namespace plugin | ||
} // namespace ola | ||
#endif // PLUGINS_USBDMX_GENERICDEVICE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Library General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* GenericOutputPort.cpp | ||
* A Generic output port that uses a widget. | ||
* Copyright (C) 2014 Simon Newton | ||
*/ | ||
|
||
#include "plugins/usbdmx/GenericOutputPort.h" | ||
|
||
#include "ola/Logging.h" | ||
#include "olad/Device.h" | ||
#include "plugins/usbdmx/Widget.h" | ||
|
||
namespace ola { | ||
namespace plugin { | ||
namespace usbdmx { | ||
|
||
GenericOutputPort::GenericOutputPort(Device *parent, | ||
unsigned int id, | ||
Widget *widget) | ||
: BasicOutputPort(parent, id), | ||
m_widget(widget) { | ||
} | ||
|
||
bool GenericOutputPort::WriteDMX(const DmxBuffer &buffer, | ||
OLA_UNUSED uint8_t priority) { | ||
m_widget->SendDMX(buffer); | ||
return true; | ||
} | ||
} // namespace usbdmx | ||
} // namespace plugin | ||
} // namespace ola |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Library General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* GenericOutputPort.h | ||
* A Generic output port that uses a widget. | ||
* Copyright (C) 2014 Simon Newton | ||
*/ | ||
|
||
#ifndef PLUGINS_USBDMX_GENERICOUTPUTPORT_H_ | ||
#define PLUGINS_USBDMX_GENERICOUTPUTPORT_H_ | ||
|
||
#include <string> | ||
#include "ola/base/Macro.h" | ||
#include "olad/Port.h" | ||
|
||
namespace ola { | ||
|
||
class Device; | ||
|
||
namespace plugin { | ||
namespace usbdmx { | ||
|
||
class Widget; | ||
|
||
/** | ||
* @brief A thin wrapper around a Widget so that it can operate as a Port. | ||
*/ | ||
class GenericOutputPort: public BasicOutputPort { | ||
public: | ||
/** | ||
* @brief Create a new GenericOutputPort. | ||
* @param parent The parent device for this port. | ||
* @param id The port id. | ||
* @param widget The widget to use to send DMX frames. | ||
*/ | ||
GenericOutputPort(Device *parent, | ||
unsigned int id, | ||
class Widget *widget); | ||
|
||
bool WriteDMX(const DmxBuffer &buffer, uint8_t priority); | ||
|
||
std::string Description() const { return ""; } | ||
|
||
private: | ||
class Widget* const m_widget; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(GenericOutputPort); | ||
}; | ||
} // namespace usbdmx | ||
} // namespace plugin | ||
} // namespace ola | ||
#endif // PLUGINS_USBDMX_GENERICOUTPUTPORT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.