Esempio n. 1
0
  /*
   * (non-Javadoc)
   *
   * @see java.lang.Object#equals(java.lang.Object)
   */
  @Override
  public boolean equals(Object obj) {

    // quick checks first.

    // object handle identity
    if (this == obj) return true;

    // if it's null, it's not the same as anything
    // (and we can't compare its fields without a null pointer exception)
    if (obj == null) return false;

    // if it's some different class, well then something is bad.
    if (getClass() != obj.getClass()) return false;

    // ok so it's the same class. in that case, let's make a reference...
    PixelPusher other = (PixelPusher) obj;

    // if it differs by less than half a msec, it has no effect on our timing
    if (Math.abs(getUpdatePeriod() - other.getUpdatePeriod()) > 500) return false;

    // some fudging to cope with the fact that pushers don't know they have RGBOW
    if (this.hasRGBOW() & !other.hasRGBOW()) {
      if (getPixelsPerStrip() != other.getPixelsPerStrip() / 3) return false;
    }
    if (!this.hasRGBOW() & other.hasRGBOW()) {
      if (getPixelsPerStrip() / 3 != other.getPixelsPerStrip()) return false;
    }
    if (!(this.hasRGBOW() || other.hasRGBOW()))
      if (getPixelsPerStrip() != other.getPixelsPerStrip()) return false;
    if (getNumberOfStrips() != other.getNumberOfStrips()) return false;

    // handle the case where someone changed the config during library runtime
    if (this.artnet_channel != other.artnet_channel
        || this.artnet_universe != other.artnet_universe) return false;

    // if the port's been changed, we need to update
    if (this.my_port != other.my_port) return false;

    // we should update every time the power total changes significantly
    if (Math.abs(this.powerTotal - other.powerTotal) > 10000) return false;

    // handle the case where our power domain changed
    if (this.powerDomain != other.powerDomain) return false;

    // ditto for number of segments and pusherFlags
    if (this.segments != other.segments) return false;

    if (this.getPusherFlags() != other.getPusherFlags()) return false;

    // if all those other things are the same, then we call it good.
    return true;
  }