// $Source: /usr/local/SimSoft/Sfx3D/src/gsl/sfxprg.h,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: sfxprg.h,v $
// Revision 1.2  2001/11/29 15:18:10  baum
// -Realzeitsteuerung eingebaut
// -Handsteuerung eingebaut
//

#ifndef _SFXPRG_H
#define _SFXPRG_H  1

#include "SimTime.h"
#include "Kalender.h"
#include "Strings.h"
#include "Angle.h"
#include "Vec3D.h"
#include "FileSys.h"

#include "sfx.h"

//---rudi---30.01.02
// folgender Block sollte nach Presta
// wieder entfernt werden!!!
//#include "transp.h"
//#include "baustein.h
//#include "programm.h"
//#include "modell.h"

#include "transp.h"
#include "baustein.h"
#include "prozess.h"
#include "programm.h"
#include "arbplan.h"
#include "ereignis.h"
#include "fts.h"
#include "maschine.h"
#include "vwagen.h"
#include "regal.h"
#include "laufkran.h"
#include "staufoer.h"
#include "realzeit.h"
#include "modell.h"
#include "mehrfachlader.h"

#ifdef _SFXPRG_CPP
#  undef _impexp
#  define _impexp __declspec(dllexport)
#elif defined BUILD_MAIN_DLL
#  undef _impexp
#  define _impexp 
#else
#  undef _impexp
#  define _impexp __declspec(dllimport)
#endif

#if defined __GNUC__ || defined __hpux
#  undef _impexp
#  define _impexp
#endif

#define This (BstNr ())

//---------------------------------------------------------
// class UserData
//---------------------------------------------------------

class _impexp UserData {
 public:
  UserData ();
  virtual ~UserData ();
  
  virtual char *LabelString (); // fuer Parameternamen
  virtual char *ParaString ();  // fuer Parameter

 protected:
  Ustring  ObjLabelString;
  Ustring  ObjParaString;
};    

/**< -------------------- Bausteinattribute ------------------- */

_impexp unsigned BstNr ();
_impexp unsigned BstTyp (unsigned bstNr);
_impexp unsigned Zustand (unsigned bstNr);
_impexp unsigned Belegung (unsigned bstNr);
_impexp unsigned Kapazitaet (unsigned bstNr);
_impexp bool hasKapazitaet (unsigned bstNr);
_impexp unsigned setKapazitaet (unsigned bstNr, unsigned kap);
_impexp unsigned Meldungen (unsigned bstNr);
_impexp SimTime Aufnahmezeit (unsigned bstNr);
_impexp void setAufnahmezeit (unsigned bstNr, const SimTime& zeit);
_impexp unsigned Strategie (unsigned bstNr);
_impexp void setStrategie (unsigned bstNr, unsigned strat);

/**< Anpassung von Bausteinen. */
_impexp void BausteinAnpassen (unsigned bstNr, Vec3D scale, int pal);

//Transportbestellsystem

_impexp void bestelleBstHolenAnfangGliedern (unsigned werBstNr, unsigned zielBstNr, unsigned palPlatz);
_impexp void bestelleBstHolen (unsigned werBstNr, unsigned zielBstNr, unsigned palPlatz);
_impexp void bestelleBstBringenAnfangGliedern (unsigned werBstNr, unsigned zielBstNr, unsigned palPlatz);
_impexp void bestelleBstBringen (unsigned werBstNr, unsigned zielBstNr, unsigned palPlatz);						     
_impexp void loescheBestellungHolen (unsigned werBstNr, unsigned zielBstNr, unsigned palPlatz);
_impexp void loescheBestellungBringen (unsigned werBstNr, unsigned zielBstNr, unsigned palPlatz);
_impexp void loescheAlleBestellungen (unsigned werBstNr);
//Transportbestellsystem Ende

_impexp int Prioritaet (unsigned bstNr);
_impexp void setPrioritaet (unsigned bstNr, int prio);
_impexp SimTime Zustandszeit (unsigned bstNr);
_impexp int AnzDirAvisIst (unsigned bstNr);
_impexp int AnzIndAvisIst (unsigned bstNr);
_impexp int AnzDirAvisSoll (unsigned bstNr);
_impexp int AnzIndAvisSoll (unsigned bstNr);
_impexp void setAnzDirAvisSoll (unsigned bstNr, int anz);
_impexp void setAnzIndAvisSoll (unsigned bstNr, int anz);
_impexp UserData *BstUserData (unsigned bstNr);
_impexp void setBstUserData (unsigned bstNr, UserData*);

