| /******************************************************************************* |
| * Copyright (c) 2004-2008 Andras Schmidt, Andras Balogh, Istvan Rath and Daniel Varro |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Andras Schmidt, Andras Balogh, Istvan Rath - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.viatra2.natives; |
| |
| import org.eclipse.viatra2.core.IModelSpace; |
| import org.eclipse.viatra2.errors.VPMRuntimeException; |
| import org.eclipse.viatra2.natives.NativeFunctionParameter.ParameterType; |
| |
| /** |
| * Native function to retrieve the current system time. |
| * |
| * @author istvan |
| * |
| */ |
| @VIATRANativeFunction(name = "systime", remark = "Returns a truncated systime to fit into a 32-bit integer. First 4 digits are dropped.", params = {}, returns = { ParameterType.STRING }) |
| public class SysTimeFunction implements ASMNativeFunction { |
| |
| public Object evaluate(IModelSpace msp, Object[] params) |
| throws VPMRuntimeException { |
| return new Integer(Long.toString(System.currentTimeMillis()).substring( |
| 4)); |
| } |
| |
| public String getDescription() { |
| return "The current system time in milliseconds (with first 4 digits dropped)."; |
| } |
| |
| public String getID() { |
| return this.getClass().getCanonicalName(); |
| } |
| |
| public String getName() { |
| return "systime"; // ez megy a VTCLbe
|
| } |
| |
| } |