Example #1
0
        private void WriteRows(List <ReportColumnMapping> columnDefinitions, List <SearchResultRow> rows)
        {
            int columnIndex;

            int progressPercent = 0;

            var firstRow = rows.First();

            for (var i = 0; i < rows.Count; i++)
            {
                columnIndex = 1;
                for (var j = 0; j < firstRow.Values.Count; j++)
                {
                    var value = rows[i].Values[j].Value;

                    var columnDefinition = columnDefinitions.First(x => x.Id == rows[i].Values[j].ColumnId);

                    string dataFormat = GetDataFormat(columnDefinition);
                    int    precision  = GetPrecision(columnDefinition);

                    SetCellValue(rowIndex, columnIndex, value, dataFormat, precision);

                    columnIndex++;

                    if (ProgressCallback != null)
                    {
                        progressPercent = (int)((((double)100) / rows.Count) * i);
                        ProgressCallback.Invoke(progressPercent);
                        LoopTimer.Loop();
                    }
                }

                rowIndex++;
            }
        }
Example #2
0
        public void TestLoopTimer3X()
        {
            // This test will fail unless the assembly is marked with the
            // [assembly: CollectionBehavior(DisableTestParallelization = true)]
            // This is because when running tests in parallel, the thread prioritization
            // system behaves unexpectedly. The lesson for end-users is: If you require something
            // to happen at a certain time, make sure that owner of the Timer object is your main thread.
            var ct462 = 0;

            ServiceTimer timer = new LoopTimer(TimeSpan.FromSeconds(0.01));

            timer.AddEvent(
                (s, e) =>
            {
                _output.WriteLine("poke: " + Interlocked.Increment(ref ct462));
            });
            timer.Run();

            var t = Task.Delay(50);

            t.Wait();

            timer.ShutDown();
            _output.WriteLine("Asserting...");
            // TODO: Running local returns 4 as expected; running on AppVeyor returns
            // 12. Presumably running in parallel on steroids?

            ct462.ShouldBeInRange(2, 6);
        }
Example #3
0
        public void Start()
        {
            Skype = new SKYPE4COMLib.Skype();
            Skype.Attach();

            LoopTimer.Start();
        }
Example #4
0
        private void DoTimer(TimeSpan delay)
        {
            if (m_Timer != null)
                m_Timer.Stop();

            m_Timer = new LoopTimer(this, delay);
            m_Timer.Start();
        }
Example #5
0
 /// <summary>
 /// Method <c>Awake</c> called by engine as part of startup process. Used to
 /// initialize important values.
 /// </summary>
 public void Awake()
 {
     rb             = GetComponent <Rigidbody2D>();
     audioSrc       = GetComponent <AudioSource>();
     gameContScript = gameCont.GetComponent <MazeNewGameController>();
     flashTimer     = new LoopTimer(MakeVisible, SwitchVisibility, 0.6f, 0.1f);
     rend           = GetComponent <SpriteRenderer>();
 }
Example #6
0
        public HealthInfo(double displayInterval, int sampleCount)
        {
            DisplayTimer = new LoopTimer(displayInterval);

            OffsetAbsoluteDeviation = new SimpleMovingAverage(0, sampleCount);
            RttAbsoluteDeviation    = new SimpleMovingAverage(0, sampleCount);

            Sent     = 0;
            Received = 0;
        }
        private void ProcessRequestThreadStart(ReportStatus status, SearchRequest request, string filePath)
        {
            try
            {
                // setup
                request.PageSize          = _defaultPageSize;
                status.ProgressPercentage = 0;
                status.StatusMessage      = "Processing";
                UpdateReportStatus(status);

                var dataSource        = _reportsDataSourceFactory.GetDataSource(status.Platform);
                var columnDefinitions = dataSource.GetColumnMappings(request.SelectedColumns);

                var loopTimer = new LoopTimer <ReportStatus>(DateTime.Now, StatusUpdateTimerInterval, x => UpdateReportStatus(x), status);

                // loop through all pages loading the data
                var data = LoadAllData(ref status, request, dataSource, loopTimer);

                // save all the data into a spreadsheet
                using (var renderer = _spreadsheetWriterFactory.NewWriter())
                {
                    status.StatusMessage = "Saving";
                    UpdateReportStatus(status);

                    renderer.LoopTimer        = loopTimer;
                    renderer.ProgressCallback = (i => status.ProgressPercentage = (int)(((double)100 * Configuration.Exports.DataLoadPercent) + ((double)Configuration.Exports.DataSavePercent * i)));

                    renderer.Write(columnDefinitions, data, writeColumnHeaders: true);
                    string fileName = string.Format("report-{0}.xlsx", status.Id);
                    renderer.Save(Path.Combine(filePath, fileName));
                }

                // finish
                status.ProgressPercentage = 100;
                status.DateCompleted      = DateTime.Now;
                status.StatusMessage      = "Complete";
                UpdateReportStatus(status);
            }
            catch (Exception ex)
            {
                // This runs in a separate thread. We can't throw or the whole process will get killed.
                try
                {
                    status.StatusMessage = "Failed";
                    status.ErrorMessage  = ex.Message;
                    status.StackTrace    = ex.StackTrace;
                    status.DateCompleted = DateTime.Now;
                    UpdateReportStatus(status);
                }
                catch (Exception e)
                {
                    // TODO: log
                }
            }
        }
