Пример #1
0
        //---------------------------------------------


        #region MainForm Events
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!this.DesignMode)
            {
                // Set form Sizing and Location
                if (!Properties.Settings.Default.main_FirstLoad)
                {
                    this.Size        = Properties.Settings.Default.main_Size;
                    this.Location    = Properties.Settings.Default.main_Location;
                    this.WindowState = Properties.Settings.Default.main_WindowState;
                }

                // Fix ToolStrip
                ToolStripManager.LoadSettings(this);

                // Load Workbench Layout
                workbench.LoadLayout();
                workbench.MruDocuments = this.mruProviderDocuments;
                workbench.MruWorkplace = this.mruProviderWorkplace;

                // Show Start Page (if configured to do so)
                if (Properties.Settings.Default.behaviour_ShowStartPage)
                {
                    StartPage page = new StartPage(workbench);
                    page.Show(this.dockMain, DockState.Document);
                }

                // Wire-up some events
                this.workbench.WorkplaceOpened += new EventHandler(Workbench_WorkplaceChanged);

                HistoryListener.Write("Sinapse Interface Loaded");
            }
        }
Пример #2
0
        internal void ResetControl()
        {
            //         this.UpdateNetworkState(new TrainingStatus());
            this.UpdateSelectedItems(0, 0);
            this.lbStatus.Text = String.Empty;

            HistoryListener.Write("Statusbar Reset");
        }
Пример #3
0
        private void networkContainer_savepointRegistered(object sender, EventArgs e)
        {
            this.SavePoints.Add(this.m_networkContainer.Savepoints.CurrentSavepoint.Epoch,
                                this.m_networkContainer.Savepoints.CurrentSavepoint.ErrorTraining);

            this.SavePoints.Add(this.m_networkContainer.Savepoints.CurrentSavepoint.Epoch,
                                this.m_networkContainer.Savepoints.CurrentSavepoint.ErrorValidation);

            HistoryListener.Write("Savepoint Registered!");
        }
Пример #4
0
        //---------------------------------------------


        #region Public Methods
        public void Forget()
        {
            this.m_networkContainer.ActivationNetwork.Randomize();
            this.m_networkContainer.Precision = 0;
            //this.m_trainingSession.ResetStatus();

            //   this.m_trainingSession.IsPaused = false;
            this.m_networkState   = new TrainingStatus();
            this.m_trainingPaused = false;
            this.m_graphControl.ClearGraph();
            this.updateStatus();

            HistoryListener.Write("Network learnings cleared");
        }
Пример #5
0
        public void Pause()
        {
            if (backgroundWorker.IsBusy)
            {
                HistoryListener.Write("Pausing Thread");
                this.backgroundWorker.CancelAsync();

                this.timer.Stop();
                this.m_trainingPaused = true;
            }
            else
            {
                HistoryListener.Write("Thread is not running");
            }
        }
Пример #6
0
        private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            this.m_networkContainer.Precision = this.m_networkState.ErrorTraining;

            if (e.Cancelled)
            {
                HistoryListener.Write("Training stopped");
            }
            else
            {
                HistoryListener.Write("Training Finished!");

                this.m_networkState.Progress = 100;
                this.updateStatus();

                if (this.TrainingComplete != null)
                {
                    this.TrainingComplete.Invoke(this, EventArgs.Empty);
                }
            }
        }
Пример #7
0
        public void Stop()
        {
            // this.m_trainingSession.ResetStatus();
            this.m_networkState   = new TrainingStatus();
            this.m_trainingPaused = false;

            this.updateStatus();

            if (backgroundWorker.IsBusy)
            {
                HistoryListener.Write("Stopping Thread");
                this.backgroundWorker.CancelAsync();

                this.timer.Stop();
                this.m_trainingPaused = false;
            }
            else
            {
                HistoryListener.Write("Thread is not running");
            }
        }
Пример #8
0
        private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (e.UserState is UpdateType)
            {
                UpdateType updateType = (UpdateType)e.UserState;


                switch (updateType)
                {
                case UpdateType.NetworkSave:
                    this.m_networkContainer.Savepoints.Register(this.m_networkState);
                    break;


                case UpdateType.Graph:
                    this.m_graphControl.TrainingPoints.Add(m_networkState.Epoch, m_networkState.ErrorTraining);
                    this.m_graphControl.ValidationPoints.Add(m_networkState.Epoch, m_networkState.ErrorValidation);

                    if (Properties.Settings.Default.graph_Autoupdate)
                    {
                        this.m_graphControl.UpdateGraph();
                    }
                    break;

                case UpdateType.Statusbar:
                    HistoryListener.Write("Training...");
                    this.updateStatus();
                    break;
                }
            }
            else
            {
                string str = e.UserState as String;
                if (str != null)
                {
                    HistoryListener.Write(str);
                    this.updateStatus();
                }
            }
        }
