Beispiel #1
0
 public ParameterSets.ParameterSetsStruc[] GetChapter(string chapter)
 {
     ParameterSets.ParameterSetsStruc[] rueckgabe = new ParameterSets.ParameterSetsStruc[0];
     foreach (inidatei i in inizeilen)
     {
         if (i.abschnitt == chapter)
         {
             Array.Resize(ref rueckgabe, rueckgabe.Length + 1);
             rueckgabe[rueckgabe.Length - 1].Chapter = chapter;
             rueckgabe[rueckgabe.Length - 1].Command = i.befehl;
             rueckgabe[rueckgabe.Length - 1].Comment = i.kommentar;
             rueckgabe[rueckgabe.Length - 1].Value   = i.wert;
         }
     }
     return(rueckgabe);
 }
Beispiel #2
0
        //Verwenden der ParameterSets.Struc
        //public struct Return
        //{
        //    public string Command;
        //    public string Value;
        //    public string Comment;
        //    public string Chapter;
        //}

        public ParameterSets.ParameterSetsStruc Get(string befehl)
        {
            ParameterSets.ParameterSetsStruc rueckgabe = new ParameterSets.ParameterSetsStruc();
            rueckgabe.Command = befehl;
            rueckgabe.Value   = "";
            rueckgabe.Comment = "";
            foreach (inidatei i in inizeilen)
            {
                if (i.befehl == befehl)
                {
                    rueckgabe.Value   = i.wert;
                    rueckgabe.Comment = i.kommentar;
                    rueckgabe.Chapter = i.abschnitt;
                }
            }
            return(rueckgabe);
        }
