コード例 #1
0
        //Case 978: 1.3.17_workflow_CSI starts up and initializes
        public void Run_WorkFlow_CSIStartsupAndInitializes_Case978()
        {
            ApplicationService applicationService = new ApplicationService();
            PatientService patientService = new PatientService();
            AcquisitionService acquisitionService = new AcquisitionService();

            XMLParameter queryPatientsParameter = new XMLParameter("filter");
            XMLParameter queryDivicesParameter = new XMLParameter("query_devices");
            XMLParameter queryLinesParameter = new XMLParameter("query_lines");
            XMLParameter setAsynAcqPatientInfoParameter = new XMLParameter("acq_info");

            CheckPoint pRegister = new CheckPoint("register", "register 2D Viewer");
            CheckPoint pQueryPatients = new CheckPoint("queryPatients", "query the patients list");
            CheckPoint pQueryDevices = new CheckPoint("queryDevices", "query installed device IDs of sensor type");
            CheckPoint pQueryLines = new CheckPoint("queryLines", "query installed line IDs of device IDs");
            CheckPoint pSetAsynAcqPatientInfo = new CheckPoint("setAsynAcqPatientInfo", "set asyn acq patient info");

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                Round r = new Round();

                r.CheckPoints.Add(pRegister);
                r.CheckPoints.Add(pQueryPatients);
                r.CheckPoints.Add(pQueryDevices);
                r.CheckPoints.Add(pQueryLines);
                r.CheckPoints.Add(pSetAsynAcqPatientInfo);

                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    if (ids.InputParameters.GetParameter(i).Step == "query_devices")
                    {
                        queryDivicesParameter.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                    }
                }

                #region Step 1: receive getType and then register 2D applciation to CSDM

                System.Threading.Thread simulator = new System.Threading.Thread(delegate()
                {
                    TwoDSim.simulator si = new TwoDSim.simulator(2010);

                    si.StartSimulater("0,2DViewer");
                    si.StopSimulator(60000);
                }); //Use simulator to simulate there is 2D running

                simulator.Start();
                System.Threading.Thread.Sleep(3000);

                XMLResult registerResult = applicationService.registerApplication("2DViewer", "localhost", 2010, true);

                try
                {
                    simulator.Join(3000);
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                if (registerResult.IsErrorOccured)
                {
                    pRegister.Result = TestResult.Fail;
                    System.Diagnostics.Debug.Print("2D Viewer register fail");
                    pRegister.Outputs.AddParameter("Register", "register 2D Viewer", registerResult.Message);

                    SaveRound(r);
                    break; // There is error, end test case
                }
                else
                {
                    pRegister.Result = TestResult.Pass;
                    System.Diagnostics.Debug.Print("2D Viewer register succeed");
                    pRegister.Outputs.AddParameter("registerApplication", "Register 2D Viewer", registerResult.Message);
                }
                #endregion

                #region Step 2: call queryPatients to get the patient list
                XMLResult queryPatientsResult = patientService.queryPatients(queryPatientsParameter);

                if (queryPatientsResult.IsErrorOccured)
                {
                    pQueryPatients.Result = TestResult.Fail;
                    System.Diagnostics.Debug.Print("query the patients list fail:");
                    pQueryPatients.Outputs.AddParameter("queryPatients", "query the patients list", queryPatientsResult.Message);

                    SaveRound(r);
                    break; // There is error, end test case
                }
                else
                {
                    pQueryPatients.Result = TestResult.Pass;
                    System.Diagnostics.Debug.Print("query the patients list succeed:");
                    pQueryPatients.Outputs.AddParameter("queryPatients", "query the patients list", queryPatientsResult.Message);
                }
                #endregion

                #region Step 3: call queryDevices to query installed device IDs of sensor type
                XMLResult queryDevicesResult = acquisitionService.queryDevices(queryDivicesParameter);

                if (queryDevicesResult.IsErrorOccured)
                {
                    pQueryDevices.Result = TestResult.Fail;
                    System.Diagnostics.Debug.Print("query installed device IDs of sensor type fail:");
                    pQueryDevices.Outputs.AddParameter("queryDevices", "query installed device IDs of sensor type", queryDevicesResult.Message);

                    SaveRound(r);
                    break; // There is error, end test case
                }
                else
                {
                    pQueryDevices.Result = TestResult.Pass;
                    System.Diagnostics.Debug.Print("query installed device IDs of sensor type succeed:");
                    pQueryDevices.Outputs.AddParameter("queryDevices", "query installed device IDs of sensor type", queryDevicesResult.Message);
                }
                #endregion

                #region Step 4: call queryLines to query installed line IDs of device IDs
                // Get the line ID sub strings from queryDevicesResult, e.g: <device id="AcqCR7400.dll">
                string pattern = "<device id=\"\\S*\">";
                System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(pattern);
                System.Text.RegularExpressions.MatchCollection matches = regex.Matches(queryDevicesResult.ResultContent);

                foreach (System.Text.RegularExpressions.Match match in matches)
                {
                    // Get the exact device ID from the result, e.g: from <device id="AcqCR7400.dll"> to AcqCR7400.dll
                    string deviceID = match.Value;
                    deviceID = deviceID.Replace("<device id=\"", "");
                    deviceID = deviceID.Replace("\">", "");

                    queryLinesParameter.AddParameter("id", deviceID);
                }

                XMLResult queryLinesResult = acquisitionService.queryLines(queryLinesParameter);

                if (queryLinesResult.IsErrorOccured)
                {
                    pQueryLines.Result = TestResult.Fail;
                    System.Diagnostics.Debug.Print("query installed line IDs of device IDs fail:");
                    pQueryLines.Outputs.AddParameter("queryLines", "query installed line IDs of device IDs", queryLinesResult.Message);

                    SaveRound(r);
                    break; // There is error, end test case
                }
                else
                {
                    pQueryLines.Result = TestResult.Pass;
                    System.Diagnostics.Debug.Print("query installed line IDs of device IDs succeed:");
                    pQueryLines.Outputs.AddParameter("queryLines", "query installed line IDs of device IDs", queryLinesResult.Message);
                }
                #endregion

                #region Step 5: setAsynAcqPatientInfo with empty patient
                setAsynAcqPatientInfoParameter.AddParameter("patient_internal_id", "");
                XMLResult setAsynAcqPatientInfoResult = acquisitionService.setAsynAcqPatientInfo(setAsynAcqPatientInfoParameter);

                if (setAsynAcqPatientInfoResult.IsErrorOccured)
                {
                    pSetAsynAcqPatientInfo.Result = TestResult.Fail;

                    System.Diagnostics.Debug.Print("Set AsynAcq PatientInfo fail:");
                    pSetAsynAcqPatientInfo.Outputs.AddParameter("setAsynAcqPatientInfo", "Set AsynAcq PatientInfo", setAsynAcqPatientInfoResult.Message);

                    SaveRound(r);
                    break; // There is error, end test case
                }
                else
                {
                    pSetAsynAcqPatientInfo.Result = TestResult.Pass;

                    System.Diagnostics.Debug.Print("Set AsynAcq PatientInfo succeed:");
                    pSetAsynAcqPatientInfo.Outputs.AddParameter("setAsynAcqPatientInfo", "Set AsynAcq PatientInfo", setAsynAcqPatientInfoResult.Message);
                }
                #endregion

                SaveRound(r);

            }

            Output();
        }
