Esempio n. 1
0
        void NotifyAgentDone(DoneReason doneReason)
        {
            m_Info.episodeId      = m_EpisodeId;
            m_Info.reward         = m_Reward;
            m_Info.done           = true;
            m_Info.maxStepReached = doneReason == DoneReason.MaxStepReached;
            // Request the last decision with no callbacks
            // We request a decision so Python knows the Agent is done immediately
            m_Brain?.RequestDecision(m_Info, sensors);

            // We also have to write any to any DemonstationStores so that they get the "done" flag.
            foreach (var demoWriter in DemonstrationWriters)
            {
                demoWriter.Record(m_Info, sensors);
            }

            if (doneReason != DoneReason.Disabled)
            {
                // We don't want to udpate the reward stats when the Agent is disabled, because this will make
                // the rewards look lower than they actually are during shutdown.
                UpdateRewardStats();
            }

            // The Agent is done, so we give it a new episode Id
            m_EpisodeId        = EpisodeIdCounter.GetEpisodeId();
            m_Reward           = 0f;
            m_CumulativeReward = 0f;
            m_RequestAction    = false;
            m_RequestDecision  = false;
        }
Esempio n. 2
0
 void _mc_OnDisconnect(MessagesCommunicator comm)
 {
     lock (this._lock)
     {
         this._done   = true;
         this._reason = DoneReason.Disconnect;
     }
 }
Esempio n. 3
0
 void ib_OnDone(BatchSender sender, DoneReason reason)
 {
     this.Log.PostHead("Emulator", "Stop sending image, reason: " + reason);
     this.ShowImageProgressBar(false);
     if (reason == DoneReason.Success)
     {
         this.Messages.Sent("Image sent success");
     }
     else
     {
         this.Messages.Sent("Cannot sent image: " + reason);
     }
 }
Esempio n. 4
0
        void NotifyAgentDone(DoneReason doneReason)
        {
            if (m_Info.done)
            {
                // The Agent was already marked as Done and should not be notified again
                return;
            }
            m_Info.episodeId      = m_EpisodeId;
            m_Info.reward         = m_Reward;
            m_Info.done           = true;
            m_Info.maxStepReached = doneReason == DoneReason.MaxStepReached;
            if (collectObservationsSensor != null)
            {
                // Make sure the latest observations are being passed to training.
                collectObservationsSensor.Reset();
                CollectObservations(collectObservationsSensor);
            }
            // Request the last decision with no callbacks
            // We request a decision so Python knows the Agent is done immediately
            m_Brain?.RequestDecision(m_Info, sensors);
            ResetSensors();

            // We also have to write any to any DemonstationStores so that they get the "done" flag.
            foreach (var demoWriter in DemonstrationWriters)
            {
                demoWriter.Record(m_Info, sensors);
            }

            if (doneReason != DoneReason.Disabled)
            {
                // We don't want to update the reward stats when the Agent is disabled, because this will make
                // the rewards look lower than they actually are during shutdown.
                m_CompletedEpisodes++;
                UpdateRewardStats();
            }

            m_Reward           = 0f;
            m_CumulativeReward = 0f;
            m_RequestAction    = false;
            m_RequestDecision  = false;
            Array.Clear(m_Info.storedVectorActions, 0, m_Info.storedVectorActions.Length);
        }
Esempio n. 5
0
 void Run()
 {
     this._mc.OnReceive    += new MessageOperationDelegate(_mc_OnReceive);
     this._mc.OnSent       += new MessageOperationDelegate(_mc_OnSent);
     this._mc.OnDisconnect += new MessageConnectorOperation(_mc_OnDisconnect);
     // send first message
     this._mc.Send(this._messages[this._sent_msg_index]);
     // wait for server answer
     while (!this._done)
     {
         lock (this._lock)
         {
             if (this._last_sent != null)
             {
                 if (this._messages[this._sent_msg_index] == this._last_sent)
                 {
                     // message sent, can wait for answer
                     this._can_wait_for_answer = true;
                     if (this.OnProcess != null)
                     {
                         this.OnProcess(this, (this._sent_msg_index + 1) / (double)this._messages.Length);
                     }
                 }
                 this._last_sent = null;
             }
             if (this._can_wait_for_answer && this._last_received != null)
             {
                 this._can_wait_for_answer = false;
                 if (this._last_received.Success)
                 {
                     // send next
                     this._sent_msg_index += 1;
                     if (this._sent_msg_index >= this._messages.Length)
                     {
                         // done
                         this._done   = true;
                         this._reason = DoneReason.Success;
                         break;
                     }
                     else
                     {
                         this._mc.Send(this._messages[this._sent_msg_index]);
                     }
                 }
                 else
                 {
                     // server answer isn't success
                     this._done   = true;
                     this._reason = DoneReason.ServerAnswerNotSuccess;
                     break;
                 }
                 this._last_received = null;
             }
         }
         if (this.Interval > 0)
         {
             if (this._sent_msg_index < this._messages.Length - 1)
             {
                 Thread.Sleep(this.Interval);
             }
             else
             {
                 Thread.Sleep(1);
             }
         }
     }
     if (this.OnDone != null)
     {
         this.OnDone(this, this._reason);
     }
     this._mc.OnDisconnect -= this._mc_OnDisconnect;
     this._mc.OnReceive    -= this._mc_OnReceive;
     this._mc.OnSent       -= this._mc_OnSent;
 }
