public Quality(BaseQualityFlags baseQuality, bool isSet = false)
 {
     Flag       = baseQuality;
     Name       = baseQuality.ToString();
     Value      = (int)baseQuality;
     this.IsSet = isSet;
 }
 public void ClearQuality(BaseQualityFlags flag)
 {
     if (quality == -1)
     {
         return;
     }
     quality ^= (int)flag;
 }
 public void SetQuality(BaseQualityFlags flag)
 {
     if (quality == -1)
     {
         quality  = 0;
         quality |= (int)flag;
     }
     quality |= (int)flag;
 }
        public void SimpleQualityConsistencyTestDss6_IRTS()
        {
            string orig = TestUtility.BasePath + "simpleQCT6_IRTS.dss";
            string fn   = TestUtility.BasePath + "simpleQCT6Copy_IRTS.dss";

            File.Delete(fn);
            File.Copy(orig, fn);
            Array  q     = Enum.GetValues(typeof(BaseQualityFlags));
            Random r     = new Random();
            var    qList = new List <int>();

            using (DssWriter w = new DssWriter(fn))
            {
                var ts = w.GetTimeSeries(new DssPath("/A/B/C//IR-YEAR/F/"));
                for (int i = 0; i < ts.Values.Length; i++)
                {
                    BaseQualityFlags flag       = (BaseQualityFlags)q.GetValue(r.Next(q.Length));
                    Quality          newQuality = new Quality(flag);
                    qList.Add(newQuality.Value);
                }
                ts.Qualities = qList.ToArray();
                w.Write(ts, true);
            }

            using (DssReader reader = new DssReader(fn))
            {
                TimeSeries ts = reader.GetTimeSeries(new DssPath("/A/B/C//IR-YEAR/F/"));
                for (int i = 0; i < ts.Values.Length; i++)
                {
                    Assert.AreEqual(ts.Qualities[i], qList[i]);
                }
            }

            using (DssWriter w = new DssWriter(fn))
            {
                var ts = w.GetTimeSeries(new DssPath("/A/B/C//IR-YEAR/F/"));
                qList.Clear();
                for (int i = 0; i < ts.Values.Length; i++)
                {
                    BaseQualityFlags flag       = (BaseQualityFlags)q.GetValue(r.Next(q.Length));
                    Quality          newQuality = new Quality(flag);
                    qList.Add(newQuality.Value);
                }
                ts.Qualities = qList.ToArray();
                w.Write(ts, true);
            }

            using (DssReader reader = new DssReader(fn))
            {
                TimeSeries ts = reader.GetTimeSeries(new DssPath("/A/B/C//IR-YEAR/F/"));
                for (int i = 0; i < ts.Values.Length; i++)
                {
                    Assert.AreEqual(ts.Qualities[i], qList[i]);
                }
            }
        }
        public void SimpleQualityConsistencyTestDss7_RTS_floats()
        {
            string fn = TestUtility.BasePath + "simpleQCT7.dss";

            File.Delete(fn);
            Array  q     = Enum.GetValues(typeof(BaseQualityFlags));
            Random r     = new Random();
            var    qList = new List <int>();

            using (DssWriter w = new DssWriter(fn))
            {
                var ts = TimeSeriesTest.CreateSampleTimeSeries(new DateTime(2020, 1, 1), "cfs", "INST", size: 10);
                ts.Path = new DssPath("a", "b", "c", "", E: "1Day", F: "f");
                for (int i = 0; i < ts.Values.Length; i++)
                {
                    BaseQualityFlags flag       = (BaseQualityFlags)q.GetValue(r.Next(q.Length));
                    Quality          newQuality = new Quality(flag);
                    qList.Add(newQuality.Value);
                }
                ts.Qualities = qList.ToArray();
                w.Write(ts, true);
            }

            using (DssReader reader = new DssReader(fn))
            {
                TimeSeries ts = reader.GetTimeSeries(new DssPath("/a/b/c//1Day/f/"));
                for (int i = 0; i < ts.Values.Length; i++)
                {
                    Assert.AreEqual(ts.Qualities[i], qList[i]);
                }
            }

            using (DssWriter w = new DssWriter(fn))
            {
                var ts = w.GetTimeSeries(new DssPath("/a/b/c//1Day/f/"));
                qList.Clear();
                for (int i = 0; i < ts.Values.Length; i++)
                {
                    BaseQualityFlags flag       = (BaseQualityFlags)q.GetValue(r.Next(q.Length));
                    Quality          newQuality = new Quality(flag);
                    qList.Add(newQuality.Value);
                }
                ts.Qualities = qList.ToArray();
                w.Write(ts, true);
            }

            using (DssReader reader = new DssReader(fn))
            {
                TimeSeries ts = reader.GetTimeSeries(new DssPath("/a/b/c//1Day/f/"));
                for (int i = 0; i < ts.Values.Length; i++)
                {
                    Assert.AreEqual(ts.Qualities[i], qList[i]);
                }
            }
        }
 public TimeSeriesPoint(DateTime dateTime, double value, BaseQualityFlags quality)
 {
     DateTime     = dateTime;
     Value        = value;
     this.quality = (int)quality;
 }
 public static bool IsQualitySet(TimeSeriesPoint tsp, BaseQualityFlags flag)
 {
     return((tsp.IntQuality & (int)flag) == (int)flag);
 }
        public void SimpleQualityConsistencyTestDss7_IRTS_floats()
        {
            string fn = TestUtility.BasePath + "simpleQCT7.dss";

            File.Delete(fn);
            Array  q     = Enum.GetValues(typeof(BaseQualityFlags));
            Random r     = new Random();
            var    qList = new List <int>();

            using (DssWriter w = new DssWriter(fn))
            {
                var      ts    = new TimeSeries();
                var      times = new List <DateTime>();
                var      vals  = new List <double>();
                DateTime start = new DateTime(2020, 1, 1);
                for (int i = 0; i < 10; i++)
                {
                    times.Add(start.AddDays(i * i));
                    vals.Add(i);
                }

                ts.Values   = vals.ToArray();
                ts.Times    = times.ToArray();
                ts.Path     = new DssPath("a", "b", "c", "", E: "IR-Year", F: "f");
                ts.Units    = "cfs";
                ts.DataType = "INST";
                for (int i = 0; i < ts.Values.Length; i++)
                {
                    BaseQualityFlags flag       = (BaseQualityFlags)q.GetValue(r.Next(q.Length));
                    Quality          newQuality = new Quality(flag);
                    qList.Add(newQuality.Value);
                }
                ts.Qualities = qList.ToArray();

                w.Write(ts, true);
            }

            using (DssReader reader = new DssReader(fn))
            {
                TimeSeries ts = reader.GetTimeSeries(new DssPath("/a/b/c//IR-Year/f/"));
                for (int i = 0; i < ts.Values.Length; i++)
                {
                    Assert.AreEqual(ts.Qualities[i], qList[i]);
                }
            }

            using (DssWriter w = new DssWriter(fn))
            {
                var ts = w.GetTimeSeries(new DssPath("/a/b/c//IR-Year/f/"));
                qList.Clear();
                for (int i = 0; i < ts.Values.Length; i++)
                {
                    BaseQualityFlags flag       = (BaseQualityFlags)q.GetValue(r.Next(q.Length));
                    Quality          newQuality = new Quality(flag);
                    qList.Add(newQuality.Value);
                }
                ts.Qualities = qList.ToArray();
                w.Write(ts, true);
            }

            using (DssReader reader = new DssReader(fn))
            {
                TimeSeries ts = reader.GetTimeSeries(new DssPath("/a/b/c//IR-Year/f/"));
                for (int i = 0; i < ts.Values.Length; i++)
                {
                    Assert.AreEqual(ts.Qualities[i], qList[i]);
                }
            }
        }