tof_dataclasses/
alerts.rs

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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
//! The alerts are just clues to trigger an individual to respond to a certain situation
//!

// kudos Grace!! (who else ^^ ) 
//so these are the alerts relating to the tof:
//-- RB rate = 0 (and if its two we'll know a RAT crashed)
//-- RB temp (from RBMoni)  too cold < -40C
//-- RB temp (from RBMoni) too warm > 80C
//-- RAT labjack temp too cold < -40C
//-- RAT labjack temp too warm > 80C
//-- CAT labjack temp too cold < ?
//-- CAT labjack temp too warm > ?
//-- tofcpu temp too cold (from db?) < -40C
//-- tofcpu temp too warm (from db?) > 95C
//-- tofcpu temp too cold (CPUMoni) < -40C
//-- tofcpu temp too warm (CPUMoni) > 95C
//-- MTB FPGA temp too cold (MTBMoni) < -40C
//-- MTB FPGA temp too warm (MTBMoni) > 80C
//-- tofcpu cpu usage (from db?) > 90%
//-- MTB rate (db) > depends
//-- MTB rate (db) == 0
//-- MTB lost rate (db) > MTB rate

use std::fmt;
use std::collections::HashMap;

use std::time::Instant;
use std::fs::File;
use std::io::{
  Read,
  Write
};

use serde_json::json;

use crate::serialization::SerializationError;

/// helper function to parse output for TofBot
fn remove_from_word(s: String, word: &str) -> String {
  if let Some(index) = s.find(word) {
    // Keep everything up to the found index (not including the word itself)
    s[..index].to_string()
  } else {
    // If the word isn't found, return the original string
    s
  }
}

/// How did whatever went wrong,
/// go bad?
#[derive(Debug, Copy, Clone, PartialEq, serde::Deserialize, serde::Serialize)]
pub enum OutOfBound {
  TooHigh,
  TooLow,
  TooLowOrTooHigh,
  TooOld,
  Zero,
  Unknown,
}

impl fmt::Display for OutOfBound {
  fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
    let repr : &str;
    match self {
      OutOfBound::Unknown         => repr = "Unknown",
      OutOfBound::TooHigh         => repr = "TooHigh",
      OutOfBound::TooLowOrTooHigh => repr = "TooLowOrTooHigh",
      OutOfBound::TooLow          => repr = "TooLow",
      OutOfBound::TooOld          => repr = "TooOld",
      OutOfBound::Zero            => repr = "Zero",
    };
    write!(f, "{}", repr)
  }
}

#[derive(Debug, Copy, Clone, PartialEq, serde::Deserialize, serde::Serialize)]
pub enum Shifters {
  Unknown,
  Grace,
  Kazu,
  Achim,
  TofBot,
}

pub trait Pageable {
  fn page(&self, content : String);

  fn resolve(&self) {
  }
}

impl fmt::Display for Shifters {
  fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
    let repr : &str;
    match self {
      Shifters::Unknown => repr = "Unknown",
      Shifters::Grace   => repr = "Grace",
      Shifters::Kazu    => repr = "Kazu",
      Shifters::Achim   => repr = "Achim",
      Shifters::TofBot  => repr = "TofBot",
    };
    write!(f, "{}", repr)
  }
}

impl Pageable for Shifters {

  fn page(&self, content : String) {
    match self {
      Shifters::Grace => {
      }
      Shifters::Kazu  => {
      }
      Shifters::Achim => {
      }
      Shifters::TofBot => {
        // currently silence TofBot
        // Achim's channel
        //let url     = "https://hooks.slack.com/services/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";
        // TofBot channel
        //let url     = "https://hooks.slack.com/services/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";
        let message = format!("\u{1F916}\u{1F680}\u{1F388} [LIFTOF (Bot)]\n {}",content);
        let clean_message = remove_from_word(message, "tofbot_webhook");
        let data = json!({
          "text" : clean_message
        });
        match serde_json::to_string(&data) {
          Err(err) => {
            error!("Can not convert .json to string! {err}");
          }
          Ok(data_string) => {
            warn!("Alert system disabled! Not paging TofBot with {}", data_string);
        //    match ureq::post(url)
        //        .set("Content-Type", "application/json")
        //        .send_string(&data_string) {
        //      Err(err) => { 
        //        error!("Unable to send {} to TofBot! {err}", data_string);
        //      }
        //      Ok(response) => {
        //        match response.into_string() {
        //          Err(err) => {
        //            error!("Not able to read response! {err}");
        //          }
        //          Ok(body) => {
        //            info!("TofBot responded with {}", body);
        //          }
        //        }
        //      }
        //    }
          }
        }
      }
      _ => error!("Can't page unknown shifter!"),
    }
  }


  fn resolve(&self) {
    match self {
      Shifters::Grace => {
      }
      Shifters::Kazu  => {
      }
      Shifters::Achim => {
      }
      Shifters::TofBot => {
      }
      _ => error!("Can't page unknown shifter!"),
    }
  }
}

/// How did whatever went wrong,
/// go bad?
#[derive(Debug, Copy, Clone, PartialEq, serde::Deserialize, serde::Serialize)]
pub enum Variable {
  Unknown,
  TriggerRate,
  Telemetry,
  LostTriggerRate,
  FPGATemp,
  CoreTemp,
  LabjackTemp,
  AvailableDiskSpace,
  DataMangling,
  MoniData,
}

impl fmt::Display for Variable {
  fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
    let repr : &str;
    match self {
      Variable::Unknown            => repr = "Unknown",
      Variable::TriggerRate        => repr = "TriggerRate",
      Variable::Telemetry          => repr = "Telemetry",
      Variable::LostTriggerRate    => repr = "LostTriggerRate",
      Variable::CoreTemp           => repr = "CoreTemp",
      Variable::FPGATemp           => repr = "FPGATemp",
      Variable::LabjackTemp        => repr = "LabjackTemp",
      Variable::AvailableDiskSpace => repr = "AvailableDiskSpace",
      Variable::DataMangling       => repr = "DataMangling",
      Variable::MoniData           => repr = "MoniData",
    };
    write!(f, "{}", repr)
  }
}

/// How did whatever went wrong,
/// go bad?
#[derive(Debug, Copy, Clone, PartialEq, serde::Deserialize, serde::Serialize)]
pub enum Component {
  MTB,
  CPU,
  CAT,
  System,
  RAT(u8),
  RB(u8),
}

impl fmt::Display for Component {
  fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
    let repr : String;
    match self {
      Component::MTB      => repr = String::from("MTB"),
      Component::CPU      => repr = String::from("CPU"),
      Component::CAT      => repr = String::from("CAT"),
      Component::RAT(rid) => repr = format!("RAT{:02}", rid),
      Component::RB(rid)  => repr = format!("RB{:02}", rid),
      Component::System   => repr = String::from("System"),
    };
    write!(f, "{}", repr)
  }
}



/// Alerts are clues to trigger a 
/// reaction of an individual, so 
/// they are designed for humans, 
/// but should be issued by a 
/// machine
///
/// ISSUES: The design choice of going with 
/// a &str here and carry the livetime around
/// is admittedly a bit questionable, especially
/// since we might want to create similar 
/// alerts automatically (which I did not think 
/// of earlier)
#[derive(Debug, Clone)]
pub struct TofAlert<'a> {
  /// a unique identifier so that we can 
  /// look this up in settings
  pub key          : &'a str,
  /// description of what had happened
  pub descr        : &'a str,
  /// recommended course of action
  pub whattodo     : Vec<&'a str>,
  /// The configurable part of the alerm, 
  /// subscirbers, bounds and is the alarm 
  /// armed
  pub config       : TofAlertConfig,
  /// The variable which is an issue, e.g Rate
  pub variable     : Variable,
  /// The part of the TofSystem which caused the 
  /// issue
  pub component    : Component, 
  /// How did the variable get out-of-bounds? 
  /// E.g. too high, too low?
  pub outofbound   : OutOfBound,
  /// When did this issue occur?
  pub triggered    : Option<Instant>,
  /// How often did this alert page?
  pub n_paged      : u32,
}

