Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
see #407 Signed-off-by: Stéphane Galland <galland@arakhne.org>
- Loading branch information
1 parent
bf9c7b3
commit 42bd194
Showing
8 changed files
with
424 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/bic/TimeSkill.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* $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.janusproject.kernel.bic; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.eclipse.xtext.xbase.lib.Inline; | ||
|
||
import io.sarl.core.Time; | ||
import io.sarl.lang.core.Agent; | ||
import io.sarl.lang.scoping.batch.SARLTimeExtensions; | ||
|
||
/** | ||
* Janus implementation of SARL's {@link Time} built-in capacity. | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
*/ | ||
public class TimeSkill extends BuiltinSkill implements Time { | ||
|
||
private static int installationOrder = -1; | ||
|
||
/** | ||
* @param agent - owner of this skill. | ||
*/ | ||
TimeSkill(Agent agent) { | ||
super(agent); | ||
} | ||
|
||
@Override | ||
public int getInstallationOrder() { | ||
if (installationOrder < 0) { | ||
installationOrder = installationOrder(this); | ||
} | ||
return installationOrder; | ||
} | ||
|
||
@Override | ||
public double getTime(TimeUnit timeUnit) { | ||
final double currentTime = System.currentTimeMillis(); | ||
final TimeUnit tu = (timeUnit == null) ? TimeUnit.SECONDS : timeUnit; | ||
return SARLTimeExtensions.convertFromTo(currentTime, TimeUnit.MILLISECONDS, tu); | ||
} | ||
|
||
@Override | ||
@Inline(value = "getTime(null)") | ||
public double getTime() { | ||
return getTime(null); | ||
} | ||
|
||
@Override | ||
public double getOSTimeFactor() { | ||
return 1; | ||
} | ||
|
||
} |
Oops, something went wrong.