Skip to content

Commit

Permalink
Added untested support for stopping recordings
Browse files Browse the repository at this point in the history
The necessary methods for stopping the recording and retreiving
the data data have been added. They are however completely untested
as this needs a real EyeLink system at hand.
  • Loading branch information
joschaschmiedt committed Jun 29, 2020
1 parent 0473ded commit 59301bc
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 3 deletions.
22 changes: 22 additions & 0 deletions Source/EyeServer/Private/EyeServerBPLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@ void UEyeServerBPLibrary::StartRecording()
TEXT("EyeServer: could not start recording"));
}

void UEyeServerBPLibrary::StartRecording(FString filename)
{
UE_LOG(LogTemp, Display, TEXT("EyeServer: starting recording with filename %s"), *filename);
ensureMsgf(EyeServerInterface::StartRecording(std::string(TCHAR_TO_UTF8(*filename))) == 0,
TEXT("EyeServer: could not start recording"));
}

void UEyeServerBPLibrary::StopRecording()
{
UE_LOG(LogTemp, Display, TEXT("EyeServer: stopping recording without EDF"));
ensureMsgf(EyeServerInterface::StopRecording() == 0,
TEXT("EyeServer: could not stop recording"));
}

void UEyeServerBPLibrary::StopRecording(FString filename)
{
UE_LOG(LogTemp, Display, TEXT("EyeServer: stopping recording and copying to file %s"), *filename);
ensureMsgf(EyeServerInterface::StopRecording(std::string(TCHAR_TO_UTF8(*filename))) == 0,
TEXT("EyeServer: could not stop recording"));

}

int UEyeServerBPLibrary::CreateTarget(float x, float y, float r, FString name)
{
UE_LOG(LogTemp, Display, TEXT("Creating EyeServer target at x=%.2f, y=%.2f, r=%.2f"), x, y, r);
Expand Down
87 changes: 84 additions & 3 deletions Source/EyeServer/Private/EyeServerInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ DWORD EyeServerInterface::StopEyeLinkServerProcess()
DWORD EyeServerInterface::StartRecording()
{

if (EyeServerInterface::recordingStarted) {
return S_OK;
}


#pragma pack(push, 1)
static struct {
Expand All @@ -130,6 +128,89 @@ DWORD EyeServerInterface::StartRecording()
return S_OK;
}

DWORD EyeServerInterface::StartRecording(std::string filename)
{
if (EyeServerInterface::recordingStarted) {
return S_OK;
}

//[00 0 2 filename] start recording

#pragma pack(push, 1)
static struct {
unsigned short key = 0;
BYTE cmd[2] = { 0, 2 };
std::string filename;
} msg;
#pragma pack(pop)

msg.filename = filename;

DWORD nBytesWritten = 0;
bool success = WriteFile(EyeServerInterface::hPipe, &msg.key, sizeof(msg), &nBytesWritten, NULL);
if ((!success) & (nBytesWritten == sizeof(msg)))
{
return GetLastError();
}

EyeServerInterface::recordingStarted = true;
return S_OK;
}

DWORD EyeServerInterface::StopRecording()
{
// [00 0 0]
if (!EyeServerInterface::recordingStarted) {
return S_OK;
}
#pragma pack(push, 1)
static struct {
unsigned short key = 0;
BYTE cmd[2] = { 0, 0 };
} msg;
#pragma pack(pop)
DWORD nBytesWritten = 0;
bool success = WriteFile(EyeServerInterface::hPipe, &msg.key, sizeof(msg), &nBytesWritten, NULL);
if ((!success) & (nBytesWritten == sizeof(msg)))
{
return GetLastError();
}

EyeServerInterface::recordingStarted = false;

return S_OK;
}

DWORD EyeServerInterface::StopRecording(std::string filename)
{
// [00 0 0 filename]
if (!EyeServerInterface::recordingStarted) {
return S_OK;
}
#pragma pack(push, 1)
static struct {
unsigned short key = 0;
BYTE cmd[2] = { 0, 0 };
std::string filename;
} msg;
#pragma pack(pop)
msg.filename = filename;

DWORD nBytesWritten = 0;
bool success = WriteFile(EyeServerInterface::hPipe, &msg.key, sizeof(msg), &nBytesWritten, NULL);
if ((!success) & (nBytesWritten == sizeof(msg)))
{
return GetLastError();
}

EyeServerInterface::recordingStarted = false;

HANDLE hEvent = CreateEventA(nullptr, false, false, "EyeServerDone");
DWORD result = WaitForSingleObject(hEvent, DWORD(180000));

return S_OK;
}

DWORD EyeServerInterface::CreateTarget(float x, float y, float r, WORD * pKey, std::string name)
{
#pragma pack(push, 1)
Expand Down
9 changes: 9 additions & 0 deletions Source/EyeServer/Public/EyeServerBPLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ class UEyeServerBPLibrary : public UBlueprintFunctionLibrary
UFUNCTION(BlueprintCallable, Category = "EyeServer")
static void StartRecording();

UFUNCTION(BlueprintCallable, Category = "EyeServer")
static void StartRecording(FString filename);

UFUNCTION(BlueprintCallable, Category = "EyeServer")
static void StopRecording();

UFUNCTION(BlueprintCallable, Category = "EyeServer")
static void StopRecording(FString filename);

UFUNCTION(BlueprintCallable, Category = "EyeServer")
static int CreateTarget(float x, float y, float r, FString name);

Expand Down
3 changes: 3 additions & 0 deletions Source/EyeServer/Public/EyeServerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class EyeServerInterface
static DWORD StartEyeLinkServerProcess();
static DWORD StopEyeLinkServerProcess();
static DWORD StartRecording();
static DWORD StartRecording(std::string filename);
static DWORD StopRecording();
static DWORD StopRecording(std::string filename);
static DWORD CreateTarget(float x, float y, float r, WORD * key, std::string name);
static DWORD ReadAcknowledgement(WORD * pKey);
static DWORD GetEyePosition(float& x, float& y);
Expand Down

0 comments on commit 59301bc

Please sign in to comment.