Changeset 1008 for trunk


Ignore:
Timestamp:
09/25/11 19:12:38 (13 years ago)
Author:
vasaie_p
Message:
 
Location:
trunk/modelicaml/org.openmodelica.modelicaml.simulation/src/org/openmodelica/modelicaml/simulation/evaluation
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modelicaml/org.openmodelica.modelicaml.simulation/src/org/openmodelica/modelicaml/simulation/evaluation/EvaluateResultXML.java

    r1003 r1008  
    55import org.openmodelica.modelicaml.simulation.xml.SimulationResult_XML_reader;
    66
     7/**
     8 * Class to evaluate results of a given property to a condition
     9 * @author parham.vasaiely
     10 *
     11 */
    712public class EvaluateResultXML {
    8    
    9 //  - [atLeastOneTimeTrue],
    10 //  - [atLeastOneTimeFalse],
    11 //  - [alwaysTrue],
    12 //  - [alwaysFalse],
    13 //  - [changedItsValue]
    1413   
    1514    /**
     
    1817     * @param result xml file
    1918     */
    20     public static String checkAtLeastOneTimeTrue(String propertyName, File xml_file){
     19    private static String checkAtLeastOneTimeTrue(String propertyName, File xml_file){
    2120        if(!xml_file.exists())
    2221            return "fileNotFound";
     
    4039     * @param result xml file
    4140     */
    42     public static String checkAtLeastOneTimeFalse(String propertyName, File xml_file){
     41    private static String checkAtLeastOneTimeFalse(String propertyName, File xml_file){
    4342        if(!xml_file.exists())
    4443            return "fileNotFound";
     
    6261     * @param result xml file
    6362     */
    64     public static String checkAlwaysTrue(String propertyName, File xml_file){
     63    private static String checkAlwaysTrue(String propertyName, File xml_file){
    6564        if(!xml_file.exists())
    6665            return "fileNotFound";
     
    8483     * @param result xml file
    8584     */
    86     public static String checkAlwaysFalse(String propertyName, File xml_file){
     85    private static String checkAlwaysFalse(String propertyName, File xml_file){
    8786        if(!xml_file.exists())
    8887            return "fileNotFound";
     
    106105     * @param result xml file
    107106     */
    108     public static String checkChangedItsValue(String propertyName, File xml_file){
     107    private static String checkChangedItsValue(String propertyName, File xml_file){
    109108        if(!xml_file.exists())
    110109            return "fileNotFound";
     
    128127        }
    129128            return "true";
     129    }
     130   
     131    /**
     132     * Evaluates the results of a property using a given check mode
     133     * @param propertyName name of the property which is going to be evaluated
     134     * @param checkMode used to evaluate the results of a property, the following check modes are allowed: atLeastOneTimeTrue, atLeastOneTimeFalse, alwaysTrue, alwaysFalse, changedItsValue
     135     * @param result_xml_file absolut path to the results XML
     136     * @return result of the evaluation as a String, the result can be: true, false, resultsNotfound, fileNotFound, checkModeUnknow
     137     */
     138    public static String evaluateProperty(String propertyName, String checkMode, String result_xml_file){
     139        File xmlResultFile = new File(result_xml_file);
     140        try{
     141            if(!xmlResultFile.exists() || !xmlResultFile.canRead())
     142                return "fileNotFound";
     143        }catch (Exception e) {
     144            // TODO: handle exception
     145        }
     146       
     147        if(checkMode.equals("atLeastOneTimeTrue"))
     148            return checkAtLeastOneTimeTrue(propertyName, xmlResultFile);       
     149        if(checkMode.equals("atLeastOneTimeFalse"))
     150            return checkAtLeastOneTimeFalse(propertyName, new File(result_xml_file));
     151        if(checkMode.equals("alwaysTrue"))
     152            return checkAlwaysTrue(propertyName, new File(result_xml_file));
     153        if(checkMode.equals("alwaysFalse"))
     154            return checkAlwaysFalse(propertyName, new File(result_xml_file));
     155        if(checkMode.equals("changedItsValue"))
     156            return checkChangedItsValue(propertyName, new File(result_xml_file));
     157        else
     158            return "checkModeUnknow";
    130159    }
    131160   
Note: See TracChangeset for help on using the changeset viewer.