forked from Leapus/hamcreek
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
110 lines (92 loc) · 3.61 KB
/
main.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <string>
#include <iostream>
#include "config.hpp"
#include "main.hpp"
#include "string.hpp"
#include "radio_config.hpp"
#include "chirp_channel_file.hpp"
#include "djmd5_file.hpp"
#include "band_channelgen.hpp"
//using leapus::csv;
using namespace std::string_literals;
using namespace leapus;
using namespace leapus::string;
using namespace leapus::hamconf;
using namespace leapus::configuration;
std::ostream &leapus::conout = std::cout;
std::istream &leapus::conin = std::cin;
std::ostream &leapus::err = std::cerr;
leapus::State leapus::state;
size_t State::channel_count() const{ return m_channels.size(); }
const channel_map_type &State::channels() const{ return m_channels; }
void State::channels( channel_map_type &&channels ){
m_channels = std::move(channels);
//m_channel_callsign_index.clear();
//for(auto &p : m_channels){
// m_channel_callsign_index.insert( std::pair( p.second. ) );
//}
}
static void bandchangen(ordinal_t &maxi, std::string prefix, freq_t start, freq_t end, freq_t width, channel_map_type &dest, power_levels power){
band_channelgen gen(maxi+1, prefix, start, end, width, power);
for( auto &c : gen.channels() ){
auto i=c.ordinal.value();
dest[i]=std::move(c);
maxi=std::max(maxi,i);
}
}
int main( int argc, const char *argv[]){
//auto x=fixed_point("123.001",5);
//std::cout << "TETS: " << fixed_to_string(x,5) << std::endl;
try{
leapus::state.config.parse(argc, argv);
}
catch(const config_exception &ex){
leapus::state.config.usage();
print_info("Error: "s + ex.what());
return -1;
}
//
// Import here
//
channel_map_type channels;
auto &maxi=state.config.max_ordinal;
if(!leapus::state.config.chirp_channels_in.empty()){
print_info( "Loading CHIRP channel data from: "s + leapus::state.config.chirp_channels_in.string() );
chirp_channel_importer import(leapus::state.config.chirp_channels_in);
channels = std::move(import.channels());
//print_info( mkstring<>() << "Imported CHIRP channels: " << channel_map.size() );
print_info( "Imported CHIRP channels: " + std::to_string( channels.size() ) );
maxi=std::max(maxi, import.max_ordinal());
}
//
// Do Mexican stuff
//
if(state.config.mexico){
//Generate channels to fill the unlicensed public bands
//All of these are 12.5kHz bandwidth, 40W max permissible, voice/data, no repeaters allowed
//No interfacing with telephone services allowed.
bandchangen(maxi, "MEX", 153012500, 153237500, 12500, channels, High);
bandchangen(maxi, "MEX", 159012500, 159200000, 12500, channels, High);
bandchangen(maxi, "MEX", 163012500, 163237500, 12500, channels, High);
bandchangen(maxi, "MEX", 450262500, 450487500, 12500, channels, High);
bandchangen(maxi, "MEX", 455262500, 455487500, 12500, channels, High);
//There's also these, but they are limited to 500mW, and the closest
//MD5 power setting is "Small" for 200mW.
bandchangen(maxi, "MEX", 462556250, 462568750, 12500, channels, Small);
bandchangen(maxi, "MEX", 462581250, 462593750, 12500, channels, Small);
}
//Merge in optional radioid.net repeater data
//
//Export here
//
djmd5_channel_exporter djmd5_exporter(leapus::state.config.stdout_path);
djmd5_exporter.write( channels );
//DEBUG
//for( auto &chan : import.channels()){
// std::cout << "Channel: " << chan.first << std::endl;
//}
return 0;
}
void leapus::print_info(const std::string &v){
leapus::err << v << std::endl;
}