impl TofAlert<'_> {
  
  pub fn acknowledge(&mut self) {
    self.triggered = None;
  }

  pub fn has_triggered(&self) -> bool {
    self.triggered.is_some()
  }

  //pub fn annoy(&self) {
  //  if self.triggered.is_some() && self.armed {
  //    for person in &self.config.subscribers {
  //      person.page();
  //    }
  //  }
  //}
  pub fn format_page(&self) -> String {
    let mut page_text = format!("<< Alert {} triggered!\n", self.key);
    page_text += &self.get_text();
    page_text += ">>";
    page_text
  }

  pub fn get_text(&self) -> String {
    let mut repr = format!("< {} | {} | {}", self.component, self.variable, self.outofbound);
    //repr    += &(format!(" -- descr : {}", self.descr));
    //repr    += &(format!(" -- action: {}", self.whattodo));
    //repr    += &(format!(" -- pages : "));
    //for shifter in &self.subscribers {
    //  repr += &(format!(" {} ", shifter)); 
    //}
    repr    += ">";
    repr
  }
  //pub fn new() -> Self {
  //  Self {
  //    message      : String::from(""),
  //    variable     :
  //    outofbound   : OutOfBound::Unknown,
  //    acknowledged : false
  //  }
  //}

  // FIXME find a solution for the unwraps
  pub fn trigger(&mut self, val : f32) {
    let mut triggered = false;
    match self.outofbound {
      OutOfBound::TooHigh => {
        match self.config.max_allowed {
          None => {
            error!("Set condition for {} as 'TooHigh', but 'max_allowed' is not specified", self.key);
          }
          Some(max_allowed) => {
            if val > max_allowed {
              warn!("Alarm {} triggered at {}!", self.key, max_allowed);
              triggered = true;
            }
          }
        }
      }
      OutOfBound::TooLow  => {
        match self.config.min_allowed {
          None => {
            error!("Set condition for {} as 'TooLow', but 'min_allowed' is not specified", self.key);
          }
          Some(min_allowed) => {
            if val < min_allowed {
              warn!("Alarm {} triggered at {}!", self.key, min_allowed);
              triggered = true;
            }
          }
        }
      }
      OutOfBound::TooLowOrTooHigh => {
        if val < self.config.min_allowed.unwrap() 
        || val > self.config.max_allowed.unwrap() {
          //warn!("Alarm {} triggered at {}!", self.key, max_allowed);
          triggered = true;
        }
      }
      OutOfBound::TooOld  => {
        match self.config.max_allowed {
          None => {
            error!("Set condition for {} as 'TooOld', but 'max_allowed' is not specified", self.key);
          }
          Some(max_allowed) => {
            if val > max_allowed {
              warn!("Alarm {} triggered at {}!", self.key, max_allowed);
              triggered = true;
            }
          }
        }
      }
      OutOfBound::Zero    => {
        if val == 0.0 {
          triggered = true;
        }
      }
      OutOfBound::Unknown => (),  
    }
    if triggered {
      self.triggered = Some(Instant::now());
    }
  }
 
  pub fn page(&mut self) {
    let content = self.format_page();
    self.n_paged += 1;
    for person in &self.config.subscribers {
      match person {
        Shifters::TofBot => {
          // always page TofBot
          person.page(content.clone());
        }
        _ => {
          if self.config.armed {
            // person who might need sleep, only 
            // page them when the alert is armed
            person.page(content.clone());
          }
        }
      }
    }
  }


  pub fn configure_from_manifest(&mut self, manifest : &TofAlertManifest)  {
    match manifest.get(self.key) {
      Some(cfg) => {
        self.config = cfg;
      }
      None => {
        error!("No entry for {} found in the alert manifest!", self.key);
      }
    }
  }
}

impl PartialEq for TofAlert<'_> {
  fn eq(&self, other: &Self) -> bool {
    self.variable      == other.variable
    && self.component  == other.component
    && self.outofbound == other.outofbound
  }
}

impl fmt::Display for TofAlert<'_> {
  fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
    let repr = self.get_text();
    write!(f, "{}", repr)
  }
}

///// Create the temperature and rate alerts for a RB
//pub fn alert_factory_rb<'a>(rb_id      : u8) -> (TofAlert<'a>, TofAlert<'a>) {
//  let rate_alert = TofAlert {
//    key          : &(format!("RB{:02}_rate_zero", rb_id)),
//    descr        : &(format!("RB{:02} is not triggering!", rb_id)),
//    whattodo     : vec!["1) Run restart", "2) Restart liftof-rb", "3) Soft reboot RB", "4) Soft reboot MTB", "5) Hard reboot RAT",  "6) Hard reboot MTB"],
//    config       : TofAlertConfig::new(),
//    variable     : Variable::TriggerRate,
//    outofbound   : OutOfBound::Zero,
//    component    : Component::RB(rb_id),
//    triggered    : None,
//  };
//  
//  let temp_alert = TofAlert {
//    key          : format!("RB{:02}_temp", rb_id).as_str(),
//    descr        : format!("RB{:02} (FPGA) temperature is out of bounds!", rb_id).as_str(),
//    whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
//    config       : TofAlertConfig::new(),
//    variable     : Variable::TriggerRate,
//    outofbound   : OutOfBound::Zero,
//    component    : Component::RB(rb_id),
//    triggered    : None,
//  };
//  (rate_alert, temp_alert)
//}



//}
//
///// Create an alert for mtb temperature out of range
//pub fn alert_factory_rb_temp<'a>(rb_id       : u8,
//                                 subscribers : Vec<Shifters>,
//                                 outofbound  : OutOfBound) -> TofAlert<'a> {
//  TofAlert {
//    key          : "rb_temp",
//    descr        : "RB (FPGA) Temperature out of bounds!!",
//    whattodo     : vec!["This is critical! Check with everyone and then shut off this RB!"],
//    config       : TofAlertConfig::new(),
//    variable     : Variable::FPGATemp,
//    outofbound   : outofbound,
//    component    : Component::RB(rb_id),
//    acknowledged : false,
//    created      : Instant::now(),
//  }
//}
//
///// Create an alert for the case where the MTB is not triggering
//pub fn alert_factory_mtb_rate_zero<'a>(subscribers : Vec<Shifters>) -> TofAlert<'a> {
//  TofAlert {
//    key          : "mtb_rate_zero",
//    descr        : "MTB is not triggering!",
//    whattodo     : vec!["1) Check about TIU status", "2) Run restart", "3) If SSH available, debug with pybindings", "4) Soft reboot MTB", "5) Hard reboot MTB"],
//    config       : TofAlertConfig::new(),
//    variable     : Variable::TriggerRate,
//    outofbound   : OutOfBound::Zero,
//    component    : Component::MTB,
//    acknowledged : false,
//    created      : Instant::now(),
//  }
//}
//
///// Create an alert for mtb temperature out of range
//pub fn alert_factory_mtb_temp<'a>(subscribers : Vec<Shifters>,
//                                  outofbound  : OutOfBound) -> TofAlert<'a> {
//  TofAlert {
//    key          : "mtb_fpga_temp",
//    descr        : "MTB Temperature out of bounds!!",
//    whattodo     : vec!["This is critical! Check with everyone and then shut off the MTB!"],
//    config       : TofAlertConfig::new(),
//    variable     : Variable::FPGATemp,
//    outofbound   : outofbound,
//    component    : Component::MTB,
//    acknowledged : false,
//    created      : Instant::now(),
//  }
//}
//
///// Create an alert for mtb temperature out of range
//pub fn alert_factory_mtb_lost_rate<'a>(subscribers : Vec<Shifters>,
//                                       outofbound  : OutOfBound) -> TofAlert<'a> {
//  TofAlert {
//    key          : "mtb_lost_rate",
//    descr        : "MTB Lost rate is whacky!!",
//    whattodo     : vec!["Unclear course of action. Check with tracker, maybe nothing can be done!"],
//    config       : TofAlertConfig::new(),
//    variable     : Variable::LostTriggerRate,
//    outofbound   : outofbound,
//    component    : Component::MTB,
//    acknowledged : false,
//    created      : Instant::now(),
//  }
//}

/// Configure alerts from a .toml file
#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct TofAlertConfig {
  pub subscribers : Vec<Shifters>,
  pub armed       : bool,
  pub min_allowed : Option<f32>,
  pub max_allowed : Option<f32>,
  pub non_zero    : Option<bool>,
}

impl TofAlertConfig {
  pub fn new() -> Self {
    Self {
      subscribers : vec![Shifters::Grace,
                         Shifters::Kazu,
                         Shifters::Achim,
                         Shifters::TofBot],
      armed       : false,
      min_allowed : Some(-40.0),
      max_allowed : Some(80.0),
      non_zero    : Some(false),
    }
  }
}



