Example #1
0
    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 - 25, midY, 50, componentHeight), stringParticipant, 25);
            if (GUI.Button(new Rect(midX + 25, midY, 70, componentHeight), "TRAINING"))
            {
                training          = true;
                numeroParticipant = int.Parse(stringParticipant);
                // init trials
                InitTrials();
                gaugeIndex = -1;
                gaugeState = GAUGE_TO_APPEAR;

                currTime = LOG_INTERVAL;
                prevTime = 0f;

                string identity = "USER_IDENTITY " + numeroParticipant + " SYSTEM_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 + 75, midY + 25, 50, componentHeight), "SMS"))
            {
                training = false;
                expanDialSticks.SetSafetyMode(ExpanDialSticks.SafetyMotionMode.SafetyRatedMonitoredStop);
                numeroParticipant = int.Parse(stringParticipant);
                // init trials
                InitTrials();
                gaugeIndex = -1;
                gaugeState = GAUGE_TO_APPEAR;

                currTime = LOG_INTERVAL;
                prevTime = 0f;
                string identity = "USER_IDENTITY " + numeroParticipant + " SYSTEM_TRIGGERED SMS TRIAL";
                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 + 75, midY - 25, 50, componentHeight), "SSM"))
            {
                training = false;
                expanDialSticks.SetSafetyMode(ExpanDialSticks.SafetyMotionMode.SpeedAndSeparationMonitoring);
                numeroParticipant = int.Parse(stringParticipant);
                // init trials
                InitTrials();
                gaugeIndex = -1;
                gaugeState = GAUGE_TO_APPEAR;

                currTime = LOG_INTERVAL;
                prevTime = 0f;
                string identity = "USER_IDENTITY " + numeroParticipant + " SYSTEM_TRIGGERED SSM TRIAL";
                expanDialSticks.client.Publish(MQTT_SYSTEM_RECORDER, System.Text.Encoding.UTF8.GetBytes(identity), MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE, false);
                unknownParticipant = false;
            }
        }
    }
Example #2
0
    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;
            }
        }
    }