_impexp typTransportEinheit* gibProjektIDTE (unsigned bstNr, unsigned artNr = 0, unsigned projektid = 0, unsigned suchid = 0);
_impexp unsigned AnzBestArbeitsplan (unsigned bstNr, unsigned arbNr, unsigned istVorg = 0);
_impexp unsigned AnzBestArtikel (unsigned bstNr, unsigned artNr, unsigned istVorg = 0);
_impexp unsigned AnzBestProjektID (unsigned bstNr, unsigned artNr, unsigned suchID);

_impexp double MengeBestArbeitsplan (unsigned bstNr, unsigned arbNr, unsigned istVorg = 0);
_impexp double MengeBestArtikel (unsigned bstNr, unsigned artNr, unsigned istVorg = 0);

_impexp unsigned AnzArbeitsplanBelegung (unsigned bstNr, unsigned arbNr, unsigned istVorg = 0);
_impexp unsigned AnzArtikelBelegung (unsigned bstNr, unsigned artNr, unsigned istVorg = 0);

_impexp double MengeArbeitsplanBelegung (unsigned bstNr, unsigned arbNr, unsigned istVorg = 0);
_impexp double MengeArtikelBelegung (unsigned bstNr, unsigned artNr, unsigned istVorg = 0);


_impexp unsigned ArbeitsplanNrVonLagerplatz (unsigned bstNr, unsigned platzNr);
_impexp unsigned ArtikelNrVonLagerplatz (unsigned bstNr, unsigned platzNr);
_impexp unsigned VorgNrVonLagerplatz (unsigned bstNr, unsigned platzNr);

/* -------------------- spezielle Bst-Parameter----------------- */

_impexp double setGeschwindigkeit (unsigned bstNr, double geschw);
_impexp void setFahrBeschleunigung (unsigned bstNr, double beschl);
_impexp void setFahrVerzoegerung (unsigned bstNr, double verz);
_impexp void setHubGeschwindigkeit (unsigned bstNr, double geschw);
_impexp void setHubBeschleunigung (unsigned bstNr, double beschl);
_impexp void setHubVerzoegerung (unsigned bstNr, double verz);
_impexp void setQuerGeschwindigkeit (unsigned bstNr, double geschw);
_impexp void setQuerBeschleunigung (unsigned bstNr, double beschl);
_impexp void setQuerVerzoegerung (unsigned bstNr, double verz);

/* -------------------- ArbeitsplanBde-------------------------- */

_impexp unsigned        AnzArbeitsplaeneEin         (unsigned arbNr);
_impexp unsigned        AnzArbeitsplaeneAus         (unsigned arbNr);
_impexp SimTime         SummeVorgangszeiten           (unsigned arbNr);
_impexp SimTime         MinBestand                  (unsigned arbNr);
_impexp SimTime         MitBestand                  (unsigned arbNr);
_impexp SimTime         MaxBestand                  (unsigned arbNr);
_impexp SimTime         MinDurchlaufzeit            (unsigned arbNr);
_impexp SimTime         MitDurchlaufzeit            (unsigned arbNr);
_impexp SimTime         MaxDurchlaufzeit            (unsigned arbNr);
_impexp void            resetDurchlaufzeit          (unsigned arbNr);
_impexp void            compressDurchlaufzeit       (unsigned arbNr);

/* -------------------- BausteinBde-------------------------- */

_impexp double          MinAuslastung               (unsigned bstNr);
_impexp double          MitAuslastung               (unsigned bstNr);
_impexp double          MaxAuslastung               (unsigned bstNr);
_impexp void            resetAuslastung             (unsigned bstNr);
_impexp void            compressAuslastung          (unsigned bstNr);
_impexp double          MinBelegung                 (unsigned bstNr);
_impexp double          MitBelegung                 (unsigned bstNr);
_impexp double          MaxBelegung                 (unsigned bstNr);
_impexp void            resetBelegung               (unsigned bstNr);
_impexp void            compressBelegung            (unsigned bstNr);
_impexp double          MinStoerung                 (unsigned bstNr);
_impexp double          MitStoerung                 (unsigned bstNr);
_impexp double          MaxStoerung                 (unsigned bstNr);
_impexp void            resetStoerung               (unsigned bstNr);
_impexp void            compressStoerung            (unsigned bstNr);

