/
bic.sarl
733 lines (661 loc) · 25.6 KB
/
bic.sarl
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
/*
* $Id$
*
* SARL is an general-purpose agent programming language.
* More details on http://www.sarl.io
*
* Copyright (C) 2014-2016 the original authors or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.sarl.core
import java.text.MessageFormat
import java.util.UUID
import java.util.concurrent.TimeUnit
import io.sarl.core.AgentTask
import io.sarl.lang.core.EventSpace
import io.sarl.lang.core.Address
import io.sarl.lang.core.Agent
import io.sarl.lang.core.AgentContext
import io.sarl.lang.core.Behavior
import io.sarl.lang.core.Event
import io.sarl.lang.core.EventListener
import io.sarl.lang.core.Scope
import io.sarl.lang.core.Space
import io.sarl.lang.core.SpaceID
import io.sarl.lang.util.SynchronizedCollection
import io.sarl.lang.util.SynchronizedSet
/**
* Provides functions for accessing and managing the external contexts of an agent.
*/
capacity ExternalContextAccess {
/**
* Replies all contexts this agent is a member of, including the default context.
*
* @return the list of the agent contexts.
*/
@Pure
def getAllContexts : SynchronizedCollection<AgentContext>
/**
* Replies the AgentContext for the given ID.
* The agent must have joined the context before calling this action or use its parentContextID
*
* @param contextID the ID of the context to get.
* @return the agent context instance.
* @throws UnknownContextException if the context specified context is not known by the agent.
* @see io.sarl.lang.core.Agent#getParentID
* @see #join
*/
@Pure
def getContext(contextID : UUID): AgentContext
/**
* Joins a new parent context (a new super holon).
* <p>
* The agent will be involved in the context with the ID given by <var>contextID</var>.
* The parameter <var>expectedDefaultSpaceID</var> is only used to check if
* the caller of this function knows the ID of the default space in the context to
* be involved in. Note that the context must already exists, and the default space
* inside this context must have the sams ID as <var>expectedDefaultSpaceID</var>.
* If the given <var>expectedDefaultSpaceID</var> does not match the ID of the
* default space in the context <var>contextID</var>, then the access to the context
* is forbidden.
*
* <p>This actions registers the agent in the default Space of the context with the
* ID <var>contextID</var>.
*
* @param contextID the identifier of the context to join.
* @param expectedDefaultSpaceID the known identifier of the default space in the agent context with the given identifier.
* @fires ContextJoined in its inner Context default space (Behaviors#wake).
* @fires MemberJoined in its parent Context default Space
*/
def join(contextID : UUID, expectedDefaultSpaceID : UUID) fires ContextJoined, MemberJoined
/**
* Leaves the parent's context.
*
* @param contextID the identifier of the context to leave.
* @fires ContextLeft in its inner Context default space (Behaviors#wake).
* @fires MemberLeft in its parent Context default Space
*/
def leave(contextID : UUID) fires ContextLeft, MemberLeft
/** Replies if the given event was emitted in the given space.
*
* @param event the event to test.
* @param space the space in which the event may be.
* @return <code>true</code> if the given event was emitted in the
* given space. Otherwise <code>false</code>.
* @since 0.2
*/
@Pure
def isInSpace(^event : Event, ^space : Space) : boolean
/** Replies if the given event was emitted in the space with
* the given identifier..
*
* @param event - the event to test.
* @param spaceID - the identifier of the space in which the event may be.
* @return <code>true</code> if the given event was emitted in the
* space with the given identifier. Otherwise <code>false</code>.
* @since 0.2
*/
@Pure
def isInSpace(^event : Event, spaceID : SpaceID) : boolean
/** Replies if the given event was emitted in the space with
* the given identifier..
*
* @param event - the event to test.
* @param spaceID - the identifier of the space in which the event may be.
* @return <code>true</code> if the given event was emitted in the
* space with the given identifier. Otherwise <code>false</code>.
* @since 0.2
*/
@Pure
def isInSpace(^event : Event, spaceID : UUID) : boolean
}
/**
* Provides functions for accessing and managing the internal contexts of an agent.
*/
capacity InnerContextAccess {
/** Replies the inner context.
*
* @return the instanceof the internal agent context.
*/
@Pure
def getInnerContext : AgentContext
/** Replies if the calling agent has other agents
* as members of its inner context.
* A member agent is an agent which is not the
* calling agent, and is a member of at least
* one space of the inner context.
*
* @return <code>true</code> if the current agent has other agents as member of its internal context; otherwise <code>false</code>
*/
@Pure
def hasMemberAgent : boolean
/** Replies the number of agents that are members
* of the inner context of the calling agent.
* A member agent is an agent which is not the
* calling agent, and is a member of at least
* one space of the inner context.
*
* <p>The replied number includes the current agent. Indeed, the current agent is member of its internal context with the role of super-holon.
*
* @return the number of members in the internal context of the current agent.
*/
@Pure
def getMemberAgentCount : int
/**
* Replies all the member agents in the inner context.
* A member agent is an agent which is not the
* calling agent, and is a member of at least
* one space of the inner context.
*
* @return the identifiers of the members of the internal context of the current agent.
*/
@Pure
def getMemberAgents : SynchronizedSet<UUID>
/** Replies if the given space is the default space of the inner context.
*
* @param space the space to test.
* @return <code>true</code> if the given space is the default space of
* the inner context. Otherwise <code>false</code>.
* @since 0.2
*/
@Pure
def isInnerDefaultSpace(^space : Space) : boolean
/** Replies if the given identifier is the identifier of the
* default space of the inner context.
*
* @param spaceID - the identifier to test.
* @return <code>true</code> if the given identifier is the identifier
* of the default space of the inner context. Otherwise <code>false</code>.
* @since 0.2
*/
@Pure
def isInnerDefaultSpace(spaceID : SpaceID) : boolean
/** Replies if the given identifier is the identifier of the
* default space of the inner context.
*
* @param spaceID - the identifier to test.
* @return <code>true</code> if the given identifier is the identifier
* of the default space of the inner context. Otherwise <code>false</code>.
* @since 0.2
*/
@Pure
def isInnerDefaultSpace(spaceID : UUID) : boolean
/** Replies if the given event was emitted in the default space
* of the inner context.
*
* @param event - the event to test.
* @return <code>true</code> if the given event was emitted
* in the default space of the inner context. Otherwise <code>false</code>.
* @since 0.2
*/
@Pure
def isInInnerDefaultSpace(^event : Event) : boolean
}
/**
* Agent behaviors management.
*/
capacity Behaviors {
/**
* Register a Behavior for the owner agent.
* The new Behavior will react to all declared events received by the agent.
*
* @param attitude the behavior to add to the agent.
* @return the given behavior.
*/
def registerBehavior(attitude : Behavior) : Behavior
/**
* Unregisters a behavior for the owner agent.
*
* @param attitude the behavior to remove to the agent.
* @return the given behavior.
*/
def unregisterBehavior(attitude : Behavior) : Behavior
/**
* Wake the agent's behaviors reacting to the Event evt.
*
* @param event the event to emit to the agent's behaviors and in the internal context.
*/
def wake(^event : Event)
/**
* Replies the interface to dispatch an event to agent's Behaviors.
*
* @return the event listener.
*/
@Pure
def asEventListener : EventListener
}
/**
* Lifecycle related actions.
*/
capacity Lifecycle {
/**
* Spawns a new member agent in the parent's context (parentID).
*
* @param agentClass the type of the agent to spawn.
* @param context the context in which the agent must be spawned.
* @param params the arguments to pass to the initialization event that will be sent to the spawned agent.
* @return the identifier of the spawned agent.
* @fires AgentSpawned inside the default context of the parent. The source of the event is this agent.
*/
def spawnInContext(agentClass : Class <? extends Agent>, context : AgentContext, params : Object*) : UUID fires AgentSpawned
/**
* Spawns a new member agent in the parent's context (parentID).
*
* @param agentClass the type of the agent to spawn.
* @param agentID the identifier of the spawned agent.
* @param context the context in which the agent must be spawned.
* @param params the arguments to pass to the initialization event that will be sent to the spawned agent.
* @return the given identifier.
* @fires AgentSpawned inside the default context of the parent. The source of the event is this agent.
*/
def spawnInContextWithID(agentClass : Class <? extends Agent>, agentID : UUID, context : AgentContext, params : Object*) : UUID fires AgentSpawned
/**
* Kills this agent.
*
* <p>This action must automatically unregister this agent from the default context
* and therefore all its spaces including the DefaultSpace.
* If this is a composable agent, it must not have any members before calling this action.
* Otherwise a RuntimeException will be thrown.
*
* @fires AgentKilled in DefaultSpace of all Contexts to which this agent belongs
* @fires Destroy inside the agent
*/
def killMe fires AgentKilled, Destroy
}
/**
* Schedules actions in time.
*/
capacity Schedules {
/**
* Schedule a given task to be executed after the specified delay.
*
* <p>The given procedure takes one parameter: the agent associated to the task. It is name <code>it</code> by default.
*
* @param task the task that will run the given closure. If <code>null</code>, a new task is created.
* @param delay time in milliseconds to delay the procedure execution.
* @param procedure the closure to execute.
* @return the generated task.
*/
def in(task : AgentTask = null, delay : long, procedure : (Agent) => void) : AgentTask
/**
* Create a named task that can be retrieved and schedule later.
* If a task with the specified name already exists, this task is returned.
*
* @param name the name of the tash.
* @return the task instance.
*/
def task(name : String) : AgentTask
/**
* Attempts to cancel execution of this task. This attempt will
* fail if the task has already completed, has already been cancelled,
* or could not be cancelled for some other reason. If successful,
* and this task has not started when <code>cancel</code> is called,
* this task should never run. If the task has already started,
* then the <code>mayInterruptIfRunning</code> parameter determines
* whether the thread executing this task should be interrupted in
* an attempt to stop the task.
*
* @param task the task to cancel.
* @param mayInterruptIfRunning <code>true</code> if the thread executing this
* task should be interrupted; otherwise, in-progress tasks are allowed
* to complete
* @return <code>false</code> if the task could not be cancelled,
* typically because it has already completed normally;
* <code>true</code> otherwise
*/
def cancel(task : AgentTask, mayInterruptIfRunning : boolean = true) : boolean
/**
* Schedule a periodic execution of the given task.
*
* <p>If the duration of the task is greater to the given period length, then
* multiple task's instances will be run in parallel, in opposite to the
* {@code atFixedDelay()} function.
* For example, consider the following code:
* <pre><code>
* every(500) [ sleep(2000) ]
* </code></pre>
* At a given time, 4 instances (A, B, C, D) of the task may be run in parallel:
* <pre><code>
* t=0 0500 1000 1500 2000 2500 3000 3500 4000 4500
* | | | | | | | | | |
* [-A-----------------------]
* [-B-------------------------]
* [-C-------------------------]
* [-D-------------------------]
* [-E-------------------------]
* [-F-------------------------]
* </code></pre>
* For executing a task with a fixed delay between the runs, and not at a fixed rate,
* you should use the {@code atFixedDelay()} function.
*
* <p>The given procedure takes one parameter: the agent associated to the task. It is name <code>it</code> by default.
*
* @param task the task to associate to the procedure. If <code>null</code> a new task is created.
* @param period the number of milliseconds between two launches of the given procedure.
* @param procedure the procedure to launch. The parameter of the procedure is the agent.
* @return the given task.
*/
def every(task : AgentTask = null, period : long, procedure : (Agent) => void ) : AgentTask
/**
* Schedule a single-execution task.
*
* <p>If the duration of the task is greater to the given delay length, then
* no multiple task's instance are run in parallel, in opposite to the
* {@code every()} function.
* For example, consider the following code:
* <pre><code>
* atFixedDelay(500) [ sleep(2000) ]
* </code></pre>
* At a given time, 3 instances (A, B, C) of the task are run in sequence, and
* each run is separated by 500 milliseconds:
* <pre><code>
* t=0 0500 1000 1500 2000 2500 3000 3500 4000 4500 5000
* | | | | | | | | | | |
* [-A-----------------------]
* [-B-------------------------]
* [-C-------------------------]
* </code></pre>
* For executing a task with a fixed rate, and not with a fixed delay between the task runs,
* you should use the {@code every()} function.
*
* <p>The given procedure takes one parameter: the agent associated to the task. It is name <code>it</code> by default.
*
* <p>It is recommended that the SRAL run-time environment, which is providing the implementation
* of this function to provide an efficient implementation in the case the argument
* {@code delay} is equal to zero. Indeed, if the {@code delay} is equal to zero, the task
* should be run in an infinite loop until it is canceled, or the owning agent is killed.
*
* @param task the task to associate to the procedure. If <code>null</code> a new task is created.
* @param procedure the procedure to launch. The parameter of the procedure is the agent.
* @return the given task.
* @since 0.5
*/
def atFixedDelay(task : AgentTask = null, delay : long, procedure : (Agent) => void ) : AgentTask
/**
* Schedule a single-execution task.
*
* <p>This function is the easy to use version and efficient implementation of the code
* {@code in(0) [statements]}.
*
* <p>The given procedure takes one parameter: the agent associated to the task. It is name <code>it</code> by default.
*
* @param task the task to associate to the procedure. If <code>null</code> a new task is created.
* @param procedure the procedure to launch. The parameter of the procedure is the agent.
* @return the given task.
* @since 0.5
*/
def execute(task : AgentTask = null, procedure : (Agent) => void ) : AgentTask
}
/**
* Gives access to the DefaultContext of the agent and common actions on its default space.
* Defines a set of commonly accessed action performed on the Default Space
* of the Default Context of the agent.
*/
capacity DefaultContextInteractions {
/**
* Returns the Default context fo the agent.
*
* @return the default context.
*/
@Pure
def getDefaultContext : AgentContext
/**
* Returns the Default Space of the Default Context.
* Equivalent to <code>defaultContext.defaultSpace</code>.
*
* @return the default event space.
*/
@Pure
def getDefaultSpace : EventSpace
/**
* Return the Address of the agent in the Default Space of the Default Context.
* Equivalent to <code>defaultContext.defaultSpace.getAddress(this.ID)</code>
*
* @return the address of the agent in the default space.
*/
@Pure
def getDefaultAddress : Address
/**
* Emits a given event with the provided scope in the DefaultSpace of the DefaultContext.
* Equivalent to <code>defaultContext.defaultSpace.emit(e,scope)</code>
*
* @param event the event to emit.
* @param scope the definition of the scope that will be used for selected the receivers of the events. If <code>null</code>, all the agents in the space will receive the event.
*/
def emit(^event : Event, scope : Scope<Address> = null)
/**
* Inverse signature of send. Useful to send events using the agent's UUID.
* Example:
* If you need to send an event to a newly created agent you should usually do :
* <code>
* ...
* const mySpawnArgs = ...
* const myAgentAddr = MyAgent.spawn(mySpawnArgs)
* defaultSpace.emit(new StartWorkingEvent, AddressScope::scope(myAgentAddr)
* </code>
* The equivalent using receive could be written:
* <code>
* ...
* MyAgent.spawn(mySpawnArgs).receive(new StartWorkingEvent)
* </code>
*
* @param receiver the identifier of the expected receiver.
* @param event the event to emit.
* @deprecated see #UUID, Event)
*/
@Deprecated
@Inline(value = "willReceive($1, $2)")
def receive(receiver : UUID, ^event : Event)
/**
* Inverse signature of send. Useful to send events using the agent's UUID.
* Example:
* If you need to send an event to a newly created agent you should usually do :
* <code>
* ...
* const mySpawnArgs = ...
* const myAgentAddr = MyAgent.spawn(mySpawnArgs)
* defaultSpace.emit(new StartWorkingEvent, AddressScope::scope(myAgentAddr)
* </code>
* <p>The equivalent using receive could be written:
* <code>
* ...
* MyAgent.spawn(mySpawnArgs).willReceive(new StartWorkingEvent)
* </code>
*
* @param receiver the identifier of the expected receiver.
* @param event the event to emit.
* @since 0.4
*/
def willReceive(receiver : UUID, ^event : Event)
/** Replies if the given space is the default space of the default context.
*
* @param space the space to test.
* @return <code>true</code> if the given space is the default space of
* the default context. Otherwise <code>false</code>.
* @since 0.2
*/
@Pure
def isDefaultSpace(^space : Space) : boolean
/** Replies if the given identifier is the identifier of the default space of
* the default context.
*
* @param space the space to test.
* @return <code>true</code> if the given identifier is the identifier
* of the default space of the default context. Otherwise <code>false</code>.
* @since 0.2
*/
@Pure
def isDefaultSpace(^space : SpaceID) : boolean
/** Replies if the given identifier is the identifier of the default space of
* the default context.
*
* @param space the space to test.
* @return <code>true</code> if the given identifier is the identifier
* of the default space of the default context. Otherwise <code>false</code>.
* @since 0.2
*/
@Pure
def isDefaultSpace(^space : UUID) : boolean
/** Replies if the given event was emitted in the default space of
* the default context.
*
* @param event the event to test.
* @return <code>true</code> if the given event is emitted in the default
* space of the default context. Otherwise <code>false</code>.
* @since 0.2
*/
@Pure
def isInDefaultSpace(^event : Event) : boolean
/** Replies if the given context is the default context.
*
* @param context the agent context to test.
* @return <code>true</code> if the given context is the default context.
* Otherwise <code>false</code>.
* @since 0.2
*/
@Pure
def isDefaultContext(context : AgentContext) : boolean
/** Replies if the given identifier is the identifier of the default context.
*
* @param contextID the identifier of the context.
* @return <code>true</code> if the given identifier is the identifier
* of the default context. Otherwise <code>false</code>.
* @since 0.2
*/
@Pure
def isDefaultContext(contextID : UUID) : boolean
//Agent Creation
/**
* Spawns a new Agent inside the default context of this agent.
* This action must automatically register the newly created agent
* within the default space of the context.
*
* @param agentType the type of the agent to spawn.
* @param params the arguments to pass in the initialization event to the spawned agent.
* @return the identifier of the spawned agent.
* @fires AgentSpawned in DefaultSpace
*/
def spawn(agentType : Class<? extends Agent>, params : Object*) : UUID fires AgentSpawned
}
/**
* Gives access to the logging mechanism associated to the agent.
*/
capacity Logging {
/** Change the name used for logging.
*
* @param name - the name used for logging.
*/
def setLoggingName(name : String)
/** Print the given message at information logging level.
* <p>
* <strong>This function is deprecated.</strong> Please use
* {@link #info(Object,Object...)} in place of <code>println</code>.
*
* @param message - the elements to display.
* @deprecated Use {@link #info(Object,Object...)}.
*/
@Deprecated
def println(message : Object)
/** Print the given message at error logging level.
*
* @param message - the elements to display. The format of the message must follow {@link MessageFormat}.
* @param exception - the exception that is the cause of the error.
* @param parameters - the values to dynamically insert into the message.
*/
def error(message : Object, exception : Throwable=null, parameters : Object*)
/** Print the given message at warning logging level.
*
* @param message - the elements to display. The format of the message must follow {@link MessageFormat}.
* @param exception - the exception that is the cause of the error.
* @param parameters - the values to dynamically insert into the message.
*/
def warning(message : Object, exception : Throwable=null, parameters : Object*)
/** Print the given message at information logging level.
*
* @param message - the elements to display. The format of the message must follow {@link MessageFormat}.
* @param parameters - the values to dynamically insert into the message.
*/
def info(message : Object, parameters : Object*)
/** Print the given message at debug logging level.
*
* @param message - the elements to display. The format of the message must follow {@link MessageFormat}.
* @param parameters - the values to dynamically insert into the message.
*/
def debug(message : Object, parameters : Object*)
/** Replies if the logging system is displaying the errors.
*
* @return <code>true</code> if the errors are logged,
* <code>false</code> if not.
*/
@Pure
def isErrorLogEnabled : boolean
/** Replies if the logging system is displaying the warnings.
*
* @return <code>true</code> if the warnings are logged,
* <code>false</code> if not.
*/
@Pure
def isWarningLogEnabled : boolean
/** Replies if the logging system is displaying the information messages.
*
* @return <code>true</code> if the information messages are logged,
* <code>false</code> if not.
*/
@Pure
def isInfoLogEnabled : boolean
/** Replies if the logging system is displaying the debugging messages.
*
* @return <code>true</code> if the debugging messages are logged,
* <code>false</code> if not.
*/
@Pure
def isDebugLogEnabled : boolean
/** Replies the logging level.
*
* @return <code>0</code> for no logging, <code>1</code> for error,
* <code>2</code> for warning, <code>3</code> for info,
* <code>5</code> for debug.
*/
@Pure
def getLogLevel : int
/** Set the logging level.
*
* @param level - <code>0</code> for no logging, <code>1</code> for error,
* <code>2</code> for warning, <code>3</code> for info,
* <code>5</code> for debug.
*/
def setLogLevel(level : int)
}
/**
* Gives access to the time in the agent application.
* Time management is application-dependent. This capacity does not make any assumption
* on neither time evolution nor time refresh rate.
*/
capacity Time {
/** Replies the current time.
*
* @param timeUnit if present, specifies the time unit of the value to reply. By default is it seconds.
* @return the current time.
*/
def getTime(timeUnit : TimeUnit = null) : double
/** Replies the scaling factor between the agent time and the operating system time.
* <p>Consider time in the agent application. It may evolves at a different rate than
* the operating system time. The value that is replied by this function permits to
* determine the proportionally between the agent application time and the operating system time.
* A typical equation for representing this relation is: os time = OSTimeFactor * agent time.
*
* @return the factor between agent time and operating system time.
*/
def getOSTimeFactor : double
}