/***************************************************************************************************************************/
/*       C-Code der   Basiskomponente   "assignment2                     " , Version "Version0                        "    */
/***************************************************************************************************************************/

#   include  "c_macros.h"
#   include  "sys_struct.h"
#   include  "sys_extern.h"
#   include  "rts_func.h"
#   include  "mod_struct.h"


    int aSSIGNMENT2 ( register struct aSSIGNMENT2 * pData )
    {
    int  status = 0;


/*  Strukturierung und Urinitialisierung  */
/*  ====================================  */
    if (Mode == Activ  &&  ActPhase == 1)
    {
       static    logic   Call1 = Yes;
       register  long    i, j;


/*     Uebergabe der Adressen  */
/*     ----------------------  */
       if ( !ReStart )
       {
#         include "offset.incl" 
       }

       SaveCompName ("assignment2");
       LinkSubComp ( &(pData->NameElem) );



       BCount ++;   FBComp [BCount] = (FPtr) aSSIGNMENT2;
                    DBComp [BCount] = pData;

       Con(GAMMA) =  0.66726E-3;
       Con(M1) =  0.2E7;
       Con(M2) =  0.3289E0;
       Con(M3) =  0.48438E1;
       Con(M4) =  0.598E1;

       StCCount ++;   pCState [StCCount]  = Adr(X1); 
       StNxt(X1) = 0;  StD(X1) = 0.0;  Sta(X1) =  0.E-1;
       StCCount ++;   pCState [StCCount]  = Adr(Y1); 
       StNxt(Y1) = 0;  StD(Y1) = 0.0;  Sta(Y1) =  0.E-1;
       StCCount ++;   pCState [StCCount]  = Adr(X2); 
       StNxt(X2) = 0;  StD(X2) = 0.0;  Sta(X2) =  0.46E2;
       StCCount ++;   pCState [StCCount]  = Adr(Y2); 
       StNxt(Y2) = 0;  StD(Y2) = 0.0;  Sta(Y2) =  0.E-1;
       StCCount ++;   pCState [StCCount]  = Adr(X3); 
       StNxt(X3) = 0;  StD(X3) = 0.0;  Sta(X3) =  0.1075E3;
       StCCount ++;   pCState [StCCount]  = Adr(Y3); 
       StNxt(Y3) = 0;  StD(Y3) = 0.0;  Sta(Y3) =  0.E-1;
       StCCount ++;   pCState [StCCount]  = Adr(X4); 
       StNxt(X4) = 0;  StD(X4) = 0.0;  Sta(X4) =  0.1496E3;
       StCCount ++;   pCState [StCCount]  = Adr(Y4); 
       StNxt(Y4) = 0;  StD(Y4) = 0.0;  Sta(Y4) =  0.E-1;
       StCCount ++;   pCState [StCCount]  = Adr(U1); 
       StNxt(U1) = 0;  StD(U1) = 0.0;  Sta(U1) =  0.E-1;
       StCCount ++;   pCState [StCCount]  = Adr(V1); 
       StNxt(V1) = 0;  StD(V1) = 0.0;  Sta(V1) =  0.E-1;
       StCCount ++;   pCState [StCCount]  = Adr(U2); 
       StNxt(U2) = 0;  StD(U2) = 0.0;  Sta(U2) =  0.E-1;
       StCCount ++;   pCState [StCCount]  = Adr(V2); 
       StNxt(V2) = 0;  StD(V2) = 0.0;  Sta(V2) =  0.592E1;
       StCCount ++;   pCState [StCCount]  = Adr(U3); 
       StNxt(U3) = 0;  StD(U3) = 0.0;  Sta(U3) =  0.E-1;
       StCCount ++;   pCState [StCCount]  = Adr(V3); 
       StNxt(V3) = 0;  StD(V3) = 0.0;  Sta(V3) =  0.35E1;
       StCCount ++;   pCState [StCCount]  = Adr(U4); 
       StNxt(U4) = 0;  StD(U4) = 0.0;  Sta(U4) =  0.E-1;
       StCCount ++;   pCState [StCCount]  = Adr(V4); 
       StNxt(V4) = 0;  StD(V4) = 0.0;  Sta(V4) =  0.3E1;

       Dep(D12) = 0.0;
       Dep(D13) = 0.0;
       Dep(D14) = 0.0;
       Dep(D23) = 0.0;
       Dep(D24) = 0.0;
       Dep(D34) = 0.0;
       Dep(F12) = 0.0;
       Dep(F13) = 0.0;
       Dep(F14) = 0.0;
       Dep(F23) = 0.0;
       Dep(F24) = 0.0;
       Dep(F34) = 0.0;

       VarEff (X1,CompNo)   = BCount;   VarEff (X1,EffFlag) = 5;
       VarEff (X1,eff_next) = NULL;
       VarEff (Y1,CompNo)   = BCount;   VarEff (Y1,EffFlag) = 5;
       VarEff (Y1,eff_next) = NULL;
       VarEff (X2,CompNo)   = BCount;   VarEff (X2,EffFlag) = 5;
       VarEff (X2,eff_next) = NULL;
       VarEff (Y2,CompNo)   = BCount;   VarEff (Y2,EffFlag) = 5;
       VarEff (Y2,eff_next) = NULL;
       VarEff (X3,CompNo)   = BCount;   VarEff (X3,EffFlag) = 5;
       VarEff (X3,eff_next) = NULL;
       VarEff (Y3,CompNo)   = BCount;   VarEff (Y3,EffFlag) = 5;
       VarEff (Y3,eff_next) = NULL;
       VarEff (X4,CompNo)   = BCount;   VarEff (X4,EffFlag) = 5;
       VarEff (X4,eff_next) = NULL;
       VarEff (Y4,CompNo)   = BCount;   VarEff (Y4,EffFlag) = 5;
       VarEff (Y4,eff_next) = NULL;
       VarEff (U1,CompNo)   = BCount;   VarEff (U1,EffFlag) = 5;
       VarEff (U1,eff_next) = NULL;
       VarEff (V1,CompNo)   = BCount;   VarEff (V1,EffFlag) = 5;
       VarEff (V1,eff_next) = NULL;
       VarEff (U2,CompNo)   = BCount;   VarEff (U2,EffFlag) = 5;
       VarEff (U2,eff_next) = NULL;
       VarEff (V2,CompNo)   = BCount;   VarEff (V2,EffFlag) = 5;
       VarEff (V2,eff_next) = NULL;
       VarEff (U3,CompNo)   = BCount;   VarEff (U3,EffFlag) = 5;
       VarEff (U3,eff_next) = NULL;
       VarEff (V3,CompNo)   = BCount;   VarEff (V3,EffFlag) = 5;
       VarEff (V3,eff_next) = NULL;
       VarEff (U4,CompNo)   = BCount;   VarEff (U4,EffFlag) = 5;
       VarEff (U4,eff_next) = NULL;
       VarEff (V4,CompNo)   = BCount;   VarEff (V4,EffFlag) = 5;
       VarEff (V4,eff_next) = NULL;
       VarEff (D12,CompNo)   = BCount;   VarEff (D12,EffFlag) = 5;
       VarEff (D12,eff_next) = NULL;
       VarEff (D13,CompNo)   = BCount;   VarEff (D13,EffFlag) = 5;
       VarEff (D13,eff_next) = NULL;
       VarEff (D14,CompNo)   = BCount;   VarEff (D14,EffFlag) = 5;
       VarEff (D14,eff_next) = NULL;
       VarEff (D23,CompNo)   = BCount;   VarEff (D23,EffFlag) = 5;
       VarEff (D23,eff_next) = NULL;
       VarEff (D24,CompNo)   = BCount;   VarEff (D24,EffFlag) = 5;
       VarEff (D24,eff_next) = NULL;
       VarEff (D34,CompNo)   = BCount;   VarEff (D34,EffFlag) = 5;
       VarEff (D34,eff_next) = NULL;
       VarEff (F12,CompNo)   = BCount;   VarEff (F12,EffFlag) = 5;
       VarEff (F12,eff_next) = NULL;
       VarEff (F13,CompNo)   = BCount;   VarEff (F13,EffFlag) = 5;
       VarEff (F13,eff_next) = NULL;
       VarEff (F14,CompNo)   = BCount;   VarEff (F14,EffFlag) = 5;
       VarEff (F14,eff_next) = NULL;
       VarEff (F23,CompNo)   = BCount;   VarEff (F23,EffFlag) = 5;
       VarEff (F23,eff_next) = NULL;
       VarEff (F24,CompNo)   = BCount;   VarEff (F24,EffFlag) = 5;
       VarEff (F24,eff_next) = NULL;
       VarEff (F34,CompNo)   = BCount;   VarEff (F34,EffFlag) = 5;
       VarEff (F34,eff_next) = NULL;

       TimeEff [BCount]. CompNo   =  BCount;
       TimeEff [BCount]. EffFlag  =  0;
       TimeEff [BCount]. eff_next =  NULL;

       ExAlg [BCount] =  3;
       ExDtl [BCount] =  3;
       ExEvt [BCount] =  0;

       pData -> CroBase  = CroCount;   CroCount  += 0;
       pData -> IndBase  = IndCount;   IndCount  += 0;
       pData -> RegBase  = RegCount;   RegCount  += 0;
       pData -> TCmpBase = TCmpCount;  TCmpCount += 0;

       return status;
    }

/*  Belegungen der Arrayinfo-Strukturen  */
/*  ===================================  */
    if (Mode == Activ  &&  ActPhase == 2)
    {
      long i;


      return status;
    }


/*  Aktuellen Komponentennamen merken  */
/*  ---------------------------------  */
    ActComp =  & (pData->NameElem);



/*  Beschreibung der Modelldynamik  */
/*  ==============================  */


    if (Mode == AlgEqu)
    {
      ActLine = 57;
      DepAsgnR ((struct RDep *) &Dep(D12), SQRT((Sta(X1) -Sta(X2))*(Sta(X1) -Sta(X2)) +(Sta(Y1) -Sta(Y2))*(Sta(Y1) -Sta(Y2))));
    }

    if (Mode == AlgEqu)
    {
      ActLine = 58;
      DepAsgnR ((struct RDep *) &Dep(D13), SQRT((Sta(X1) -Sta(X3))*(Sta(X1) -Sta(X3)) +(Sta(Y1) -Sta(Y3))*(Sta(Y1) -Sta(Y3))));
    }

    if (Mode == AlgEqu)
    {
      ActLine = 59;
      DepAsgnR ((struct RDep *) &Dep(D14), SQRT((Sta(X1) -Sta(X4))*(Sta(X1) -Sta(X4)) +(Sta(Y1) -Sta(Y4))*(Sta(Y1) -Sta(Y4))));
    }

    if (Mode == AlgEqu)
    {
      ActLine = 60;
      DepAsgnR ((struct RDep *) &Dep(D23), SQRT((Sta(X2) -Sta(X3))*(Sta(X2) -Sta(X3)) +(Sta(Y2) -Sta(Y3))*(Sta(Y2) -Sta(Y3))));
    }

    if (Mode == AlgEqu)
    {
      ActLine = 61;
      DepAsgnR ((struct RDep *) &Dep(D24), SQRT((Sta(X2) -Sta(X4))*(Sta(X2) -Sta(X4)) +(Sta(Y2) -Sta(Y4))*(Sta(Y2) -Sta(Y4))));
    }

    if (Mode == AlgEqu)
    {
      ActLine = 62;
      DepAsgnR ((struct RDep *) &Dep(D34), SQRT((Sta(X3) -Sta(X4))*(Sta(X3) -Sta(X4)) +(Sta(Y3) -Sta(Y4))*(Sta(Y3) -Sta(Y4))));
    }

    if (Mode == AlgEqu)
    {
      ActLine = 65;
      DepAsgnR ((struct RDep *) &Dep(F12), Con(M1)*Con(M2)*Con(GAMMA)/(Dep(D12)*Dep(D12)));
    }

    if (Mode == AlgEqu)
    {
      ActLine = 66;
      DepAsgnR ((struct RDep *) &Dep(F13), Con(M1)*Con(M3)*Con(GAMMA)/(Dep(D13)*Dep(D13)));
    }

    if (Mode == AlgEqu)
    {
      ActLine = 67;
      DepAsgnR ((struct RDep *) &Dep(F14), Con(M1)*Con(M4)*Con(GAMMA)/(Dep(D14)*Dep(D14)));
    }

    if (Mode == AlgEqu)
    {
      ActLine = 68;
      DepAsgnR ((struct RDep *) &Dep(F23), Con(M2)*Con(M3)*Con(GAMMA)/(Dep(D23)*Dep(D23)));
    }

    if (Mode == AlgEqu)
    {
      ActLine = 69;
      DepAsgnR ((struct RDep *) &Dep(F24), Con(M2)*Con(M4)*Con(GAMMA)/(Dep(D24)*Dep(D24)));
    }

    if (Mode == AlgEqu)
    {
      ActLine = 70;
      DepAsgnR ((struct RDep *) &Dep(F34), Con(M3)*Con(M4)*Con(GAMMA)/(Dep(D34)*Dep(D34)));
    }

/*  Differentialgleichungen */
/*  ======================= */
    if (Mode == DtlEqu)
    {
      ActLine = 76;
      StD (U1) =  (Sta(X2) -Sta(X1))/Dep(D12)*Dep(F12)/Con(M1) +(Sta(X3) -Sta(X1))/Dep(D13)*Dep(F13)/Con(M1) +(Sta(X4) -Sta(X1))/Dep(D14)*Dep(F14)/Con(M1);
      ActLine = 77;
      StD (V1) =  (Sta(Y2) -Sta(Y1))/Dep(D12)*Dep(F12)/Con(M1) +(Sta(Y3) -Sta(Y1))/Dep(D13)*Dep(F13)/Con(M1) +(Sta(Y4) -Sta(Y1))/Dep(D14)*Dep(F14)/Con(M1);
      ActLine = 80;
      StD (U2) =  (Sta(X1) -Sta(X2))/Dep(D12)*Dep(F12)/Con(M2) +(Sta(X3) -Sta(X2))/Dep(D23)*Dep(F23)/Con(M2) +(Sta(X4) -Sta(X2))/Dep(D24)*Dep(F24)/Con(M2);
      ActLine = 81;
      StD (V2) =  (Sta(Y1) -Sta(Y2))/Dep(D12)*Dep(F12)/Con(M2) +(Sta(Y3) -Sta(Y2))/Dep(D23)*Dep(F23)/Con(M2) +(Sta(Y4) -Sta(Y2))/Dep(D24)*Dep(F24)/Con(M2);
      ActLine = 84;
      StD (U3) =  (Sta(X1) -Sta(X3))/Dep(D13)*Dep(F13)/Con(M3) +(Sta(X2) -Sta(X3))/Dep(D23)*Dep(F23)/Con(M3) +(Sta(X4) -Sta(X3))/Dep(D34)*Dep(F34)/Con(M3);
      ActLine = 85;
      StD (V3) =  (Sta(Y1) -Sta(Y3))/Dep(D13)*Dep(F13)/Con(M3) +(Sta(Y2) -Sta(Y3))/Dep(D23)*Dep(F23)/Con(M3) +(Sta(Y4) -Sta(Y3))/Dep(D34)*Dep(F34)/Con(M3);
      ActLine = 88;
      StD (U4) =  (Sta(X1) -Sta(X4))/Dep(D14)*Dep(F14)/Con(M4) +(Sta(X2) -Sta(X4))/Dep(D24)*Dep(F24)/Con(M4) +(Sta(X3) -Sta(X4))/Dep(D34)*Dep(F34)/Con(M4);
      ActLine = 89;
      StD (V4) =  (Sta(Y1) -Sta(Y4))/Dep(D14)*Dep(F14)/Con(M4) +(Sta(Y2) -Sta(Y4))/Dep(D24)*Dep(F24)/Con(M4) +(Sta(Y3) -Sta(Y4))/Dep(D34)*Dep(F34)/Con(M4);
      ActLine = 92;
      StD (X1) =  Sta(U1);
      ActLine = 93;
      StD (Y1) =  Sta(V1);
      ActLine = 94;
      StD (X2) =  Sta(U2);
      ActLine = 95;
      StD (Y2) =  Sta(V2);
      ActLine = 96;
      StD (X3) =  Sta(U3);
      ActLine = 97;
      StD (Y3) =  Sta(V3);
      ActLine = 98;
      StD (X4) =  Sta(U4);
      ActLine = 99;
      StD (Y4) =  Sta(V4);
    }

    ActComp =  NULL;

    return status;

    }

/*  ===================== Ende der Modellkomponente =====================  */
/*  =====================================================================  */
