Ejemplo n.º 1
0
        public static bool IsConnected()
        {
            bool isConnected = false;

            try
            {
                // string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
                var           dir     = GTPath.GetLocalApplicationDataPath();
                DirectoryInfo dirInfo = new DirectoryInfo(new Uri(dir).LocalPath);
                //Context ctx = new Context(dirInfo.FullName + "\\" + configFile);
                //ProductionNode irNode = ctx.FindExistingNode(NodeType.IR) as IRGenerator;

                //if (irNode != null)
                //  isConnected = true;

                //irNode.Dispose();
                //ctx.Dispose();
            }
            catch (Exception)
            {
                isConnected = false;
            }

            return(isConnected);
        }
Ejemplo n.º 2
0
        private void AcceptCalibration(object sender, RoutedEventArgs e)
        {
            // Hide UI
            calibrationMenu.Visibility  = Visibility.Collapsed;
            this.visualPoint.Visibility = Visibility.Collapsed;

            // Grab screenshot
            string savePath =
                GTPath.GetLocalApplicationDataPath()
                + Path.DirectorySeparatorChar
                + "Calibration"
                + Path.DirectorySeparatorChar
                + Tracker.Instance.Calibration.ID
                + Path.DirectorySeparatorChar
                + "calibrationScreen.png";

            SaveImage(savePath, CanvasRoot.GetScreenShot(1));

            // Dump Instance settings into the calibration folder
            FileInfo fileSettings = new FileInfo(Settings.Instance.FileSettings.SettingsDirectory + Settings.Instance.GetLatestConfigurationFile());

            try
            {
                File.Copy(fileSettings.FullName, Tracker.Instance.Calibration.DataFolder + "\\" + fileSettings.Name);
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine("Error dumping calibration data in CalibrationWindow.AcceptCalibration(), message: " + ex.Message);
            }

            // Trigger global calibration accept (will hide this)
            GTCommands.Instance.Calibration.Accept();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Prevents a default instance of the GTSettings class from being created.
        /// </summary>
        private Settings()
        {
            fileSettings          = new FileSettings();
            processingSettings    = new Processing();
            eyestrackerSettings   = new Eyestracker();
            eyetrackerSettings    = new Eyetracker();
            cameraSettings        = new Camera();
            calibrationSettings   = new Calibration();
            networkSettings       = new Network();
            visualizationSettings = new Visualization();
            autotuneSettings      = new Autotune();
            eyeMovementSettings   = new EyeMovement();
            cloudSettings         = new Cloud();

            // Observe Config directory and update combobox when new files are written/changed/deleted..
            myWatcher = new FileSystemWatcher(GTPath.GetLocalApplicationDataPath() +
                                              Path.DirectorySeparatorChar + "Settings",
                                              "*.xml");
            myWatcher.Path = fileSettings.SettingsDirectory;
            myWatcher.EnableRaisingEvents   = true;
            myWatcher.IncludeSubdirectories = false;
            myWatcher.Created += WatcherSettingsDirUpdated;
            myWatcher.Changed += WatcherSettingsDirUpdated;
            myWatcher.Deleted += WatcherSettingsDirUpdated;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Writes the given line into the log file.
        /// </summary>
        /// <param name="line">A <see cref="string"/> with the text to be written.</param>
        public void WriteLine(string line)
        {
            // logwriter is created when logfilepath is set, if not use default "gazeLog.txt"
            if (logWriter == null)
            {
                if (logFilePath == null)
                {
                    fs =
                        new FileStream(
                            GTPath.GetLocalApplicationDataPath() +
                            Path.DirectorySeparatorChar + "gazeLog.txt",
                            FileMode.Create);
                }
                else
                {
                    fs = new FileStream(logFilePath, FileMode.Append);
                }

                logWriter = new StreamWriter(fs);
            }

            if (isSystemLog)
            {
                logWriter.WriteLine(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString() + " " +
                                    line);
            }
            else
            {
                logWriter.WriteLine(line);
            }

            logWriter.Flush();
        }
Ejemplo n.º 5
0
        public FileSettings()
        {
            string appDataPath = GTPath.GetLocalApplicationDataPath() +
                                 Path.DirectorySeparatorChar + "Settings";

            if (!Directory.Exists(appDataPath))
            {
                Directory.CreateDirectory(appDataPath);
            }

            settingsDirectory = appDataPath;
            loggingEnabled    = false;
            logFilePath       = "";
            settingsName      = "";
        }
Ejemplo n.º 6
0
        public override bool Initialize()
        {
            // string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
            var           dir     = GTPath.GetLocalApplicationDataPath();
            DirectoryInfo dirInfo = new DirectoryInfo(new Uri(dir).LocalPath);

            //this.context = new Context(dirInfo.FullName + Path.DirectorySeparatorChar + configFile);

            //this.ir = context.FindExistingNode(NodeType.IR) as IRGenerator;

            //if (this.ir != null)
            //  return true;
            //else
            return(false);
        }
Ejemplo n.º 7
0
        private void CreateOutputfolder()
        {
            // var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
            var basePath = GTPath.GetLocalApplicationDataPath();

            // Check if default "Calibration" dir exists, if not create it
            if (!Directory.Exists(basePath + Path.DirectorySeparatorChar + baseFolder))
            {
                Directory.CreateDirectory(basePath + Path.DirectorySeparatorChar + baseFolder);
            }

            this.dataPath = basePath + Path.DirectorySeparatorChar + baseFolder + Path.DirectorySeparatorChar + this.id;

            if (!Directory.Exists(this.dataPath))
            {
                Directory.CreateDirectory(this.dataPath);
            }
        }
Ejemplo n.º 8
0
        //private void worker_data_DoWork(object sender, DoWorkEventArgs e)
        //{
        // used for the gazegroup php upload script
        //string id = e.Argument as string;

        //string directory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
        //directory += "\\Community";

        //Uri dirUri = new Uri(directory);

        //FileInfo fileNfoImage = new FileInfo(dirUri.LocalPath + "\\" + id + ".jpg");
        //FileInfo fileNfoData = new FileInfo(dirUri.LocalPath + "\\" + id + ".txt");

        //UploadFile[] files = new UploadFile[]
        //{
        //    new UploadFile(fileNfoData.FullName, "data", "text/plain"),
        //    new UploadFile(fileNfoImage.FullName, "image", "image/jpeg"),
        //};

        //HttpWebRequest req = HttpWebRequest.Create(new Uri("http://www.gazegroup.org/community/calibrationupload.php"));

        //NameValueCollection form = new NameValueCollection();
        //form["name1"] = "value1";

        //    try
        //    {
        //        string response = HttpUploadHelper.Upload("http://www.gazegroup.org/community/calibrationupload.php", files, form);
        //    }
        //    catch(Exception ex)
        //    {
        //        Console.Out.WriteLine("CalibrationSharing: " + ex.Message);
        //    }
        //}


        private void worker_data_DoWork(object sender, DoWorkEventArgs e)
        {
            var id = e.Argument as string;

            // string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
            var directory = GTPath.GetLocalApplicationDataPath();

            directory += Path.DirectorySeparatorChar + "Community";

            var dirUri = new Uri(directory);

            var fileNfoImage = new FileInfo(dirUri.LocalPath + Path.DirectorySeparatorChar + id + ".jpg");

            SendFile(fileNfoImage, true);

            var fileNfoData = new FileInfo(dirUri.LocalPath + Path.DirectorySeparatorChar + id + ".txt");

            SendFile(fileNfoData, false);
        }
Ejemplo n.º 9
0
        public ThorlabCamera()
        {
            // hwndSource must be set to addhook to messageloop for thorlab messages
            this.messageDummyWindow        = new Window();
            this.messageDummyWindow.Width  = 1;
            this.messageDummyWindow.Height = 1;
            this.messageDummyWindow.Left   = 2000;
            this.messageDummyWindow.Show();

            var wih = new WindowInteropHelper(this.messageDummyWindow);

            this.hwndSource = HwndSource.FromHwnd(wih.Handle);
            if (this.hwndSource != null)
            {
                this.hwnd = this.hwndSource.Handle;
            }
            else
            {
                throw new Exception("HwndSource of Thorlabs=null");
            }

            //var curProc = Process.GetCurrentProcess();
            //this.hwndSource = HwndSource.FromHwnd(curProc.MainWindowHandle);
            //this.hwnd = this.hwndSource.Handle;

            // Settings file
            // string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
            var dir     = GTPath.GetLocalApplicationDataPath();
            var dirInfo = new DirectoryInfo(new Uri(dir).LocalPath);

            this.parametersFileStr = dirInfo.FullName + Path.DirectorySeparatorChar + this.defaultParametersFile;

            this.m_uc480  = new ThorlabDevice();
            this.settings = new ThorlabSettings(this.m_uc480);

            this.Name = "Thorlabs UC480";

            this.DetermineMaxFPS();
        }
Ejemplo n.º 10
0
        public ThorlabCamera()
        {
            // Must be set
            var curProc = Process.GetCurrentProcess();

            this.hwndSource = HwndSource.FromHwnd(curProc.MainWindowHandle);
            this.hwnd       = this.hwndSource.Handle;

            // Settings file
            // string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
            var dir     = GTPath.GetLocalApplicationDataPath();
            var dirInfo = new DirectoryInfo(new Uri(dir).LocalPath);

            this.parametersFileStr = dirInfo.FullName + Path.DirectorySeparatorChar + this.defaultParametersFile;

            this.m_uc480  = new ThorlabDevice();
            this.settings = new ThorlabSettings(this.m_uc480);

            this.Name = "Thorlabs UC480";

            this.DetermineMaxFPS();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// This method writes the given line into the ErrorLog.txt file.
        /// </summary>
        /// <param name="line">A <see cref="string"/> toi be written to file.</param>
        public static void WriteLine(string line)
        {
            try
            {
                // Use always ErrorLog.txt in LocalApplicationData
                if (logWriter == null)
                {
                    fs =
                        new FileStream(GTPath.GetLocalApplicationDataPath() +
                                       Path.DirectorySeparatorChar + "GTErrorLog.txt",
                                       FileMode.Append);
                    logWriter = new StreamWriter(fs);
                }

                logWriter.WriteLine(line);
                logWriter.Flush();
                Console.WriteLine(line);
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine("ErrorLogger.cs, exception in WriteLine(string). Message: " + ex.Message);
            }
        }
Ejemplo n.º 12
0
        private void SendDataGazeGroup(string calibrationData, BitmapSource bitmapImage)
        {
            bmp = bitmapImage;

            // Generate ID
            var rand = new Random(DateTime.Now.Millisecond);

            id = rand.Next(9999999);
            this.calibrationData = id + "\n" + calibrationData;

            // Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
            string directory = GTPath.GetLocalApplicationDataPath();

            directory += Path.DirectorySeparatorChar + "Community";
            var dirUri = new Uri(directory);

            // Check dir
            if (!Directory.Exists(dirUri.LocalPath))
            {
                Directory.CreateDirectory(dirUri.LocalPath);
            }

            // Save to files
            var fileCalibrationData = new FileInfo(dirUri.LocalPath + Path.DirectorySeparatorChar + id + ".txt");

            SaveCalibrationData(fileCalibrationData, calibrationData);

            var fileImage = new FileInfo(dirUri.LocalPath + Path.DirectorySeparatorChar + id + ".jpg");

            SaveImage(fileImage, bitmapImage);

            // Send data
            worker_data                     = new BackgroundWorker();
            worker_data.DoWork             += worker_data_DoWork;
            worker_data.RunWorkerCompleted += worker_data_Completed;
            worker_data.RunWorkerAsync(id.ToString());
        }
Ejemplo n.º 13
0
 public Settings()
 {
     // Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
     this.directory = GTPath.GetLocalApplicationDataPath();
     this.LoadSettings();
 }