/// Describes a .toml file with alert. 
/// settings
#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct TofAlertManifest {
  pub data_mangling   : TofAlertConfig,
  pub miss_tofevid    : TofAlertConfig,
  pub tofev_vs_merge  : TofAlertConfig,
  pub notof_vs_merge  : TofAlertConfig,
  pub frac_interest   : TofAlertConfig,
  pub mtb_lost_rate   : TofAlertConfig,
  pub mtb_fpga_temp   : TofAlertConfig,
  pub mtb_rate_zero   : TofAlertConfig,
  pub mtb_hk_too_old  : TofAlertConfig,
  pub cpu_core0_temp  : TofAlertConfig,
  pub cpu_core1_temp  : TofAlertConfig,
  pub cpu_hk_too_old  : TofAlertConfig,
  pub cpu_disk        : TofAlertConfig,
  pub rb01_temp       : TofAlertConfig,
  pub rb02_temp       : TofAlertConfig,  
  pub rb03_temp       : TofAlertConfig,  
  pub rb04_temp       : TofAlertConfig, 
  pub rb05_temp       : TofAlertConfig, 
  pub rb06_temp       : TofAlertConfig, 
  pub rb07_temp       : TofAlertConfig,
  pub rb08_temp       : TofAlertConfig, 
  pub rb09_temp       : TofAlertConfig, 
  pub rb11_temp       : TofAlertConfig, 
  pub rb13_temp       : TofAlertConfig,
  pub rb14_temp       : TofAlertConfig, 
  pub rb15_temp       : TofAlertConfig, 
  pub rb16_temp       : TofAlertConfig, 
  pub rb17_temp       : TofAlertConfig, 
  pub rb18_temp       : TofAlertConfig, 
  pub rb19_temp       : TofAlertConfig, 
  pub rb20_temp       : TofAlertConfig, 
  pub rb21_temp       : TofAlertConfig, 
  pub rb22_temp       : TofAlertConfig, 
  pub rb23_temp       : TofAlertConfig, 
  pub rb24_temp       : TofAlertConfig, 
  pub rb25_temp       : TofAlertConfig, 
  pub rb26_temp       : TofAlertConfig, 
  pub rb27_temp       : TofAlertConfig, 
  pub rb28_temp       : TofAlertConfig, 
  pub rb29_temp       : TofAlertConfig, 
  pub rb30_temp       : TofAlertConfig, 
  pub rb31_temp       : TofAlertConfig, 
  pub rb32_temp       : TofAlertConfig, 
  pub rb33_temp       : TofAlertConfig, 
  pub rb34_temp       : TofAlertConfig, 
  pub rb35_temp       : TofAlertConfig, 
  pub rb36_temp       : TofAlertConfig, 
  pub rb39_temp       : TofAlertConfig, 
  pub rb40_temp       : TofAlertConfig, 
  pub rb41_temp       : TofAlertConfig, 
  pub rb42_temp       : TofAlertConfig, 
  pub rb44_temp       : TofAlertConfig, 
  pub rb46_temp       : TofAlertConfig, 
  pub rb01_rate_zero  : TofAlertConfig, 
  pub rb02_rate_zero  : TofAlertConfig,  
  pub rb03_rate_zero  : TofAlertConfig,  
  pub rb04_rate_zero  : TofAlertConfig, 
  pub rb05_rate_zero  : TofAlertConfig, 
  pub rb06_rate_zero  : TofAlertConfig, 
  pub rb07_rate_zero  : TofAlertConfig, 
  pub rb08_rate_zero  : TofAlertConfig, 
  pub rb09_rate_zero  : TofAlertConfig, 
  pub rb11_rate_zero  : TofAlertConfig, 
  pub rb13_rate_zero  : TofAlertConfig, 
  pub rb14_rate_zero  : TofAlertConfig, 
  pub rb15_rate_zero  : TofAlertConfig, 
  pub rb16_rate_zero  : TofAlertConfig, 
  pub rb17_rate_zero  : TofAlertConfig, 
  pub rb18_rate_zero  : TofAlertConfig, 
  pub rb19_rate_zero  : TofAlertConfig, 
  pub rb20_rate_zero  : TofAlertConfig, 
  pub rb21_rate_zero  : TofAlertConfig, 
  pub rb22_rate_zero  : TofAlertConfig, 
  pub rb23_rate_zero  : TofAlertConfig, 
  pub rb24_rate_zero  : TofAlertConfig, 
  pub rb25_rate_zero  : TofAlertConfig, 
  pub rb26_rate_zero  : TofAlertConfig, 
  pub rb27_rate_zero  : TofAlertConfig, 
  pub rb28_rate_zero  : TofAlertConfig, 
  pub rb29_rate_zero  : TofAlertConfig, 
  pub rb30_rate_zero  : TofAlertConfig, 
  pub rb31_rate_zero  : TofAlertConfig, 
  pub rb32_rate_zero  : TofAlertConfig, 
  pub rb33_rate_zero  : TofAlertConfig, 
  pub rb34_rate_zero  : TofAlertConfig, 
  pub rb35_rate_zero  : TofAlertConfig, 
  pub rb36_rate_zero  : TofAlertConfig, 
  pub rb39_rate_zero  : TofAlertConfig, 
  pub rb40_rate_zero  : TofAlertConfig, 
  pub rb41_rate_zero  : TofAlertConfig, 
  pub rb42_rate_zero  : TofAlertConfig, 
  pub rb44_rate_zero  : TofAlertConfig, 
  pub rb46_rate_zero  : TofAlertConfig, 
  pub rb01_hk_too_old : TofAlertConfig, 
  pub rb02_hk_too_old : TofAlertConfig,  
  pub rb03_hk_too_old : TofAlertConfig,  
  pub rb04_hk_too_old : TofAlertConfig, 
  pub rb05_hk_too_old : TofAlertConfig, 
  pub rb06_hk_too_old : TofAlertConfig, 
  pub rb07_hk_too_old : TofAlertConfig, 
  pub rb08_hk_too_old : TofAlertConfig, 
  pub rb09_hk_too_old : TofAlertConfig, 
  pub rb11_hk_too_old : TofAlertConfig, 
  pub rb13_hk_too_old : TofAlertConfig, 
  pub rb14_hk_too_old : TofAlertConfig, 
  pub rb15_hk_too_old : TofAlertConfig, 
  pub rb16_hk_too_old : TofAlertConfig, 
  pub rb17_hk_too_old : TofAlertConfig, 
  pub rb18_hk_too_old : TofAlertConfig, 
  pub rb19_hk_too_old : TofAlertConfig, 
  pub rb20_hk_too_old : TofAlertConfig, 
  pub rb21_hk_too_old : TofAlertConfig, 
  pub rb22_hk_too_old : TofAlertConfig, 
  pub rb23_hk_too_old : TofAlertConfig, 
  pub rb24_hk_too_old : TofAlertConfig, 
  pub rb25_hk_too_old : TofAlertConfig, 
  pub rb26_hk_too_old : TofAlertConfig, 
  pub rb27_hk_too_old : TofAlertConfig, 
  pub rb28_hk_too_old : TofAlertConfig, 
  pub rb29_hk_too_old : TofAlertConfig, 
  pub rb30_hk_too_old : TofAlertConfig, 
  pub rb31_hk_too_old : TofAlertConfig, 
  pub rb32_hk_too_old : TofAlertConfig, 
  pub rb33_hk_too_old : TofAlertConfig, 
  pub rb34_hk_too_old : TofAlertConfig, 
  pub rb35_hk_too_old : TofAlertConfig, 
  pub rb36_hk_too_old : TofAlertConfig, 
  pub rb39_hk_too_old : TofAlertConfig, 
  pub rb40_hk_too_old : TofAlertConfig, 
  pub rb41_hk_too_old : TofAlertConfig, 
  pub rb42_hk_too_old : TofAlertConfig, 
  pub rb44_hk_too_old : TofAlertConfig, 
  pub rb46_hk_too_old : TofAlertConfig, 
}

