// $Source: /usr/local/SimSoft/Sfx3D/src/gts/gtsmexp.cpp,v $
// $Revision: 1.2 $
// $Author: baum $
// $Date: 2001/11/29 15:18:10 $
//
// Login name of the user who locked the revision
// $Locker:  $
// Tag name used to checkout the file
// $Name: Release-14 $
// State assigned to revision
// $State: Exp $
//
//
// $Log: gtsmexp.cpp,v $
// Revision 1.2  2001/11/29 15:18:10  baum
// -Realzeitsteuerung eingebaut
// -Handsteuerung eingebaut
//

#define _GTSMEXP_CPP

/*** Windows headers ***/
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
//#include <winnt.h>
#endif /*WIN32*/

#ifdef __GNUC__
#include <unistd.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "XGraph/Select.h"
#include "XGraph/Parent.h"
#include "XGraph/GeoObj.h"
#include "XGraph/Space.h"

#include <tcl.h>
#include <tk.h>
#include "IniFile.h"
#include "gtsglob.h"
#include "gtsbst.h"
#include "gtstzt.h"
#include "gtstlm.h"

void EreignisVerwaltung (const char *argv2, const char *argv3, const char * /*argv4*/, const char * /*argv5*/)
{
  if (!strcmp("INFO", argv2))
  {
    sprintf (DlgBuffer, "%s", (char*)EreignisListe->Info().str());
  }
  else
  if (!strcmp("UP", argv2)) EreignisListe->nachOben (ArgInt(argv3));
  else
  if (!strcmp("DOWN", argv2)) EreignisListe->nachUnten (ArgInt(argv3));
  else
  if (!strcmp("ERZEUGEN", argv2))
       sprintf (DlgBuffer, "%s", (char*)EreignisListe->Erzeugen(argv3).str());
  else
  if (!strcmp("AENDERN", argv2))
       sprintf (DlgBuffer, "%s", (char*)EreignisListe->Aendern(argv3).str());
  else
  if (!strcmp("SELECT", argv2)) 
       sprintf (DlgBuffer, "%s", 
                (char*)EreignisListe->Select(ArgInt(argv3)).str());
  else
  if (!strcmp("LOESCHEN", argv2)) EreignisListe->loeschen (ArgInt(argv3));
}  // ENDE EreignisVerwaltung


void ProzessVerwaltung (const char *argv2, const char *argv3, const char *argv4, const char *argv5)
{
  if (!strcmp("INFO", argv2))
       sprintf (DlgBuffer, "%s", (char*)ProzessListe->Info().str());
  else
  if (!strcmp("SETVERTEIL0", argv2))
       sprintf (DlgBuffer, "%s",  
       (char*)ProzessListe->setBetrifft (ArgInt(argv3), 
                            ArgInt(argv4), ArgInt(argv5)).str());
  else
  if (!strcmp("GETVERTEIL1", argv2))
       sprintf (DlgBuffer, "%s",  
       (char*)ProzessListe->getAbstandVerteilung(ArgInt(argv3)).str());
  else
  if (!strcmp("SETVERTEIL1", argv2))
       sprintf (DlgBuffer, "%s",  
       (char*)ProzessListe->setAbstandVerteilung(ArgInt(argv3), ArgInt(argv4), argv5).str());
  else
  if (!strcmp("GETVERTEIL2", argv2))
       sprintf (DlgBuffer, "%s", 
         (char*)ProzessListe->getMengeDauerVerteilung(ArgInt(argv3)).str());
  else
  if (!strcmp("SETVERTEIL2", argv2))
       sprintf (DlgBuffer, "%s", 
       (char*)ProzessListe->setMengeDauerVerteilung(ArgInt(argv3), ArgInt(argv4), argv5).str());
  else
  if (!strcmp("SELECT", argv2)) 
       sprintf (DlgBuffer, "%s",
         (char*)ProzessListe->Select(ArgInt(argv3)).str());
  else
  if (!strcmp("SETPROZESSNR", argv2)) 
       sprintf (DlgBuffer, "%s", 
       (char*)ProzessListe->setProzessnr (ArgInt(argv3), ArgInt(argv4)).str());
  else
  if (!strcmp("ERZEUGEN", argv2)) 
       sprintf (DlgBuffer, "%s",  
       (char*)ProzessListe->erzeugen(ArgInt(argv3), ArgInt(argv4), ArgInt(argv5)).str());
  else
  if (!strcmp("LOESCHEN", argv2)) ProzessListe->loeschen (ArgInt(argv3));
}  // ENDE ProzessVerwaltung

void ZeitVerwaltung (const char *argv2, const char *argv3, const char * /*argv4*/, const char * /*argv5*/)
{
  if (!strcmp("GETLAUFZEIT", argv2))
      sprintf (DlgBuffer, "%s", 
               (char*)EreignisListe->getSimulationEnde(1).str());
  else
  if (!strcmp("SETLAUFZEIT", argv2))
      sprintf (DlgBuffer, "%s",
               (char*)EreignisListe->setSimulationEnde(argv3,1).str());
}  // ENDE ZeitVerwaltung

int DlgExperiment (ClientData /*clientData*/,
                     Tcl_Interp *interp, int argc, const char *argv[] )
{
  GTSInterpreter = interp;
  if (testprog) {
    Write("DlgExperiment: Anfang >%s<", argv[1]);
    for (int i = 2; i <= argc; i++) Write(" >%s< ", argv[i]);
  }
  sprintf(DlgBuffer, "%s", "");


  if ( !strcmp("EREIGNISSE", argv[1]) )
             EreignisVerwaltung (argv[2], argv[3], argv[4], argv[5]);
  else 
  if ( !strcmp("PROZESSE", argv[1]) )
             ProzessVerwaltung (argv[2], argv[3], argv[4], argv[5]);
  else 
  if ( !strcmp("ZEITMODELL", argv[1]) )
             ZeitVerwaltung (argv[2], argv[3], argv[4], argv[5]);
  else 
  {
    sprintf (DlgBuffer, "DlgExp: Unbekannte Methode \"%.32s\"\n " , argv[1]);
    Tcl_SetResult( interp, DlgBuffer, TCL_STATIC );
    return TCL_ERROR;
  }

  if (testprog) Write("  -> Ende: DlgBuffer >%s<\n", DlgBuffer);
  Tcl_SetResult(interp, DlgBuffer, TCL_STATIC);
  return TCL_OK;
} //  ENDE DlgExperiment

