예제 #1
0
    private void SetDevice(DeviceMode device)
    {
        if (device == DeviceMode.None)
        {
            return;
        }

        if (device == DeviceMode.Level)
        {
            //protractorBtn.GetComponent<Image>().color = deviceNormal;
            //levelBtn.GetComponent<Image>().color = deviceSelected;
            level.enabled = true;
            //protractor.enabled = false;
            //ToggleZero( false );

            m_isDeviceActive = true;
            m_device         = level;
        }
        //else if(device == DeviceMode.Protractor) {
        //    protractorBtn.GetComponent<Image>().color = deviceSelected;
        //    levelBtn.GetComponent<Image>().color = deviceNormal;
        //    level.enabled = false;
        //    protractor.enabled = true;
        //    ToggleZero( true );

        //    m_isDeviceActive = true;
        //    m_device = protractor;
        //}

        // Start Coroutine to update angles
        StartCoroutine(UpdateView());

        m_deviceMode = device;
        Settings.SetValue(k_deviceModeKey, m_deviceMode.ToString());
    }
예제 #2
0
        public void SetMode(DeviceMode mode)
        {
            string statusUrl = string.Format("{0}?mode={1}", settingsUrl, mode.ToString());

            using (HttpClient httpClient = new HttpClient())
            {
                var httpResponse = httpClient.GetStringAsync(statusUrl).Result;
                //  StatusResponse statusResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<StatusResponse>(httpResponse);
            }
        }
예제 #3
0
 public void WriteProfile(Profile driverProfile)
 {
     if (Hub.DebugTraceState)
     {
         Hub.TL.LogMessage("Sensor.WriteProfile", SensorName + " DeviceMode: " + DeviceMode.ToString());
     }
     driverProfile.WriteValue(Hub.DRIVER_PROGID, DEVICEMODE_PROFILENAME, DeviceMode.ToString(), SensorName);
     if (Hub.DebugTraceState)
     {
         Hub.TL.LogMessage("Sensor.WriteProfile", SensorName + " ProgID: " + ProgID);
     }
     driverProfile.WriteValue(Hub.DRIVER_PROGID, PROGID_PROFILENAME, ProgID, SensorName);
     if (Hub.DebugTraceState)
     {
         Hub.TL.LogMessage("Sensor.WriteProfile", SensorName + " SwitchNumber: " + SwitchNumber.ToString());
     }
     driverProfile.WriteValue(Hub.DRIVER_PROGID, SWITCHNUMBER_PROFILENAME, SwitchNumber.ToString(CultureInfo.InvariantCulture), SensorName);
     if (Hub.DebugTraceState)
     {
         Hub.TL.LogMessage("Sensor.WriteProfile", SensorName + " Completed writing profile values");
     }
 }
예제 #4
0
        public void WriteConfigFile(XmlTextWriter xmlWriter)
        {
            if (DeviceName.Length < 1)
            {
                DeviceName = "Settings " + DateTime.Now;
            }

            xmlWriter.WriteStartElement("CameraSettings");

            Settings.WriteElement(xmlWriter, "DeviceName", DeviceName);
            Settings.WriteElement(xmlWriter, "DeviceNumber", DeviceNumber.ToString());
            Settings.WriteElement(xmlWriter, "DeviceMode", DeviceMode.ToString());

            Settings.WriteElement(xmlWriter, "Brightness", Brightness.ToString());
            Settings.WriteElement(xmlWriter, "BrightnessAuto", BrightnessAuto.ToString());

            Settings.WriteElement(xmlWriter, "Contrast", Contrast.ToString());
            Settings.WriteElement(xmlWriter, "ContrastAuto", ContrastAuto.ToString());

            Settings.WriteElement(xmlWriter, "Saturation", Saturation.ToString());
            Settings.WriteElement(xmlWriter, "SaturationAuto", SaturationAuto.ToString());

            Settings.WriteElement(xmlWriter, "Sharpness", Sharpness.ToString());
            Settings.WriteElement(xmlWriter, "SharpnessAuto", SharpnessAuto.ToString());

            Settings.WriteElement(xmlWriter, "Zoom", Zoom.ToString());
            Settings.WriteElement(xmlWriter, "ZoomAuto", ZoomAuto.ToString());

            Settings.WriteElement(xmlWriter, "Focus", Focus.ToString());
            Settings.WriteElement(xmlWriter, "FocusAuto", FocusAuto.ToString());

            Settings.WriteElement(xmlWriter, "Exposure", Exposure.ToString());
            Settings.WriteElement(xmlWriter, "ExposureAuto", ExposureAuto.ToString());

            Settings.WriteElement(xmlWriter, "FlipImage", FlipImage.ToString());

            xmlWriter.WriteEndElement();
        }
