// OnStateChange (optional) // An optional callback for when the ExperimentState field changes. This enables // additional experiment flow control and visibility into the Experiment State Machine. public void OnExperimentStateChange(ExperimentState oldState, ExperimentState newState) { if (oldState == ExperimentState.WaitingForTellResponse) { SetText("Querying for next trial"); } }
public void StartExperiment(string jsonParams) { bool IsParamsReadable = false; if (es.Equals(ExperimentState.IsStopped)) { es = ExperimentState.IsStarting; ToConsole("Starting. Reading experiment parameters..."); try { initialiseExperimentalParameters(jsonParams); IsParamsReadable = true; } catch (ExperimentalParametersException) //Catch weird parameters from UI that would crash the experiment { ToConsole("Could not interpret experiment parameters. Please check and try again."); IsParamsReadable = false; } if (IsParamsReadable) { dataArchive = new List <DataSet>(); experimentThread = new Thread(new ThreadStart(run)); experimentThread.Start(); es = ExperimentState.IsRunning; ToConsole("Thread started. Running experiment sequence."); //Data should be coming in here; As fake data, generate a point every 0.5 seconds. } } }
void OnNetworkDataReceived(object sender, ReceivedNetworkDataEventArgs e) { NetworkData data = e.Data; switch (e.Type) { case ENetDataType.ExperimentState: { ExperimentState state = (ExperimentState)data; ExperimentManager.Instance().SetExperimentStatus(state.Status); break; } case ENetDataType.UserState: ExperimentManager.Instance().ReceivedUserStateUpdate((UserState)data); break; case ENetDataType.RandomState: ExperimentManager.Instance().ReceivedRandomStateUpdate((RandomState)data); break; case ENetDataType.ResponseState: ExperimentManager.Instance().ReceivedResponseStateUpdate((ResponseState)data); break; default: throw new ArgumentOutOfRangeException(); } }
private void RunCheck(Guid vesselId, string experimentId, ExperimentState state) { if (experimentId == this.experimentId) { CheckVessel(FlightGlobals.FindVessel(vesselId)); } }
// OnStateChange (optional) // An optional callback for when the ExperimentState field changes. This enables // additional experiment flow control and visibility into the Experiment State Machine. public void OnExperimentStateChange(ExperimentState oldState, ExperimentState newState) { if (newState == ExperimentState.WaitingForAskResponse) { SetText("Querying for next trial"); } AEPsychClient.Log(string.Format("SetState: {0} -> {1}", oldState, newState)); }
private void SendExperimentStateChanged(ExperimentState toState) { if (ExperimentStateChanged != null) { ExperimentStateChanged(this, new ExperimentStateArgs { Experiment = this, FromState = ExperimentState.ToString(), ToState = toState.ToString() }); } }
public void StopExperiment() { if (experimentThread != null) { es = ExperimentState.IsFinishing; experimentThread.Join(); } es = ExperimentState.IsStopped; }
public Experiment(IHubConnectionContext <dynamic> clients) { Clients = clients; hardware = new DAQmxTriggeredMultiAIHardware(); //hardware = new FakeHardware(); es = ExperimentState.IsStopped; }
public ExperimentControl(IHubConnectionContext <dynamic> clients) { Clients = clients; exp = new CombQCLScanHardware(); //exp = new FakeHardware(); es = ExperimentState.IsStopped; Clients.All.toConsole("Experiment is ready."); }
public void moveTo(ExperimentStorage exp) { if (state == ExperimentState.INSTALLED) { state = ExperimentState.STORED; } store.removeExperimentData(); exp.part.mass += getMass(); exp.storeExperiment(this); }
private void button1_Click(object sender, EventArgs e) { testStarted = true; groupBox1.Visible = false; pictureBox.Visible = true; flowLayoutPanel2.Visible = true; expState = ExperimentState.InTest; ShowBlankImage(); }
public override EvalState Evaluate(Part part, float deltaTime, ExperimentState state) { bool valid; if (!initialUpdate && initialOnly) valid = true; float consumption; if (initialUpdate) { initialUpdate = false; consumption = part.RequestResource(resourceName, initialConsumption); if (state.CurrentState != ExperimentState.StateEnum.RESEARCHING) part.RequestResource (resourceName, consumption * -1); if (consumption.CompareTo(initialConsumption) != 0 && !validIfEmpty) { Debug.Log(String.Format("RealScience: Resource: initial consumption of {0:F6} != expected {1:F6}", consumption, initialConsumption)); valid = false; } else valid = true; } else { consumption = part.RequestResource(resourceName, usagePerSecond * deltaTime); if (state.CurrentState != ExperimentState.StateEnum.RESEARCHING) part.RequestResource (resourceName, consumption * -1); if (consumption.CompareTo(usagePerSecond * deltaTime) != 0 && !validIfEmpty) { Debug.Log(String.Format("RealScience: Resource: consumption of {0:F6} != expected {1:F6}", consumption, (usagePerSecond * deltaTime))); valid = false; } else valid = true; } if (!restriction) { if (valid) return EvalState.VALID; else return EvalState.INVALID; } else { if (!valid) return EvalState.VALID; else { if (exclusion.ToLower() == "reset") return EvalState.RESET; else if (exclusion.ToLower() == "fail") return EvalState.FAILED; else return EvalState.INVALID; } } }
void FixedUpdate() { #if UNITY_EDITOR if (!Application.isPlaying) { return; } #endif recordManager._Update(Time.fixedDeltaTime); if (state == ExperimentState.Prepare) { /*if (InputManager.GetStartButton()) * { * * }*/ if (!usingGazeInfo) { if (InputManager.GetStartButton()) { StartExperiment(); } } } else if (state == ExperimentState.Performing) { if (InputManager.GetPauseButton()) { state = ExperimentState.Pause; } else if (InputManager.GetQuitButton()) { EndExperiment(); taskManager.End(); state = ExperimentState.Prepare; } else { ; } taskManager.update(Time.deltaTime); } else if (state == ExperimentState.Pause) { if (InputManager.GetResumeButton()) { state = ExperimentState.Performing; } } else { ; } }
public IEnumerator RunInstructions() { isRunningInstructions = true; //IF THERE ARE ANY PRELIMINARY INSTRUCTIONS YOU WANT TO SHOW BEFORE THE EXPERIMENT STARTS, YOU COULD PUT THEM HERE... currentState = ExperimentState.inExperiment; isRunningInstructions = false; yield return(0); }
public void StartExperiment(Gender gender) { if (experimentLogs == null) { return; } this.gender = gender; int subNo = experimentLogs.numOfSubjects; experimentEnded = false; nextImageIsPractice = true; if (subjectListLog != null) { subjectListLog.Clear(); } subjectListLog = new List <SubjectLog>(); if (subjectEyeLog != null) { subjectEyeLog.Clear(); } subjectEyeLog = new List <SubjectEyeLog>(); subjectLogHandler = new ConfigDataListXMLSerializer <SubjectLog>(configPath + @"\" + experimentLogs.numOfSubjects + ".xml"); subjectEyeLogHandler = new ConfigDataListXMLSerializer <SubjectEyeLog>(configPath + @"\" + experimentLogs.numOfSubjects + "_EyeLog.xml"); if (subjectErrorListLog != null) { subjectErrorListLog.Clear(); } subjectErrorListLog = new List <ErrorLog>(); if (eyeDataList != null) { eyeDataList.Clear(); } eyeDataList = new List <EyeData>(); logCounter = 0; imagePool = new List <string>(); imagePool.AddRange(practiceImages.Keys); expState = ExperimentState.InPractice; panel1.Focus(); ShowBlankImage(); }
void SetState(ExperimentState newState) { ExperimentState oldState = _experimentState; if (newState != oldState) { _experimentState = newState; if (onStateChanged != null) { onStateChanged(oldState, newState); } } }
public void StopExperiment() { if (experimentThread.IsAlive) { ToConsole("Stopping..."); es = ExperimentState.IsFinishing; experimentThread.Join(); } else { ToConsole("Experiment seems to be stopped already."); } }
public void UpdateData() { taskNumber = tm.taskNumber; f = tm.prompt; es = tm.state; elapsedTime += Time.deltaTime; currentSliver = tm.currentSliver; currentTarget = tm.currentTarget; distance = Vector3.Distance( currentSliver.transform.position, currentTarget.transform.position ); taskID = tm.taskID; objectName = currentSliver.name; angle = Quaternion.Angle(currentTarget.transform.rotation, currentSliver.transform.rotation); }
public override EvalState Evaluate(Part part, float deltaTime, ExperimentState state) { bool valid = false; tooltip = "\nBody Condition"; if (restriction) { if (exclusion.ToLower() == "reset") tooltip += "\nThe following condition must <b>not</b> be met. If they are the experiment will be <b>reset</b>."; else if (exclusion.ToLower() == "fail") tooltip += "\nThe following condition must <b>not</b> be met. If they are, the experiment will <b>fail</b>."; else tooltip += "\nThe following condition must <b>not</b> be met."; } else tooltip += "\nThe following condition must be met."; foreach (Part vPart in part.vessel.Parts) { if (vPart.partName.ToLower() == requiredPartName) valid = true; } tooltip += String.Format("\nCraft has part named <b>{0}</b>. Currently <b>{1}</b>", requiredPartName, valid); if (!restriction) { if (valid) return EvalState.VALID; else return EvalState.INVALID; } else { if (!valid) return EvalState.VALID; else { if (exclusion.ToLower() == "reset") return EvalState.RESET; else if (exclusion.ToLower() == "fail") return EvalState.FAILED; else return EvalState.INVALID; } } }
public void StartExperiment(string jsonParams) { if (es.Equals(ExperimentState.IsStopped)) { es = ExperimentState.IsStarting; initialiseExperimentalParameters(jsonParams); experimentThread = new Thread(new ThreadStart(run)); experimentThread.Start(); es = ExperimentState.IsRunning; //Data should be coming in here; As fake data, generate a point every 0.5 seconds. } }
public override EvalState Evaluate(Part part, float deltaTime, ExperimentState state) { bool valid = true; tooltip = "\nAltitude Condition"; if (restriction) { if (exclusion.ToLower() == "reset") tooltip += "\nThe following condition must <b>not</b> be met. If they are the experiment will be <b>reset</b>."; else if (exclusion.ToLower() == "fail") tooltip += "\nThe following condition must <b>not</b> be met. If they are, the experiment will <b>fail</b>."; else tooltip += "\nThe following condition must <b>not</b> be met."; } else tooltip += "\nThe following condition must be met."; float altitude = FlightGlobals.getAltitudeAtPos(part.transform.position); tooltip += String.Format("\nAltitude between <b>{0:F2}</b> and <b>{1:F2}</b>. Currently <b>{2:F2}</b>", altitudeMin, altitudeMax, altitude); if (altitude >= altitudeMin && altitude <= altitudeMax) valid = true; else valid = false; if (!restriction) { if (valid) return EvalState.VALID; else return EvalState.INVALID; } else { if (!valid) return EvalState.VALID; else { if (exclusion.ToLower() == "reset") return EvalState.RESET; else if (exclusion.ToLower() == "fail") return EvalState.FAILED; else return EvalState.INVALID; } } }
public override EvalState Evaluate(Part part, float deltaTime, ExperimentState state) { bool valid; tooltip = "\nBiome Condition"; if (restriction) { if (exclusion.ToLower() == "reset") tooltip += "\nThe following condition must <b>not</b> be met. If they are the experiment will be <b>reset</b>."; else if (exclusion.ToLower() == "fail") tooltip += "\nThe following condition must <b>not</b> be met. If they are, the experiment will <b>fail</b>."; else tooltip += "\nThe following condition must <b>not</b> be met."; } else tooltip += "\nThe following condition must be met."; string currentBiome = ScienceUtil.GetExperimentBiome(part.vessel.mainBody, part.vessel.latitude, part.vessel.longitude); tooltip += String.Format("\nCraft biome equal to <b>{0}</b>. Currently <b>{1}</b>", biome, currentBiome); if (biome.ToLower() == currentBiome.ToLower()) valid = true; else valid = false; if (!restriction) { if (valid) return EvalState.VALID; else return EvalState.INVALID; } else { if (!valid) return EvalState.VALID; else { if (exclusion.ToLower() == "reset") return EvalState.RESET; else if (exclusion.ToLower() == "fail") return EvalState.FAILED; else return EvalState.INVALID; } } }
private void ButtonStateChanged(object sender, ExperimentStateArgs args) { ExperimentState toState = (ExperimentState)Enum.Parse(typeof(ExperimentState), args.ToState); switch (toState) { case ExperimentState.Started: SetButtonStop(); break; case ExperimentState.Closed: SetButtonStart(); break; default: break; } }
public override EvalState Evaluate(Part part, float deltaTime, ExperimentState state) { bool valid = false; tooltip = "\nBody Condition"; if (restriction) { if (exclusion.ToLower() == "reset") tooltip += "\nThe following condition must <b>not</b> be met. If they are the experiment will be <b>reset</b>."; else if (exclusion.ToLower() == "fail") tooltip += "\nThe following condition must <b>not</b> be met. If they are, the experiment will <b>fail</b>."; else tooltip += "\nThe following condition must <b>not</b> be met."; } else tooltip += "\nThe following condition must be met."; tooltip += String.Format("\nCraft sphere of influence equal to <b>{0}</b>. Currently <b>{1}</b>", body, part.vessel.mainBody.name.ToLower()); if (part.vessel.mainBody.name.ToLower() == body) valid = true; if (!restriction) { if (valid) return EvalState.VALID; else return EvalState.INVALID; } else { if (!valid) return EvalState.VALID; else { if (exclusion.ToLower() == "reset") return EvalState.RESET; else if (exclusion.ToLower() == "fail") return EvalState.FAILED; else return EvalState.INVALID; } } }
public override EvalState Evaluate(Part part, float deltaTime, ExperimentState state) { bool valid = false; tooltip = "\nCrewed Condition"; if (restriction) { if (exclusion.ToLower() == "reset") tooltip += "\nThe following condition must <b>not</b> be met. If they are the experiment will be <b>reset</b>."; else if (exclusion.ToLower() == "fail") tooltip += "\nThe following condition must <b>not</b> be met. If they are, the experiment will <b>fail</b>."; else tooltip += "\nThe following condition must <b>not</b> be met."; } else tooltip += "\nThe following condition must be met."; int currentCrew = part.vessel.GetCrewCount(); if (currentCrew >= minimumCrew && currentCrew <= maximumCrew) valid = true; if (!restriction) { if (valid) return EvalState.VALID; else return EvalState.INVALID; } else { if (!valid) return EvalState.VALID; else { if (exclusion.ToLower() == "reset") return EvalState.RESET; else if (exclusion.ToLower() == "fail") return EvalState.FAILED; else return EvalState.INVALID; } } }
public void PauseExperiment() { if (experimentThread.IsAlive) { if (es.Equals(ExperimentState.IsRunning)) { ToConsole("Pausing experiment..."); es = ExperimentState.IsPaused; } else if (es.Equals(ExperimentState.IsPaused)) { ToConsole("Restarting experiment..."); es = ExperimentState.IsRunning; } } else { ToConsole("Cannot Pause. Experiment doesn't seem to be running."); } }
internal static void Update(Guid vesselId, string id, int state) { if (vesselId == null) { return; } if (!states.ContainsKey(vesselId)) { states[vesselId] = new List <StateEntry>(); } var list = states[vesselId]; var entry = list.Find(e => e.id == id); bool changed = false; // Kerbalism ExpStatus { 0: Stopped, 1: Running, 2: Forced, 3: Waiting, 4: Issue, 5: Broken } ExperimentState value = (state == 1 || state == 2) ? ExperimentState.running : ExperimentState.stopped; Utils.LogDebug($"{vesselId} {id} {state} ({value})"); if (entry == null) { changed = true; list.Add(new StateEntry(id, value)); } else { changed = entry.value != value; entry.value = value; } if (changed) { for (int i = listeners.Count - 1; i >= 0; i--) { listeners[i](vesselId, id, value); } } }
public override EvalState Evaluate(Part part, float deltaTime, ExperimentState state) { tooltip = "\nGeeForce Condition"; if (restriction) { if (exclusion.ToLower() == "reset") tooltip += "\nThe following condition must <b>not</b> be met. If they are the experiment will be <b>reset</b>."; else if (exclusion.ToLower() == "fail") tooltip += "\nThe following condition must <b>not</b> be met. If they are, the experiment will <b>fail</b>."; else tooltip += "\nThe following condition must <b>not</b> be met."; } else tooltip += "\nThe following condition must be met."; tooltip += String.Format("\nG-Force between <b>{0:F2}</b> and <b>{1:F2}</b>. Currently <b>{2:F2}</b>", gMin, gMax, FlightGlobals.ship_geeForce); bool valid = FlightGlobals.ship_geeForce >= gMin && FlightGlobals.ship_geeForce <= gMax; if (!restriction) { if (valid) return EvalState.VALID; else return EvalState.INVALID; } else { if (!valid) return EvalState.VALID; else { if (exclusion.ToLower() == "reset") return EvalState.RESET; else if (exclusion.ToLower() == "fail") return EvalState.FAILED; else return EvalState.INVALID; } } }
/// <summary> /// Switch to a designated state and handle the associated changes to the experimental and stimulus settings /// </summary> /// <param name = "newState"> The state to switch to</param> private void ChangeState(ExperimentState newState) { // define what happens in each state switch (newState) { case ExperimentState.Idle: break; case ExperimentState.PrepPractice: // Instructions startTime = Time.time; // Define Starttime for state textToSpeechManager.SpeakText("Welcome to our experiment! Let's begin with a quick tutorial. Depending on the experimental condition, you will see overlays that may help you with the task. Click to start exploring the room.Try walking around the room with the HoloLens and try to get an idea of what is in the room. "); break; case ExperimentState.BeginPractice: //startTime = Time.time; // Define Starttime for state textToSpeechManager.SpeakText("Begin!"); DisplayShader(); // load shader break; case ExperimentState.Practice: startTime = Time.time; // Define Starttime for state break; case ExperimentState.EndPractice: mappingMaterial.DrawVisualMeshes = false; // switch shader off again textToSpeechManager.SpeakText("Thank you, the tutorial is over. You can take off the HoloLens now hand it back to the experimenter and wait for instructions."); break; case ExperimentState.QuitApp: Application.Quit(); // Quit App break; default: break; } currentState = newState; }
public override EvalState Evaluate(Part part, float deltaTime, ExperimentState state) { bool valid = part.vessel.srfSpeed >= velocityMin && part.vessel.srfSpeed <= velocityMax; tooltip = "\nSurfaceSpeed Condition"; if (restriction) { if (exclusion.ToLower() == "reset") tooltip += "\nThe following condition must <b>not</b> be met. If they are the experiment will be <b>reset</b>."; else if (exclusion.ToLower() == "fail") tooltip += "\nThe following condition must <b>not</b> be met. If they are, the experiment will <b>fail</b>."; else tooltip += "\nThe following condition must <b>not</b> be met."; } else tooltip += "\nThe following condition must be met."; tooltip += String.Format("\nSurface speed between <b>{0:F2}</b> and <b>{1:F2}</b>. Currently <b>{2:F2}</b>", velocityMin, velocityMax, part.vessel.srfSpeed); if (!restriction) { if (valid) return EvalState.VALID; else return EvalState.INVALID; } else { if (!valid) return EvalState.VALID; else { if (exclusion.ToLower() == "reset") return EvalState.RESET; else if (exclusion.ToLower() == "fail") return EvalState.FAILED; else return EvalState.INVALID; } } }
public virtual EvalState Evaluate(Part part, float deltaTime, ExperimentState state) { return EvalState.VALID; }
void run() { ToConsole("Initialising hardware."); exp.Initialise(parameters); ToConsole("Acquiring data..."); int numberOfScans = 0; while (es.Equals(ExperimentState.IsRunning) || es.Equals(ExperimentState.IsPaused)) { //Tell UI to clear in preparation for new data. Clients.All.clearPlot(); currentDataSet = new DataSet(); int i = 0, iterationsSinceLastDataUpdate = 0; while (i < parameters.ScanParams.NumberOfPoints) { //This is to break out mid-scan if (es.Equals(ExperimentState.IsRunning)) { //Need to call this whether acquiring or not... (otherwise DDS command doesn't get sent) currentDataSet.Add(exp.SetupAndAcquire(parameters.ScanParams.ScanParameterValues[i])); i++; iterationsSinceLastDataUpdate++; //Only send to plot if acquisition happened. if (parameters.ScanParams.AcquireDataDuringScan) { //Cheezy solution for real time plotting. Update roughly every 0.5 seconds. If I update too often, it crashes on UI side. if (iterationsSinceLastDataUpdate * parameters.ScanParams.Sleep > 500) { //Push data down to the client like this. Clients.All.pushLatestData(currentDataSet.GetSubset(i - iterationsSinceLastDataUpdate, i).ToJson()); iterationsSinceLastDataUpdate = 0; } } } else if (es.Equals(ExperimentState.IsPaused)) { //Only send to plot if acquisition happened. if (parameters.ScanParams.AcquireDataDuringScan) { //Plots any residual data points during pause, if there is anything to plot if (iterationsSinceLastDataUpdate != 0) { Clients.All.pushLatestData(currentDataSet.GetSubset(i - iterationsSinceLastDataUpdate, i).ToJson()); iterationsSinceLastDataUpdate = 0; } } Thread.Sleep(1000); } else { break; //Somebody pressed the stop button during a scan. } } if (parameters.ScanParams.AcquireDataDuringScan) { dataArchive.Add(currentDataSet); numberOfScans++; //Push data down to the client like this. Clients.All.pushLatestData(currentDataSet.GetSubset(i - iterationsSinceLastDataUpdate, i).ToJson()); } if (parameters.ScanParams.StopOnEOS) { es = ExperimentState.IsFinishing; } } ToConsole("Acquisition/Move complete."); ToConsole("Disposing hardware classes..."); exp.Dispose(); ToConsole("Disposed."); ToConsole("Setting ExperimentState to stopped and closing thread..."); es = ExperimentState.IsStopped; }
public override EvalState Evaluate(Part part, float deltaTime, ExperimentState state) { bool valid = true; double r_ap = part.vessel.orbit.semiMajorAxis * (1 + part.vessel.orbit.eccentricity); double r_pe = part.vessel.orbit.semiMajorAxis * (1 - part.vessel.orbit.eccentricity); double radius = part.vessel.orbit.referenceBody.Radius; double ap = r_ap - radius; double pe = r_pe - radius; tooltip = "\nOrbit Condition"; if (restriction) { if (exclusion.ToLower() == "reset") tooltip += "\nThe following conditions must <b>not</b> be met. If they are the experiment will be <b>reset</b>."; else if (exclusion.ToLower() == "fail") tooltip += "\nThe following conditions must <b>not</b> be met. If they are, the experiment will <b>fail</b>."; else tooltip += "\nThe following conditions must <b>not</b> be met."; } else tooltip += "\nThe following conditions must be met."; tooltip += String.Format("\nCraft sphere of influence equal to <b>{0}</b>. Currently <b>{1}</b>", mainBody, part.vessel.mainBody.ToString().ToLower()); tooltip += String.Format("\nEccentricity between <b>{0:F2}</b> and <b>{1:F2}</b>. Currently <b>{2:F2}</b>", eccentricityMin, eccentricityMax, part.vessel.orbit.eccentricity); tooltip += String.Format("\nInclination between <b>{0:F2}</b> and <b>{1:F2}</b>. Currently <b>{2:F2}</b>", inclinationMin, inclinationMax, part.vessel.orbit.inclination); tooltip += String.Format("\nApoapsis between <b>{0:F2}</b> and <b>{1:F2}</b>. Currently <b>{2:F2}</b>", apoapsisMin, apoapsisMax, ap); tooltip += String.Format("\nPeriapsis between <b>{0:F2}</b> and <b>{1:F2}</b>. Currently <b>{2:F2}</b>", periapsisMin, periapsisMax, pe); tooltip += String.Format("\nOrbital velocity between <b>{0:F2}</b> and <b>{1:F2}</b>. Currently <b>{2:F2}</b>", velocityMin, velocityMax, part.vessel.obt_speed); if (part.vessel.mainBody.name.ToLower() != mainBody.ToLower()) valid = false; if (part.vessel.orbit.eccentricity < eccentricityMin) valid = false; if (part.vessel.orbit.eccentricity > eccentricityMax) valid = false; if (part.vessel.orbit.inclination < inclinationMin) valid = false; if (part.vessel.orbit.inclination > inclinationMax) valid = false; if ((float)ap < apoapsisMin) valid = false; if ((float)ap > apoapsisMax) valid = false; if ((float)pe < periapsisMin) valid = false; if ((float)pe > periapsisMax) valid = false; if (part.vessel.obt_speed < velocityMin) valid = false; if (part.vessel.obt_speed > velocityMax) valid = false; if (!restriction) { if (valid) return EvalState.VALID; else return EvalState.INVALID; } else { if (!valid) return EvalState.VALID; else { if (exclusion.ToLower() == "reset") return EvalState.RESET; else if (exclusion.ToLower() == "fail") return EvalState.FAILED; else return EvalState.INVALID; } } }
// Update is called once per frame protected virtual void Update() { //previousState = currentState; currentState = currentState.HandleInput(this); currentState.UpdateState(this); }
internal void finalize() { state = ExperimentState.FINALIZED; }
internal void installed(LabEquipment rack) { state = ExperimentState.INSTALLED; store = rack; rack.getLab().part.mass += getMass(); }
protected virtual void load(ConfigNode node) { state = getState(node.GetValue(STATE_VALUE)); }
void Update() { LogMessage msg; while (LogQueue.GetNext(out msg)) { switch (msg.Type) { case ELogType.Info: Debug.Log(msg.Message); break; case ELogType.Warning: Debug.LogWarning(msg.Message); break; case ELogType.Error: Debug.LogError(msg.Message); break; } } while (Net.GetNextEvent(out ConnectionEvent e)) { switch (e.EventType) { case ConnectionEvent.EType.Connected: OnClientConnected?.Invoke(this, new ConnectionEventArgs(e.Connection)); break; case ConnectionEvent.EType.Disconnected: OnClientDisconnected?.Invoke(this, new ConnectionEventArgs(e.Connection)); break; } } if (Net.GetState() == ENetworkState.Running) { while (Net.GetNextMessage(out byte[] message, out ConnectionHandle connection, out ENetChannel channel)) { NetworkData networkData = null; ENetDataType type = (ENetDataType)message[0]; switch (type) { case ENetDataType.UserState: networkData = new UserState(); break; case ENetDataType.ExperimentState: networkData = new ExperimentState(); break; case ENetDataType.RandomState: networkData = new RandomState(); break; case ENetDataType.ResponseState: networkData = new ResponseState(); break; default: Debug.LogError("Unknown NetDataType " + (int)type); break; } if (networkData != null) { networkData.Deserialize(message); ReceivedNetworkDataEventArgs args = new ReceivedNetworkDataEventArgs(connection, networkData, type); OnNetworkDataReceived?.Invoke(this, args); //Debug.LogFormat("Received Network data of type '{0}'", type.ToString(), networkData); } } } }
/// <summary> /// Switch to a designated state and handle the associated changes to the experimental and stimulus settings /// </summary> /// <param name = "newState"> The state to switch to</param> private void ChangeState(ExperimentState newState) { // define what happens in each state switch (newState) { case ExperimentState.Idle: break; case ExperimentState.PrepTasks: startTime = Time.time; // Define Starttime for state textToSpeechManager.SpeakText("Once you are in the room and ready to start, click to go to the next step."); break; case ExperimentState.InstrTask1: startTime = Time.time; // Define Starttime for state //textToSpeechManager.SpeakText("Your first task is to find a chair and sit down as quickly as possible. Use the clicker as soon as you sat down. Click to start when you are ready!"); textToSpeechManager.SpeakText("Click to start!"); // ChangeMesh(); // loads an existing room model (high res mesh) and uses that instead of the online mesh. DON'T DO THIS YET. break; case ExperimentState.BeginTask1: startTime = Time.time; // Define Starttime for state textToSpeechManager.SpeakText("Go!"); DisplayShader(); //mappingMaterial.DrawVisualMeshes = true; // switch shader on break; case ExperimentState.Task1: startTime = Time.time; // Define Starttime for state break; case ExperimentState.EndTask1: startTime = Time.time; // Define Starttime for state mappingMaterial.DrawVisualMeshes = false; // shader off textToSpeechManager.SpeakText("Great! You've completed the first task! Wait for instructions."); break; case ExperimentState.BeginTask2: textToSpeechManager.SpeakText("Go!"); DisplayShader(); break; case ExperimentState.Task2: startTime = Time.time; break; case ExperimentState.EndTask2: startTime = Time.time; mappingMaterial.DrawVisualMeshes = false; textToSpeechManager.SpeakText("Great! You've completed the second task! Keep the HoloLens and the low vision goggles on while the experimenter guides you out of the room."); break; case ExperimentState.QuitApp: //startTime = Time.time; // Define Starttime for state Application.Quit(); // Quit App break; default: break; } currentState = newState; }
public void StartExploration() { prevState = _experimentState; SetState(ExperimentState.Exploring); }