コード例 #1
0
        private void PublishResults(PseudoResult result)
        {
            // Turn results into output measurements
            Measurement[] measurements = new Measurement[Outputs.Length];

            foreach (Output output in Outputs)
            {
                int index = (int)output;

                switch (output)
                {
                case Output.Band1Energy:
                    measurements[index]            = Measurement.Clone(OutputMeasurements[index], result.Band1Energy, result.Timestamp);
                    measurements[index].StateFlags = DeriveQualityFlags.From(result.Band1EnergyQualityIsGood, m_timeQualityIsGood);
                    break;

                case Output.Band2Energy:
                    measurements[index]            = Measurement.Clone(OutputMeasurements[index], result.Band2Energy, result.Timestamp);
                    measurements[index].StateFlags = DeriveQualityFlags.From(result.Band2EnergyQualityIsGood, m_timeQualityIsGood);
                    break;

                case Output.Band3Energy:
                    measurements[index]            = Measurement.Clone(OutputMeasurements[index], result.Band3Energy, result.Timestamp);
                    measurements[index].StateFlags = DeriveQualityFlags.From(result.Band3EnergyQualityIsGood, m_timeQualityIsGood);
                    break;

                case Output.Band4Energy:
                    measurements[index]            = Measurement.Clone(OutputMeasurements[index], result.Band4Energy, result.Timestamp);
                    measurements[index].StateFlags = DeriveQualityFlags.From(result.Band4EnergyQualityIsGood, m_timeQualityIsGood);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            m_publishMeasurements(measurements);
        }
コード例 #2
0
        public void Load(DateTime timestamp, double[,] values, bool[,] qualities)
        {
            PseudoResult result = new PseudoResult {
                Timestamp = timestamp
            };

            for (int i = 0; i < values.GetLength(0); i++)
            {
                switch ((OscillationDetector.Output)i)
                {
                case OscillationDetector.Output.Band1Energy:
                    result.Band1Energy = values.GetColumn(i).Average();
                    result.Band1EnergyQualityIsGood = qualities.GetColumn(i).All(state => state);
                    break;

                case OscillationDetector.Output.Band2Energy:
                    result.Band2Energy = values.GetColumn(i).Average();
                    result.Band2EnergyQualityIsGood = qualities.GetColumn(i).All(state => state);
                    break;

                case OscillationDetector.Output.Band3Energy:
                    result.Band3Energy = values.GetColumn(i).Average();
                    result.Band3EnergyQualityIsGood = qualities.GetColumn(i).All(state => state);
                    break;

                case OscillationDetector.Output.Band4Energy:
                    result.Band4Energy = values.GetColumn(i).Average();
                    result.Band4EnergyQualityIsGood = qualities.GetColumn(i).All(state => state);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            ReportCallback(result);
        }