Ignore:
Timestamp:
01/10/13 17:21:24 (12 years ago)
Author:
wschamai
Message:
  • BUG FIX and MOD: simulation files file handling for verification results analysis
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modelicaml/org.openmodelica.modelicaml.common/src/org/openmodelica/modelicaml/common/services/ModelicaMLServices.java

    r1642 r1684  
    862862                    //TODO: here the models are in different root Models which are at the same hierarchy?
    863863                    // which to take?
    864                     System.err.println("PROBLEM detecting common root model: Root models are at the same hierarchy levels.");
     864                    System.err.println("PROBLEM detecting common root model. The root models are at the same hierarchy levels.");
    865865                }
    866866            }
     
    912912   
    913913   
    914     public static String getSimulationResultsFileName(NamedElement model){
     914   
     915    /*
     916     * Simulation files handling
     917     */
     918   
     919    public static String getOMCSimulationResultsFileName(NamedElement model){
    915920        return getModelQName((NamedElement) model) + "_res.mat";
    916921    }
    917922   
    918     public static String getSimulationResultsFileName(String modelName){
     923    public static String getOMCSimulationResultsFileName(String modelName){
    919924        return StringUtls.replaceSpecCharExceptThis( modelName, "::").replaceAll("::", ".") + "_res.mat";
    920925    }
     
    923928        return StringUtls.replaceSpecCharExceptThis( model.getQualifiedName(), "::").replaceAll("::", ".");
    924929    }
     930   
     931    public static HashMap<Element,File> findSimulationFiles(HashSet<Element> generatedModels, String fileExtension, String folderAbsolutePath){
     932        HashMap<Element,File> foundFiles = new HashMap<Element,File>();
     933        HashSet<Element> ambiguousCases = new HashSet<Element>();
     934        if (folderAbsolutePath == null || fileExtension == null) { return null; }
     935       
     936        File folder = new File(folderAbsolutePath);
     937       
     938        if (folder.exists() && folder.isDirectory()) {
     939            for (Element element : generatedModels) {
     940                if (element instanceof NamedElement) {
     941                    NamedElement model = (NamedElement) element;
     942                   
     943                    for (File file : folder.listFiles()) {
     944                        String fileName = file.getName();
     945                        String modelName = StringUtls.replaceSpecChar(model.getName());
     946                        if (fileName.contains(fileExtension) && fileName.contains(modelName)) {
     947                           
     948                            /*
     949                             * We collect conflict case when for one model multiple files matches. 
     950                             */
     951                            if (foundFiles.get(element) != null) {
     952                                ambiguousCases.add(element);
     953                            }
     954                            foundFiles.put(element, file);
     955                        }
     956                    }
     957                }
     958            }
     959        }
     960       
     961        /*
     962         * Remove all ambiguous cases. User should select the files manually.
     963         */
     964        for (Element element : ambiguousCases) {
     965            foundFiles.remove(element);
     966        }
     967       
     968        return foundFiles;
     969    }
     970   
     971   
    925972   
    926973   
Note: See TracChangeset for help on using the changeset viewer.