예제 #1
0
        private void FrameToGUI(Cmd.Commando_Struct Parsed)
        {
            string DecStrParas = "";

            if (listView1.Items.Count > 1000)
            {
                listView1.Items.Clear();
            }

            try
            {
                DialogResult UserResult = new DialogResult();
                if (byte.Parse(toolStripMenuItem2.Text) == Parsed.MessageID && iDToolStripMenuItem.CheckState == CheckState.Checked)
                {
                    if (checkBox1.CheckState == CheckState.Checked)
                    {
                        UserResult = MessageBox.Show("Eingestellte \"ID\" empfangen!\r\nZyklisch senden beenden?", "Benachrichtigung", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    }
                    else
                    {
                        UserResult = MessageBox.Show("Eingestellte \"ID\" empfangen!", "Benachrichtigung", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                if (byte.Parse(toolStripMenuItem3.Text) == Parsed.DataLength && frameLängeToolStripMenuItem.CheckState == CheckState.Checked)
                {
                    if (checkBox1.CheckState == CheckState.Checked)
                    {
                        UserResult = MessageBox.Show("Eingestellte \"Frame Länge\" empfangen!\r\nZyklisch senden beenden?", "Benachrichtigung", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    }
                    else
                    {
                        UserResult = MessageBox.Show("Eingestellte \"Frame Länge\" empfangen!", "Benachrichtigung", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                if (byte.Parse(toolStripMenuItem4.Text) == Parsed.Exitcode && exitkodeToolStripMenuItem.CheckState == CheckState.Checked)
                {
                    if (checkBox1.CheckState == CheckState.Checked)
                    {
                        UserResult = MessageBox.Show("Eingestellten \"Exitcode\" empfangen!\r\nZyklisch senden beenden?", "Benachrichtigung", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    }
                    else
                    {
                        UserResult = MessageBox.Show("Eingestellten \"Exitcode\" empfangen!", "Benachrichtigung", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                if (UserResult == DialogResult.Yes)
                {
                    checkBox1.Checked = false;
                    Port.RingBuff.Clear();
                }
            }
            finally { }

            switch (Parsed.DataType)
            {
            /*  Vorzeichenbehaftete Werte
             */
            case (byte)Cmd.Data_Type_Enum.DATA_TYP_INT8:
            {
                DecStrParas = Parser.ConvertByteToSignedByte(Parsed.Data, 0, Parsed.DataLength, " , ");
            } break;

            case (byte)Cmd.Data_Type_Enum.DATA_TYP_INT16:
            {
                DecStrParas = Parser.ConvertInt16ToInt16(Parsed.Data, 0, Parsed.DataLength, " , ");
            } break;

            case (byte)Cmd.Data_Type_Enum.DATA_TYP_INT32:
            {
                DecStrParas = Parser.ConvertInt32ToInt32(Parsed.Data, 0, Parsed.DataLength, " , ");
            } break;


            /*  Vorzeichenlose Werte
             */
            case (byte)Cmd.Data_Type_Enum.DATA_TYP_UINT8:
            {
                DecStrParas = Parser.ConvertByte(Parsed.Data, 0, Parsed.DataLength, " , ");
            } break;


            case (byte)Cmd.Data_Type_Enum.DATA_TYP_UINT16:
            {
                DecStrParas = Parser.ConvertUInt16(Parsed.Data, 0, Parsed.DataLength, " , ");
            } break;


            case (byte)Cmd.Data_Type_Enum.DATA_TYP_UINT32:
            {
                DecStrParas = Parser.ConvertUInt32(Parsed.Data, 0, Parsed.DataLength, " , ");
            } break;


            case (byte)Cmd.Data_Type_Enum.DATA_TYP_FLOAT:
            {
                DecStrParas = Parser.ConvertToFloat(Parsed.Data, 0, Parsed.DataLength, " , ");
            } break;

            /*  String
             */
            case (byte)Cmd.Data_Type_Enum.DATA_TYP_STRING:
            {
                DecStrParas = Parser.ConvertToString(Parsed.Data, 0, Parsed.DataLength);
            } break;
            }


            ListViewItem cmdItems = new ListViewItem(Parsed.MessageID.ToString());

            cmdItems.SubItems.Add(Parsed.DataLength.ToString());
            cmdItems.SubItems.Add(Parsed.Exitcode.ToString());
            cmdItems.SubItems.Add(Parsed.DataType.ToString());

            if (Parsed.DataLength > 0)
            {
                cmdItems.SubItems.Add(DecStrParas);
            }
            else
            {
                cmdItems.SubItems.Add("-");
            }

            listView1.Items.Add(cmdItems);
            listView1.Items[listView1.Items.Count - 1].EnsureVisible();

            float FrameErrorPercent = (((float)Parser.BadFrameCount / (float)Parser.GoodFrameCount)) * 100;

            lbl_crc_statistik.Text = "Erfolgreich: " + Parser.GoodFrameCount.ToString() + "\r\n" + "Fehlgeschlagen: " + Parser.BadFrameCount.ToString() + " " + "( " + FrameErrorPercent.ToString("0.0000") + "% )";


            if (messageBoxAnzeigenToolStripMenuItem.CheckState == CheckState.Checked)
            {
                this.Show();
            }

            this.Text = "Kommando Interpreter" + "          " + ">>[" + Parser.GoodFrameCount.ToString() + "]<<" + " " + "Kommando(s) empfangen!";
        }