Пример #1
0
 public void OnItemEnd(DutInfo DUTInfo, TestItem TItem, ArrayList Values, string ExecutionID, DateTime TimeStamp)
 {
     if (dlgtStart != null)
     {
         dlgtEnd(this, new ItemEndEventArgs(DUTInfo, TItem, Values, ExecutionID, TimeStamp));
     }
 }
Пример #2
0
 public void OnItemStart(DutInfo DUTInfo, TestItem TItem, string ExecutionID, DateTime TimeStamp)
 {
     if (dlgtStart != null)
     {
         dlgtStart(this, new ItemStartEventArgs(DUTInfo, TItem, ExecutionID, TimeStamp));
     }
 }
Пример #3
0
 public Log(DutInfo DUT, DirectoryInfo Path)
 {
     this.StartTime    = DateTime.Now;
     this.Path         = Path.FullName;
     this.SerialNumber = DUT.SerialNumber;
     this.Position     = DUT.Position;
     //swLog = Open();
 }
Пример #4
0
        //to trigger event when an item done
        public void ItemEnded(object sender, ItemEndEventArgs e)
        {
            try
            {
                if (false == e.ExecutionID.Equals(this.ExecutionID))
                {
                    throw new Exception(string.Format("Execution ID changed."));
                }
                if (false == e.ExecutionID.Equals(this.ExecutionID))
                {
                    return;//not the unit on this position.
                }
                string  FileName = string.Empty;
                DutInfo Dut      = null;
                FileName = string.Empty;

                if (true == string.IsNullOrEmpty(FullName) || false == System.IO.File.Exists(FullName))//full name is null or the file does not exist
                {
                    Dut = e.Dut;
                    if (false == string.IsNullOrEmpty(Dut.SerialNumber))
                    {
                        FileName = string.Format("{0}_", Dut.SerialNumber);
                    }
                    if (null != e.TimeStamp)//not null
                    {
                        FileName = string.Format("{0}{1}.json)", FileName, e.TimeStamp.ToString(CommonTags.Common_LongDateTime));
                    }
                }
                for (int index = 0; index < e.Item.OutputSpec.Count; index++)
                //ToDo: add an item.
                {
                    string strPointID = e.Item.OutputSpec[index].MeasPointID;
                    Dictionary <string, string> dictPointInfo = PointRecord(e.Item, index, e.OutputValue);

                    JObject joNew = JObject.Parse(JsonConvert.SerializeObject(dictPointInfo)); //convert dictionary to jobject

                    JObject joFile = OpenFile();                                               //open record file
                    if (false == string.IsNullOrEmpty(strPointID))
                    {
                        joFile[strPointID].Replace((JToken)joNew); // replace the item info with test value
                    }
                    else
                    {
                        throw new Exception("Can't get Point ID from test plan. It's necessary to identify test.");
                    }
                    File.WriteAllText(FullName, joFile.ToString());//save recode
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #5
0
        // to trigger event when item starts
        public void ItemStarted(object sender, ItemStartEventArgs e)
        {
            try
            {
                if (false == e.ExecutionID.Equals(this.ExecutionID))
                {
                    throw new Exception(string.Format("Execution ID changed."));
                }
                string  FileName = string.Empty;
                DutInfo Dut      = null;
                FileName = string.Empty;
                TestItem tiStart = e.Item;

                if (true == string.IsNullOrEmpty(FullName) || false == System.IO.File.Exists(FullName))//full name is null or the file does not exist
                {
                    Dut     = e.Dut;
                    tiStart = e.Item;
                    if (false == string.IsNullOrEmpty(Dut.SerialNumber))
                    {
                        FileName = string.Format("{0}_", Dut.SerialNumber);
                    }
                    if (null != e.TimeStamp)//not null
                    {
                        FileName = string.Format("{0}{1}.json)", FileName, e.TimeStamp.ToString(CommonTags.Common_LongDateTime));
                    }
                }
                //Open record file
                JObject joFile = OpenFile();//open record file

                //ToDo: add an item.
                TestItemInfo ItemInfo = e.Item.ItemInfo;
                DutInfo      DUT      = e.Dut;
                string       strPointID;

                for (int index = 0; index < tiStart.OutputSpec.Count; index++)
                {
                    Dictionary <string, string> dictPointInfo = PointRecord(tiStart, index, null);
                    strPointID = tiStart.OutputSpec[index].MeasPointID;

                    JObject joInfo = JObject.Parse(JsonConvert.SerializeObject(dictPointInfo)); //convert dictionary to jobject
                    joFile.Add(strPointID, joInfo);                                             //add new point to record. update values by point id later.
                }

                File.WriteAllText(FullName, joFile.ToString());//save recode
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #6
0
        public Processor(TestPlan TP,          //test plan
                         DutInfo Dut,          // Info of device under test
                         Hashtable CoreParams) // core data
        {
            CurrentPlan    = TP;
            DUTInfo        = Dut;
            hashCoreParams = CoreParams;
            ExecutionID    = Guid.NewGuid().ToString();

            //TODO: To define a upper level controller to control a test
            //below three lines could be defined or declared out of this class.
            ReportController rcReportor = new ReportController(ExecutionID);

            this.dlgtStart += new delegateTestItemStart(rcReportor.ItemStarted);
            this.dlgtEnd   += new delegateTestItemEnd(rcReportor.ItemEnded);
        }
Пример #7
0
        static void Main(string[] args)
        {
            Hashtable CoreParams = new Hashtable();
            TestPlan  TP         = TestPlanReader.LoadJson("TestPlanExample.json");
            DutInfo   DUT        = new DutInfo();

            DUT.SerialNumber = "ABCD1234";
            DUT.Position     = 1;

            #region Init core sessions
            SessionManager sm = new SessionManager("SessionMapSample.json");
            CoreParams.Add(CommonTags.CoreData_SessionManage, sm);

            RsrDataTable DataTable = new RsrDataTable();
            CoreParams.Add(CommonTags.CoreData_DataTable, DataTable);
            #endregion

            Processor processor = new Processor(TP, DUT, CoreParams);
            processor.PlanExecution();


            #region Clear sessions after test
            ///TODO:
            ///reset instead of dispose?

            lock (sm)
            {
                List <string> listToRemove = new List <string>();

                foreach (DictionaryEntry de in sm)
                {
                    string strName = Convert.ToString(de.Key);
                    if (strName.EndsWith(string.Format("_{0}", DUT.Position.ToString())))
                    {
                        listToRemove.Add(strName);
                    }
                }

                foreach (string strName in listToRemove)
                {
                    string strSessionName = strName.Substring(0, strName.LastIndexOf('_'));
                    sm.Remove(strSessionName, DUT.Position);
                }
            }
            #endregion
        }
Пример #8
0
 public Log(DutInfo DUT)
 {
     this.StartTime    = DateTime.Now;
     this.SerialNumber = DUT.SerialNumber;
     this.Position     = DUT.Position;
 }