Esempio n. 6
0
 void ib_OnDone(BatchSender sender, DoneReason reason)
 {
     this.Log.PostHead("Emulator", "Stop sending image, reason: " + reason);
     this.ShowImageProgressBar(false);
     if (reason == DoneReason.Success)
         this.Messages.Sent("Image sent success");
     else
         this.Messages.Sent("Cannot sent image: " + reason);
 }
 internal void UploadDone(DoneReason doneReason) {
   if (this.UploadDoneEvent != null) {
     this.UploadDoneEvent(doneReason);
   }
 }
 void googleEmailUploaderModel_UploadDoneEvent(DoneReason doneReason) {
   if (this.notificationTrayIcon.Visible) {
     this.Invoke(new VoidDelegate(this.ForceShow));
   }
   this.UnhookModelEvents();
   if (this.IsHandleCreated && !this.IsDisposed) {
     this.Invoke(new UploadDoneDelegate(this.MorphToDoneState),
                 new object[] { doneReason });
   }
 }
    void MorphToDoneState(DoneReason doneReason) {
      this.Controls.Clear();

      Label uploadCompleteHeaderLabel = new Label();
      uploadCompleteHeaderLabel.Location = new Point(60, 23);
      uploadCompleteHeaderLabel.AutoSize = true;
      uploadCompleteHeaderLabel.Font = new Font("Arial", 11F, FontStyle.Bold);
      uploadCompleteHeaderLabel.BackColor = Program.TopStripBackColor;

      Label uploadCompleteTextLabel = new Label();
      uploadCompleteTextLabel.Location = new Point(35, 60);
      uploadCompleteTextLabel.Font = new Font("Arial", 9.25F);

      if (doneReason == DoneReason.Completed) {
        this.BackgroundImage =
            Resources.GoogleEmailUploaderImportCompleteBackgroundImage;
        uploadCompleteTextLabel.Size = new Size(250, 30);
        uploadCompleteHeaderLabel.Text = Resources.UploadCompleteHeaderText;
        uploadCompleteTextLabel.Text = Resources.UploadCompleteText;

        Label uploadCompleteInfoLabel = new Label();
        uploadCompleteInfoLabel.Location = new Point(35, 95);
        uploadCompleteInfoLabel.Size = new Size(250, 45);
        uploadCompleteInfoLabel.Font = new Font("Arial", 9.25F);
        uploadCompleteInfoLabel.Text = Resources.UploadCompleteInfoText;
        this.Controls.Add(uploadCompleteInfoLabel);

        if (this.googleEmailUploaderModel.HasFailures) {
          Label errorsTextLabel = new Label();
          errorsTextLabel.Location = new Point(35, 145);
          errorsTextLabel.Size = new Size(250, 20);
          errorsTextLabel.Font = new Font("Arial", 9.25F);
          errorsTextLabel.Text =
              string.Format(Resources.UploadErrorsText,
                            this.googleEmailUploaderModel.TotalFailedItemCount);
          errorsTextLabel.ForeColor = Color.Red;
          this.Controls.Add(errorsTextLabel);

          LinkLabel openLogLabel = new LinkLabel();
          openLogLabel.Location = new Point(35, 165);
          openLogLabel.Font = new Font("Arial", 9.25F);
          openLogLabel.AutoSize = true;
          openLogLabel.Text = Resources.OpenLogText;
          openLogLabel.Click += new EventHandler(this.openLogLabel_Click);
          this.Controls.Add(openLogLabel);
        }

      } else {
        this.BackgroundImage =
            Resources.GoogleEmailUploaderBackgroundImage;
        uploadCompleteTextLabel.Size = new Size(250, 60);
        if (doneReason == DoneReason.Stopped) {
          uploadCompleteTextLabel.Text = Resources.UploadStoppedText;
          uploadCompleteHeaderLabel.Text = Resources.UploadStoppedHeaderText;
        } else if (doneReason == DoneReason.Unauthorized) {
          uploadCompleteTextLabel.Text = Resources.UploadForbiddenText;
          uploadCompleteHeaderLabel.Text = Resources.UploadUnauthorizedHeaderText;
        } else if (doneReason == DoneReason.Forbidden) {
          uploadCompleteTextLabel.Text = Resources.UploadForbiddenText;
          uploadCompleteHeaderLabel.Text = Resources.UploadForbiddenHeaderText;
        }
      }

      Button finishButton = new Button();
      finishButton.Location = new Point(30, 287);
      finishButton.Size = new Size(72, 23);
      finishButton.Font = new Font("Arial", 9.25F);
      finishButton.Text = Resources.FinishText;
      finishButton.FlatStyle = FlatStyle.System;
      finishButton.Click += new EventHandler(finishButton_Click);

      this.Controls.Add(uploadCompleteHeaderLabel);
      this.Controls.Add(uploadCompleteTextLabel);
      this.Controls.Add(finishButton);

      this.ActiveControl = finishButton;
    }