/**
 *  Stores the messages about the events that occur where it is connected
 *  THIS AGENT IS NOT COMPLETE.
 *  It is skeleton for a wrapper that computes result from request.
 *  You must complete the go(..) method self dependently.
 *  Generated 2002.9.21  by Sight 2.0, Ulm university.
 */
package impl.manipulators;

import Sight.Agents.*;
import Sight.dds.*;
import java.io.*;
import Sight.Agents.util.*;

public class alarmBell extends Sight.Agents.Prototypes.Wrapper implements Serializable {
  /* Data structure to pass query to this robot. */
  public class Request extends Sight.Request implements java.io.Serializable {
        /** Information */
        public CharSequence field_0;
        /** Information */
        public CharSequence field_1;
        /** Information */
        public CharSequence field_2;
        /** Information */
        public CharSequence field_3;
       /** Submit request, compute key by SHA digesting algorithm. */
       public Sight.Agents.Request submit() { return Sight.Agents.Request.submit(Public, this, getKey()); };
       /** Submit request with the known key. */
       public Sight.Agents.Request submit(String key)
        { return Sight.Agents.Request.submit(Public, this, key); };
       };

  /** Get default request for this robot. */
  public static Request getDefaultRequest() {
     return Public.getRequest(); }
  private Request getRequest() { return new Request(); }; // must be non static

    /** Type definitions for Request. */
   public dStructure getRequestDds() {
    return new Sight.dds.Records(true,
     new dField[] {
        new dField("field_0","CharSequence","Information",""),
        new dField("field_1","CharSequence","Information",""),
        new dField("field_2","CharSequence","Information",""),
        new dField("field_3","CharSequence","Information","")                 }
    );
   }

  public static class Result extends Sight.Result implements Serializable {
   public Object[] a = new Object[1];
   String id;
   public String getReport(int verbosityLevel)
    {
      return "<a href=\"Events.html#evt_"+id+"\">note "+id+"</a><a name=\"evt_"+id+"\"></a>";
    };

   public CharSequence getReportForRecord(Object x, int verbosityLevel)
    {
      return getReport(verbosityLevel);
    };
  };

   public static PrintStream alarms = null;
   public static int id = 1;

   /** Implementation of the central go method.  */
   public synchronized Object go(Object o_request) throws Exception
    {

     if (alarms==null)
      alarms = Sight.Log.LogFileOpener.OpenHTML("Events");

     Request r = (Request) o_request;

     alarms.println("<a href=\"Index.html#evt_"+id+"\">note "+id+"</a>");
     alarms.print("<a name=\"evt_"+id+"\"></a>");
     alarms.print("<blockquote>");

     if (r.field_0!=null)
      alarms.print(r.field_0);

     if (r.field_1!=null)
      alarms.print("<br>"+r.field_1);

     if (r.field_2!=null)
      alarms.print("<br>"+r.field_2);

     if (r.field_3!=null)
      alarms.print("<br>"+r.field_3);

     alarms.println("</blockquote>");
     alarms.flush();

     Result R = new Result();
     R.id = Integer.toString(id);

     id++;
     return R;
    };

  public alarmBell() {
   setDescription("Stores the messages about the events that occur where it is connected in 'Events.html'");
   setMasterURL("");
   // this robot newer uses caching:
   setWriteCache(false);
   setReadCache(false);
   };
  /** Public instance of agent for user. */
  public static alarmBell Public = new alarmBell();
  public static Agent getAvailableAgent() { return Public; };
  /** main(..) method provided to check robot, launching it
   * as standalone program. */
  public static void main(String[] args) {
  Sight.Agents.util.Pind.showConsoles();
      try {
        Request request = getDefaultRequest();
        // Now modify and assign request fields in accordance with task:
        Sight.Agents.Request submission = request.submit();
        // processing now started in separate thread:
        Result response = (Result) submission.getResult();
        // print report, verbosity level 2:
        System.out.println(response.getReport(2));
      } catch (Exception exc)
         { if (exc!=null) System.out.println(exc.getMessage());
           exc.printStackTrace();
         };
   }
;
  }