/* -------------------- Attribute der Arbeitsplaene      ---- */

_impexp SimTime         ArbVorgangszeit             (unsigned arbNr, unsigned vorgNr);
_impexp void            setArbVorgangszeit          (unsigned arbNr, unsigned vorgNr,
                                                     const SimTime& zeit);

/* -------------------- Attribute der Transporteinheiten ---- */

_impexp SimTime         Vorgangszeit                (unsigned bstNr);
_impexp unsigned        VorgangsNr                  (unsigned bstNr);
_impexp SimTime         TELaufzeit                  (unsigned bstNr);
_impexp SimTime         TEStartzeit                 (unsigned bstNr);
_impexp unsigned        ArbeitsplanNr               (unsigned bstNr);
_impexp unsigned        ArtikelNr                   (unsigned bstNr);
_impexp void            setArtikelNr                (unsigned bstNr,
                                                     unsigned artNr);
_impexp unsigned        TEVariante                  (unsigned bstNr);
_impexp void            setTEVariante               (unsigned bstNr,
                                                     unsigned vari,
                                                     unsigned unterVari = 1);
_impexp int             TEPrioritaet                (unsigned bstNr);
_impexp void            setTEPrioritaet             (unsigned bstNr, int prio);
_impexp double          TEMenge                     (unsigned bstNr);
_impexp double          incTEMenge                  (unsigned bstNr,
                                                     double menge = 1.0);
_impexp double          decTEMenge                  (unsigned bstNr,
                                                     double menge = 1.0);
_impexp double          setTEMenge                  (unsigned bstNr,
                                                     double menge);
_impexp unsigned        TEProgrammNr                (unsigned bstNr);
_impexp UserData        *TEUserData                 (unsigned bstNr);
_impexp void            setTEUserData               (unsigned bstNr,
                                                     UserData*);
_impexp void            loescheTEUserData           (unsigned bstNr);
_impexp void            dreheTE                     (unsigned bstNr, const Angle& ang);
_impexp void            ausrichtenTE                (unsigned bstNr, const Angle& ang);
_impexp void            bewegeTE                    (unsigned bstNr, const Vec3D& v);
_impexp void            positioniereTE              (unsigned bstNr, const Vec3D& v);

/* ------------------------ Anweisungen --------------------- */

_impexp void            aufnehmen                   ();
_impexp void            arbeiten                    (SimTime arbZeit =
                                                     SimTime (-1.0),
                                                     unsigned ncProgNr = 0);
_impexp void            abgeben                     (unsigned vorgNr = 0);
_impexp void            schlafen                    (SimTime zeit);
_impexp void            warten                      ();
_impexp void            aktivieren                  (unsigned bstNr,
                                                     SimTime delta =
                                                     SimTime (-1.0), 
                                                     unsigned vonbstNr = 0);
_impexp void            bestelleArbeitsplan         (unsigned arbNr,
                                                     unsigned bstNr,
                                                     unsigned wieoft = 1,
                                                     unsigned istVorg = 0,
                                                     unsigned sollVorg = 0);
_impexp void            bestelleArtikel             (unsigned artNr,
                                                     unsigned bstNr,
                                                     unsigned wieoft = 1,
                                                     unsigned istVorg = 0,
                                                     unsigned sollVorg = 0);
_impexp void            bestelleTE                  (typTransportEinheit *TE,
                                                     unsigned bstNr,
                                                     unsigned sollVorg = 0);
_impexp void            storniereArbeitsplan        (unsigned arbNr,
                                                     unsigned bstNr,
                                                     unsigned istVorg = 0);
_impexp void            storniereTE                 (typTransportEinheit *TE,
                                                     unsigned bstNr);
_impexp void            storniereArtikel            (unsigned artNr,
                                                     unsigned bstNr,
                                                     unsigned istVorg = 0);
