Exemplo n.º 1
0
  /**
   * Set SimObject data from a managed class
   *
   * @param data value
   * @param objectId object id
   * @throws IOException IO Error
   * @throws IllegalDataDefinition if the class of <code>data</code> was not registered (see {@link
   *     #registerClass(Class)})
   * @throws NullPointerException if data is null
   */
  public <T> void setSimObjectData(T data, int objectId) throws IOException, IllegalDataDefinition {
    Class<?> cl = data.getClass();
    if (!definitionIds.containsKey(cl))
      throw new IllegalDataDefinition("Class not defined in this wrapper.");

    int dataLen = classDataSize(cl);
    DataWrapper dw = new DataWrapper(dataLen);
    wrap(data, dw);

    int defId = ((Integer) definitionIds.get(cl)).intValue();

    simConnect.setDataOnSimObject(defId, objectId, false, 1, dw);
  }