-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUploadPayload.cs
58 lines (45 loc) · 1.64 KB
/
UploadPayload.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using GeoJSON.Net.Geometry;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProtocolPayloadBenchmark {
/// <summary>
/// Internal POCO class used to serialize data to JSON.
/// </summary>
[JsonObject(MemberSerialization.OptIn)]
public class UploadPayload {
[JsonProperty("bearing")]
public double Bearing { get; set; }
[JsonProperty("time")]
public DateTime Time { get; set; }
[JsonProperty("duration")]
public int Duration { get; set; }
[JsonProperty("position-resolution")]
public int PositionResolution { get; set; }
[JsonProperty("position")]
public Point Position { get; set; }
[JsonProperty("values")]
public double[] Values { get; set; }
private static Random _rnd = new Random();
private static readonly long DefaultDuration = TimeSpan.FromSeconds(1.0 / 100.0).Ticks;
public static UploadPayload GenerateRandom() {
return new UploadPayload {
Bearing = _rnd.NextDouble() * 360.0,
Time = DateTime.UtcNow,
Duration = (int)DefaultDuration,
PositionResolution = (int)(_rnd.NextDouble() * 100),
Position = new Point(new GeographicPosition(0, 0)),
Values = new double[] {
_rnd.NextDouble(),
_rnd.NextDouble(),
_rnd.NextDouble(),
_rnd.NextDouble(),
_rnd.NextDouble()
}
};
}
}
}