Пример #1
0
    private void GunTrackOn()
    {
      if (cameraWindow1.Camera != null && cameraWindow1.Camera.MotionDetector != null)
      {

        //sentry activated sound    
        if (soundOn)
        {
          PlaySound(pwd + "\\Sounds\\Sentry Sounds\\Bootup\\sentry_mode_activated.wav", IntPtr.Zero, SoundFlags.SND_FILENAME | SoundFlags.SND_ASYNC);
        }

        TrackingTimer.Start();
        aimDot.Visible = true;
        //servos = new Servos(1600, 1477, cameraWindow1.Width / 2, cameraWindow1.Height / 2);
        //servos = new Servos(1600, 1477);

        GunTrackButton.Text = "ON";
        GunTrackButton.BackColor = Color.Green;
        GunFireButton.Enabled = true;
        MotionDetectionButton.Enabled = false;
      }
      else
      {
        MessageBox.Show("No Active Camera w/ Active Motion Detector!");
      }
    }
Пример #2
0
        public async Task <Result> ActionAsync(string inquiryNumber)
        {
            _track ??= new Tracking();

            if (_config == null)
            {
                _config = new Config();
                _config = _config.GetConfig();

                if (_config == null)
                {
                    return(new Result
                    {
                        Status = ResultStatus.FailedOnApp,
                        Message = $"PostTrackingのコンフィグファイル読み込みに失敗しました。"
                    });
                }
            }

            var trackTime = new TrackingTimer(inquiryNumber, Elapsed);

            _timerList.Add(trackTime);

            return(new Result
            {
                Status = ResultStatus.SuccessOnAppHasMessage,
                Message = $"配送番号{inquiryNumber}の配送監視を設定しました。"
            });
        }
Пример #3
0
        /**
         * ビューがアンロードロードされたときのクリーンアップ処理
         */
        private void OnUnloaded(object sender, RoutedEventArgs e)
        {
            TrackingTimer.Stop();

            Ready = false;
            mPlayerElement.SetMediaPlayer(null);
            mPlayer.Pause();
            mPlayer.PlaybackSession.PlaybackStateChanged -= PBS_StateChanged;
            mPlayer.MediaFailed -= MP_Failed;
            mPlayer.Dispose();
            mPlayer = null;
        }
Пример #4
0
    private void GunTrackOff()
    {
      GunTrackButton.Text = "OFF";
      GunTrackButton.BackColor = Color.Red;
      GunFireButton.Enabled = false;
      MotionDetectionButton.Enabled = true;

      TrackingTimer.Stop();
      aimDot.Visible = false;

      //Packet packet = new Packet(servos.CenterServosPosition);
      //packet.setFireOff();
      //sendData(packet);

    }
Пример #5
0
            public override void OnResponse(NetState state, int index)
            {
                if (m_List == null || index < 0 || index >= m_List.Count)
                {
                    return;
                }

                Mobile m = m_List[index] as Mobile;

                if (m == null || m.Deleted)
                {
                    return;
                }

                Timer timer = m_Table[m] as Timer;

                if (timer != null && timer.Running)
                {
                    timer.Stop();
                }
                m_Table[m] = timer = new TrackingTimer(m, state.Mobile);
                timer.Start();
            }
