Ejemplo n.º 1
0
 public AdissCsvFile(string projectName, string permitCode, string clientName, int tripNumber, Scow scow, string materialSource, DateTime transitStart, DateTime disposalStart, string note, IEnumerable <AdissCsvRecord> records, double averageDraftStartTransitToDisposalArea, double averageDraftLossDuringTransit, double maximumSpeedDuringTransit, DateTime startLoadingDateTime, DateTime endLoadingDateTime, DateTime startTransitToDisposalAreaDateTime, DateTime endReturnFromDisposalAreaDateTime, TimeSpan totalTransitTime, AdissCsvRecord startDumpRecord, AdissCsvRecord endDumpRecord, DateTime scowOpenDateTime)
 {
     ProjectName    = projectName;
     PermitCode     = permitCode;
     ClientName     = clientName;
     TripNumber     = tripNumber;
     Scow           = scow;
     MaterialSource = materialSource;
     TransitStart   = transitStart;
     DisposalStart  = disposalStart;
     Note           = note;
     Records        = records;
     AverageDraftStartTransitToDisposalArea = averageDraftStartTransitToDisposalArea;
     AverageDraftLossDuringTransit          = averageDraftLossDuringTransit;
     MaximumSpeedDuringTransit          = maximumSpeedDuringTransit;
     StartLoadingDateTime               = startLoadingDateTime;
     EndLoadingDateTime                 = endLoadingDateTime;
     StartTransitToDisposalAreaDateTime = startTransitToDisposalAreaDateTime;
     EndReturnFromDisposalAreaDateTime  = endReturnFromDisposalAreaDateTime;
     TotalTransitTime = totalTransitTime;
     StartDumpRecord  = startDumpRecord;
     EndDumpRecord    = endDumpRecord;
     ScowOpenDateTime = scowOpenDateTime;
 }
Ejemplo n.º 2
0
        public OutputData Generate(UserInput userInput, DredgeRecord dredgeRecord, AdissCsvFile adissCsvFile)
        {
            IEnumerable <AdissCsvRecord> transitRecords         = adissCsvFile.Records.Where(r => r.PlacementPhase == PlacementPhase.Transit);
            IEnumerable <AdissCsvRecord> reversedTransitRecords = transitRecords.Reverse();

            AdissCsvRecord firstRecordExitedTheChannelBeforeGoingStraightToDisposal = reversedTransitRecords
                                                                                      .TakeWhile(r => !charlestonDeepening2Service.IsWithinChannel(r.XYCoordinate))
                                                                                      .Last();

            double?averageDraftLeavingTheChannel = null;

            if (!ReferenceEquals(firstRecordExitedTheChannelBeforeGoingStraightToDisposal, transitRecords.First())) //true if scow was outside the channel the whole time
            {
                averageDraftLeavingTheChannel = firstRecordExitedTheChannelBeforeGoingStraightToDisposal.AverageDraftInternationalFeet;
            }

            AdissCsvRecord firstRecordInsideDisposalArea               = adissCsvFile.Records.FirstOrDefault(r => userInput.DisposalArea.Polygon2D.DoesBound(r.XYCoordinate));
            double?        averageDraftEnteringDisposalArea            = null;
            double?        averageDraftLossDuringTransitToDisposalArea = null;

            if (firstRecordInsideDisposalArea != null)
            {
                averageDraftEnteringDisposalArea            = firstRecordInsideDisposalArea.AverageDraftInternationalFeet;
                averageDraftLossDuringTransitToDisposalArea = firstRecordInsideDisposalArea.AverageDraftInternationalFeet - transitRecords.First().AverageDraftInternationalFeet;
            }

            bool?isStartDumpInsideOfBerm = null;

            if (charlestonDeepening2Service.ShouldDumpInBermArea(userInput.DisposalArea))
            {
                isStartDumpInsideOfBerm = charlestonDeepening2Service.IsWithinBermArea(adissCsvFile.StartDumpRecord.XYCoordinate);
            }

            bool isMisDump = !userInput.DisposalArea.Polygon2D.DoesBound(adissCsvFile.StartDumpRecord.XYCoordinate);

            bool isScowOpenViolation = adissCsvFile.Records
                                       .Where(r => r.HullStatus == HullStatus.Open || r.PlacementPhase == PlacementPhase.Disposal)
                                       .Any(r => !userInput.DisposalArea.Polygon2D.DoesBound(r.XYCoordinate));

            return(new OutputData(
                       adissLoadNumber: adissCsvFile.TripNumber,
                       dredgeLoadNumber: userInput.DredgeLoadNumber,
                       dredge: userInput.Dredge,
                       scowVesselName: adissCsvFile.Scow.Name,
                       tugVesselName: userInput.TugVesselName,
                       disposalArea: userInput.DisposalArea.Name,
                       averageDraftLossDuringTransitToDisposalArea: averageDraftLossDuringTransitToDisposalArea,
                       maximumSpeedDuringTransit: adissCsvFile.MaximumSpeedDuringTransit,
                       isStartDumpInsideOfBerm: isStartDumpInsideOfBerm,
                       isScowOpenViolation: isScowOpenViolation,
                       isMisDump: isMisDump,
                       isEmergencyDump: userInput.IsEmergencyDump,
                       startLoadingDateTime: adissCsvFile.StartLoadingDateTime,
                       endLoadingDateTime: adissCsvFile.EndLoadingDateTime,
                       startTransitToDisposalAreaDateTime: adissCsvFile.StartTransitToDisposalAreaDateTime,
                       averageDraftStartTransitToDisposalArea: adissCsvFile.AverageDraftStartTransitToDisposalArea,
                       averageDraftEnteringDisposalArea: averageDraftEnteringDisposalArea,
                       startDumpXY: adissCsvFile.StartDumpRecord.XYCoordinate,
                       startDumpDateTime: adissCsvFile.StartDumpRecord.LocalDateTime,
                       endDumpXY: adissCsvFile.EndDumpRecord.XYCoordinate,
                       endDumpDateTime: adissCsvFile.EndDumpRecord.LocalDateTime,
                       averageDraftLeavingTheChannel: averageDraftLeavingTheChannel,
                       endReturnFromDisposalAreaDateTime: adissCsvFile.EndReturnFromDisposalAreaDateTime,
                       totalTransitDuration: adissCsvFile.TotalTransitTime,
                       estimatedLoad: adissCsvFile.LookupEstimatedLoadSize(),
                       startTransitToDisposalAreaDredgeDigX: dredgeRecord?.X,
                       startTransitToDisposalAreaDredgeDigY: dredgeRecord?.Y,
                       startTransitToDisposalAreaDredgeDigDepth: dredgeRecord?.Depth,
                       startTransitToDisposalAreaDredgeDigStation: dredgeRecord?.Station));
        }
