forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vortex-web-client.d.ts
471 lines (404 loc) · 11.4 KB
/
vortex-web-client.d.ts
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
// Type definitions for Vortex Web 1.2.0p1
// Project: http://www.prismtech.com/vortex/vortex-web
// Definitions by: Stefan Profanter <https://github.com/Pro/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/*
Vortex Web
This software and documentation are Copyright 2010 to 2015 PrismTech
Limited and its licensees. All rights reserved. See file:
docs/LICENSE.html
for full copyright notice and license terms.
*/
declare module DDS {
/**
* Base class for all policies
*/
interface Policy {
}
/**
* History policy
*/
export enum HistoryKind {
KeepAll = 0,
KeepLast = 1
}
/**
* History policy
*/
export class History implements Policy {
/**
* KeepAll - KEEP_ALL qos policy
*/
static KeepAll:any;
/**
* KeepLast - KEEP_LAST qos policy
*/
static KeepLast:any;
}
/**
* Reliability Policy
* @example var qos = Reliability.Reliable
*/
export enum ReliabilityKind {
Reliable = 0,
BestEffort = 1
}
/**
* History policy
*/
export class Reliability implements Policy {
/**
* Reliable - 'Reliable' reliability policy
*/
static Reliable:any;
/**
* BestEffort - 'BestEffort' reliability policy
*/
static BestEffort:any;
}
/**
* Create new partition policy
*
* @param policies - partition names
* @example var qos = Partition('p1', 'p2')
*/
export function Partition(...policies:string[]):Policy;
/**
* Create new content filter policy
*
* @param expr - filter expression
* @example var filter = ContentFilter("x>10 AND y<50")
*/
export function ContentFilter(expr:string):Policy;
/**
* Create new time filter policy
*
* @param period - time duration (unit ?)
* @example var filter = TimeFilter(100)
*/
export function TimeFilter(period:number):Policy;
/**
* Durability Policy
*/
export enum DurabilityKind {
Volatile = 0,
TransientLocal = 1,
Transient = 2,
Persistent = 3
}
/**
* Durability Qos Policy
*/
export class Durability implements Policy {
/**
* Volatile - Volatile durability policy
*/
static Volatile:any;
/**
* TransientLocal - TransientLocal durability policy
*/
static TransientLocal:any;
/**
* Transient - Transient durability policy
*/
static Transient:any;
/**
* Persistent - Persistent durability policy
*/
static Persistent:any;
}
interface EntityQos {
/**
* Creates any of the DDS entities quality of service, including DataReaderQos and DataWriterQos.
*
* @param policies - list of policies for the Qos entity
*/
new (...policies:Policy[]): EntityQos;
/**
* Adds the given policy to this instance.
* @param policy - the policy to add
* @return A new copy of this instance with the combined policies
*/
add (policy:Policy): EntityQos;
}
/**
* Topic quality of service object
*/
export var TopicQos:EntityQos;
/**
* DataReader quality of service object
*/
export var DataReaderQos:EntityQos;
/**
* DataWriter quality of service object
*/
export var DataWriterQos:EntityQos;
export class Topic {
/**
* Creates a `Topic` in the domain `did`, named `tname`, having `qos` Qos,
* for the type `ttype` whose registered name is `tregtype`
* @param {number} did - DDS domain ID
* @param {string} tname - topic name
* @param {TopicQos} qos - topic Qos
* @param {string} ttype - topic type. If not specified, a generic type is used.
* @param {string} tregtype - topic registered type name. If not specified, 'ttype' is used.
*/
constructor(did:number, tname:string, qos:EntityQos, ttype?:string, tregtype?:string);
/**
* Called when topic gets registered in the runtime
*/
onregistered():void;
/**
* Called when topic gets unregistered in the runtime
*/
onunregistered():void;
}
export class DataReader {
/**
* Creates a `DataReader` for a given topic and a specific in a specific DDS runtime.
*
* A `DataReader` allows to read data for a given topic with a specific QoS. A `DataReader`
* * goes through different states, it is intially disconnected and changes to the connected state
* when the underlying transport connection is successfully established with the server. At this point
* a `DataReader` can be explicitely closed or disconnected. A disconnection can happen as the result
* of a network failure or server failure. Disconnection and reconnections are managed by the runtime.
*
* @param runtime - DDS Runtime
* @param topic - DDS Topic
* @param qos - DataReader quality of service
*/
constructor(runtime:Runtime, topic:Topic, qos:EntityQos);
resetStats():void;
/**
* Attaches the listener `l` to this data reader and returns
* the id associated to the listener.
* @param l - listener code
* @returns listener handle
*/
addListener(l:(msg:any) => void):number;
/**
* removes a listener from this data reader.
* @param idx - listener id
*/
removeListener(idx:number):void;
/**
* closes the DataReader
*/
close():void;
}
export class DataWriter {
/**
* Creates a `DataWriter` for a given topic and a specific in a specific DDS runtime
*
* defines a DDS data writer. This type
* is used to write data for a specific topic with a given QoS.
* A `DataWriter` goes through different states, it is intially disconnected and changes to the connected
* state when the underlying transport connection is successfully established with the server.
* At this point a `DataWriter` can be explicitely closed or disconnected. A disconnection can happen
* as the result of a network failure or server failure. Disconnection and reconnections are managed by the
* runtime.
*
* @param runtime - DDS Runtime
* @param topic - DDS Topic
* @param qos - DataWriter quality of service
*/
constructor(runtime:Runtime, topic:Topic, qos:EntityQos);
/**
* Writes one or more samples.
* @param ds - data sample
*/
write(...ds:any[]):void;
/**
* Closes the DataWriter
*/
close():void;
}
export class DataCache {
/**
* Constructs a `DataCache` with a given `depth`. If the `cache` parameter
* is present, then the current cache is initialized with this parameter.
*
* Provides a way of storing and flexibly accessing the
* data received through a `DataReader`. A `DataCache` is organized as
* a map of queues. The depth of the queues is specified at construction
* time.
*
* @param depth - cache size
* @param cache - cache data structure
*/
constructor(depth:number, cache:any);
/**
* Register a listener to be notified whenever data which matches a predicate is written into the cache.
* If no predicate is provided then the listeners is always notified upon data inserion.
*
* @param l - listener function
* @param p - predicate
*/
addListener(l:(data:any) => void, p?:(data:any) => boolean):void;
/**
* Write the element `data` with key `k` into the cache.
*
* @param k - data key
* @param data - data value
* @returns the written data value
*/
write(k:any, data:any):any;
/**
* Same as forEach but applied, for each key, only to the first `n` samples of the cache
*
* @param f - the function to be applied
* @param n - samples set size
*/
forEachN(f:(data:any) => any, n:number):any[];
/**
* Execute the function `f` for each element of the cache.
*
* @memberof! dds.DataCache#
* @param f - the function to be applied
* @returns results of the function execution
*/
forEach(f:(data:any) => any):any[];
/**
* Returns a cache that is the result of applying `f` to each element of the cache.
*
* @param f - the function to be applied
* @returns A cache holding the results of the function execution
*/
map(f:(data:any) => any):DataCache;
/**
* Returns the list of elements in the cache that satisfy the predicate `f`.
*
* @param f - the predicate to be applied to filter the cache values
* @returns An array holding the filtered values
*/
filter(f:(data:any) => boolean):any[];
/**
* Returns the list of elements in the cache that doesn't satisfy the predicate `f`.
*
* @returns An array holding the filtered values
* @see DataCache#filter
*/
filterNot(f:(data:any) => boolean):any[];
/**
* Returns the values included in the cache as an array.
*
* @return All the cache values
*/
read():any[];
/**
* Returns the last value of the cache in an array.
*
* @return the last value of the cache
*/
readLast():any;
/**
* Returns all the values included in the cache as an array and empties the cache.
*
* @return All the cache values
*/
takeAll():any[];
/**
* Returns the `K`ith value of the cache as Monad, ie: `coffez.Some` if it exists, `coffez.None` if not.
*
* @return the 'k'th value
*/
take():any;
/**
* Takes elements from the cache up to when the predicate `f` is satisfied
*
* @param f - the predicate
* @return taken cache values
*/
takeWithFilter(f:(data:any) => boolean):any[];
/**
* Return `coffez.Some(v)` if there is an element in the cache corresponding to the
* key `k` otherwise it returns `coffez.None`.
*
* @param k - key
*/
get(k:any):any;
/**
* Return `coffez.Some(v)` if there is an element in the cache corresponding to the
* key `k` otherwise executes `f` and returns its result.
*
* @param k - key
* @param f - the function to apply
*/
getOrElse(k:any, f:(data:any)=> any):any;
/**
* folds the element of the cache using `z` as the `zero` element and
* `f` as the binary operator.
*
* @param z - initial value
* @param {function} f - reduce function
*/
fold(z:any, f:(data:any) => any):void;
/**
* clears the data cache
*/
clear():void;
}
interface Runtime {
/**
* Constructs a DDS Runtime object
*
* maintains the connection with the server, re-establish the connection
* if dropped and mediates the `DataReader` and `DataWriter` communication.
*/
new (): Runtime;
/**
* Connect the runtime to the server. If the runtime is already connected an exception is thrown
*
* @param srv - Vortex Web server WebSocket URL
* @param authToken - Authorization token
*/
connect(server:string, authToken?:string): void;
/**
* Disconnects, withouth closing, a `Runtime`. Notice that upon re-connection all existing
* subscriptions and publications will be re-restablished.
*/
disconnect(): void;
/**
* Registers the provided Topic.
*
* @param t - Topic to be registered
*/
registerTopic(t:Topic): void;
/**
* Function called when runtime is connected.
*
* @param e
*/
onconnect(e:any): void;
/**
* Function called when runtime is disconnected.
*
* @param e
*/
ondisconnect(e:any): void;
/**
* Closes the DDS runtime and as a consequence all the `DataReaders` and `DataWriters` that belong to this runtime.
*
*/
close(): void;
/**
* Checks whether the Runtime is connected.
* @return `true` if connected, `false` if not
*/
isConnected() : boolean;
/**
* Checks whether the Runtime is closed.
* @return `true` if connected, `false` if not
*/
isClosed() : boolean;
}
export var runtime:{
Runtime : Runtime;
};
export var VERSION:string;
}
/**
* Defines the core Vortex-Web-Client javascript library. It includes the JavaScript API for DDS. This API allows
* web applications to share data among them as well as with native DDS applications.
*/
declare var dds:typeof DDS;