123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml;
- using static OTSDataType.otsdataconst;
- namespace OTSModelSharp
- {
-
- public class CMsrThreadStatus
- {
-
-
- public CMsrThreadStatus()
- {
-
- Init();
- }
- // copy constructor
- public CMsrThreadStatus(ref CMsrThreadStatus a_oSource) //CMsrThreadStatus(const CMsrThreadStatus&); (const CMsrThreadStatus& 转换成 ref CMsrThreadStatus
- {
- // can't copy itself
- if (a_oSource == this)
- {
- return;
- }
- // copy data over
- Duplicate(a_oSource);
- }
- // copy constructor
- public CMsrThreadStatus(CMsrThreadStatus a_poSource)
- {
- // input check
- try
- {
- // can't copy itself
- if (a_poSource == this)
- {
- return;
- }
-
- // copy data over
- Duplicate(a_poSource);
- }
- catch
- {
- return;
- }
- }
-
- public OTS_MSR_THREAD_STATUS GetStatus()
- {
- return m_nStatus;
- }
- public void SetStatus(OTS_MSR_THREAD_STATUS a_nStatus)
- {
- m_nStatus = a_nStatus;
- }
- // start time
- public DateTime GetStartTime()
- {
- return m_timeStart;
- }
- public void SetStartTime(DateTime a_timeStart)
- {
- m_timeStart = a_timeStart;
- }
- // used time
- public TimeSpan GetUsedTime()
- {
- return m_timeUsed;
- }
- public void SetUsedTime(TimeSpan a_timeUsed)
- {
- m_timeUsed = a_timeUsed;
- }
- // end time
- public DateTime GetEndTime()
- {
- return m_timeEnd;
- }
- public void SetEndTime(DateTime a_timeEnd)
- {
- m_timeEnd = a_timeEnd;
- }
- // completed samples
- public List<string> GetCompletedSamples() //COTSSamplesList转List<string>
- {
- return m_listCpldSamples;
- }
- public void SetCompletedSamples(ref List<string> a_listCpldSamples) //COTSSamplesList转List<string>
- {
- m_listCpldSamples.Clear();
- for (int i=0; i< a_listCpldSamples.Count;i++)
- {
- m_listCpldSamples.Add(a_listCpldSamples[i]);
- }
- }
- // current start time
- public DateTime GetCurrentStartTime()
- {
- return m_timeStartCur;
- }
- public void SetCurrentStartTime(DateTime a_timeStartCur)
- {
- m_timeStartCur = a_timeStartCur;
- }
- // compute time
- public bool ComputeTime(OTS_THREAD_TIME_TYPE a_nType)
- {
- if (a_nType == OTS_THREAD_TIME_TYPE.START)
- {
- if (m_timeStart == new DateTime())
- {
- m_timeStart = DateTime.Now; //OleDateTime.GetCurrentTime();
- m_timeStartCur = m_timeStart;
- m_timeUsedLast = m_timeUsed;
- }
- else
- {
- m_timeStartCur = DateTime.Now;
- m_timeUsedLast = m_timeUsed;
- }
- }
- else if (a_nType == OTS_THREAD_TIME_TYPE.STOPPED)
- {
- // set current time as end time
- m_timeEnd = DateTime.Now;
- // compute used time
- if (m_timeStartCur == m_timeStart)
- {
- // first compute time
- m_timeUsed = m_timeEnd - m_timeStart;
- }
- else
- {
- // not the first compute time
-
- m_timeUsed = m_timeEnd - m_timeStartCur + m_timeUsedLast;
- }
-
- }
- else if (a_nType == OTS_THREAD_TIME_TYPE.COMPLT)
- {
- m_timeEnd = DateTime.Now;
- if (m_timeStartCur == m_timeStart)
- {
- // first compute time
- m_timeUsed = m_timeEnd - m_timeStart;
- }
- else
- {
- // not the first compute time
- m_timeUsed = m_timeEnd - m_timeStartCur + m_timeUsedLast;
- }
- }
- return true;
- }
- // cleanup
- protected void Cleanup()
- {
- m_listCpldSamples.Clear();
- }
- // initialization
- protected void Init()
- {
- m_nStatus = OTS_MSR_THREAD_STATUS.READY;
- m_timeStart = DateTime.Now;
- m_timeUsed = new TimeSpan(0);
- m_timeEnd = DateTime.Now;
- m_timeStartCur = DateTime.Now;
- m_listCpldSamples.Clear();
- }
- // duplication
- protected void Duplicate(CMsrThreadStatus a_oSource)
- {
- // initialization
- Init();
- // copy data over
- m_nStatus = a_oSource.m_nStatus;
- m_timeStart = a_oSource.m_timeStart;
- m_timeUsed = a_oSource.m_timeUsed;
- m_timeEnd = a_oSource.m_timeEnd;
- foreach (var pSample in a_oSource.m_listCpldSamples)
- {
- string pSampleNew = pSample; //COTSSamplePtr pSampleNew = COTSSamplePtr(new COTSSample(pSample.get()));??? vector<COTSSamplePtr>转成List<string> COTSSamplePtr 转换成string
- m_listCpldSamples.Add(pSampleNew);
- }
- }
- // status
- protected OTS_MSR_THREAD_STATUS m_nStatus = new OTS_MSR_THREAD_STATUS();
- // start time
- protected DateTime m_timeStart = new DateTime();
- // used time
- protected TimeSpan m_timeUsed = new TimeSpan();
- // end time
- protected DateTime m_timeEnd = new DateTime();
- // completed samples
- protected List<string> m_listCpldSamples = new List<string>();// vector<COTSSamplePtr>转成List<string>
- // current start time
- protected DateTime m_timeStartCur = new DateTime();
- private TimeSpan m_timeUsedLast;
- }
-
- }
|