Exemplo n.º 1
0
        public void TestEquality()
        {
            TimeInterval interval1 = new TimeInterval(new JulianDate(1.0), new JulianDate(2.0));
            TimeInterval interval2 = new TimeInterval(new JulianDate(1.0), new JulianDate(2.0));
            Assert.AreEqual(interval1, interval2);
            Assert.AreEqual(interval2, interval1);
            Assert.IsTrue(interval1.Equals(interval2));
            Assert.IsTrue(interval2.Equals(interval1));
            Assert.IsTrue(interval1 == interval2);
            Assert.IsTrue(interval2 == interval1);
            Assert.IsFalse(interval1 != interval2);
            Assert.IsFalse(interval2 != interval1);

            interval2 = new TimeInterval(new JulianDate(1.0), new JulianDate(3.0));
            Assert.AreNotEqual(interval1, interval2);
            Assert.AreNotEqual(interval2, interval1);
            Assert.IsFalse(interval1.Equals(interval2));
            Assert.IsFalse(interval2.Equals(interval1));
            Assert.IsFalse(interval1 == interval2);
            Assert.IsFalse(interval2 == interval1);
            Assert.IsTrue(interval1 != interval2);
            Assert.IsTrue(interval2 != interval1);

            Assert.AreNotEqual(interval1, 5);
        }
Exemplo n.º 2
0
        public void Add(string[] cbttPcodeList, DateTime t1, DateTime t2,
            HydrometHost svr = HydrometHost.PN, TimeInterval interval = TimeInterval.Monthly, int back=0)
        {
            // make cbttPcodeList unique.
            List<string> lst = new List<string>(cbttPcodeList);
            cbttPcodeList =  lst.Distinct().ToArray();

            //minT = t1;
            //maxT = t2;
            m_interval = interval;

            string query = String.Join(",",cbttPcodeList);

            if (query.Length >0)
            {
                DataTable m_table = new DataTable();
                if (interval == TimeInterval.Monthly)
                {
                    m_table = HydrometDataUtility.MPollTable(svr, query, t1, t2);
                }
                else if (interval == TimeInterval.Daily)
                {
                    m_table = HydrometDataUtility.ArchiveTable(svr, query, t1, t2,back);
                }
                else if (interval == TimeInterval.Irregular)
                {
                    m_table = HydrometDataUtility.DayFilesTable(svr, query, t1, t2,back);
                }
                m_table.ExtendedProperties.Add("interval", interval.ToString());
                s_counter++;
                m_table.TableName = svr.ToString()+"_"+interval.ToString() + s_counter;
                m_dataSet.Tables.Add(m_table);
            }
        }
        public List<PVTableRow> AverageSessionLengthChart(string gameShort, TimeInterval interval, AWSRegion region, DateTime startDate, DateTime endDate)
        {
            GameMonitoringConfig game = Games.Instance.GetMonitoredGames().Where(x => x.ShortTitle == gameShort).FirstOrDefault();
            List<PVTableRow> DataTableInfo = GetAverageSessionLengthTable(interval, region, startDate, endDate, game);

            return DataTableInfo;
        }
        public JsonResult PrivateVsPublic(string game, AWSRegion region, TimeInterval interval, string start, string end)
        {
            DateTime st = Convert.ToDateTime(start);
            DateTime et = Convert.ToDateTime(end);

            return JsonResult(GameSessionsModel.Instance.GetPrivateSessionTimeSeries(game, interval, st, et));
        }
        public List<PVTimeSeries> GetAverageSessionLength(TimeInterval interval, AWSRegion region, DateTime startDate, DateTime endDate, string gameShortName)
        {
            List<PVTimeSeries> timeSeriesData = new List<PVTimeSeries>();
            DataTable queryResults = new DataTable();

            GameMonitoringConfig game = Games.Instance.GetMonitoredGames().Where(x => x.ShortTitle == gameShortName).FirstOrDefault();
            string query = String.Format(
                        @"select DATE(RecordCreated) as RecordTimeStamp,
                         SessionTypeFriendly as SeriesName,
                         round(avg(minute(timediff(RecordLastUpdateTime, RecordCreated)))) * 60 * 1000 as AverageSessionLength
                            from {0}
                            WHERE GameId = '{1}'
                            AND DATE(RecordCreated) BETWEEN '{2}' and '{3}'
                            AND minute(timediff(RecordLastUpdateTime, RecordCreated)) > 1
                            group by DATE(RecordCreated), SessionTypeFriendly
                            order by RecordCreated asc;",
                        "GameSessionMeta", game.Id, startDate.ToString("yyyy-MM-dd HH:mm:ss"), endDate.ToString("yyyy-MM-dd HH:mm:ss"));

            try
            {
                queryResults = DBManager.Instance.Query(Datastore.Monitoring, query);
                timeSeriesData = Charts.Instance.ProcessedTimeSeries(queryResults, interval, startDate, endDate, "RecordTimestamp");

            }
            catch (Exception ex)
            {
                Logger.Instance.Exception(ex.Message, ex.StackTrace);
            }

            return timeSeriesData;
        }
        public JsonResult UsersOnlineBySessionType(string game, AWSRegion region, TimeInterval interval, string start, string end)
        {
            DateTime st = Convert.ToDateTime(start);
            DateTime et = Convert.ToDateTime(end);

            return JsonResult(GameSessionsModel.Instance.UsersOnlineBySessionType(game, interval, region, st, et));
        }
        public JsonResult SessionLengthGraphData(string game, AWSRegion region, TimeInterval interval, string start, string end)
        {
            DateTime st = Convert.ToDateTime(start);
            DateTime et = Convert.ToDateTime(end);

            return JsonResult(GameSessionsModel.Instance.GetAverageSessionLength(interval, region, st, et, game));
        }
 public void SetCathedraModificator(Cathedra cathedra, TimeInterval interval)
 {
     foreach (var dataProvider in _dataProviders)
     {
         dataProvider.SetCathedraModificator(cathedra, interval);
     }
 }