impl TofAlertManifest {
  pub fn new() -> Self {
    Self {
      data_mangling   : TofAlertConfig::new(),
      miss_tofevid    : TofAlertConfig::new(),
      tofev_vs_merge  : TofAlertConfig::new(),
      notof_vs_merge  : TofAlertConfig::new(),
      frac_interest   : TofAlertConfig::new(),
      mtb_lost_rate   : TofAlertConfig::new(),
      mtb_fpga_temp   : TofAlertConfig::new(),
      mtb_rate_zero   : TofAlertConfig::new(),
      mtb_hk_too_old  : TofAlertConfig::new(),
      cpu_core0_temp  : TofAlertConfig::new(),
      cpu_core1_temp  : TofAlertConfig::new(),
      cpu_hk_too_old  : TofAlertConfig::new(),
      cpu_disk        : TofAlertConfig::new(),
      rb01_temp       : TofAlertConfig::new(),
      rb02_temp       : TofAlertConfig::new(),  
      rb03_temp       : TofAlertConfig::new(),  
      rb04_temp       : TofAlertConfig::new(), 
      rb05_temp       : TofAlertConfig::new(), 
      rb06_temp       : TofAlertConfig::new(), 
      rb07_temp       : TofAlertConfig::new(),
      rb08_temp       : TofAlertConfig::new(), 
      rb09_temp       : TofAlertConfig::new(), 
      rb11_temp       : TofAlertConfig::new(), 
      rb13_temp       : TofAlertConfig::new(),
      rb14_temp       : TofAlertConfig::new(), 
      rb15_temp       : TofAlertConfig::new(), 
      rb16_temp       : TofAlertConfig::new(), 
      rb17_temp       : TofAlertConfig::new(), 
      rb18_temp       : TofAlertConfig::new(), 
      rb19_temp       : TofAlertConfig::new(), 
      rb20_temp       : TofAlertConfig::new(), 
      rb21_temp       : TofAlertConfig::new(), 
      rb22_temp       : TofAlertConfig::new(), 
      rb23_temp       : TofAlertConfig::new(), 
      rb24_temp       : TofAlertConfig::new(), 
      rb25_temp       : TofAlertConfig::new(), 
      rb26_temp       : TofAlertConfig::new(), 
      rb27_temp       : TofAlertConfig::new(), 
      rb28_temp       : TofAlertConfig::new(), 
      rb29_temp       : TofAlertConfig::new(), 
      rb30_temp       : TofAlertConfig::new(), 
      rb31_temp       : TofAlertConfig::new(), 
      rb32_temp       : TofAlertConfig::new(), 
      rb33_temp       : TofAlertConfig::new(), 
      rb34_temp       : TofAlertConfig::new(), 
      rb35_temp       : TofAlertConfig::new(), 
      rb36_temp       : TofAlertConfig::new(), 
      rb39_temp       : TofAlertConfig::new(), 
      rb40_temp       : TofAlertConfig::new(), 
      rb41_temp       : TofAlertConfig::new(), 
      rb42_temp       : TofAlertConfig::new(), 
      rb44_temp       : TofAlertConfig::new(), 
      rb46_temp       : TofAlertConfig::new(), 
      rb01_rate_zero  : TofAlertConfig::new(), 
      rb02_rate_zero  : TofAlertConfig::new(),  
      rb03_rate_zero  : TofAlertConfig::new(),  
      rb04_rate_zero  : TofAlertConfig::new(), 
      rb05_rate_zero  : TofAlertConfig::new(), 
      rb06_rate_zero  : TofAlertConfig::new(), 
      rb07_rate_zero  : TofAlertConfig::new(), 
      rb08_rate_zero  : TofAlertConfig::new(), 
      rb09_rate_zero  : TofAlertConfig::new(), 
      rb11_rate_zero  : TofAlertConfig::new(), 
      rb13_rate_zero  : TofAlertConfig::new(), 
      rb14_rate_zero  : TofAlertConfig::new(), 
      rb15_rate_zero  : TofAlertConfig::new(), 
      rb16_rate_zero  : TofAlertConfig::new(), 
      rb17_rate_zero  : TofAlertConfig::new(), 
      rb18_rate_zero  : TofAlertConfig::new(), 
      rb19_rate_zero  : TofAlertConfig::new(), 
      rb20_rate_zero  : TofAlertConfig::new(), 
      rb21_rate_zero  : TofAlertConfig::new(), 
      rb22_rate_zero  : TofAlertConfig::new(), 
      rb23_rate_zero  : TofAlertConfig::new(), 
      rb24_rate_zero  : TofAlertConfig::new(), 
      rb25_rate_zero  : TofAlertConfig::new(), 
      rb26_rate_zero  : TofAlertConfig::new(), 
      rb27_rate_zero  : TofAlertConfig::new(), 
      rb28_rate_zero  : TofAlertConfig::new(), 
      rb29_rate_zero  : TofAlertConfig::new(), 
      rb30_rate_zero  : TofAlertConfig::new(), 
      rb31_rate_zero  : TofAlertConfig::new(), 
      rb32_rate_zero  : TofAlertConfig::new(), 
      rb33_rate_zero  : TofAlertConfig::new(), 
      rb34_rate_zero  : TofAlertConfig::new(), 
      rb35_rate_zero  : TofAlertConfig::new(), 
      rb36_rate_zero  : TofAlertConfig::new(), 
      rb39_rate_zero  : TofAlertConfig::new(), 
      rb40_rate_zero  : TofAlertConfig::new(), 
      rb41_rate_zero  : TofAlertConfig::new(), 
      rb42_rate_zero  : TofAlertConfig::new(), 
      rb44_rate_zero  : TofAlertConfig::new(), 
      rb46_rate_zero  : TofAlertConfig::new(), 
      rb01_hk_too_old : TofAlertConfig::new(), 
      rb02_hk_too_old : TofAlertConfig::new(),  
      rb03_hk_too_old : TofAlertConfig::new(),  
      rb04_hk_too_old : TofAlertConfig::new(), 
      rb05_hk_too_old : TofAlertConfig::new(), 
      rb06_hk_too_old : TofAlertConfig::new(), 
      rb07_hk_too_old : TofAlertConfig::new(), 
      rb08_hk_too_old : TofAlertConfig::new(), 
      rb09_hk_too_old : TofAlertConfig::new(), 
      rb11_hk_too_old : TofAlertConfig::new(), 
      rb13_hk_too_old : TofAlertConfig::new(), 
      rb14_hk_too_old : TofAlertConfig::new(), 
      rb15_hk_too_old : TofAlertConfig::new(), 
      rb16_hk_too_old : TofAlertConfig::new(), 
      rb17_hk_too_old : TofAlertConfig::new(), 
      rb18_hk_too_old : TofAlertConfig::new(), 
      rb19_hk_too_old : TofAlertConfig::new(), 
      rb20_hk_too_old : TofAlertConfig::new(), 
      rb21_hk_too_old : TofAlertConfig::new(), 
      rb22_hk_too_old : TofAlertConfig::new(), 
      rb23_hk_too_old : TofAlertConfig::new(), 
      rb24_hk_too_old : TofAlertConfig::new(), 
      rb25_hk_too_old : TofAlertConfig::new(), 
      rb26_hk_too_old : TofAlertConfig::new(), 
      rb27_hk_too_old : TofAlertConfig::new(), 
      rb28_hk_too_old : TofAlertConfig::new(), 
      rb29_hk_too_old : TofAlertConfig::new(), 
      rb30_hk_too_old : TofAlertConfig::new(), 
      rb31_hk_too_old : TofAlertConfig::new(), 
      rb32_hk_too_old : TofAlertConfig::new(), 
      rb33_hk_too_old : TofAlertConfig::new(), 
      rb34_hk_too_old : TofAlertConfig::new(), 
      rb35_hk_too_old : TofAlertConfig::new(), 
      rb36_hk_too_old : TofAlertConfig::new(), 
      rb39_hk_too_old : TofAlertConfig::new(), 
      rb40_hk_too_old : TofAlertConfig::new(), 
      rb41_hk_too_old : TofAlertConfig::new(), 
      rb42_hk_too_old : TofAlertConfig::new(), 
      rb44_hk_too_old : TofAlertConfig::new(), 
      rb46_hk_too_old : TofAlertConfig::new(), 
    }
  }

