Repository navigation
Expand file tree
/
Copy pathTml.java
More file actions
2339 lines (2185 loc) · 91.9 KB
/
Copy pathTml.java
File metadata and controls
2339 lines (2185 loc) · 91.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* libTML: A BEEP based Messaging Suite
* Copyright (C) 2015 wobe-systems GmbH
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* You may find a copy of the license under this software is released
* at COPYING file. This is LGPL software: you are welcome to develop
* proprietary applications using this library without any royalty or
* fee but returning back any change, improvement or addition in the
* form of source code, project image, documentation patches, etc.
*
* Homepage:
* http://www.libtml.org
*
* For professional support contact us:
*
* wobe-systems GmbH
*/
/** @defgroup tmlGroup TML API
* @ingroup basicAPI
* @brief Description of TML API functions.
*/
/** @ingroup tmlGroup
* @defgroup tmlReturn TML return codes
* @brief TML return codes
*/
/** @ingroup tmlGroup
* @defgroup coreGeneral General functions
* @brief General library functions
*/
/** @ingroup tmlGroup
* @defgroup coreHandle TMLCore
* @brief TMLCore functions
*
* All communications in TML is related to a TMLCore object. At least one
* TMLCore must exist before any TML communication is possible.
*/
/** @ingroup coreHandle
* @defgroup coreManagement Listener management
* @brief TMLCore listener management
*
* A TMLCore listener must be started and initialized to enable incoming traffic.
*/
/** @ingroup coreHandle
* @defgroup dispatching Profile management
* @brief TMLCore profile
*
* A profile is linked to a TMLCore and diapatches incoming traffic to command handling functions.
*/
/** @ingroup coreHandle
* @defgroup dataIO Sending commands
* @brief Using the TMLCore to send commands.
*/
/** @ingroup coreHandle
* @defgroup eventIO Event handling
* @brief Sending of events to multiple destinations.
*
* Sending event messages to multiple peers without a reply.
*/
/** @ingroup coreHandle
* @defgroup loadbalancedIO Load balancing
* @brief Balance command calls.
*
* For backup and load balancing TML provides an API to call a group of peers instead of a specific peer to
* process a command. If one peer fails the remaining will still handle the command.
*/
/** @ingroup tmlGroup
* @defgroup tmlHandle TML commands
* @brief Creating and handling of TML commands.
*
* TML commands contain data and header information. The data can be set and read using
* the SIDEX API. All SIDEX datatypes can be used to be exchanged through a TML command call.
*/
/** @ingroup tmlHandle
* @defgroup tmlCmdCallbacks Command message callbacks
* @brief Callback methods for multiple answers and asynchronous reply handling.
*
* If commands are called asynchronously or status/progress replies are used, callbacks can
* be registered for a command to handle this information.
*/
/** @ingroup tmlHandle
* @defgroup tmlheader Accessing header information
* @brief Functions to access command header information.
*/
/** @ingroup coreHandle
* @defgroup streamIO Stream communication
* @brief Using TML streams.
*
* The stream API enables TML to transfer files without using another port or protocol.
*/
/** @ingroup tmlGroup
* @defgroup tmlCallback TML callback interfaces
* @brief Definition of callback interfaces used in TML API.
*
* TML API is using various callback interfaces to support asynchronous and threaded functionality.
*/
package com.tmlsidex.jni;
import java.nio.ByteBuffer;
/**
* Native TML API functions.
**/
public class Tml {
private static final int TML_SUCCESS = 0;
///////////////////////
// General:
private native void NativeTmlCoreGetCopyright(StringBuffer sValue, int[] iLength);
private native int NativeTmlCoreGetLoggingValue(long coreHandle, int[] iLogValue);
private native void NativeTmlCoreGetVersion(int[] apiVer, int[] libVer, StringBuffer verStr);
private native int NativeTmlCoreSetLoggingValue(long coreHandle, int iLogValue);
private native int NativeTmlCoreSetPassword(String pUserName, String pPassWord);
///////////////////////
// TMLCore:
private native int NativeTmlCoreClose(long coreHandle);
private native int NativeTmlCoreGeneralDeregistration(long coreHandle);
private native int NativeTmlCoreOpen(long[] coreHandle, int iLogValue);
///////////////////////////////////////////////
//TMLCore / Listener management
private native int NativeTmlCoreGetListenerEnabled(long coreHandle, boolean[] bEnable);
private native int NativeTmlCoreGetListenerIP(long coreHandle, StringBuffer sIP);
private native int NativeTmlCoreGetListenerPort(long coreHandle, StringBuffer sPort);
private native int NativeTmlCoreSetListenerEnabled(long coreHandle, boolean bEnable);
private native int NativeTmlCoreSetListenerIP(long coreHandle, String sIP);
private native int NativeTmlCoreSetListenerPort(long coreHandle, String sPort);
///////////////////////////////////////////////
//TMLCore / Profile management
private native int NativeTmlProfileGetRegistered(long coreHandle, long[] profiles);
private native int NativeTmlProfileGetRegisteredCount(long coreHandle, int[] iSize);
private native int NativeTmlProfileGetRegisterState(long coreHandle, String profile, boolean[] bRegistered);
private native int NativeTmlProfileRegister(long coreHandle, String profile);
private native int NativeTmlProfileRegisterCmd(long coreHandle, String profile, int cmdID, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlProfileSetOnCustomDispatch(long coreHandle, String profile, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlProfileSetOnDeleteCmd(long coreHandle, String profile, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlProfileUnregister(long coreHandle, String profile);
///////////////////////////////////////////////
//TMLCore / Sending commands
private native int NativeTmlSendAsyncMessage(long coreHandle, long cmdHandle, String sProfile, String sIP, String sPort, long timeout);
private native int NativeTmlSendAsyncProgressReply(long cmdHandle, int progress);
private native int NativeTmlSendAsyncStatusReply(long cmdHandle, int iType, String sStatus);
private native int NativeTmlSendSyncMessage(long coreHandle, long cmdHandle, String sProfile, String sIP, String sPort, long timeout);
///////////////////////////////////////////////
//TMLCore / Event handling
private native int NativeTmlEvtGetMaxConnectionFailCount(long coreHandle, int[] iCount);
private native int NativeTmlEvtGetMaxQueuedEventMessages(long coreHandle, int[] iMaximum);
private native int NativeTmlEvtGetSubscribedMessageDestinations(long coreHandle, String sProfile, long[] subscriptions);
private native int NativeTmlEvtSendMessage(long coreHandle, long cmdHandle, String sProfile);
private native int NativeTmlEvtSendSubscriptionRequest(long coreHandle, String sProfile, String sSourceHost, String sSourcePort, String sDestHost, String sDestPort, long timeout);
private native int NativeTmlEvtSendUnsubscriptionRequest(long coreHandle, String sProfile, String sSourceHost, String sSourcePort, String sDestHost, String sDestPort, long timeout);
private native int NativeTmlEvtSetMaxConnectionFailCount(long coreHandle, int iCount);
private native int NativeTmlEvtSetMaxQueuedEventMessages(long coreHandle, int iMaximum);
private native int NativeTmlEvtSetOnError(long coreHandle, String profile, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlEvtSetOnPeerRegister(long coreHandle, String profile, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlEvtSetOnPopulate(long coreHandle, String profile, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlEvtSetOnQueueOverflow(long coreHandle, String profile, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlEvtSubscribeMessageDestination(long coreHandle, String sProfile, String sHost, String sPort);
private native int NativeTmlEvtUnsubscribeAllMessageDestinations(long coreHandle, String sProfile);
private native int NativeTmlEvtUnsubscribeMessageDestination(long coreHandle, String sProfile, String sHost, String sPort);
///////////////////////////////////////////////
//TMLCore / Load balancing
private native int NativeTmlBalGetMaxConnectionFailCount(long coreHandle, int[] iCount);
private native int NativeTmlBalGetSubscribedMessageDestinations(long coreHandle, String sProfile, long[] subscriptions);
private native int NativeTmlBalSendAsyncMessage(long coreHandle, long cmdHandle, String sProfile, long iTimeout);
private native int NativeTmlBalSendSubscriptionRequest(long coreHandle, String sProfile, String sSourceHost, String sSourcePort, String sDestHost, String sDestPort, long timeout);
private native int NativeTmlBalSendSyncMessage(long coreHandle, long cmdHandle, String sProfile, long iTimeout);
private native int NativeTmlBalSendUnsubscriptionRequest(long coreHandle, String sProfile, String sSourceHost, String sSourcePort, String sDestHost, String sDestPort, long timeout);
private native int NativeTmlBalSetMaxConnectionFailCount(long coreHandle, int iCount);
private native int NativeTmlBalSetOnBusyStatusRequest(long coreHandle, String profile, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlBalSetOnCalculation(long coreHandle, String profile, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlBalSetOnPeerRegister(long coreHandle, String profile, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlBalSetOnPopulate(long coreHandle, String profile, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlBalSubscribeMessageDestination(long coreHandle, String sProfile, String sHost, String sPort);
private native int NativeTmlBalUnsubscribeAllMessageDestinations(long coreHandle, String sProfile);
private native int NativeTmlBalUnsubscribeMessageDestination(long coreHandle, String sProfile, String sHost, String sPort);
///////////////////////////////////////////////
//TMLCore / Stream communication
private native int NativeTmlRecStreamClose(long coreHandle, long iID, boolean bRetainOpen);
private native int NativeTmlRecStreamDownloadData(long coreHandle, long iID, int buffersize,
Object callerClassDld, String sCBNameDld, Object pCBDataDld,
Object callerClassFinish, String sCBNameFinish, Object pCBDataFinish);
private native int NativeTmlRecStreamGetPosition(long coreHandle, long iID, long[] rposition);
private native int NativeTmlRecStreamGetSize(long coreHandle, long iID, long[] rsize);
private native int NativeTmlRecStreamOpen(long coreHandle, long iID, String sProfile, String sIP, String sPort);
private native int NativeTmlRecStreamRead(long coreHandle, long iID, ByteBuffer buffer, int count, int[] bytesRead);
private native int NativeTmlRecStreamReadBuffer(long coreHandle, long iID, ByteBuffer buffer, int count);
private native int NativeTmlRecStreamSeek(long coreHandle, long iID, long seekPos, int origin);
private native int NativeTmlRecStreamWrite(long coreHandle, long iID, byte[] buffer, int count);
private native int NativeTmlSndStreamClose(long coreHandle, long iID);
private native int NativeTmlSndStreamOpen(long coreHandle, long[] iID, String sProfile, String sIP, String sPort);
private native int NativeTmlSndStreamRegisterClose(long coreHandle, long iID, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlSndStreamRegisterGetPosition(long coreHandle, long iID, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlSndStreamRegisterGetSize(long coreHandle, long iID, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlSndStreamRegisterOnError(long coreHandle, long iID, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlSndStreamRegisterRead(long coreHandle, long iID, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlSndStreamRegisterSeek(long coreHandle, long iID, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlSndStreamRegisterWrite(long coreHandle, long iID, Object callerClass, String sCBName, Object pCBData);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////
// TML commands:
private native int NativeTmlCmdAcquireSidexHandle(long cmdHandle, long[] sidexHandle);
private native int NativeTmlCmdCreate(long[] cmdHandle);
private native int NativeTmlCmdFree(long cmdHandle);
private native int NativeTmlCmdReleaseSidexHandle(long cmdHandle);
///////////////////////////////////////////////
//TML commands / Command message callbacks
private native int NativeTmlCmdRegisterCommandReady(long cmdHandle, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlCmdRegisterProgress(long cmdHandle, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlCmdRegisterStatusReply(long cmdHandle, Object callerClass, String sCBName, Object pCBData);
private native int NativeTmlCmdRegisteredCommandReady(long cmdHandle, Object[] callerClass, Object sCBName, Object[] pCBData);
private native int NativeTmlCmdRegisteredStatusReply(long cmdHandle, Object[] callerClass, Object sCBName, Object[] pCBData);
private native int NativeTmlCmdRegisteredProgress(long cmdHandle, Object[] callerClass, Object sCBName, Object[] pCBData);
///////////////////////////////////////////////
//TML commands / Accessing header information
private native int NativeTmlCmdHeaderGetCommand(long cmdHandle, int[] cmdID);
private native int NativeTmlCmdHeaderGetCreationTime(long cmdHandle, StringBuffer time);
private native int NativeTmlCmdHeaderGetError(long cmdHandle, int[] error);
private native int NativeTmlCmdHeaderGetErrorMessage(long cmdHandle, StringBuffer msg);
private native int NativeTmlCmdHeaderGetMode(long cmdHandle, int[] mode);
private native int NativeTmlCmdHeaderGetProgress(long cmdHandle, int[] progress);
private native int NativeTmlCmdHeaderGetReplyMessage(long cmdHandle, StringBuffer msg);
private native int NativeTmlCmdHeaderGetReplyType(long cmdHandle, int[] type);
private native int NativeTmlCmdHeaderGetState(long cmdHandle, int[] state);
private native int NativeTmlCmdHeaderSetCommand(long cmdHandle, int cmdID);
private native int NativeTmlCmdHeaderSetError(long cmdHandle, int error);
private native int NativeTmlCmdHeaderSetErrorMessage(long cmdHandle, String msg);
private native int NativeTmlCmdHeaderSetMode(long cmdHandle, int mode);
private native int NativeTmlCmdHeaderSetProgress(long cmdHandle, int progress);
private native int NativeTmlCmdHeaderSetReplyMessage(long cmdHandle, String msg);
private native int NativeTmlCmdHeaderSetReplyType(long cmdHandle, int type);
private native int NativeTmlCmdHeaderSetState(long cmdHandle, int state);
///////////////////////
// General:
/**
* @addtogroup coreGeneral
* @{
*/
/**
* @brief get copyright information
*
* @return copyright information
*/
public String tml_Core_Get_Copyright(){
int[] iLength = new int[1];
StringBuffer buffer = new StringBuffer("");
NativeTmlCoreGetCopyright(buffer, iLength);
String sRet = buffer.toString();
buffer = null;
iLength = null;
return sRet;
}
/**
* @brief get interface api and library version
*
* @param iApiVer array of size 1 - returns api version
* @param iLibVer array of size 1 - returns library version
*
* @return library version as string
*/
public String tml_Core_Get_Version(int[] iApiVer, int[] iLibVer){
StringBuffer buffer = new StringBuffer("");
NativeTmlCoreGetVersion(iApiVer, iLibVer, buffer);
String sRet = buffer.toString();
buffer = null;
return sRet;
}
/**
* @brief get the license key
*
* Before the sdk functions can be used a license key must be applied.
*
* @note Since TML/SIDEX is open source this API call is deprecated. It returns allways SIDEX_SUCCESS.
* It has been left in the API to be backward compatible.
*
* @param pUserName user name (case sensitive)
* @param pPassWord password (case insensitive)
*/
public void tml_Core_Set_Password(String pUserName, String pPassWord) throws TmlSidexException{
int iRet = NativeTmlCoreSetPassword(pUserName, pPassWord);
if (SidexErr.SIDEX_SUCCESS != iRet){
throw new TmlSidexException("tml_Core_Set_Password / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief set debug log value
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param iLogValue debug log value
*/
public void tml_Core_Set_LoggingValue(long coreHandle, int iLogValue) throws TmlSidexException{
int iRet = NativeTmlCoreSetLoggingValue(coreHandle, iLogValue);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Core_Set_LoggingValue / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief get debug log value
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
*
* @return current debug log value
*/
public int tml_Core_Get_LoggingValue(long coreHandle) throws TmlSidexException{
int[] iLogValue = new int[1];
int iRet = NativeTmlCoreGetLoggingValue(coreHandle, iLogValue);
if (TML_SUCCESS != iRet){
iLogValue = null;
throw new TmlSidexException("tml_Core_Get_LoggingValue / Error "+Integer.toString(iRet), iRet);
}
int iRetVal = iLogValue[0];
iLogValue = null;
return iRetVal;
}
/* @} */
///////////////////////
// TMLCore:
/**
* @addtogroup coreHandle
* @{
*/
/**
* @brief release a TML core handle
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
*
* @throws TmlSidexException
*/
public void tml_Core_Close(long coreHandle) throws TmlSidexException{
int iRet = NativeTmlCoreClose(coreHandle);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Core_Close / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief clear registration of all callback functions
*
* Deregister all callbacks for a safe shutdown.
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
*
* @throws TmlSidexException
*/
public void tml_Core_GeneralDeregistration(long coreHandle) throws TmlSidexException{
int iRet = NativeTmlCoreGeneralDeregistration(coreHandle);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Core_GeneralDeregistration / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief open a new TML core handle
*
* @param iLogValue debug log value
*
* @return TML core handle (TML_CORE_HANDLE).
*
* @throws TmlSidexException
* @see Tml#tml_Core_Close(long)
*/
public long tml_Core_Open(int iLogValue) throws TmlSidexException{
long[] coreHandle = new long[1];
int iRet = NativeTmlCoreOpen(coreHandle, iLogValue);
if (TML_SUCCESS != iRet){
coreHandle = null;
throw new TmlSidexException("tml_Core_Open / Error "+Integer.toString(iRet), iRet);
}
long retValue = coreHandle[0];
coreHandle = null;
return retValue;
}
/* @} */
///////////////////////////////////////////////
//TMLCore / Listener management
/**
* @addtogroup coreManagement
* @{
*/
/**
* @brief get listener status
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
*
* @return listener status, true if listener is enabled, false if listener is disabled
*
* @throws TmlSidexException
*/
public boolean tml_Core_Get_ListenerEnabled(long coreHandle) throws TmlSidexException{
boolean[] value = new boolean[1];
int iRet = NativeTmlCoreGetListenerEnabled(coreHandle, value);
if (TML_SUCCESS != iRet){
value = null;
throw new TmlSidexException("tml_Core_Get_ListenerEnabled / Error "+Integer.toString(iRet), iRet);
}
boolean bValue = value[0];
return bValue;
}
/**
* @brief get the listener interface (IP)
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
*
* @return interface IP
*
* @throws TmlSidexException
*/
public String tml_Core_Get_ListenerIP(long coreHandle) throws TmlSidexException{
StringBuffer buffer = new StringBuffer("");
int iRet = NativeTmlCoreGetListenerIP(coreHandle, buffer);
if (TML_SUCCESS != iRet){
buffer = null;
throw new TmlSidexException("tml_Core_Get_ListenerIP / Error "+Integer.toString(iRet), iRet);
}
String sRet = buffer.toString();
buffer = null;
return sRet;
}
/**
* @brief get listener port number
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
*
* @return port number
*
* @throws TmlSidexException
*/
public String tml_Core_Get_ListenerPort(long coreHandle) throws TmlSidexException{
StringBuffer buffer = new StringBuffer("");
int iRet = NativeTmlCoreGetListenerPort(coreHandle, buffer);
if (TML_SUCCESS != iRet){
buffer = null;
throw new TmlSidexException("tml_Core_Get_ListenerPort / Error "+Integer.toString(iRet), iRet);
}
String sRet = buffer.toString();
buffer = null;
return sRet;
}
/**
* @brief enable or disable TML listener
*
* The interface IP and port have to be configured before enabling the listener.
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param bEnable true to enable, false to disable the listener
*
* @throws TmlSidexException
*/
public void tml_Core_Set_ListenerEnabled(long coreHandle, boolean bEnable) throws TmlSidexException{
int iRet = NativeTmlCoreSetListenerEnabled(coreHandle, bEnable);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Core_Set_ListenerEnabled / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief set the listener interface (IP)
*
* The listener can be assigned to a specific network interface or to all network interfaces
* available ("0.0.0.0) which is the default.
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param sIP interface IP
*
* @throws TmlSidexException
*/
public void tml_Core_Set_ListenerIP(long coreHandle, String sIP) throws TmlSidexException{
int iRet = NativeTmlCoreSetListenerIP(coreHandle, sIP);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Core_Set_ListenerIP / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief set listener port
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param sPort number, 0 = random port number, default 44000
*
* @throws TmlSidexException
*/
public void tml_Core_Set_ListenerPort(long coreHandle, String sPort) throws TmlSidexException{
int iRet = NativeTmlCoreSetListenerPort(coreHandle, sPort);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Core_Set_ListenerPort / Error "+Integer.toString(iRet), iRet);
}
}
/* @} */
///////////////////////////////////////////////
//TMLCore / Profile management
/**
* @addtogroup dispatching
* @{
*/
/**
* @brief get a list of registered profile names
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
*
* @return A SIDEX list containing profile names
*
* @throws TmlSidexException
*/
public long tml_Profile_Get_Registered(long coreHandle) throws TmlSidexException{
long[] profiles = new long[1];
int iRet = NativeTmlProfileGetRegistered(coreHandle, profiles);
if (TML_SUCCESS != iRet){
profiles = null;
throw new TmlSidexException("tml_Profile_Get_Registered / Error "+Integer.toString(iRet), iRet);
}
long lRet = profiles[0];
profiles = null;
return lRet;
}
/**
* @brief get the number of registered profiles
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
*
* @return number of registered profiles
*
* @throws TmlSidexException
*/
public int tml_Profile_Get_Registered_Count(long coreHandle) throws TmlSidexException{
int[] iSize = new int[1];
int iRet = NativeTmlProfileGetRegisteredCount(coreHandle, iSize);
if (TML_SUCCESS != iRet){
iSize = null;
throw new TmlSidexException("tml_Profile_Get_Registered_Count / Error "+Integer.toString(iRet), iRet);
}
int iCount = iSize[0];
iSize = null;
return iCount;
}
/**
* @brief check if a profile name is already registered
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param profile profile name
*
* @return true if the profile is registered
*
* @throws TmlSidexException
*/
public boolean tml_Profile_Get_RegisterState(long coreHandle, String profile) throws TmlSidexException{
boolean[] bRegistered = new boolean[1];
int iRet = NativeTmlProfileGetRegisterState(coreHandle, profile, bRegistered);
if (TML_SUCCESS != iRet){
bRegistered = null;
throw new TmlSidexException("tml_Profile_Get_RegisterState / Error "+Integer.toString(iRet), iRet);
}
boolean bRet = bRegistered[0];
bRegistered = null;
return bRet;
}
/**
* @brief register a profile
*
* Before any other operation referring to a profile is accepted
* by the TML core, the profile has to be registered.
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param profile profile name
*
* @throws TmlSidexException
*/
public void tml_Profile_Register(long coreHandle, String profile) throws TmlSidexException{
int iRet = NativeTmlProfileRegister(coreHandle, profile);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Profile_Register / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief register a command handler
*
* The command handler is a called if the listerner receives a message
* with a matching iCmdID. If no command handler is registered either an error is returned
* to the caller or the general command handler is called if registered.
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param profile profile name
* @param iCmdID command id
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param cbData custom data or null / set null for deregistration
*
* @throws TmlSidexException
*/
public void tml_Profile_Register_Cmd(long coreHandle, String profile, int iCmdID, TmlJniCmdDispatchIF cbInstance, Object cbData) throws TmlSidexException{
int iRet = NativeTmlProfileRegisterCmd(coreHandle, profile, iCmdID, cbInstance, TmlJniCmdDispatchIF.CB_NAME, cbData);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Profile_Register_Cmd / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief register a general command handler
*
* If no command handler was registered for a command id,
* the profile will call the general command handler if registered.
* This can be used to implement an own dispatching mechanism to handle incoming commands and events.
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param profile profile name
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param cbData custom data or null / set null for deregistration
*
* @throws TmlSidexException
*/
public void tml_Profile_Set_OnCustomDispatch(long coreHandle, String profile, TmlJniCustomDispatchIF cbInstance, Object cbData) throws TmlSidexException{
int iRet = NativeTmlProfileSetOnCustomDispatch(coreHandle, profile, cbInstance, TmlJniCustomDispatchIF.CB_NAME, cbData);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Profile_Set_OnCustomDispatch / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief register a callback to release custom data assigned to a command handler
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param profile profile name
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param cbData custom data or null / set null for deregistration
*
* @throws TmlSidexException
*/
public void tml_Profile_Set_OnDeleteCmd(long coreHandle, String profile, TmlJniCmdDeleteIF cbInstance, Object cbData) throws TmlSidexException{
int iRet = NativeTmlProfileSetOnDeleteCmd(coreHandle, profile, cbInstance, TmlJniCmdDeleteIF.CB_NAME, cbData);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Profile_Set_OnDeleteCmd / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief deregister a profile
*
* All command handlers registered for the profile will be removed from the TML core.
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param profile profile name
*
* @throws TmlSidexException
*/
public void tml_Profile_Unregister(long coreHandle, String profile) throws TmlSidexException{
int iRet = NativeTmlProfileUnregister(coreHandle, profile);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Profile_Unregister / Error "+Integer.toString(iRet), iRet);
}
}
/* @} */
///////////////////////////////////////////////
//TMLCore / Sending commands
/**
* @addtogroup dataIO
* @{
*/
/**
* @brief send an asynchronous message
*
* The call returns after sending the message without waiting for a reply.
* If a result of the call is processed by the CommandReady handler.
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param cmdHandle TML command handle
* @param sProfile profile name
* @param sIP hostname or IP address
* @param sPort port number
* @param timeout timeout in milliseconds
*
* @throws TmlSidexException
* @see Tml#tml_Cmd_Register_CommandReady(long, TmlJniCmdReadyIF, Object)
*/
public void tml_Send_AsyncMessage(long coreHandle, long cmdHandle, String sProfile, String sIP, String sPort, long timeout) throws TmlSidexException{
int iRet = NativeTmlSendAsyncMessage(coreHandle, cmdHandle, sProfile, sIP, sPort, timeout);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Send_AsyncMessage / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief send a progress reply to the caller
*
* @param cmdHandle TML command handle
* @param progress progress value (0-100)
*
* @throws TmlSidexException
*/
public void tml_Send_AsyncProgressReply(long cmdHandle, int progress) throws TmlSidexException{
int iRet = NativeTmlSendAsyncProgressReply(cmdHandle, progress);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Send_AsyncProgressReply / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief send a status reply to the caller
*
* Status reply types:
* <TABLE>
* <TR><TD><B>Name </B></TD><TD><B>Value </B></TD><TD><B>Description </B></TD></TR>
* <TR><TD>TMLCOM_RPY_WARNING </TD><TD>10</TD><TD>warning message reply</TD></TR>
* <TR><TD>TMLCOM_RPY_ERROR </TD><TD>20</TD><TD>error message reply</TD></TR>
* <TR><TD>TMLCOM_RPY_INFORMATION </TD><TD>30</TD><TD>information message reply</TD></TR>
* </TABLE>
*
* @param cmdHandle TML command handle
* @param rType status reply type
* @param rMsg status reply message
*
* @throws TmlSidexException
*/
public void tml_Send_AsyncStatusReply(long cmdHandle, int rType, String rMsg) throws TmlSidexException{
int iRet = NativeTmlSendAsyncStatusReply(cmdHandle, rType, rMsg);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Send_AsyncStatusReply / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief send a synchronous message
*
* Sending a message synchronously means that the call is waiting for the reply.
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param cmdHandle TML command handle
* @param sProfile profile name
* @param sIP hostname or IP address
* @param sPort port number
* @param timeout timeout in milliseconds
*
* @throws TmlSidexException
*/
public void tml_Send_SyncMessage(long coreHandle, long cmdHandle, String sProfile, String sIP, String sPort, long timeout) throws TmlSidexException{
int iRet = NativeTmlSendSyncMessage(coreHandle, cmdHandle, sProfile, sIP, sPort, timeout);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Send_SyncMessage / Error "+Integer.toString(iRet), iRet);
}
}
/* @} */
///////////////////////////////////////////////
//TMLCore / Event handling
/**
* @addtogroup eventIO
* @{
*/
/**
* @brief get maximum event connection fail count
*
* The maximum connection fail count defines after how many unsuccessful connections an event
* consumer is automatically removed from the list. A value of 0 means it is never removed.
* The default value is 1.
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
*
* @return maximum fail count
*
* @throws TmlSidexException
*/
public int tml_Evt_Get_MaxConnectionFailCount(long coreHandle) throws TmlSidexException{
int[] iCount = new int[1];
int iRet = NativeTmlEvtGetMaxConnectionFailCount(coreHandle, iCount);
if (TML_SUCCESS != iRet){
iCount = null;
throw new TmlSidexException("tml_Evt_Get_MaxConnectionFailCount / Error "+Integer.toString(iRet), iRet);
}
int iVal = iCount[0];
iCount = null;
return iVal;
}
/**
* @brief get the maximum number of queued event
*
* If the maximum number of queued events is reached, the oldest event
* is deleted. The default value is 1000.
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
*
* @return maximum queue count
*
* @throws TmlSidexException
*/
public int tml_Evt_Get_MaxQueuedEventMessages(long coreHandle) throws TmlSidexException{
int[] iMaximum = new int[1];
int iRet = NativeTmlEvtGetMaxQueuedEventMessages(coreHandle, iMaximum);
if (TML_SUCCESS != iRet){
iMaximum = null;
throw new TmlSidexException("tml_Evt_Get_MaxQueuedEventMessages / Error "+Integer.toString(iRet), iRet);
}
int iVal = iMaximum[0];
return iVal;
}
/**
* @brief get event receiver list
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param sProfile profile name
*
* @return reference to a SIDEX table with event receiver data.
* The table has to be released with sidex_Variant_DecRef().
* Table columns are "PROFILE", "HOST" and "PORT".
*
* @throws TmlSidexException
*/
public long tml_Evt_Get_Subscribed_MessageDestinations(long coreHandle, String sProfile) throws TmlSidexException{
long[] subscriptions = new long[1];
int iRet = NativeTmlEvtGetSubscribedMessageDestinations(coreHandle, sProfile, subscriptions);
if (TML_SUCCESS != iRet){
subscriptions = null;
throw new TmlSidexException("tml_Evt_Get_Subscribed_MessageDestinations / Error "+Integer.toString(iRet), iRet);
}
long lRet = subscriptions[0];
subscriptions = null;
return lRet;
}
/**
* @brief send an event to all registered receivers
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param cmdHandle TML command handle
* @param sProfile profile name
*
* @throws TmlSidexException
*/
public void tml_Evt_Send_Message(long coreHandle, long cmdHandle, String sProfile) throws TmlSidexException{
int iRet = NativeTmlEvtSendMessage(coreHandle, cmdHandle, sProfile);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Evt_Send_Message / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief send an event subscription request
*
* Register a peer to receive events of a specifc profile from an event producer.
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param sProfile profile name
* @param sSourceHost host name / IP addresse of the subscriber
* @param sSourcePort port number of the subscriber
* @param sDestHost host name / IP addresse of the event producer
* @param sDestPort port number of the event producer
* @param timeout timeout in milliseconds
*
* @throws TmlSidexException
*/
public void tml_Evt_Send_SubscriptionRequest(long coreHandle, String sProfile, String sSourceHost, String sSourcePort, String sDestHost, String sDestPort, long timeout) throws TmlSidexException{
int iRet = NativeTmlEvtSendSubscriptionRequest(coreHandle, sProfile, sSourceHost, sSourcePort, sDestHost, sDestPort, timeout);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Evt_Send_SubscriptionRequest / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief unsubscribe a peer from receiving events
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param sProfile profile name
* @param sSourceHost host name / IP addresse of the subscriber
* @param sSourcePort port number of the subscriber
* @param sDestHost host name / IP addresse of the event producer
* @param sDestPort port number of the event producer
* @param timeout timeout in milliseconds
*
* @throws TmlSidexException
* @see Tml#tml_Evt_Send_SubscriptionRequest(long, String, String, String, String, String, long)
*/
public void tml_Evt_Send_UnsubscriptionRequest(long coreHandle, String sProfile, String sSourceHost, String sSourcePort, String sDestHost, String sDestPort, long timeout) throws TmlSidexException{
int iRet = NativeTmlEvtSendUnsubscriptionRequest(coreHandle, sProfile, sSourceHost, sSourcePort, sDestHost, sDestPort, timeout);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Evt_Send_UnsubscriptionRequest / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief set the maximum event connection fail count
*
* The maximum connection fail count defines after how many unsuccessful connections
* an event consumer is automatically removed from the list. A value of 0 means it is never removed.
* The default value is 1
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param iCount maximum fail count
*
* @throws TmlSidexException
*/
public void tml_Evt_Set_MaxConnectionFailCount(long coreHandle, int iCount) throws TmlSidexException{
int iRet = NativeTmlEvtSetMaxConnectionFailCount(coreHandle, iCount);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Evt_Set_MaxConnectionFailCount / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief set the maximum number of queued events.
*
* If the maximum number of queued events is reached, the oldest event will be removed.
* The default value is 1000.
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param iMaximum maximum queue count
*
* @throws TmlSidexException
*/
public void tml_Evt_Set_MaxQueuedEventMessages(long coreHandle, int iMaximum) throws TmlSidexException{
int iRet = NativeTmlEvtSetMaxQueuedEventMessages(coreHandle, iMaximum);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Evt_Set_MaxQueuedEventMessages / Error "+Integer.toString(iRet), iRet);
}
}
/**
* @brief register an event error handler
*
* @param coreHandle TML core handle (TML_CORE_HANDLE)
* @param profile profile name
* @param cbInstance instance of an implementation of the callback method interface / set null for deregistration
* @param cbData custom data or null / set null for deregistration
*
* @throws TmlSidexException
*/
public void tml_Evt_Set_OnError(long coreHandle, String profile, TmlJniEvtErrorHandlerIF cbInstance, Object cbData) throws TmlSidexException{
int iRet = NativeTmlEvtSetOnError(coreHandle, profile, cbInstance, TmlJniEvtErrorHandlerIF.CB_NAME, cbData);
if (TML_SUCCESS != iRet){
throw new TmlSidexException("tml_Evt_Set_OnError / Error "+Integer.toString(iRet), iRet);