Exemple #1
0
  public Entity[] waitsetTimedWait(Waitset waitset, Time time) throws CommunicationException {
    Entity[] result = null;
    this.checkConnection();

    try {
      String xmlWaitset = entitySerializer.serializeEntity(waitset);
      String xmlEntities = this.jniWaitsetTimedWait(xmlWaitset, time.sec, time.nsec);
      this.checkConnection();

      Entity[] entityResult = entityDeserializer.deserializeEntityList(xmlEntities);

      if (entityResult != null) {
        result = new Entity[entityResult.length];

        for (int i = 0; i < entityResult.length; i++) {
          result[i] = entityResult[i];
        }
      } else {
        throw new CommunicationException("waitsetTimedWait failed (2)");
      }
    } catch (TransformationException e) {
      throw new CommunicationException("waitsetTimedWait failed");
    }
    return result;
  }
Exemple #2
0
  public Topic[] participantFindTopic(Participant participant, String topicName)
      throws CommunicationException {
    Topic[] result = null;
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(participant);
      String xmlEntities = this.jniParticipantFindTopic(xmlEntity, topicName);
      this.checkConnection();
      Entity[] entityResult = entityDeserializer.deserializeEntityList(xmlEntities);

      if (entityResult != null) {
        result = new Topic[entityResult.length];

        for (int i = 0; i < entityResult.length; i++) {
          result[i] = (Topic) (entityResult[i]);
        }
      } else {
        throw new CommunicationException("Could not find topic.");
      }
    } catch (TransformationException e) {
      throw new CommunicationException("Could not find topic.");
    }
    return result;
  }
Exemple #3
0
  public void waitsetDetach(Waitset waitset, Entity entity) throws CommunicationException {
    this.checkConnection();

    try {
      String xmlWaitset = entitySerializer.serializeEntity(waitset);
      String xmlEntity = entitySerializer.serializeEntity(entity);
      String result = this.jniWaitsetDetach(xmlWaitset, xmlEntity);
      this.checkConnection();

      if (!("<result>OK</result>".equals(result))) {
        throw new CommunicationException(result.substring(8, result.length() - 9));
      }
    } catch (TransformationException e) {
      throw new CommunicationException("Could not detach Entity from Waitset.");
    }
    return;
  }
Exemple #4
0
  public Writer writerNew(Publisher p, String name, Topic t, WriterQoS qos)
      throws CommunicationException {
    Writer wri;
    String xmlQos = null;
    this.checkConnection();

    try {
      if (qos != null) {
        xmlQos = qosSerializer.serializeQoS(qos);
      }
      String xmlEntity = entitySerializer.serializeEntity(p);
      String xmlTopic = entitySerializer.serializeEntity(t);
      String xmlResult = this.jniCreateWriter(xmlEntity, name, xmlTopic, xmlQos);
      this.checkConnection();
      wri = (Writer) (entityDeserializer.deserializeEntity(xmlResult));
    } catch (TransformationException e) {
      throw new CommunicationException("Could not create writer.");
    }
    return wri;
  }
Exemple #5
0
  public void entityFree(Entity entity) throws CommunicationException {
    String xmlEntity;
    this.checkConnection();

    try {
      xmlEntity = entitySerializer.serializeEntity(entity);
    } catch (TransformationException e) {
      throw new CommunicationException(e.getMessage());
    }
    this.jniEntityFree(xmlEntity);
    this.checkConnection();
  }
Exemple #6
0
  public Partition partitionNew(Participant p, String name) throws CommunicationException {
    Partition dom;
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(p);
      String xmlDom = this.jniDomainNew(xmlEntity, name);
      this.checkConnection();
      dom = (Partition) (entityDeserializer.deserializeEntity(xmlDom));
    } catch (TransformationException e) {
      throw new CommunicationException("Could not create partition.");
    }
    return dom;
  }
Exemple #7
0
  public ReaderSnapshot readerSnapshotNew(Reader reader) throws CommunicationException {
    ReaderSnapshot rs = null;
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(reader);
      String xmlSnapshot = this.jniReaderSnapshotNew(xmlEntity);
      this.checkConnection();
      rs = snapshotDeserializer.deserializeReaderSnapshot(xmlSnapshot, reader);
    } catch (TransformationException e) {
      throw new CommunicationException("Could not create a snapshot of the supplied reader.");
    }
    return rs;
  }