Example #8
0
 private void InitializeGame()
 {
     player       = new Player();
     enemyManager = EnemyManager.GetInstance();
     enemyManager.Initialize();
     projectileManager = ProjectileManager.GetInstance();
     projectileManager.Initialize();
     loopTimer  = LoopTimer.GetInstance();
     timeLogger = TimeLogger.GetInstance();
     Loop();
 }
Example #9
0
 /// <summary>
 /// Starts the TimerViewModel clock and the LoopTimer clock.
 /// Instantiates the LoopTimer with the TimerViewModel's attributes.
 /// </summary>
 public async Task Start()
 {
     clock           = new Timer(100);
     clock.Elapsed  += Sync;
     clock.AutoReset = true;
     clock.Start();
     await Task.Run(() =>
     {
         lt = new LoopTimer(this);
         lt.Start();
     });
 }
Example #10
0
        public ServerTime(ManualLogSource log, Peer server, double interval, Timestamped <PingMessage> seed)
        {
            _log    = log;
            _server = server;

            _pingTimer = new LoopTimer(interval);

            var offset = ProcessPong(seed, out var rtt, out _offsetBounds);

            _offsetAverage = new ExponentialMovingAverage(offset, EMA_ALPHA);
            _rttAverage    = new ExponentialMovingAverage(rtt, EMA_ALPHA);
        }
Example #11
0
        internal H3Client(ManualLogSource log, ClientConfig config, StatefulActivity discord, PeerMessageList <H3Client> messages, byte channelsCount, double tickDeltaTime, Version version, IPEndPoint endpoint, ConnectionRequestMessage request, OnH3ClientDisconnect onDisconnected)
            : base(log, messages, channelsCount, new Events(), version, endpoint, x => x.Put(request))
        {
            _log            = log;
            _config         = config;
            _discord        = discord;
            _onDisconnected = onDisconnected;

            _tickDeltaTime = tickDeltaTime;
            _tickTimer     = new LoopTimer(tickDeltaTime);

            _players = new Dictionary <byte, Puppet>();
            _health  = new HealthInfo(HEALTH_INTERVAL, (int)(HEALTH_INTERVAL / PING_INTERVAL));
        }
Example #12
0
 public Projectile(
     MovementModule movementModule,
     SKBitmap projBitmap,
     Animator animatorExpl,
     float damage
     )
 {
     this.movementModule = movementModule;
     this.projBitmap     = projBitmap;
     this.animatorExpl   = animatorExpl;
     explDuration        = animatorExpl.GetLoopDuration();
     this.damage         = damage;
     friendly            = false;
     loopTimer           = LoopTimer.GetInstance();
 }
Example #13
0
    private void Start()
    {
        float height = Camera.main.orthographicSize * 2;
        float width  = height * Camera.main.aspect;

        viewPort  = new Vector2(width, height);
        xPosition = width * xPercentage - width / 2;

        rend          = GetComponent <SpriteRenderer>();
        spriteHeight  = rend.sprite.bounds.size.y;
        spriteHeight *= transform.localScale.y;

        flashTimer = new LoopTimer(MakeVisible, SwitchVisibility, 0.50f, 0.1f);

        audioSrc = GetComponent <AudioSource>();
    }
