OpenSplice Java FACE API  v6.x
OpenSplice Future Airborne Capability Environment (FACE) Java API
TS.java
Go to the documentation of this file.
1 /*
2  * Vortex OpenSplice
3  *
4  * This software and documentation are Copyright 2006 to 2021 ADLINK
5  * Technology Limited, its affiliated companies and licensors. All rights
6  * reserved.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 package org.vortex.FACE;
21 
25 package FACE;
26 
27 import java.util.logging.Level;
28 import org.vortex.FACE.*;
29 import FACE.RETURN_CODE_TYPE;
30 
31 public class TS {
32  private TransportServices impl;
33 
34  protected TS() {
35  }
36 
37  private static class LazyHolder {
38  private static final TS INSTANCE = new TS();
39  }
40 
41  protected static TS getInstance() {
42  return LazyHolder.INSTANCE;
43  }
44 
46  return impl;
47  }
48 
67  public static void Initialize(String configuration,
68  FACE.RETURN_CODE_TYPEHolder return_code) {
69  if (return_code == null) {
70  return;
71  }
72  if (TS.getInstance().impl != null) {
73  return_code.value = FACE.RETURN_CODE_TYPE.NO_ACTION;
74  return;
75  }
77  org.vortex.FACE.TSFactory.getInstance().getTS(configuration, tsHolder,
78  return_code);
79  if (return_code.value == FACE.RETURN_CODE_TYPE.NO_ERROR) {
80  TS.getInstance().impl = tsHolder.value;
81  }
82  }
83 
135  public static void Create_Connection(String connection_name,
136  FACE.MESSAGING_PATTERN_TYPE pattern,
137  us.opengroup.FACE.LongHolder connection_id,
138  FACE.CONNECTION_DIRECTION_TYPEHolder connection_direction,
139  us.opengroup.FACE.IntHolder max_message_size, long timeout,
140  FACE.RETURN_CODE_TYPEHolder return_code) {
141  if (TS.getInstance().impl == null) {
142  return_code.value = FACE.RETURN_CODE_TYPE.NOT_AVAILABLE;
143  return;
144  }
145  TS.getInstance().impl.Create_Connection(connection_name, pattern,
146  connection_id,
147  connection_direction, max_message_size, timeout, return_code);
148  }
149 
150 
177  public static void Destroy_Connection(long connection_id,
178  FACE.RETURN_CODE_TYPEHolder return_code) {
179  if (TS.getInstance().impl == null) {
180  return_code.value = FACE.RETURN_CODE_TYPE.NOT_AVAILABLE;
181  return;
182  }
183  TS.getInstance().impl.Destroy_Connection(connection_id, return_code);
184  }
185 
198  public static void Unregister_Callback(long connection_id,
199  FACE.RETURN_CODE_TYPEHolder return_code) {
200  if (TS.getInstance().impl == null) {
201  return_code.value = FACE.RETURN_CODE_TYPE.NOT_AVAILABLE;
202  return;
203  }
204  TS.getInstance().impl
205  .Unregister_Callback(connection_id, return_code);
206  }
207 
236  public static void Get_Connection_Parameters(
237  us.opengroup.FACE.StringHolder connection_name,
238  us.opengroup.FACE.LongHolder connection_id,
239  FACE.TRANSPORT_CONNECTION_STATUS_TYPEHolder connection_status,
240  FACE.RETURN_CODE_TYPEHolder return_code) {
241  if (TS.getInstance().impl == null) {
242  return_code.value = FACE.RETURN_CODE_TYPE.NOT_AVAILABLE;
243  return;
244  }
245  TS.getInstance().impl.Get_Connection_Parameters(connection_name,
246  connection_id,
247  connection_status, return_code);
248  }
249 
289  public static void Receive_Message(long connection_id, long timeout,
290  us.opengroup.FACE.LongHolder transaction_id,
291  DataTypeHolder message,
292  int message_size, FACE.RETURN_CODE_TYPEHolder return_code) {
293  if (TS.getInstance().getImpl() == null) {
294  return_code.value = FACE.RETURN_CODE_TYPE.NOT_AVAILABLE;
295  Logger.getInstance().log("Receive_Message method not available", Level.SEVERE);
296  return;
297  }
298  if (message == null) {
299  return_code.value = RETURN_CODE_TYPE.INVALID_PARAM;
300  Logger.getInstance().log("Invalid argument message", Level.SEVERE);
301  return;
302  }
303  Holder<DataType> holder = new Holder<DataType>();
304  TS.getInstance()
305  .getImpl()
306  .Receive_Message(connection_id, timeout, transaction_id,
307  holder, message_size, return_code);
308  message.value = holder.value;
309  }
310 
355  public static void Send_Message(long connection_id, long timeout,
356  us.opengroup.FACE.LongHolder transaction_id,
357  DataTypeHolder message,
358  us.opengroup.FACE.IntHolder message_size,
359  FACE.RETURN_CODE_TYPEHolder return_code) {
360  if (TS.getInstance().getImpl() == null) {
361  return_code.value = FACE.RETURN_CODE_TYPE.NOT_AVAILABLE;
362  Logger.getInstance().log("Send_Message method not available", Level.SEVERE);
363  return;
364  }
365  if (message == null) {
366  return_code.value = RETURN_CODE_TYPE.INVALID_PARAM;
367  Logger.getInstance().log("Invalid argument message", Level.SEVERE);
368  return;
369  }
370  Holder<DataType> holder = new Holder<DataType>();
371  holder.value = message.value;
372  TS.getInstance()
373  .getImpl()
374  .Send_Message(connection_id, timeout,
375  transaction_id, holder,
376  message_size, return_code);
377  }
378 
433  public static void Register_Callback(long connection_id, boolean[] waitset,
434  DataTypeRead_CallbackHolder data_callback,
435  int max_message_size, FACE.RETURN_CODE_TYPEHolder return_code) {
436  if (TS.getInstance().getImpl() == null) {
437  return_code.value = FACE.RETURN_CODE_TYPE.NOT_AVAILABLE;
438  Logger.getInstance().log("Register_Callback method not available", Level.SEVERE);
439  return;
440  }
441  if (data_callback == null) {
442  return_code.value = RETURN_CODE_TYPE.INVALID_PARAM;
443  Logger.getInstance().log("Invalid argument data_callback", Level.SEVERE);
444  return;
445  }
446  final FACE.DM.IMU_DataRead_CallbackHolder callback = data_callback;
447 
448  org.vortex.FACE.Read_CallbackHolder<DataType> holder = new org.vortex.FACE.Read_CallbackHolder<DataType>();
449  holder.value = new org.vortex.FACE.Read_Callback<DataType>() {
450 
451  @Override
452  public void send_event(long transaction_id,
453  Holder<DataType> message, long message_type_id,
454  int message_size, boolean[] waitset,
455  FACE.RETURN_CODE_TYPEHolder return_code) {
456  DataTypeHolder holder = new DataTypeHolder();
457  holder.value = message.value;
458  callback.value.send_event(transaction_id, holder,
459  message_type_id, message_size, waitset, return_code);
460  }
461  };
462  TS.getInstance()
463  .getImpl()
464  .Register_Callback(connection_id, waitset,
465  holder,
466  max_message_size, return_code);
467  }
468 }
static void Receive_Message(long connection_id, long timeout, us.opengroup.FACE.LongHolder transaction_id, DataTypeHolder message, int message_size, FACE.RETURN_CODE_TYPEHolder return_code)
The Receive_Message Function is used to receive data from another source.
Definition: TS.java:289
static TSFactory getInstance()
Definition: TSFactory.java:38
void log(String message, Level level)
Definition: Logger.java:47
static void Send_Message(long connection_id, long timeout, us.opengroup.FACE.LongHolder transaction_id, DataTypeHolder message, us.opengroup.FACE.IntHolder message_size, FACE.RETURN_CODE_TYPEHolder return_code)
The Send_Message Function is used to send data to another source.
Definition: TS.java:355
static void Get_Connection_Parameters(us.opengroup.FACE.StringHolder connection_name, us.opengroup.FACE.LongHolder connection_id, FACE.TRANSPORT_CONNECTION_STATUS_TYPEHolder connection_status, FACE.RETURN_CODE_TYPEHolder return_code)
The purpose of Get_Connection_Parameters is to get the information regarding the requested connection...
Definition: TS.java:236
static void Create_Connection(String connection_name, FACE.MESSAGING_PATTERN_TYPE pattern, us.opengroup.FACE.LongHolder connection_id, FACE.CONNECTION_DIRECTION_TYPEHolder connection_direction, us.opengroup.FACE.IntHolder max_message_size, long timeout, FACE.RETURN_CODE_TYPEHolder return_code)
The Transport Services Segment (TSS) provides an interface to create a connection.
Definition: TS.java:135
static void Unregister_Callback(long connection_id, FACE.RETURN_CODE_TYPEHolder return_code)
The purpose of Unregister_Callback is to provide a mechanism to unregister the callback associated wi...
Definition: TS.java:198
Definition: TS.java:31
void Create_Connection(String connection_name, MESSAGING_PATTERN_TYPE pattern, us.opengroup.FACE.LongHolder connection_id, CONNECTION_DIRECTION_TYPEHolder connection_direction, us.opengroup.FACE.IntHolder max_message_size, long timeout, RETURN_CODE_TYPEHolder return_code)
static TS getInstance()
Definition: TS.java:41
static void Register_Callback(long connection_id, boolean[] waitset, DataTypeRead_CallbackHolder data_callback, int max_message_size, FACE.RETURN_CODE_TYPEHolder return_code)
The purpose of Register_Callback is to provide a mechanism to read data without polling.
Definition: TS.java:433
static Logger getInstance()
Definition: Logger.java:43
TransportServices getImpl()
Definition: TS.java:45
void getTS(String configuration, Holder< TransportServices > tsHolder, RETURN_CODE_TYPEHolder holder)
Definition: TSFactory.java:42
This is a typed class which will be generated by idlpp.
Definition: TS.java:25
static void Destroy_Connection(long connection_id, FACE.RETURN_CODE_TYPEHolder return_code)
The Destroy_Connection function frees up any resources allocated to the connection.
Definition: TS.java:177
void Destroy_Connection(long connection_id, RETURN_CODE_TYPEHolder return_code)
For DDS, TS shall keep track of the DomainParticipant and Topic variables for deletion.
void Get_Connection_Parameters(us.opengroup.FACE.StringHolder connection_name, us.opengroup.FACE.LongHolder connection_id, TRANSPORT_CONNECTION_STATUS_TYPEHolder connection_status, RETURN_CODE_TYPEHolder return_code)
TS()
Definition: TS.java:34
static void Initialize(String configuration, FACE.RETURN_CODE_TYPEHolder return_code)
The Initialize function call allows for the Portable Components Segment (PCS) and Platform-Specific S...
Definition: TS.java:67