001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004// Code generated by protocol buffer compiler. Do not edit!
005package org.wpilib.math.proto;
006
007import java.io.IOException;
008import us.hebi.quickbuf.Descriptors;
009import us.hebi.quickbuf.FieldName;
010import us.hebi.quickbuf.InvalidProtocolBufferException;
011import us.hebi.quickbuf.JsonSink;
012import us.hebi.quickbuf.JsonSource;
013import us.hebi.quickbuf.MessageFactory;
014import us.hebi.quickbuf.ProtoMessage;
015import us.hebi.quickbuf.ProtoSink;
016import us.hebi.quickbuf.ProtoSource;
017import us.hebi.quickbuf.ProtoUtil;
018
019/**
020 * Protobuf type {@code ProtobufDCMotor}
021 */
022@SuppressWarnings("hiding")
023public final class ProtobufDCMotor extends ProtoMessage<ProtobufDCMotor> implements Cloneable {
024  private static final long serialVersionUID = 0L;
025
026  /**
027   * <code>optional double nominal_voltage = 1;</code>
028   */
029  private double nominalVoltage;
030
031  /**
032   * <code>optional double stall_torque = 2;</code>
033   */
034  private double stallTorque;
035
036  /**
037   * <code>optional double stall_current = 3;</code>
038   */
039  private double stallCurrent;
040
041  /**
042   * <code>optional double free_current = 4;</code>
043   */
044  private double freeCurrent;
045
046  /**
047   * <code>optional double free_speed = 5;</code>
048   */
049  private double freeSpeed;
050
051  private ProtobufDCMotor() {
052  }
053
054  /**
055   * @return a new empty instance of {@code ProtobufDCMotor}
056   */
057  public static ProtobufDCMotor newInstance() {
058    return new ProtobufDCMotor();
059  }
060
061  /**
062   * <code>optional double nominal_voltage = 1;</code>
063   * @return whether the nominalVoltage field is set
064   */
065  public boolean hasNominalVoltage() {
066    return (bitField0_ & 0x00000001) != 0;
067  }
068
069  /**
070   * <code>optional double nominal_voltage = 1;</code>
071   * @return this
072   */
073  public ProtobufDCMotor clearNominalVoltage() {
074    bitField0_ &= ~0x00000001;
075    nominalVoltage = 0D;
076    return this;
077  }
078
079  /**
080   * <code>optional double nominal_voltage = 1;</code>
081   * @return the nominalVoltage
082   */
083  public double getNominalVoltage() {
084    return nominalVoltage;
085  }
086
087  /**
088   * <code>optional double nominal_voltage = 1;</code>
089   * @param value the nominalVoltage to set
090   * @return this
091   */
092  public ProtobufDCMotor setNominalVoltage(final double value) {
093    bitField0_ |= 0x00000001;
094    nominalVoltage = value;
095    return this;
096  }
097
098  /**
099   * <code>optional double stall_torque = 2;</code>
100   * @return whether the stallTorque field is set
101   */
102  public boolean hasStallTorque() {
103    return (bitField0_ & 0x00000002) != 0;
104  }
105
106  /**
107   * <code>optional double stall_torque = 2;</code>
108   * @return this
109   */
110  public ProtobufDCMotor clearStallTorque() {
111    bitField0_ &= ~0x00000002;
112    stallTorque = 0D;
113    return this;
114  }
115
116  /**
117   * <code>optional double stall_torque = 2;</code>
118   * @return the stallTorque
119   */
120  public double getStallTorque() {
121    return stallTorque;
122  }
123
124  /**
125   * <code>optional double stall_torque = 2;</code>
126   * @param value the stallTorque to set
127   * @return this
128   */
129  public ProtobufDCMotor setStallTorque(final double value) {
130    bitField0_ |= 0x00000002;
131    stallTorque = value;
132    return this;
133  }
134
135  /**
136   * <code>optional double stall_current = 3;</code>
137   * @return whether the stallCurrent field is set
138   */
139  public boolean hasStallCurrent() {
140    return (bitField0_ & 0x00000004) != 0;
141  }
142
143  /**
144   * <code>optional double stall_current = 3;</code>
145   * @return this
146   */
147  public ProtobufDCMotor clearStallCurrent() {
148    bitField0_ &= ~0x00000004;
149    stallCurrent = 0D;
150    return this;
151  }
152
153  /**
154   * <code>optional double stall_current = 3;</code>
155   * @return the stallCurrent
156   */
157  public double getStallCurrent() {
158    return stallCurrent;
159  }
160
161  /**
162   * <code>optional double stall_current = 3;</code>
163   * @param value the stallCurrent to set
164   * @return this
165   */
166  public ProtobufDCMotor setStallCurrent(final double value) {
167    bitField0_ |= 0x00000004;
168    stallCurrent = value;
169    return this;
170  }
171
172  /**
173   * <code>optional double free_current = 4;</code>
174   * @return whether the freeCurrent field is set
175   */
176  public boolean hasFreeCurrent() {
177    return (bitField0_ & 0x00000008) != 0;
178  }
179
180  /**
181   * <code>optional double free_current = 4;</code>
182   * @return this
183   */
184  public ProtobufDCMotor clearFreeCurrent() {
185    bitField0_ &= ~0x00000008;
186    freeCurrent = 0D;
187    return this;
188  }
189
190  /**
191   * <code>optional double free_current = 4;</code>
192   * @return the freeCurrent
193   */
194  public double getFreeCurrent() {
195    return freeCurrent;
196  }
197
198  /**
199   * <code>optional double free_current = 4;</code>
200   * @param value the freeCurrent to set
201   * @return this
202   */
203  public ProtobufDCMotor setFreeCurrent(final double value) {
204    bitField0_ |= 0x00000008;
205    freeCurrent = value;
206    return this;
207  }
208
209  /**
210   * <code>optional double free_speed = 5;</code>
211   * @return whether the freeSpeed field is set
212   */
213  public boolean hasFreeSpeed() {
214    return (bitField0_ & 0x00000010) != 0;
215  }
216
217  /**
218   * <code>optional double free_speed = 5;</code>
219   * @return this
220   */
221  public ProtobufDCMotor clearFreeSpeed() {
222    bitField0_ &= ~0x00000010;
223    freeSpeed = 0D;
224    return this;
225  }
226
227  /**
228   * <code>optional double free_speed = 5;</code>
229   * @return the freeSpeed
230   */
231  public double getFreeSpeed() {
232    return freeSpeed;
233  }
234
235  /**
236   * <code>optional double free_speed = 5;</code>
237   * @param value the freeSpeed to set
238   * @return this
239   */
240  public ProtobufDCMotor setFreeSpeed(final double value) {
241    bitField0_ |= 0x00000010;
242    freeSpeed = value;
243    return this;
244  }
245
246  @Override
247  public ProtobufDCMotor copyFrom(final ProtobufDCMotor other) {
248    cachedSize = other.cachedSize;
249    if ((bitField0_ | other.bitField0_) != 0) {
250      bitField0_ = other.bitField0_;
251      nominalVoltage = other.nominalVoltage;
252      stallTorque = other.stallTorque;
253      stallCurrent = other.stallCurrent;
254      freeCurrent = other.freeCurrent;
255      freeSpeed = other.freeSpeed;
256    }
257    return this;
258  }
259
260  @Override
261  public ProtobufDCMotor mergeFrom(final ProtobufDCMotor other) {
262    if (other.isEmpty()) {
263      return this;
264    }
265    cachedSize = -1;
266    if (other.hasNominalVoltage()) {
267      setNominalVoltage(other.nominalVoltage);
268    }
269    if (other.hasStallTorque()) {
270      setStallTorque(other.stallTorque);
271    }
272    if (other.hasStallCurrent()) {
273      setStallCurrent(other.stallCurrent);
274    }
275    if (other.hasFreeCurrent()) {
276      setFreeCurrent(other.freeCurrent);
277    }
278    if (other.hasFreeSpeed()) {
279      setFreeSpeed(other.freeSpeed);
280    }
281    return this;
282  }
283
284  @Override
285  public ProtobufDCMotor clear() {
286    if (isEmpty()) {
287      return this;
288    }
289    cachedSize = -1;
290    bitField0_ = 0;
291    nominalVoltage = 0D;
292    stallTorque = 0D;
293    stallCurrent = 0D;
294    freeCurrent = 0D;
295    freeSpeed = 0D;
296    return this;
297  }
298
299  @Override
300  public ProtobufDCMotor clearQuick() {
301    if (isEmpty()) {
302      return this;
303    }
304    cachedSize = -1;
305    bitField0_ = 0;
306    return this;
307  }
308
309  @Override
310  public boolean equals(Object o) {
311    if (o == this) {
312      return true;
313    }
314    if (!(o instanceof ProtobufDCMotor)) {
315      return false;
316    }
317    ProtobufDCMotor other = (ProtobufDCMotor) o;
318    return bitField0_ == other.bitField0_
319      && (!hasNominalVoltage() || ProtoUtil.isEqual(nominalVoltage, other.nominalVoltage))
320      && (!hasStallTorque() || ProtoUtil.isEqual(stallTorque, other.stallTorque))
321      && (!hasStallCurrent() || ProtoUtil.isEqual(stallCurrent, other.stallCurrent))
322      && (!hasFreeCurrent() || ProtoUtil.isEqual(freeCurrent, other.freeCurrent))
323      && (!hasFreeSpeed() || ProtoUtil.isEqual(freeSpeed, other.freeSpeed));
324  }
325
326  @Override
327  public void writeTo(final ProtoSink output) throws IOException {
328    if ((bitField0_ & 0x00000001) != 0) {
329      output.writeRawByte((byte) 9);
330      output.writeDoubleNoTag(nominalVoltage);
331    }
332    if ((bitField0_ & 0x00000002) != 0) {
333      output.writeRawByte((byte) 17);
334      output.writeDoubleNoTag(stallTorque);
335    }
336    if ((bitField0_ & 0x00000004) != 0) {
337      output.writeRawByte((byte) 25);
338      output.writeDoubleNoTag(stallCurrent);
339    }
340    if ((bitField0_ & 0x00000008) != 0) {
341      output.writeRawByte((byte) 33);
342      output.writeDoubleNoTag(freeCurrent);
343    }
344    if ((bitField0_ & 0x00000010) != 0) {
345      output.writeRawByte((byte) 41);
346      output.writeDoubleNoTag(freeSpeed);
347    }
348  }
349
350  @Override
351  protected int computeSerializedSize() {
352    int size = 0;
353    if ((bitField0_ & 0x00000001) != 0) {
354      size += 9;
355    }
356    if ((bitField0_ & 0x00000002) != 0) {
357      size += 9;
358    }
359    if ((bitField0_ & 0x00000004) != 0) {
360      size += 9;
361    }
362    if ((bitField0_ & 0x00000008) != 0) {
363      size += 9;
364    }
365    if ((bitField0_ & 0x00000010) != 0) {
366      size += 9;
367    }
368    return size;
369  }
370
371  @Override
372  @SuppressWarnings("fallthrough")
373  public ProtobufDCMotor mergeFrom(final ProtoSource input) throws IOException {
374    // Enabled Fall-Through Optimization (QuickBuffers)
375    int tag = input.readTag();
376    while (true) {
377      switch (tag) {
378        case 9: {
379          // nominalVoltage
380          nominalVoltage = input.readDouble();
381          bitField0_ |= 0x00000001;
382          tag = input.readTag();
383          if (tag != 17) {
384            break;
385          }
386        }
387        case 17: {
388          // stallTorque
389          stallTorque = input.readDouble();
390          bitField0_ |= 0x00000002;
391          tag = input.readTag();
392          if (tag != 25) {
393            break;
394          }
395        }
396        case 25: {
397          // stallCurrent
398          stallCurrent = input.readDouble();
399          bitField0_ |= 0x00000004;
400          tag = input.readTag();
401          if (tag != 33) {
402            break;
403          }
404        }
405        case 33: {
406          // freeCurrent
407          freeCurrent = input.readDouble();
408          bitField0_ |= 0x00000008;
409          tag = input.readTag();
410          if (tag != 41) {
411            break;
412          }
413        }
414        case 41: {
415          // freeSpeed
416          freeSpeed = input.readDouble();
417          bitField0_ |= 0x00000010;
418          tag = input.readTag();
419          if (tag != 0) {
420            break;
421          }
422        }
423        case 0: {
424          return this;
425        }
426        default: {
427          if (!input.skipField(tag)) {
428            return this;
429          }
430          tag = input.readTag();
431          break;
432        }
433      }
434    }
435  }
436
437  @Override
438  public void writeTo(final JsonSink output) throws IOException {
439    output.beginObject();
440    if ((bitField0_ & 0x00000001) != 0) {
441      output.writeDouble(FieldNames.nominalVoltage, nominalVoltage);
442    }
443    if ((bitField0_ & 0x00000002) != 0) {
444      output.writeDouble(FieldNames.stallTorque, stallTorque);
445    }
446    if ((bitField0_ & 0x00000004) != 0) {
447      output.writeDouble(FieldNames.stallCurrent, stallCurrent);
448    }
449    if ((bitField0_ & 0x00000008) != 0) {
450      output.writeDouble(FieldNames.freeCurrent, freeCurrent);
451    }
452    if ((bitField0_ & 0x00000010) != 0) {
453      output.writeDouble(FieldNames.freeSpeed, freeSpeed);
454    }
455    output.endObject();
456  }
457
458  @Override
459  public ProtobufDCMotor mergeFrom(final JsonSource input) throws IOException {
460    if (!input.beginObject()) {
461      return this;
462    }
463    while (!input.isAtEnd()) {
464      switch (input.readFieldHash()) {
465        case 1374862050:
466        case 173092603: {
467          if (input.isAtField(FieldNames.nominalVoltage)) {
468            if (!input.trySkipNullValue()) {
469              nominalVoltage = input.readDouble();
470              bitField0_ |= 0x00000001;
471            }
472          } else {
473            input.skipUnknownField();
474          }
475          break;
476        }
477        case 2075810250:
478        case 1238615945: {
479          if (input.isAtField(FieldNames.stallTorque)) {
480            if (!input.trySkipNullValue()) {
481              stallTorque = input.readDouble();
482              bitField0_ |= 0x00000002;
483            }
484          } else {
485            input.skipUnknownField();
486          }
487          break;
488        }
489        case -2105262663:
490        case 2006484954: {
491          if (input.isAtField(FieldNames.stallCurrent)) {
492            if (!input.trySkipNullValue()) {
493              stallCurrent = input.readDouble();
494              bitField0_ |= 0x00000004;
495            }
496          } else {
497            input.skipUnknownField();
498          }
499          break;
500        }
501        case 1024355693:
502        case 240406182: {
503          if (input.isAtField(FieldNames.freeCurrent)) {
504            if (!input.trySkipNullValue()) {
505              freeCurrent = input.readDouble();
506              bitField0_ |= 0x00000008;
507            }
508          } else {
509            input.skipUnknownField();
510          }
511          break;
512        }
513        case -444654277:
514        case -552732492: {
515          if (input.isAtField(FieldNames.freeSpeed)) {
516            if (!input.trySkipNullValue()) {
517              freeSpeed = input.readDouble();
518              bitField0_ |= 0x00000010;
519            }
520          } else {
521            input.skipUnknownField();
522          }
523          break;
524        }
525        default: {
526          input.skipUnknownField();
527          break;
528        }
529      }
530    }
531    input.endObject();
532    return this;
533  }
534
535  @Override
536  public ProtobufDCMotor clone() {
537    return new ProtobufDCMotor().copyFrom(this);
538  }
539
540  @Override
541  public boolean isEmpty() {
542    return ((bitField0_) == 0);
543  }
544
545  public static ProtobufDCMotor parseFrom(final byte[] data) throws InvalidProtocolBufferException {
546    return ProtoMessage.mergeFrom(new ProtobufDCMotor(), data).checkInitialized();
547  }
548
549  public static ProtobufDCMotor parseFrom(final ProtoSource input) throws IOException {
550    return ProtoMessage.mergeFrom(new ProtobufDCMotor(), input).checkInitialized();
551  }
552
553  public static ProtobufDCMotor parseFrom(final JsonSource input) throws IOException {
554    return ProtoMessage.mergeFrom(new ProtobufDCMotor(), input).checkInitialized();
555  }
556
557  /**
558   * @return factory for creating ProtobufDCMotor messages
559   */
560  public static MessageFactory<ProtobufDCMotor> getFactory() {
561    return ProtobufDCMotorFactory.INSTANCE;
562  }
563
564  /**
565   * @return this type's descriptor.
566   */
567  public static Descriptors.Descriptor getDescriptor() {
568    return ProtobufSystemDescriptor.wpi_proto_ProtobufDCMotor_descriptor;
569  }
570
571  private enum ProtobufDCMotorFactory implements MessageFactory<ProtobufDCMotor> {
572    INSTANCE;
573
574    @Override
575    public ProtobufDCMotor create() {
576      return ProtobufDCMotor.newInstance();
577    }
578  }
579
580  /**
581   * Contains name constants used for serializing JSON
582   */
583  static class FieldNames {
584    static final FieldName nominalVoltage = FieldName.forField("nominalVoltage", "nominal_voltage");
585
586    static final FieldName stallTorque = FieldName.forField("stallTorque", "stall_torque");
587
588    static final FieldName stallCurrent = FieldName.forField("stallCurrent", "stall_current");
589
590    static final FieldName freeCurrent = FieldName.forField("freeCurrent", "free_current");
591
592    static final FieldName freeSpeed = FieldName.forField("freeSpeed", "free_speed");
593  }
594}