Example #14
0
        internal H3Server(ManualLogSource log, HostConfig config, RandomNumberGenerator rng, PeerMessageList <H3Server> messages, byte channelsCount, Version version, double tickDeltaTime, IPEndPoint publicEndPoint)
            : base(log, messages, channelsCount, new Events(messages.Definitions[typeof(Timestamped <PingMessage>)]), version, config.Binding.IPv4.Value, config.Binding.IPv6.Value, config.Binding.Port.Value)
        {
            _log     = log;
            _config  = config;
            _partyID = Key32.FromRandom(rng);

            _tickTimer = new LoopTimer(tickDeltaTime);
            _peerIDs   = new Dictionary <Peer, byte>();
            _husks     = new Dictionary <byte, Husk>();

            _selfID = -1;

            Secret  = new JoinSecret(version, publicEndPoint, Key32.FromRandom(rng), tickDeltaTime);
            HostKey = Key32.FromRandom(rng);
        }
Example #15
0
 public Animator(string resourceString, int nSteps, int stepDuration)
 {
     nStepsPre         = 0;
     nStepsHold        = nSteps;
     nStepsPost        = 0;
     this.stepDuration = stepDuration;
     bitmapsArrayHold  = new SKBitmap[nSteps];
     for (int i = 0; i < nSteps; i++)
     {
         bitmapsArrayHold[i] = Helper.LoadBitmap(
             resourceString + GetStepIdentifierString(i) + ".png"
             );
     }
     loopTimer = LoopTimer.GetInstance();
     //TODO move call out of constructor
     Start();
 }
Example #16
0
 public Enemy(
     float maxHealth,
     MovementModule movementModule,
     WeaponModule weaponModule,
     Animator animatorNormal,
     Animator animatorExpl
     )
 {
     this.maxHealth      = maxHealth;
     health              = maxHealth;
     this.movementModule = movementModule;
     this.weaponModule   = weaponModule;
     this.animatorNormal = animatorNormal;
     this.animatorExpl   = animatorExpl;
     explDuration        = animatorExpl.GetLoopDuration();
     loopTimer           = LoopTimer.GetInstance();
 }
Example #17
0
    private void DoStageSetup()
    {
        //Debug.Log("Difficulty: " + _GlobalVariables.difficulty);
        float waitTime        = difficultyWaitTimes[_GlobalVariables.difficulty];
        float spawnTime       = difficultySpawnRates[_GlobalVariables.difficulty];
        float spawnPeriodTime = spawnTime * (difficultySectionFaces[_GlobalVariables.difficulty] + 1);

        //Added  1 to section faces number to make final "spawn" actually be the switch to restTimer

        currentSection = 0;

        spawnPattern = GetSpawnPattern();
        //Debug.Log("spawnPattern: " + spawnPattern.ToString());
        restTimer  = new LoopTimer(SwitchTimer, waitTime);
        spawnTimer = new LoopTimer(SwitchTimer, SpawnNextFace, spawnPeriodTime, spawnTime);

        currentTimer = restTimer;
        currentTimer.Reset();
    }
Example #18
0
 public WeaponModuleUnit(
     float frequency,
     float damage,
     MovementModule movementTemplate,
     SKBitmap projBitmap,
     Animator animatorExpl
     )
 {
     shootInterval         = 1000 / frequency;
     this.damage           = damage;
     this.movementTemplate = movementTemplate;
     this.projBitmap       = projBitmap;
     this.animatorExpl     = animatorExpl;
     loopTimer             = LoopTimer.GetInstance();
     cooldownStartTime     = loopTimer.GetTotalMs();
     friendly          = false;
     projectileManager = ProjectileManager.GetInstance();
     //fireAudioPlayer =
     //	Helper.LoadAudioPlayer("JetPack.media.samples.laserpew.ogg");
 }
