Skip to content

Commit

Permalink
Merge 3f971d1 into 8bc7854
Browse files Browse the repository at this point in the history
  • Loading branch information
nomis52 committed Nov 27, 2014
2 parents 8bc7854 + 3f971d1 commit f52a655
Show file tree
Hide file tree
Showing 11 changed files with 683 additions and 6 deletions.
46 changes: 46 additions & 0 deletions plugins/usbdmx/GenericDevice.cpp
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
68 changes: 68 additions & 0 deletions plugins/usbdmx/GenericDevice.h
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_
45 changes: 45 additions & 0 deletions plugins/usbdmx/GenericOutputPort.cpp
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
64 changes: 64 additions & 0 deletions plugins/usbdmx/GenericOutputPort.h
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_
8 changes: 8 additions & 0 deletions plugins/usbdmx/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ plugins_usbdmx_libolausbdmxwidget_la_SOURCES = \
plugins/usbdmx/ScanlimeFadecandy.h \
plugins/usbdmx/ScanlimeFadecandyFactory.cpp \
plugins/usbdmx/ScanlimeFadecandyFactory.h \
plugins/usbdmx/Sunlite.cpp \
plugins/usbdmx/Sunlite.h \
plugins/usbdmx/SunliteFactory.cpp \
plugins/usbdmx/SunliteFactory.h \
plugins/usbdmx/SyncronizedWidgetObserver.cpp \
plugins/usbdmx/SyncronizedWidgetObserver.h \
plugins/usbdmx/ThreadedUsbSender.cpp \
Expand All @@ -46,6 +50,10 @@ plugins_usbdmx_libolausbdmx_la_SOURCES = \
plugins/usbdmx/EuroliteProDevice.h \
plugins/usbdmx/EuroliteProOutputPort.cpp \
plugins/usbdmx/EuroliteProOutputPort.h \
plugins/usbdmx/GenericDevice.cpp \
plugins/usbdmx/GenericDevice.h \
plugins/usbdmx/GenericOutputPort.cpp \
plugins/usbdmx/GenericOutputPort.h \
plugins/usbdmx/LibUsbUtils.cpp \
plugins/usbdmx/LibUsbUtils.h \
plugins/usbdmx/FirmwareLoader.h \
Expand Down
Loading

0 comments on commit f52a655

Please sign in to comment.