diff --git a/femto_st.gama.mpi/META-INF/MANIFEST.MF b/femto_st.gama.mpi/META-INF/MANIFEST.MF index 343c3301..b19a8d28 100644 --- a/femto_st.gama.mpi/META-INF/MANIFEST.MF +++ b/femto_st.gama.mpi/META-INF/MANIFEST.MF @@ -12,4 +12,3 @@ Require-Bundle: msi.gama.core, ummisco.gama.network Bundle-ClassPath: ext/mpi.jar, . -Import-Package: ummisco.gama.serializer.factory diff --git a/ummisco.gama.extension.hecras/src/ummisco/gama/extension/hecras/skill/Program.java b/ummisco.gama.extension.hecras/src/ummisco/gama/extension/hecras/skill/Program.java deleted file mode 100644 index dfdd48f4..00000000 --- a/ummisco.gama.extension.hecras/src/ummisco/gama/extension/hecras/skill/Program.java +++ /dev/null @@ -1,117 +0,0 @@ -package ummisco.gama.extension.hecras.skill; - -/** - * @author Pavel Savara (original) - */ -public class Program { - /* - public native void CreateDfs0File(String string, boolean calendarAxis); - - public interface HECRASController extends Library { - @SuppressWarnings("deprecation") - HECRASController INSTANCE = (HECRASController) Native.loadLibrary( - (Platform.isWindows() ? "RAS506" : "AS506LinuxPort"), HECRASController.class); - // it's possible to check the platform on which program runs, for example purposes we assume that there's a linux port of the library (it's not attached to the downloadable project) -// byte giveVoidPtrGetChar(Pointer param); // char giveVoidPtrGetChar(void* param); -// int giveVoidPtrGetInt(Pointer param); //int giveVoidPtrGetInt(void* param); - void Compute_ShowComputationWindow(String a); // int giveIntGetInt(int a); - } - public static void main(String[] args) { - - String env = System.getProperty("java.library.path"); -// if (!env.contains("jri")) { -// final String RPath = GamaPreferences.External.LIB_R.value(scope).getPath(scope).replace("libjri.jnilib", "") -// .replace("libjri.so", "").replace("jri.dll", ""); - final String RPath = "E:\\git\\gama.experimental\\ummisco.gama.extension.hecras\\lib"; -// if (System.getProperty("os.name").startsWith("Windows")) { - System.setProperty("java.library.path", RPath + ";" + env); -// } - System.loadLibrary("RAS506"); - Field fieldSysPath; - try { - fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths"); - fieldSysPath.setAccessible( true ); - fieldSysPath.set( null, null ); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - HECRASController sdll = HECRASController.INSTANCE; - - - int a = 3; - sdll.Compute_ShowComputationWindow(""); // calling function with int parameter&result - -// try { -// -// JISystem.getLogger().setLevel(Level.FINEST); -// JISession session = JISession.createSession("localhost", "hqnghi88@hotmail.com", "ngan2105"); -// session.useSessionSecurity(true); -// JIProgId pid = JIProgId.valueOf("RAS506.HECRASController"); -// pid.setAutoRegistration(true); -// JIComServer comStub = null; -// try { -// comStub = new JIComServer(pid, "localhost", session); -// } catch (UnknownHostException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// IJIComObject unknown = comStub.createInstance(); -// IJIDispatch dispatch = (IJIDispatch) JIObjectFactory.narrowObject(unknown.queryInterface(IJIDispatch.IID)); -// // File filePath = new -// // File("F:\\Archivio\\Clienti\\CFD\\Aggiornamento\\xSalari\\Modelli_HEC_RT\\RAS\\Tevere\\Tevere.prj"); -// File filePath = new File( -// "C:\\HEC Data\\HEC-RAS\\Example Data\\2D Unsteady Flow Hydraulics\\Muncie\\Muncie.prj"); -// if (!filePath.exists()) { -// System.out.println(filePath + " file does not exist"); -// return; -// } -// JIString JIfilePath = new JIString(filePath.getAbsolutePath()); -// dispatch.callMethod("Project_Open", new JIString[] { JIfilePath }); -// // Integer[] a = new Integer[1]; -// JIVariant nmsg = new JIVariant(0, true); -// JIString[] strs = new JIString[1]; -// Arrays.fill(strs, new JIString("1")); -// JIVariant msg = new JIVariant(new JIArray(strs, true), true); -// dispatch.callMethod("Compute_CurrentPlan", new JIVariant[] { nmsg, msg }); -// } catch (JIException ex) { -// ex.printStackTrace(); -// } - // create bridge, with default setup - // it will lookup jni4net.n.dll next to jni4net.j.jar -// Bridge.setVerbose(true); -// Bridge.init(); -// Bridge.LoadAndRegisterAssemblyFrom(new File("D:\\AAa\\DHI.Generic.hecrasZero.DFS.dll")); -// -// // here you go! -// Console.WriteLine("Hello .NET world!\n"); -// Program p=new Program(); -// p.CreateDfs0File("", true); - // OK, simple hello is boring, let's play with System.Environment - // they are Hashtable realy -// final IDictionary variables = system.Environment.GetEnvironmentVariables(); -// // let's enumerate all keys -// final IEnumerator keys = variables.getKeys().GetEnumerator(); -// while (keys.MoveNext()) { -// // there hash table is not generic and returns system.Object -// // but we know is should be system.String, so we could cast -// final system.String key = (system.String) keys.getCurrent(); -// Console.Write(key); -// -// // this is automatic conversion of JVM string to system.String -// Console.Write(" : "); -// -// // we use the hashtable -// Object value = variables.getItem(key); -// -// // and this is JVM toString() redirected to CLR ToString() method -// String valueToString = value.toString(); -// Console.WriteLine(valueToString); -// } -// -// // Console output is really TextWriter on stream -// final TextWriter writer = Console.getOut(); -// writer.Flush(); - } - */ -} \ No newline at end of file diff --git a/ummisco.gama.extension.hecras/src/ummisco/gama/extension/hecras/skill/ReadDLL.java b/ummisco.gama.extension.hecras/src/ummisco/gama/extension/hecras/skill/ReadDLL.java deleted file mode 100644 index 62443ad7..00000000 --- a/ummisco.gama.extension.hecras/src/ummisco/gama/extension/hecras/skill/ReadDLL.java +++ /dev/null @@ -1,133 +0,0 @@ -package ummisco.gama.extension.hecras.skill; - -//import com.jacob.activeX.*; -//import com.jacob.com.*; -/** - * This class uses the the Jacob tech - * to use and interact with a Com cmponent - * in a java application - */ -public class ReadDLL { -// public static void main(String[] args) { -// /** -// * `System.getProperty("os.arch")` -// * It'll tell us on which platform Java Program is executing. Based on that we'll load respective DLL file. -// * Placed under same folder of program file(.java/.class). -// */ -//// String libFile = System.getProperty("os.arch").equals("amd64") ? "jacob-1.17-x64.dll" : "jacob-1.17-x86.dll"; -// String libFile="E:\\git\\gama.experimental\\ummisco.gama.extension.hecras\\lib\\jacob-1.19\\jacob-1.19-x64.dll"; -// try { -// /* Read DLL file*/ -//// InputStream inputStream = ReadDLL.class.getResourceAsStream(libFile); -//// /** -//// * Step 1: Create temporary file under <%user.home%>\AppData\Local\Temp\jacob.dll -//// * Step 2: Write contents of `inputStream` to that temporary file. -//// */ -//// File temporaryDll = File.createTempFile("jacob", ".dll"); -//// FileOutputStream outputStream = new FileOutputStream(temporaryDll); -//// byte[] array = new byte[8192]; -//// for (int i = inputStream.read(array); i != -1; i = inputStream.read(array)) { -//// outputStream.write(array, 0, i); -//// } -//// outputStream.close(); -// /** -// * `System.setProperty(LibraryLoader.JACOB_DLL_PATH, temporaryDll.getAbsolutePath());` -// * Set System property same like setting java home path in system. -// * -// * `LibraryLoader.loadJacobLibrary();` -// * Load JACOB library in current System. -// */ -// System.setProperty(LibraryLoader.JACOB_DLL_PATH, libFile); -// LibraryLoader.loadJacobLibrary(); -// -// /** -// * Create ActiveXComponent using CLSID. You can also use program id here. -// * Next line(commented line/compProgramID) shows you how you can create ActiveXComponent using ProgramID. -// */ -//// ActiveXComponent compCLSID = new ActiveXComponent("clsid:{00024500-0000-0000-C000-000000000046}"); -// /*ActiveXComponent compProgramID = new ActiveXComponent("Excel.Application");*/ -// ActiveXComponent compCLSID = new ActiveXComponent("RAS506.HECRASController"); -// -// System.out.println("The Library been loaded, and an activeX component been created"); -// -// /** -// * This is function/method of Microsoft Excel to use it with COM bridge. -// * Excel methods and its use can be found on -// * http://msdn.microsoft.com/en-us/library/bb179167(v=office.12).aspx -// * -// * Understand code: -// * 1. Make Excel visible -// * 2. Get workbook of excel object. -// * 3. Open 1test.xls1 file in excel -// */ -// -//// for(int i=0; i<100; i++) { -//// System.out.println(i); -//// System.out.println(); -// try { -// Dispatch.call(compCLSID, "Project_Open", new Variant("E:\\Downloads\\HWC\\HelloWorldCoupling.prj")); -// SafeArray sa = new SafeArray(Variant.VariantString, 1); -//// sa.setString(1, "null"); -// SafeArray sa1 = new SafeArray(Variant.VariantLongInt, 1); -// sa1.setLong(1, 0); -//// sa.setString(0, "Unsteady Flow 01"); -// Variant pData= new Variant(Variant.VariantPointer,true); -// pData.putLong(1); -// Variant vn = new Variant(Variant.VariantArray,true); -// vn.putSafeArrayRef(sa); -//// Variant vsvs=new Variant(new String[] {}); -// -// Variant res=Dispatch.call(compCLSID, "Plan_GetFilename", new Variant("Plan 04")); -// System.out.println(res); -// Variant optional = new Variant(); -// -// Dispatch.call(compCLSID, "Compute_CurrentPlan",pData, vn); -// }catch(Exception ex){ex.printStackTrace();} -// finally { -// Dispatch.call(compCLSID, "QuitRas"); -// System.out.println("closed"); -// } -// -//// } -// -// -//// Dispatch.put(compCLSID, "Visible", new Variant(true)); -//// Dispatch workbook = compCLSID.getProperty("Workbooks").toDispatch(); -//// Dispatch.call(workbook, "Open", new Variant("D:\\test\\test.xls")); -// -// /* Temporary file will be removed after terminating-closing-ending the application-program */ -//// temporaryDll.deleteOnExit(); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// } - -// public static void main(String[] args){ -// -// //Loading the library: -// ActiveXComponent comp=new ActiveXComponent("Com.Calculation"); -// System.out.println("The Library been loaded, and an activeX component been created"); -// -// int arg1=100; -// int arg2=50; -// //using the functions from the library: -// int summation=Dispatch.call(comp, "sum",arg1,arg2).toInt(); -// System.out.println("Summation= "+ summation); -// -// int subtraction= Dispatch.call(comp,"subtract",arg1,arg2).toInt(); -// System.out.println("Subtraction= "+ subtraction); -// -// int multiplication=Dispatch.call(comp,"multi",arg1,arg2).toInt(); -// System.out.println("Multiplication= "+ multiplication); -// -// double division=Dispatch.call(comp,"div",arg1,arg2).toDouble(); -// System.out.println("Division= "+ division); -// -// /**The following code is abstract of using the get, -// * when the library contains a function that return -// * some kind of a struct, and then get its properties and values -// **/ -//// Dispatch disp=Dispatch.call(comp,"sum",100,10).toDispatch(); -//// DataType Var=Dispatch.get(disp,"Property Name"); -// } -} diff --git a/ummisco.gama.extension.hecras/src/ummisco/gama/extension/hecras/skill/HecRasEngine.java b/ummisco.gama.extension.hecras/src/ummisco/gaml/extensions/hecras/skill/HecRasEngine.java similarity index 98% rename from ummisco.gama.extension.hecras/src/ummisco/gama/extension/hecras/skill/HecRasEngine.java rename to ummisco.gama.extension.hecras/src/ummisco/gaml/extensions/hecras/skill/HecRasEngine.java index d186a90b..58115560 100644 --- a/ummisco.gama.extension.hecras/src/ummisco/gama/extension/hecras/skill/HecRasEngine.java +++ b/ummisco.gama.extension.hecras/src/ummisco/gaml/extensions/hecras/skill/HecRasEngine.java @@ -1,4 +1,4 @@ -package ummisco.gama.extension.hecras.skill; +package ummisco.gaml.extensions.hecras.skill; /* * The contents of this file is dual-licensed under 2 * alternative Open Source/Free licenses: LGPL 2.1 or later and @@ -24,10 +24,8 @@ import java.io.File; import java.io.FileWriter; -import java.io.IOException; import java.lang.reflect.Array; -import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; @@ -38,26 +36,20 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; import com.sun.jna.Pointer; import com.sun.jna.platform.win32.OaIdl.SAFEARRAY; import com.sun.jna.platform.win32.Ole32; -import com.sun.jna.platform.win32.User32; import com.sun.jna.platform.win32.Variant; -import com.sun.jna.platform.win32.WinUser; import com.sun.jna.platform.win32.Variant.VARIANT; import com.sun.jna.platform.win32.Variant.VARIANT.ByReference; import com.sun.jna.platform.win32.WTypes.VARTYPE; -import com.sun.jna.platform.win32.WinDef.HWND; import com.sun.jna.platform.win32.WinDef.LONG; - -import msi.gama.precompiler.doc.utils.XMLElements; -import msi.gama.precompiler.doc.utils.XMLUtils; - import com.sun.jna.platform.win32.COM.COMException; import com.sun.jna.platform.win32.COM.COMLateBindingObject; +import msi.gama.precompiler.doc.utils.XMLUtils; + public class HecRasEngine extends COMLateBindingObject { public static void main(String args[]) { Ole32.INSTANCE.CoInitializeEx(Pointer.NULL, Ole32.COINIT_MULTITHREADED); diff --git a/ummisco.gama.extension.hecras/src/ummisco/gama/extension/hecras/skill/HecRasSkill.java b/ummisco.gama.extension.hecras/src/ummisco/gaml/extensions/hecras/skill/HecRasSkill.java similarity index 97% rename from ummisco.gama.extension.hecras/src/ummisco/gama/extension/hecras/skill/HecRasSkill.java rename to ummisco.gama.extension.hecras/src/ummisco/gaml/extensions/hecras/skill/HecRasSkill.java index 70a33b5a..e4a52cdd 100644 --- a/ummisco.gama.extension.hecras/src/ummisco/gama/extension/hecras/skill/HecRasSkill.java +++ b/ummisco.gama.extension.hecras/src/ummisco/gaml/extensions/hecras/skill/HecRasSkill.java @@ -1,34 +1,26 @@ -package ummisco.gama.extension.hecras.skill; - -import msi.gama.precompiler.GamlAnnotations.doc; -import msi.gama.precompiler.GamlAnnotations.skill; +package ummisco.gaml.extensions.hecras.skill; import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.PrintWriter; import org.apache.commons.lang3.ArrayUtils; import com.sun.jna.Pointer; import com.sun.jna.platform.win32.Ole32; -import com.sun.jna.platform.win32.User32; -import com.sun.jna.platform.win32.WinDef.HWND; import io.jhdf.HdfFile; import io.jhdf.api.Dataset; - -import com.sun.jna.platform.win32.WinUser; - import msi.gama.precompiler.GamlAnnotations.action; import msi.gama.precompiler.GamlAnnotations.arg; +import msi.gama.precompiler.GamlAnnotations.doc; import msi.gama.precompiler.GamlAnnotations.example; -import msi.gaml.types.IType; +import msi.gama.precompiler.GamlAnnotations.skill; import msi.gama.precompiler.IConcept; import msi.gama.runtime.IScope; import msi.gama.runtime.exceptions.GamaRuntimeException; -import msi.gama.util.IList; import msi.gaml.skills.Skill; +import msi.gaml.types.IType; @skill(name = "hecrasSkill", concept = { IConcept.STATISTIC, IConcept.SKILL }) @doc("read hecras data")