Exemplo n.º 9
0
 public DataTableSeries(DataTable tbl, TimeInterval interval, string dateColumn, string valueColumnName)
 {
     this.data = tbl;
     this.TimeInterval = interval;
     this.dateColumn = dateColumn;
     this.valueColumnName = valueColumnName;
 }
 public void SetProfessorModificator(Person professor, TimeInterval interval)
 {
     foreach (var dataProvider in _dataProviders)
     {
         dataProvider.SetPersonModificator(professor, interval);
     }
 }
 public void SetFacultyModificator(TimeInterval interval)
 {
     foreach (var dataProvider in _dataProviders)
     {
         dataProvider.SetFacultyModificator(interval);
     }
 }
        public void PassToIso8601Interval()
        {
            //Since ToIso8601Interval is just a simple wrapper around two calls to
            //CesiumFormattingHelper.ToIso8601, this test is just a smoke screen.
            string expectedBasicInterval = "19800801T000000Z/20720703T000000Z";
            string expectedExtendedInterval = "1980-08-01T00:00:00Z/2072-07-03T00:00:00Z";
            string expectedCompactInterval = "19800801T00Z/20720703T00Z";

            JulianDate start = new GregorianDate(1980, 08, 01).ToJulianDate();
            JulianDate stop = new GregorianDate(2072, 07, 03).ToJulianDate();

            string basicInterval = CesiumFormattingHelper.ToIso8601Interval(start, stop, Iso8601Format.Basic);
            Assert.AreEqual(expectedBasicInterval, basicInterval);

            string extendedInterval = CesiumFormattingHelper.ToIso8601Interval(start, stop, Iso8601Format.Extended);
            Assert.AreEqual(expectedExtendedInterval, extendedInterval);

            string compactInterval = CesiumFormattingHelper.ToIso8601Interval(start, stop, Iso8601Format.Compact);
            Assert.AreEqual(expectedCompactInterval, compactInterval);

            TimeInterval interval = new TimeInterval(start, stop);
            basicInterval = CesiumFormattingHelper.ToIso8601Interval(interval, Iso8601Format.Basic);
            Assert.AreEqual(expectedBasicInterval, basicInterval);

            extendedInterval = CesiumFormattingHelper.ToIso8601Interval(interval, Iso8601Format.Extended);
            Assert.AreEqual(expectedExtendedInterval, extendedInterval);

            compactInterval = CesiumFormattingHelper.ToIso8601Interval(interval, Iso8601Format.Compact);
            Assert.AreEqual(expectedCompactInterval, compactInterval);
        }