예제 #5
0
        void Awake()
        {
            // Attach communication components.
            receiver = gameObject.AddComponent <Receiver>();
            receiver.DataReceived += (source, message) => OnDataReceivedFromNetwork(message);
            arduino = gameObject.AddComponent <Arduino>();
            arduino.DataReceived += (source, data) => {
                OnDataReceivedFromArduino(data);
            };

            // Setup UI components.
            menuCanvas      = GameObject.Find("MenuCanvas").GetComponent <Canvas>();
            intertrialImage = GameObject.Find("Blank").GetComponent <RawImage>();
            consoleText     = GameObject.Find("Console").GetComponent <Text>();

            InputField startPositionInput = GameObject.Find("StartPosition").GetComponent <InputField>();

            startPosition = PlayerPrefs.GetFloat(startPositionInput.name, startPosition);
            SetupCombo(GameObject.Find("SetStartPosition").GetComponent <Button>(), startPositionInput, startPosition.ToString(), TestFloat,
                       () => {
                startPosition = float.Parse(startPositionInput.text);
                PlayerPrefs.SetFloat(startPositionInput.name, startPosition);
                PlayerPrefs.Save();
            },
                       () => transform.position = new Vector3(transform.position.x, transform.position.y, startPosition)
                       );

            InputField finishPositionInput = GameObject.Find("FinishPosition").GetComponent <InputField>();

            finishPosition = PlayerPrefs.GetFloat(finishPositionInput.name, finishPosition);
            SetupCombo(GameObject.Find("SetFinishPosition").GetComponent <Button>(), finishPositionInput, finishPosition.ToString(), TestFloat,
                       () => {
                finishPosition = float.Parse(finishPositionInput.text);
                PlayerPrefs.SetFloat(finishPositionInput.name, finishPosition);
                PlayerPrefs.Save();
            },
                       () => transform.position = new Vector3(transform.position.x, transform.position.y, finishPosition)
                       );

            InputField intertrialDurationInput = GameObject.Find("IntertrialDuration").GetComponent <InputField>();

            intertrialDuration = PlayerPrefs.GetFloat(intertrialDurationInput.name, intertrialDuration);
            SetupCombo(GameObject.Find("SetIntertrialDuration").GetComponent <Button>(), intertrialDurationInput, intertrialDuration.ToString(), TestPositiveFloat,
                       () => {
                intertrialDuration = float.Parse(intertrialDurationInput.text);
                PlayerPrefs.SetFloat(intertrialDurationInput.name, intertrialDuration);
                PlayerPrefs.Save();
            },
                       () => StartIntertrial()
                       );

            InputField wheelRadiusInput = GameObject.Find("WheelRadius").GetComponent <InputField>();

            wheelRadius = PlayerPrefs.GetFloat(wheelRadiusInput.name, wheelRadius);
            SetupCombo(GameObject.Find("SetWheelRadius").GetComponent <Button>(), wheelRadiusInput, wheelRadius.ToString(), TestFloat,
                       () => {
                wheelRadius = float.Parse(wheelRadiusInput.text);
                wheelFactor = 2 * Mathf.PI / wheelSteps * wheelRadius;
                PlayerPrefs.SetFloat(wheelRadiusInput.name, wheelRadius);
                PlayerPrefs.Save();
            }
                       );

            InputField wheelStepsInput = GameObject.Find("WheelSteps").GetComponent <InputField>();

            wheelSteps = (int)PlayerPrefs.GetFloat(wheelStepsInput.name, wheelSteps);
            SetupCombo(GameObject.Find("SetWheelSteps").GetComponent <Button>(), wheelStepsInput, wheelSteps.ToString(), TestInt,
                       () => {
                wheelSteps  = int.Parse(wheelStepsInput.text);
                wheelFactor = 2 * Mathf.PI / wheelSteps * wheelRadius;
                PlayerPrefs.SetFloat(wheelStepsInput.name, wheelSteps);
                PlayerPrefs.Save();
            }
                       );

            InputField serialNameInput      = GameObject.Find("SerialName").GetComponent <InputField>();
            Button     serialNameButton     = GameObject.Find("SetSerialName").GetComponent <Button>();
            Text       serialNameButtonText = serialNameButton.GetComponentInChildren <Text>();

            serialNameButtonText.text = "Connect";
            serialName           = PlayerPrefs.GetString(serialNameInput.name, serialName);
            serialNameInput.text = serialName;
            bool serialConnected = false;

            serialNameInput.onValidateInput +=
                delegate(string input, int charIndex, char addedChar) {
                if (serialConnected)
                {
                    serialNameButton.interactable = true;
                    serialConnected = false;
                    arduino.Stop();
                }
                serialNameButtonText.text = "Connect";
                return(addedChar);
            };
            serialNameButton.onClick.AddListener(
                delegate {
                if (serialConnected)
                {
                    serialConnected           = false;
                    serialNameButtonText.text = "Connect";
                    arduino.Stop();
                }
                else
                {
                    serialNameButton.interactable = false;
                    arduino.Setup(serialNameInput.text, baudrate,
                                  (connected, message) => {
                        serialNameButton.interactable = true;
                        if (connected)
                        {
                            serialConnected           = true;
                            serialNameButtonText.text = "Disconnect";
                        }
                        else
                        {
                            Log(string.Format("Unable to connect to '{0}': {1}", serialNameInput.text, message.Trim()));
                        }
                    }
                                  );
                    // Always save regarless of connection outcome.
                    serialName = serialNameInput.text;
                    PlayerPrefs.SetString(serialNameInput.name, serialName);
                    PlayerPrefs.Save();
                }
            }
                );

            InputField ipsInput      = GameObject.Find("IPs").GetComponent <InputField>();
            Button     ipsButton     = GameObject.Find("SetIPs").GetComponent <Button>();
            Text       ipsButtonText = ipsButton.GetComponentInChildren <Text>();

            ipsButtonText.text = "Connect";
            ips           = PlayerPrefs.GetString(ipsInput.name, ips);
            ipsInput.text = ips;
            bool senderConnected = false;

            ipsInput.onValidateInput +=
                delegate(string input, int charIndex, char addedChar) {
                if (senderConnected)
                {
                    senderConnected = false;
                    sender.Stop();
                }
                ipsButtonText.text = "Connect";
                return(addedChar);
            };
            ipsButton.onClick.AddListener(
                delegate {
                if (senderConnected)
                {
                    senderConnected    = false;
                    ipsButtonText.text = "Connect";
                    sender.Stop();
                }
                else
                {
                    bool success     = true;
                    string[] ipArray = Regex.Split(ipsInput.text, @"[\s,]+");
                    foreach (string ip in ipArray)
                    {
                        if (ip.Trim() != String.Empty && !Sender.Validate(ip))
                        {
                            Log(string.Format("'{0}' is not a valid IP address.", ip));
                            success = false;
                        }
                    }
                    if (success)
                    {
                        senderConnected    = true;
                        ipsButtonText.text = "Disconnect";
                        ips = ipsInput.text;
                        PlayerPrefs.SetString(ipsInput.name, ips);
                        PlayerPrefs.Save();
                        sender.Setup(ipArray, port);
                    }
                }
            }
                );

            viewAngleText = GameObject.Find("ViewAngle").GetComponentInChildren <Text>();
            Button viewAngleButton = GameObject.Find("SetViewAngle").GetComponent <Button>();

            viewAngleIndex = PlayerPrefs.GetInt("ViewAngleIndex", viewAngleIndex);
            ViewAngle      = viewAngles[viewAngleIndex];
            // Rotate views.
            viewAngleButton.onClick.AddListener(
                () => {
                viewAngleIndex = (viewAngleIndex + 1) % viewAngles.Length;
                ViewAngle      = viewAngles[viewAngleIndex];
                PlayerPrefs.SetInt("ViewAngleIndex", viewAngleIndex);
                PlayerPrefs.Save();
            }
                );

            deviceModeText = GameObject.Find("DeviceMode").GetComponentInChildren <Text>();
            Button deviceModeButton = GameObject.Find("SetDeviceMode").GetComponent <Button>();

            deviceMode = (DeviceModes)Enum.Parse(typeof(DeviceModes), PlayerPrefs.GetString("DeviceMode", deviceMode.ToString()));
            DeviceMode = deviceMode;
            // Alternate device modes.
            deviceModeButton.onClick.AddListener(
                () => {
                switch (DeviceMode)
                {
                case DeviceModes.Control:
                    DeviceMode          = DeviceModes.Monitor;
                    deviceModeText.text = "Monitor";
                    break;

                case DeviceModes.Monitor:
                    DeviceMode          = DeviceModes.Control;
                    deviceModeText.text = "Control";
                    break;
                }
                PlayerPrefs.SetString("DeviceMode", DeviceMode.ToString());
                PlayerPrefs.Save();
            }
                );


            wheelFactor        = 2 * Mathf.PI / wheelSteps * wheelRadius;
            transform.position = new Vector3(transform.position.x, transform.position.y, startPosition);

            if (!receiver.Setup(port))
            {
                Log(string.Format("Port {0} is unavailable in this device and remote data won't reach this device.", port));
            }

            string filename = System.IO.Path.Combine(outputFolder, string.Format("VR{0}.csv", System.DateTime.Now.ToString("yyyyMMddHHmmss")));

            logger = new Logger(filename);
            Log("Version: " + version);
            Log("About: [email protected]");
            Log("Filename: " + filename);
        }