  pub fn keys(&self) -> Vec<&'static str> {
    let keys = vec!["data_mangling",  
                    "miss_tofevid",   
                    "tofev_vs_merge", 
                    "notof_vs_merge", 
                    "frac_interest",  
                    "mtb_lost_rate",
                    "mtb_fpga_temp",
                    "mtb_rate_zero",
                    "mtb_hk_too_old",
                    "cpu_core0_temp",
                    "cpu_core1_temp",
                    "cpu_hk_too_old",
                    "cpu_disk",
                    "rb01_temp",
                    "rb02_temp",  
                    "rb03_temp",  
                    "rb04_temp", 
                    "rb05_temp", 
                    "rb06_temp", 
                    "rb07_temp",
                    "rb08_temp", 
                    "rb09_temp", 
                    "rb11_temp", 
                    "rb13_temp",
                    "rb14_temp", 
                    "rb15_temp", 
                    "rb16_temp", 
                    "rb17_temp", 
                    "rb18_temp", 
                    "rb19_temp", 
                    "rb20_temp", 
                    "rb21_temp", 
                    "rb22_temp", 
                    "rb23_temp", 
                    "rb24_temp", 
                    "rb25_temp", 
                    "rb26_temp", 
                    "rb27_temp", 
                    "rb28_temp", 
                    "rb29_temp", 
                    "rb30_temp", 
                    "rb31_temp", 
                    "rb32_temp", 
                    "rb33_temp", 
                    "rb34_temp", 
                    "rb35_temp", 
                    "rb36_temp", 
                    "rb39_temp", 
                    "rb40_temp", 
                    "rb41_temp", 
                    "rb42_temp", 
                    "rb44_temp", 
                    "rb46_temp", 
                    "rb01_rate_zero", 
                    "rb02_rate_zero",  
                    "rb03_rate_zero",  
                    "rb04_rate_zero", 
                    "rb05_rate_zero", 
                    "rb06_rate_zero", 
                    "rb07_rate_zero", 
                    "rb08_rate_zero", 
                    "rb09_rate_zero", 
                    "rb11_rate_zero", 
                    "rb13_rate_zero", 
                    "rb14_rate_zero", 
                    "rb15_rate_zero", 
                    "rb16_rate_zero", 
                    "rb17_rate_zero", 
                    "rb18_rate_zero", 
                    "rb19_rate_zero", 
                    "rb20_rate_zero", 
                    "rb21_rate_zero", 
                    "rb22_rate_zero", 
                    "rb23_rate_zero", 
                    "rb24_rate_zero", 
                    "rb25_rate_zero", 
                    "rb26_rate_zero", 
                    "rb27_rate_zero", 
                    "rb28_rate_zero", 
                    "rb29_rate_zero", 
                    "rb30_rate_zero", 
                    "rb31_rate_zero", 
                    "rb32_rate_zero", 
                    "rb33_rate_zero", 
                    "rb34_rate_zero", 
                    "rb35_rate_zero", 
                    "rb36_rate_zero", 
                    "rb39_rate_zero", 
                    "rb40_rate_zero", 
                    "rb41_rate_zero", 
                    "rb42_rate_zero", 
                    "rb44_rate_zero", 
                    "rb46_rate_zero", 
                    "rb01_hk_too_old", 
                    "rb02_hk_too_old",  
                    "rb03_hk_too_old",  
                    "rb04_hk_too_old", 
                    "rb05_hk_too_old", 
                    "rb06_hk_too_old", 
                    "rb07_hk_too_old", 
                    "rb08_hk_too_old", 
                    "rb09_hk_too_old", 
                    "rb11_hk_too_old", 
                    "rb13_hk_too_old", 
                    "rb14_hk_too_old", 
                    "rb15_hk_too_old", 
                    "rb16_hk_too_old", 
                    "rb17_hk_too_old", 
                    "rb18_hk_too_old", 
                    "rb19_hk_too_old", 
                    "rb20_hk_too_old", 
                    "rb21_hk_too_old", 
                    "rb22_hk_too_old", 
                    "rb23_hk_too_old", 
                    "rb24_hk_too_old", 
                    "rb25_hk_too_old", 
                    "rb26_hk_too_old", 
                    "rb27_hk_too_old", 
                    "rb28_hk_too_old", 
                    "rb29_hk_too_old", 
                    "rb30_hk_too_old", 
                    "rb31_hk_too_old", 
                    "rb32_hk_too_old", 
                    "rb33_hk_too_old", 
                    "rb34_hk_too_old", 
                    "rb35_hk_too_old", 
                    "rb36_hk_too_old", 
                    "rb39_hk_too_old", 
                    "rb40_hk_too_old", 
                    "rb41_hk_too_old", 
                    "rb42_hk_too_old", 
                    "rb44_hk_too_old", 
                    "rb46_hk_too_old", 
                    ];
    return keys;
  }

  pub fn get(&self, key :  &str) -> Option<TofAlertConfig> {
    match key {
      "data_mangling"   => Some(self.data_mangling.clone()),  
      "miss_tofevid"    => Some(self.miss_tofevid.clone()),   
      "tofev_vs_merge"  => Some(self.tofev_vs_merge.clone()), 
      "notof_vs_merge"  => Some(self.notof_vs_merge.clone()), 
      "frac_interest"   => Some(self.frac_interest.clone()),  
      "mtb_lost_rate"   => Some(self.mtb_lost_rate.clone()),
      "mtb_fpga_temp"   => Some(self.mtb_fpga_temp.clone()),
      "mtb_rate_zero"   => Some(self.mtb_rate_zero.clone()),
      "mtb_hk_too_old"  => Some(self.mtb_hk_too_old.clone()),
      "cpu_core0_temp"  => Some(self.cpu_core0_temp.clone()),
      "cpu_core1_temp"  => Some(self.cpu_core1_temp.clone()),
      "cpu_hk_too_old"  => Some(self.cpu_hk_too_old.clone()),
      "cpu_disk"        => Some(self.cpu_disk.clone()),
      "rb01_temp"       => Some(self.rb01_temp.clone()),
      "rb02_temp"       => Some(self.rb02_temp.clone()),  
      "rb03_temp"       => Some(self.rb03_temp.clone()),  
      "rb04_temp"       => Some(self.rb04_temp.clone()), 
      "rb05_temp"       => Some(self.rb05_temp.clone()), 
      "rb06_temp"       => Some(self.rb06_temp.clone()), 
      "rb07_temp"       => Some(self.rb07_temp.clone()),
      "rb08_temp"       => Some(self.rb08_temp.clone()), 
      "rb09_temp"       => Some(self.rb09_temp.clone()), 
      "rb11_temp"       => Some(self.rb11_temp.clone()), 
      "rb13_temp"       => Some(self.rb13_temp.clone()),
      "rb14_temp"       => Some(self.rb14_temp.clone()), 
      "rb15_temp"       => Some(self.rb15_temp.clone()), 
      "rb16_temp"       => Some(self.rb16_temp.clone()), 
      "rb17_temp"       => Some(self.rb17_temp.clone()), 
      "rb18_temp"       => Some(self.rb18_temp.clone()), 
      "rb19_temp"       => Some(self.rb19_temp.clone()), 
      "rb20_temp"       => Some(self.rb20_temp.clone()), 
      "rb21_temp"       => Some(self.rb21_temp.clone()), 
      "rb22_temp"       => Some(self.rb22_temp.clone()), 
      "rb23_temp"       => Some(self.rb23_temp.clone()), 
      "rb24_temp"       => Some(self.rb24_temp.clone()), 
      "rb25_temp"       => Some(self.rb25_temp.clone()), 
      "rb26_temp"       => Some(self.rb26_temp.clone()), 
      "rb27_temp"       => Some(self.rb27_temp.clone()), 
      "rb28_temp"       => Some(self.rb28_temp.clone()), 
      "rb29_temp"       => Some(self.rb29_temp.clone()), 
      "rb30_temp"       => Some(self.rb30_temp.clone()), 
      "rb31_temp"       => Some(self.rb31_temp.clone()), 
      "rb32_temp"       => Some(self.rb32_temp.clone()), 
      "rb33_temp"       => Some(self.rb33_temp.clone()), 
      "rb34_temp"       => Some(self.rb34_temp.clone()), 
      "rb35_temp"       => Some(self.rb35_temp.clone()), 
      "rb36_temp"       => Some(self.rb36_temp.clone()), 
      "rb39_temp"       => Some(self.rb39_temp.clone()), 
      "rb40_temp"       => Some(self.rb40_temp.clone()), 
      "rb41_temp"       => Some(self.rb41_temp.clone()), 
      "rb42_temp"       => Some(self.rb42_temp.clone()), 
      "rb44_temp"       => Some(self.rb44_temp.clone()), 
      "rb46_temp"       => Some(self.rb46_temp.clone()), 
      "rb01_rate_zero"  => Some(self.rb01_rate_zero.clone()), 
      "rb02_rate_zero"  => Some(self.rb02_rate_zero.clone()),  
      "rb03_rate_zero"  => Some(self.rb03_rate_zero.clone()),  
      "rb04_rate_zero"  => Some(self.rb04_rate_zero.clone()), 
      "rb05_rate_zero"  => Some(self.rb05_rate_zero.clone()), 
      "rb06_rate_zero"  => Some(self.rb06_rate_zero.clone()), 
      "rb07_rate_zero"  => Some(self.rb07_rate_zero.clone()), 
      "rb08_rate_zero"  => Some(self.rb08_rate_zero.clone()), 
      "rb09_rate_zero"  => Some(self.rb09_rate_zero.clone()), 
      "rb11_rate_zero"  => Some(self.rb11_rate_zero.clone()), 
      "rb13_rate_zero"  => Some(self.rb13_rate_zero.clone()), 
      "rb14_rate_zero"  => Some(self.rb14_rate_zero.clone()), 
      "rb15_rate_zero"  => Some(self.rb15_rate_zero.clone()), 
      "rb16_rate_zero"  => Some(self.rb16_rate_zero.clone()), 
      "rb17_rate_zero"  => Some(self.rb17_rate_zero.clone()), 
      "rb18_rate_zero"  => Some(self.rb18_rate_zero.clone()), 
      "rb19_rate_zero"  => Some(self.rb19_rate_zero.clone()), 
      "rb20_rate_zero"  => Some(self.rb20_rate_zero.clone()), 
      "rb21_rate_zero"  => Some(self.rb21_rate_zero.clone()), 
      "rb22_rate_zero"  => Some(self.rb22_rate_zero.clone()), 
      "rb23_rate_zero"  => Some(self.rb23_rate_zero.clone()), 
      "rb24_rate_zero"  => Some(self.rb24_rate_zero.clone()), 
      "rb25_rate_zero"  => Some(self.rb25_rate_zero.clone()), 
      "rb26_rate_zero"  => Some(self.rb26_rate_zero.clone()), 
      "rb27_rate_zero"  => Some(self.rb27_rate_zero.clone()), 
      "rb28_rate_zero"  => Some(self.rb28_rate_zero.clone()), 
      "rb29_rate_zero"  => Some(self.rb29_rate_zero.clone()), 
      "rb30_rate_zero"  => Some(self.rb30_rate_zero.clone()), 
      "rb31_rate_zero"  => Some(self.rb31_rate_zero.clone()), 
      "rb32_rate_zero"  => Some(self.rb32_rate_zero.clone()), 
      "rb33_rate_zero"  => Some(self.rb33_rate_zero.clone()), 
      "rb34_rate_zero"  => Some(self.rb34_rate_zero.clone()), 
      "rb35_rate_zero"  => Some(self.rb35_rate_zero.clone()), 
      "rb36_rate_zero"  => Some(self.rb36_rate_zero.clone()), 
      "rb39_rate_zero"  => Some(self.rb39_rate_zero.clone()), 
      "rb40_rate_zero"  => Some(self.rb40_rate_zero.clone()), 
      "rb41_rate_zero"  => Some(self.rb41_rate_zero.clone()), 
      "rb42_rate_zero"  => Some(self.rb42_rate_zero.clone()), 
      "rb44_rate_zero"  => Some(self.rb44_rate_zero.clone()), 
      "rb46_rate_zero"  => Some(self.rb46_rate_zero.clone()), 
      "rb01_hk_too_old" => Some(self.rb01_hk_too_old.clone()), 
      "rb02_hk_too_old" => Some(self.rb02_hk_too_old.clone()),  
      "rb03_hk_too_old" => Some(self.rb03_hk_too_old.clone()),  
      "rb04_hk_too_old" => Some(self.rb04_hk_too_old.clone()), 
      "rb05_hk_too_old" => Some(self.rb05_hk_too_old.clone()), 
      "rb06_hk_too_old" => Some(self.rb06_hk_too_old.clone()), 
      "rb07_hk_too_old" => Some(self.rb07_hk_too_old.clone()), 
      "rb08_hk_too_old" => Some(self.rb08_hk_too_old.clone()), 
      "rb09_hk_too_old" => Some(self.rb09_hk_too_old.clone()), 
      "rb11_hk_too_old" => Some(self.rb11_hk_too_old.clone()), 
      "rb13_hk_too_old" => Some(self.rb13_hk_too_old.clone()), 
      "rb14_hk_too_old" => Some(self.rb14_hk_too_old.clone()), 
      "rb15_hk_too_old" => Some(self.rb15_hk_too_old.clone()), 
      "rb16_hk_too_old" => Some(self.rb16_hk_too_old.clone()), 
      "rb17_hk_too_old" => Some(self.rb17_hk_too_old.clone()), 
      "rb18_hk_too_old" => Some(self.rb18_hk_too_old.clone()), 
      "rb19_hk_too_old" => Some(self.rb19_hk_too_old.clone()), 
      "rb20_hk_too_old" => Some(self.rb20_hk_too_old.clone()), 
      "rb21_hk_too_old" => Some(self.rb21_hk_too_old.clone()), 
      "rb22_hk_too_old" => Some(self.rb22_hk_too_old.clone()), 
      "rb23_hk_too_old" => Some(self.rb23_hk_too_old.clone()), 
      "rb24_hk_too_old" => Some(self.rb24_hk_too_old.clone()), 
      "rb25_hk_too_old" => Some(self.rb25_hk_too_old.clone()), 
      "rb26_hk_too_old" => Some(self.rb26_hk_too_old.clone()), 
      "rb27_hk_too_old" => Some(self.rb27_hk_too_old.clone()), 
      "rb28_hk_too_old" => Some(self.rb28_hk_too_old.clone()), 
      "rb29_hk_too_old" => Some(self.rb29_hk_too_old.clone()), 
      "rb30_hk_too_old" => Some(self.rb30_hk_too_old.clone()), 
      "rb31_hk_too_old" => Some(self.rb31_hk_too_old.clone()), 
      "rb32_hk_too_old" => Some(self.rb32_hk_too_old.clone()), 
      "rb33_hk_too_old" => Some(self.rb33_hk_too_old.clone()), 
      "rb34_hk_too_old" => Some(self.rb34_hk_too_old.clone()), 
      "rb35_hk_too_old" => Some(self.rb35_hk_too_old.clone()), 
      "rb36_hk_too_old" => Some(self.rb36_hk_too_old.clone()), 
      "rb39_hk_too_old" => Some(self.rb39_hk_too_old.clone()), 
      "rb40_hk_too_old" => Some(self.rb40_hk_too_old.clone()), 
      "rb41_hk_too_old" => Some(self.rb41_hk_too_old.clone()), 
      "rb42_hk_too_old" => Some(self.rb42_hk_too_old.clone()), 
      "rb44_hk_too_old" => Some(self.rb44_hk_too_old.clone()), 
      "rb46_hk_too_old" => Some(self.rb46_hk_too_old.clone()), 
      _                => None
    }
  }
  
  pub fn from_toml(filename : &str) -> Result<Self, SerializationError> {
    match File::open(filename) {
      Err(err) => {
        println!("Unable to open {}! {}", filename, err);
        return Err(SerializationError::TomlDecodingError);
      }
      Ok(mut file) => {
        let mut toml_string = String::from("");
        match file.read_to_string(&mut toml_string) {
          Err(err) => {
            println!("Unable to read {}! {}", filename, err);
            return Err(SerializationError::TomlDecodingError);
          }
          Ok(_) => {
            match toml::from_str::<TofAlertManifest>(&toml_string) {
              Err(err) => {
                println!("Can't interpret toml! {}", err);
                return Err(SerializationError::TomlDecodingError);
              }
              Ok(manifest) => {
                Ok(manifest)
              }
            }
          }
        }
      }
    }
  }
  
  pub fn to_toml(&self, mut filename : String) {
    if !filename.ends_with(".toml") {
      filename += ".toml";
    }
    info!("Will write to file {}!", filename);
    match File::create(&filename) {
      Err(err) => {
        error!("Unable to open file {}! {}", filename, err);
      }
      Ok(mut file) => {
        match toml::to_string_pretty(&self) {
          Err(err) => {
            error!("Unable to serialize toml! {err}");
          }
          Ok(toml_string) => {
            match file.write_all(toml_string.as_bytes()) {
              Err(err) => error!("Unable to write to file {}! {}", filename, err),
              Ok(_)    => debug!("Wrote settings to {}!", filename)
            }
          }
        }
      }
    }
  }
  
}


