Skip to content
Snippets Groups Projects
Commit f992c2ca authored by RZ-WIN\vr-admin's avatar RZ-WIN\vr-admin
Browse files

avoid crash if starting on study map for debugging (in which case a setup does not really exist...)

parent 6ded2f7e
No related branches found
No related tags found
1 merge request!2GazeTracking Logging
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
......@@ -34,7 +34,7 @@ void FSFLoggingUtils::SetupLoggingStreams()
ILogStream* SFLog = UniLog.NewLogStream("SFLog", "StudyFramework/DebuggingLogs", "SFLog.txt", false);
SFLog->SetLogToDefaultLog(true);
//ParticipantLog, PositionLog, GazeTrackingLog are set up in Participant init function
//ParticipantLog, PositionLog, GazeTrackingLog are set up in SFParticipant::SetupLoggingStreams() function
ILogStream* SFErrorLog = UniLog.NewLogStream("SFErrorLog", "StudyFramework/DebuggingLogs", "SFLog.txt", false);
SFErrorLog->SetLogToDefaultLog(true);
......
......@@ -131,10 +131,14 @@ void USFGameInstance::RestoreLastParticipantForDebugStart(USFCondition* InStartC
const int ParticipantID = USFParticipant::GetLastParticipantId();
Participant = NewObject<USFParticipant>(this,
FName(TEXT("Participant_") + FString::FromInt(ParticipantID)));
StudySetup = USFParticipant::GetLastParticipantSetup();
Participant->Initialize(ParticipantID);
Participant->SetupLoggingStreams(StudySetup->UseGazeTracker != EGazeTrackerMode::NotTracking);
Participant->LoadConditionsFromJson();
StudySetup = USFParticipant::GetLastParticipantSetup();
InitFadeHandler(StudySetup->FadeConfig);
StartCondition = InStartCondition;
......@@ -240,6 +244,7 @@ void USFGameInstance::PrepareWithStudySetup(ASFStudySetup* Setup)
Participant = NewObject<USFParticipant>(this,
FName(TEXT("Participant_") + FString::FromInt(ParticipantID)));
Participant->Initialize(ParticipantID);
Participant->SetupLoggingStreams(StudySetup->UseGazeTracker != EGazeTrackerMode::NotTracking);
Participant->SetStudyConditions(Conditions);
if (bRecoverParticipantData)
......
......@@ -22,19 +22,24 @@ bool USFParticipant::Initialize(int Participant)
{
ParticipantID = Participant;
StartTime = FPlatformTime::Seconds();
return true;
}
void USFParticipant::SetupLoggingStreams(bool bGazeTracking)
{
const FString Timestamp = FDateTime::Now().ToString();
const FString Filename = "LogParticipant-" + FString::FromInt(ParticipantID) + "_" + Timestamp + ".txt";
ILogStream* ParticipantLog = UniLog.NewLogStream("ParticipantLog", "StudyFramework/StudyLogs/ParticipantLogs",
Filename, false);
ILogStream* PositionLog = UniLog.NewLogStream("PositionLog", "StudyFramework/StudyLogs/PositionLogs",
"Position" + Filename, false);
if(USFGameInstance::Get()->GetStudySetup()->UseGazeTracker != EGazeTrackerMode::NotTracking)
if (bGazeTracking)
{
ILogStream* GazeTrackingLog = UniLog.NewLogStream("GazeTrackingLog", "StudyFramework/StudyLogs/GazeTrackingLogs",
"GazeTracking" + Filename, false);
}
StartTime = FPlatformTime::Seconds();
if (USFGameInstance::Get())
{
USFGameInstance::Get()->GetLogObject()->WritePositionLogHeaderRow();
......@@ -44,7 +49,6 @@ bool USFParticipant::Initialize(int Participant)
{
FSFLoggingUtils::Log("GameInstance not set up yet, no header rows are written to participant logs.");
}
return true;
}
void USFParticipant::SetStudyConditions(TArray<USFCondition*> NewConditions)
......
......@@ -29,6 +29,7 @@ public:
~USFParticipant();
bool Initialize(int Participant);
void SetupLoggingStreams(bool bGazeTracking);
void SetStudyConditions(TArray<USFCondition*> NewConditions);
bool StartStudy();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment