Пример #1
0
        public async void RunAsync(int simulationType, int orderAmount, double arivalRate, int estimatedThroughputTime)
        {
            _context.ClearCustomerOrders();

            var simConfig = ArgumentConverter.ConfigurationConverter(resultCtx: _resultCtx, 1);

            // update customized Items
            simConfig.AddOption(new DBConnectionString(_resultCtx.Database.GetDbConnection().ConnectionString));
            simConfig.ReplaceOption(new KpiTimeSpan(240));
            simConfig.ReplaceOption(new TimeToAdvance(value: TimeSpan.FromMilliseconds(50)));
            simConfig.ReplaceOption(new TimeConstraintQueueLength(480));
            simConfig.ReplaceOption(new OrderArrivalRate(value: arivalRate));
            simConfig.ReplaceOption(new OrderQuantity(value: orderAmount));
            simConfig.ReplaceOption(new EstimatedThroughPut(value: estimatedThroughputTime));
            simConfig.ReplaceOption(new TimePeriodForThroughputCalculation(value: 2880));
            simConfig.ReplaceOption(new Seed(value: 169));
            simConfig.ReplaceOption(new SettlingStart(value: 2880));
            simConfig.ReplaceOption(new SimulationEnd(value: 10080));
            simConfig.ReplaceOption(new SaveToDB(value: false));
            simConfig.ReplaceOption(new DebugSystem(value: false));
            simConfig.ReplaceOption(new WorkTimeDeviation(0.2));
            simConfig.ReplaceOption(new MaxDeliveryTime(3120));
            simConfig.ReplaceOption(new MinDeliveryTime(2160));



            switch (simulationType)
            {
            case 1: RunAgentSimulation(simConfig); return;

            case 2: RunGanttSimulation(simConfig); return;

            default: return;
            }
        }
Пример #2
0
        private void PlayerRemote(IntPtr playerpointer, uint eventNameHash, ArgumentsData data)
        {
            var player    = Collections.PlayerCollection[playerpointer];
            var arguments = ArgumentConverter.ConvertToObjects(data);

            _eventManager.CallAsync(new PlayerRemoteEvent(player, eventNameHash, arguments));
        }
Пример #3
0
        public async void RunAsync(int simulationType, int orderAmount, double arivalRate, int estimatedThroughputTime)
        {
            var simKind = SimulationType.None;

            switch (simulationType)
            {
            case 1: simKind = SimulationType.Default; break;

            default: return;
            }
            // using Default Test Values
            var simConfig = ArgumentConverter.ConfigurationConverter(_resultCtx, 1);

            // update customized Items
            simConfig.ReplaceOption(new SimulationKind(value: simKind));
            simConfig.ReplaceOption(new TimeToAdvance(value: TimeSpan.FromMilliseconds(50)));
            simConfig.ReplaceOption(new OrderArrivalRate(value: arivalRate));
            simConfig.ReplaceOption(new OrderQuantity(value: orderAmount));
            simConfig.ReplaceOption(new EstimatedThroughPut(value: estimatedThroughputTime));
            simConfig.ReplaceOption(new KpiTimeSpan(value: 60));
            simConfig.ReplaceOption(new Seed(value: 1337));
            simConfig.ReplaceOption(new SettlingStart(value: 2880));
            simConfig.ReplaceOption(new SimulationEnd(value: 20160));
            simConfig.ReplaceOption(new SaveToDB(value: false));
            simConfig.ReplaceOption(new TimeConstraintQueueLength(480));
            // simConfig.ReplaceOption(new DebugSystem(true));
            // new DBConnectionString(value: "Server=(localdb)\\mssqllocaldb;Database=Master40Results;Trusted_Connection=True;MultipleActiveResultSets=true")

            await _agentSimulator.RunAkkaSimulation(configuration : simConfig);
        }
