-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsatellites.cpp
93 lines (79 loc) · 3.41 KB
/
satellites.cpp
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
/*******************************************************************************
* wirbelscan: A plugin for the Video Disk Recorder
* See the README file for copyright information and how to reach the author.
******************************************************************************/
#define SAT_COUNT(x) (sizeof(x)/sizeof(struct cSat))
#define SAT_TRANSPONDER_COUNT(x) (sizeof(x)/sizeof(struct __sat_transponder))
#define B(ID) static const struct __sat_transponder ID[] = {
#define E(ID) };
#include <string>
#include "common.h"
#include "satellites.h"
#include "satellites.dat"
/******************************************************************************
* convert position constant to index number
*****************************************************************************/
int txt_to_satellite(std::string id) {
for(size_t i=0; i<SAT_COUNT(sat_list); i++)
if (id == sat_list[i].short_name)
return sat_list[i].id;
return -1;
}
/******************************************************************************
* return numbers of satellites defined.
*****************************************************************************/
size_t sat_count(void) {
return SAT_COUNT(sat_list);
}
/******************************************************************************
* convert index number to position constant
*****************************************************************************/
std::string satellite_to_short_name(size_t idx) {
for(size_t i=0; i<SAT_COUNT(sat_list); i++)
if (idx == sat_list[i].id)
return sat_list[i].short_name;
return "??";
}
/******************************************************************************
* convert index number to satellite name
*****************************************************************************/
std::string satellite_to_full_name(size_t idx) {
for(size_t i=0; i<SAT_COUNT(sat_list); i++)
if (idx == sat_list[i].id)
return sat_list[i].full_name;
warning("SATELLITE CODE NOT DEFINED. PLEASE RE-CHECK WHETHER YOU TYPED CORRECTLY.");
mSleep(5000);
return "??";
}
/******************************************************************************
* return index number from rotor position
*****************************************************************************/
int rotor_position_to_sat_list_index(int rotor_position) {
for(size_t i=0; i<SAT_COUNT(sat_list); i++)
if (rotor_position == sat_list[i].rotor_position)
return i;
return 0;
}
/******************************************************************************
* print list of all satellites
*****************************************************************************/
void print_satellites(void) {
for(size_t i=0; i<SAT_COUNT(sat_list); i++)
info("\t" + std::string(sat_list[i].short_name) +
"\t\t" + std::string(sat_list[i].full_name));
}
/******************************************************************************
* choose a satellite by it's id.
*****************************************************************************/
int choose_satellite(std::string satellite, int& channellist) {
int retval = 0;
channellist = txt_to_satellite(satellite);
if (channellist < 0) {
channellist = S19E2;
warning("\n\nSATELLITE CODE IS NOT DEFINED. FALLING BACK TO 'S19E2'\n");
mSleep(10000);
retval = -1;
}
info("using settings for '" + satellite_to_full_name(channellist) + "'");
return retval;
}