예제 #1
0
    private void ResolveConflictForShipMoveTask(ShipMoveTask task, ShipSchedule schedule)
    {
        if (!ShipMoveTaskHasConflict(task))
        {
            return;
        }

        List <Reservation> reservationList = reservationOnConnections[task.connection];
        TimeSpan           minTimeSpan     = TimeSpan.MaxValue;

        foreach (Reservation reservation in reservationList)
        {
            TimeSpan timeDiff = reservation.EndTime + safetyTime - task.StartTime;
            if (timeDiff < TimeSpan.Zero)
            {
                continue;
            }

            if (reservation.ConflictWithTask(task.StartTime + timeDiff, task.EndTime + timeDiff))
            {
                continue;
            }

            if (timeDiff < minTimeSpan)
            {
                minTimeSpan = timeDiff;
            }
        }

        if (minTimeSpan == TimeSpan.Zero)
        {
            minTimeSpan = minTimeSpan.Add(new TimeSpan(0, 0, 1));
        }

        schedule.Postpone(minTimeSpan);
    }
예제 #2
0
    private void ResolveConflictForUnloadingTask(UnloadingTask task, ShipSchedule schedule)
    {
        if (!UnloadingTaskHasConflict(task))
        {
            return;
        }

        List <Reservation> reservationList = reservationOnDocks[task.dock];
        TimeSpan           minTimeSpan     = TimeSpan.MaxValue;

        foreach (Reservation reservation in reservationList)
        {
            TimeSpan timeDiff = reservation.EndTime + safetyTime - task.StartTime;
            if (timeDiff.CompareTo(TimeSpan.Zero) < 0)
            {
                continue;
            }

            if (reservation.ConflictWithTask(task.StartTime + timeDiff, task.EndTime + timeDiff))
            {
                continue;
            }

            if (timeDiff < minTimeSpan)
            {
                minTimeSpan = timeDiff;
            }
        }

        if (minTimeSpan == TimeSpan.Zero)
        {
            minTimeSpan = minTimeSpan.Add(new TimeSpan(0, 0, 1));
        }

        schedule.Postpone(minTimeSpan);
    }