_impexp void            zuweisenArbeitsplan         (unsigned arbNr,
                                                     unsigned vonBstNr,
                                                     unsigned nachBstNr,
                                                     unsigned wieoft = 1,
                                                     unsigned istVorg = 0,
                                                     unsigned sollVorg = 0);
_impexp void            zuweisenArtikel             (unsigned artNr,
                                                     unsigned vonBstNr,
                                                     unsigned nachBstNr,
                                                     unsigned wieoft = 1,
                                                     unsigned istVorg = 0,
                                                     unsigned sollVorg = 0);
_impexp void            planeSofort                 (unsigned eTyp,
                                                     int info1 = 0, 
                                                     int info2 = 0, 
                                                     int info3 = 0);
_impexp void            planeEin                    (const SimTime& zeit, 
                                                     unsigned eTyp, 
                                                     int info1 = 0, 
                                                     int info2 = 0, 
                                                     int info3 = 0);
_impexp void            planeDelta                  (const SimTime& zeit, 
                                                     unsigned eTyp, 
                                                     int info1 = 0,
                                                     int info2 = 0,
                                                     int info3 = 0);
_impexp double          zufallszahl                 (unsigned prozNr,
                                                     unsigned zeile);
_impexp void            PrgProzess                  (unsigned nr, 
                                                     int Art,
                                                     float v1_min,
                                                     float v1_mittel,
                                                     float v1_max,
                                                     int v1_start,
                                                     float v2_min,
                                                     float v2_mittel,
                                                     float v2_max,
                                                     int v2_start);
_impexp void            syncBst                     (unsigned bstNr);
_impexp void            simAbbruch                  ();
_impexp void            DebugTraceEin               ();
_impexp void            DebugTraceAus               ();

_impexp bool            ausrichtenAufBst            (unsigned bstNr, unsigned AufBstNr);
_impexp bool            immerausrichtenAufBst       (unsigned bstNr, unsigned AufBstNr, bool heben = true);

_impexp void            dreheBst                    (unsigned bstNr, const Angle& ang);
_impexp void            ausrichtenBst               (unsigned bstNr, const Angle& ang);
_impexp void            bewegeBst                   (unsigned bstNr, const Vec3D& v);
_impexp void            positioniereBst             (unsigned bstNr, const Vec3D& v);

/* ------------------------ Verwaltung --------------------- */

_impexp void            installEvent                (unsigned eTyp,
                                                     unsigned bstNr, 
                                                     char* fName);
_impexp unsigned        removeEvent                 (unsigned eTyp, 
                                                     unsigned bstNr);
_impexp void            installProg                 (unsigned progNr);
_impexp unsigned        removeProg                  (unsigned progNr);
_impexp void            DateiMitModellPfad          (Ustring& datName);
_impexp Ustring         GibModellPfad		    ();
_impexp bool            VerzeichnisVorhanden        (Ustring dirName);
_impexp Ustring         GibAusgabePfad		    ();
// ---hla von rudi---
_impexp void SchickeMeldungUeberHLA (double EreignisZeit, int ETyp, int BausteinNr, int ArbPlNr, int Menge);
_impexp void Hla_SendInteractionWithClassAndParameterName (double EreignisZeit, int ETyp, \
							   int BausteinNr, int ArbPlNr, \
							   int Menge, const char* className, const char* parName);
_impexp void Hla_SendInteractionMessageWithClassAndParameterName (const char* iaMessage, const char* className, \
								  const char* parName);
_impexp const char*     istHlaInteractionVorhanden ();

_impexp void Hla_PublishObject (const char* className, int bstNr, DynArray<char> &attribs);
_impexp void Hla_SubscribeObject (const char* className, DynArray<char> &attribs);
// ---ergaenzt von rudi---30.01.02
//_impexp typPrgModul     getPrgModul ();


_impexp GeoObject*    	ErzeugeGeoObject	    (unsigned bstNr,Vec3D v);


_impexp void SimulatorBeenden();


#if defined __GNUC__ || defined __hpux
#  undef _impexp
#  define _impexp
#else
#  undef _impexp
#  define _impexp __declspec(dllexport)
#endif

#endif //! _SFXPRG_H










