Esempio n. 1
0
        public void UpdateSpeedPowerSavingsColl(double meanDraft)
        {
            var records = PowerRecords.Where(rec => rec.Draft == meanDraft);

            if (!records.Any())
            {
                MessageBox.Show("No data exists for given draft.");
                return;
            }

            var speeds    = records.Select(x => x.Speed).Distinct().OrderBy(y => y);
            var speedList = new ObservableCollection <PowerSavingsForSpeed>();

            foreach (var speed in speeds)
            {
                var speedRow        = new PowerSavingsForSpeed();
                var filteredRecords = records.Where(x => x.Speed == speed).OrderBy(x => x.Trim);
                foreach (var rec in filteredRecords)
                {
                    speedRow.Savings.Add(String.Format("{0:N2}", rec.PowerSavings));
                }
                speedList.Add(speedRow);
            }
            PowerSavingsForSpeedColl = speedList;
            var trims      = records.Select(x => x.Trim).Distinct().OrderBy(x => x);
            var headerlist = new ObservableCollection <string>();

            foreach (var item in trims)
            {
                headerlist.Add(String.Format("{0:N2}", item));
            }
            HeadersList = headerlist;
        }
Esempio n. 2
0
        private void ComputePlotPoints(out List <DataPoint> puPoints, out List <DataPoint> psPoints)
        {
            var filteredPowerRecords = PowerRecords.Where(x => x.Draft == Draft && x.Speed == Speed);

            puPoints = new List <DataPoint>();
            psPoints = new List <DataPoint>();

            if (filteredPowerRecords.Any())
            {
                foreach (var powerRec in filteredPowerRecords)
                {
                    puPoints.Add(new DataPoint(powerRec.Trim, powerRec.Power));
                    psPoints.Add(new DataPoint(powerRec.Trim, powerRec.PowerSavings));
                }
            }
            else
            {
                var draftMatches = PowerRecords.Where(x => x.Draft == Draft);
                var speedMatches = PowerRecords.Where(x => x.Speed == Speed);
                if (draftMatches.Any())
                {
                    InterpolateGraphPointsForMissingSpeed(draftMatches, psPoints, puPoints);
                }
                else if (speedMatches.Any())
                {
                    InterpolateGraphPointsForMissingDraft(speedMatches, psPoints, puPoints);
                }
                else
                {
                    InterpolateGraphPointsFroMissingDraftAndSpeed(psPoints, puPoints);
                }
            }
        }