Changeset 14046


Ignore:
Timestamp:
11/28/12 17:35:23 (12 years ago)
Author:
ltnguyen
Message:

CHG: Fixed header issue.

Location:
issm/trunk-jpl/src/android/ISSM
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/android/ISSM

    • Property svn:ignore
      •  

        old new  
        1 Makefile.in
        2 Makefile
         1gen
         2.settings
        33libs
        44obj
         5Makefile
         6Makefile.in
  • issm/trunk-jpl/src/android/ISSM/.classpath

    r13890 r14046  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<classpath>
     3        <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
     4        <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    35        <classpathentry kind="src" path="src"/>
    46        <classpathentry kind="src" path="gen"/>
    5         <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    6         <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    77        <classpathentry kind="output" path="bin/classes"/>
    88</classpath>
  • issm/trunk-jpl/src/android/ISSM/AndroidManifest.xml

    r13998 r14046  
    77        android:minSdkVersion="10"
    88        android:targetSdkVersion="15" />
    9 
     9        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    1010    <application
    1111        android:icon="@drawable/ic_launcher"
     
    1616            <intent-filter>
    1717                <action android:name="android.intent.action.MAIN" />
    18 
    19                 <category android:name="android.intent.category.LAUNCHER" />
     18                                <category android:name="android.intent.category.LAUNCHER" />
    2019            </intent-filter>
    2120            </activity>
  • issm/trunk-jpl/src/android/ISSM/bin

    • Property svn:ignore
      •  

        old new  
        1 ISSM.apk
         1*ISSM.apk
        22resources.ap_
        33res
  • issm/trunk-jpl/src/android/ISSM/bin/AndroidManifest.xml

    r13891 r14046  
    55
    66    <uses-sdk
    7         android:minSdkVersion="15"
     7        android:minSdkVersion="10"
    88        android:targetSdkVersion="15" />
    9 
     9        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    1010    <application
    1111        android:icon="@drawable/ic_launcher"
    1212        android:label="@string/app_name"
    1313        android:theme="@style/AppTheme" >
    14         <activity
     14        <activity android:name=".MapSelection"
     15                  android:label="@string/title_activity_issm" >
     16            <intent-filter>
     17                <action android:name="android.intent.action.MAIN" />
     18                                <category android:name="android.intent.category.LAUNCHER" />
     19            </intent-filter>
     20            </activity>
     21            <activity
    1522            android:name=".ISSM"
    1623            android:label="@string/title_activity_issm" >
    17             <intent-filter>
    18                 <action android:name="android.intent.action.MAIN" />
    19 
    20                 <category android:name="android.intent.category.LAUNCHER" />
    21             </intent-filter>
    2224        </activity>
    2325    </application>
  • issm/trunk-jpl/src/android/ISSM/jni/Android.mk

    r13931 r14046  
    1111LOCAL_PATH := $(my_LOCAL_PATH)
    1212LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
    13 LOCAL_CFLAGS := -Wno-psabi
     13LOCAL_CFLAGS := -Wno-psabi -DHAVE_CONFIG_H
    1414LOCAL_LDLIBS := -llog -ldl
    1515LOCAL_MODULE := IssmJni
  • issm/trunk-jpl/src/android/ISSM/jni/Main.cpp

    r13997 r14046  
    11#include <jni.h>
    22#include "../../../c/android/fac.h"
     3#include "../../../c/issm.h"
    34#include <cstddef>
     5#include <stdio.h>
    46///////////////////////////////////////////////////////////////////////////////////////////
    57namespace com_example_issm
    68{
    79        fac* f;
     10        //FemModel *fm;
    811//------------------------------------------------------------------------------------
    9         void initilizeObject(JNIEnv *env, jclass clazz)
     12        jint initilize(JNIEnv *env, jclass clazz, jstring file)
    1013        {
     14                const char *nativefile = env->GetStringUTFChars(file,0);
     15
    1116                f = new fac();
     17
     18                //call Model constructor passing in infile as File Descriptor parameter.
     19                // fm  = new FemModel(nativefile);
     20
     21                env->ReleaseStringUTFChars(file, nativefile); //must realease the char*
     22                //jint size = (jint) fm->bufferSize();
     23                //return size;
     24
     25                return 0; //return 0 for now.
    1226        }
    1327//------------------------------------------------------------------------------------
    1428        //fill out the first two slots, extract the same way in java using get(int position)
    15         void fillBuffer(JNIEnv *env, jclass clazz , jobject buf)
     29        void solve(JNIEnv *env, jclass clazz , jint alpha, jobject buf)
    1630        {
    17                 jdouble *bBuf = (jdouble *)env->GetDirectBufferAddress(buf);
    18                 bBuf[1] = 10.67;
    19                 bBuf[2] = 100.0;
     31                jdouble *dBuf = (jdouble *)env->GetDirectBufferAddress(buf);
     32
     33                //pass bBuff to fem model to allocate data
     34                // fm -> solve(dBuf, alpha);
     35
    2036        }
    2137//------------------------------------------------------------------------------------
     
    3147        {
    3248                        {"fac"          ,     "(J)J"    , (void *) factorial},
    33                         {"initialize"   ,     "()V"     , (void *) initilizeObject},
    34                         {"processBuffer", "(Ljava/nio/DoubleBuffer;)V", (void *) fillBuffer}
     49                        {"createISSMModel"   ,"(Ljava/lang/String;)I"  , (void *) initilize},
     50                        {"processBuffer", "(ILjava/nio/DoubleBuffer;)V", (void *) solve}
    3551        };
    3652}
     
    5571        else return -1;
    5672    }
    57 
    58     // Get jclass with env->FindClass.
    59     // Register methods with env->RegisterNatives.
    6073}
    6174///////////////////////////////////////////////////////////////////////////////////////////
  • issm/trunk-jpl/src/android/ISSM/jni/issmlib/Android.mk

    r14000 r14046  
    33LOCAL_MODULE    := libISSMCore
    44LOCAL_SRC_FILES := libISSMCore.a
    5 LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
    65include $(PREBUILT_STATIC_LIBRARY)
    7 
    8 
    9 #include $(CLEAR_VARS)
    10 #LOCAL_MODULE    := libTestBuffer
    11 #LOCAL_SRC_FILES := libTestBuffer.a
    12 #LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
    13 #include $(PREBUILT_STATIC_LIBRARY)
  • issm/trunk-jpl/src/android/ISSM/src/com/example/issm/ISSM.java

    r13996 r14046  
    2626        private IssmJni issmNative;
    2727        private String mapName;
    28         private String textinFile;
    29         private String actualinput;
     28        private String issmFolder;
     29        private int size;
    3030    @Override
    3131  //------------------------------------------------------------------------------------------------   
     
    3737                {
    3838                        mapName = map.getString("map");
     39                        issmFolder = map.getString("pathToFile");
    3940                }
    4041        }
     
    4445        Button button = (Button) super.findViewById(R.id.button1);
    4546        button.setOnClickListener(this);
    46         this.readFile(mapName);
    4747       
    4848        //load up the ISSM library and create double buffer in java
     
    5050        issmNative = new IssmJni();
    5151        buff = ByteBuffer.allocateDirect(15*8).order(ByteOrder.nativeOrder()).asDoubleBuffer();
    52         this.createModel("Model");
     52        this.createModel();
    5353    }
    5454//------------------------------------------------------------------------------------------------   
    55     public void createModel(String Model)
     55    public void createModel()
    5656    {
    57         issmNative.initialize();
    58     }
    59 //------------------------------------------------------------------------------------------------
    60     public void readFile(String mapName)
    61     {
    62         AssetManager am = getAssets();
    63         String mapNameFile = "Map/"+mapName+".txt";
    64         try {
    65                         InputStream is = am.open(mapNameFile);
    66                         int size = is.available();
    67                         byte[]buffer = new byte[size];
    68                         is.read(buffer);
    69                         is.close();
    70                        
    71                         textinFile = new String(buffer);
    72                        
    73                         //testing on actual file
    74                         InputStream is1 = am.open("Map/test102.petsc");
    75                         int size1 = is1.available();
    76                         byte[]buffer1 = new byte[size1];
    77                         is1.read(buffer1);
    78                         System.out.println(buffer1);
    79                         is1.close();
    80                         actualinput = new String(buffer1);
    81                 } catch (IOException e) {
    82                         // TODO Auto-generated catch block
    83                         e.printStackTrace();
     57        String file = "";
     58        if( mapName.equals("greenland"))
     59                {
     60                file = "test102.petsc";
    8461                }
     62        else file = "test102.petsc";
     63        size = issmNative.createISSMModel(issmFolder + file);
    8564    }
    8665//------------------------------------------------------------------------------------------------
    8766    public void fillBuffer()
    8867    {
    89         issmNative.processBuffer(buff);
     68        issmNative.processBuffer(5,buff);
    9069    }
    9170 //------------------------------------------------------------------------------------------------   
     
    10483                //print result from fac and the first two slot of filled buffer.
    10584                this.output.setText("Result = " + resultfromFac + "\n"
    106                                                                                 + "First two slot from buffer:\n"
    107                                                                                 + buff.get(1) + "          " + buff.get(2)
    108                                                                                 + "\nmap name = " + mapName
    109                                                                                 + "\nTxtFile    " + textinFile
    110                                                                                 +"\nactualFile   " + actualinput);
     85                                                                                + "First slot from buffer:\n"
     86                                                                                + buff.get(0) + " size " +  size);
    11187
    11288        }
  • issm/trunk-jpl/src/android/ISSM/src/com/example/issm/IssmJni.java

    r13996 r14046  
    55{
    66        public native long fac(long n);
    7         public native void processBuffer(DoubleBuffer buff);
    8         public native void initialize();
     7        public native void processBuffer(int alpha, DoubleBuffer buff);
     8        public native int createISSMModel(String file);
    99        static
    1010        {
  • issm/trunk-jpl/src/android/ISSM/src/com/example/issm/MapSelection.java

    r13996 r14046  
    11package com.example.issm;
     2
     3import java.io.File;
     4import java.io.FileOutputStream;
     5import java.io.IOException;
     6import java.io.InputStream;
     7import java.io.OutputStream;
    28
    39import android.app.Activity;
    410import android.os.Bundle;
     11import android.os.Environment;
    512import android.text.TextUtils;
     13import android.util.Log;
    614import android.view.Menu;
    715import android.view.View;
    816import android.widget.Button;
     17import android.widget.Toast;
    918import android.content.Intent;
    10 
     19import android.content.SharedPreferences;
     20import android.content.res.AssetManager;
     21///////////////////////////////////////////////////////////////////////////
    1122public class MapSelection extends Activity
    1223{
    13         private String map;
    1424        ISSM issm = new ISSM();
     25        private static final String PREFERENCE_FIRST_RUN = null;
     26        private String extStorageDirectory;
     27        private String issmFolder;
     28//------------------------------------------------------------------------     
    1529        public void onCreate(Bundle icicle)
    1630        {
     
    1832                setContentView(R.layout.activity_mapselection);
    1933               
     34                 SharedPreferences settings = this.getSharedPreferences("ISSM", 0);
     35                    boolean firstrun = settings.getBoolean(PREFERENCE_FIRST_RUN, true);
     36                    extStorageDirectory = Environment.getExternalStorageDirectory().toString();
     37                   
     38                    issmFolder = extStorageDirectory + "/ISSM/input_files/";
     39                    if (firstrun)
     40                    { // Checks to see if we've ran the application b4
     41                        SharedPreferences.Editor e = settings.edit();
     42                        e.putBoolean(PREFERENCE_FIRST_RUN, false);
     43                       
     44                        e.commit();
     45                        // If not, run these methods:
     46                        SetDirectory(issmFolder);
     47                    }
     48                   
     49       
    2050                //this button represents greenland and pass signal to issm
    2151                Button gl = (Button) findViewById(R.id.button1);               
    2252                gl.setOnClickListener(new View.OnClickListener()
    2353                {
    24                        
    2554                        public void onClick(View v)
    2655                        {
    27                                 // TODO Auto-generated method stub
    2856                                Intent i = new Intent(MapSelection.this, ISSM.class);
    2957                                i.putExtra("map", "greenland");
     58                                i.putExtra("pathToFile", issmFolder);
    3059                        startActivity(i);
    3160                        }
    3261                });
    3362               
    34                 //this button represents artantice and pass signal to issm
     63                //this button represents artarctica and pass signal to issm
    3564                Button art = (Button) findViewById(R.id.button2);
    3665                art.setOnClickListener(new View.OnClickListener()
    3766                {
    38                        
    3967                        public void onClick(View v)
    4068                        {
    41                                 // TODO Auto-generated method stub
    4269                                Intent i = new Intent(MapSelection.this, ISSM.class);
    4370                                i.putExtra("map", "antarctica");
     71                                i.putExtra("pathToFile", issmFolder);
    4472                        startActivity(i);
    4573                        }
    4674                });
    4775        }
     76//------------------------------------------------------------------------
     77        private void SetDirectory(String directory)
     78        {
     79            if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
     80            {
     81                System.out.println(issmFolder);
     82                File txtDirectory = new File(issmFolder);
     83               
     84                // Check and create directory in SDcard
     85                if(!txtDirectory.exists())
     86                {
     87                        txtDirectory.mkdirs();
     88                        System.out.println("making directory");
     89                }
     90                CopyAssets(); // Then run the method to copy the file.
     91
     92            }
     93            else if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED_READ_ONLY))
     94            {
     95                Toast toast = Toast.makeText(this.getApplicationContext(), "Memory is not mounted to device", Toast.LENGTH_LONG);
     96                toast.show();
     97            }
     98
     99        }
     100//----------------------------------------------------------------------------
     101        /**
     102         * -- Copy the file from the assets folder to the sdCard
     103         * ===========================================================
     104         **/
     105                private void CopyAssets()
     106                {
     107                    AssetManager assetManager = getAssets();
     108                    String[] files = null;
     109                    try {
     110                        files = assetManager.list("Map");
     111                    } catch (IOException e) {
     112                        Log.e("tag", e.getMessage());
     113                    }
     114                    for (int i = 0; i < files.length; i++) {
     115                        InputStream in = null;
     116                        OutputStream out = null;
     117                        try {
     118                            in = assetManager.open("Map/"+files[i]);
     119                            out = new FileOutputStream(issmFolder + files[i]);
     120                            copyFile(in, out);
     121                            in.close();
     122                            in = null;
     123                            out.flush();
     124                            out.close();
     125                            out = null;
     126                        } catch (Exception e) {
     127                            Log.e("tag", e.getMessage());
     128                        }
     129                    }
     130                    System.out.println("Done");
     131                }
     132//----------------------------------------------------------------------------
     133                private void copyFile(InputStream in, OutputStream out) throws IOException
     134                {
     135                    byte[] buffer = new byte[1024];
     136                    int read;
     137                    while ((read = in.read(buffer)) != -1) {
     138                        out.write(buffer, 0, read);
     139                    }
     140                }
     141//----------------------------------------------------------------------------
    48142}
    49 
     143///////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.