-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompass.cs
More file actions
73 lines (71 loc) · 1.51 KB
/
Compass.cs
File metadata and controls
73 lines (71 loc) · 1.51 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Threading;
using Windows.Devices.Sensors;
using System.Threading.Tasks;
namespace Produire.Sensor
{
public class 方位センサー : IProduireClass
{
private Compass _compass;
/// <summary>
/// センサーから計測してその結果を返します。
/// </summary>
[自分で]
public 方位情報 計測()
{
if (_compass == null) _compass = Compass.GetDefault();
if (_compass != null)
{
var reading = _compass.GetCurrentReading();
return new 方位情報(reading);
}
else
return null;
}
/// <summary>
/// 測定に使用するセンサーをデバイスIDで選択します。
/// </summary>
[自分から]
public bool 選択(string ID)
{
Task<Compass> t1 = null;
Task.Run(() =>
{
t1 = Compass.FromIdAsync(ID).AsTask<Compass>();
}).Wait();
_compass = t1.Result;
return _compass != null;
}
public string デバイス名
{
get { return _compass.DeviceId; }
}
}
public class 方位情報 : ProduireEventArgs
{
CompassReading reading;
public 方位情報(CompassReading args)
{
this.reading = args;
}
public double 北角度
{
get { return reading.HeadingTrueNorth.Value; }
}
public double 方位
{
get { return reading.HeadingMagneticNorth; }
}
public DateTimeOffset 測定時刻
{
get { return reading.Timestamp; }
}
public TimeSpan 測定回数
{
get { return reading.PerformanceCount.Value; }
}
}
}