Пример #4
0
 public bool TryGetValue(
     IValueDescriptor valueDescriptor,
     BindingContext?bindingContext,
     out object?boundValue)
 {
     boundValue = ArgumentConverter.GetDefaultValue(valueDescriptor.ValueType);
     return(true);
 }
        public SwitchlessPropertyParser(int argumentIndex, PropertyInfo propertyInfo, ArgumentConverter converter) : base(propertyInfo)
        {
            if (converter == null)
            {
                throw new ArgumentNullException(nameof(converter));
            }

            this.ArgumentIndex = argumentIndex;
            this._converter    = converter;
        }
Пример #6
0
        public async Task InvokeAsync(uint dimension, ulong nativeHash, IEnumerable <object> arguments)
        {
            Contract.NotNull(arguments, nameof(arguments));

            var data = ArgumentConverter.ConvertFromObjects(arguments);

            await TickScheduler.Instance
            .Schedule(() => Rage.PlayerPool.PlayerPool__InvokeInDimension(_nativePointer, dimension, nativeHash, data, (ulong)data.Length));

            ArgumentData.Dispose(data);
        }
Пример #7
0
        public void SetSharedData(string key, object data)
        {
            Contract.NotEmpty(key, nameof(key));
            CheckExistence();

            using (var converter = new StringConverter())
            {
                var arg = ArgumentConverter.ConvertFromObject(data);

                Rage.Entity.Entity_SetVariable(NativePointer, converter.StringToPointer(key), ref arg);
            }
        }
Пример #8
0
        public async Task InvokeAsync(ulong nativeHash, IEnumerable <object> arguments)
        {
            Contract.NotNull(arguments, nameof(arguments));
            CheckExistence();

            var data = ArgumentConverter.ConvertFromObjects(arguments);

            await TickScheduler.Instance
            .Schedule(() => Rage.Player.Player__Invoke(NativePointer, nativeHash, data, (ulong)data.Length))
            .ConfigureAwait(false);

            ArgumentData.Dispose(data);
        }
Пример #9
0
        public void BackgroundSimulation(int simulationId, int simNumber, PerformContext consoleContext)
        {
            _messageHub = new ProcessingHub(consoleContext);
            // _messageHub.StartSimulation(simId: simulationId.ToString() , simNumber: simNumber.ToString());
            var simConfig = ArgumentConverter.ConfigurationConverter(_resultContext, simulationId);

            simConfig.AddOption(new DBConnectionString(ConfigurationManager.AppSettings[RESULT_CONNECTION]));
            simConfig.Remove(typeof(SimulationNumber));
            simConfig.AddOption(new SimulationNumber(simNumber));

            RunAkkaSimulation(simConfig).Wait();
            // _messageHub.EndSimulation("Succ", simId: simulationId.ToString() , simNumber: simNumber.ToString());
        }
Пример #10
0
        public async Task InvokeAsync(IEnumerable <IPlayer> players, ulong nativeHash, IEnumerable <object> arguments)
        {
            Contract.NotNull(players, nameof(players));
            Contract.NotNull(arguments, nameof(arguments));

            var data           = ArgumentConverter.ConvertFromObjects(arguments);
            var playerPointers = players.Select(x => x.NativePointer).ToArray();

            await TickScheduler.Instance
            .Schedule(() => Rage.PlayerPool.PlayerPool__InvokeFor(_nativePointer, playerPointers, (ulong)playerPointers.Length, nativeHash, data, (ulong)data.Length));

            ArgumentData.Dispose(data);
        }
Пример #11
0
        public bool TryGetSharedData(string key, out object data)
        {
            Contract.NotEmpty(key, nameof(key));
            CheckExistence();

            using (var converter = new StringConverter())
            {
                var argument = Rage.Entity.Entity_GetVariable(NativePointer, converter.StringToPointer(key));

                data = ArgumentConverter.ConvertToObject(StructConverter.PointerToStruct <ArgumentData>(argument));

                return(data != null);
            }
        }
