예제 #1
0
    /** Register SVT histogram callback */
    protected void setHistoCallback(boolean setCallback) {
      TipcCb pHist = null;
      String dest = AppConstants.HISTO_SUBJECT;
      try {
        if (setCallback) {
          if (!srv.getSubjectSubscribe(dest)) {
            ProcessHistMessage evRef = new ProcessHistMessage();
            pHist = srv.addProcessCb(evRef, dest, srv);
            if (pHist == null) {
              Tut.exitFailure("WARNING. Couldn't register Histogram subject callback!\n");
            }
            srv.setSubjectSubscribe(dest, true);
            warn("INFO. Subscribed to  " + dest, Color.green);

            addObserver(histoObserver);
          }
        } else {
          if (srv.getSubjectSubscribe(dest)) {
            srv.setSubjectSubscribe(dest, false);
            warn("INFO. Unsubscribed from  " + dest, Color.red);

            deleteObserver(histoObserver);
          }
        }
      } catch (TipcException Tipe) {
        Tut.warning(Tipe);
      }
    }
예제 #2
0
      /**
       * Process SVT Histogram related messages when the callback is triggered
       *
       * @param msg Reference to the SmartSockets message
       * @param obj User specified object that might be passed to the callback
       */
      public void process(TipcMsg msg, Object arg) {
        if (isDebugOn()) warn("Histogram messages published", Color.green);
        try {
          msg.setCurrent(0); // position the field ptr to the beginning of the message
          int run = msg.nextInt4();
          int time = msg.nextInt4();
          int nhist = msg.nextMsgArray().length; // Find how many histograms are published
          if (isDebugOn()) warn("# of histograms published: " + nhist, Color.blue);
          if (nhist > 0) {
            if (histoData == null) histoData = new SvtHistogramColl();
            histoData.fillHistogramData(msg);
          }
        } catch (TipcException e) {
          Tut.warning(e);
        }

        setChanged();
        notifyObservers(histoData);
      }