Ejemplo n.º 1
0
        //////////////////////////////////////////////////////////////////////////
        // simulation-related methods

        private void SimulatePB_Click(object sender, RoutedEventArgs e)
        {
            if (!m_simulationRunning)
            {
                StartSimulationTimer(1000);
                m_simulationRunning = true;
                RunPB.IsEnabled     = false;
                SimulatePB.Content  = "Stop";
            }
            else
            {
                StopSimulation();
                m_simulationRunning = false;
                RunPB.IsEnabled     = true;
                SimulatePB.Content  = "Sim";

                ReportDialog dlg = new ReportDialog(m_project, m_experiment, m_indicatorList);
                dlg.ShowDialog();
            }
        }
Ejemplo n.º 2
0
        private void CreateReportPB_Click(object sender, RoutedEventArgs e)
        {
            ObservableCollection <ExperimentIndicatorContainer> expIndicatorList;
            bool success = m_wgDB.GetAllExperimentIndicatorsForExperiment(VM.CurrentExperiment.ExperimentID, out expIndicatorList);

            if (success)
            {
                ProjectContainer project;
                success = m_wgDB.GetProject(VM.CurrentProject.ProjectID, out project);

                if (success && project != null)
                {
                    ExperimentContainer experiment;
                    success = m_wgDB.GetExperiment(VM.CurrentExperiment.ExperimentID, out experiment);

                    if (success && experiment != null)
                    {
                        ReportDialog dlg = new ReportDialog(project, experiment, expIndicatorList);

                        dlg.ShowDialog();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        void m_vworks_PostVWorksCommandEvent(object sender, WaveGuideEvents.VWorksCommandEventArgs e)
        {
            VWORKS_COMMAND       command        = e.Command;
            int                  param1         = e.Param1;
            string               name           = e.Name;
            string               desc           = e.Description;
            int                  sequenceNumber = m_imager.GetSequenceCount();
            bool                 success;
            EventMarkerContainer eventMarker;

            switch (command)
            {
            case VWORKS_COMMAND.Protocol_Aborted:
                PostMessage("VWorks - Protocol Aborted");

                m_dispatcher.Invoke((Action)(() =>
                {
                    m_timer.Stop();
                    VM.DelayText = "";
                    m_tokenSource.Cancel();      // stops the imaging task
                    VM.RunState = RunExperiment_ViewModel.RUN_STATE.ABORTED;
                    SetButton(VM.RunState);
                }));

                break;

            case VWORKS_COMMAND.Protocol_Resumed:
                PostMessage("VWorks - Protocol Resumed");
                m_dispatcher.Invoke((Action)(() =>
                {
                    m_timer.Stop();
                    VM.DelayText = "";
                    VM.DelayHeaderVisible = false;
                }));
                break;

            case VWORKS_COMMAND.Protocol_Complete:
                PostMessage("VWorks - Protocol Complete");

                m_dispatcher.Invoke((Action)(() =>
                {
                    m_timer.Stop();
                    VM.DelayText = "";
                    VM.DelayHeaderVisible = false;
                    m_tokenSource.Cancel();         // make sure the imaging task stops
                    VM.RunState = RunExperiment_ViewModel.RUN_STATE.FINISHED;
                    SetButton(VM.RunState);

                    ReportDialog dlg = new ReportDialog(m_project, m_experiment, m_indicatorList);
                    dlg.ShowDialog();
                }));


                break;

            case VWORKS_COMMAND.Protocol_Paused:
                PostMessage("VWorks - Protocol Paused");

                m_dispatcher.Invoke((Action)(() =>
                {
                    m_delayTime = param1;
                    VM.DelayHeaderVisible = true;
                    m_timer.Start();
                }));

                break;

            case VWORKS_COMMAND.Event_Marker:
                PostMessage("VWorks - Event Marker");

                m_dispatcher.Invoke((Action)(() =>
                {
                    ChartArray.AddEventMarker(sequenceNumber, desc);
                    eventMarker = new EventMarkerContainer();
                    eventMarker.Description = desc;
                    eventMarker.ExperimentID = m_experiment.ExperimentID;
                    eventMarker.Name = name;
                    eventMarker.SequenceNumber = sequenceNumber;
                    eventMarker.TimeStamp = DateTime.Now;
                    success = m_wgDB.InsertEventMarker(ref eventMarker);
                    if (!success)
                    {
                        PostMessage("Database Error in InsertEventMarker: " + m_wgDB.GetLastErrorMsg());
                    }
                }));


                break;

            case VWORKS_COMMAND.Initialization_Complete:
                PostMessage("VWorks Initialization Complete");

                m_dispatcher.Invoke((Action)(() =>
                {
                    BringWindowToFront();
                }));

                break;

            case VWORKS_COMMAND.Pause_Until:
                //PostMessage("VWorks - Pause Until");

                m_dispatcher.Invoke((Action)(() =>
                {
                    m_delayTime = param1;
                    VM.DelayHeaderVisible = true;
                    VM.DelayText = ((int)(m_delayTime / 1000)).ToString();
                    m_timer.Start();
                }));


                break;

            case VWORKS_COMMAND.Set_Time_Marker:
                //PostMessage("VWorks - Set Time Marker");
                break;

            case VWORKS_COMMAND.Start_Imaging:
                PostMessage("VWorks - Start Imaging");

                /////////////////////////////////////////////////////////////////////////////////

                /// Start Imaging Task
                m_dispatcher.Invoke((Action)(() =>
                {
                    BringWindowToFront();
                }));

                StartImaging_2(10000);

                ////////////////////////////////////////////////////////////////////////////////


                break;

            case VWORKS_COMMAND.Stop_Imaging:
                PostMessage("VWorks - Stop Imaging");

                m_dispatcher.Invoke((Action)(() =>
                {
                    StopImaging();
                }));

                break;

            case VWORKS_COMMAND.Unrecoverable_Error:
                PostMessage("VWorks - Unrecoverable Error" + ", " + name + ", " + desc);

                m_dispatcher.Invoke((Action)(() =>
                {
                    m_timer.Stop();
                    VM.DelayText = "";
                    m_tokenSource.Cancel();      // stops the imaging task
                    VM.RunState = RunExperiment_ViewModel.RUN_STATE.ERROR;
                    SetButton(VM.RunState);
                }));

                break;

            case VWORKS_COMMAND.Error:
                PostMessage("VWorks - Error" + ", " + name + ", " + desc);

                m_dispatcher.Invoke((Action)(() =>
                {
                    m_timer.Stop();
                    VM.DelayText = "";
                    VM.DelayHeaderVisible = false;
                    m_tokenSource.Cancel();      // stops the imaging task
                    VM.RunState = RunExperiment_ViewModel.RUN_STATE.ERROR;
                    SetButton(VM.RunState);
                }));

                break;

            case VWORKS_COMMAND.Message:
                PostMessage("VWorks - Message, " + name + ", " + desc);
                break;

            default:
                break;
            }
        }