Пример #6
0
    //Timer that tracks refresh of position tracking
    private void TrackingTimer_Tick(object sender, EventArgs e) //125ms refresh rate as of right now
    {
      if (cameraWindow1.Camera != null && cameraWindow1.Camera.MotionDetector != null)
      {
        CountingMotionDetector cmd = (CountingMotionDetector)cameraWindow1.Camera.MotionDetector;
        Rectangle[] rectmotion = cmd.ObjectRectangles;

        if (rectmotion.Length != 0)
        {
          if (!firingsoundplayed && soundOn)
          {
            switch (soundTracker % 4)
            {
              case 0:
                PlaySound(pwd + "\\Sounds\\Sentry Sounds\\Target Found\\firing.wav", IntPtr.Zero, SoundFlags.SND_FILENAME | SoundFlags.SND_ASYNC);
                firingsoundplayed = true;
                break;
              case 1:
                PlaySound(pwd + "\\Sounds\\Sentry Sounds\\Target Found\\i_see_you.wav", IntPtr.Zero, SoundFlags.SND_FILENAME | SoundFlags.SND_ASYNC);
                firingsoundplayed = true;
                break;
              case 2:
                PlaySound(pwd + "\\Sounds\\Sentry Sounds\\Target Found\\target_acquired.wav", IntPtr.Zero, SoundFlags.SND_FILENAME | SoundFlags.SND_ASYNC);
                firingsoundplayed = true;
                break;
              case 3:
                PlaySound(pwd + "\\Sounds\\Sentry Sounds\\Target Found\\there_you_are.wav", IntPtr.Zero, SoundFlags.SND_FILENAME | SoundFlags.SND_ASYNC);
                firingsoundplayed = true;
                break;
            }
          }
          ceasefiringsoundplayed = false;
          aimDot.BackColor = Color.Red;
          //aimDot.Visible = true;
          //calculate largest detected motion area
          Rectangle largest = rectmotion[0];
          for (int i = 1; i < rectmotion.Length; i++)
          {
            if (rectmotion[i].Width * rectmotion[i].Height > largest.Width * largest.Height)
            {
              largest = rectmotion[i];
            }
          }

          //get center of largest motion area
          int x = largest.X + largest.Width / 2 + cameraWindow1.Location.X;
          int y = largest.Y + largest.Height / 2 + cameraWindow1.Location.Y;

          //calculate difference from last center point and adjust target lead depending on speed
          if (lastCenterPosition.IsEmpty)
          {
            lastCenterPosition = new Point(x, y);
            lastLeadingPosition = new Point(lastCenterPosition.X, lastCenterPosition.Y);
          }
          else if (!lastCenterPosition.IsEmpty)
          {
            int xdiff = x - lastCenterPosition.X;
            int ydiff = y - lastCenterPosition.Y;
            lastLeadingPosition = new Point(x + multiplier*xdiff, y + ydiff);
            lastCenterPosition = new Point(x, y);
            Console.WriteLine(xdiff.ToString());
          }

          //set aimdot location
          aimDot.Location = new Point(lastLeadingPosition.X - 2, lastLeadingPosition.Y - 2);

          //create packet, set servo position, and fire
          servos.SetPorportionalMathPosition(cameraWindow1.Bounds, lastLeadingPosition);
          Packet packet = new Packet(servos.ServosPosition);
          //Console.WriteLine("(" + servos.Position.X + "," + servos.Position.Y + ")");
          //MessageBox.Show("(" + servos.Position.X + "," + servos.Position.Y + ")");
          packet.setFireOff();
          if (firingOn)
          {
            packet.setFireOn();
          }
          sendData(packet);
        }
        else if (rectmotion.Length == 0)
        {
          if (!ceasefiringsoundplayed && soundOn)
          {
            switch (soundTracker % 4)
            {
              case 0:
                PlaySound(pwd + "\\Sounds\\Sentry Sounds\\Target lost\\searching.wav", IntPtr.Zero, SoundFlags.SND_FILENAME | SoundFlags.SND_ASYNC);

                ceasefiringsoundplayed = true;
                break;
              case 1:
                PlaySound(pwd + "\\Sounds\\Sentry Sounds\\Target lost\\is_anyone_there.wav", IntPtr.Zero, SoundFlags.SND_FILENAME | SoundFlags.SND_ASYNC);
                ceasefiringsoundplayed = true;
                break;
              case 2:
                PlaySound(pwd + "\\Sounds\\Sentry Sounds\\Target lost\\target_lost.wav", IntPtr.Zero, SoundFlags.SND_FILENAME | SoundFlags.SND_ASYNC);
                ceasefiringsoundplayed = true;
                break;
              case 3:
                PlaySound(pwd + "\\Sounds\\Sentry Sounds\\Target Lost\\are_you_still_there.wav", IntPtr.Zero, SoundFlags.SND_FILENAME | SoundFlags.SND_ASYNC);
                ceasefiringsoundplayed = true;
                break;
            }
            soundTracker++;
          }
          firingsoundplayed = false;
          //when no motion, center aimDot and return servos to center position
          aimDot.Location = new Point(cameraWindow1.Location.X + cameraWindow1.Width / 2 - 2, cameraWindow1.Location.Y + cameraWindow1.Height / 2 - 2);
          aimDot.BackColor = Color.Yellow;
          //aimDot.Visible = false;
          lastCenterPosition = new Point();
          lastLeadingPosition = new Point();
          Packet packet = new Packet(servos.CenterServosPosition);
          packet.setFireOff();
          sendData(packet);
        }
      }
      else
      {
        MessageBox.Show("No Active Camera w/ Active Motion Detector!");
        TrackingTimer.Stop();
      }
    }
Пример #7
0
            public override void OnResponse(NetState state, int index)
            {
                if ( m_List == null || index < 0 || index >= m_List.Count )
                    return;

                Mobile m = m_List[index] as Mobile;
                if ( m == null || m.Deleted )
                    return;

                Timer timer = m_Table[m] as Timer;
                if ( timer != null && timer.Running )
                    timer.Stop();
                m_Table[m] = timer = new TrackingTimer( m, state.Mobile );
                timer.Start();
            }