예제 #1
0
        /* 更新Flow-Presure Plot */
        private void UpdateFPPlot(double presure, double flow)
        {
            double x = presure;
            double y = flow;
            /* 按presure升序插入(presure重复项,flow求均值) */
            int i = 0;

            for (i = 0; i < m_pointsFP.Count; ++i)
            {
                if (x >= m_pointsFP[i].X)
                {
                    break;
                }
            }
            if (i < m_pointsFP.Count)
            {
                if (x == m_pointsFP[i].X)
                {
                    y             = (y + m_pointsFP[i].Y) / 2.0;
                    m_pointsFP[i] = new DataPoint(x, y); // 替换
                }
                else
                {
                    m_pointsFP.Insert(i, new DataPoint(x, y)); // 插入
                }
            }
            else
            {
                m_pointsFP.Add(new DataPoint(x, y));
            }

            /* 更新校准结果 */
            if (m_calParamAviable)
            {
                m_pointsFPResult.Clear();
                m_pointsFPResultP.Clear();
                m_pointsFPResultN.Clear();

                for (double p = m_minPresure - 1; p <= m_maxPresure + 1; p += 0.001)
                {
#if true
                    double f = FlowCalibrator.PresureToFlow(p, m_calParamValList,
                                                            m_calParamValListP, m_calParamValListN,
                                                            m_minPresure, m_maxPresure);
                    m_pointsFPResult.Add(new DataPoint(p, f));
#else
                    double f = FlowCalibrator.PresureToFlow(p, m_calParamValList);
                    m_pointsFPResult.Add(new DataPoint(p, f));

                    f = FlowCalibrator.PresureToFlow(p, m_calParamValListP);
                    m_pointsFPResultP.Add(new DataPoint(p, f));

                    f = FlowCalibrator.PresureToFlow(p, m_calParamValListN);
                    m_pointsFPResultN.Add(new DataPoint(p, f));
#endif
                }
            }

            plotViewFP.InvalidatePlot(true);
        }
예제 #2
0
        private double m_maxPresure = 0.0;                                                    // 最大压差

        public FormCalibration(FlowSensor flowSensor, double calVolume = 1.0)
        {
            /* 流量传感器 */
            m_flowSensor = flowSensor;

            /* 流量校准器 */
            m_flowCalibrator = new FlowCalibrator(m_flowSensor.SAMPLE_RATE, calVolume);

            InitializeComponent();

            this.Text = $"校准-{calVolume}L定标桶";
        }