Beispiel #3
0
        /// <summary>
        /// SChreiben der Parameter für Funktion writeParameter
        /// </summary>
        /// <param name="mainForm"></param>
        /// <param name="value"></param>
        private bool parameterWrite(FormMain mainForm, ParameterSets.ParameterSetsStruc value)
        {
            mainForm.Cursor = Cursors.WaitCursor;
            try
            {
                string temp;
                //sp.Write("M");
                // nur ein Write hatte nicht zuverlässig funktioniert
                // für ein write müsste das readline durch read ersetzt und anders ausgewertet werden
                sp.WriteLine("M");
                // log über sendekey
                if (Properties.Settings.Default.logLevel > 0)
                {
                    Log.write(mainForm, "send: \"M\" for Parameter: " +
                              Convert.ToInt16(value.Command.Substring(9)).ToString("00"), 1);
                }
                temp = sp.ReadLine();


                // alle inputs durchgehen
                //while (temp != ">M\r")
                // hier auf Parameter warten - es ist sonst immer zu einem timeout gekommen
                while (temp != "Register ")
                {
                    temp = sp.ReadLine();
                    // log schreiben wenn debuglevel
                    if (Properties.Settings.Default.logLevel > 0)
                    {
                        Log.write(mainForm, temp + "first write M", 1);
                    }
                }
                ////Hier der Code für ein write
                ////sp.WriteLine(Convert.ToInt16(value.Command.Substring(9)).ToString("00"));
                ////temp = sp.ReadLine();
                ////while (temp != (Convert.ToInt16(value.Command.Substring(9)).ToString("00") + " = "))
                ////{
                ////    temp = sp.ReadLine();
                ////    // log schreiben wenn debuglevel
                ////    if (Properties.Settings.Default.logLevel > 0)
                ////    {
                ////        Log.write(mainForm, temp, 1);
                ////    }
                ////}
                ////sp.WriteLine(Convert.ToInt16(value.Value).ToString("00"));
                // schreiben auf einmal
                sp.Write(Convert.ToInt16(value.Command.Substring(9)).ToString("00"));
                sp.Write(Convert.ToInt16(value.Value).ToString("00"));
                temp = sp.ReadLine();
                if (temp != Convert.ToInt16(value.Command.Substring(9)).ToString("00") +
                    " = " + Convert.ToInt16(value.Value).ToString("00") + "\r")
                {
                    throw (new Exception());
                }
                ////Hier der Code für ein write
                ////while (temp != ">")
                ////{
                ////    temp = sp.ReadLine();
                ////    // log schreiben wenn debuglevel
                ////    if (Properties.Settings.Default.logLevel > 0)
                ////    {
                ////        Log.write(mainForm, temp, 1);
                ////    }
                ////}
                // log über sendekey
                Log.write(mainForm, (labels.GetString("writeParameter") +
                                     Convert.ToInt16(value.Command.Substring(9)).ToString("00") + " = " +
                                     Convert.ToInt16(value.Value).ToString("00")), 0);

                // Progressbar hochzählen
                mainForm.toolStripProgressBar.Increment(4);
                // Infotext in status schreiben
                mainForm.infoleisteToolStripStatusLabel.Text = labels.GetString("writeParameter") + Convert.ToInt16(value.Command.Substring(9)).ToString("00") + " = " + Convert.ToInt16(value.Value).ToString("00");
                Application.DoEvents();
                mainForm.Cursor = Cursors.Default;
                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(errorLabels.GetString("askPic"), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log.write(mainForm, e.ToString() + "\r\nTest Return from Pic", 1);
                mainForm.Cursor = Cursors.Default;
                return(false);
            }
        }
Beispiel #4
0
        private bool parameterWrite(FormMain mainForm, ParameterSets.ParameterSetsStruc value)
        {
            mainForm.Cursor = Cursors.WaitCursor;
            try
            {
                string temp;

                sp.WriteLine("M");
                if (Properties.Settings.Default.logLevel > 0)
                {
                    Log.write(mainForm, "send: \"M\" for Parameter: " +
                              Convert.ToInt16(value.Command.Substring(9)).ToString("00"), 1);
                }

                Thread.Sleep(Properties.Settings.Default.iReadSleep);
                temp = sp.ReadLine();

                while (temp != "Register ")
                {
                    Thread.Sleep(Properties.Settings.Default.iReadSleep);
                    temp = sp.ReadLine();
                    if (Properties.Settings.Default.logLevel > 0)
                    {
                        Log.write(mainForm, temp + "first write M", 1);
                    }
                }

                Thread.Sleep(10);

                if (Properties.Settings.Default.logLevel > 0)
                {
                    Log.write(mainForm, value.Command.Substring(9).ToString() + " = " +
                              value.Value, 1);
                }

                sp.Write(Convert.ToInt16(value.Command.Substring(9)).ToString("00"));

                Thread.Sleep(10);

                if (Properties.Settings.Default.logLevel > 0)
                {
                    Log.write(mainForm, "Write: " + Convert.ToInt16(value.Command.Substring(9)).ToString("00").ToString(), 1);
                }

                sp.Write(Convert.ToInt16(value.Value).ToString("000"));//zzz


                if (Properties.Settings.Default.logLevel > 0)
                {
                    Log.write(mainForm, "Write: " + Convert.ToInt16(value.Value).ToString("00").ToString(), 1);
                }

                Thread.Sleep(Properties.Settings.Default.iReadSleep);
                Thread.Sleep(10);

                temp = sp.ReadLine();

                if (temp != Convert.ToInt16(value.Command.Substring(9)).ToString("00") +
                    " = " + Convert.ToInt16(value.Value).ToString("000") + "\r") //zzz
                {
                    throw (new Exception());
                }

                Log.write(mainForm, (labels.GetString("writeParameter") +
                                     Convert.ToInt16(value.Command.Substring(9)).ToString("00") + " = " +
                                     Convert.ToInt16(value.Value).ToString("000")), 0); // zzz now 3 digits but still int8

                mainForm.toolStripProgressBar.Increment(2);
                mainForm.infoleisteToolStripStatusLabel.Text = labels.GetString("writeParameter") + Convert.ToInt16(value.Command.Substring(9)).ToString("00") + " = " + Convert.ToInt16(value.Value).ToString("000"); // zzz
                Application.DoEvents();
                mainForm.Cursor = Cursors.Default;
                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(errorLabels.GetString("askPic"), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log.write(mainForm, e.ToString() + "\r\nTest Return from PIC", 1);
                mainForm.Cursor = Cursors.Default;
                return(false);
            }
        }