public void ValueEqualsFalseValTest() { TimeSeriesValue tsv1 = new TimeSeriesValue { Date = date1, Value = val1 }; TimeSeriesValue tsv2 = new TimeSeriesValue { Date = date1, Value = val2 }; Assert.IsFalse(tsv1.ValueEquals(tsv2)); }
public async Task JsonCappedList_SaveLoadAsync() { using var db = RedisHelper.CreateRedisConnection(this.Logger, UnitTestSettingsFile); var input = new TimeSeriesValue <string> { Y = "asdf", X = new DateTimeOffset(12, 12, 12, 12, 12, 12, TimeSpan.FromMinutes(30)) }; var key = Guid.NewGuid().ToString(); { var l = new JsonCappedList <TimeSeriesValue <string> >(key, 3, db.GetDatabase().Native); await l.Remote.LoadAsync(default);
public void ConvertToStruct2() { TSDateValueStruct tsdvs = new TSDateValueStruct { Date = date2, Value = val2 }; TimeSeriesValue tsv = new TimeSeriesValue { Date = date2, Value = val2 }; TSDateValueStruct actual = ((TSDateValueStruct)(tsv)); Assert.AreEqual(tsdvs, actual); }
public void ConvertFromStruct2() { TSDateValueStruct tsdvs = new TSDateValueStruct { Date = date2, Value = val2 }; TimeSeriesValue tsv = new TimeSeriesValue { Date = date2, Value = val2 }; TimeSeriesValue actual = ((TimeSeriesValue)(tsdvs)); Assert.IsTrue(tsv.ValueEquals(actual)); }
private async Task RunQueryEventsSample(TimeSeriesInsightsQueries queriesClient, TimeSeriesId tsId) { #region Snippet:TimeSeriesInsightsSampleQueryEvents Console.WriteLine("\n\nQuery for raw temperature events over the past 10 minutes.\n"); // Get events from last 10 minute DateTimeOffset endTime = DateTime.UtcNow; DateTimeOffset startTime = endTime.AddMinutes(-10); QueryAnalyzer temperatureEventsQuery = queriesClient.CreateEventsQuery(tsId, startTime, endTime); await foreach (TimeSeriesPoint point in temperatureEventsQuery.GetResultsAsync()) { TimeSeriesValue temperatureValue = point.GetValue("Temperature"); // Figure out what is the underlying type for the time series value. Since you know your Time Series Insights // environment best, you probably do not need this logic and you can skip to directly casting to the proper // type. This logic demonstrates how you can figure out what type to cast to in the case where you are not // too familiar with the property type. if (temperatureValue.Type == typeof(double?)) { Console.WriteLine($"{point.Timestamp} - Temperature: {point.GetNullableDouble("Temperature")}"); } else if (temperatureValue.Type == typeof(int?)) { Console.WriteLine($"{point.Timestamp} - Temperature: {point.GetNullableInt("Temperature")}"); } else { Console.WriteLine("The type of the Time Series value for Temperature is not numeric."); } } #endregion Snippet:TimeSeriesInsightsSampleQueryEvents // Query for raw events using a time interval #region Snippet:TimeSeriesInsightsSampleQueryEventsUsingTimeSpan Console.WriteLine("\n\nQuery for raw humidity events over the past 30 seconds.\n"); QueryAnalyzer humidityEventsQuery = queriesClient.CreateEventsQuery(tsId, TimeSpan.FromSeconds(30)); await foreach (TimeSeriesPoint point in humidityEventsQuery.GetResultsAsync()) { TimeSeriesValue humidityValue = point.GetValue("Humidity"); // Figure out what is the underlying type for the time series value. Since you know your Time Series Insights // environment best, you probably do not need this logic and you can skip to directly casting to the proper // type. This logic demonstrates how you can figure out what type to cast to in the case where you are not // too familiar with the property type. if (humidityValue.Type == typeof(double?)) { Console.WriteLine($"{point.Timestamp} - Humidity: {point.GetNullableDouble("Humidity")}"); } else if (humidityValue.Type == typeof(int?)) { Console.WriteLine($"{point.Timestamp} - Humidity: {point.GetNullableInt("Humidity")}"); } else { Console.WriteLine("The type of the Time Series value for Humidity is not numeric."); } } #endregion Snippet:TimeSeriesInsightsSampleQueryEventsUsingTimeSpan }