Пример #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;
  }
Пример #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;
  }
Пример #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;
  }
Пример #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;
  }
Пример #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();
  }
Пример #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;
  }
Пример #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;
  }
Пример #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;
  }
Пример #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;
  }
Пример #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;
  }
Пример #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;
  }
Пример #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.");
    }
  }
Пример #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");
    }
  }
Пример #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;
  }
Пример #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.");
    }
  }
Пример #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;
  }
Пример #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.");
    }
  }
Пример #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;
  }
Пример #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.");
    }
  }
Пример #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;
  }
Пример #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.");
    }
  }
Пример #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.");
    }
  }
Пример #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;
  }
Пример #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.");
    }
  }
Пример #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;
  }
Пример #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.");
    }
  }
Пример #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;
  }
Пример #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;
  }
Пример #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;
  }
Пример #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;
  }