import java.io.*; 
import java.util.*;
import java.awt.*;

/**
 * Title:        WaterMixApplet
 * Description:  Mixing water with Fuzzy Logic
 * Copyright:    Copyright (c) 2001
 * @author S. Robl <stefan@qdev.de>, A. Heinze <mail@aheinze.de>
 * @version 1.0
 */

class FuzzyMain
{  
  public static void main(String[] args)
  {
    WaterMixFuzzyLogic watermix=new WaterMixFuzzyLogic();
    
    Frame frame=new Frame("WaterMix");
    frame.setSize(620,510);
    frame.setVisible(true);
    
    System.out.println("...fuzzy control...");

    while (true)
    {
      watermix.setInitialValues(34, .5, 10, 60, 20, 10);
      
      int i=0;
      while (true)
      {
        i++;
        
        System.out.println(i+":   current temp: "+watermix.getContainerWaterTemp()+" ¡C, current volume: "+watermix.getContainerWaterVolume()+" l");
        
        if (watermix.finishedCalculation())
          break;
        
        watermix.singleCalculation();
        
        if (watermix.getColdOrHotCup())
          System.out.println("COLD water to pour: "+watermix.getColdCupWaterVolume()+" l");
        else
          System.out.println(" HOT water to pour: "+watermix.getHotCupWaterVolume()+" l");
          
        watermix.getTempFuzzyCollection().drawInputGraph(frame.getGraphics(),      10,     30, 600, 150);
        watermix.getRemainVolFuzzyCollection().drawInputGraph(frame.getGraphics(), 10, 30+160, 600, 150);
        watermix.getFillVolFuzzyCollection().drawOutputGraph(frame.getGraphics(),  10, 30+320, 600, 150);
      
        try { Thread.sleep(100); } 
        catch (InterruptedException ie)
        { }
        
        System.out.println("-----------------");
      }
      System.out.println("***************** FINISHED *****************");
      
      try { Thread.sleep(1000); } 
      catch (InterruptedException ie)
      { }
    }
  }
}
