Example #1
0
        private bool DoFreqTstStep(int step, Int16[] scaleList)
        {
            Int16[] chValues = new Int16[100];
            Int16[] refValues = new Int16[100];
            SetFreq(step);
            sigSource.SetAmpli(freqFullValues[step] * 0.75f);
            DateTime startTime = DateTime.Now;
            AppendText(this.txtMessage, String.Format("��ʼƵ��{0}����һ���Բ���,��ֵ�ȶ��������������һ��Ƶ��\r\n", freqNameList[step]));
            waitKey.Reset();
            while ((DateTime.Now - startTime).TotalSeconds < 10)
            {
                if (!Funs485.RdAllCh(cardAddr, out chValues))
                {
                    AppendText(this.txtMessage, String.Format("��ȡ��{0}ģ��������ʧ��", cardAddr));
                    return false;
                }
                if (!Funs485.RdAllCh(refCardNo, out refValues))
                {
                    AppendText(this.txtMessage, String.Format("��ȡ��{0}ģ��������ʧ��", cardAddr));
                    return false;
                }
                if (chValues.Length != refValues.Length)
                {
                    AppendText(this.txtMessage, String.Format("��׼�����У׼�岻һ��"));
                    return false;
                }
                chValues.CopyTo(WaitCalcValues, 0);
                refValues.CopyTo(RefValues, 0);
                InvalidateCtrl(this.gridValueView);
                if (waitKey.WaitOne(0,true)) break;
            }
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("����������{0}:", step);
            for (int i = 0; i < chValues.Length / 3; i++)
            {

                float refVal = refValues[i * 3];
                float realVal = chValues[i * 3];
                sb.AppendFormat("{0}/{1}/{2}%,", realVal, refVal, realVal * 100 / refVal);

            }
            sb.AppendLine();
            AppendText(this.txtMessage, sb.ToString());
            WriteToFile(sb.ToString());
            InvalidateCtrl(this.gridValueView);
            return true;
        }
Example #2
0
        private bool DoCalcStep(int step, Int16[] scaleList)
        {
            Int16[] chValues = new Int16[100];
            Int16[] refValues = new Int16[100];
            SetFreq(step);

            DateTime startTime = DateTime.Now;
            AppendText(this.txtMessage, String.Format("��ʼУ׼Ƶ��{0},��ֵ�ȶ��������������һ��Ƶ��\r\n", freqNameList[step]));
            waitKey.Reset();
            while ((DateTime.Now - startTime).TotalSeconds < 10)
            {
                if (!Funs485.RdAllCh(cardAddr, out chValues))
                {
                    AppendText(this.txtMessage, String.Format("��ȡ��{0}ģ��������ʧ��", cardAddr));
                    return false;
                }
                if (!Funs485.RdAllCh(refCardNo, out refValues))
                {
                    AppendText(this.txtMessage, String.Format("��ȡ��{0}ģ��������ʧ��", cardAddr));
                    return false;
                }
                if (chValues.Length != refValues.Length)
                {
                    AppendText(this.txtMessage, String.Format("��׼�����У׼�岻һ��"));
                    return false;
                }
                chValues.CopyTo(WaitCalcValues, 0);
                refValues.CopyTo(RefValues, 0);
                InvalidateCtrl(this.gridValueView);
                if (waitKey.WaitOne(0,true)) break;
            }
            for (int i = 0; i < chValues.Length / 3; i++)
            {
                double coef = scaleList[i * 4 + step] * 1.0;
                float refVal = refValues[i * 3];
                float realVal = chValues[i * 3];
                coef = coef * refVal;
                coef = coef / realVal;
                // coef *= coef * refVal /realVal;
                scaleList[i * 4 + step] = (Int16)Math.Round(coef);
            }
            scaleList.CopyTo(CoeffValues, 0);
            InvalidateCtrl(this.gridValueView);
            return true;
        }