Пример #12
0
        private void ParseOptionArguments(OptionNode optionNode)
        {
            var argument = optionNode.Option.Argument;

            var contiguousTokens   = 0;
            var continueProcessing = true;

            while (More() &&
                   CurrentToken.Type == TokenType.Argument &&
                   continueProcessing)
            {
                if (IsFull(argument))
                {
                    if (contiguousTokens > 0)
                    {
                        return;
                    }

                    if (argument.Arity.MaximumNumberOfValues == 0)
                    {
                        return;
                    }
                }
                else if (argument.ValueType == typeof(bool))
                {
                    if (ArgumentConverter.ConvertObject(
                            argument,
                            argument.ValueType,
                            CurrentToken.Value,
                            _configuration.Resources) is FailedArgumentTypeConversionResult)
                    {
                        return;
                    }
                }

                optionNode.AddChildNode(
                    new OptionArgumentNode(
                        CurrentToken,
                        argument,
                        optionNode));

                IncrementCount(argument);

                contiguousTokens++;

                Advance();

                continueProcessing = optionNode.Option.AllowMultipleArgumentsPerToken;
            }
        }
Пример #13
0
        static void Main(string[] args)
        {
            Console.WriteLine(value: "Welcome to AkkaSim Cli");

            // has to be Installed here other wise it would attach a new log listener every time a simulation is called.
            LogConfiguration.LogTo(TargetTypes.Console, TargetNames.LOG_AGENTS, LogLevel.Info, LogLevel.Info);
            //LogConfiguration.LogTo(TargetTypes.File, TargetNames.LOG_AGENTS, LogLevel.Debug, LogLevel.Debug);
            //LogConfiguration.LogTo(TargetTypes.File, TargetNames.LOG_AKKA, LogLevel.Trace);
            //LogConfiguration.LogTo(TargetTypes.Console, TargetNames.LOG_AKKA, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AKKA, LogLevel.Warn);

            var masterDb      = ProductionDomainContext.GetContext(ConfigurationManager.AppSettings[AgentCore.DEFAULT_CONNECTION]);
            var validCommands = Commands.GetAllValidCommands;
            var command       = validCommands.Single(predicate: x => x.ArgLong == "Help");
            var lastArg       = 0;
            var config        = new SimulationCore.Environment.Configuration();

            for (; lastArg < args.Length; lastArg++)
            {
                if (args[lastArg] == "-?" || args[lastArg] == "/?")
                {
                    command.Action(arg1: null, arg2: null);
                    return;
                }

                if (ArgumentConverter.IsArg(validCommands: validCommands, argument: args[lastArg], command: ref command))
                {
                    if (command.HasProperty)
                    {
                        lastArg++;
                        command.Action(arg1: config, arg2: args[lastArg]);
                    }
                    else
                    {
                        command.Action(arg1: config, arg2: null);
                    }
                }
            }

            if (config.TryGetValue(typeof(StartHangfire), out object startHangfire))
            {
                StartHangfire(((StartHangfire)startHangfire).Silent).Wait();
            }
            else
            {
                RunSimulationTask(masterDb: masterDb, config: config).Wait();
                Console.WriteLine(value: "Simulation Run Finished.");
            }
        }
Пример #14
0
        public async Task CallAsync(Vector3 position, float range, uint dimension, string eventName, IEnumerable <object> arguments)
        {
            Contract.NotEmpty(eventName, nameof(eventName));
            Contract.NotNull(arguments, nameof(arguments));

            var data = ArgumentConverter.ConvertFromObjects(arguments);

            using (var converter = new StringConverter())
            {
                var eventNamePointer = converter.StringToPointer(eventName);

                await TickScheduler.Instance.Schedule(() => Rage.PlayerPool.PlayerPool__CallInRange(_nativePointer, position, range, dimension, eventNamePointer, data, (ulong)data.Length));
            }

            ArgumentData.Dispose(data);
        }
