home Forums # Technical Support SimpleDimmer.java : how to get one specific power value back from engine?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2206
    Unknown
    Member

    Hello,

    Working from SimpleDimmer.java, what is the better object-oriented way of accomplishing the same as the following?

        public void method2() 
        {
            Engine engine = null;
            String configurationFile = "C:\\IBM\\workspaceFuzzyLite\\1.fll";
            try 
            {
            	engine = new FllImporter().fromFile(new File(configurationFile));
            } 
            catch (Exception ex) 
            {
                FuzzyLite.logger().log(Level.SEVERE, ex.toString(), ex);
            }
                
            //FuzzyLite.logger().info(new FldExporter().toString(engine));
            
            String str = new FldExporter().toString(engine);
            
            String[] parts = str.split("\n");
            
            for(int i=0; i < parts.length; i++)
            {
            	String[] duo = parts[i].split(" ");
            	if( (duo.length == 2) && (duo[0].equals("0,310")) )
            	{
            		System.out.println("Answer is " + duo[1]);
            	}
            }
        }
    #2207

    Hi,

    thank you for your post.

    you can automatically generate the Java or C++ code of any engine with: new JavaExporter().toString(engine);. Thus, you can export the engine to Java and use the exported Java code in your application instead.

    For example:

    Engine engine = null;
    String configurationFile = "C:\\IBM\\workspaceFuzzyLite\\1.fll";
    try         {
        engine = new FllImporter().fromFile(new File(configurationFile));
    } catch (Exception ex)         {
      FuzzyLite.logger().log(Level.SEVERE, ex.toString(), ex);
    }
    System.out.println(new JavaExporter().toString(engine)); //this will print the engine in Java code

    Once you copy and paste your java-coded engine in your application, you can do:

    inputVariable.setInputValue(0.310);
    engine.process()
    System.out.println("Answer is " + outputVariable.getOutputValue());

    Please, refer to http://www.fuzzylite.com/java to see how an engine in Java looks like.

    Cheers.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.