コード例 #2
0
        public void Run_Acquisition_QueryLinces_Case5()
        {
            //int runCount = this.Input.Repetition;

            int runCount = 0; // this is the initial run count. Use this count to repeat different test data set.

            foreach (InputDataSet ids in this.Input.DataSets)
            {
                runCount++;
                Round r = this.NewRound(runCount.ToString(), "Test round");

                //Mark the check point here to indicate what's the check point here
                CheckPoint p = new CheckPoint("QueryLines", "Test queryLines");

                r.CheckPoints.Add(p);

                //create required PAS service instaces here
                AcquisitionService acqs = new AcquisitionService();

                //create input parameters here, it may include XML path type and string type value
                XMLParameter pa = new XMLParameter("query_lines");

                for (int i = 0; i < ids.InputParameters.Count; i++)
                {
                    pa.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
                }

                //Get service result
                System.Diagnostics.Debug.Print("PAS: queryLines start!");
                XMLResult result = acqs.queryLines(pa);

                //Log service output
                if (result.IsErrorOccured)
                {
                    p.Result = TestResult.Fail;
                    p.Outputs.AddParameter("QueryLines", "Error", result.Message);
                }
                else
                {
                    p.Result = TestResult.Pass;
                    p.Outputs.AddParameter("QueryLines", "Success", result.ResultContent);
                }

                //Save data for each round
                SaveRound(r);
            }

            //Save service log as xml file
            Output();
        }