Пример #15
0
        private void ParseOptionArguments(OptionNode optionNode)
        {
            var argument = optionNode.Option.Argument;

            var contiguousTokens = 0;

            while (More() &&
                   CurrentToken.Type == TokenType.Argument)
            {
                if (IsFull(argument))
                {
                    if (contiguousTokens > 0)
                    {
                        return;
                    }

                    if (argument.Arity.MaximumNumberOfValues == 0)
                    {
                        return;
                    }
                }
                else if (argument.Type == typeof(bool))
                {
                    if (ArgumentConverter.ConvertObject(
                            argument,
                            argument.Type,
                            CurrentToken.Value) is FailedArgumentTypeConversionResult)
                    {
                        return;
                    }
                }

                optionNode.AddChildNode(
                    new OptionArgumentNode(
                        CurrentToken,
                        argument,
                        optionNode));

                IncrementCount(argument);

                contiguousTokens++;

                Advance();
            }
        }
Пример #16
0
        public async Task CallClientAsync(string eventName, IEnumerable <object> arguments)
        {
            Contract.NotEmpty(eventName, nameof(eventName));
            Contract.NotNull(arguments, nameof(arguments));
            CheckExistence();

            var data = ArgumentConverter.ConvertFromObjects(arguments);

            using (var converter = new StringConverter())
            {
                var eventNamePointer = converter.StringToPointer(eventName);

                await TickScheduler.Instance
                .Schedule(() => Rage.Player.Player__Call(NativePointer, eventNamePointer, data, (ulong)data.Length))
                .ConfigureAwait(false);
            }

            ArgumentData.Dispose(data);
        }
Пример #17
0
        internal Plugin(IntPtr multiplayer)
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
            MP.Setup(this);

            NativeMultiplayer = multiplayer;
            _mainThreadId     = Thread.CurrentThread.ManagedThreadId;
            _taskScheduler    = new RageTaskScheduler();
            _resourceLoader   = new ResourceLoader(this);

            ArgumentConverter = new ArgumentConverter(this);

            Logger         = new Logger(this);
            EventScripting = new EventScripting(this);
            Commands       = new Commands(this);
            Utility        = new Utility(this);

            PlayerPool     = CreateNativeManager <PlayerPool>(Rage.Multiplayer.Multiplayer_GetPlayerPool);
            VehiclePool    = CreateNativeManager <VehiclePool>(Rage.Multiplayer.Multiplayer_GetVehiclePool);
            BlipPool       = CreateNativeManager <BlipPool>(Rage.Multiplayer.Multiplayer_GetBlipPool);
            CheckpointPool = CreateNativeManager <CheckpointPool>(Rage.Multiplayer.Multiplayer_GetCheckpointPool);
            ColshapePool   = CreateNativeManager <ColshapePool>(Rage.Multiplayer.Multiplayer_GetColshapePool);
            MarkerPool     = CreateNativeManager <MarkerPool>(Rage.Multiplayer.Multiplayer_GetMarkerPool);
            ObjectPool     = CreateNativeManager <ObjectPool>(Rage.Multiplayer.Multiplayer_GetObjectPool);
            TextLabelPool  = CreateNativeManager <TextLabelPool>(Rage.Multiplayer.Multiplayer_GetLabelPool);

            Config = CreateNativeManager <Config>(Rage.Multiplayer.Multiplayer_GetConfig);
            World  = CreateNativeManager <World>(Rage.Multiplayer.Multiplayer_GetWorld);

            _entityPoolMapping = new Dictionary <EntityType, IInternalPool>
            {
                { EntityType.Player, PlayerPool },
                { EntityType.Vehicle, VehiclePool },
                { EntityType.Blip, BlipPool },
                { EntityType.Checkpoint, CheckpointPool },
                { EntityType.Colshape, ColshapePool },
                { EntityType.Marker, MarkerPool },
                { EntityType.Object, ObjectPool },
                { EntityType.TextLabel, TextLabelPool }
            };
        }
        internal static ArgumentResult GetValueAs(
            this ArgumentResult result,
            Type type)
        {
            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            if (!(result is SuccessfulArgumentResult successful))
            {
                return(result);
            }

            if (type.IsInstanceOfType(successful.Value))
            {
                return(result);
            }

            return(ArgumentConverter.Parse(result.Argument, type, successful.Value));
        }
