Exemplo n.º 1
0
 private void connectButton_Click(object sender, EventArgs e)
 {
     picConnect.connect(mainForm, true, false);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Ausgabe der debugkurve
        /// </summary>
        /// <param name="pic">bei True --> PIC bei False --> File</param>
        private void debugAusgabe(bool pic)
        {
            // für Ausgabe
            graph1 = dia1Panel.CreateGraphics();
            graph2 = dia2Panel.CreateGraphics();
            graph3 = dia3Panel.CreateGraphics();


            werte = new ArrayList();

            string temp = "";



            int[] mapping =
            {
                Properties.Settings.Default.map1 - 1,
                Properties.Settings.Default.map2 - 1,
                Properties.Settings.Default.map3 - 1,
                Properties.Settings.Default.map4 - 1,
                Properties.Settings.Default.map5 - 1,
                Properties.Settings.Default.map6 - 1,
                Properties.Settings.Default.map7 - 1,
                Properties.Settings.Default.map8 - 1,
                Properties.Settings.Default.map9 - 1
            };

            int[] divisor =
            {
                Properties.Settings.Default.div1,
                Properties.Settings.Default.div2,
                Properties.Settings.Default.div3,
                Properties.Settings.Default.div4,
                Properties.Settings.Default.div5,
                Properties.Settings.Default.div6,
                Properties.Settings.Default.div7,
                Properties.Settings.Default.div8,
                Properties.Settings.Default.div9
            };

            int[] offset =
            {
                Properties.Settings.Default.off1,
                Properties.Settings.Default.off2,
                Properties.Settings.Default.off3,
                Properties.Settings.Default.off4,
                Properties.Settings.Default.off5,
                Properties.Settings.Default.off6,
                Properties.Settings.Default.off7,
                Properties.Settings.Default.off8,
                Properties.Settings.Default.off9
            };

            int[] basis =
            {
                Properties.Settings.Default.bas1,
                Properties.Settings.Default.bas2,
                Properties.Settings.Default.bas3,
                Properties.Settings.Default.bas4,
                Properties.Settings.Default.bas5,
                Properties.Settings.Default.bas6,
                Properties.Settings.Default.bas7,
                Properties.Settings.Default.bas8,
                Properties.Settings.Default.bas9
            };

            //int[] divisor = {
            //                        div[mapping[0]],
            //                        div[mapping[1]],
            //                        div[mapping[2]],
            //                        div[mapping[3]],
            //                        div[mapping[4]],
            //                        div[mapping[5]],
            //                        div[mapping[6]],
            //                        div[mapping[7]],
            //                        div[mapping[8]]
            //                    };

            //int[] offset = {
            //                        off[mapping[0]],
            //                        off[mapping[1]],
            //                        off[mapping[2]],
            //                        off[mapping[3]],
            //                        off[mapping[4]],
            //                        off[mapping[5]],
            //                        off[mapping[6]],
            //                        off[mapping[7]],
            //                        off[mapping[8]]
            //                    };

            //int[] basis = {
            //                        bas[mapping[0]],
            //                        bas[mapping[1]],
            //                        bas[mapping[2]],
            //                        bas[mapping[3]],
            //                        bas[mapping[4]],
            //                        bas[mapping[5]],
            //                        bas[mapping[6]],
            //                        bas[mapping[7]],
            //                        bas[mapping[8]]
            //                    };


            // DebugWerte lesen

            if (pic == true)
            {
                picConnect.connect(mainForm, true, false);

                while (run == true)
                {
                    try
                    {
                        temp = picConnect.sp.ReadLine();
                    }
                    catch
                    {
                        Application.DoEvents();
                        continue;
                    }
                    drawGraph(temp, last, aktuell, mapping, divisor, offset, basis, pic);
                }
                run = true;
                // StreamReader schließen
                try
                {
                    picConnect.sp.Close();
                }
                catch {
                }
            }
            else
            {
                // StreamReader-Instanz für die Datei erzeugen
                StreamReader sr = null;

                DialogResult result = openFileDialog1.ShowDialog();
                if (result == DialogResult.OK)
                {
                    string fileName = openFileDialog1.FileName;
                    try
                    {
                        sr = new StreamReader(fileName, Encoding.GetEncoding("windows-1252"));
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Fehler beim Öffnen der Datei '" + fileName + "': " +
                                        ex.Message, Application.ProductName, MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                        return;
                    }
                    // Datei zeilenweise einlesen
                    while ((temp = sr.ReadLine()) != null && run == true)
                    {
                        drawGraph(temp, last, aktuell, mapping, divisor, offset, basis, pic);
                        System.Threading.Thread.Sleep(10);
                    }

                    run = true;
                    // StreamReader schließen
                    sr.Close();
                }
            }
        }