Пример #1
0
        private void ButtonRecipe_Click(object sender, EventArgs e)
        {
            // use Btn sender to parse through control lists
            string txt = ((Button)sender).Name;
            int    index;

            if (txt.Length == 8)
            {
                index = int.Parse(txt.Substring(txt.Length - 1)) - 1;
            }
            else
            {
                index = int.Parse(txt.Substring(txt.Length - 2)) - 1;
            }

            var form = new RecipeEditor <CCRecipe>(BQConn, new CCRecipe(), _samples[index].Text);

            form.ShowDialog();
            _ccRecipe = form.CurrentRecipe;

            if (_ccRecipe.SampleName != null)
            {
                Properties.Settings.Default.Samples[index] = _ccRecipe.SampleName;
                Properties.Settings.Default.Save();
                _samples[index].Text     = _ccRecipe.SampleName;
                _cycleLabels[index].Text = _ccRecipe.CycleNumber.ToString();
                _numCells[index].Text    = _ccRecipe.NumCells.ToString();
                _voc[index].Text         = _ccRecipe.CellVoc.ToString();
                _tempSensors[index].Text = _ccRecipe.TempSensor.ToString();
                _setCurrents[index].Text = _ccRecipe.SetCurrent.ToString();
            }
        }
Пример #2
0
        /// <summary>
        /// Updates comboBox with newest Samples and starts the InitializeTable function
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UpdateData(object sender, ProgressChangedEventArgs e)
        {
            comboBoxSelect.Items.Clear();
            _loading = true;
            comboBoxSelect.Items.Add("Select a Recipe to Update or Load");
            comboBoxSelect.Items.Add("Create new recipe");
            comboBoxSelect.SelectedIndex = 0;
            if (_recipeList == null || _recipeList.Count == 0)
            {
                InitializeTable(false);
                return;
            }
            var index = 1;

            foreach (var r in _recipeList)
            {
                comboBoxSelect.Items.Add(r);
                index++;
                if (r == _selectedSample)
                {
                    //CurrentRecipe = _conn.GetCurrentRecipe(_selectedSample);
                    CurrentRecipe = _conn.GetCurrentRecipeCSV(_selectedSample);
                    comboBoxSelect.SelectedIndex = index;
                }
            }


            _loading = false;
            InitializeTable(false);
        }
Пример #3
0
        public RecipeEditor(Data conn, CCRecipe recipe, string sample)
        {
            InitializeComponent();
            _recipeList         = new List <string>();
            _selectedSample     = sample;
            _conn               = conn;
            CurrentRecipe       = recipe;
            _dataWorker.DoWork += RunDataWorker;
            _dataWorker.WorkerReportsProgress = true;
            _dataWorker.ProgressChanged      += UpdateData;

            Shown += UpdateUi;
        }
Пример #4
0
        private void comboBoxSelect_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_loading || comboBoxSelect.SelectedIndex <= 0)
            {
                return;
            }

            // creates new default recipe and lets user write to it
            if (comboBoxSelect.SelectedIndex == 1)
            {
                CurrentRecipe = new CCRecipe();
                InitializeTable(false);
            }
            // select recipe already there
            else
            {
                _selectedSample = comboBoxSelect.SelectedItem.ToString();
                CurrentRecipe   = _conn.GetCurrentRecipe(_selectedSample);
                InitializeTable(true);
            }
        }
Пример #5
0
        private void ButtonRecipe_Click(object sender, EventArgs e)
        {
            // use Btn sender to parse through control lists
            string txt = ((Button)sender).Name;
            int    index;

            if (txt.Length == 8)
            {
                index = int.Parse(txt.Substring(txt.Length - 1)) - 1;
            }
            else
            {
                index = int.Parse(txt.Substring(txt.Length - 2)) - 1;
            }

            var form = new RecipeEditor <CCRecipe>(BQConn, new CCRecipe(), _samples[index].Text);

            form.ShowDialog();
            _ccRecipe = form.CurrentRecipe;

            // set CurrentRecipe values to port GUI values
            if (_ccRecipe.SampleName != null)
            {
                Properties.Settings.Default.Samples[index] = _ccRecipe.SampleName;
                Properties.Settings.Default.Save();
                _samples[index].Text     = _ccRecipe.SampleName;
                _cycleLabels[index].Text = _ccRecipe.CycleNumber.ToString();
                _numCells[index].Text    = _ccRecipe.NumCells.ToString();
                _voc[index].Text         = _ccRecipe.CellVoc.ToString();
                _tempSensors[index].Text = _ccRecipe.TempSensor.ToString();
                _setCurrents[index].Text = _ccRecipe.SetCurrent.ToString();

                var samplePath = U.CCDataDir + _ccRecipe.SampleName + "\\";
                // if new sample create directory for it to reference later for local recipes
                if (!Directory.Exists(samplePath))
                {
                    Directory.CreateDirectory(samplePath);
                }
            }
        }
Пример #6
0
        public CCRecipe GetCurrentRecipeCSV(string currentSample)
        {
            var recipe = new CCRecipe();
            var line   = new List <string>();

            try {
                var samplePath = U.CCDataDir + currentSample + "\\";
                // if no files in directory then set values to default
                if (Directory.GetFiles(samplePath).Length == 0)
                {
                    recipe = new CCRecipe()
                    {
                        SampleName  = currentSample,
                        NumCells    = 0,
                        CellVoc     = 0,
                        TempSensor  = 0,
                        SetCurrent  = 0,
                        CycleNumber = 0,
                    };
                }
                else
                {
                    (int cycle, string filePath) = GetLastCycleFromSample(currentSample);
                    line   = File.ReadLines(filePath).Last().Split(',').ToList();
                    recipe = new CCRecipe()
                    {
                        SampleName  = line[5],
                        NumCells    = int.Parse(line[8]),
                        CellVoc     = double.Parse(line[9]),
                        TempSensor  = int.Parse(line[10]),
                        SetCurrent  = double.Parse(line[11]),
                        CycleNumber = int.Parse(line[0]),
                    };
                }
            }
            catch (Exception exc) {
                U.Logger.WriteLine(exc.ToString());
            }
            return(recipe);
        }
Пример #7
0
        /// <summary>
        /// Gets recipe parameters from data query and returns them to the Recipe form
        /// </summary>
        /// <param name="currentSample"></param>
        /// <returns></returns>
        public CCRecipe GetCurrentRecipe(string currentSample)
        {
            var recipe = new CCRecipe();

            try {
                var sql = $"SELECT * FROM {_table} WHERE SampleName = \"{currentSample}\" ORDER BY CycleNumber DESC LIMIT 1";

                var results = _client.ExecuteQuery(sql, null);
                var row     = results.FirstOrDefault();
                recipe = new CCRecipe()
                {
                    SampleName  = row["SampleName"].ToString(),
                    NumCells    = int.Parse(row["NumCells"].ToString()),
                    CellVoc     = double.Parse(row["CellVoc_Volts"].ToString()),
                    TempSensor  = int.Parse(row["TempSensorNumber"].ToString()),
                    SetCurrent  = double.Parse(row["SetCurrent_Amps"].ToString()),
                    CycleNumber = int.Parse(row["CycleNumber"].ToString()),
                };
            }
            catch (Exception exc) {
                U.Logger.WriteLine(exc.ToString());
            }
            return(recipe);
        }