Exemplo n.º 1
0
        public int Setup(int serial)
        {
            int setupResult = 0;

            serialNum = serial;
            bool found = tub.Initialize(tub.GetSettingsFromDB(serial));

            if (found)
            {
                setupResult++;
            }
            var runSettings = found && tub.name.Length > 0 ? DBHelper.SearchTable(Settings.Default.SettingsTable, "Moxtek#", tub.name) : null;

            found = runSettings != null;
            if (found)
            {
                GiveSettings(runSettings.Rows[0].ItemArray);
                picTube.Image = tub.productImage;
                setupResult++;
            }
            else
            {
                runTime       = new TimeSpan(0, 0, 0);
                picTube.Image = picTube.ErrorImage;
                tub.status    = Tube.Status.Error;
            }
            ledStatus.Value = true;
            return(setupResult);
        }
Exemplo n.º 2
0
 private void txtSerial_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         int id = 0;
         if (int.TryParse(txtSerial.Text.Split('-')[0], out id))
         {
             var search = tub.GetSettingsFromDB(id);
             if (search != null)
             {
                 var ask = MessageBox.Show($"Is the power supply a { search[1] }?", $"Load { search[10] }?", MessageBoxButtons.YesNo);
                 if (ask == DialogResult.Yes && tub.Initialize(search))
                 {
                     if (lnkLog.Enabled)
                     {
                         lnkLog.Text = $@"K:\Software\Tubes\Saved Data\{ tub.serialNum }\{ Log.timeStamp }.txt";
                     }
                     picTube.Image = tub.productImage;
                     picTube.Show();
                     if (tub.controlType == Tube.ControlType.I2C && !tabControl1.TabPages.Contains(tabI2C))
                     {
                         tabControl1.TabPages.Add(tabI2C);
                     }
                     else if (tabControl1.TabPages.Contains(tabI2C))
                     {
                         tabControl1.TabPages.Remove(tabI2C);
                     }
                 }
                 else
                 {
                     txtSerial.Clear();
                 }
             }
             else
             {
                 txtSerial.Clear();
             }
         }
         else
         {
             txtSerial.Clear();
         }
     }
 }