public void TestBackwardSchedulingTransitionTimeForeachOperationIsCorrect( string testConfigurationFileName) { InitThisTest(testConfigurationFileName); IDbTransactionData dbTransactionData = ZppConfiguration.CacheManager.ReloadTransactionData(); foreach (var productionOrderBomAsDemand in dbTransactionData.ProductionOrderBomGetAll()) { ProductionOrderBom productionOrderBom = (ProductionOrderBom)productionOrderBomAsDemand; int expectedStartBackward = productionOrderBom.GetStartTimeBackward().GetValue() + TransitionTimer.GetTransitionTimeFactor() * productionOrderBom.GetDurationOfOperation().GetValue(); int actualStartBackward = productionOrderBom.GetStartTimeOfOperation().GetValue(); Assert.True(expectedStartBackward.Equals(actualStartBackward), $"The transition time before operationStart is not correct: " + $"expectedStartBackward: {expectedStartBackward}, actualStartBackward {actualStartBackward}"); int expectedEndBackward = productionOrderBom.GetStartTimeOfOperation().GetValue() + productionOrderBom.GetDurationOfOperation().GetValue(); int actualEndBackward = productionOrderBom.GetEndTimeBackward().GetValue(); Assert.True(expectedEndBackward.Equals(actualEndBackward), $"EndBackward is not correct: " + $"expectedEndBackward: {expectedEndBackward}, actualEndBackward {actualEndBackward}"); } }
public DueTime GetEarliestPossibleStartTimeOf(ProductionOrderBom productionOrderBom) { DueTime earliestStartTime = productionOrderBom.GetStartTimeBackward(); Providers providers = ZppConfiguration.CacheManager.GetAggregator() .GetAllChildProvidersOf(productionOrderBom); if (providers.Count() > 1) { throw new MrpRunException("A productionOrderBom can only have one provider !"); } Provider stockExchangeProvider = providers.GetAny(); if (earliestStartTime.IsGreaterThanOrEqualTo( stockExchangeProvider.GetStartTimeBackward())) { earliestStartTime = stockExchangeProvider.GetStartTimeBackward(); } else { throw new MrpRunException("A provider of a demand cannot have a later dueTime."); } Demands stockExchangeDemands = ZppConfiguration.CacheManager.GetAggregator() .GetAllChildDemandsOf(stockExchangeProvider); if (stockExchangeDemands.Any() == false) // StockExchangeProvider has no childs (stockExchangeDemands), // take that from stockExchangeProvider { DueTime childDueTime = stockExchangeProvider.GetStartTimeBackward(); if (childDueTime.IsGreaterThan(earliestStartTime)) { earliestStartTime = childDueTime; } } else // StockExchangeProvider has childs (stockExchangeDemands) { foreach (var stockExchangeDemand in stockExchangeDemands) { DueTime stockExchangeDemandDueTime = stockExchangeDemand.GetStartTimeBackward(); if (stockExchangeDemandDueTime.IsGreaterThan(earliestStartTime)) { earliestStartTime = stockExchangeDemandDueTime; } } } return(earliestStartTime); }