123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml;
- namespace OTSDataType
- {
- public class CDoubleRange:ISlo
- {
- private double m_dStart;
- private double m_dEnd;
- public CDoubleRange()
- {
- m_dStart = 0;
- m_dEnd = 0;
- }
- public CDoubleRange(double a_dStart, double a_dEnd)
- {
-
- m_dStart = Math.Min(a_dStart, a_dEnd);
- m_dEnd = Math.Max(a_dStart, a_dEnd);
- }
- public CDoubleRange(CDoubleRange a_poSource)
- {
- // can't copy itself
- if (a_poSource == this)
- {
- return;
- }
- // copy data over
- Duplicate(a_poSource);
- }
- public void Duplicate( CDoubleRange a_oSource)
- { // copy data over
- m_dStart = a_oSource.m_dStart;
- m_dEnd = a_oSource.m_dEnd;
- }
- public void Normalise()
- {
-
- m_dEnd = Math.Max(m_dStart, m_dEnd);
- m_dStart = Math.Min(m_dStart, m_dEnd);
- }
- public bool DataInRange(double a_dData)
- {
- return a_dData >= m_dStart && a_dData <= m_dEnd;
- }
- // start
- public void SetStart(double a_dStart)
- {
- m_dStart = a_dStart;
- Normalise();
- }
- public double GetStart()
- {
- return m_dStart;
- }
- // end
- public void SetEnd(double a_dEnd)
- {
- m_dEnd = a_dEnd;
- Normalise();
- }
- public double GetEnd()
- {
- return m_dEnd;
- }
- public bool equals(CDoubleRange a_oSource)
- {
- return m_dStart == a_oSource.m_dStart && m_dEnd == a_oSource.m_dEnd;
- }
- public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
- {
- xDouble xStart=new xDouble();
- xDouble xEnd=new xDouble();
- Slo slo=new Slo();
- slo.Register("start", xStart);
- slo.Register("end", xEnd);
- if (isStoring)
- {
- xStart.AssignValue( m_dStart);
- xEnd .AssignValue(m_dEnd);
- slo.Serialize(true, classDoc, rootNode);
- }
- else
- {
- slo.Serialize(false, classDoc, rootNode);
- m_dStart = xStart.value();
- m_dEnd = xEnd.value();
- }
- }
- }
- }
|