private void TriggerOverlay() { List <Vector2Int> unsafeCandidates = FindAllCandidatesAroundTarget(target); //FindAllUnsafesUnderDistance(safetyDistance); if (currSubChanges.Count() <= unsafeCandidates.Count()) { ListExtension.Shuffle(unsafeCandidates); diffCandidates = new List <Vector3Int>(); for (int i = 0; i < currSubChanges.Count(); i++) { diffCandidates.Add(new Vector3Int(unsafeCandidates[i].x, unsafeCandidates[i].y, currSubChanges[i])); } // Output Control for (int i = 0; i < expanDialSticks.NbRows; i++) { for (int j = 0; j < expanDialSticks.NbColumns; j++) { expanDialSticks.modelMatrix[i, j].CurrentFeedForwarded = 0; } } foreach (Vector3Int diffCandidate in diffCandidates) { expanDialSticks.modelMatrix[diffCandidate.x, diffCandidate.y].CurrentFeedForwarded = diffCandidate.z; } expanDialSticks.triggerSafetyChange(); safeGuard.Freeze(); DisplayInstructions("Tourner les cylindres arrêtés <b>du plus descendant au plus ascendant</b>."); string shapeChangeMsg = "SHAPE_CHANGE ["; foreach (Vector3Int diffCandidate in diffCandidates) { shapeChangeMsg += " " + diffCandidate.ToString() + " "; } shapeChangeMsg += "]"; expanDialSticks.client.Publish(MQTT_SYSTEM_RECORDER, System.Text.Encoding.UTF8.GetBytes(shapeChangeMsg), MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, false); LogMetrics(); overlayAppeared = true; } else { DisplayInstructions("Veuillez réessayer."); } }
void OnGUI() { if (unknownParticipant) { // Make a text field that modifies stringToEdit. float midX = Screen.width / 2.0f; float midY = Screen.height / 2.0f; float componentHeight = 20; //GUI.Label(new Rect(midX - 50 - , midY, 100, 20), "Hello World!"); stringParticipant = GUI.TextField(new Rect(midX - 55, midY, 50, componentHeight), stringParticipant, 25); if (GUI.Button(new Rect(midX + 5, midY - 50, 150, componentHeight), "Training Overlay")) { numeroParticipant = int.Parse(stringParticipant); Debug.Log("TRAINING"); string identity = "USER_IDENTITY " + numeroParticipant + " TRAINING"; expanDialSticks.client.Publish(MQTT_SYSTEM_RECORDER, System.Text.Encoding.UTF8.GetBytes(identity), MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, false); // init trials /*InitTrials(); * moleIndex = -1; * moleState = MOLE_TO_APPEAR; * * currTime = LOG_INTERVAL; * prevTime = 0f; * string identity = "USER_IDENTITY " + numeroParticipant + " USER_TRIGGERED TRAINING"; * expanDialSticks.client.Publish(MQTT_SYSTEM_RECORDER, System.Text.Encoding.UTF8.GetBytes(identity), MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, false); */ unknownParticipant = false; } if (GUI.Button(new Rect(midX + 5, midY - 25, 150, componentHeight), "Edge Overlay")) { expanDialSticks.SetSafetyMode(ExpanDialSticks.SafetyMotionMode.SafetyRatedMonitoredStop); numeroParticipant = int.Parse(stringParticipant); Debug.Log("Start"); currOverlay = ExpanDialSticks.SafetyOverlayMode.Edge; expanDialSticks.SetOverlayMode(currOverlay); expanDialSticks.triggerSafetyChange(); string identity = "USER_IDENTITY " + numeroParticipant + " EDGE_OVERLAY"; expanDialSticks.client.Publish(MQTT_SYSTEM_RECORDER, System.Text.Encoding.UTF8.GetBytes(identity), MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, false); unknownParticipant = false; } if (GUI.Button(new Rect(midX + 5, midY, 150, componentHeight), "Surface Overlay")) { expanDialSticks.SetSafetyMode(ExpanDialSticks.SafetyMotionMode.SafetyRatedMonitoredStop); numeroParticipant = int.Parse(stringParticipant); Debug.Log("Start"); currOverlay = ExpanDialSticks.SafetyOverlayMode.Fill; expanDialSticks.SetOverlayMode(currOverlay); expanDialSticks.triggerSafetyChange(); string identity = "USER_IDENTITY " + numeroParticipant + " SURFACE_OVERLAY"; expanDialSticks.client.Publish(MQTT_SYSTEM_RECORDER, System.Text.Encoding.UTF8.GetBytes(identity), MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, false); unknownParticipant = false; } if (GUI.Button(new Rect(midX + 5, midY + 25, 150, componentHeight), "Hull Overlay")) { expanDialSticks.SetSafetyMode(ExpanDialSticks.SafetyMotionMode.SafetyRatedMonitoredStop); numeroParticipant = int.Parse(stringParticipant); Debug.Log("Start"); currOverlay = ExpanDialSticks.SafetyOverlayMode.Hull; expanDialSticks.SetOverlayMode(currOverlay); expanDialSticks.triggerSafetyChange(); string identity = "USER_IDENTITY " + numeroParticipant + " HULL_OVERLAY"; expanDialSticks.client.Publish(MQTT_SYSTEM_RECORDER, System.Text.Encoding.UTF8.GetBytes(identity), MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, false); unknownParticipant = false; } if (GUI.Button(new Rect(midX + 5, midY + 50, 150, componentHeight), "Zone Overlay")) { expanDialSticks.SetSafetyMode(ExpanDialSticks.SafetyMotionMode.SafetyRatedMonitoredStop); numeroParticipant = int.Parse(stringParticipant); Debug.Log("Start"); currOverlay = ExpanDialSticks.SafetyOverlayMode.Zone; expanDialSticks.SetOverlayMode(currOverlay); expanDialSticks.triggerSafetyChange(); string identity = "USER_IDENTITY " + numeroParticipant + " ZONE_OVERLAY"; expanDialSticks.client.Publish(MQTT_SYSTEM_RECORDER, System.Text.Encoding.UTF8.GetBytes(identity), MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, false); unknownParticipant = false; } } }