示例#1
0
        private void GetInput(int num)
        {
            int i = num;

            if (ListINP[i].Box.Text != "")
            {
                if (RadioButtonInputHex.IsChecked == true)
                {
                    if (CStat.IsHex(ListINP[i].Box.Text))
                    {
                        int result = Convert.ToInt32(ListINP[i].Box.Text, 16);

                        if (result < 256)
                        {
                            ListINP[i].QueueInput.Enqueue(result);
                            ListINP[i].LastInput.Content = result.ToString("X2");
                            ListINP[i].Box.Text          = "";
                            ListINP[i].Num.Background    = Brushes.LightGreen;
                        }
                        else
                        {
                            ListINP[i].Num.Background = Brushes.Red;
                        }
                    }
                    else
                    {
                        ListINP[i].Num.Background = Brushes.Red;
                    }
                }
                else if (RadioButtonInputBin.IsChecked == true)
                {
                    try
                    {
                        int result = Convert.ToInt32(ListINP[i].Box.Text, 2);

                        if (result < 256)
                        {
                            ListINP[i].QueueInput.Enqueue(result);
                            ListINP[i].LastInput.Content = result.ToString("X2");
                            ListINP[i].Box.Text          = "";
                            ListINP[i].Num.Background    = Brushes.LightGreen;
                        }
                        else
                        {
                            ListINP[i].Num.Background = Brushes.Red;
                        }
                    }
                    catch
                    {
                        ListINP[i].Num.Background = Brushes.Red;
                    }
                }
                else if (RadioButtonInputChar.IsChecked == true)
                {
                    for (int l = 0; l < ListINP[i].Box.Text.Length; l++)
                    {
                        char c = ListINP[i].Box.Text[l];

                        ListINP[i].QueueInput.Enqueue((int)c);
                        ListINP[i].LastInput.Content = ((int)c).ToString("X2");
                    }
                    ListINP[i].Box.Text       = "";
                    ListINP[i].Num.Background = Brushes.LightGreen;
                }
            }
        }
示例#2
0
        public static (string term1, string comp, string term2) CheckCondition(string term)
        {
            string sign = "== >= <= > <";

            string[] signs = sign.Split();

            string termLinks  = "";
            string v          = "";
            string termRechts = "";

            bool found = false;

            for (int i = 0; i < signs.Length; i++)
            {
                string[] s = term.Split(signs[i]);
                if (s.Length == 2)
                {
                    termLinks  = s[0];
                    v          = signs[i];
                    termRechts = s[1];
                    found      = true;
                    break;
                }
            }

//          mögliche Einträge für Register:			        möglicher Eintrag:
//          R1..RF  RP RX                                   Akku D

//          mögliche Einträge für Adressen:
//          '4stellig-Hex' zB: A0F7

//          Beispieleinträge für Register und Hexwert       D und Hexwert

//          R5 > A12F                                       D > A12F
//          R5 >= A12F                                      D >= A12F
//          R5 < A12F                                       D < A12F
//          R5 <= A12F                                      D <= A12F
//          R5 == A12F                                      D == A12F

//          Beispieleinträge für  Register und Register

//          R5 > R6
//          R5 >= R6
//          R5 < R6
//          R5 <= R6
//          R5 == R6


            if (!found)
            {
                return("", "", "");
            }

            bool term1Ok = false;
            bool term2Ok = false;


            if (termLinks.Length == 2 && termLinks.StartsWith("R"))
            {
                if (termLinks[1] == 'P')        // RP
                {
                    term1Ok = true;
                }
                else if (termLinks[1] == 'X')   // RX
                {
                    term1Ok = true;
                }
                else if (CStat.IsHex(termLinks[1].ToString())) //Rn
                {
                    term1Ok = true;
                }
            }


            if (termLinks.Length == 4 && CStat.IsHex(termLinks))
            {
                term1Ok = true;
            }

            if (termLinks == "D")
            {
                term1Ok = true;
            }


            if (termRechts.Length == 2 && termRechts.StartsWith("R"))
            {
                if (termRechts[1] == 'P')        // RP
                {
                    term2Ok = true;
                }
                else if (termRechts[1] == 'X')   // RX
                {
                    term2Ok = true;
                }
                else if (CStat.IsHex(termRechts[1].ToString())) //Rn
                {
                    term2Ok = true;
                }
            }

            if (termRechts.Length == 4 && CStat.IsHex(termRechts))
            {
                term2Ok = true;
            }



            if (term1Ok && term2Ok)
            {
                return(termLinks, v, termRechts);
            }
            else
            {
                return("", "", "");
            }
        }