Пример #19
0
        public void SetSharedData(IDictionary <string, object> data)
        {
            Contract.NotNull(data, nameof(data));
            CheckExistence();

            using (var converter = new StringConverter())
            {
                var keys   = new IntPtr[data.Count];
                var values = new ArgumentData[data.Count];

                var index = 0;
                foreach (var element in data)
                {
                    keys[index]   = converter.StringToPointer(element.Key);
                    values[index] = ArgumentConverter.ConvertFromObject(element.Value);

                    index++;
                }

                Rage.Entity.Entity_SetVariables(NativePointer, keys, values, (ulong)data.Count);
            }
        }
Пример #20
0
        public async Task CallAsync(IEnumerable <IPlayer> players, string eventName, IEnumerable <object> arguments)
        {
            Contract.NotNull(players, nameof(players));
            Contract.NotEmpty(eventName, nameof(eventName));
            Contract.NotNull(arguments, nameof(arguments));

            var data           = ArgumentConverter.ConvertFromObjects(arguments);
            var playerPointers = players.Select(x => x.NativePointer).ToArray();

            if (playerPointers.Any() == false)
            {
                return;
            }

            using (var converter = new StringConverter())
            {
                var eventNamePointer = converter.StringToPointer(eventName);

                await TickScheduler.Instance
                .Schedule(() => Rage.PlayerPool.PlayerPool__CallFor(_nativePointer, playerPointers, (ulong)playerPointers.Length, eventNamePointer, data, (ulong)data.Length));
            }

            ArgumentData.Dispose(data);
        }