Exemple #8
0
  public Status entityGetStatus(Entity entity) throws CommunicationException {
    Status status;
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(entity);
      String xmlStatus = this.jniEntityStatus(xmlEntity);
      this.checkConnection();
      status = statusDeserializer.deserializeStatus(xmlStatus);
    } catch (TransformationException e) {
      throw new CommunicationException("Could not resolve entity status.");
    }
    return status;
  }
Exemple #9
0
  public ServiceState serviceGetState(Service service) throws CommunicationException {
    ServiceState state;
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(service);
      String xmlState = this.jniGetServiceState(xmlEntity);
      this.checkConnection();
      state = (ServiceState) (entityDeserializer.deserializeEntity(xmlState));
    } catch (TransformationException e) {
      throw new CommunicationException("Could not resolve service state.");
    }
    return state;
  }
Exemple #10
0
  public int waitsetGetEventMask(Waitset waitset) throws CommunicationException {
    int result = Event.UNDEFINED;
    this.checkConnection();

    try {
      String xmlWaitset = entitySerializer.serializeEntity(waitset);
      result = this.jniWaitsetGetEventMask(xmlWaitset);
      this.checkConnection();

    } catch (TransformationException e) {
      throw new CommunicationException("Could not attach Entity to Waitset.");
    }
    return result;
  }
Exemple #11
0
  public QoS entityGetQoS(Entity entity) throws CommunicationException {
    QoS result;
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(entity);
      String xmlQoS = this.jniEntityQoS(xmlEntity);
      this.checkConnection();
      result = qosDeserializer.deserializeQoS(xmlQoS);
    } catch (TransformationException e) {
      throw new CommunicationException("Could not resolve qos.");
    }
    return result;
  }
Exemple #12
0
  public void subscriberSubscribe(Subscriber s, String expression) throws CommunicationException {
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(s);
      String xmlResult = this.jniSubscriberSubscribe(xmlEntity, expression);
      this.checkConnection();

      if (!("<result>OK</result>".equals(xmlResult))) {
        throw new CommunicationException("Subscription failed.");
      }
    } catch (TransformationException e) {
      throw new CommunicationException("Subscription failed.");
    }
  }
Exemple #13
0
  public void publisherPublish(Publisher p, String expression) throws CommunicationException {
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(p);
      String xmlResult = this.jniPublisherPublish(xmlEntity, expression);
      this.checkConnection();

      if (!("<result>OK</result>".equals(xmlResult))) {
        throw new CommunicationException("Publication failed.");
      }
    } catch (TransformationException e) {
      throw new CommunicationException("Publication failed");
    }
  }
Exemple #14
0
  public MetaType writerGetDataType(Writer writer)
      throws CommunicationException, DataTypeUnsupportedException {
    MetaType result = null;
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(writer);
      String xmlType = this.jniWriterDataType(xmlEntity);
      this.checkConnection();
      result = typeDeserializer.deserializeMetaType(xmlType);
    } catch (TransformationException e) {
      throw new CommunicationException("Could not resolve topic data type of writer.");
    }
    return result;
  }
Exemple #15
0
  public void waitsetSetEventMask(Waitset waitset, int mask) throws CommunicationException {
    this.checkConnection();

    try {
      String xmlWaitset = entitySerializer.serializeEntity(waitset);
      String result = this.jniWaitsetSetEventMask(xmlWaitset, mask);
      this.checkConnection();

      if (!("<result>OK</result>".equals(result))) {
        throw new CommunicationException(result.substring(8, result.length() - 9));
      }
    } catch (TransformationException e) {
      throw new CommunicationException("Could not attach Entity to Waitset.");
    }
  }
