Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:

env:
artifactoryApiKey: ${{ secrets.artifactoryApiKey }}
ARTIFACTORY_ACCESS_TOKEN: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
build_dir: "Build"
package: EphysSocket-linux

Expand Down Expand Up @@ -43,4 +43,4 @@ jobs:
cp -r $build_dir/*.so plugins
zipfile=${package}_${new_plugin_ver}.zip
zip -r -X $zipfile plugins
curl -H "X-JFrog-Art-Api:$artifactoryApiKey" -T $zipfile "https://openephys.jfrog.io/artifactory/EphysSocket-plugin/linux/$zipfile"
curl -H "X-JFrog-Art-Api:$ARTIFACTORY_ACCESS_TOKEN" -T $zipfile "https://openephys.jfrog.io/artifactory/EphysSocket-plugin/linux/$zipfile"
4 changes: 2 additions & 2 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:

env:
artifactoryApiKey: ${{ secrets.artifactoryApiKey }}
ARTIFACTORY_ACCESS_TOKEN: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
build_dir: "Build/Release"
package: EphysSocket-mac

Expand Down Expand Up @@ -41,4 +41,4 @@ jobs:
cp -r $build_dir/*.bundle plugins
zipfile=${package}_${new_plugin_ver}.zip
zip -r -X $zipfile plugins
curl -H "X-JFrog-Art-Api:$artifactoryApiKey" -T $zipfile "https://openephys.jfrog.io/artifactory/EphysSocket-plugin/mac/$zipfile"
curl -H "X-JFrog-Art-Api:$ARTIFACTORY_ACCESS_TOKEN" -T $zipfile "https://openephys.jfrog.io/artifactory/EphysSocket-plugin/mac/$zipfile"
6 changes: 3 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:

env:
artifactoryApiKey: ${{ secrets.artifactoryApiKey }}
ARTIFACTORY_ACCESS_TOKEN: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
build_dir: "Build/Release"
package: EphysSocket-windows

Expand All @@ -28,7 +28,7 @@ jobs:
cd plugin-GUI/Build
cmake -G "Visual Studio 16 2019" -A x64 ..
mkdir Release && cd Release
curl -L https://openephysgui.jfrog.io/artifactory/Libraries/open-ephys-lib-v0.6.0.zip --output open-ephys-lib.zip
curl -L https://openephys.jfrog.io/artifactory/GUI-binaries/Libraries/open-ephys-lib-v0.6.0.zip --output open-ephys-lib.zip
unzip open-ephys-lib.zip
shell: bash

Expand Down Expand Up @@ -58,5 +58,5 @@ jobs:
cp $build_dir/*.dll plugins
zipfile=${package}_${new_plugin_ver}.zip
powershell Compress-Archive -Path "plugins" -DestinationPath ${zipfile}
curl -H "X-JFrog-Art-Api:$artifactoryApiKey" -T $zipfile "https://openephys.jfrog.io/artifactory/EphysSocket-plugin/windows/$zipfile"
curl -H "X-JFrog-Art-Api:$ARTIFACTORY_ACCESS_TOKEN" -T $zipfile "https://openephys.jfrog.io/artifactory/EphysSocket-plugin/windows/$zipfile"
shell: bash
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ if(MSVC)
target_compile_options(${PLUGIN_NAME} PRIVATE /sdl- /W0)

install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION ${GUI_BIN_DIR}/plugins CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES})
install(FILES $<TARGET_PDB_FILE:${PLUGIN_NAME}> DESTINATION ${GUI_BIN_DIR}/plugins OPTIONAL)

set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../libs)
elseif(LINUX)
Expand Down
33 changes: 21 additions & 12 deletions Resources/python-example-tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
oneCycle = np.concatenate((intList_1, intList_2))
allData = np.tile(oneCycle, (numChannels, totalDuration)).T

# ---- WAIT FOR USER INPUT ---- #
value = input("Press enter key to start...")

# ---- CREATE THE SOCKET SERVER ---- #
tcpServer = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
tcpServer.bind(('localhost', 9001))
tcpServer.listen(1)

# ---- WAIT FOR USER INPUT ---- #
value = input("Press enter key to start...")

print("Waiting for external connection to start...")
(tcpClient, address) = tcpServer.accept()
print("Connected.")
Expand All @@ -61,14 +61,23 @@ def currentTime():
return time.time_ns() / (10 ** 9)

# ---- STREAM DATA ---- #
while (bufferIndex < totalBytes):
t1 = currentTime()
rc = tcpClient.sendto(header + bytesToSend[bufferIndex:bufferIndex+bytesPerBuffer], address)
t2 = currentTime()

while ((t2 - t1) < bufferInterval):
try:
while (bufferIndex < totalBytes):
t1 = currentTime()
rc = tcpClient.sendto(header + bytesToSend[bufferIndex:bufferIndex+bytesPerBuffer], address)
t2 = currentTime()

bufferIndex += bytesPerBuffer

while ((t2 - t1) < bufferInterval):
t2 = currentTime()

bufferIndex += bytesPerBuffer

print("Done")
except BrokenPipeError:
print("Connection closed by the server. Unable to send data. Exiting...")

except ConnectionAbortedError:
print("Connection was aborted, unable to send data. Try disconnecting and reconnecting the remote client. Exiting...")

print("Done")
except ConnectionResetError:
print("Connection was aborted, unable to send data. Try disconnecting and reconnecting the remote client. Exiting...")
6 changes: 4 additions & 2 deletions Source/EphysSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DataThread* EphysSocket::createDataThread(SourceNode* sn)
return new EphysSocket(sn);
}

EphysSocket::EphysSocket(SourceNode* sn) : DataThread(sn), socket("socket_thread")
EphysSocket::EphysSocket(SourceNode* sn) : DataThread(sn), socket("socket_thread", this)
{
port = DEFAULT_PORT;
sample_rate = DEFAULT_SAMPLE_RATE;
Expand All @@ -39,7 +39,9 @@ EphysSocket::~EphysSocket()
}

void EphysSocket::disconnectSocket()
{
{
socket.signalThreadShouldExit();
socket.waitForThreadToExit(1000);
socket.disconnectSocket();
}

Expand Down
2 changes: 1 addition & 1 deletion Source/OpenEphysLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extern "C" EXPORT void getLibInfo(Plugin::LibraryInfo* info)
{
info->apiVersion = PLUGIN_API_VER;
info->name = "Ephys Socket";
info->libVersion = "0.4.0";
info->libVersion = "0.4.1";
info->numPlugins = NUM_PLUGINS;
}

Expand Down
11 changes: 9 additions & 2 deletions Source/SocketThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
#endif

#include "SocketThread.h"
#include "EphysSocket.h"

using namespace EphysSocketNode;

SocketThread::SocketThread(String name)
: Thread(name), editor(NULL)
SocketThread::SocketThread(String name, EphysSocket* processor_)
: Thread(name), editor(NULL), processor(processor_)
{
lastPacketReceived = time(nullptr);

Expand Down Expand Up @@ -51,6 +52,12 @@ void SocketThread::startAcquisition()
void SocketThread::stopAcquisition()
{
acquiring = false;

if (shouldReconnect)
{
processor->disconnectSocket();
editor->enableInputs();
}
}

bool SocketThread::connectSocket(int port, bool printOutput)
Expand Down
7 changes: 6 additions & 1 deletion Source/SocketThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@

namespace EphysSocketNode
{
class EphysSocket;

class SocketThread : public Thread
{
public:

SocketThread(String name);
SocketThread(String name, EphysSocket*);

~SocketThread();

Expand Down Expand Up @@ -87,6 +89,9 @@ namespace EphysSocketNode
/** Pointer to the editor */
EphysSocketEditor* editor;

/** Pointer to the plugin processor */
EphysSocket* processor;

/** TCP Socket object */
std::unique_ptr<StreamingSocket> socket;

Expand Down