Ejemplo n.º 3
0
        public AdissCsvFile Parse(string filePath)
        {
            using (var streamReader = new StreamReader(File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
            {
                streamReader.Read(new char[9], 0, 9);
                string projectName = streamReader.ReadLine();

                streamReader.Read(new char[8], 0, 8);
                string permitCode = streamReader.ReadLine();

                streamReader.Read(new char[8], 0, 8);
                string clientName = streamReader.ReadLine();

                streamReader.Read(new char[6], 0, 6);
                int tripNumber = int.Parse(streamReader.ReadLine());

                streamReader.Read(new char[13], 0, 13);
                Scow scow = new ScowParser().ParseFromScowVesselName(streamReader.ReadLine());

                streamReader.Read(new char[17], 0, 17);
                string materialSource = streamReader.ReadLine();

                streamReader.Read(new char[15], 0, 15);
                DateTime transitStart = DateTime.Parse(streamReader.ReadLine());

                streamReader.Read(new char[16], 0, 16);
                DateTime disposalStart = DateTime.Parse(streamReader.ReadLine());

                streamReader.Read(new char[6], 0, 6);
                string note = streamReader.ReadLine();

                streamReader.ReadLine(); // skip empty line 10
                streamReader.ReadLine(); // skip line 11: Local Date/Time,Easting,Northing,Heading,Speed (knots),Aft Draft (ft),Fore Draft (ft),Water Depth (ft),Placement Phase,Hull Status

                List <AdissCsvRecord> records = new CsvReader(streamReader, csvConfiguration).GetRecords <AdissCsvRecord>().ToList();

                IEnumerable <AdissCsvRecord> transitRecords = records.Where(r => r.PlacementPhase == PlacementPhase.Transit);
                AdissCsvRecord firstTransitRecord           = transitRecords.First();
                AdissCsvRecord lastTransitRecord            = transitRecords.Last();

                IEnumerable <AdissCsvRecord> loadingRecords = records.Where(r => r.PlacementPhase == PlacementPhase.Loading);
                AdissCsvRecord firstLoadingRecord           = loadingRecords.First();
                AdissCsvRecord lastLoadingRecord            = loadingRecords.Last();

                IEnumerable <AdissCsvRecord> returnRecords = records.Where(r => r.PlacementPhase == PlacementPhase.Return);
                AdissCsvRecord lastReturnRecord            = returnRecords.Last();

                IEnumerable <AdissCsvRecord> disposalRecords = records.Where(r => r.PlacementPhase == PlacementPhase.Disposal);
                AdissCsvRecord firstDisposalRecord           = disposalRecords.First();
                AdissCsvRecord lastDisposalRecord            = disposalRecords.Last();

                IEnumerable <AdissCsvRecord> scowOpenRecords = records.Where(r => r.HullStatus == HullStatus.Open);
                AdissCsvRecord firstScowOpenRecord           = scowOpenRecords.First();

                return(new AdissCsvFile(
                           projectName: projectName,
                           permitCode: permitCode,
                           clientName: clientName,
                           tripNumber: tripNumber,
                           scow: scow,
                           materialSource: materialSource,
                           transitStart: transitStart,
                           disposalStart: disposalStart,
                           note: note,
                           records: records,
                           averageDraftStartTransitToDisposalArea: firstTransitRecord.AverageDraftInternationalFeet,
                           averageDraftLossDuringTransit: lastTransitRecord.AverageDraftInternationalFeet - firstTransitRecord.AverageDraftInternationalFeet,
                           maximumSpeedDuringTransit: transitRecords.Max(r => r.SpeedKnots),
                           startLoadingDateTime: firstLoadingRecord.LocalDateTime,
                           endLoadingDateTime: lastLoadingRecord.LocalDateTime,
                           startTransitToDisposalAreaDateTime: firstTransitRecord.LocalDateTime,
                           endReturnFromDisposalAreaDateTime: lastReturnRecord.LocalDateTime,
                           totalTransitTime: lastTransitRecord.LocalDateTime - firstTransitRecord.LocalDateTime,
                           startDumpRecord: firstDisposalRecord,
                           endDumpRecord: lastDisposalRecord,
                           scowOpenDateTime: firstScowOpenRecord.LocalDateTime));
            }
        }