Example #1
0
 public Bot(IReadOnlyList <Command> genome, EmulationConfig config, int generationNumber = 1)
 {
     this.config      = config;
     Genome           = genome;
     GenerationNumber = generationNumber;
     Health           = config.BotInitialHealth;
 }
Example #2
0
        private void Emulate()
        {
            _cts = new CancellationTokenSource();
            if (string.IsNullOrEmpty(_fileName) && _file.Length == 0)
            {
                MessageBox.Show("Le chemin vers le fichier log est vide", "Attention", MessageBoxButton.OK,
                                MessageBoxImage.Warning);
                return;
            }

            Logs.Clear();
            // ReSharper disable once ComplexConditionExpression
            var t = new Task(() =>
            {
                var config = new EmulationConfig
                {
                    BoxNumber     = _boxNumber,
                    IpAddress     = _ipAddress,
                    Port          = _port,
                    SleepPeriod   = _sleepPeriod * 1000,
                    SourceOfImeIs = _sourceOfImeIs
                };
                if (_sourceOfImeIs == SourceOfIMEIs.OneIMEI)
                {
                    if (string.IsNullOrEmpty(_imei))
                    {
                        MessageBox.Show("Le champs IMEI est requis", "Attention", MessageBoxButton.OK,
                                        MessageBoxImage.Warning);
                        return;
                    }

                    config.IMEIs = new[] { _imei };
                }
                TeltonikaPacketEncoder.UpdateLogDataGird += log =>
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        if (!Logs.Any(x => x.Equals(log)))
                        {
                            Logs.Add(log);
                        }
                    });
                };
                // extracting and parsing and encoding  avl data.
                var encodedData = (!string.IsNullOrEmpty(_fileName))?
                                  TeltonikaPacketEncoder.Encoding(AvlDataParser.ParseAvlData(_fileName)):
                                  TeltonikaPacketEncoder.Encoding(AvlDataParser.ParseAvlData(_file));
                // launch the emulation
                var emulator = new Emulator();
                emulator.UpdateLogDataGird += log =>
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        if (!Logs.Any(x => x.Equals(log)))
                        {
                            Logs.Add(log);
                        }
                    });
                };

                emulator.Emulate(config, encodedData, _cts.Token);
            });

            t.Start();
        }
Example #3
0
 [DllImport(DllPath)] public static extern void SetEmulationConfig(EmulationConfig config);
Example #4
0
 public DefaultMapFiller(EmulationConfig config, Random random)
 {
     this.config = config;
     this.random = random;
 }
Example #5
0
 public DefaultMapProvider(EmulationConfig config)
 {
     this.config = config;
 }
 public DefaultGenerationBuilder(EmulationConfig config, IGenomeBuilder genomeBuilder)
 {
     this.config        = config;
     this.genomeBuilder = genomeBuilder;
 }
Example #7
0

        
Example #8
0
 public UnconditionalJumpCommandFactory(EmulationConfig config) => SubtypesCount = config.GenomeSize / 2;
Example #9
0
 public DefaultGenomeBuilder(ICommandsCollection availableCommands, EmulationConfig config, Random random)
 {
     this.availableCommands = availableCommands;
     this.config            = config;
     this.random            = random;
 }