2 * Copyright © 2010 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 import java.awt.event.*;
23 import javax.swing.event.*;
24 import org.altusmetrum.AltosLib.*;
25 import org.altusmetrum.altosuilib.*;
27 public class AltosConfigUI
29 implements ActionListener, ItemListener, DocumentListener, AltosConfigValues
36 JLabel main_deploy_label;
37 JLabel apogee_delay_label;
38 JLabel apogee_lockout_label;
39 JLabel frequency_label;
40 JLabel radio_calibration_label;
41 JLabel radio_frequency_label;
42 JLabel radio_enable_label;
43 JLabel aprs_interval_label;
44 JLabel flight_log_max_label;
45 JLabel ignite_mode_label;
46 JLabel pad_orientation_label;
47 JLabel callsign_label;
55 JComboBox main_deploy_value;
56 JComboBox apogee_delay_value;
57 JComboBox apogee_lockout_value;
58 AltosFreqList radio_frequency_value;
59 JTextField radio_calibration_value;
60 JRadioButton radio_enable_value;
61 JComboBox aprs_interval_value;
62 JComboBox flight_log_max_value;
63 JComboBox ignite_mode_value;
64 JComboBox pad_orientation_value;
65 JTextField callsign_value;
76 ActionListener listener;
78 static String[] main_deploy_values = {
79 "100", "150", "200", "250", "300", "350",
83 static String[] apogee_delay_values = {
84 "0", "1", "2", "3", "4", "5"
87 static String[] apogee_lockout_values = {
88 "0", "5", "10", "15", "20"
91 static String[] flight_log_max_values = {
92 "64", "128", "192", "256", "320",
93 "384", "448", "512", "576", "640",
94 "704", "768", "832", "896", "960",
97 static String[] ignite_mode_values = {
103 static String[] aprs_interval_values = {
110 static String[] pad_orientation_values = {
115 /* A window listener to catch closing events and tell the config code */
116 class ConfigListener extends WindowAdapter {
119 public ConfigListener(AltosConfigUI this_ui) {
123 public void windowClosing(WindowEvent e) {
124 ui.actionPerformed(new ActionEvent(e.getSource(),
125 ActionEvent.ACTION_PERFORMED,
130 boolean is_telemini() {
131 String product = product_value.getText();
132 return product != null && product.startsWith("TeleMini");
135 boolean is_telemetrum() {
136 String product = product_value.getText();
137 return product != null && product.startsWith("TeleMetrum");
140 void set_radio_calibration_tool_tip() {
141 if (radio_calibration_value.isEnabled())
142 radio_calibration_value.setToolTipText("Tune radio output to match desired frequency");
144 radio_calibration_value.setToolTipText("Cannot tune radio while connected over packet mode");
147 void set_radio_enable_tool_tip() {
148 if (radio_enable_value.isEnabled())
149 radio_enable_value.setToolTipText("Enable/Disable telemetry and RDF transmissions");
151 radio_enable_value.setToolTipText("Firmware version does not support disabling radio");
154 void set_aprs_interval_tool_tip() {
155 if (aprs_interval_value.isEnabled())
156 aprs_interval_value.setToolTipText("Enable APRS and set the interval between APRS reports");
158 aprs_interval_value.setToolTipText("Hardware doesn't support APRS");
161 void set_flight_log_max_tool_tip() {
162 if (flight_log_max_value.isEnabled())
163 flight_log_max_value.setToolTipText("Size reserved for each flight log (in kB)");
166 flight_log_max_value.setToolTipText("Cannot set max value with flight logs in memory");
167 else if (is_telemini())
168 flight_log_max_value.setToolTipText("TeleMini stores only one flight");
170 flight_log_max_value.setToolTipText("Cannot set max flight log value");
174 void set_ignite_mode_tool_tip() {
175 if (ignite_mode_value.isEnabled())
176 ignite_mode_value.setToolTipText("Select when igniters will be fired");
178 ignite_mode_value.setToolTipText("Older firmware could not select ignite mode");
181 void set_pad_orientation_tool_tip() {
182 if (pad_orientation_value.isEnabled())
183 pad_orientation_value.setToolTipText("How will TeleMetrum be mounted in the airframe");
186 pad_orientation_value.setToolTipText("Older TeleMetrum firmware must fly antenna forward");
187 else if (is_telemini())
188 pad_orientation_value.setToolTipText("TeleMini doesn't care how it is mounted");
190 pad_orientation_value.setToolTipText("Can't select orientation");
194 /* Build the UI using a grid bag */
195 public AltosConfigUI(JFrame in_owner, boolean remote) {
196 super (in_owner, "Configure TeleMetrum", false);
199 GridBagConstraints c;
202 Insets il = new Insets(4,4,4,4);
203 Insets ir = new Insets(4,4,4,4);
205 pane = getContentPane();
206 pane.setLayout(new GridBagLayout());
209 c = new GridBagConstraints();
210 c.gridx = 0; c.gridy = row;
212 c.fill = GridBagConstraints.NONE;
213 c.anchor = GridBagConstraints.LINE_START;
215 product_label = new JLabel("Product:");
216 pane.add(product_label, c);
218 c = new GridBagConstraints();
219 c.gridx = 4; c.gridy = row;
221 c.fill = GridBagConstraints.HORIZONTAL;
223 c.anchor = GridBagConstraints.LINE_START;
225 product_value = new JLabel("");
226 pane.add(product_value, c);
230 c = new GridBagConstraints();
231 c.gridx = 0; c.gridy = row;
233 c.fill = GridBagConstraints.NONE;
234 c.anchor = GridBagConstraints.LINE_START;
237 version_label = new JLabel("Software version:");
238 pane.add(version_label, c);
240 c = new GridBagConstraints();
241 c.gridx = 4; c.gridy = row;
243 c.fill = GridBagConstraints.HORIZONTAL;
245 c.anchor = GridBagConstraints.LINE_START;
248 version_value = new JLabel("");
249 pane.add(version_value, c);
253 c = new GridBagConstraints();
254 c.gridx = 0; c.gridy = row;
256 c.fill = GridBagConstraints.NONE;
257 c.anchor = GridBagConstraints.LINE_START;
260 serial_label = new JLabel("Serial:");
261 pane.add(serial_label, c);
263 c = new GridBagConstraints();
264 c.gridx = 4; c.gridy = row;
266 c.fill = GridBagConstraints.HORIZONTAL;
268 c.anchor = GridBagConstraints.LINE_START;
271 serial_value = new JLabel("");
272 pane.add(serial_value, c);
276 c = new GridBagConstraints();
277 c.gridx = 0; c.gridy = row;
279 c.fill = GridBagConstraints.NONE;
280 c.anchor = GridBagConstraints.LINE_START;
283 main_deploy_label = new JLabel("Main Deploy Altitude(m):");
284 pane.add(main_deploy_label, c);
286 c = new GridBagConstraints();
287 c.gridx = 4; c.gridy = row;
289 c.fill = GridBagConstraints.HORIZONTAL;
291 c.anchor = GridBagConstraints.LINE_START;
294 main_deploy_value = new JComboBox(main_deploy_values);
295 main_deploy_value.setEditable(true);
296 main_deploy_value.addItemListener(this);
297 pane.add(main_deploy_value, c);
298 main_deploy_value.setToolTipText("Height above pad altitude to fire main charge");
302 c = new GridBagConstraints();
303 c.gridx = 0; c.gridy = row;
305 c.fill = GridBagConstraints.NONE;
306 c.anchor = GridBagConstraints.LINE_START;
309 apogee_delay_label = new JLabel("Apogee Delay(s):");
310 pane.add(apogee_delay_label, c);
312 c = new GridBagConstraints();
313 c.gridx = 4; c.gridy = row;
315 c.fill = GridBagConstraints.HORIZONTAL;
317 c.anchor = GridBagConstraints.LINE_START;
320 apogee_delay_value = new JComboBox(apogee_delay_values);
321 apogee_delay_value.setEditable(true);
322 apogee_delay_value.addItemListener(this);
323 pane.add(apogee_delay_value, c);
324 apogee_delay_value.setToolTipText("Delay after apogee before charge fires");
328 c = new GridBagConstraints();
329 c.gridx = 0; c.gridy = row;
331 c.fill = GridBagConstraints.NONE;
332 c.anchor = GridBagConstraints.LINE_START;
335 apogee_lockout_label = new JLabel("Apogee Lockout(s):");
336 pane.add(apogee_lockout_label, c);
338 c = new GridBagConstraints();
339 c.gridx = 4; c.gridy = row;
341 c.fill = GridBagConstraints.HORIZONTAL;
343 c.anchor = GridBagConstraints.LINE_START;
346 apogee_lockout_value = new JComboBox(apogee_lockout_values);
347 apogee_lockout_value.setEditable(true);
348 apogee_lockout_value.addItemListener(this);
349 pane.add(apogee_lockout_value, c);
350 apogee_lockout_value.setToolTipText("Time after boost while apogee detection is locked out");
354 c = new GridBagConstraints();
355 c.gridx = 0; c.gridy = row;
357 c.fill = GridBagConstraints.NONE;
358 c.anchor = GridBagConstraints.LINE_START;
361 radio_frequency_label = new JLabel("Frequency:");
362 pane.add(radio_frequency_label, c);
364 c = new GridBagConstraints();
365 c.gridx = 4; c.gridy = row;
367 c.fill = GridBagConstraints.HORIZONTAL;
369 c.anchor = GridBagConstraints.LINE_START;
372 radio_frequency_value = new AltosFreqList();
373 radio_frequency_value.addItemListener(this);
374 pane.add(radio_frequency_value, c);
375 radio_frequency_value.setToolTipText("Telemetry, RDF and packet frequency");
378 /* Radio Calibration */
379 c = new GridBagConstraints();
380 c.gridx = 0; c.gridy = row;
382 c.fill = GridBagConstraints.NONE;
383 c.anchor = GridBagConstraints.LINE_START;
386 radio_calibration_label = new JLabel("RF Calibration:");
387 pane.add(radio_calibration_label, c);
389 c = new GridBagConstraints();
390 c.gridx = 4; c.gridy = row;
392 c.fill = GridBagConstraints.HORIZONTAL;
394 c.anchor = GridBagConstraints.LINE_START;
397 radio_calibration_value = new JTextField(String.format("%d", 1186611));
398 radio_calibration_value.getDocument().addDocumentListener(this);
400 radio_calibration_value.setEnabled(false);
401 pane.add(radio_calibration_value, c);
402 set_radio_calibration_tool_tip();
406 c = new GridBagConstraints();
407 c.gridx = 0; c.gridy = row;
409 c.fill = GridBagConstraints.NONE;
410 c.anchor = GridBagConstraints.LINE_START;
413 radio_enable_label = new JLabel("Telemetry/RDF/APRS Enable:");
414 pane.add(radio_enable_label, c);
416 c = new GridBagConstraints();
417 c.gridx = 4; c.gridy = row;
419 c.fill = GridBagConstraints.HORIZONTAL;
421 c.anchor = GridBagConstraints.LINE_START;
424 radio_enable_value = new JRadioButton("Enabled");
425 radio_enable_value.addItemListener(this);
426 pane.add(radio_enable_value, c);
427 set_radio_enable_tool_tip();
431 c = new GridBagConstraints();
432 c.gridx = 0; c.gridy = row;
434 c.fill = GridBagConstraints.NONE;
435 c.anchor = GridBagConstraints.LINE_START;
438 aprs_interval_label = new JLabel("APRS Interval(s):");
439 pane.add(aprs_interval_label, c);
441 c = new GridBagConstraints();
442 c.gridx = 4; c.gridy = row;
444 c.fill = GridBagConstraints.HORIZONTAL;
446 c.anchor = GridBagConstraints.LINE_START;
449 aprs_interval_value = new JComboBox(aprs_interval_values);
450 aprs_interval_value.setEditable(true);
451 aprs_interval_value.addItemListener(this);
452 pane.add(aprs_interval_value, c);
453 set_aprs_interval_tool_tip();
457 c = new GridBagConstraints();
458 c.gridx = 0; c.gridy = row;
460 c.fill = GridBagConstraints.NONE;
461 c.anchor = GridBagConstraints.LINE_START;
464 callsign_label = new JLabel("Callsign:");
465 pane.add(callsign_label, c);
467 c = new GridBagConstraints();
468 c.gridx = 4; c.gridy = row;
470 c.fill = GridBagConstraints.HORIZONTAL;
472 c.anchor = GridBagConstraints.LINE_START;
475 callsign_value = new JTextField(AltosUIPreferences.callsign());
476 callsign_value.getDocument().addDocumentListener(this);
477 pane.add(callsign_value, c);
478 callsign_value.setToolTipText("Callsign reported in telemetry data");
482 c = new GridBagConstraints();
483 c.gridx = 0; c.gridy = row;
485 c.fill = GridBagConstraints.NONE;
486 c.anchor = GridBagConstraints.LINE_START;
489 flight_log_max_label = new JLabel("Maximum Flight Log Size:");
490 pane.add(flight_log_max_label, c);
492 c = new GridBagConstraints();
493 c.gridx = 4; c.gridy = row;
495 c.fill = GridBagConstraints.HORIZONTAL;
497 c.anchor = GridBagConstraints.LINE_START;
500 flight_log_max_value = new JComboBox(flight_log_max_values);
501 flight_log_max_value.setEditable(true);
502 flight_log_max_value.addItemListener(this);
503 pane.add(flight_log_max_value, c);
504 set_flight_log_max_tool_tip();
508 c = new GridBagConstraints();
509 c.gridx = 0; c.gridy = row;
511 c.fill = GridBagConstraints.NONE;
512 c.anchor = GridBagConstraints.LINE_START;
515 ignite_mode_label = new JLabel("Igniter Firing Mode:");
516 pane.add(ignite_mode_label, c);
518 c = new GridBagConstraints();
519 c.gridx = 4; c.gridy = row;
521 c.fill = GridBagConstraints.HORIZONTAL;
523 c.anchor = GridBagConstraints.LINE_START;
526 ignite_mode_value = new JComboBox(ignite_mode_values);
527 ignite_mode_value.setEditable(false);
528 ignite_mode_value.addItemListener(this);
529 pane.add(ignite_mode_value, c);
530 set_ignite_mode_tool_tip();
533 /* Pad orientation */
534 c = new GridBagConstraints();
535 c.gridx = 0; c.gridy = row;
537 c.fill = GridBagConstraints.NONE;
538 c.anchor = GridBagConstraints.LINE_START;
541 pad_orientation_label = new JLabel("Pad Orientation:");
542 pane.add(pad_orientation_label, c);
544 c = new GridBagConstraints();
545 c.gridx = 4; c.gridy = row;
547 c.fill = GridBagConstraints.HORIZONTAL;
549 c.anchor = GridBagConstraints.LINE_START;
552 pad_orientation_value = new JComboBox(pad_orientation_values);
553 pad_orientation_value.setEditable(false);
554 pad_orientation_value.addItemListener(this);
555 pane.add(pad_orientation_value, c);
556 set_pad_orientation_tool_tip();
560 c = new GridBagConstraints();
561 c.gridx = 4; c.gridy = row;
563 c.fill = GridBagConstraints.HORIZONTAL;
564 c.anchor = GridBagConstraints.LINE_START;
567 pyro = new JButton("Configure Pyro Channels");
569 pyro.addActionListener(this);
570 pyro.setActionCommand("Pyro");
574 c = new GridBagConstraints();
575 c.gridx = 0; c.gridy = row;
577 c.fill = GridBagConstraints.NONE;
578 c.anchor = GridBagConstraints.LINE_START;
580 save = new JButton("Save");
582 save.addActionListener(this);
583 save.setActionCommand("Save");
585 c = new GridBagConstraints();
586 c.gridx = 2; c.gridy = row;
588 c.fill = GridBagConstraints.NONE;
589 c.anchor = GridBagConstraints.CENTER;
591 reset = new JButton("Reset");
593 reset.addActionListener(this);
594 reset.setActionCommand("Reset");
596 c = new GridBagConstraints();
597 c.gridx = 4; c.gridy = row;
599 c.fill = GridBagConstraints.NONE;
600 c.anchor = GridBagConstraints.CENTER;
602 reboot = new JButton("Reboot");
604 reboot.addActionListener(this);
605 reboot.setActionCommand("Reboot");
607 c = new GridBagConstraints();
608 c.gridx = 6; c.gridy = row;
610 c.fill = GridBagConstraints.NONE;
611 c.anchor = GridBagConstraints.LINE_END;
613 close = new JButton("Close");
615 close.addActionListener(this);
616 close.setActionCommand("Close");
618 addWindowListener(new ConfigListener(this));
621 /* Once the initial values are set, the config code will show the dialog */
622 public void make_visible() {
624 setLocationRelativeTo(owner);
628 /* If any values have been changed, confirm before closing */
629 public boolean check_dirty(String operation) {
631 Object[] options = { String.format("%s anyway", operation), "Keep editing" };
633 i = JOptionPane.showOptionDialog(this,
634 String.format("Configuration modified. %s anyway?", operation),
635 "Configuration Modified",
636 JOptionPane.DEFAULT_OPTION,
637 JOptionPane.WARNING_MESSAGE,
638 null, options, options[1]);
647 save.setEnabled(true);
650 public void set_clean() {
652 save.setEnabled(false);
655 AltosConfigPyroUI pyro_ui;
657 /* Listen for events from our buttons */
658 public void actionPerformed(ActionEvent e) {
659 String cmd = e.getActionCommand();
661 if (cmd.equals("Pyro")) {
662 if (pyro_ui == null && pyros != null) {
663 pyro_ui = new AltosConfigPyroUI(this, pyros);
664 pyro_ui.make_visible();
669 if (cmd.equals("Close") || cmd.equals("Reboot"))
670 if (!check_dirty(cmd))
672 listener.actionPerformed(e);
673 if (cmd.equals("Close") || cmd.equals("Reboot")) {
680 /* ItemListener interface method */
681 public void itemStateChanged(ItemEvent e) {
685 /* DocumentListener interface methods */
686 public void changedUpdate(DocumentEvent e) {
690 public void insertUpdate(DocumentEvent e) {
694 public void removeUpdate(DocumentEvent e) {
698 /* Let the config code hook on a listener */
699 public void addActionListener(ActionListener l) {
703 /* set and get all of the dialog values */
704 public void set_product(String product) {
705 radio_frequency_value.set_product(product);
706 product_value.setText(product);
707 set_pad_orientation_tool_tip();
708 set_flight_log_max_tool_tip();
711 public void set_version(String version) {
712 version_value.setText(version);
715 public void set_serial(int serial) {
716 radio_frequency_value.set_serial(serial);
717 serial_value.setText(String.format("%d", serial));
720 public void set_main_deploy(int new_main_deploy) {
721 main_deploy_value.setSelectedItem(Integer.toString(new_main_deploy));
724 public int main_deploy() {
725 return Integer.parseInt(main_deploy_value.getSelectedItem().toString());
728 public void set_apogee_delay(int new_apogee_delay) {
729 apogee_delay_value.setSelectedItem(Integer.toString(new_apogee_delay));
730 apogee_delay_value.setEnabled(new_apogee_delay >= 0);
733 public int apogee_delay() {
734 return Integer.parseInt(apogee_delay_value.getSelectedItem().toString());
737 public void set_apogee_lockout(int new_apogee_lockout) {
738 apogee_lockout_value.setSelectedItem(Integer.toString(new_apogee_lockout));
739 apogee_lockout_value.setEnabled(new_apogee_lockout >= 0);
742 public int apogee_lockout() {
743 return Integer.parseInt(apogee_lockout_value.getSelectedItem().toString());
746 public void set_radio_frequency(double new_radio_frequency) {
748 for (i = 0; i < radio_frequency_value.getItemCount(); i++) {
749 AltosFrequency f = (AltosFrequency) radio_frequency_value.getItemAt(i);
751 if (f.close(new_radio_frequency)) {
752 radio_frequency_value.setSelectedIndex(i);
756 for (i = 0; i < radio_frequency_value.getItemCount(); i++) {
757 AltosFrequency f = (AltosFrequency) radio_frequency_value.getItemAt(i);
759 if (new_radio_frequency < f.frequency)
762 String description = String.format("%s serial %s",
763 product_value.getText(),
764 serial_value.getText());
765 AltosFrequency new_frequency = new AltosFrequency(new_radio_frequency, description);
766 AltosUIPreferences.add_common_frequency(new_frequency);
767 radio_frequency_value.insertItemAt(new_frequency, i);
768 radio_frequency_value.setSelectedIndex(i);
771 public double radio_frequency() {
772 return radio_frequency_value.frequency();
775 public void set_radio_calibration(int new_radio_calibration) {
776 radio_calibration_value.setText(String.format("%d", new_radio_calibration));
779 public int radio_calibration() {
780 return Integer.parseInt(radio_calibration_value.getText());
783 public void set_radio_enable(int new_radio_enable) {
784 if (new_radio_enable >= 0) {
785 radio_enable_value.setSelected(new_radio_enable > 0);
786 radio_enable_value.setEnabled(true);
788 radio_enable_value.setSelected(true);
789 radio_enable_value.setEnabled(false);
791 set_radio_enable_tool_tip();
794 public int radio_enable() {
795 if (radio_enable_value.isEnabled())
796 return radio_enable_value.isSelected() ? 1 : 0;
801 public void set_callsign(String new_callsign) {
802 callsign_value.setText(new_callsign);
805 public String callsign() {
806 return callsign_value.getText();
809 public void set_flight_log_max(int new_flight_log_max) {
810 flight_log_max_value.setEnabled(new_flight_log_max > 0);
811 flight_log_max_value.setSelectedItem(Integer.toString(new_flight_log_max));
812 set_flight_log_max_tool_tip();
815 public void set_flight_log_max_enabled(boolean enable) {
816 flight_log_max_value.setEnabled(enable);
817 set_flight_log_max_tool_tip();
820 public int flight_log_max() {
821 return Integer.parseInt(flight_log_max_value.getSelectedItem().toString());
824 public void set_flight_log_max_limit(int flight_log_max_limit) {
825 //boolean any_added = false;
826 flight_log_max_value.removeAllItems();
827 for (int i = 0; i < flight_log_max_values.length; i++) {
828 if (Integer.parseInt(flight_log_max_values[i]) < flight_log_max_limit){
829 flight_log_max_value.addItem(flight_log_max_values[i]);
833 flight_log_max_value.addItem(String.format("%d", flight_log_max_limit));
836 public void set_ignite_mode(int new_ignite_mode) {
837 if (new_ignite_mode >= ignite_mode_values.length)
839 if (new_ignite_mode < 0) {
840 ignite_mode_value.setEnabled(false);
843 ignite_mode_value.setEnabled(true);
845 ignite_mode_value.setSelectedIndex(new_ignite_mode);
846 set_ignite_mode_tool_tip();
849 public int ignite_mode() {
850 if (ignite_mode_value.isEnabled())
851 return ignite_mode_value.getSelectedIndex();
857 public void set_pad_orientation(int new_pad_orientation) {
858 if (new_pad_orientation >= pad_orientation_values.length)
859 new_pad_orientation = 0;
860 if (new_pad_orientation < 0) {
861 pad_orientation_value.setEnabled(false);
862 new_pad_orientation = 0;
864 pad_orientation_value.setEnabled(true);
866 pad_orientation_value.setSelectedIndex(new_pad_orientation);
867 set_pad_orientation_tool_tip();
870 public int pad_orientation() {
871 if (pad_orientation_value.isEnabled())
872 return pad_orientation_value.getSelectedIndex();
877 public void set_pyros(AltosPyro[] new_pyros) {
879 pyro.setEnabled(pyros != null);
880 if (pyros != null && pyro_ui != null)
881 pyro_ui.set_pyros(pyros);
884 public AltosPyro[] pyros() {
886 pyros = pyro_ui.get_pyros();
890 public void set_aprs_interval(int new_aprs_interval) {
893 if (new_aprs_interval <= 0)
896 s = Integer.toString(new_aprs_interval);
897 aprs_interval_value.setSelectedItem(s);
898 aprs_interval_value.setEnabled(new_aprs_interval >= 0);
899 set_aprs_interval_tool_tip();
902 public int aprs_interval() {
903 String s = aprs_interval_value.getSelectedItem().toString();
905 if (s.equals("Disabled"))
907 return Integer.parseInt(s);