Skip to content

Commit

Permalink
Fixed last question bug and asses ability to edit number of ReadOnly …
Browse files Browse the repository at this point in the history
…and ClosedLoop sessions for a participant
  • Loading branch information
bruskajp committed Feb 16, 2022
1 parent c9b27e3 commit 747ebdb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Assets/NiclsInterface/NiclsInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public class NiclsListener {
messageBuffer += System.Text.Encoding.UTF8.GetString(buffer, 0, bytesRead);
List<string> received = new List<string>();

UnityEngine.Debug.Log("ParseBuffer\n" + messageBuffer.ToString());
//UnityEngine.Debug.Log("ParseBuffer\n" + messageBuffer.ToString());
while (messageBuffer.IndexOf("\n") != -1) {
string message = messageBuffer.Substring(0, messageBuffer.IndexOf("\n") + 1);
received.Add(message);
Expand Down
24 changes: 15 additions & 9 deletions Assets/Scripts/DeliveryExperiment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ public class DeliveryExperiment : CoroutineExperiment

private static int sessionNumber = -1;
private static int continuousSessionNumber = -1;
private int niclsReadOnlySessions = -1;
private int niclsClosedLoopSessions = -1;
private static bool useRamulator;
private static bool useNiclServer;
private static string expName;

// JPB: TODO: Make these configuration variables
private const bool NICLS_COURIER = true;

private const string COURIER_VERSION = "v5.1.3";
private const string COURIER_VERSION = "v5.1.4";
private const string RECALL_TEXT = "*******"; // JPB: TODO: Remove this and use display system
// Constants moved to the Config File
//private const int DELIVERIES_PER_TRIAL = LESS_DELIVERIES ? 3 : (NICLS_COURIER ? 16 : 13);
Expand Down Expand Up @@ -69,6 +71,7 @@ public class DeliveryExperiment : CoroutineExperiment
private const int NICLS_READ_ONLY_SESSIONS = 8;
private const int NICLS_CLOSED_LOOP_SESSIONS = 4;


private const int NUM_MUSIC_VIDEOS = 6;
private const int NUM_MUSIC_VIDEOS_PER_SESSION = 2;
private readonly int[] MUSIC_VIDEO_RECALL_SESSIONS = { 9, 10, 11 }; // Can't make const arrays in c#
Expand Down Expand Up @@ -124,12 +127,8 @@ public static void ConfigureExperiment(bool newUseRamulator, bool newUseNiclServ
useRamulator = newUseRamulator;
useNiclServer = newUseNiclServer;
sessionNumber = newSessionNumber;
continuousSessionNumber = useNiclServer
? NICLS_READ_ONLY_SESSIONS + sessionNumber
: sessionNumber;
expName = newExpName;
Config.experimentConfigName = expName;

}

void UncaughtExceptionHandler(object sender, UnhandledExceptionEventArgs args)
Expand Down Expand Up @@ -175,6 +174,14 @@ void Start()
syncs.StartPulse();
}

// Setup number of nicls sessions
niclsReadOnlySessions = Config.Get(() => Config.niclsReadOnlySessions, NICLS_READ_ONLY_SESSIONS);
niclsClosedLoopSessions = Config.Get(() => Config.niclsClosedLoopSessions, NICLS_CLOSED_LOOP_SESSIONS);
continuousSessionNumber = useNiclServer ? niclsReadOnlySessions + sessionNumber : sessionNumber;
Debug.Log(niclsReadOnlySessions);
Debug.Log(niclsClosedLoopSessions);
Debug.Log(continuousSessionNumber);

// Randomize efr correct/incorrect button sides
if (Config.efrEnabled && Config.counterBalanceCorrectIncorrectButton)
{
Expand Down Expand Up @@ -243,10 +250,9 @@ private IEnumerator ExperimentCoroutine()
yield return messageImageDisplayer.DisplayMessage(messageImageDisplayer.general_message_display);
WorldScreen();
yield return DoTownLearning(1, environment.stores.Length);
}
}
}


// Task Recap Instructions and Practice Trials
// Using useNiclsServer to skip practices on closed loop sessions
if (sessionNumber == 0 && !useNiclServer)
Expand Down Expand Up @@ -281,12 +287,12 @@ private IEnumerator ExperimentCoroutine()
if (MUSIC_VIDEO_RECALL_SESSIONS.Contains(continuousSessionNumber))
yield return DoMusicVideoRecall(videoOrder);

if (continuousSessionNumber == NICLS_READ_ONLY_SESSIONS + NICLS_CLOSED_LOOP_SESSIONS - 1)
if (continuousSessionNumber == (niclsReadOnlySessions + niclsClosedLoopSessions - 1))
{
var ratings = new string[] { "music video question 0 rating 0", "music video question 0 rating 1" };
messageImageDisplayer.SetSlidingScale2Text(titleText: "music video question 0 title",
ratings: ratings);
StartCoroutine(messageImageDisplayer.DisplaySlidingScale2Message(messageImageDisplayer.sliding_scale_2_display));
yield return messageImageDisplayer.DisplaySlidingScale2Message(messageImageDisplayer.sliding_scale_2_display);
}
}

Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/FlexibleConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class Config
if (lessDeliveries) return 3;
else return Config.GetSetting("deliveriesPerPracticeTrial"); } }
public static int newEfrKeypressPractices { get { return Config.GetSetting("newEfrKeypressPractices"); } }
public static int niclsReadOnlySessions { get { return Config.GetSetting("niclsReadOnlySessions"); } }
public static int niclsClosedLoopSessions { get { return Config.GetSetting("niclsClosedLoopSessions"); } }

private const string SYSTEM_CONFIG_NAME = "config.json";

Expand Down

0 comments on commit 747ebdb

Please sign in to comment.