-
Notifications
You must be signed in to change notification settings - Fork 1
/
cordrecord.php
executable file
·461 lines (391 loc) · 16.9 KB
/
cordrecord.php
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
#!/usr/bin/env php
<?php
/*
This program will generate a plain text formated record of FASMA coordination
records for a record ID. There are mutiple options presented:
* Private Coordination Record - for sending to the trustee
* Public Record for posting to website
* PCN record for sending to adjacent states
Copyright (C) 2020 Bryan Fields
+1-727-409-1194
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License Version 3,
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
--------------------------- Revision History ----------------------------------
2020-08-15 bfields Inital prototype, Private record only
2021-01-26 bfields public and private records working
2021-01-27 bfields PCN working
2021-01-28 bfields Fixed PCN output missing lat/lon records
2021-01-31 bfields Added Tx PO, and feedline info to private record
2021-04-07 bfields Added the Orig Coord date and Coments to private record
2021-04-07 bfields Added the Feature field
2021-05-05 bfields Fixed the formating of feature and comments to prevent dropping the first char
2021-06-09 bfields Fixed the PCN notice text formatting
*/
include('config.php');
require 'vendor/autoload.php';
use GetOptionKit\OptionCollection;
use GetOptionKit\OptionParser;
use GetOptionKit\OptionPrinter\ConsoleOptionPrinter;
// Specs needed here
// Should
$specs = new OptionCollection;
$specs->add('i|id:', 'Record ID' )
->isa('number');
$specs->add('c|coord', 'Print only coordinated repeaters')
->isa('boolean')
->defaultValue('false');
$specs->add('p|public', 'Print public coordination record')
->isa('boolean')
->defaultValue('false');
$specs->add('n|pcn', 'Print PCN coordination record')
->isa('boolean')
->defaultValue('false');
$specs->add('f|force', 'force printing non-coordinated repeaters')
->isa('boolean')
->defaultValue('false');
$parser = new OptionParser($specs);
$result = $parser->parse($argv);
//var_dump($result);
$id = $result->id;
$private = $result->coord;
$public = $result->public;
$pcn = $result->pcn;
$force = $result->force;
//echo "$id \n";
//echo "<table style='border: solid 1px black;'>";
//echo "<tr><th>Id</th><th>Firstname</th><th>Lastname</th></tr>";
function formatNum($num){
return sprintf("%+g",$num);
}
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT *, Watts2dBm(ERP) AS dBm FROM filemaker where record_id = $id");
$stmt->execute();
// set the resulting array to associative
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
// iterate over rows
foreach($data as $row) {
// iterate over values in each row
//foreach($row as $v) {
// echo $v, "\n ";
// }
// format dBm to positive if positive
$row["dBm"] = formatNum($row["dBm"]);
// format the various things that nee to be upper case
// however don't do this if null, as strtoupper make is not null after.
if (is_null($row["antStructType"]) == false) {$row["antStructType"] = strtoupper($row["antStructType"]);}
if (is_null($row["emission_1"]) == false) {$row["emission_1"] = strtoupper($row["emission_1"]);}
if (is_null($row["emission_2"]) == false) {$row["emission_2"] = strtoupper($row["emission_2"]);}
if (is_null($row["Repeater_callsign"]) == false) {$row["Repeater_callsign"] = strtoupper($row["Repeater_callsign"]);}
if (is_null($row["Trustee_callsign"]) == false) {$row["Trustee_callsign"] = strtoupper($row["Trustee_callsign"]);}
// Define the vars
$row["CTCSS_RX_text"] = NULL;
$row["CTCSS_TX_text"] = NULL;
$row["DCS_CODE_text"] = NULL;
$row["NXDN_text"] = NULL;
$row["DMR_text"] = NULL;
$row["P25NAC_TX_text"] = NULL;
$row["P25NAC_RX_text"] = NULL;
$row["ADJ1_text"] = NULL;
$row["ADJ2_text"] = NULL;
//echo "$private\n";
// Check if coordidnated, if not error if -c is set
if ($row["COORDINATED"] == false ) {
echo "ERROR: RECORD {$row["record_ID"]} not coordinated \n";
if ( (($private == true) || ($pcn == false)) && ($force == false) ){
exit (254);
}
}
// check if PL/DCS is set if emission is analog (16k0f3e or 11k2f3e)
// if not set, error
if ( $row["emission_1"] == ('16K0F3E') or $row["emission_1"] == ('11K2F3E') or $row["emission_2"] == ('16K0F3E') or $row["emission_2"] == ('11K2F3E') ) {
//echo "we have a winner\n";
// check if CTCSS is NULL and DCS is set to 0
if (is_null($row["CTCSS_IN"]) and $row["DCS"] == false) {
$row["CTCSS_RX_text"] = <<<EOT
Access Tone In : ERROR: TONE IS UNSET, PLEASE UPDATE RECORD!\n
EOT;
} elseif (is_null($row["CTCSS_IN"]) and $row["DCS"] == true) {
unset($row["CTCSS_RX_text"]);
} else {
$row["CTCSS_RX_text"] = <<<EOT
Access Tone In : {$row["CTCSS_IN"]} Hz\n
EOT;
}
if (is_null($row["CTCSS_OUT"]) and $row["DCS"] == false) {
$row["CTCSS_TX_text"] = <<<EOT
Access Tone Out: ERROR: TONE IS UNSET, PLEASE UPDATE RECORD!\n
EOT;
} elseif (is_null($row["CTCSS_OUT"]) and $row["DCS"] == true) {
unset($$row["CTCSS_TX_text"]);
} else {
$row["CTCSS_TX_text"] = <<<EOT
Access Tone Out: {$row["CTCSS_OUT"]} Hz\n
EOT;
}
}
// Check if DCS is true, print it
if ($row["DCS"] == true) {
if (is_null($row["DCS_CODE"])) {
$row["DCS_CODE_text"] = <<<EOT
DCS CODE : ERROR: CODE IS UNSET, PLEASE UPDATE RECORD!\n
EOT;
} else {
$row["DCS_CODE_text"] = <<<EOT
DCS CODE : {$row["DCS_CODE"]}\n
EOT;
}
}
// check if RAN is set if emisson is NXDN
if ( $row["emission_1"] == ('4K00F1E') or $row["emission_2"] == ('4K00F1E') ) {
// Check if RAN is blank
if (is_null($row["NXDN_RAN"])) {
$row["NXDN_text"] = <<<EOT
NXDN RAN : ERROR: CODE IS UNSET, PLEASE UPDATE RECORD!\n
EOT;
} else {
$row["NXDN_text"] = <<<EOT
NXDN RAN : {$row["NXDN_RAN"]}\n
EOT;
}
}
// check if cc is set if emisson is DMR
if ( $row["emission_1"] == ('7K60FXE') or $row["emission_2"] == ('7K60FXE') ) {
// Check if code is unset
if (is_null($row["DMR1_COLOR_CODE"]) or is_null($row["DMR2_COLOR_CODE"])) {
$row["DMR_text"] = <<<EOT
DMR CC : ERROR: CC1 or CC2 IS UNSET, PLEASE UPDATE RECORD!\n
EOT;
} else {
$row["DMR_text"] = <<<EOT
DMR CC : CC1 = {$row["DMR1_COLOR_CODE"]}, CC2 = {$row["DMR2_COLOR_CODE"]}\n
EOT;
}
}
// check if NAC is set is emisson is P25 Phase 1
if ( $row["emission_1"] == ('8K10F1E') or $row["emission_2"] == ('8K10F1E') ) {
// Check if code is unset
if (is_null($row["P25_NAC"])) {
$row["P25NAC_TX_text"] = <<<EOT
P25 NAC TX : ERROR: P25 NAC UNSET, PLEASE UPDATE RECORD!\n
EOT;
} else {
$row["P25NAC_TX_text"] = <<<EOT
P25 NAC TX : 0x{$row["P25_NAC"]}\n
EOT;
}
if (is_null($row["P25_NAC_IN"])) {
$row["P25NAC_RX_text"] = <<<EOT
P25 NAC RX : ERROR: P25 NAC UNSET, PLEASE UPDATE RECORD!\n
EOT;
} else {
$row["P25NAC_RX_text"] = <<<EOT
P25 NAC RX : 0x{$row["P25_NAC_IN"]}\n
EOT;
}
}
// Check that various required fields are set
if (is_null($row["Original_coordination_date"])) {$row["Original_coordination_date"] = "ERROR: ORIG COORD DATE";}
if (is_null($row["Coordination_date"])) {$row["Coordination_date"] = "ERROR: COORD DATE";}
if (is_null($row["update_date"])) {$row["update_date"] = "ERROR: UPDATE DATE";}
if (is_null($row["Holder_name"])) { $row["Holder_name"] = "ERROR: HOLDER NAME";}
if (is_null($row["Holder_address"])) { $row["Holder_address"] = "ERROR: HOLDER ADDRESS";}
if (is_null($row["Holder_city"])) { $row["Holder_city"] = "ERROR: HOLDER CITY";}
if (is_null($row["Holder_state"])) { $row["Holder_state"] = "ERROR: STATE";}
if (is_null($row["Holder_zip"])) { $row["Holder_zip"] = "ERROR: ZIP";}
if (is_null($row["Holder_phone"])) { $row["Holder_phone"] = "ERROR: HOLDER PHONE";}
if (is_null($row["Holder_email"])) { $row["Holder_email"] = "Not on File";}
if (is_null($row["Trustee_name"])) { $row["Trustee_name"] = "ERROR: TRUSTEE NAME";}
if (is_null($row["Trustee_callsign"])) { $row["Trustee_callsign"] = "ERROR: TRUSTEE CALL";}
if (is_null($row["Trustee_address"])) { $row["Trustee_address"] = "ERROR: TRUSTEE ADDRESS";}
if (is_null($row["Trustee_city"])) { $row["Trustee_city"] = "ERROR: TRUSTEE CITY";}
if (is_null($row["Trustee_state"])) { $row["Trustee_state"] = "ERROR: TRUSTEE STATE";}
if (is_null($row["Trustee_ZIP"])) { $row["Trustee_ZIP"] = "ERROR: TRUSTEE ZIP";}
if (is_null($row["Trustee_home_phone"])) { $row["Trustee_home_phone"] = "ERROR: TRUSTEE PHONE";}
if (is_null($row["Trustee_email_address"])) { $row["Trustee_email_address"] = "ERROR: TRUSTEE EMAIL";}
if (is_null($row["URL"])) { $row["URL"] = "No URL On File";}
if (is_null($row["County"])) { $row["County"] = "ERROR: COUNTY";}
if (is_null($row["Repeater_city"])) { $row["Repeater_city"] = "ERROR: CITY";}
if (is_null($row["Repeater_callsign"])) { $row["Repeater_callsign"] = "ERROR: CALLSIGN";}
if (is_null($row["Input_frequency"])) { $row["Input_frequency"] = "Input not defined";}
if (is_null($row["Output_frequency"])) { $row["Output_frequency"] = "ERROR: OUTPUT FREQUENCY";}
if (is_null($row["chan_Size_kHz"])) { $row["chan_Size_kHz"] = "ERROR: CHANNEL SIZE";}
if (is_null($row["emission_1"])) { $row["emission_1"] = "ERROR: EMISSION";}
if (is_null($row["ERP"])) { $row["ERP"] = "ERROR: ERP";}
if (is_null($row["antennaModelCode"])) { $row["antennaModelCode"] = "Not on File";}
if (is_null($row["antenna_Height_Meters"])) { $row["antenna_Height_Meters"] = "ERROR: AGL";}
if (is_null($row["antStructType"])) { $row["antStructType"] = "Not on File";}
if (is_null($row["model_Name"])) { $row["model_Name"] = "ERROR: MODEL MISSING";}
if (is_null($row["Service_Ring_km"])) { $row["Service_Ring_km"] = "ERROR: SERVICE MISSING";}
if (is_null($row["Interference_Ring_km"])) { $row["Interference_Ring_km"] = "ERROR: INTERFERENCE MISSING";}
if (is_null($row["Coax_Model"])) { $row["Coax_Model"] = "ERROR: COAX UNSET";}
if (is_null($row["Coax_Length_Meters"])) { $row["Coax_Length_Meters"] = "ERROR: COAX LENGTH UNSET";}
if (is_null($row["TxOutputWatts"])) { $row["TxOutputWatts"] = "ERROR: TX OUTPUT POWER UNSET";}
// Check for the coments_all and format if exists
if (!is_null($row["Coments_all"])) {
$row["Coments_all"] = wordwrap($row["Coments_all"], 63, "\n");
$tok = strtok($row["Coments_all"], "\n");
$i=0;
while ($tok !== false) {
if ($i == 0) {$comments = "Comments : $tok\n"; $i++;}
else {$comments .= " : $tok\n";}
$tok = strtok("\n");
}
$row["Coments_all"] = $comments;
}
// check for the Repeater_features
if (!is_null($row["Repeater_features"])) {
$row["Repeater_features"] = wordwrap($row["Repeater_features"], 63, "\n");
$tok = strtok($row["Repeater_features"], "\n");
$i = 0;
while ($tok !== false) {
if ($i == 0) {$features ="Features : $tok\n"; $i++;}
else {$features .=" : $tok\n";}
$tok = strtok("\n");
}
$row["Repeater_features"] = $features;
}
// Only set the next two if needed for the adjacent channels
if (is_null($row["adj1_ring_km"]) == false) {
$row["ADJ1_text"] = <<<EOT
Adjacent 1 : {$row["adj1_ring_km"]} km\n
EOT;
}
// only print adj2 if adj1 is set
if ((is_null($row["adj1_ring_km"]) == false) and (is_null($row["adj2_ring_km"]) == false)) {
$row["ADJ2_text"] = <<<EOT
Adjacent 2 : {$row["adj2_ring_km"]} km\n
EOT;
}
function PrivateRecord($row) {
// need to add in DATE in here too.
echo <<<EOT
====FASMA COORDINATION RECORD {$row["record_ID"]}====
Dear {$row["Trustee_name"]},
Your repeater, Record: {$row['record_ID']}, Callsign: {$row["Repeater_callsign"]}, on {$row["Output_frequency"]} is coordinated as follows:
Record ID : {$row["record_ID"]}
Coord Date : {$row["Coordination_date"]}
Update Date : {$row["update_date"]}
Orig Cord Date : {$row["Original_coordination_date"]}
Holder : {$row["Holder_name"]}
Holder Address : {$row["Holder_address"]}
: {$row["Holder_city"]}, {$row["Holder_state"]} {$row["Holder_zip"]}
Holder Phone : {$row["Holder_phone"]}
Holder Email : {$row["Holder_email"]}
Trustee : {$row["Trustee_name"]}, {$row["Trustee_callsign"]}
Trustee Address: {$row["Trustee_address"]}
: {$row["Trustee_city"]}, {$row["Trustee_state"]} {$row["Trustee_ZIP"]}
Trustee Phone : {$row["Trustee_home_phone"]}
Trustee email : {$row["Trustee_email_address"]}
URL : {$row["URL"]}
County : {$row["County"]}
City : {$row["Repeater_city"]}
Lat, Lon : {$row["Latitude"]}, {$row["Longitude"]}
Callsign : {$row["Repeater_callsign"]}
Output Freq : {$row["Output_frequency"]} MHz
Input Freq : {$row["Input_frequency"]} MHz
Bandwidth : {$row["chan_Size_kHz"]} KHz
Emission 1 : {$row["emission_1"]}
Emission 2 : {$row["emission_2"]}
ERP : {$row["ERP"]} Watts, {$row['dBm']} dBm
Power Out : {$row["TxOutputWatts"]} Watts
Coax Type : {$row["Coax_Model"]}
Coax Length : {$row["Coax_Length_Meters"]} Meters
Antenna Model : {$row["antennaModelCode"]}
Antenna Height : {$row["antenna_Height_Meters"]} Meters
Structure : {$row["antStructType"]}
{$row["CTCSS_TX_text"]}{$row["CTCSS_RX_text"]}{$row["DCS_CODE_text"]}{$row["NXDN_text"]}{$row["DMR_text"]}{$row["P25NAC_TX_text"]}{$row["P25NAC_RX_text"]}Model : {$row["model_Name"]}
Service : {$row["Service_Ring_km"]} km
Interference : {$row["Interference_Ring_km"]} km
{$row["ADJ1_text"]}{$row["ADJ2_text"]}{$row["Repeater_features"]}{$row["Coments_all"]}
NOTE: any change of antenna height, effective radiated power, modulation,
frequency, bandwidth, location or callsign must be approved by FASMA, _PRIOR_ to
the change. Failure to follow this process will void this coordination.
The coverage model is a standard KML format and may be viewed in google earth.
This is automatically generated based on your location, antenna height, ERP and
frequency.
Florida Amateur Spectrum Management Association, Inc.
http://www.fasma.org
EOT;
}
if ($private == true){
PrivateRecord ($row);
}
function PublicRecord($row){
echo <<<EOT
====FASMA COORDINATION RECORD {$row["record_ID"]}====
Record ID : {$row["record_ID"]}
Coord Date : {$row["Coordination_date"]}
Update Date : {$row["update_date"]}
Orig Cord Date : {$row["Original_coordination_date"]}
Holder : {$row["Holder_name"]}
Trustee : {$row["Trustee_name"]}, {$row["Trustee_callsign"]}
URL : {$row["URL"]}
County : {$row["County"]}
City : {$row["Repeater_city"]}
Lat, Lon : {$row["Latitude"]}, {$row["Longitude"]}
Callsign : {$row["Repeater_callsign"]}
Output Freq : {$row["Output_frequency"]} MHz
Input Freq : {$row["Input_frequency"]} MHz
Bandwidth : {$row["chan_Size_kHz"]} KHz
Emission 1 : {$row["emission_1"]}
Emission 2 : {$row["emission_2"]}
ERP : {$row["ERP"]} Watts, {$row['dBm']} dBm
Antenna Height : {$row["antenna_Height_Meters"]} Meters
{$row["CTCSS_TX_text"]}{$row["CTCSS_RX_text"]}{$row["DCS_CODE_text"]}{$row["NXDN_text"]}{$row["DMR_text"]}{$row["P25NAC_TX_text"]}{$row["P25NAC_RX_text"]}Model : {$row["model_Name"]}
Service : {$row["Service_Ring_km"]} km
Interference : {$row["Interference_Ring_km"]} km
{$row["ADJ1_text"]}{$row["ADJ2_text"]}{$row["Repeater_features"]}
The coverage model is a standard KML format and may be viewed in google earth.
This is automatically generated based on your location, antenna height, ERP and
frequency.
Florida Amateur Spectrum Management Association, Inc.
http://www.fasma.org
EOT;
}
if ($public == true) {
PublicRecord($row);
}
function PriorCoordinationNotice($row){
echo <<<EOT
Greetings,
I'm with FASMA and we are sending notice of proposed coordination for this
repeater below.
As this is <200 km from the state line we are making a PCN notice regarding
this repeater. You may find the models for the service contour and
interference contour below. The kmz can be loaded natively in google earth.
If more than one frequency is listed, you may respond with one which works
best of multiple listed. Your prompt response is requested.
Barring no objections in 15 business days, we will consider the notice
approved.
=====BEGIN PCN DATA=====
Record ID : {$row["record_ID"]}
City : {$row["Repeater_city"]}
Lat, Lon : {$row["Latitude"]}, {$row["Longitude"]}
Proposed frequency : PROPOSED FREQ
Channel Bandwidth : {$row["chan_Size_kHz"]} KHz
Emission 1 : {$row["emission_1"]}
Emission 2 : {$row["emission_2"]}
Antenna Model : {$row["antennaModelCode"]}
Antenna Height AGL : {$row["antenna_Height_Meters"]} Meters
ERP : {$row["ERP"]} Watts, {$row['dBm']} dBm
Service Contour : {$row["Service_Ring_km"]} km
Interferer Contour : {$row["Interference_Ring_km"]} km
{$row["ADJ1_text"]}{$row["ADJ2_text"]}Model : {$row["model_Name"]}
=====END PCN DATA=====
Thank you for your assistance and 73,
EOT;
}
if ($pcn == true) {
PriorCoordinationNotice($row);
}
}
?>