/// Load all alerts from the manifest
pub fn load_alerts<'a>(manifest : TofAlertManifest) -> HashMap<&'a str, TofAlert<'a>> {
  let mut alerts = HashMap::from([("mtb_rate_zero", TofAlert {
                                                        key          : "mtb_rate_zero",
                                                        descr        : "MTB is not triggering!",
                                                        whattodo     : vec!["1) Check about TIU status", "2) Run restart", "3) If SSH available, debug with pybindings", "4) Soft reboot MTB", "5) Hard reboot MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::MTB,
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                   ("mtb_lost_rate", TofAlert { 
                                                        key          : "mtb_lost_rate",
                                                        descr        : "MTB Lost rate is whacky!!",
                                                        whattodo     : vec!["Unclear course of action. Check with tracker, maybe nothing can be done!"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::LostTriggerRate,
                                                        outofbound   : OutOfBound::TooHigh,
                                                        component    : Component::MTB,
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("mtb_fpga_temp", TofAlert {
                                                        key          : "mtb_fpga_temp",
                                                        descr        : "MTB Temperature out of bounds!!",
                                                        whattodo     : vec!["This is critical! Check with everyone and then shut off the MTB!"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::MTB,
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("mtb_hk_too_old" , TofAlert {
                                                        key          : "mtb_hk_too_old", 
                                                        descr        : "MTBMoniData is out-of-date!",
                                                        whattodo     : vec!["Critical! This most likely means we are not triggering!" ,  "1) Check with tracker", "2) Run restart", "3) Soft reboot MTB", "4) Powercycle CAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(40),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("cpu_core0_temp", TofAlert {
                                                        key          : "cpu_core0_temp",
                                                        descr        : "CPU Core0 temperatrue is out of bounds!",
                                                        whattodo     : vec!["This is critical! Check with everyone and then stop the run and likely turn off the CAT!"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::CoreTemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::CPU,
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("cpu_core1_temp", TofAlert {
                                                        key          : "cpu_core1_temp",
                                                        descr        : "CPU Core1 temperatrue is out of bounds!",
                                                        whattodo     : vec!["This is critical! Check with everyone and then stop the run and likely turn off the CAT!"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::CoreTemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::CPU,
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("cpu_disk", TofAlert {
                                                        key          : "cpu_disk",
                                                        descr        : "The disks on the TOF CPU are getting full.",
                                                        whattodo     : vec!["This is a general issue and need to be discussed in ops","No immediate action necessary"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::AvailableDiskSpace,
                                                        outofbound   : OutOfBound::TooHigh,
                                                        component    : Component::CPU,
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("cpu_hk_too_old" , TofAlert {
                                                        key          : "cpu_hk_too_old", 
                                                        descr        : "CPUMoniData is out-of-date!",
                                                        whattodo     : vec!["If everything else is fine, this is non-critical", "Typicallly, if this is an issue, there might be other, more severe issues!"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(40),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("data_mangling", TofAlert {
                                                        key          : "data_mangling",
                                                        descr        : "Data mangling (intermix of RB channels on one or several RBs) is excessive!",
                                                        whattodo     : vec!["This is a general issue!","No immediate action necessary","Options have to be discussed"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::DataMangling,
                                                        outofbound   : OutOfBound::TooHigh,
                                                        component    : Component::System,
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("miss_tofevid", TofAlert {
                                                        key          : "miss_tofevid",
                                                        descr        : "The Tof system is missing event ids in an excessive amount!",
                                                        whattodo     : vec!["This is nist likely related to ","No immediate action necessary","Options have to be discussed"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::DataMangling,
                                                        outofbound   : OutOfBound::TooHigh,
                                                        component    : Component::System,
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("tofev_vs_merge", TofAlert {
                                                        key          : "tofev_vs_merge",
                                                        descr        : "The rate of Tof event is larger thatn the rate of merged events!",
                                                        whattodo     : vec!["If you are getting the tof events from telemetry, this simply can't happen ","If this happens, something is utterly broken, most likely with our monitoring","In case we don't get TofEventSummary from telemetry but directlly from the TofCPU, we are on ground and this simply needs to be debugged"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::Telemetry,
                                                        outofbound   : OutOfBound::TooHigh,
                                                        component    : Component::System,
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("notof_vs_merge", TofAlert {
                                                        key          : "notof_vs_merge",
                                                        descr        : "The rate of merged events without TofEvents is excessive!",
                                                        whattodo     : vec!["The stream of TofEvents to the flight computer might have stopped","1) Run restart recommended","2) Soft Reboot MTB", "3) Hard reboot CAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::Telemetry,
                                                        outofbound   : OutOfBound::TooHigh,
                                                        component    : Component::System,
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("frac_interest", TofAlert {
                                                        key          : "frac_interest",
                                                        descr        : "The rate of interesting events is too low!",
                                                        whattodo     : vec!["The stream of TofEvents to the flight computer might have stopped","1) Run restart recommended","2) Soft Reboot MTB", "3) Hard reboot CAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::Telemetry,
                                                        outofbound   : OutOfBound::TooHigh,
                                                        component    : Component::System,
                                                        n_paged      : 0,
                                                        triggered    : None}),

                                    // 40x 3 RB alerts. I am only doing this to celebrate me being
                                    // miserable on basically ny's eve. May the gods have mercy and 
                                    // strike me down.
                                    ("rb01_rate_zero" , TofAlert {
                                                        key          : "rb01_rate_zero", 
                                                        descr        : "RB01 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(1),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb01_temp" , TofAlert {
                                                        key          : "rb01_temp", 
                                                        descr        : "RB01 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(1),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb01_hk_too_old" , TofAlert {
                                                        key          : "rb01_hk_too_old", 
                                                        descr        : "RB01 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(1),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    /////////////////////////////////////////////////////////
                                    ("rb02_rate_zero" , TofAlert {
                                                        key          : "rb02_rate_zero", 
                                                        descr        : "RB02 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(2),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb02_temp" , TofAlert {
                                                        key          : "rb02_temp", 
                                                        descr        : "RB02 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(2),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb02_hk_too_old" , TofAlert {
                                                        key          : "rb02_hk_too_old", 
                                                        descr        : "RB02 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        n_paged      : 0,
                                                        component    : Component::RB(2),
                                                        triggered    : None}),
                                    ("rb03_rate_zero" , TofAlert {
                                                        key          : "rb03_rate_zero", 
                                                        descr        : "RB03 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        n_paged      : 0,
                                                        component    : Component::RB(3),
                                                        triggered    : None}),
                                    ("rb03_temp" , TofAlert {
                                                        key          : "rb03_temp", 
                                                        descr        : "RB03 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(3),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb03_hk_too_old" , TofAlert {
                                                        key          : "rb03_hk_too_old", 
                                                        descr        : "RB03 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(3),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb04_rate_zero" , TofAlert {
                                                        key          : "rb04_rate_zero", 
                                                        descr        : "RB04 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(4),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb04_temp" , TofAlert {
                                                        key          : "rb04_temp", 
                                                        descr        : "RB04 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(4),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb04_hk_too_old" , TofAlert {
                                                        key          : "rb05_hk_too_old", 
                                                        descr        : "RB05 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(4),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb05_rate_zero" , TofAlert {
                                                        key          : "rb05_rate_zero", 
                                                        descr        : "RB05 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        n_paged      : 0,
                                                        component    : Component::RB(5),
                                                        triggered    : None}),
                                    ("rb05_temp" , TofAlert {
                                                        key          : "rb05_temp", 
                                                        descr        : "RB01 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(5),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb05_hk_too_old" , TofAlert {
                                                        key          : "rb05_hk_too_old", 
                                                        descr        : "RB01 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(5),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb06_rate_zero" , TofAlert {
                                                        key          : "rb06_rate_zero", 
                                                        descr        : "RB06 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(6),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb06_temp" , TofAlert {
                                                        key          : "rb06_temp", 
                                                        descr        : "RB06 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(6),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb06_hk_too_old" , TofAlert {
                                                        key          : "rb06_hk_too_old", 
                                                        descr        : "RB06 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(6),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb07_rate_zero" , TofAlert {
                                                        key          : "rb07_rate_zero", 
                                                        descr        : "RB07 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(7),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb07_temp" , TofAlert {
                                                        key          : "rb07_temp", 
                                                        descr        : "RB07 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(7),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb07_hk_too_old" , TofAlert {
                                                        key          : "rb07_hk_too_old", 
                                                        descr        : "RB07 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(7),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb08_rate_zero" , TofAlert {
                                                        key          : "rb08_rate_zero", 
                                                        descr        : "RB08 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(8),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb08_temp" , TofAlert {
                                                        key          : "rb08_temp", 
                                                        descr        : "RB08 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(8),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb08_hk_too_old" , TofAlert {
                                                        key          : "rb08_hk_too_old", 
                                                        descr        : "RB08 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(8),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb09_rate_zero" , TofAlert {
                                                        key          : "rb09_rate_zero", 
                                                        descr        : "RB09 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(9),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb09_temp" , TofAlert {
                                                        key          : "rb09_temp", 
                                                        descr        : "RB09 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(9),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb09_hk_too_old" , TofAlert {
                                                        key          : "rb09_hk_too_old", 
                                                        descr        : "RB09 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(9),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb11_rate_zero" , TofAlert {
                                                        key          : "rb11_rate_zero", 
                                                        descr        : "RB11 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(11),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb11_temp" , TofAlert {
                                                        key          : "rb11_temp", 
                                                        descr        : "RB11 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(11),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb11_hk_too_old" , TofAlert {
                                                        key          : "rb11_hk_too_old", 
                                                        descr        : "RB11 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(11),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    /////////////////////////////////////////////////////////
                                    ("rb13_rate_zero" , TofAlert {
                                                        key          : "rb13_rate_zero", 
                                                        descr        : "RB13 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(13),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb13_temp" , TofAlert {
                                                        key          : "rb13_temp", 
                                                        descr        : "RB13 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(13),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb13_hk_too_old" , TofAlert {
                                                        key          : "rb13_hk_too_old", 
                                                        descr        : "RB13 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(13),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb14_rate_zero" , TofAlert {
                                                        key          : "rb14_rate_zero", 
                                                        descr        : "RB14 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(14),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb14_temp" , TofAlert {
                                                        key          : "rb14_temp", 
                                                        descr        : "RB14 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(14),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb14_hk_too_old" , TofAlert {
                                                        key          : "rb14_hk_too_old", 
                                                        descr        : "RB14 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(14),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb15_rate_zero" , TofAlert {
                                                        key          : "rb15_rate_zero", 
                                                        descr        : "RB15 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(15),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb15_temp" , TofAlert {
                                                        key          : "rb15_temp", 
                                                        descr        : "RB15 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(15),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb15_hk_too_old" , TofAlert {
                                                        key          : "rb15_hk_too_old", 
                                                        descr        : "RB15 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(15),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb16_rate_zero" , TofAlert {
                                                        key          : "rb16_rate_zero", 
                                                        descr        : "RB16 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(16),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb16_temp" , TofAlert {
                                                        key          : "rb16_temp", 
                                                        descr        : "RB16 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(16),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb16_hk_too_old" , TofAlert {
                                                        key          : "rb16_hk_too_old", 
                                                        descr        : "RB16 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(16),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb17_rate_zero" , TofAlert {
                                                        key          : "rb17_rate_zero", 
                                                        descr        : "RB17 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(17),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb17_temp" , TofAlert {
                                                        key          : "rb17_temp", 
                                                        descr        : "RB17 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(17),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb17_hk_too_old" , TofAlert {
                                                        key          : "rb17_hk_too_old", 
                                                        descr        : "RB17 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(17),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb18_rate_zero" , TofAlert {
                                                        key          : "rb18_rate_zero", 
                                                        descr        : "RB18 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(18),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb18_temp" , TofAlert {
                                                        key          : "rb18_temp", 
                                                        descr        : "RB18 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(18),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb18_hk_too_old" , TofAlert {
                                                        key          : "rb18_hk_too_old", 
                                                        descr        : "RB18 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(18),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb19_rate_zero" , TofAlert {
                                                        key          : "rb19_rate_zero", 
                                                        descr        : "RB19 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(19),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb19_temp" , TofAlert {
                                                        key          : "rb19_temp", 
                                                        descr        : "RB19 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(19),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb19_hk_too_old" , TofAlert {
                                                        key          : "rb19_hk_too_old", 
                                                        descr        : "RB19 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(19),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb20_rate_zero" , TofAlert {
                                                        key          : "rb20_rate_zero", 
                                                        descr        : "RB20 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(20),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb20_temp" , TofAlert {
                                                        key          : "rb20_temp", 
                                                        descr        : "RB20 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(20),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb20_hk_too_old" , TofAlert {
                                                        key          : "rb20_hk_too_old", 
                                                        descr        : "RB20 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(20),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb21_rate_zero" , TofAlert {
                                                        key          : "rb21_rate_zero", 
                                                        descr        : "RB21 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(21),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb21_temp" , TofAlert {
                                                        key          : "rb21_temp", 
                                                        descr        : "RB21 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(21),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb21_hk_too_old" , TofAlert {
                                                        key          : "rb21_hk_too_old", 
                                                        descr        : "RB21 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(21),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ////////////////////////////////////////////////////////
                                    ("rb22_rate_zero" , TofAlert {
                                                        key          : "rb22_rate_zero", 
                                                        descr        : "RB22 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(22),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb22_temp" , TofAlert {
                                                        key          : "rb22_temp", 
                                                        descr        : "RB22 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(22),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb22_hk_too_old" , TofAlert {
                                                        key          : "rb22_hk_too_old", 
                                                        descr        : "RB22 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(22),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb23_rate_zero" , TofAlert {
                                                        key          : "rb23_rate_zero", 
                                                        descr        : "RB23 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(23),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb23_temp" , TofAlert {
                                                        key          : "rb23_temp", 
                                                        descr        : "RB23 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(23),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb23_hk_too_old" , TofAlert {
                                                        key          : "rb23_hk_too_old", 
                                                        descr        : "RB23 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(23),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb24_rate_zero" , TofAlert {
                                                        key          : "rb24_rate_zero", 
                                                        descr        : "RB24 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(24),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb24_temp" , TofAlert {
                                                        key          : "rb24_temp", 
                                                        descr        : "RB24 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(24),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb24_hk_too_old" , TofAlert {
                                                        key          : "rb24_hk_too_old", 
                                                        descr        : "RB24 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(24),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb25_rate_zero" , TofAlert {
                                                        key          : "rb25_rate_zero", 
                                                        descr        : "RB25 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(25),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb25_temp" , TofAlert {
                                                        key          : "rb25_temp", 
                                                        descr        : "RB25 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(25),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb25_hk_too_old" , TofAlert {
                                                        key          : "rb25_hk_too_old", 
                                                        descr        : "RB25 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(25),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb26_rate_zero" , TofAlert {
                                                        key          : "rb26_rate_zero", 
                                                        descr        : "RB26 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(26),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb26_temp" , TofAlert {
                                                        key          : "rb26_temp", 
                                                        descr        : "RB26 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(26),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb26_hk_too_old" , TofAlert {
                                                        key          : "rb26_hk_too_old", 
                                                        descr        : "RB26 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(26),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb27_rate_zero" , TofAlert {
                                                        key          : "rb27_rate_zero", 
                                                        descr        : "RB27 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(27),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb27_temp" , TofAlert {
                                                        key          : "rb27_temp", 
                                                        descr        : "RB27 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(27),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb27_hk_too_old" , TofAlert {
                                                        key          : "rb27_hk_too_old", 
                                                        descr        : "RB27 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(27),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb28_rate_zero" , TofAlert {
                                                        key          : "rb28_rate_zero", 
                                                        descr        : "RB28 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(28),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb28_temp" , TofAlert {
                                                        key          : "rb28_temp", 
                                                        descr        : "RB28 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(28),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb28_hk_too_old" , TofAlert {
                                                        key          : "rb28_hk_too_old", 
                                                        descr        : "RB28 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(28),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb29_rate_zero" , TofAlert {
                                                        key          : "rb29_rate_zero", 
                                                        descr        : "RB29 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(29),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb29_temp" , TofAlert {
                                                        key          : "rb29_temp", 
                                                        descr        : "RB29 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(29),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb29_hk_too_old" , TofAlert {
                                                        key          : "rb29_hk_too_old", 
                                                        descr        : "RB29 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(29),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ////////////////////////////////////////////////////////
                                    ("rb30_rate_zero" , TofAlert {
                                                        key          : "rb30_rate_zero", 
                                                        descr        : "RB30 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(30),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb30_temp" , TofAlert {
                                                        key          : "rb30_temp", 
                                                        descr        : "RB30 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(30),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb30_hk_too_old" , TofAlert {
                                                        key          : "rb30_hk_too_old", 
                                                        descr        : "RB30 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(30),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb31_rate_zero" , TofAlert {
                                                        key          : "rb31_rate_zero", 
                                                        descr        : "RB31 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(31),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb31_temp" , TofAlert {
                                                        key          : "rb31_temp", 
                                                        descr        : "RB31 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(31),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb31_hk_too_old" , TofAlert {
                                                        key          : "rb31_hk_too_old", 
                                                        descr        : "RB31 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(31),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb32_rate_zero" , TofAlert {
                                                        key          : "rb32_rate_zero", 
                                                        descr        : "RB32 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(32),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb32_temp" , TofAlert {
                                                        key          : "rb32_temp", 
                                                        descr        : "RB32 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(32),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb32_hk_too_old" , TofAlert {
                                                        key          : "rb32_hk_too_old", 
                                                        descr        : "RB30 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(32),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb33_rate_zero" , TofAlert {
                                                        key          : "rb33_rate_zero", 
                                                        descr        : "RB33 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(33),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb33_temp" , TofAlert {
                                                        key          : "rb33_temp", 
                                                        descr        : "RB33 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(33),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb33_hk_too_old" , TofAlert {
                                                        key          : "rb33_hk_too_old", 
                                                        descr        : "RB33 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(33),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb34_rate_zero" , TofAlert {
                                                        key          : "rb34_rate_zero", 
                                                        descr        : "RB34 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(34),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb34_temp" , TofAlert {
                                                        key          : "rb34_temp", 
                                                        descr        : "RB34 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(34),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb34_hk_too_old" , TofAlert {
                                                        key          : "rb34_hk_too_old", 
                                                        descr        : "RB34 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(34),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb35_rate_zero" , TofAlert {
                                                        key          : "rb35_rate_zero", 
                                                        descr        : "RB35 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(35),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb35_temp" , TofAlert {
                                                        key          : "rb35_temp", 
                                                        descr        : "RB35 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(35),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb35_hk_too_old" , TofAlert {
                                                        key          : "rb35_hk_too_old", 
                                                        descr        : "RB35 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(35),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb36_rate_zero" , TofAlert {
                                                        key          : "rb36_rate_zero", 
                                                        descr        : "RB36 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(36),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb36_temp" , TofAlert {
                                                        key          : "rb36_temp", 
                                                        descr        : "RB36 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(36),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb36_hk_too_old" , TofAlert {
                                                        key          : "rb36_hk_too_old", 
                                                        descr        : "RB36 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(36),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb39_rate_zero" , TofAlert {
                                                        key          : "rb39_rate_zero", 
                                                        descr        : "RB39 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(39),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb39_temp" , TofAlert {
                                                        key          : "rb39_temp", 
                                                        descr        : "RB39 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(39),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb39_hk_too_old" , TofAlert {
                                                        key          : "rb39_hk_too_old", 
                                                        descr        : "RB39 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(39),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                ///////////////////////////////////////////////////////////
                                    ("rb40_rate_zero" , TofAlert {
                                                        key          : "rb40_rate_zero", 
                                                        descr        : "RB40 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(40),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb40_temp" , TofAlert {
                                                        key          : "rb40_temp", 
                                                        descr        : "RB40 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(40),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb40_hk_too_old" , TofAlert {
                                                        key          : "rb40_hk_too_old", 
                                                        descr        : "RB40 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(40),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb41_rate_zero" , TofAlert {
                                                        key          : "rb41_rate_zero", 
                                                        descr        : "RB41 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(41),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb41_temp" , TofAlert {
                                                        key          : "rb41_temp", 
                                                        descr        : "RB41 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(41),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb41_hk_too_old" , TofAlert {
                                                        key          : "rb41_hk_too_old", 
                                                        descr        : "RB41 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(41),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb42_rate_zero" , TofAlert {
                                                        key          : "rb42_rate_zero", 
                                                        descr        : "RB42 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(42),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb42_temp" , TofAlert {
                                                        key          : "rb42_temp", 
                                                        descr        : "RB42 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(42),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb42_hk_too_old" , TofAlert {
                                                        key          : "rb42_hk_too_old", 
                                                        descr        : "RB42 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(42),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb44_rate_zero" , TofAlert {
                                                        key          : "rb44_rate_zero", 
                                                        descr        : "RB44 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(44),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb44_temp" , TofAlert {
                                                        key          : "rb44_temp", 
                                                        descr        : "RB44 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(44),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb44_hk_too_old" , TofAlert {
                                                        key          : "rb44_hk_too_old", 
                                                        descr        : "RB44 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(44),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb46_rate_zero" , TofAlert {
                                                        key          : "rb46_rate_zero", 
                                                        descr        : "RB46 is not triggering!", 
                                                        whattodo     : vec!["If we are getting HK data, but the RAT is not triggering, this indicated an issue with either the RAT (the other RB might be down as well or the MTB", "If the other RB in the RAT is working, try soft rebooting the MTB", "Hard reboot the MTB"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::TriggerRate,
                                                        outofbound   : OutOfBound::Zero,
                                                        component    : Component::RB(46),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb46_temp" , TofAlert {
                                                        key          : "rb46_temp", 
                                                        descr        : "RB46 (FPGA) temperature is out of bounds!",
                                                        whattodo     : vec!["This is critical!" ,  "Check with everybody and then likeliy switch off the RAT"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::FPGATemp,
                                                        outofbound   : OutOfBound::TooLowOrTooHigh,
                                                        component    : Component::RB(46),
                                                        n_paged      : 0,
                                                        triggered    : None}),
                                    ("rb46_hk_too_old" , TofAlert {
                                                        key          : "rb46_hk_too_old", 
                                                        descr        : "RB46 RBMoniData is out-of-date!",
                                                        whattodo     : vec!["Maybe the RB is down?" ,  "Telemetry issues?", "Have an eye on it and take notes"],
                                                        config       : TofAlertConfig::new(),
                                                        variable     : Variable::MoniData,
                                                        outofbound   : OutOfBound::TooOld,
                                                        component    : Component::RB(46),
                                                        n_paged      : 0,
                                                        triggered    : None}),

  ]);
   // rb ids
   // 1,2,3,4,5,6,7,8,9,11,13,14,15,16,17,18,19,
   // 20,21,22,23,24,25,26,27,28,29,
   // 30,31,32,33,34,35,36,
   // 39,40,41,44,46

//  TofAlert {
//    key          : "rb_rate_zero",
//    descr        : "RB1 is not triggering!",
//    whattodo     : vec!["1) Run restart", "2) Restart liftof-rb", "3) Soft reboot RB", "4) Soft reboot MTB", "5) Hard reboot RAT",  "6) Hard reboot MTB"],
//    config       : TofAlertConfig::new(),
//    variable     : Variable::TriggerRate,
//    outofbound   : OutOfBound::Zero,
//    component    : Component::RB(rb_id),
//    acknowledged : false,
//    created      : None,
//  }
  //let mut alerts = HashMap::<&str, TofAlert>::new();
  for k in manifest.keys() {
    println!("{}",k);
    alerts.get_mut(k).unwrap().config = manifest.get(k).unwrap().clone();
  }
  alerts

}

#[test]
fn write_alert_manifest() {
  let settings = TofAlertManifest::new();
  //println!("{}", settings);
  settings.to_toml(String::from("alert-manifest-test.toml"));
}

#[test]
fn read_alert_manifest() {
  let _settings = TofAlertManifest::from_toml("alert-manifest-test.toml");
}