Пример #21
0
        public void RunProduction(int uniqueSimNum, int orderQuantity, ModelSize resourceModelSize,
                                  ModelSize setupModelSize, ModelSize operatorModelSize, int numberOfWorkers, bool secondResource)
        {
            LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Info, LogLevel.Info);
            LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Debug, LogLevel.Debug);
            _testOutputHelper.WriteLine("DatabaseString: " + _contextDataBase.ConnectionString.Value);

            _testOutputHelper.WriteLine("ResultDatabaseString: " + _resultContextDataBase.ConnectionString.Value);
            //Handle this one in our Resource Model?
            MasterDBInitializerTruck.DbInitialize(_contextDataBase.DbContext, resourceModelSize, setupModelSize,
                                                  operatorModelSize, numberOfWorkers, secondResource);
            _testOutputHelper.WriteLine("MasterDBInitialized finished");
            ResultDBInitializerBasic.DbInitialize(_resultContextDataBase.DbContext);
            _testOutputHelper.WriteLine("ResultDBInitializerBasic finished");
            var messageHub = new ConsoleHub();
            var simContext = new AgentSimulation(DBContext: _contextDataBase.DbContext, messageHub: messageHub);
            var simConfig  = ArgumentConverter.ConfigurationConverter(_resultContextDataBase.DbContext, 1);

            _testOutputHelper.WriteLine("ArgumentConverter finished");

            simConfig.ReplaceOption(new DBConnectionString(_resultContextDataBase.ConnectionString.Value));
            simConfig.ReplaceOption(new TimeToAdvance(new TimeSpan(0L)));
            simConfig.ReplaceOption(new KpiTimeSpan(240));
            simConfig.ReplaceOption(new DebugAgents(true));
            simConfig.ReplaceOption(new MinDeliveryTime(1440));
            simConfig.ReplaceOption(new MaxDeliveryTime(2880));
            simConfig.ReplaceOption(new TransitionFactor(3));
            simConfig.ReplaceOption(new SimulationKind(value: SimulationType.Default));
            simConfig.ReplaceOption(new OrderArrivalRate(value: 0.15));
            simConfig.ReplaceOption(new OrderQuantity(value: orderQuantity));
            simConfig.ReplaceOption(new EstimatedThroughPut(value: 1920));
            simConfig.ReplaceOption(new TimePeriodForThroughputCalculation(value: 2880));
            simConfig.ReplaceOption(new Seed(value: 1337));
            simConfig.ReplaceOption(new SettlingStart(value: 0));
            simConfig.ReplaceOption(new SimulationEnd(value: 4380));
            simConfig.ReplaceOption(new SaveToDB(value: true));
            simConfig.ReplaceOption(new MaxBucketSize(value: 480));
            simConfig.ReplaceOption(new SimulationNumber(value: uniqueSimNum));
            simConfig.ReplaceOption(new DebugSystem(value: true));
            simConfig.ReplaceOption(new WorkTimeDeviation(0.0));
            simConfig.ReplaceOption(new TimeConstraintQueueLength(480));

            var simulation = simContext.InitializeSimulation(configuration: simConfig).Result;

            _testOutputHelper.WriteLine("simContext.InitializeSimulation finished");

            var sim = simulation.RunAsync();

            _testOutputHelper.WriteLine("simulation.RunAsync() finished");
            Within(TimeSpan.FromSeconds(120), async() =>
            {
                simContext.StateManager.ContinueExecution(simulation);
                await sim;
            }).Wait();

            var processedOrders =
                _resultContextDataBase.DbContext.Kpis
                .Single(x => x.IsFinal.Equals(true) && x.Name.Equals("OrderProcessed")).Value;

            Assert.Equal(orderQuantity, processedOrders);

            Assert.False(AnyOverlappingTaskItemsExistsOnOneMachine());

            foreach (var obj in messageHub.Logs)
            {
                dynamic guardChildCounter = JsonConvert.DeserializeObject(obj);
                Assert.Equal(0, int.Parse(guardChildCounter[1].Value));
            }

            _contextDataBase.DbContext.Dispose();
            _resultContextDataBase.DbContext.Dispose();
        }
Пример #22
0
 public CustomValueSwitchParser(PropertyInfo propertyInfo, CommandOptionCustomValueSwitchAttribute optionCustomValueAtt, ArgumentConverter converter) : base(propertyInfo, optionCustomValueAtt.CommandLiterals)
 {
     this._converter = converter;
 }
Пример #23
0
 public void Setup()
 {
     _converter = new ArgumentConverter();
 }
Пример #24
0
        public void ConvertIncludesArgNameAndValue()
        {
            var converter = new ArgumentConverter();

            Assert.AreEqual("-preset medium", converter.Convert("-preset", "medium"));
        }
