示例#1
0
        void lockClient_GetRemotHostTestValue(string value)
        {
            anguiResult = anguiResult.GetValue(value);
            SetLabelText(lblJieDi, anguiResult.TestData[0].ToString("F3"));
            SetLabelText(lblJueYuan, anguiResult.TestData[1].ToString("F1"));
            SetLabelText(lblNaiYa, anguiResult.TestData[2].ToString("F3"));
            SetLabelText(lblXieLou, anguiResult.TestData[3].ToString("F3"));

            SetLedColor(ledJieDi, anguiResult.TestResult[0] ? Color.Green : Color.Red);
            SetLedColor(ledJueYuan, anguiResult.TestResult[1] ? Color.Green : Color.Red);
            SetLedColor(ledNaiYa, anguiResult.TestResult[2] ? Color.Green : Color.Red);
            SetLedColor(ledXieLou, anguiResult.TestResult[3] ? Color.Green : Color.Red);
        }
        public AnGuiData GetValue(string value)
        {
            AnGuiData result = new AnGuiData();

            string[] buff  = value.Split('~');
            int      index = 0;

            result.isPass = All.Class.Num.ToBool(buff[index++]);
            for (int i = 0; i < TestData.Length; i++)
            {
                result.TestData[i]   = All.Class.Num.ToDouble(buff[index++]);
                result.TestResult[i] = All.Class.Num.ToBool(buff[index++]);
            }
            return(result);
        }
        public static bool ReadData(AnGuiData mAnGuiData, AnGuiList anGuiList, ref bool isReadOver)
        {
            bool isOk       = false;
            bool isRead7440 = false;
            bool isRead7623 = false;

            cHYAnGui.TempAnGuiData tmpData = new TempAnGuiData();
            tmpData.isReadOk = new bool[AnGuiData.testCount];
            tmpData.ReadData = new float[AnGuiData.testCount];
            tmpData.isPass   = new bool[AnGuiData.testCount];
            tmpData.index    = new int[AnGuiData.testCount];
            for (int i = 0; i < tempAnGuiData.ReadData.Length; i++)
            {
                tmpData.ReadData[i] = 0;
                tmpData.isReadOk[i] = false;
                tmpData.isPass[i]   = true;
                tmpData.index[i]    = i + 1;
            }
            AnGuiTestList tmpAnGuiTestList = AnGuiTestList.JieDi;

            isReadOver = true;
            try
            {
                switch (anGuiList)
                {
                case AnGuiList.HY7440:
                    isRead7440 = true;
                    break;

                case AnGuiList.HY7623:
                    isRead7623 = true;
                    break;

                case AnGuiList.BothTwo:
                    isRead7440 = true;
                    isRead7623 = true;
                    break;
                }
                if (isRead7623)
                {
                    if (hy7623 != null)
                    {
                        if (!tmpData.isReadOk[3])
                        {
                            if (hy7623.HYAnGuiRead(AnGuiList.HY125, 1, ref tmpData.ReadData[3], ref tmpData.isPass[3], out tmpAnGuiTestList))
                            {
                                tmpData.isReadOk[3] = true;
                                switch (tmpAnGuiTestList)
                                {
                                case AnGuiTestList.JieDi:
                                    tmpData.index[3] = 0;
                                    break;

                                case AnGuiTestList.JueYuan:
                                    tmpData.index[3] = 1;
                                    break;

                                case AnGuiTestList.NaiYa:
                                    tmpData.index[3] = 2;
                                    break;

                                case AnGuiTestList.XieLou:
                                    tmpData.index[3] = 3;
                                    break;
                                }
                            }
                        }
                    }
                }
                if (isRead7440)
                {
                    if (hy7440 != null)
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            if (!tmpData.isReadOk[i])
                            {
                                Thread.Sleep(100);
                                if (hy7440.HYAnGuiRead(AnGuiList.HY7440, i + 1, ref tmpData.ReadData[i], ref tmpData.isPass[i], out tmpAnGuiTestList))
                                {
                                    tmpData.isReadOk[i] = true;
                                    switch (tmpAnGuiTestList)
                                    {
                                    case AnGuiTestList.JieDi:
                                        tmpData.index[i] = 0;
                                        break;

                                    case AnGuiTestList.JueYuan:
                                        tmpData.index[i] = 1;
                                        break;

                                    case AnGuiTestList.NaiYa:
                                        tmpData.index[i] = 2;
                                        break;

                                    case AnGuiTestList.XieLou:
                                        tmpData.index[i] = 3;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                for (int i = 0; i < tmpData.isReadOk.Length; i++)
                {
                    if (!tmpData.isReadOk[i])
                    {
                        isReadOver = false;
                        break;
                    }
                }
                if (isReadOver)
                {
                    mAnGuiData.isPass = true;
                    for (int i = 0; i < tmpData.ReadData.Length; i++)
                    {
                        if (tmpData.index[i] < AnGuiData.testCount)
                        {
                            mAnGuiData.TestData[tmpData.index[i]]   = tmpData.ReadData[i];
                            mAnGuiData.TestResult[tmpData.index[i]] = tmpData.isPass[i];
                            mAnGuiData.isPass = (mAnGuiData.isPass && tmpData.isPass[i]);
                        }
                    }
                }
                isOk = true;
            }
            catch (Exception exc)
            {
                All.Class.Error.Add(exc);
            }
            return(isOk);
        }