1 // ----------------------------------------------------------------------------
2 // Copyright (C) 2014
3 //              David Freese, W1HKJ
4 //
5 // This file is part of fldigi
6 //
7 // fldigi is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // fldigi is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 // ----------------------------------------------------------------------------
20 
21 #ifndef XML_H
22 #define XML_H
23 
24 #include <string>
25 #include <list>
26 #include <vector>
27 
28 using namespace std;
29 
30 struct MODE {
31 	std::string SYMBOL;
32 	std::string BYTES;
MODEMODE33 	MODE(std::string nm, std::string b) { SYMBOL = nm; BYTES = b;}
MODEMODE34 	MODE(std::string nm, char c) { SYMBOL = nm; BYTES += c;}
35 };
36 
37 struct BW {
38 	std::string SYMBOL;
39 	std::string BYTES;
BWBW40 	BW(std::string nm, std::string b) { SYMBOL = nm; BYTES = b;}
BWBW41 	BW(std::string nm, char c) { SYMBOL = nm; BYTES += c;}
42 };
43 
44 struct DATA {
45 	std::string dtype;
46 	int size;
47 	int max;
48 	int min;
49 	float resolution;
50 	bool reverse;
51 	int	andmask;
52 	int shiftbits;
clearDATA53 	void clear() {
54 		size = 0;
55 		dtype.clear();
56 		max = 199999999;
57 		min = 0;
58 		resolution = 1.0;
59 		reverse = false;
60 		andmask = 0xFF;
61 		shiftbits = 0;
62 	}
63 };
64 
65 struct XMLIOS {
66 	std::string	SYMBOL;
67 	int 	size;
68 	std::string	str1;
69 	std::string	str2;
70 	DATA	data;
71 	int		fill1;
72 	int		fill2;
73 	std::string	info;
74 	std::string	ok;
75 	std::string	bad;
clearXMLIOS76 	void clear() {
77 		SYMBOL.clear();
78 		str1.clear();
79 		str2.clear();
80 		info.clear();
81 		ok.clear();
82 		bad.clear();
83 		size = fill1 = fill2 = 0;
84 		data.clear();
85 	}
86 };
87 
88 struct TAGS { const char *tag; void (*fp)(size_t &);};
89 
90 struct PAIR {
91 	int val;
92 	int mtr;
PAIRPAIR93 	PAIR(int v, int s) { val = v; mtr = s; }
clearPAIR94 	void clear() {val = 0; mtr = 0; }
95 };
96 
97 struct XMLRIG {
XMLRIGXMLRIG98 	XMLRIG() {
99 		clear();
100 	}
101 
102 	std::string	port;
103 	string rigTitle;
104 	int		baud;
105 	int		stopbits;
106 	bool	dtr;
107 	bool	dtrptt;
108 	bool	rts;
109 	bool	rtsptt;
110 	bool	rtscts;
111 	bool	restore_tio;
112 	int     write_delay;
113 	int		init_delay;
114 	int		wait_for_device;
115 	int		post_write_delay;
116 	int		timeout;
117 	int		retries;
118 	bool	echo;
119 	bool	cmdptt;
120 	bool	vsp;
121 	bool	logstr;
122 	int		pollinterval;
123 	bool	use_smeter;
124 	vector< PAIR > smeter;
125 	bool	use_pwrmeter;
126 	vector< PAIR > pmeter;
127 	bool	use_notch;
128 	vector< PAIR > notch;
129 	bool	use_pwrlevel;
130 	vector< PAIR >pwrlevel;
131 
132 	bool	debug;
133 	bool	noserial;
134 	bool	ascii;
135 	bool	xmlok;
136 
clearXMLRIG137 	void clear() {
138 		port.clear();
139 		baud = 1200;
140 		stopbits = 2;
141 		dtr = false;
142 		dtrptt = false;
143 		rts = false;
144 		rtsptt = false;
145 		rtscts = false;
146 		restore_tio = true;
147 		echo = false;
148 		cmdptt = false;
149 		vsp = false;
150 		logstr = false;
151 		write_delay = 0;
152 		init_delay = 0;
153 		wait_for_device = 0;
154 		post_write_delay = 50;
155 		timeout = 200;
156 		retries = 5;
157 		rigTitle = "";
158 		pollinterval = 100;
159 
160 		debug = false;
161 		noserial = false;
162 		ascii = false;
163 		xmlok = false;
164 
165 		use_smeter = false;
166 		use_pwrmeter = false;
167 		use_pwrlevel = false;
168 		smeter.clear();
169 		pmeter.clear();
170 		pwrlevel.clear();
171 		notch.clear();
172 	}
173 };
174 
175 extern std::list<XMLIOS> commands;
176 extern std::list<XMLIOS> reply;
177 extern std::list<MODE> lmodes;
178 extern std::list<MODE> lmodeCMD;
179 extern std::list<MODE> lmodeREPLY;
180 extern std::list<BW> lbws;
181 extern std::list<BW> lbwCMD;
182 extern std::list<BW> lbwREPLY;
183 extern std::list<std::string> LSBmodes;
184 extern XMLRIG xmlrig;
185 
186 extern bool readRigXML();
187 extern void	selectRigXmlFilename();
188 extern void loadRigXmlFile(void);
189 #endif
190 
191