private void SetEquations(MeterCalibration calibration)
        {
            var slope1     = _parsedData.MeterConst1;
            var intercept1 = _parsedData.MeterConst2;
            var slope2     = _parsedData.MeterConst3;
            var intercept2 = _parsedData.MeterConst4;

            var interceptUnit = CommonMapper.GetUnitSystem(_parsedData).VelocityUnitId;

            //Sample files show: C5=0, C3=C1, C4=C2. This should be 1 segment equation.
            if (!AreEqualDoubles(slope1, 0.0d) || !AreEqualDoubles(intercept1, 0.0d))
            {
                calibration.Equations.Add(
                    new MeterCalibrationEquation {
                    Slope = slope1, Intercept = intercept1, InterceptUnitId = interceptUnit
                });
            }

            //Assuming this is a 2 segment equation setup:
            if (!AreEqualDoubles(slope1, slope2) ||
                !AreEqualDoubles(intercept1, intercept2))
            {
                calibration.Equations.Add(
                    new MeterCalibrationEquation {
                    Slope = slope2, Intercept = intercept2, InterceptUnitId = interceptUnit
                });
            }
        }
        public DischargeActivity GetDischargeActivity()
        {
            var unitSystem          = CommonMapper.GetUnitSystem(_parsedData);
            var observationInterval = CommonMapper.GetObservationTimeInterval(_visitInterval.Start,
                                                                              _parsedData);

            var dischargeActivity = CreateDischargeActivityWithSummary(observationInterval, unitSystem);

            SetManualGaugingSection(dischargeActivity, unitSystem, observationInterval);

            return(dischargeActivity);
        }
        private void SetTechnologyInfo(ManualGaugingDischargeSection dischargeSection)
        {
            //Primary Current Meter: will be inferred from verticals.

            //Deployment method:
            dischargeSection.DeploymentMethod =
                CommonMapper.GetDeploymentMethodBySoundingWeight(_parsedData.SoundingWeight);

            //Meter Suspension:
            if (dischargeSection.DeploymentMethod == DeploymentMethodType.Wading)
            {
                dischargeSection.MeterSuspension = MeterSuspensionType.RoundRod;
            }

            //Suspension weight: in vertical's OpenWaterData.
        }
        public IEnumerable <Vertical> GetVerticals()
        {
            var timeInterval = CommonMapper.GetObservationTimeInterval(_visitStart, _parsedData);

            var verticals   = new List <Vertical>();
            var startOfDate = new DateTimeOffset(timeInterval.Start.Date, timeInterval.Start.Offset);

            var calculatedTotalQ = _parsedData.VerticalObservations.Sum(v => v.FlowQSum);
            var meterCalibration = GetMeterCalibration();

            for (var index = 0; index < _parsedData.VerticalObservations.Count; index++)
            {
                var verticalObservation = _parsedData.VerticalObservations[index];
                var previousTaglinePos  = index == 0 ? 0 : _parsedData.VerticalObservations[index - 1].Distance;

                var segment        = GetSegment(verticalObservation, previousTaglinePos, calculatedTotalQ);
                var sequenceNumber = index + 1;

                var vertical = new Vertical
                {
                    Segment = segment,
                    MeasurementConditionData = GetConditionData(verticalObservation),
                    TaglinePosition          = verticalObservation.Distance,
                    SequenceNumber           = sequenceNumber,
                    MeasurementTime          = startOfDate.Add(verticalObservation.StartTime),
                    VerticalType             = GetVerticalTypeOrMidRiver(verticalObservation, sequenceNumber),
                    EffectiveDepth           = verticalObservation.Depth,

                    VelocityObservation     = GetVelocityObservation(verticalObservation, meterCalibration, sequenceNumber),
                    Comments                = verticalObservation.Comments,
                    FlowDirection           = FlowDirectionType.Normal,
                    SoundedDepth            = verticalObservation.Depth,
                    IsSoundedDepthEstimated = verticalObservation.Comments.Contains("DEPTH ESTIMATED"),
                    //ObliqueFlowCorrection: N/A
                };

                SetAdditionalVerticalComments(vertical, verticalObservation);

                verticals.Add(vertical);
            }

            return(verticals);
        }
        private VelocityObservation GetVelocityObservation(VerticalObservation verticalObservation,
                                                           MeterCalibration meterCalibration, int sequenceNumber)
        {
            var depthObservations = GetVelocityDepthObservations(verticalObservation.ObservationPoints);

            var velocityObservationMethod = GetVelocityObservationMethodOrUnknown(verticalObservation, sequenceNumber);

            var velocityObservation = new VelocityObservation
            {
                MeterCalibration          = meterCalibration,
                DeploymentMethod          = CommonMapper.GetDeploymentMethodBySoundingWeight(_parsedData.SoundingWeight),
                VelocityObservationMethod = velocityObservationMethod,
                MeanVelocity = verticalObservation.MeanVelocity
            };

            foreach (var velocityDepthObservation in depthObservations)
            {
                velocityObservation.Observations.Add(velocityDepthObservation);
            }

            return(velocityObservation);
        }