Esempio n. 1
0
 private void RunTimer_Tick(object sender, EventArgs e)
 {
     // this timer keeps the mount in position while it is waiting for the satellite to pass
     if (nextAos < DateTime.Now.Add(new TimeSpan(offsetHours, offsetMins, 1)) && nextAos > DateTime.Now.Add(new TimeSpan(offsetHours, offsetMins, -1))) // need to include a tolerence
     {
         sdx = 0;
         ImageTimer.Start();
         RunTimer.Stop();
     }
     else if (nextAos < DateTime.Now.Add(new TimeSpan(offsetHours, offsetMins, 0)))
     {
         RunTimer.Stop();
         lbTargetLocked.Text = "Missed image";
         trackSatellites();
     }
     else
     {
         lbTargetLocked.Text = "Awaiting frame";
         lbTime.Text         = DateTime.Now.Add(new TimeSpan(offsetHours, offsetMins, 0)).ToString();
     }
 }
Esempio n. 2
0
        // sets CurrentAction, PreviousAction, ImagePath
        // should be called often
        public void Advance(float x, float y)
        {
            // detect movement
            var action = DetectMovement(x, y);

            // detect if we are idle
            if (IdleTimer.ElapsedMilliseconds > IdleLimit)
            {
                action = ChangeAction(MotionAction.Idle);
                IdleTimer.Stop();
            }

            // get the relevant image
            ImageSet set = default(ImageSet);

            if (!ImageSets.TryGetValue(CurrentAction, out set))
            {
                throw new Exception("Failed to get images for action : " + CurrentAction);
            }
            var index = ImageIndex % set.Images.Length;

            Image = set.Images[index].Image;

            // advance
            if (ImageTimer.ElapsedMilliseconds > set.PerImageLimit)
            {
                if (index == 0)
                {
                    ImageIndex = 1;
                }
                else
                {
                    ImageIndex++;
                }
                ImageTimer.Stop(); ImageTimer.Reset(); ImageTimer.Start();
            }
        }