Пример #25
0
        public async Task SystemTestAsync(int approachId
                                          , int orderQuantity
                                          , int maxBucketSize
                                          , long throughput
                                          , int seed
                                          , double arrivalRate
                                          , long simulationEnd)
        {
            ResultContext           ctxResult  = ResultContext.GetContext(resultCon: testResultCtxString);
            ProductionDomainContext masterCtx  = ProductionDomainContext.GetContext(testCtxString);
            DataGeneratorContext    dataGenCtx = DataGeneratorContext.GetContext(testGeneratorCtxString);

            var approach  = ApproachRepository.GetApproachById(dataGenCtx, approachId);
            var generator = new MainGenerator();
            await Task.Run(() =>
                           generator.StartGeneration(approach, masterCtx, ctxResult));

            var simContext = new AgentSimulation(DBContext: masterCtx, messageHub: new ConsoleHub());
            var simConfig  = ArgumentConverter.ConfigurationConverter(ctxResult, 1);

            //LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Trace, LogLevel.Trace);
            LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Info, LogLevel.Info);
            //LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Debug, LogLevel.Debug);
            //LogConfiguration.LogTo(TargetTypes.Debugger, CustomLogger.PRIORITY, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.File, CustomLogger.SCHEDULING, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.File, CustomLogger.DISPOPRODRELATION, LogLevel.Debug, LogLevel.Debug);
            //LogConfiguration.LogTo(TargetTypes.Debugger, CustomLogger.PROPOSAL, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.Debugger, CustomLogger.INITIALIZE, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.Debugger, CustomLogger.JOB, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.File, CustomLogger.ENQUEUE, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.Debugger, CustomLogger.JOBSTATE, LogLevel.Warn, LogLevel.Warn);
            //LogConfiguration.LogTo(TargetTypes.File, TargetNames.LOG_AKKA, LogLevel.Trace, LogLevel.Trace);
            //LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AKKA, LogLevel.Warn);

            var dataGenSim = new DB.GeneratorModel.Simulation();

            dataGenSim.ApproachId = approachId;
            dataGenSim.StartTime  = DateTime.Now;
            await Task.Run(() =>
            {
                dataGenCtx.Simulations.AddRange(dataGenSim);
                dataGenCtx.SaveChanges();
            });

            // update customized Configuration
            simConfig.AddOption(new DBConnectionString(testResultCtxString));
            simConfig.ReplaceOption(new TimeConstraintQueueLength(480));
            simConfig.ReplaceOption(new OrderArrivalRate(value: arrivalRate));
            simConfig.ReplaceOption(new OrderQuantity(value: orderQuantity));
            simConfig.ReplaceOption(new EstimatedThroughPut(value: throughput));
            simConfig.ReplaceOption(new TimePeriodForThroughputCalculation(value: 2880));
            simConfig.ReplaceOption(new Seed(value: seed));
            simConfig.ReplaceOption(new SettlingStart(value: 0));
            simConfig.ReplaceOption(new SimulationEnd(value: simulationEnd));
            simConfig.ReplaceOption(new SaveToDB(value: true));
            simConfig.ReplaceOption(new MaxBucketSize(value: maxBucketSize));
            simConfig.ReplaceOption(new SimulationNumber(value: dataGenSim.Id));
            simConfig.ReplaceOption(new DebugSystem(value: true));
            simConfig.ReplaceOption(new WorkTimeDeviation(0.0));
            // anpassen der Lieferzeiten anhand der Erwarteten Durchlaufzeit.
            simConfig.ReplaceOption(new MinDeliveryTime(80));
            simConfig.ReplaceOption(new MaxDeliveryTime(150));

            await Task.Run(() =>
                           ArgumentConverter.ConvertBackAndSave(ctxResult, simConfig, dataGenSim.Id));

            var simulation = await simContext.InitializeSimulation(configuration : simConfig);


            if (simulation.IsReady())
            {
                // Start simulation
                var sim = simulation.RunAsync();
                simContext.StateManager.ContinueExecution(simulation);
                await sim;
                dataGenSim.FinishTime           = DateTime.Now;
                dataGenSim.FinishedSuccessfully = sim.IsCompletedSuccessfully;
                await Task.Run(() =>
                               dataGenCtx.SaveChanges());

                System.Diagnostics.Debug.WriteLine("################################# Simulation has finished with number " + dataGenSim.Id);
                Assert.True(condition: sim.IsCompleted);
            }
        }