Exemple #16
0
  public Entity[] entityDependantEntities(Entity entity, EntityFilter filter)
      throws CommunicationException {
    Entity[] result = null;
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(entity);
      String xmlEntities = this.jniGetDependantEntities(xmlEntity, EntityFilter.getString(filter));
      this.checkConnection();
      result = entityDeserializer.deserializeEntityList(xmlEntities);
    } catch (TransformationException e) {
      throw new CommunicationException("Could not resolve dependant entities.");
    }
    return result;
  }
Exemple #17
0
  public void entityEnable(Entity entity) throws CommunicationException {
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(entity);
      String result = this.jniEntityEnable(xmlEntity);
      this.checkConnection();

      if (!("<result>OK</result>".equals(result))) {
        throw new CommunicationException(result.substring(8, result.length() - 9));
      }
    } catch (TransformationException e) {
      throw new CommunicationException("Could not enable entity.");
    }
  }
Exemple #18
0
  public Waitset waitsetNew(Participant participant) throws CommunicationException {
    Waitset waitset = null;

    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(participant);
      String xmlWaitset = this.jniWaitsetNew(xmlEntity);
      this.checkConnection();
      waitset = (Waitset) (entityDeserializer.deserializeEntity(xmlWaitset));
    } catch (TransformationException e) {
      throw new CommunicationException("Could not create waitset.");
    }
    return waitset;
  }
Exemple #19
0
  public void entityResetStatistics(Entity entity, String fieldName) throws CommunicationException {
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(entity);
      String result = this.jniEntityResetStatistics(xmlEntity, fieldName);
      this.checkConnection();

      if (!("<result>OK</result>".equals(result))) {
        throw new CommunicationException(result.substring(8, result.length() - 9));
      }
    } catch (TransformationException e) {
      throw new CommunicationException("Could not reset statistics.");
    }
  }
Exemple #20
0
  public Query queryNew(Reader source, String name, String expression)
      throws CommunicationException {
    Query q;
    this.checkConnection();

    try {
      String xmlRea = entitySerializer.serializeEntity(source);
      String xmlResult = this.jniQueryNew(xmlRea, name, expression);
      this.checkConnection();
      q = (Query) (entityDeserializer.deserializeEntity(xmlResult));
    } catch (TransformationException e) {
      throw new CommunicationException("Could not create query.");
    }
    return q;
  }
Exemple #21
0
  public void writerUnregister(Writer writer, UserData data) throws CommunicationException {
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(writer);
      String xmlData = userDataSerializer.serializeUserData(data);
      String success = this.jniWriterUnregister(xmlEntity, xmlData);
      this.checkConnection();

      if (!("<result>OK</result>".equals(success))) {
        throw new CommunicationException("Unregister failed.");
      }
    } catch (TransformationException e) {
      throw new CommunicationException("Could not unregister instance with suppplied writer.");
    }
  }
Exemple #22
0
  public void entitySetQoS(Entity entity, QoS qos) throws CommunicationException {
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(entity);
      String xmlQoS = qosSerializer.serializeQoS(qos);
      String result = this.jniEntitySetQoS(xmlEntity, xmlQoS);
      this.checkConnection();

      if (!("<result>OK</result>".equals(result))) {
        throw new CommunicationException(result.substring(8, result.length() - 9));
      }
    } catch (TransformationException e) {
      throw new CommunicationException("Applying new qos failed.");
    }
  }
Exemple #23
0
  public Statistics entityGetStatistics(Entity entity) throws CommunicationException {
    Statistics statistics = null;
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(entity);
      String result = this.jniEntityGetStatistics(xmlEntity);
      this.checkConnection();

      if (result != null) {
        statistics = statisticsDeserializer.deserializeStatistics(result, entity);
      }
    } catch (TransformationException e) {
      throw new CommunicationException("Could not reset statistics.");
    }
    return statistics;
  }
Exemple #24
0
  public void participantRegisterType(Participant participant, MetaType type)
      throws CommunicationException {
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(participant);
      String xmlType = type.toXML();
      String result = this.jniRegisterType(xmlEntity, xmlType);
      this.checkConnection();

      if (!("<result>OK</result>".equals(result))) {
        throw new CommunicationException(result.substring(8, result.length() - 9));
      }
    } catch (TransformationException e) {
      throw new CommunicationException("Could not register type.");
    }
  }