Пример #9
0
        protected override void OnClosing(CancelEventArgs e)
        {
            HistoryListener.Write("Exiting...");

            base.OnClosing(e);

            // Close Workbench


            // Close Workplace, always asking for confirmation
            if (!workbench.CloseAllDocuments(true))
            {
                e.Cancel = true;
                return;
            }


            // Save ToolStripPanels
            ToolStripManager.SaveSettings(this);

            // Save Workbench Layout
            workbench.SaveLayout();

            // Save settings before closing
            Properties.Settings.Default.main_FirstLoad   = false;
            Properties.Settings.Default.main_WindowState = this.WindowState;
            if (this.WindowState == FormWindowState.Normal)
            {
                Properties.Settings.Default.main_Size     = this.Size;
                Properties.Settings.Default.main_Location = this.Location;
            }
            else
            {
                Properties.Settings.Default.main_Size     = this.RestoreBounds.Size;
                Properties.Settings.Default.main_Location = this.RestoreBounds.Location;
            }
        }
Пример #10
0
    IEnumerator GetHistory(string url, HistoryListener listener)
    {
        Debug.Log(url);

        UnityWebRequest www = UnityWebRequest.Get(url);

        www.SetRequestHeader("Cookie", string.Format("device={0}", token));
        yield return(www.SendWebRequest());

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
            string text = "{\"logs\":" + www.downloadHandler.text + "}";

            var values = JsonUtility.FromJson <SensorHistory>(text);

            listener.newValues(values);
            // Show results as text
            //Debug.Log(www.downloadHandler.text);
        }
    }
Пример #11
0
        public void Start()
        {
            if (this.backgroundWorker.IsBusy)
            {
                HistoryListener.Write("Trainer thread is busy!");
            }
            else
            {
                HistoryListener.Write("Gathering information...");

                TrainingOptions options = new TrainingOptions();
                options.momentum           = (double)numMomentum.Value;
                options.firstLearningRate  = (double)numLearningRate.Value;
                options.limError           = (double)numErrorLimit.Value;
                options.limEpoch           = (int)numEpochLimit.Value;
                options.validateNetwork    = cbValidate.Checked;
                options.secondLearningRate = cbChangeRate.Checked ? (double?)numChangeRate.Value : null;

                if (cbTrainingLayer.SelectedIndex == 0)
                {
                    options.TrainingVectors = this.NetworkDatabase.CreateVectors(NetworkSet.Training);
                }
                else
                {
                    options.TrainingVectors = this.NetworkDatabase.CreateVectors(NetworkSet.Training, (ushort)cbTrainingLayer.SelectedIndex);
                }


                options.ValidationVectors = this.NetworkDatabase.CreateVectors(NetworkSet.Validation);

                if (rbEpochLimit.Checked)
                {
                    options.TrainingType = TrainingType.ByEpoch;
                }
                else if (rbErrorLimit.Checked)
                {
                    options.TrainingType = TrainingType.ByError;
                }
                else if (rbManual.Checked)
                {
                    options.TrainingType = TrainingType.Manual;
                }

                /* //foreach (Double[] inputs in options.TrainingVectors.Input)
                 * //{
                 *   String str = String.Empty;
                 *   foreach (Double input in options.TrainingVectors.Input[0])
                 *   {
                 *       str += input + " ";
                 *   }
                 *   MessageBox.Show(str);
                 *   str = String.Empty;
                 *   foreach (Double input in options.TrainingVectors.Output[0])
                 *   {
                 *       str += input + " ";
                 *   }
                 *   MessageBox.Show(str);
                 * //}
                 */
                if (this.m_trainingPaused)
                {   // Network is paused, then
                    this.m_trainingPaused = false;
                }
                else
                {   // Network is stopped, then
                    //         this.m_graphControl.ClearGraph();
                }

                this.m_graphControl.TrimGraph(m_networkState.Epoch);

                if (this.cbSwitchGraph.Checked)
                {
                    this.m_graphControl.ShowTab();
                }

                if (this.TrainingStarted != null)
                {
                    this.TrainingStarted.Invoke(this, EventArgs.Empty);
                }

                // Start timer
                this.timer.Start();

                HistoryListener.Write("Starting thread");
                this.backgroundWorker.RunWorkerAsync(options);
            }
        }
Пример #12
0
        private void networkContainer_savepointRestored(object sender, EventArgs e)
        {
            //      this.newSavepoint = true;

            HistoryListener.Write("Savepoint Restored!");
        }
Пример #13
0
 public void getHistory(HistoryListener listener)
 {
     behaviour.StartCoroutine(GetHistory("http://tfm.4m1g0.com:1880/powerHistory", listener));
 }