Пример #26
0
        //[InlineData(SimulationType.DefaultSetup, 1, Int32.MaxValue, 1920, 169, ModelSize.Small, ModelSize.Small)]
        public async Task CentralSystemTest()
        {
            //LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Trace, LogLevel.Trace);
            LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Info, LogLevel.Info);
            //LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Debug, LogLevel.Debug);
            LogConfiguration.LogTo(TargetTypes.Debugger, TargetNames.LOG_AGENTS, LogLevel.Warn, LogLevel.Warn);

            var simtulationType = SimulationType.Central;
            var seed            = 169;
            var throughput      = 1920;
            var arrivalRate     = 0.015;

            //Create Master40Data
            var masterPlanContext = ProductionDomainContext.GetContext(masterCtxString);

            masterPlanContext.Database.EnsureDeleted();
            masterPlanContext.Database.EnsureCreated();
            MasterDBInitializerTruck.DbInitialize(masterPlanContext, ModelSize.Medium, ModelSize.Medium, ModelSize.Small, 3, false);

            //CreateMaster40Result
            var masterPlanResultContext = ResultContext.GetContext(masterResultCtxString);

            masterPlanResultContext.Database.EnsureDeleted();
            masterPlanResultContext.Database.EnsureCreated();
            ResultDBInitializerBasic.DbInitialize(masterPlanResultContext);

            //Reset GanttPLan DB?
            var ganttPlanContext = GanttPlanDBContext.GetContext(GanttPlanCtxString);

            ganttPlanContext.Database.ExecuteSqlRaw("EXEC sp_MSforeachtable 'DELETE FROM ? '");

            //Synchronisation GanttPlan
            GanttPlanOptRunner.RunOptAndExport("Init");

            var simContext = new GanttSimulation(GanttPlanCtxString, masterCtxString, messageHub: new ConsoleHub());
            var simConfig  = ArgumentConverter.ConfigurationConverter(masterPlanResultContext, 1);

            // update customized Items
            simConfig.AddOption(new DBConnectionString(masterResultCtxString));
            simConfig.ReplaceOption(new KpiTimeSpan(240));
            simConfig.ReplaceOption(new TimeConstraintQueueLength(480));
            simConfig.ReplaceOption(new SimulationKind(value: simtulationType));
            simConfig.ReplaceOption(new OrderArrivalRate(value: arrivalRate));
            simConfig.ReplaceOption(new OrderQuantity(value: 141));
            simConfig.ReplaceOption(new EstimatedThroughPut(value: throughput));
            simConfig.ReplaceOption(new TimePeriodForThroughputCalculation(value: 4000));
            simConfig.ReplaceOption(new Seed(value: seed));
            simConfig.ReplaceOption(new SettlingStart(value: 2880));
            simConfig.ReplaceOption(new SimulationEnd(value: 10080));
            simConfig.ReplaceOption(new SaveToDB(value: true));
            simConfig.ReplaceOption(new DebugSystem(value: false));
            simConfig.ReplaceOption(new WorkTimeDeviation(0.2));

            var simulation = await simContext.InitializeSimulation(configuration : simConfig);

            //emtpyResultDBbySimulationNumber(simNr: simConfig.GetOption<SimulationNumber>());

            var simWasReady = false;

            if (simulation.IsReady())
            {
                // set for Assert
                simWasReady = true;
                // Start simulation
                var sim = simulation.RunAsync();
                simContext.StateManager.ContinueExecution(simulation);
                await sim;
            }

            Assert.True(condition: simWasReady);
        }
 /// <inheritdoc />
 public object?GetDefaultValue() => ArgumentConverter.GetDefaultValue(ValueType);
Пример #28
0
 /// <inheritdoc />
 public object?GetDefaultValue() =>
 _parameterInfo.DefaultValue is DBNull
         ? ArgumentConverter.GetDefaultValue(ValueType)
         : _parameterInfo.DefaultValue;
Пример #29
0
 private BaseSwitchPropertyParser BuildValueOptionParser(PropertyInfo propertyInfo, CommandOptionCustomValueSwitchAttribute optionCustomValueAtt, object[] attributes, ArgumentConverter converter)
 {
     return(new CustomValueSwitchParser(propertyInfo, optionCustomValueAtt, converter));
 }