Exemple #25
0
  public Sample readerTake(Reader reader)
      throws CommunicationException, DataTypeUnsupportedException {
    Sample result = null;
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(reader);
      String xmlSample = this.jniReaderTake(xmlEntity);
      this.checkConnection();
      result = untypedSampleDeserializer.deserializeSample(xmlSample, reader.getDataType());
    } catch (CMException e) {
      throw new CommunicationException(e.getMessage());
    } catch (TransformationException e) {
      throw new CommunicationException("Could not take sample.");
    }
    return result;
  }
Exemple #26
0
  public void dataReaderWaitForHistoricalData(DataReader d, Time time)
      throws CommunicationException {
    this.checkConnection();

    try {
      String xmlDataReader = entitySerializer.serializeEntity(d);
      String result = this.jniDataReaderWaitForHistoricalData(xmlDataReader, time.sec, time.nsec);
      this.checkConnection();

      if (!("<result>OK</result>".equals(result))) {
        throw new CommunicationException(
            "Wait for historical data failed: " + result.substring(8, result.length() - 9));
      }
    } catch (TransformationException e) {
      throw new CommunicationException("Could not wait for historical data.");
    }
  }
Exemple #27
0
  public DataReader dataReaderNew(Subscriber s, String name, String viewExpression, ReaderQoS qos)
      throws CommunicationException {
    DataReader dr;
    String xmlQos = null;
    this.checkConnection();

    try {
      if (qos != null) {
        xmlQos = qosSerializer.serializeQoS(qos);
      }
      String xmlSub = entitySerializer.serializeEntity(s);
      String xmlResult = this.jniCreateDataReader(xmlSub, name, viewExpression, xmlQos);
      this.checkConnection();
      dr = (DataReader) (entityDeserializer.deserializeEntity(xmlResult));
    } catch (TransformationException e) {
      throw new CommunicationException("Could not create datareader.");
    }
    return dr;
  }
Exemple #28
0
  public Subscriber subscriberNew(Participant p, String name, SubscriberQoS qos)
      throws CommunicationException {
    Subscriber sub;
    String xmlQos = null;
    this.checkConnection();

    try {
      if (qos != null) {
        xmlQos = qosSerializer.serializeQoS(qos);
      }
      String xmlEntity = entitySerializer.serializeEntity(p);
      String xmlSub = this.jniSubscriberNew(xmlEntity, name, xmlQos);
      this.checkConnection();
      sub = (Subscriber) (entityDeserializer.deserializeEntity(xmlSub));
    } catch (TransformationException e) {
      throw new CommunicationException("Could not create subscriber.");
    }
    return sub;
  }
Exemple #29
0
  public Topic topicNew(Participant p, String name, String typeName, String keyList, TopicQoS qos)
      throws CommunicationException {
    Topic top;
    String xmlQos = null;
    this.checkConnection();

    try {
      if (qos != null) {
        xmlQos = qosSerializer.serializeQoS(qos);
      }
      String xmlEntity = entitySerializer.serializeEntity(p);
      String xmlTop = this.jniTopicNew(xmlEntity, name, typeName, keyList, xmlQos);
      this.checkConnection();
      top = (Topic) (entityDeserializer.deserializeEntity(xmlTop));
    } catch (TransformationException e) {
      throw new CommunicationException("Could not create topic.");
    }
    return top;
  }
Exemple #30
0
  public Sample readerReadNext(Reader reader, GID instanceGID)
      throws CommunicationException, DataTypeUnsupportedException {
    Sample result = null;
    this.checkConnection();

    try {
      String xmlEntity = entitySerializer.serializeEntity(reader);
      String xmlSample =
          this.jniReaderReadNext(
              xmlEntity,
              Long.toString(instanceGID.getLocalId()),
              Long.toString(instanceGID.getSystemId()));
      this.checkConnection();
      result = untypedSampleDeserializer.deserializeSample(xmlSample, reader.getDataType());
    } catch (CMException e) {
      throw new CommunicationException(e.getMessage());
    } catch (TransformationException e) {
      throw new CommunicationException("Could not read next sample.");
    }
    return result;
  }