|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace BultonFr\NMEA\Frames; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Define the parser system for GSV frame type |
|
7
|
|
|
* |
|
8
|
|
|
* @package BultonFr\NMEA |
|
9
|
|
|
* @author Vermeulen Maxime <[email protected]> |
|
10
|
|
|
* @link http://www.gpsinformation.org/dale/nmea.htm#GSV |
|
11
|
|
|
* @link http://aprs.gids.nl/nmea/#gsv |
|
12
|
|
|
*/ |
|
13
|
|
|
class GSV extends \BultonFr\NMEA\Frame |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* {@inheritdoc} |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $frameType = 'GSV'; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* {@inheritdoc} |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $frameRegex = '/^' |
|
24
|
|
|
.'([A-Z]{2}[A-Z]{3}),' //Equipment and trame type |
|
25
|
|
|
.'(\d*),' //Number of sentences for full data |
|
26
|
|
|
.'(\d*),' //Sentence number |
|
27
|
|
|
.'(\d*)' //Number of satellites in view |
|
28
|
|
|
.'(,(\d*),(\d*),(\d*),(\d*)' //Infos about first satellite |
|
29
|
|
|
.'(,(\d*),(\d*),(\d*),(\d*)' //Infos about second satellite |
|
30
|
|
|
.'(,(\d*),(\d*),(\d*),(\d*)' //Infos about trird satellite |
|
31
|
|
|
.'(,(\d*),(\d*),(\d*),(\d*)' //Infos about fourth satellite |
|
32
|
|
|
.')?)?)?)?' |
|
33
|
|
|
.'$/m'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var int $sentenceTotalNumber Number of sentences for full data |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $sentenceTotalNumber; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var int $sentenceCurrentNumber Sentence number |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $sentenceCurrentNumber; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var int $satellitesNumber Number of satellites in view |
|
47
|
|
|
*/ |
|
48
|
|
|
protected $satellitesNumber; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @var \stdClass[] $satellitesInfos Infos about satellites |
|
52
|
|
|
* Array of object; Object contains properties : |
|
53
|
|
|
* * prnNumber |
|
54
|
|
|
* * elevation in degrees. max 90 |
|
55
|
|
|
* * azimuth, degrees from tue north. 0 to 359 |
|
56
|
|
|
* * SNR. 0 to 99dB |
|
57
|
|
|
*/ |
|
58
|
|
|
protected $satellitesInfos; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Getter to property sentenceTotalNumber |
|
62
|
|
|
* |
|
63
|
|
|
* @return int |
|
64
|
|
|
*/ |
|
65
|
|
|
public function getSentenceTotalNumber() |
|
66
|
|
|
{ |
|
67
|
1 |
|
return $this->sentenceTotalNumber; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Getter to property sentenceCurrentNumber |
|
72
|
|
|
* |
|
73
|
|
|
* @return int |
|
74
|
|
|
*/ |
|
75
|
|
|
public function getSentenceCurrentNumber() |
|
76
|
|
|
{ |
|
77
|
1 |
|
return $this->sentenceCurrentNumber; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Getter to property satellitesNumber |
|
82
|
|
|
* |
|
83
|
|
|
* @return int |
|
84
|
|
|
*/ |
|
85
|
|
|
public function getSatellitesNumber() |
|
86
|
|
|
{ |
|
87
|
1 |
|
return $this->satellitesNumber; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Getter to property satelliteInfos |
|
92
|
|
|
* |
|
93
|
|
|
* @return \stdClass[] |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getSatellitesInfos() |
|
96
|
|
|
{ |
|
97
|
1 |
|
return $this->satellitesInfos; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* {@inheritdoc} |
|
102
|
|
|
*/ |
|
103
|
|
|
protected function decodeFrame($msgParts) |
|
104
|
|
|
{ |
|
105
|
1 |
|
$this->sentenceTotalNumber = (int) $msgParts[2]; |
|
106
|
1 |
|
$this->sentenceCurrentNumber = (int) $msgParts[3]; |
|
107
|
1 |
|
$this->satellitesNumber = (int) $msgParts[4]; |
|
108
|
|
|
|
|
109
|
1 |
|
for ($svIndex = 0; $svIndex <= 3; $svIndex++) { |
|
110
|
1 |
|
$this->satellitesInfos[$svIndex] = (object) [ |
|
111
|
1 |
|
'prnNumber' => 0, |
|
112
|
|
|
'elevation' => 0, |
|
113
|
|
|
'azimuth' => 0, |
|
114
|
|
|
'SNR' => 0, |
|
115
|
|
|
]; |
|
116
|
|
|
|
|
117
|
1 |
|
$indexPos = 5 * $svIndex; |
|
118
|
1 |
|
if (!isset($msgParts[(6 + $indexPos)])) { |
|
119
|
1 |
|
continue; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
1 |
|
$svInfos = &$this->satellitesInfos[$svIndex]; |
|
123
|
1 |
|
$svInfos->prnNumber = (int) $msgParts[(6 + $indexPos)]; |
|
124
|
1 |
|
$svInfos->elevation = (int) $msgParts[(7 + $indexPos)]; |
|
125
|
1 |
|
$svInfos->azimuth = (int) $msgParts[(8 + $indexPos)]; |
|
126
|
1 |
|
$svInfos->SNR = (int) $msgParts[(9 + $indexPos)]; |
|
127
|
|
|
} |
|
128
|
1 |
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|