Ejemplo n.º 1
0
        private void GetDataArrived2()
        {
            while (true)
            {
                rbuff2 += clientCalc2.GetRcvMsg();
                int idx1 = rbuff2.IndexOf(TSocket.sSTX());
                if (idx1 < 0)
                {
                    break;
                }
                int idx2 = rbuff2.IndexOf(TSocket.sETX(), idx1);

                if (idx1 >= 0 && idx2 > idx1)
                {
                    string stReq = rbuff2.Substring(idx1 + 1, 2);
                    if (stReq == "PO")
                    {
                        IsPO2 = true;
                    }
                    else if (stReq == "RO")
                    {
                        IsRO2 = true;
                    }
                    else if (stReq == "CS")
                    {
                        lblRsp2.Text = "Respond2: Calculating";
                    }
                    else if (stReq == "CC")
                    {
                        lblRsp2.Text = "Respond2: End";
                        NumPNOrg2.Clear();
                    }
                    else if (stReq == "PN")
                    {
                        string stNum = rbuff2.Substring(idx1 + 3, idx2 - (idx1 + 3));
                        NumPNOrg2.Add(Convert.ToInt32(stNum));
                    }
                    else if (stReq == "TC")
                    {
                        IsDraw2 = true;
                    }
                    // Trim Rx Buffer2
                    rbuff2 = rbuff2.Substring(idx2 + 1);
                }
            }
        }