Skip to content
Snippets Groups Projects
Commit 881a3601 authored by Septen's avatar Septen
Browse files

PluginGenerator: added RecordEngine plugin template. Bugs fixes.

* Added template file for the RecordEngine plugin type.
* Changed a bit structure of other plugin template files.
* Added missing functions for some plugin template files.
* Fixed some bugs with OpenEphysLib.cpp file template.
* Typos fixed.
parent dbafa619
Branches
Tags
No related merge requests found
Showing
with 255 additions and 35 deletions
......@@ -24,6 +24,7 @@
using namespace Plugin;
static String getProcessorTypeString (PluginProcessorType processorType)
{
switch (processorType)
......@@ -45,6 +46,7 @@ static String getProcessorTypeString (PluginProcessorType processorType)
};
}
/** Return the string representation of a given plugin type */
static String getLibPluginTypeString (PluginType pluginType)
{
......@@ -64,6 +66,7 @@ static String getLibPluginTypeString (PluginType pluginType)
};
}
/** Returns the string representation (name) of the function which is used to create a plugin of a given type. */
static String getLibPluginCreateFunctionString (PluginType pluginType)
{
......@@ -82,6 +85,26 @@ static String getLibPluginCreateFunctionString (PluginType pluginType)
};
}
/** Returns the string represenatation of a give plugin info type.
E.g. plugins can have templates like: "info->processor", "info->fileSource" and etc. */
static String getLibPluginInfoType (PluginType pluginType)
{
switch (pluginType)
{
case PLUGIN_TYPE_PROCESSOR:
return "processor";
case PLUGIN_TYPE_RECORD_ENGINE:
return "recordEngine";
case PLUGIN_TYPE_DATA_THREAD:
return "dataThread";
case PLUGIN_TYPE_FILE_SOURCE:
return "fileSource";
default:
return "InvalidPluginInfoType";
};
}
/** Returns the string representation of a given plugin processor type. */
static String getLibProcessorTypeString (PluginProcessorType processorType)
{
......@@ -103,3 +126,26 @@ static String getLibProcessorTypeString (PluginProcessorType processorType)
return "Plugin::InvalidProcessor";
};
}
// ============================================================================
// ============================================================================
// ============================================================================
/** Returns the name of the file which contains template of the processor of a plugin of given type */
static String getTemplateProcessorFileName (PluginType pluginType)
{
switch (pluginType)
{
case PLUGIN_TYPE_PROCESSOR:
return "openEphys_ProcessorPluginTemplate";
case PLUGIN_TYPE_RECORD_ENGINE:
return "openEphys_RecordEnginePluginTemplate";
case PLUGIN_TYPE_DATA_THREAD:
return "openEphys_DataThreadPluginTemplate";
case PLUGIN_TYPE_FILE_SOURCE:
return "openEphys_FileSourcePluginTemplate";
default:
return "InvalidFileName";
};
}
......@@ -279,17 +279,22 @@ struct OpenEphysPluginAppWizard : public NewProjectWizard
{
String libPluginType = getLibPluginTypeString (m_pluginType);
String libCreateFunctionName = getLibPluginCreateFunctionString (m_pluginType);
String libPluginProcessorType = getLibProcessorTypeString (m_processorType);
String libPluginInfoType = getLibPluginInfoType (m_pluginType);
const auto templatePluginLibFile = templatesFolder.getChildFile ("openEphys_OpenEphysLibTemplate.cpp");
const auto newPluginLibFile = getSourceFilesFolder().getChildFile ("OpenEphysLib.cpp");
String libPluginProcessorType = m_pluginType == PLUGIN_TYPE_PROCESSOR
? ("info->processor.type = " + getLibProcessorTypeString (m_processorType) + ";")
: "";
String pluginLibCppFileContent = templatePluginLibFile.loadFileAsString()
.replace ("PROCESSORCLASSNAME", pluginProcessorName, false)
.replace ("PLUGINLIBRARYNAME", "Temporary " + pluginFriendlyName + " library", false) // TODO <Kirill A>: set library name variable
.replace ("PLUGINLIBRARYVERSION", "1", false) // TODO <Kirill A>: set library version variable
.replace ("PLUGINGUINAME", "Temporary " + pluginFriendlyName, false) // TODO <Kirill A>: set library gui name variable
.replace ("LIBPLUGINTYPE", libPluginType, false)
.replace ("LIBPLUGININFOTYPE", libPluginInfoType, false)
.replace ("LIBPLUGINCREATEFUNCTION", libCreateFunctionName, false)
// TODO <Kirill A>: we should either add or remove appropriate line for plugin processor
// type, because it should be preset only if we generate processor plugin
......@@ -337,9 +342,10 @@ struct OpenEphysPluginAppWizard : public NewProjectWizard
const String& editorName,
const String& pluginFriendlyName)
{
const auto templateProcessorCppFile = templatesFolder.getChildFile ("openEphys_ProcessorPluginTemplate.cpp");
const auto templateProcessorHFile = templateProcessorCppFile.withFileExtension (".h");
const auto sourceFolder = getSourceFilesFolder();
const auto processorFileTemplateName = getTemplateProcessorFileName (m_pluginType);
const auto templateProcessorCppFile = templatesFolder.getChildFile (processorFileTemplateName + ".cpp");
const auto templateProcessorHFile = templateProcessorCppFile.withFileExtension (".h");
const auto sourceFolder = getSourceFilesFolder();
auto newProcessorCppFile = sourceFolder.getChildFile (processorName + ".cpp");
auto newProcessorHFile = sourceFolder.getChildFile (processorName + ".h");
......
......@@ -22,43 +22,45 @@
#include <cstdio>
PLUGINHEADERS
PROCESSORHEADERS
PLUGINCLASSMAME::PLUGINCLASSMAME (SourceNode* sn)
PROCESSORCLASSNAME::PROCESSORCLASSNAME (SourceNode* sn)
: DataThread (sn)
{
}
PLUGINCLASSNAME::~PLUGINCLASSNAME()
PROCESSORCLASSNAME::~PROCESSORCLASSNAME()
{
}
float PLUGINCLASSNAME::getSampleRate() const { return 44100.f; }
float PLUGINCLASSNAME::getBitVolts() const { return 0.f; }
int PROCESSORCLASSNAME::getNumHeadstageOutputs() const { return 2; }
float PROCESSORCLASSNAME::getSampleRate() const { return 44100.f; }
float PROCESSORCLASSNAME::getBitVolts (Channel* channel) const { return 0.f; }
bool PLUGINCLASSNAME::foundInputSource()
bool PROCESSORCLASSNAME::foundInputSource()
{
return true;
}
bool PLUGINCLASSNAME::startAcquisition()
bool PROCESSORCLASSNAME::startAcquisition()
{
return true;
}
bool PLUGINCLASSNAME::stopAcquisition()
bool PROCESSORCLASSNAME::stopAcquisition()
{
return true;
}
bool PLUGINCLASSNAME::updateBuffer()
bool PROCESSORCLASSNAME::updateBuffer()
{
return true;
}
......@@ -25,7 +25,8 @@
#include "../../../JuceLibraryCode/JuceHeader.h"
#include "DataThread.h"
// TODO <Kirill A> replace this including by using more versatile method
#include "../../Processors/DataThreads/DataThread.h"
class SourceNode;
......@@ -37,14 +38,16 @@ class SourceNode;
@see DataThread
*/
class PLUGINCLASSNAME : public DataThread
class PROCESSORCLASSNAME : public DataThread
{
public:
PLUGINCLASSNAME (SourceNode* sn);
~PLUGINCLASSMAME();
PROCESSORCLASSNAME (SourceNode* sn);
~PROCESSORCLASSNAME();
float getSampleRate() const override;
float getBitVolts() const override;
int getNumHeadstageOutputs() const override;
float getSampleRate() const override;
float getBitVolts (Channel* chan) const override;
bool foundInputSource() override;
bool startAcquisition() override;
......@@ -54,7 +57,7 @@ public:
private:
bool updateBuffer() override;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PLUGINCLASSNAME);
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PROCESSORCLASSNAME);
};
......
......@@ -21,48 +21,48 @@
*/
PLUGINHEADERS
PROCESSORHEADERS
#include <CoreServicesHeader.h>
PLUGINCLASSMAME::PLUGINCLASSMAME()
PROCESSORCLASSNAME::PROCESSORCLASSNAME()
{
}
PLUGINCLASSNAME::~PLUGINCLASSNAME()
PROCESSORCLASSNAME::~PROCESSORCLASSNAME()
{
}
bool PLUGINCLASSNAME::Open (File file)
bool PROCESSORCLASSNAME::Open (File file)
{
return true;
}
void PLUGINCLASSNAME::fillRecordInfo()
void PROCESSORCLASSNAME::fillRecordInfo()
{
}
void PLUGINCLASSNAME::updateActiveRecord()
void PROCESSORCLASSNAME::updateActiveRecord()
{
}
int PLUGINCLASSNAME::readData (int16* buffer, int nSamples)
int PROCESSORCLASSNAME::readData (int16* buffer, int nSamples)
{
return 0;
}
void PLUGINCLASSNAME::processChannelData (int16* inBuffer, float* outBuffer, int channel, int64 numSamples)
void PROCESSORCLASSNAME::processChannelData (int16* inBuffer, float* outBuffer, int channel, int64 numSamples)
{
}
bool PLUGINCLASSNAME::isReady()
bool PROCESSORCLASSNAME::isReady()
{
}
......@@ -26,11 +26,11 @@
#include <FileSourceHeaders.h>
class PLUGINCLASSMAME : public FileSource
class PROCESSORCLASSNAME : public FileSource
{
public:
PLUGINCLASSMAME();
~PLUGINCLASSMAME();
PROCESSORCLASSNAME();
~PROCESSORCLASSNAME();
int readData (int16* buffer, int nSamples) override;
......
......@@ -60,13 +60,14 @@ extern "C" EXPORT int getPluginInfo (int index, Plugin::PluginInfo* info)
info->type = LIBPLUGINTYPE;
//For processor
info->processor.name = "PLUGINGUINAME"; //Processor name shown in the GUI
info->LIBPLUGININFOTYPE.name = "PLUGINGUINAME"; //Processor name shown in the GUI
//Type of processor. Can be FilterProcessor, SourceProcessor, SinkProcessor or UtilityProcessor. Specifies where on the processor list will appear
info->processor.type = LIBPLUGINPROCESSORTYPE;
//info->processor.type = LIBPLUGINPROCESSORTYPE;
LIBPLUGINPROCESSORTYPE
//Class factory pointer. Replace "ExampleProcessor" with the name of your class.
info->processor.creator = &(Plugin::LIBPLUGINCREATEFUNCTION<PROCESSORCLASSNAME>);
info->LIBPLUGININFOTYPE.creator = &(Plugin::LIBPLUGINCREATEFUNCTION<PROCESSORCLASSNAME>);
break;
/**
Examples for other plugin types
......
/*
------------------------------------------------------------------
This file is part of the Open Ephys GUI
Copyright (C) 2016 Open Ephys
------------------------------------------------------------------
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 3 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
PROCESSORHEADERS
PROCESSORCLASSNAME::PROCESSORCLASSNAME()
{
}
PROCESSORCLASSNAME::~PROCESSORCLASSNAME()
{
}
String PROCESSORCLASSNAME::getEngineID() const
{
return "PROCESSORCLASSNAME";
}
void PROCESSORCLASSNAME::openFiles (File rootFolder, int experimentNumber, int recordingNumber)
{
}
void PROCESSORCLASSNAME::closeFiles()
{
}
void PROCESSORCLASSNAME::writeData (int writeChannel, int realChannel, const float* buffer, int size)
{
}
void PROCESSORCLASSNAME::writeEvent (int eventType, const MidiMessage& event, int64 timestamp)
{
}
void PROCESSORCLASSNAME::writeSpike (int electrodeIndex, const SpikeObject& spike, int64 timestamp)
{
}
void PROCESSORCLASSNAME::addChannel (int index, const Channel* chan)
{
}
void PROCESSORCLASSNAME::addSpikeElectrode (int index, const SpikeRecordInfo* elec)
{
}
void PROCESSORCLASSNAME::registerProcessor (const GenericProcessor* processor)
{
}
void PROCESSORCLASSNAME::resetChannels()
{
}
void PROCESSORCLASSNAME::startAcquisition()
{
}
void PROCESSORCLASSNAME::endChannelBlock (bool lastBlock)
{
}
RecordEngineManager* PROCESSORCLASSNAME::getEngineManager()
{
RecordEngineManager* man = new RecordEngineManager ("PROCESSORCLASSNAME","PLUGINGUINAME", &(engineFactory<PROCESSORCLASSNAME>));
return man;
}
/*
------------------------------------------------------------------
This file is part of the Open Ephys GUI
Copyright (C) 2016 Open Ephys
------------------------------------------------------------------
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 3 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HEADERGUARD
#define HEADERGUARD
#include <RecordingLib.h>
class PROCESSORCLASSNAME : public RecordEngine
{
public:
PROCESSORCLASSNAME();
~PROCESSORCLASSNAME();
String getEngineID() const override;
void openFiles (File rootFolder, int experimentNumber, int recordingNumber) override;
void closeFiles() override;
void writeData (int writeChannel, int realChannel, const float* buffer, int size) override;
void writeEvent (int eventType, const MidiMessage& event, int64 timestamp) override;
void writeSpike (int electrodeIndex, const SpikeObject& spike, int64 timestamp) override;
void addChannel (int index, const Channel* chan) override;
void addSpikeElectrode (int index, const SpikeRecordInfo* elec) override;
void registerProcessor (const GenericProcessor* processor) override;
void resetChannels() override;
void startAcquisition() override;
void endChannelBlock (bool lastBlock) override;
static RecordEngineManager* getEngineManager();
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PROCESSORCLASSNAME);
};
#endif // HEADERGUARD
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment