Esempio n. 1
0
  public IBitFieldDMData readBitField(Object element) {
    /*
     * Get the DMC and the session. If element is not an register DMC, or
     * session is stale, then bail out.
     */
    IBitFieldDMContext dmc = getBitFieldDMC(element);
    if (dmc == null) return null;
    DsfSession session = DsfSession.getSession(dmc.getSessionId());
    if (session == null) return null;

    /*
     * Create the query to request the value from service. Note: no need to
     * guard agains RejectedExecutionException, because
     * DsfSession.getSession() above would only return an active session.
     */
    GetBitFieldValueQuery query = new GetBitFieldValueQuery(dmc);
    session.getExecutor().execute(query);

    /*
     * Now we have the data, go and get it. Since the call is completed now
     * the ".get()" will not suspend it will immediately return with the
     * data.
     */
    try {
      return query.get();
    } catch (InterruptedException e) {
      assert false;
      return null;
    } catch (ExecutionException e) {
      return null;
    }
  }
Esempio n. 2
0
  public void writeBitField(Object element, String value, String formatId) {

    /*
     * Get the DMC and the session. If element is not an register DMC, or
     * session is stale, then bail out.
     */
    IBitFieldDMContext dmc = getBitFieldDMC(element);
    if (dmc == null) return;
    DsfSession session = DsfSession.getSession(dmc.getSessionId());
    if (session == null) return;

    /*
     * Create the query to write the value to the service. Note: no need to
     * guard agains RejectedExecutionException, because
     * DsfSession.getSession() above would only return an active session.
     */
    SetBitFieldValueQuery query = new SetBitFieldValueQuery(dmc, value, formatId);
    session.getExecutor().execute(query);

    /*
     * Now we have the data, go and get it. Since the call is completed now
     * the ".get()" will not suspend it will immediately return with the
     * data.
     */
    try {
      /*
       * Return value is irrelevant, any error would come through with an
       * exception.
       */
      query.get();
    } catch (InterruptedException e) {
      assert false;
    } catch (ExecutionException e) {
      assert false;
      /*
       * View must be shutting down, no need to show erro dialog.
       */
    }
  }
Esempio n. 3
0
  public IBitFieldDMData getBitFieldDMData(Object element) {
    IBitFieldDMContext dmc = null;
    if (element instanceof IDMVMContext) {
      dmc =
          DMContexts.getAncestorOfType(
              ((IDMVMContext) element).getDMContext(), IBitFieldDMContext.class);
    }

    if (dmc != null) {
      DsfSession session = DsfSession.getSession(dmc.getSessionId());

      if (session != null) {
        GetBitFieldQuery query = new GetBitFieldQuery(dmc);
        session.getExecutor().execute(query);

        try {
          return query.get();
        } catch (InterruptedException e) {
        } catch (ExecutionException e) {
        }
      }
    }
    return null;
  }