+
+ public AltosMag() {
+ along = AltosLib.MISSING;
+ across = AltosLib.MISSING;
+ through = AltosLib.MISSING;
+ }
+
+ public AltosMag(int along, int across, int through) {
+ this.along = along;
+ this.across = across;
+ this.through = through;
+ }
+
+ static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException {
+ try {
+ AltosMag mag = new AltosMag(link);
+
+ if (mag != null)
+ state.set_mag(mag);
+ } catch (TimeoutException te) {
+ }
+ }
+
+ public AltosMag(AltosLink link) throws InterruptedException, TimeoutException {
+ this();
+ link.printf("M\n");
+ for (;;) {
+ String line = link.get_reply_no_dialog(5000);
+ if (line == null) {
+ throw new TimeoutException();
+ }
+ if (parse_string(line))
+ break;
+ }
+ }
+
+ public AltosHashSet hashSet() {
+ AltosHashSet h = new AltosHashSet();
+
+ h.putInt("along", along);
+ h.putInt("across", across);
+ h.putInt("through", through);
+ return h;
+ }
+
+ public AltosJson json() {
+ AltosJson j = new AltosJson();
+
+ j.put("along", along);
+ j.put("across", across);
+ j.put("through", through);
+ return j;
+ }
+
+ public AltosMag(AltosHashSet h) {
+ this();
+
+ along = h.getInt("along", along);
+ across = h.getInt("across", across);
+ through = h.getInt("through", through);
+ }
+
+ public static AltosMag fromHashSet(AltosHashSet h, AltosMag def) {
+ if (h == null)
+ return def;
+
+ return new AltosMag(h);
+ }
+
+ public AltosMag(AltosJson j) {
+ this();
+
+ along = j.get_int("along", along);
+ across = j.get_int("across", across);
+ through = j.get_int("through", through);
+ }
+
+ public static AltosMag fromJson(AltosJson j, AltosMag def) {
+ if (j == null)
+ return def;
+
+ return new AltosMag(j);
+ }