Example #19
0
 public Animator(
     string resourceStringPre,
     string resourceStringHold,
     string resourceStringPost,
     int nStepsPre,
     int nStepsHold,
     int nStepsPost,
     int stepDuration
     )
 {
     this.nStepsPre    = nStepsPre;
     this.nStepsHold   = nStepsHold;
     this.nStepsPost   = nStepsPost;
     this.stepDuration = stepDuration;
     bitmapsArrayPre   = new SKBitmap[nStepsPre];
     bitmapsArrayHold  = new SKBitmap[nStepsHold];
     bitmapsArrayPost  = new SKBitmap[nStepsPost];
     for (int i = 0; i < nStepsPre; i++)
     {
         bitmapsArrayPre[i] = Helper.LoadBitmap(
             resourceStringPre + GetStepIdentifierString(i) + ".png"
             );
     }
     for (int i = 0; i < nStepsHold; i++)
     {
         bitmapsArrayHold[i] = Helper.LoadBitmap(
             resourceStringHold + GetStepIdentifierString(i) + ".png"
             );
     }
     for (int i = 0; i < nStepsPost; i++)
     {
         bitmapsArrayPost[i] = Helper.LoadBitmap(
             resourceStringPost + GetStepIdentifierString(i) + ".png"
             );
     }
     loopTimer = LoopTimer.GetInstance();
 }
Example #20
0
 public Player()
 {
     pos = new SKPoint(
         Settings.Player.startPosX,
         Settings.Player.startPosY
         );
     speed               = 0;
     playerBitmapUp      = Helper.LoadBitmap("JetPack.media.player.up.png");
     playerBitmapDown    = Helper.LoadBitmap("JetPack.media.player.down.png");
     playerBitmapNeutral = Helper.LoadBitmap("JetPack.media.player.neutral.png");
     weaponModuleFactory = WeaponModuleFactory.GetInstance();
     loopTimer           = LoopTimer.GetInstance();
     weapon              = weaponModuleFactory.CreatePlayerWeapon(
         Settings.Player.Weapon.frequency,
         Settings.Player.Weapon.damage,
         Settings.Player.Weapon.projSpeed
         );
     weapon.SetFriendly();
     weapon.active = false;
     jetPackActive = false;
     animatorExpl  = new Animator(
         "JetPack.media.explosions.explosion1_",
         1,
         Settings.Player.explAnimStepDuration
         );
     explDuration    = Settings.Player.explAnimStepDuration * 1;
     animatorJetPack = new Animator(
         "JetPack.media.fire.fire_start_",
         "JetPack.media.fire.fire_hold_",
         "JetPack.media.fire.fire_stop_",
         8,
         23,
         19,
         Settings.Player.jetPackAnimStepDuration
         );
 }
Example #21
0
 private BackAndForthMovUnit()
 {
     loopTimer  = LoopTimer.GetInstance();
     cycleStart = loopTimer.GetTotalMs();
 }
Example #22
0
 public void Stop()
 {
     LoopTimer.Stop();
     Skype = null;
 }
        private List <SearchResultRow> LoadAllData(ref ReportStatus status, SearchRequest request, IReportsDataSource dataSource, LoopTimer <ReportStatus> loopTimer)
        {
            request.PageIndex = 0;
            request.GetCount  = true;

            // get the first page, with a count
            var page = GetPage(request, dataSource);

            var totalRows  = page.Summary.TotalRows;
            var totalPages = (int)Math.Ceiling((double)totalRows / request.PageSize);

            var result = page.Data;

            // getting count could have an impact on performance and is only needed for the first request
            request.GetCount = false;

            while (request.PageIndex + 1 < totalPages)
            {
                request.PageIndex++;
                page = GetPage(request, dataSource);
                if (page != null && page.Data != null && page.Data.Any())
                {
                    result.AddRange(page.Data);
                }

                status.ProgressPercentage = (int)Math.Floor(((double)100 / totalPages) * (request.PageIndex + 1) * Configuration.Exports.DataLoadPercent);

                loopTimer.Loop();
            }

            return(result);
        }
Example #24
0
 private CircularMovUnit()
 {
     loopTimer  = LoopTimer.GetInstance();
     cycleStart = loopTimer.GetTotalMs();
 }
Example #25
0
        private void DoTimer(TimeSpan delay)
        {
            if (this.m_Timer != null)
                this.m_Timer.Stop();

            this.m_Timer = new LoopTimer(this, delay);
            this.m_Timer.Start();
        }
Example #26
0
 private void TimerForm_Load(object sender, EventArgs e)
 {
     LoopTimer.Start();
     this.Size = new Size(168, 32);
 }