Ejemplo n.º 1
0
        private readonly double STOP_FLOW_THRESHOLD = 0.01; // 停止检测流量阈值,当启动测试后如果流量对值小于阈值,则开始检测停止条件

        public FlowValidator(double sampleRate, double calVolume = 1.0)
        {
            SAMPLE_RATE = sampleRate;
            SAMPLE_TIME = 1000 / sampleRate;

            m_waveAnalyzer = new WaveAnalyzer(sampleRate,
                                              START_SAMPLE_COUNT, START_FLOW_DELTA,
                                              STOP_SAMPLE_COUNT, STOP_FLOW_THRESHOLD);

            CalVolume = calVolume;

            m_waveAnalyzer.SampleStarted += (uint dataIndex, WaveSampleDirection direction) =>
            {
                /* 转换为呼吸方向 */
                RespireDirection respireDir = ToRespireDirection(direction);
                SampleStarted?.Invoke(dataIndex, respireDir);
            };

            m_waveAnalyzer.SampleStoped += (uint dataIndex, WaveSampleDirection direction, uint sampleIndex) =>
            {
                /* 转换为呼吸方向 */
                RespireDirection respireDir = ToRespireDirection(direction);
                SampleStoped?.Invoke(dataIndex, respireDir, sampleIndex);
            };
        }