Пример #1
0
        private void Window_Closed(object sender, EventArgs e)
        {
            //Close all booth windows
            foreach (var i in this.BoothList.Items)
            {
                var vm = i as BoothViewModel;
                if (vm != null)
                {
                    vm.CloseBoothWindowPermanently();
                }
            }

            //Get an instance of the scope manager.  This should also create the first instance,
            //which should also configure all of the oscilloscopes.
            var scopeManager = ScopeManager.GetInstance();

            //Stop streaming on all scopes
            foreach (PicoScope s in scopeManager.Scopes)
            {
                s.ShutdownOscilloscope();
            }

            //Close all file streams from the booth save manager
            BoothSaveManager b = BoothSaveManager.GetInstance();

            b.CloseAllStreams();
        }
Пример #2
0
        /// <summary>
        /// Returns the singleton instance of the scope manager
        /// </summary>
        /// <returns>ScopeManager object</returns>
        public static ScopeManager GetInstance()
        {
            if (_instance == null)
            {
                lock (syncRoot)
                {
                    if (_instance == null)
                    {
                        _instance = new ScopeManager();
                    }
                }
            }

            return(_instance);
        }
Пример #3
0
        /// <summary>
        /// Constructs a new booth view-model object
        /// </summary>
        public BoothViewModel(PicoScope s)
        {
            _scope = s;
            _scope.PropertyChanged += _scope_PropertyChanged;

            //Create a plot model for this booth and give it a set of axes.
            BoothPlotModel = new PlotModel {
                Title = "VNS Traces"
            };
            LinearAxis y_axis = new LinearAxis();

            y_axis.Minimum  = ScopeManager.GetInstance().PlotYLimit_Min;
            y_axis.Maximum  = ScopeManager.GetInstance().PlotYLimit_Max;
            y_axis.Position = AxisPosition.Left;
            BoothPlotModel.Axes.Add(y_axis);
        }
Пример #4
0
        public MainWindow()
        {
            InitializeComponent();

            //Get an instance of the scope manager.  This should also create the first instance,
            //which should also configure all of the oscilloscopes.
            var scopeManager = ScopeManager.GetInstance();

            //Start streaming on all scopes
            foreach (PicoScope s in scopeManager.Scopes)
            {
                //Create a view model for the booth/scope
                BoothViewModel vm = new BoothViewModel(s);

                //Add the booth/scope to the items control of this window
                BoothList.Items.Add(vm);
            }
        }
Пример #5
0
        public void Stop()
        {
            //Get the scope manager
            var scopeManager = ScopeManager.GetInstance();

            //Get the user's desired us/sample
            uint desired_us_per_sample = Convert.ToUInt32(this._scope.NanosecondsPerSample / 1000.0d);

            //For streaming mode, simply set the actual us/sample equal to the desired us/sample
            uint actual_us_per_sample = desired_us_per_sample;

            //Display peak voltage data to the user
            DisplayPeakVoltageData(_trials);

            //Save data
            try
            {
                Messages = Messages + "Saving data to primary path...";
                SaveScopeData.SaveData(scopeManager.PrimaryDataPath, this.RatName, _scope.BoothName, _scope.SerialCode, "A", _trials, actual_us_per_sample);
                Messages = Messages + "done\n";
            }
            catch
            {
                Messages = Messages + "\n";
                Messages = Messages + "Error while trying to save to primary data path!!!";
            }

            try
            {
                Messages = Messages + "Saving data to secondary path...";
                SaveScopeData.SaveData(scopeManager.SecondaryDataPath, this.RatName, _scope.BoothName, _scope.SerialCode, "A", _trials, actual_us_per_sample);
                Messages = Messages + "done\n";
            }
            catch
            {
                Messages = Messages + "\n";
                Messages = Messages + "Error while trying to save to primary data path!!!";
            }

            //Stop streaming from the scope (this function call may be uneccessary, i'm not sure)
            _scope.StopSession();
        }
Пример #6
0
        protected override void OnStartup(StartupEventArgs e)
        {
            if (!createdNew)
            {
                return;
            }
            else
            {
                //Start up the scope manager, connect to each scope, and load the configuration file
                var s_manager = ScopeManager.GetInstance();

                //Iterate over each scope and start a background thread for each
                foreach (var s in s_manager.Scopes)
                {
                    s.StartBackgroundWorker();
                }

                //Create the main window
                var mw = new ScopeVNS.MainWindow();
                mw.Show();
            }
        }
Пример #7
0
        public List <StreamWriter> CreateStreamWriter(int booth_number)
        {
            //Set the "last save" timestamp for this booth number, so that we don't accidentally try to create
            //a stream for the same file again
            LastSaveForEachBooth[booth_number] = DateTime.Now;

            //Get the parts of the file name
            var    scopeManager        = ScopeManager.GetInstance();
            string primary_base_path   = scopeManager.PrimaryDataPath;
            string secondary_base_path = scopeManager.SecondaryDataPath;
            string group_id            = scopeManager.GroupID;

            DateTime now        = DateTime.Now;
            string   date_today = now.ToString("_yyyy_MM_dd");

            string booth_file_name = "Booth" + booth_number.ToString() + date_today;

            //Make the full file path for each save location
            string full_primary_path   = primary_base_path;
            string full_secondary_path = secondary_base_path;

            if (!string.IsNullOrEmpty(group_id))
            {
                full_primary_path   += group_id + @"\";
                full_secondary_path += group_id + @"\";
            }

            full_primary_path   += booth_number.ToString() + @"\" + booth_file_name;
            full_secondary_path += booth_number.ToString() + @"\" + booth_file_name;

            List <StreamWriter> result = new List <StreamWriter>();

            if (!string.IsNullOrEmpty(primary_base_path))
            {
                //Create directory if it doesn't exist
                new FileInfo(full_primary_path).Directory.Create();

                try
                {
                    StreamWriter p = new StreamWriter(full_primary_path, true);
                    result.Add(p);
                }
                catch
                {
                    //empty
                }
            }
            if (!string.IsNullOrEmpty(secondary_base_path))
            {
                //Create directory if it doesn't exist
                new FileInfo(full_secondary_path).Directory.Create();

                try
                {
                    StreamWriter s = new StreamWriter(full_secondary_path, true);
                    result.Add(s);
                }
                catch
                {
                    //empty
                }
            }

            return(result);
        }