Beispiel #1
0
 public Receiver(FormMain mainForm)
 {
     InitializeComponent();
     this.mainForm = mainForm;
 }
Beispiel #2
0
        public void burnPic(FormMain mainForm, string fileName)
        {
            //Hex laden
            // StreamReader-Instanz für die Datei erzeugen
            StreamReader sr = null;

            try
            {
                sr = new StreamReader(fileName, Encoding.GetEncoding("windows-1252"));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                Log.write(mainForm, ex.ToString(), 1);
                return;
            }

            // Datei zeilenweise einlesen

            ArrayList hexFile = new ArrayList();
            string    line    = null;

            while ((line = sr.ReadLine()) != null)
            {
                hexFile.Add(line);
            }

            Log.write(mainForm, ("Read File: " + fileName), 0);
            Log.write(mainForm, ("Lines: " + hexFile.Count.ToString()), 1);


            // Progressbar einblenden und Cursor auf wait setzen
            mainForm.toolStripProgressBar.Visible = true;
            Cursor.Current = Cursors.WaitCursor;

            // Brennen in PIC
            // wenn noch keine Verbindung besteht automatisch öffnen
            if (!sp.IsOpen)
            {
                connect(mainForm);
            }


            Log.write(mainForm, Properties.Settings.Default.comPort, 1);


            int    i = 1;
            string temp;

            sp.WriteLine("B");
            temp = sp.ReadLine();
            Log.write(mainForm, temp, 1);
            mainForm.toolStripProgressBar.Maximum = Convert.ToInt16(hexFile.Count);

            try
            {
                foreach (string zeile in hexFile)
                {
                    Log.write(mainForm, zeile, 1);
                    // Progressbar hochzählen
                    mainForm.toolStripProgressBar.Increment(1);
                    // Infotext in status schreiben
                    mainForm.infoleisteToolStripStatusLabel.Text = labels.GetString("writeLine") +
                                                                   " " + i.ToString() + " " + labels.GetString("writeMax") + " " + Convert.ToInt16(hexFile.Count) + "  ";
                    // Infotext in Log schreiben
                    Log.write(mainForm, ("Line: " + i.ToString() + ": " + zeile), 0);
                    Application.DoEvents();
                    i++;

                    // zeile senden
                    sp.WriteLine(zeile);
                    for (int j = 1; j < 4; j++)
                    {
                        // etwas warten bis der PIC die Daten verarbeitet hat und bei jedem Versuch länger!
                        Thread.Sleep(Properties.Settings.Default.writeSleep * j * j);
                        temp = sp.ReadLine();
                        Log.write(mainForm, temp, 1);
                        if (temp == "ERR\r")
                        {
                            // zeile senden
                            sp.WriteLine(zeile);
                            Log.write(mainForm, ("Try: " + (j).ToString() + " " + zeile), 1);
                        }
                        else
                        {
                            break;
                        }
                    }
                    if (temp == "ERR\r")
                    {
                        MessageBox.Show(errorLabels.GetString("flashError"));
                        break;
                    }
                    // log schreiben wenn debuglevel
                    Log.write(mainForm, temp, 1);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                Log.write(mainForm, e.ToString(), 1);
            }

            // Info um Board neu zu starten
            MessageBox.Show(labels.GetString("flashInfo"));

            // Progressbar ausblenden und Cursor auf default setzen
            mainForm.toolStripProgressBar.Value   = 0;
            mainForm.toolStripProgressBar.Visible = false;
            mainForm.toolStripProgressBar.Maximum = 100;
            Cursor.Current = Cursors.Default;
        }
Beispiel #3
0
        /// <summary>
        /// allgemeine Funktion die von jedem Steuerelement aufgerufen werden kann
        /// </summary>
        /// <param name="mainForm"></param>
        static public void info(FormMain mainForm)
        {
// RollAchse Hilfe
            // Setting 1
            if (mainForm.rollProp1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Proportional");
            }
            if (mainForm.rollDiff1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Differenzial");
            }
            if (mainForm.rollInt1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Integral");
            }
            if (mainForm.rollLimit1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Limiter");
            }
            if (mainForm.rollIntLimit1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("IntegralLimiter");
            }
            if (mainForm.rollMa1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("EbenenAusgleich");
            }
            if (mainForm.rollA1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Neutral");
            }
            //Setting 2
            if (mainForm.rollProp2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Proportional");
            }
            if (mainForm.rollDiff2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Differenzial");
            }
            if (mainForm.rollInt2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Integral");
            }
            if (mainForm.rollLimit2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Limiter");
            }
            if (mainForm.rollIntLimit2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("IntegralLimiter");
            }
            if (mainForm.rollMa2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("EbenenAusgleich");
            }
            if (mainForm.rollA2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Neutral");
            }
// NickAchse Hilfe
            // Setting 1
            if (mainForm.nickProp1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Proportional");
            }
            if (mainForm.nickDiff1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Differenzial");
            }
            if (mainForm.nickInt1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Integral");
            }
            if (mainForm.nickLimit1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Limiter");
            }
            if (mainForm.nickIntLimit1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("IntegralLimiter");
            }
            if (mainForm.nickMa1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("EbenenAusgleich");
            }
            if (mainForm.nickA1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Neutral");
            }
            // Setting 2
            if (mainForm.nickProp2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Proportional");
            }
            if (mainForm.nickDiff2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Differenzial");
            }
            if (mainForm.nickInt2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Integral");
            }
            if (mainForm.nickLimit2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Limiter");
            }
            if (mainForm.nickIntLimit2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("IntegralLimiter");
            }
            if (mainForm.nickMa2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("EbenenAusgleich");
            }
            if (mainForm.nickA2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Neutral");
            }
// GierAchse Hilfe
            // Setting 1
            if (mainForm.gierProp1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Proportional");
            }
            if (mainForm.gierDiff1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Differenzial");
            }
            if (mainForm.gierInt1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Integral");
            }
            if (mainForm.gierLimit1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Limiter");
            }
            if (mainForm.gierIntLimit1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("IntegralLimiter");
            }
            if (mainForm.gierMa1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("EbenenAusgleich");
            }
            if (mainForm.gierA1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Neutral");
            }
            // Setting 2
            if (mainForm.gierProp2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Proportional");
            }
            if (mainForm.gierDiff2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Differenzial");
            }
            if (mainForm.gierInt2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Integral");
            }
            if (mainForm.gierLimit2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Limiter");
            }
            if (mainForm.gierIntLimit2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("IntegralLimiter");
            }
            if (mainForm.gierMa2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("EbenenAusgleich");
            }
            if (mainForm.gierA2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Neutral");
            }
// Sonstiges
            // Setting 1
            if (mainForm.bit01CheckBox.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("X+Modus");
            }
            if (mainForm.bit11CheckBox.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Gas-Kanal");
            }
            if (mainForm.bit21CheckBox.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Integrierzustand");
            }
            if (mainForm.bit31CheckBox.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("HalbRollNick");
            }
            if (mainForm.bit41CheckBox.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("EmpfängerImpulse");
            }
            if (mainForm.impulseAusgabe1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Impuls");
            }
            if (mainForm.leerlaufgas1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Leerlaufgas");
            }
            if (mainForm.kamera1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Kameraausgleich");
            }
            if (mainForm.compass1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Kompass");
            }
            if (mainForm.akku1NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Unterspannung");
            }
            // Setting 2
            if (mainForm.bit02CheckBox.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("X+Modus");
            }
            if (mainForm.bit12CheckBox.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Gas-Kanal");
            }
            if (mainForm.bit22CheckBox.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Integrierzustand");
            }
            if (mainForm.bit32CheckBox.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("HalbRollNick");
            }
            if (mainForm.bit42CheckBox.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("EmpfängerImpulse");
            }
            if (mainForm.impulseAusgabe2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Impuls");
            }
            if (mainForm.leerlaufgas2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Leerlaufgas");
            }
            if (mainForm.kamera2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Kameraausgleich");
            }
            if (mainForm.compass2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Kompass");
            }
            if (mainForm.akku2NumericUpDown.Focused)
            {
                mainForm.infoTextBox.Text = mainForm.help.GetString("Unterspannung");
            }
            //mainForm.rollProp1NumericUpDown.ForeColor = farbeElement;
            //mainForm.rollInt1NumericUpDown.ForeColor = farbeElement;
            //mainForm.rollDiff1NumericUpDown.ForeColor = farbeElement;
            //mainForm.rollLimit1NumericUpDown.ForeColor = farbeElement;
            //mainForm.rollIntLimit1NumericUpDown.ForeColor = farbeElement;
            //mainForm.nickProp1NumericUpDown.ForeColor = farbeElement;
            //mainForm.nickInt1NumericUpDown.ForeColor = farbeElement;
            //mainForm.nickDiff1NumericUpDown.ForeColor = farbeElement;
            //mainForm.nickLimit1NumericUpDown.ForeColor = farbeElement;
            //mainForm.nickIntLimit1NumericUpDown.ForeColor = farbeElement;
            //mainForm.gierProp1NumericUpDown.ForeColor = farbeElement;
            //mainForm.gierInt1NumericUpDown.ForeColor = farbeElement;
            //mainForm.gierDiff1NumericUpDown.ForeColor = farbeElement;
            //mainForm.gierLimit1NumericUpDown.ForeColor = farbeElement;
            //mainForm.gierIntLimit1NumericUpDown.ForeColor = farbeElement;
            //mainForm.bit01CheckBox.ForeColor = farbeElement;
            //mainForm.bit11CheckBox.ForeColor = farbeElement;
            //mainForm.bit21CheckBox.ForeColor = farbeElement;
            //mainForm.bit31CheckBox.ForeColor = farbeElement;
            //mainForm.bit41CheckBox.ForeColor = farbeElement;
            //mainForm.impulseAusgabe1NumericUpDown.ForeColor = farbeElement;
            //mainForm.akku1NumericUpDown.ForeColor = farbeElement;
            //mainForm.rollMa1NumericUpDown.ForeColor = farbeElement;
            //mainForm.nickMa1NumericUpDown.ForeColor = farbeElement;
            //mainForm.gierMa1NumericUpDown.ForeColor = farbeElement;
            //mainForm.gierA1NumericUpDown.ForeColor = farbeElement;
            //mainForm.leerlaufgas1NumericUpDown.ForeColor = farbeElement;
            //mainForm.rollA1NumericUpDown.ForeColor = farbeElement;
            //mainForm.nickA1NumericUpDown.ForeColor = farbeElement;
            //mainForm.kamera1NumericUpDown.ForeColor = farbeElement;

            //mainForm.rollProp2NumericUpDown.ForeColor = farbeElement;
            //mainForm.rollInt2NumericUpDown.ForeColor = farbeElement;
            //mainForm.rollDiff2NumericUpDown.ForeColor = farbeElement;
            //mainForm.rollLimit2NumericUpDown.ForeColor = farbeElement;
            //mainForm.rollIntLimit2NumericUpDown.ForeColor = farbeElement;
            //mainForm.nickProp2NumericUpDown.ForeColor = farbeElement;
            //mainForm.nickInt2NumericUpDown.ForeColor = farbeElement;
            //mainForm.nickDiff2NumericUpDown.ForeColor = farbeElement;
            //mainForm.nickLimit2NumericUpDown.ForeColor = farbeElement;
            //mainForm.nickIntLimit2NumericUpDown.ForeColor = farbeElement;
            //mainForm.gierProp2NumericUpDown.ForeColor = farbeElement;
            //mainForm.gierInt2NumericUpDown.ForeColor = farbeElement;
            //mainForm.gierDiff2NumericUpDown.ForeColor = farbeElement;
            //mainForm.gierLimit2NumericUpDown.ForeColor = farbeElement;
            //mainForm.gierIntLimit2NumericUpDown.ForeColor = farbeElement;
            //mainForm.bit02CheckBox.ForeColor = farbeElement;
            //mainForm.bit12CheckBox.ForeColor = farbeElement;
            //mainForm.bit22CheckBox.ForeColor = farbeElement;
            //mainForm.bit32CheckBox.ForeColor = farbeElement;
            //mainForm.bit42CheckBox.ForeColor = farbeElement;
            //mainForm.impulseAusgabe2NumericUpDown.ForeColor = farbeElement;
            //mainForm.akku2NumericUpDown.ForeColor = farbeElement;
            //mainForm.rollMa2NumericUpDown.ForeColor = farbeElement;
            //mainForm.nickMa2NumericUpDown.ForeColor = farbeElement;
            //mainForm.gierMa2NumericUpDown.ForeColor = farbeElement;
            //mainForm.gierA2NumericUpDown.ForeColor = farbeElement;
            //mainForm.leerlaufgas2NumericUpDown.ForeColor = farbeElement;
            //mainForm.rollA2NumericUpDown.ForeColor = farbeElement;
            //mainForm.nickA2NumericUpDown.ForeColor = farbeElement;
            //mainForm.kamera2NumericUpDown.ForeColor = farbeElement;
        }
Beispiel #4
0
        /// <summary>
        /// lesen der Parameter
        /// </summary>
        /// <param name="mainForm"></param>
        /// <param name="parameter"></param>
        public void readParameters(FormMain mainForm, ParameterSets parameter)
        {
            // Cursor auf wait setzen
            Cursor.Current = Cursors.WaitCursor;


            // Abfrage der Prameter mit L und speichern in array
            ArrayList para = askPic(mainForm, "L");

            // wenn Loglevel auf debug - deshalb mit if damit foreach nicht so oft aufgerufen wird
            if (Properties.Settings.Default.logLevel > 0)
            {
                foreach (string output in para)
                {
                    Log.write(mainForm, output, 1);
                }
            }
            // standardausgabe
            else
            {
                Log.write(mainForm, para[1].ToString(), 0);
            }

            // springen auf richtiges TAB
            mainForm.tabControlParameter.SelectedIndex = Convert.ToInt16(para[1].ToString().Substring(24, 1)) - 1;

            // markieren des TABS
            if (mainForm.tabControlParameter.SelectedIndex == 0)
            {
                mainForm.tabPageParameterSet1.Text = labels.GetString("paraSetAktiv1");
                mainForm.tabPageParameterSet2.Text = labels.GetString("paraSet2");
            }
            else
            {
                mainForm.tabPageParameterSet1.Text = labels.GetString("paraSet1");
                mainForm.tabPageParameterSet2.Text = labels.GetString("paraSetAktiv2");
            }

            // wenn tab Parameter Set 1 gelesen wird
            if (mainForm.tabControlParameter.SelectedIndex == 0)
            {
                //TODO: hier die Schleife erweitern wenn neuer Parameter hinzukommt
                // durchgehen des arrays und in Prameter Struc speichern
                for (int i = 0; i < para.Count - 2; i++)
                {
                    // + in den Parametern ausschneiden
                    if (para[i + 2].ToString().Substring(15, 1) == "+")
                    {
                        para[i + 2] = Convert.ToInt16(para[i + 2].ToString().Substring(16, 3));
                        parameter.parameterPic1[i].Command = "Register " + (i + 1).ToString();
                        parameter.parameterPic1[i].Value   = para[i + 2].ToString();
                    }
                    else
                    {
                        para[i + 2] = Convert.ToInt16(para[i + 2].ToString().Substring(15, 4));
                        parameter.parameterPic1[i].Command = "Register " + (i + 1).ToString();
                        parameter.parameterPic1[i].Value   = para[i + 2].ToString();
                    }
                }
                // ganzes Form mit den Daten updaten
                parameter.updateForm(parameter.parameterPic1, mainForm, ParameterSets.Farbe.green);
            }
            // gleiches wenn Parameter Set 2 gelesen wird
            else
            {
                //TODO: Auch hier die Schleife erweitern wenn Parameter hinzukommt
                // durchgehen des arrays und in Prameter Struc speichern
                for (int i = 0; i < para.Count - 2; i++)
                {
                    // + in den Parametern ausschneiden
                    if (para[i + 2].ToString().Substring(15, 1) == "+")
                    {
                        para[i + 2] = Convert.ToInt16(para[i + 2].ToString().Substring(16, 3));
                        parameter.parameterPic2[i].Command = "Register " + (i + 1).ToString();
                        parameter.parameterPic2[i].Value   = para[i + 2].ToString();
                    }
                    else
                    {
                        para[i + 2] = Convert.ToInt16(para[i + 2].ToString().Substring(15, 4));
                        parameter.parameterPic2[i].Command = "Register " + (i + 1).ToString();
                        parameter.parameterPic2[i].Value   = para[i + 2].ToString();
                    }
                }
                // ganzes Form mit den Daten updaten
                parameter.updateForm(parameter.parameterPic2, mainForm, ParameterSets.Farbe.green);

                // Cursor auf default setzen
                Cursor.Current = Cursors.Default;
            }
        }