Exemplo n.º 13
0
        public ActionResult Create(string name, int poolId)
        {
            try
            {
                Pool p = db.PoolSet.Find(poolId);
                int max = p.Division.Pools.Max(x => x.Teams.Count);
                if (p.Teams.Count == max)
                {
                    db.FinalsLinkSet.Add(new FinalsLink() { Division = p.Division, PoolPlacement = max + 1, Finalstage = max + 1 });
                }
                Team t = db.TeamSet.Add(new Team() { Name = name, Pool = p });
                // Add time intervals and default them to the tournament's time intervals
                foreach (TimeInterval ti in p.Division.Tournament.TimeIntervals)
                {
                    TimeInterval timeinterval = new TimeInterval() { Team = t, StartTime = ti.StartTime, EndTime = ti.EndTime };
                    db.TimeIntervalSet.Add(timeinterval);
                    t.TimeIntervals.Add(timeinterval);
                }
                //Clear the schedule
                sm.DeleteSchedule(p.Division.Tournament.Id, db);

                db.SaveChanges();

                return Json(new { status = "success", message = "New team added", id = t.Id }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return Json(new { status = "error", message = "New team not added", details = ex.Message }, JsonRequestBehavior.AllowGet);
            }
        }
Exemplo n.º 14
0
 public ConstantSeries(string name, string parameter, double value, TimeInterval interval)
 {
     m_value = value;
       this.Name = name;
       this.Parameter = parameter;
       this.TimeInterval = interval;
 }
Exemplo n.º 15
0
        public static Series ReadCorpsDataFile(string url, TimeInterval interval, params string[] headers)
        {
            string units = headers[headers.Length - 1];
            if( units == "n (ft)") // hack for Banks Lake.
                units = "(ft)";

            Series rval = new Series(units, interval);
            rval.HasFlags = true;

            string fileName = FileUtility.GetTempFileName(".txt");
            Web.GetTextFile(url, fileName, true);

            int[] widths = new int[] { 9, 5, 9, 9, 9, 9, 9, 9, 9, 9, 9,9,9 };

            var tf = new FixedWidthTextFile(fileName, widths);

            int col, row;
            tf.FindIndexToRange(headers, out row, out col);
            if (row < 0 || col < 0)
            {
                Logger.WriteLine("Error: no index found for headers '" + String.Join("','", headers) + "'");
                return rval;
            }

            rval.Name = String.Join(" ", headers, 0, headers.Length - 1);
            ReadDataIntoSeries(tf, rval, row + headers.Length, col);

            return rval;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Lookup hydromet Series.
        /// name is  interval_cbtt_pcode
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public override ParserResult Lookup(string name, TimeInterval defaultInterval)
        {
            var interval = defaultInterval;

            TimeSeriesName tn = new TimeSeriesName(name);
            if( tn.HasInterval)
            {
                interval = tn.GetTimeInterval();
            }

            if (tn.Valid)
            {
                Logger.WriteLine("Hydromet Lookup " + tn.siteid + "," + tn.pcode);
                var s = new Series();

                if (interval ==  TimeInterval.Monthly)
                {
                    s = new HydrometMonthlySeries(tn.siteid, tn.pcode,svr);
                }
                else if (interval == TimeInterval.Irregular)
                {
                    s = new HydrometInstantSeries(tn.siteid, tn.pcode,svr);
                }
                else if (interval == TimeInterval.Daily)
                {
                    s = new HydrometDailySeries(tn.siteid, tn.pcode,svr);
                }

                return new ParserResult(s);
            }
            else
            {
                return base.Lookup(name,interval);
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// </summary>
        /// <param name="stationID">example: 13245000</param>
        /// <param name="ipcoType">Q,Qin,HW,Qx,S</param>
        /// <param name="numDays">how many days back</param>
        /// <returns></returns>
        public static Series GetIdahoPowerData(string stationID, string ipcoType, int numDays, TimeInterval interval)
        {
            string xmlFileName = GetIdahoPowerXmlFile(stationID, interval, numDays);

            var s = ParseXmlData(xmlFileName, stationID, ipcoType, interval);
            return s;
        }
Exemplo n.º 18
0
 public void MomentTest() {
     DateTime moment = ClockProxy.Clock.Now;
     TimeInterval timeInterval = new TimeInterval(moment);
     Assert.AreEqual(timeInterval.Start, moment);
     Assert.AreEqual(timeInterval.End, moment);
     Assert.IsTrue(timeInterval.IsMoment);
     Assert.IsTrue(timeInterval.IsDegenerate);
 }
Exemplo n.º 19
0
        public void TestCalculateDuration()
        {
            JulianDate start = new JulianDate(2451545.0);
            JulianDate stop = start + Duration.FromDays(1.5);
            TimeInterval interval = new TimeInterval(start, stop);

            Assert.AreEqual(Duration.FromDays(1.5), interval.ToDuration());
        }
Exemplo n.º 20
0
 public void TestRetainValue()
 {
     JulianDate start = new JulianDate(DateTime.UtcNow);
     JulianDate stop = start + Duration.FromDays(1.5);
     TimeInterval interval = new TimeInterval(start, stop);
     Assert.AreEqual(start, interval.Start);
     Assert.AreEqual(stop, interval.Stop);
 }
Exemplo n.º 21
0
        public void TestIsEmpty()
        {
            TimeInterval interval = new TimeInterval(new JulianDate(1.0), new JulianDate(1.0));
            Assert.IsTrue(interval.IsEmpty);

            interval = new TimeInterval(new JulianDate(5.0), new JulianDate(4.0));
            Assert.IsTrue(interval.IsEmpty);
        }
Exemplo n.º 22
0
        public void TimeInterval_GetHashCode()
        {
            var ti = new TimeInterval<string>(null, TimeSpan.FromSeconds(123.45));
            Assert.True(ti.GetHashCode() != 0);
            Assert.Equal(ti.GetHashCode(), ti.GetHashCode());

            var t2 = new TimeInterval<string>("", TimeSpan.FromSeconds(123.45));
            Assert.NotEqual(ti.GetHashCode(), t2.GetHashCode());
        }
Exemplo n.º 23
0
 public void DefaultTest() {
     TimeInterval timeInterval = new TimeInterval();
     Assert.AreNotEqual(timeInterval, TimeInterval.Anytime);
     Assert.AreEqual(timeInterval.GetRelation(TimeInterval.Anytime), PeriodRelation.ExactMatch);
     Assert.IsTrue(timeInterval.IsAnytime);
     Assert.IsTrue(timeInterval.IsClosed);
     Assert.IsFalse(timeInterval.IsOpen);
     Assert.IsFalse(timeInterval.IsMoment);
     Assert.IsFalse(timeInterval.IsReadOnly);
 }
Exemplo n.º 24
0
Arquivo: Math.cs Projeto: usbr/Pisces
        /// <summary>
        /// Function that averages a series based on a defined Time-Interval
        /// </summary>
        /// <param name="s">Input Series</param>
        /// <param name="tInterval">Averaging Time-Interval</param>
        /// <returns></returns>
        public static Series Average(Series s, TimeInterval tInterval)
        {
            Series rval = s.Clone();
            if (s.Count == 0)
                return rval;

            // Define starting date of averaging process
            DateTime t = new DateTime(s[0].DateTime.Year, s[0].DateTime.Month, s[0].DateTime.Day,
                s[0].DateTime.Hour, 0, 0);

            // Find which averaging process to accomplish
            if (tInterval == TimeInterval.Daily)
            {
                // Define series time-interval
                rval.TimeInterval = TimeInterval.Daily;
                // Loop through the dates
                while (t < s[s.Count - 1].DateTime.Date)
                {
                    // Get the series subset based on the averaging time-interval
                    Series sTemp = s.Subset(t, t.AddDays(1));
                    // Average the values of the subset
                    DoAverage(rval, t, sTemp);
                    // Increment DateTime by averaging time-interval
                    t = t.AddDays(1);
                }
            }
            // Ditto on the other processes below
            else if (tInterval == TimeInterval.Monthly)
            {
                rval.TimeInterval = TimeInterval.Monthly;
                while (t < s[s.Count - 1].DateTime.Date)
                {
                    Series sTemp = s.Subset(t, t.AddMonths(1));
                    DoAverage(rval, t, sTemp);
                    t = t.AddMonths(1);
                }
            }
            else if (tInterval == TimeInterval.Hourly)
            {
                rval.TimeInterval = TimeInterval.Hourly;
                while (t < s.MaxDateTime)
                {

                    Series sTemp = Math.Subset(s, new DateRange(t, t.AddHours(1)), false);
                    DoAverage(rval, t, sTemp);
                    t = t.AddHours(1);

                }
            }
            else
            { throw new Exception("Time Interval " + tInterval.ToString() + " not supported!"); }

            return rval;
        }
Exemplo n.º 25
0
        public void HasEndTest() {
            TimeInterval timeInterval1 = new TimeInterval(TimeSpec.MinPeriodTime, ClockProxy.Clock.Now);
            Assert.IsFalse(timeInterval1.HasStart);
            Assert.IsTrue(timeInterval1.HasEnd);

            TimeInterval timeInterval2 = new TimeInterval(TimeSpec.MinPeriodTime, TimeSpec.MaxPeriodTime);
            Assert.IsFalse(timeInterval2.HasEnd);

            TimeInterval timeInterval3 = new TimeInterval(
                TimeSpec.MinPeriodTime, TimeSpec.MaxPeriodTime, IntervalEdge.Open, IntervalEdge.Open);
            Assert.IsTrue(timeInterval3.HasEnd);
        }
Exemplo n.º 26
0
 public HDBSeries(int sdi,TimeInterval interval, HDBServer server )
 {
     m_sdi = sdi;
     m_server = server;
     this.TimeInterval = TimeSeries.TimeInterval.Daily;
     Source = "hdb"; //  need icon for HDB
     Provider = "HDBSeries";
     ConnectionString = "server=" + m_server
     + ";sdi=" + m_sdi
     + ";TimeInterval="+interval.ToString()
     +";LastUpdate=" + DateTime.Now.ToString(DateTimeFormatInstantaneous);
     Init();
 }
        public List<PVTableRow> GetAverageSessionLengthTable(TimeInterval interval, AWSRegion region, DateTime startDate, DateTime endDate, GameMonitoringConfig game)
        {
            #region Validation

            if (!interval.IsSupportedInterval(TimeInterval.Minute, TimeInterval.Year))
            {
                throw new Exception(String.Format("Chart data only supports an interval between {0} and {1}", TimeInterval.Day, TimeInterval.Year));
            }

            if (startDate == DateTime.MinValue || endDate == DateTime.MinValue || (startDate >= endDate))
            {
                throw new Exception("StartDate and EndDate cannot be null, and StartDate must come before EndDate");
            }

            if (String.IsNullOrEmpty(game.Id))
            {
                throw new Exception("GameID cannot be empty or null");
            }

            #endregion
            List<PVTableRow> dataTableData = new List<PVTableRow>();
            DataTable queryResults = new DataTable();

            startDate = startDate.RoundDown(interval);
            endDate = endDate.RoundDown(interval);

            string query = String.Format(
                        @"select DATE(RecordCreated) as RecordTimeStamp,
                         SessionTypeFriendly as SeriesName,
                         round(avg(minute(timediff(RecordLastUpdateTime, RecordCreated)))) as AverageSessionLength
                            from {0}
                            WHERE GameId = '{1}'
                            AND DATE(RecordCreated) BETWEEN '{2}' and '{3}'
                            AND minute(timediff(RecordLastUpdateTime, RecordCreated)) > 1
                            group by DATE(RecordCreated), SessionTypeFriendly
                            order by RecordCreated asc;",
                        "GameSessionMeta", game.Id, startDate.ToString("yyyy-MM-dd HH:mm:ss"), endDate.ToString("yyyy-MM-dd HH:mm:ss"));

            try
            {
                queryResults = DBManager.Instance.Query(Datastore.Monitoring, query);
                dataTableData = Charts.Instance.ProcessedSessionLengthData(queryResults, interval, startDate, endDate, "RecordTimestamp");

            }
            catch (Exception ex)
            {
                Logger.Instance.Exception(ex.Message, ex.StackTrace);
            }

            return dataTableData;
        }
Exemplo n.º 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Event"/> struct.
 /// </summary>
 /// <param name="category">
 /// Typically the object that was interacted with (e.g. button)
 /// </param>
 /// <param name="action">
 /// The type of interaction (e.g. click)
 /// </param>
 /// <param name="from">
 /// The inclusive start of the period that we're interested in.
 /// </param>
 /// <param name="to">
 /// The exclusive end of the period that we're interested in.
 /// </param>
 /// <param name="timeInterval">
 /// The accuracy at which we want the data. For example, setting this to TimeInterval.OneDay means there won't
 /// be any keys at the fifteen minute or one hour levels, so if the <paramref name="from"/> DateTime is for the
 /// middle of a day, it'll include the entire day.
 /// </param>
 public Event(
     string category,
     string action,
     DateTime from,
     DateTime to,
     TimeInterval timeInterval = TimeInterval.FifteenMinutes)
 {
     this._category = category;
     this._action = action;
     this._from = from;
     this._to = to;
     this._redisKeys = null;
     this._timeInterval = timeInterval;
 }
Exemplo n.º 29
0
        public static Series GetIdahoPowerData(string stationID, string ipcoType, TimeInterval interval, DateTime t1, DateTime t2)
        {
            if( t1 > DateTime.Now)
                return new Series();

            var ts = TimeSpan.FromTicks( DateTime.Now.Ticks- t1.Ticks );

            string xmlFileName = GetIdahoPowerXmlFile(stationID, interval, ts.Days);

            var s = ParseXmlData(xmlFileName, stationID, ipcoType, interval);

            s.Trim(t1, t2);
            return s;
        }
        public List<PVTimeSeries> AverageSessionLength(string gameShort, TimeInterval interval, AWSRegion region, DateTime startDate, DateTime endDate)
        {
            //List<OnlineBySessionTypeSeries> retVal = new List<OnlineBySessionTypeSeries>();

            //need to format this data in the appropriate way as to feed it directly into high charts
            List<PVTimeSeries> TimeSeriesChart = GetAverageSessionLength(interval, region, startDate, endDate, gameShort);

            //this is the datetime format with TimeZone encoded in thatjavascript understands
            // the Z means UTC
            // and also JS Date has a method to JSON that turns the datetime into this string.
            // f**k yeah
            string IEFTFormatForJSON = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");

            return TimeSeriesChart;
        }
Exemplo n.º 31
0
 public void Update(TimeInterval gt)
 {
 }
Exemplo n.º 32
0
        public static void Main(string[] args)
        {
            var times = new TimeInterval[] { new TimeInterval(30, 75), new TimeInterval(0, 50), new TimeInterval(60, 150) };

            Console.WriteLine(GetRequiredRoomAmount(times));
        }
 public async Task InsertOrMergeAsync(IEnumerable <IFeedCandle> candles, string asset, TimeInterval interval, PriceType priceType)
 {
     foreach (var candle in candles)
     {
         await this.InsertOrMergeAsync(candle, asset, interval, priceType);
     }
 }
Exemplo n.º 34
0
 /// <inheritdoc />
 public void Update(TimeInterval messagesTimeInterval, TimeInterval messagesOriginatingTimeInterval)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 35
0
 /// <summary>
 /// Maximum acceptable error for a benchmark (by default, BenchmarkDotNet continue iterations until the actual error is less than the specified error).
 /// Doesn't have a default value.
 /// <remarks>If <see cref="AccuracyMode.MaxRelativeError"/> is also provided, the smallest value is used as stop criteria.</remarks>
 /// </summary>
 public static Job WithMaxAbsoluteError(this Job job, TimeInterval value) => job.WithCore(j => j.Accuracy.MaxAbsoluteError = value);
Exemplo n.º 36
0
 public void UpdateMainInterval(TimeInterval ti, CameraTimeInfo[] tmpList)
 {
     main = ti;
     UpdateAll(tmpList);
 }
Exemplo n.º 37
0
 /// <summary>
 /// Determines whether the current TimeInterval&lt;T&gt; value has the same Value and Interval as a specified TimeInterval&lt;T&gt; value.
 /// </summary>
 /// <param name="other">An object to compare to the current TimeInterval&lt;T&gt; value.</param>
 /// <returns>true if both TimeInterval&lt;T&gt; values have the same Value and Interval; otherwise, false.</returns>
 public bool Equals(TimeInterval <T> other)
 {
     return(other.Interval.Equals(Interval) && EqualityComparer <T> .Default.Equals(Value, other.Value));
 }
Exemplo n.º 38
0
        private void GetHistory(TimeInterval interval, TimeSpan span, DateTime now)
        {
            var entry = _context.TimeEvents.OrderBy(e => e.Created, SortOrder.Desc).FirstOrDefault(e => e.Type == interval);

            _lastCheck.Add(interval, new CheckHolder(entry?.Created ?? now, span));
        }
 public QuantityConstraintModel()
 {
     ForTimeInterval    = new TimeInterval();
     Quantity           = 0;
     ComparisonOperator = ComparisonOperator.Equals;
 }
Exemplo n.º 40
0
 public CsvFormatter(TimeInterval interval, bool printFlags)
     : base(interval, printFlags)
 {
 }
Exemplo n.º 41
0
        public static void AddAvarageTimeInterval(this AvarageTimeInterval targetTimeInterval, TimeInterval newTimeInterval)
        {
            var prevDuration = targetTimeInterval.AvarageDuration * targetTimeInterval.Count;

            targetTimeInterval.Count++;
            targetTimeInterval.AvarageDuration = (prevDuration + newTimeInterval.Duration) / targetTimeInterval.Count;
        }
Exemplo n.º 42
0
 private NowUntil(TimeInterval timeInterval) => _timeInterval = timeInterval;
 public string FormatTimeInterval(TimeInterval interval)
 {
     return(String.Format("({0}) - ({1})", FormatDateTime(interval.Start), FormatDateTime(interval.End.AddTicks(1))));
 }
Exemplo n.º 44
0
        private DateTime GetEndDate(DateTime now, TimeInterval interval, int numberOfCandleSticks)
        {
            switch (interval)
            {
            case TimeInterval.Minutes_1:
                return(now.AddDays(-5));

                break;

            case TimeInterval.Minutes_3:
                return(now.AddDays(-5));

                break;

            case TimeInterval.Minutes_5:
                return(now.AddDays(-5));

                break;

            case TimeInterval.Minutes_15:
                return(now.AddDays(-5));

                break;

            case TimeInterval.Minutes_30:
                return(now.AddDays(-5));

                break;

            case TimeInterval.Hours_1:
                return(now.AddDays(-10));

                break;

            case TimeInterval.Hours_2:
                return(now.AddDays(-10));

                break;

            case TimeInterval.Hours_4:
                return(now.AddDays(-50));

                break;

            case TimeInterval.Hours_6:
                return(now.AddDays(-50));

                break;

            case TimeInterval.Hours_8:
                return(now.AddDays(-50));

                break;

            case TimeInterval.Hours_12:
                return(now.AddDays(-50));

                break;

            case TimeInterval.Days_1:
                return(now.AddDays(-100));

                break;

            case TimeInterval.Days_3:
                return(now.AddDays(-300));

                break;

            case TimeInterval.Weeks_1:
                return(now.AddDays(-700));

                break;

            case TimeInterval.Months_1:
                return(now.AddMonths(-100));

                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(interval), interval, null);
            }
        }
Exemplo n.º 45
0
 public void Initialize()
 {
     main = new TimeInterval(DateTime.Now, DateTime.Now.AddMinutes(10));
 }
 public Task <IEnumerable <IFeedCandle> > GetCandlesAsync(string asset, TimeInterval interval, PriceType priceType, DateTime from, DateTime to)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 47
0
 public void Initialize(DateTime startTime, DateTime endTime)
 {
     main = new TimeInterval(startTime, endTime);
 }
 public Task <IFeedCandle> GetCandleAsync(string asset, TimeInterval interval, PriceType priceType, DateTime dateTime)
 {
     throw new NotImplementedException();
 }
 public MinIterationTimeAttribute(double milliseconds) : base(Job.Default.WithMinIterationTime(TimeInterval.FromMilliseconds(milliseconds)))
 {
 }
Exemplo n.º 50
0
        /// <summary>
        /// Expand simplified query
        /// BOII MX,MN,MM
        /// is translated to
        /// BOII MX, BOII MN, BOII MM
        ///
        /// GREY
        /// is translated to
        /// GREY GH, GREY Q
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public static string ExpandQuery(string query, TimeInterval db)
        {
            var rval = new List <string>();


            string title = "";
            var    idx   = query.IndexOf("#");

            if (idx >= 0)
            {
                title = query.Substring(idx);
                query = query.Substring(0, idx);
            }
            query = query.Trim();

            if (CbttOnly(query))
            {
                string[] pcodes = GetParameters(query, db);
                if (pcodes.Length > 0)
                {
                    query = query + " " + String.Join(",", pcodes);
                    //   return query;
                }
            }

            string[] pairs = query.Split(',');
            string   cbtt  = "";
            var      pc    = "";

            for (int i = 0; i < pairs.Length; i++)
            {
                string s = pairs[i];
                s = s.Replace(": ", ":");
                var tokens = s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                if (i == 0 && tokens.Length != 2)
                {
                    Logger.WriteLine("query syntax Error: first pair must have cbtt and pcode");
                    return(query);
                }

                if (tokens.Length == 2)
                {
                    cbtt = tokens[0];
                    pc   = tokens[1];
                }
                else if (tokens.Length == 1)
                {
                    pc = tokens[0];
                }
                else if (tokens.Length == 0)
                {
                    continue;
                }

                rval.Add(cbtt + " " + pc);
            }
            string r = String.Join(",", rval.ToArray());

            if (r.Trim() != query.Trim())
            {
                Logger.WriteLine("query expanded to '" + r + "'");
            }
            return(r + title);
        }
Exemplo n.º 51
0
        private void PrintHtmlInventory(string siteID, TimeInterval interval, bool ui)
        {
            var parms = db.GetParameters(siteID, interval);
            var desc  = db.GetSiteDescription(siteID);

            WriteLine("<!DOCTYPE html>");
            WriteLine("<html>");



            DataTable tbl = new DataTable();

            tbl.Columns.Add("parameter");
            tbl.Columns.Add("available records");
            tbl.Columns.Add("description");
            int firstYear = DateTime.Now.Year;
            int minYr = 0, maxYr = 0;
            int min = 0, max = 0;

            for (int i = 0; i < parms.Length; i++)
            {
                string por = db.GetPeriodOfRecord(siteID, parms[i], interval, out minYr, out maxYr);
                if (i == 0)
                {
                    min = minYr;
                    max = maxYr;
                }
                if (minYr < min)
                {
                    min = minYr;
                }
                if (maxYr > max)
                {
                    max = maxYr;
                }

                if (ui)
                {
                    var cb = " <input type=\"checkbox\" name=\"pcode\" value=\"" + parms[i] + "\" id=\"" + parms[i] + "\">" + parms[i].ToUpper();
                    tbl.Rows.Add(cb, db.GetParameterDescription(parms[i], interval), por);
                }
                else
                {
                    tbl.Rows.Add(parms[i], db.GetParameterDescription(parms[i], interval), por);
                }
            }

            if (ui)
            {
                string cgiTag = "";
                if (CgiUtility.IsRemoteRequest())
                {
                    cgiTag = ".pl";
                }
                if (interval == TimeInterval.Daily)
                {
                    WriteLine("<form name=\"Form\" action=\"/pn-bin/daily" + cgiTag + "\" method=\"get\" >");
                }
                else
                {
                    WriteLine("<form name=\"Form\" action=\"/pn-bin/instant" + cgiTag + "\" method=\"get\" >");
                }

                WriteLine("<input name=station type=\"hidden\" value=\"" + siteID + "\">");
                WriteLine("<input name=format type=\"hidden\" value=\"html\">");

                WriteTimeSelector(siteID, min, max);
            }
            var s = DataTableOutput.ToHTML(tbl, false, desc);

            WriteLine(s);

            WriteLine("<p><input type=\"submit\" value=\"Retrieve Daily Data\">");

            if (ui)
            {
                WriteLine("</form>");
            }
            //WriteLine("<\\html>");
        }
Exemplo n.º 52
0
 public void SetWorkingHours(TimeInterval hours)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 53
0
 /// <summary>
 /// Minimum time of a single iteration. Unlike Run.IterationTime, this characteristic specifies only the lower limit. In case of need, BenchmarkDotNet can increase this value.
 /// The default value is 500 milliseconds.
 /// </summary>
 public static Job WithMinIterationTime(this Job job, TimeInterval value) => job.WithCore(j => j.Accuracy.MinIterationTime = value);
Exemplo n.º 54
0
 public void SetAnnualLeave(TimeInterval period)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 55
0
 /// <summary>
 /// Desired time of execution of an iteration. Used by Pilot stage to estimate the number of invocations per iteration.
 /// The default value is 500 milliseconds.
 /// </summary>
 public static Job WithIterationTime(this Job job, TimeInterval time) => job.WithCore(j => j.Run.IterationTime = time);
Exemplo n.º 56
0
 public void RunActions(TimeInterval gt)
 {
 }
 public BlockingConstraintModel()
 {
     ForTimeInterval         = new TimeInterval();
     ForPeriodicTimeInterval = new PeriodicTimeIntervalModel();
 }
Exemplo n.º 58
0
        private static bool InCache(DataTable tbl, string key, DateTime t1, DateTime t2, TimeInterval interval)
        {
            int idx = tbl.Columns.IndexOf(key);

            if (idx < 0)
            {
                return(false);
            }
            if (tbl.Rows.Count == 0)
            {
                return(false);
            }

            DateTime tMin = (DateTime)tbl.Rows[0][0];
            DateTime tMax = (DateTime)tbl.Rows[tbl.Rows.Count - 1][0];

            if (interval == TimeInterval.Monthly)
            {
                tMin = tMin.FirstOfMonth();
                tMax = tMax.EndOfMonth();
            }

            if (interval == TimeInterval.Irregular)
            {  // hydromet/agrimet data comes in once per hour..
                // loosen tolerence to corespond
                tMin = tMin.AddHours(-1);
                tMax = tMax.AddHours(1);
            }



            return((t1 >= tMin && t1 <= tMax) &&
                   (t2 >= tMin && t2 <= tMax));
        }
Exemplo n.º 59
0
        /// <summary>
        /// Receiver for the combined VAD signal and audio data.
        /// </summary>
        /// <param name="data">A message containing the combined VAD signal and audio data.</param>
        /// <param name="e">The message envelope</param>
        /// <returns>The <see cref="Task"/> representing the asynchronous operation.</returns>
        protected override async Task ReceiveAsync(ValueTuple <AudioBuffer, bool> data, Envelope e)
        {
            byte[] audioData = data.Item1.Data;
            bool   hasSpeech = data.Item2;

            this.lastAudioOriginatingTime = e.OriginatingTime;

            // Throw if a fatal error has occurred in the OnConversationError event handler
            if (this.fatalError)
            {
                if (this.conversationError != null)
                {
                    var error = this.conversationError;
                    this.conversationError = null;
                    throw error;
                }

                // Stop processing until the pipeline terminates
                return;
            }

            if (hasSpeech || this.lastAudioContainedSpeech)
            {
                // Send the audio data to the cloud
                await this.speechRecognitionClient.SendAudioAsync(audioData, this.cancellationTokenSource.Token);

                // Add audio to the current utterance queue so we can reconstruct it in the recognition result later
                this.currentQueue.Enqueue(data.DeepClone(this.In.Recycler));
            }

            // If this is the last audio packet containing speech
            if (!hasSpeech && this.lastAudioContainedSpeech)
            {
                this.lastVADSpeechEndTime      = e.OriginatingTime;
                this.lastVADSpeechTimeInterval = new TimeInterval(this.lastVADSpeechStartTime, this.lastVADSpeechEndTime);

                // Allocate a buffer large enough to hold the buffered audio
                BufferWriter bw = new BufferWriter(this.currentQueue.Sum(b => b.Item1.Length));

                // Get the audio associated with the recognized text from the current queue.
                ValueTuple <AudioBuffer, bool> buffer;
                while (this.currentQueue.TryDequeue(out buffer))
                {
                    bw.Write(buffer.Item1.Data);

                    // We are done with this buffer so enqueue it for recycling
                    this.In.Recycle(buffer);
                }

                // Save the buffered audio
                this.lastAudioBuffer = bw.Buffer;

                // Call EndAudio to signal that this is the last packet
                await this.speechRecognitionClient.SendEndAudioAsync(this.cancellationTokenSource.Token);
            }
            else if (hasSpeech && !this.lastAudioContainedSpeech)
            {
                // If this is the first audio packet containing speech
                this.lastVADSpeechStartTime = e.OriginatingTime;

                // Also post a null partial recognition result
                this.lastPartialResult = string.Empty;
                this.OutputResult(this.BuildPartialSpeechRecognitionResult(this.lastPartialResult), e.OriginatingTime);
            }

            // Remember last audio state.
            this.lastAudioContainedSpeech = hasSpeech;
        }
Exemplo n.º 60
0
 public RecentDataFormatter(TimeInterval interval, bool printFlags) : base(interval, printFlags)
 {
 }