static IPTR mWindow_Setup(struct IClass *cl, Object *obj, struct MUIP_Window_Setup *msg)
{
  IPTR result = FALSE;

  ENTER();

  if(DoSuperMethodA(cl, obj, (Msg)msg))
  {
    struct data *data = INST_DATA(cl, obj);

    if(isFlagClear(data->flags, FLG_Notifies))
    {
      DoMethod(data->use, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)obj, 1, MUIM_BrowserEditWin_Use);
      DoMethod(data->cancel, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)obj, 3, MUIM_Set, MUIA_Window_CloseRequest, TRUE);

      DoMethod(obj, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)_app(obj), 6, MUIM_Application_PushMethod,
          (IPTR)_app(obj), 3, MUIM_App_CloseWin, MUIA_BrowserEditWin_Browser, (IPTR)data->bn);

      SET_FLAG(data->flags, FLG_Notifies);

      result = TRUE;
    }
  }

  RETURN(result);
  return result;
}
Exemple #2
0
BOOL updateFTPList(struct List * list, struct MinList PrefsFTPList)
{
    struct URL_FTPNode  *   fn      = NULL,
                        *   newNode = NULL;

    // libération de la liste
    freeList(list);

    // ajout des nouvelles données
    for (fn = (struct URL_FTPNode *)PrefsFTPList.mlh_Head;
         fn->ufn_Node.mln_Succ;
         fn = (struct URL_FTPNode *)fn->ufn_Node.mln_Succ)
    {
        if((newNode = (struct URL_FTPNode*)IListBrowser->AllocListBrowserNode(3,
            LBNA_NodeSize,  sizeof(struct URL_FTPNode),
            LBNA_CheckBox,  TRUE,
            LBNA_Checked,   isFlagClear(fn->ufn_Flags, UNF_DISABLED),
            LBNA_Column,    1,
            LBNCA_Text, "",
            LBNA_Column, 2,
            LBNCA_Text, "",
            TAG_DONE)) != NULL)
        {
            IExec->CopyMem(fn, newNode, sizeof(struct URL_FTPNode));
            IListBrowser->SetListBrowserNodeAttrs((struct Node*)newNode, LBNA_Column,    1,
                                                            LBNCA_Text,     newNode->ufn_Name,
                                                            LBNA_Column,    2,
                                                            LBNCA_Text,     newNode->ufn_Path,
                                                            TAG_END);

            IIntuition->SetAttrs(edit_ftp_win,  WINDOW_UserData, fn, TAG_DONE);
            IExec->AddTail(list, (struct Node*)newNode);
        }
        else
        {
            IDOS->Printf(" AllocListBrowserNode() failed\n");
            return(FALSE);
        }
    }

    return TRUE;
}
Exemple #3
0
/*---------------------*
 * Split line into two *
 *---------------------*/
BOOL SplitLine(LONG x, struct line_node *line, BOOL move_crsr, struct UserAction *buffer, struct InstData *data)
{
  struct line_node *newline;
  struct line_node *next;
  struct pos_info pos;
  LONG line_nr, lines;
  ULONG c;
  UWORD crsr_x = data->CPos_X;
  struct line_node *crsr_l = data->actualline;

  ENTER();

  OffsetToLines(x, line, &pos, data);
  lines = pos.lines;

  next = line->next;
  if((newline = AllocLine(data)) != NULL)
  {
    UWORD *styles = line->line.Styles;
    UWORD *newstyles = NULL;
    UWORD *colors = line->line.Colors;
    UWORD *newcolors = NULL;

    data->HasChanged = TRUE;
    Init_LineNode(newline, line, line->line.Contents+x, data);
    newline->line.Color = line->line.Color;
    newline->line.Flow = line->line.Flow;
    newline->line.Separator = line->line.Separator;
    if(buffer != NULL)
    {
      newline->line.Color = buffer->del.style;
      newline->line.Flow = buffer->del.flow;
      newline->line.Separator = buffer->del.separator;
    }

    if(styles != NULL)
    {
      LONG  style = 0;
      LONG  length = 0;
      UWORD *ostyles;

      while(*styles++ <= x+1)
      {
        if(*styles > 0xff)
          style &= *styles++;
        else
          style |= *styles++;
      }
      styles--;
      ostyles = styles;
      while(*(styles+length) != EOS)
        length += 2;
      length = (length*2) + 16;

      if((newstyles = MyAllocPooled(data->mypool, length)) != NULL)
      {
          UWORD *nstyles = newstyles;

        if(isFlagSet(style, BOLD))
        {
          *nstyles++ = 1;
          *nstyles++ = BOLD;
        }
        if(isFlagSet(style, ITALIC))
        {
          *nstyles++ = 1;
          *nstyles++ = ITALIC;
        }
        if(isFlagSet(style, UNDERLINE))
        {
          *nstyles++ = 1;
          *nstyles++ = UNDERLINE;
        }

        while(*styles != EOS)
        {
          *nstyles++ = (*styles++) - x;
          *nstyles++ = *styles++;
        }
        *nstyles = EOS;
      }

      if(isFlagSet(style, BOLD))
      {
        *ostyles++ = x+1;
        *ostyles++ = ~BOLD;
      }
      if(isFlagSet(style, ITALIC))
      {
        *ostyles++ = x+1;
        *ostyles++ = ~ITALIC;
      }
      if(isFlagSet(style, UNDERLINE))
      {
        *ostyles++ = x+1;
        *ostyles++ = ~UNDERLINE;
      }
      if(x != 0)
        ostyles = line->line.Styles;
      *ostyles = EOS;
    }
    newline->line.Styles = newstyles;

    if(colors != NULL)
    {
      UWORD color = GetColor(x, line);
      UWORD length = 0;
      UWORD *ocolors;

      while(*colors <= x+1)
      {
        colors += 2;
      }
      ocolors = colors;

      while(*(colors+length) != 0xffff)
        length += 2;
      length = (length*2) + 16;

      if((newcolors = MyAllocPooled(data->mypool, length)) != NULL)
      {
        UWORD *ncolors = newcolors;

        if(color && *colors-x != 1)
        {
          *ncolors++ = 1;
          *ncolors++ = color;
        }

        while(*colors != 0xffff)
        {
          *ncolors++ = (*colors++) - x;
          *ncolors++ = *colors++;
        }
        *ncolors = 0xffff;
      }
      if(x != 0)
        ocolors = line->line.Colors;
      *ocolors = 0xffff;
    }
    newline->line.Colors = newcolors;


    newline->next = next;
    if(next != NULL)
      next->previous = newline;

    *(line->line.Contents+x) = '\n';
    *(line->line.Contents+x+1) = '\0';
    line->line.Length = x+1;

/*------------------*/
    c = line->visual;
    line->visual = VisualHeight(line, data);
    CompressLine(line, data);

    line_nr = LineToVisual(line, data) + line->visual - 1;
    if(line_nr < 0)
      line_nr = 0;

    if(move_crsr)
    {
      data->CPos_X = 0;
      data->actualline = data->actualline->next;
    }

    if(x == 0)
    {
      line->line.Color = 0;
      line->line.Separator = 0;
      if(!(line->previous && line->previous->line.Flow == line->line.Flow))
      {
        line->line.Flow = MUIV_TextEditor_Flow_Left;
      }
      if(line_nr != data->maxlines)
      {
        data->totallines += 1;
        if(data->fastbackground)
        {
          if(line_nr)
          {
            ScrollDown(line_nr-1, 1, data);
            PrintLine(0, line, line_nr, FALSE, data);
          }
          else
          {
            ScrollDown(line_nr, 1, data);
          }
        }
        else  DumpText(data->visual_y+line_nr-1, line_nr-1, data->maxlines, TRUE, data);
      }
      else
      {
        data->visual_y++;
        data->totallines += 1;
        if(isFlagClear(data->flags, FLG_Quiet))
        {
          struct Hook *oldhook;

          oldhook = InstallLayerHook(data->rport->Layer, LAYERS_NOBACKFILL);
          ScrollRasterBF(data->rport, 0, data->height,
                    data->xpos, data->ypos,
                    data->xpos + data->innerwidth - 1, (data->ypos + ((data->maxlines-1) * data->height)) - 1);
          InstallLayerHook(data->rport->Layer, oldhook);

          PrintLine(0, line, data->maxlines-1, FALSE, data);
          if(!data->fastbackground)
          {
            DumpText(data->visual_y+data->maxlines-1, data->maxlines-1, data->maxlines, TRUE, data);
          }
        }
      }

      RETURN(TRUE);
      return(TRUE);
    }

    if(x == (LONG)(line->line.Length + newline->line.Length - 2))
    {
      data->totallines += 1;
      if(buffer == NULL)
      {
        line->next->line.Color = 0;
        line->next->line.Separator = 0;
      }
      SetCursor(crsr_x, crsr_l, FALSE, data);
      if(line_nr < data->maxlines)
      {
        if(data->fastbackground)
        {
          ScrollDown(line_nr, 1, data);
          if(line_nr+1 <= data->maxlines)
            PrintLine(0, line->next, line_nr+1, FALSE, data);
        }
        else  DumpText(data->visual_y+line_nr, line_nr, data->maxlines, TRUE, data);
      }

      RETURN(TRUE);
      return(TRUE);
    }
    x = line->line.Length;

    OffsetToLines(x-1, line, &pos, data);
    if(((ULONG)(line->visual + line->next->visual) >= c) && (line->visual == lines))
    {
      if((ULONG)(line->visual + line->next->visual) > c)
        data->totallines += 1;

      PrintLine(pos.bytes, line, line_nr, TRUE, data);

      if((line_nr+line->next->visual-1 < data->maxlines) && ((ULONG)(line->visual + line->next->visual) > c))
      {
        ScrollDown(line_nr+line->next->visual-1, 1, data);
      }
    }
    else
    {
      PrintLine((x-1)-pos.x, line, line_nr, TRUE, data);

      if((line_nr < data->maxlines) && ((ULONG)(line->visual + line->next->visual) < c))
      {
        data->totallines -= 1;
        ScrollUp(line_nr, 1, data);
      }
    }
/*------------------*/
    line = line->next;
    line_nr++;
    c = 0;
    while((c < line->line.Length) && (line_nr <= data->maxlines))
      c = c + PrintLine(c, line, line_nr++, TRUE, data);
  /* Her printes !HELE! den nye linie, burde optimeres! */

    RETURN(TRUE);
    return (TRUE);
  }
  else
  {
    RETURN(FALSE);
    return (FALSE);
  }
}
Exemple #4
0
/* Save_Struct_Gnuplot_Data()
 *
 * Saves antenna structure data for gnuplot
 */
  void
Save_Struct_Gnuplot_Data( char *filename )
{
  FILE *fp = NULL;

  /* Open gplot file, abort on error */
  if( !Open_File(&fp, filename, "w") )
    return;

  /* Output if patch segs and no new input pending */
  if( data.m && isFlagClear(INPUT_PENDING) )
  {
    int idx, m2;

    /* Output segments data */
    fprintf( fp, _("# structure patch segmenets\n") );

    /* Output first segment outside loop to enable separation of wires */
    fprintf( fp, "%10.3E %10.3E %10.3E\n%10.3E %10.3E %10.3E\n",
        (double)data.px1[0], (double)data.py1[0], (double)data.pz1[0],
        (double)data.px2[0], (double)data.py2[0], (double)data.pz2[0] );

    /* Start from second segment and check for connection of ends */
    m2 = data.m * 2;
    for( idx = 1; idx < m2; idx++ )
    {
      fprintf( fp, "%10.3E %10.3E %10.3E\n%10.3E %10.3E %10.3E\n",
          (double)data.px1[idx], (double)data.py1[idx], (double)data.pz1[idx],
          (double)data.px2[idx], (double)data.py2[idx], (double)data.pz2[idx] );
    } /* for( idx = 1; idx < m2; idx++ ) */

    fprintf( fp, "\n\n" );
  } /* if( data.m && isFlagSet(INPUT_PENDING) ) */

  /* Output if wire segs and no new input pending */
  if( data.n && isFlagClear(INPUT_PENDING) )
  {
    int idx;

    /* Output segments data */
    fprintf( fp, _("# structure wire segmenets\n") );

    /* Output first segment outside loop to enable separation of wires */
    fprintf( fp, "%10.3E %10.3E %10.3E\n%10.3E %10.3E %10.3E\n",
        (double)data.x1[0], (double)data.y1[0], (double)data.z1[0],
        (double)data.x2[0], (double)data.y2[0], (double)data.z2[0] );

    /* Start from second segment and check for connection of ends */
    for( idx = 1; idx < data.n; idx++ )
    {
      /* Leave a 2-line gap to next segment */
      if( (data.icon1[idx] == 0) || (data.icon1[idx] == (idx+1)) )
        fprintf( fp, "\n\n" );
      fprintf( fp, "%10.3E %10.3E %10.3E\n%10.3E %10.3E %10.3E\n",
          (double)data.x1[idx], (double)data.y1[idx], (double)data.z1[idx],
          (double)data.x2[idx], (double)data.y2[idx], (double)data.z2[idx] );
      /* Leave a 2-line gap to next segment */
      if( (data.icon2[idx] == 0) || (data.icon2[idx] == (idx+1)) )
        fprintf( fp, "\n\n" );

    } /* for( idx = 1; idx < data.n; idx++ ) */
  } /* if( data.n && isFlagSet(INPUT_PENDING) ) */

  fclose( fp );
} /* Save_Struct_Gnuplot_Data() */
Exemple #5
0
/* Save_FreqPlots_Gnuplot_Data()
 *
 * Saves frequency plots data to a file for gnuplot
 */
  void
Save_FreqPlots_Gnuplot_Data( char *filename )
{
  /* Abort if plot data not available */
  if( isFlagClear(FREQ_LOOP_DONE) )
    return;

  /* Used to calculate net gain */
  double Zr, Zo, Zi;

  /* Open gplot file, abort on error */
  FILE *fp = NULL;
  if( !Open_File(&fp, filename, "w") )
    return;

  /* Plot max gain vs frequency, if possible */
  if( isFlagSet(PLOT_GMAX) && isFlagSet(ENABLE_RDPAT) )
  {
    int nth, nph, idx, pol;
    gboolean no_fbr;

    double
      gmax,     /* Max gain buffer */
      netgain,  /* Viewer direction net gain buffer */
      gdir_phi, /* Direction in phi of gain */
      fbratio;  /* Front to back ratio */

    /* Find max gain and direction, F/B ratio */
    no_fbr = FALSE;
    netgain = 0;

    /* Polarization type and impedance */
    pol = calc_data.pol_type;
    Zo = calc_data.zo;

    /* Save data for all frequency steps that were used */
    fprintf( fp, _("# Gain and F/B Ratio vs Frequency\n") );
    for( idx = 0; idx <= calc_data.lastf; idx++ )
    {
      double fbdir;
      int fbidx, mgidx;

      /* Index to gtot buffer where max gain
       * occurs for given polarization type */
      mgidx = rad_pattern[idx].max_gain_idx[pol];

      /* Max gain for given polarization type */
      gmax = rad_pattern[idx].gtot[mgidx] +
        Polarization_Factor(pol, idx, mgidx);

      /* Net gain if selected */
      if( isFlagSet(PLOT_NETGAIN) )
      {
        Zr = impedance_data.zreal[idx];
        Zi = impedance_data.zimag[idx];
        netgain = gmax + 10*log10(4*Zr*Zo/(pow(Zr+Zo,2)+pow(Zi,2)));
      }

      /* Radiation angle/phi where max gain occurs */
      gdir_phi = rad_pattern[idx].max_gain_phi[pol];

      /* Find F/B direction in theta */
      fbdir = 180.0 - rad_pattern[idx].max_gain_tht[pol];
      if( fpat.dth == 0.0 )
        nth = 0;
      else
        nth = (int)( fbdir/fpat.dth + 0.5 );

      /* If the antenna is modelled over ground, then use the same
       * theta as the max gain direction, relying on phi alone to
       * take us to the back. Patch supplied by Rik van Riel AB1KW
       */
      if( (nth >= fpat.nth) || (nth < 0) )
      {
        fbdir = rad_pattern[idx].max_gain_tht[pol];
        if( fpat.dth == 0.0 )
          nth = 0;
        else
          nth = (int)( fbdir/fpat.dth + 0.5 );
      }

      /* Find F/B direction in phi */
      fbdir = gdir_phi + 180.0;
      if( fbdir >= 360.0 ) fbdir -= 360.0;
      nph = (int)( fbdir/fpat.dph + 0.5 );

      /* No F/B calc. possible if no phi step at +180 from max gain */
      if( (nph >= fpat.nph) || (nph < 0) )
        no_fbr = TRUE;

      /* Index to gtot buffer for gain in back direction */
      fbidx = nth + nph*fpat.nth;

      /* Front to back ratio */
      fbratio  = pow( 10.0, gmax / 10.0 );
      fbratio /= pow( 10.0,
          (rad_pattern[idx].gtot[fbidx] +
           Polarization_Factor(pol, idx, fbidx)) / 10.0 );
      fbratio = 10.0 * log10( fbratio );

      if( no_fbr && isFlagClear(PLOT_NETGAIN) ) /* Plot max gain only */
        fprintf( fp, "%13.6E %10.3E\n", save.freq[idx], gmax );
      else if( isFlagSet(PLOT_NETGAIN) ) /* Plot max gain and net gain */
        fprintf( fp, "%13.6E %10.3E %10.3E\n", save.freq[idx], gmax, netgain );
      else if( !no_fbr ) /* Plot max gain and F/B ratio */
        fprintf( fp, "%13.6E %10.3E %10.3E\n", save.freq[idx], gmax, fbratio );
    } /* for( idx = 0; idx < calc_data.lastf; idx++ ) */

    /* Plot gain direction in phi and theta */
    if( isFlagSet(PLOT_GAIN_DIR) )
    {
      fprintf( fp, "\n\n" );
      fprintf( fp, _("# Direction of gain in theta and phi\n") );
      for( idx = 0; idx < calc_data.lastf; idx++ )
      {
        double gdir_tht; /* Direction in theta of gain */

        /* Radiation angle/phi where max gain occurs */
        gdir_tht = 90.0 - rad_pattern[idx].max_gain_tht[pol];
        gdir_phi = rad_pattern[idx].max_gain_phi[pol];
        fprintf( fp, "%13.6E %10.3E %10.3E\n", save.freq[idx], gdir_tht, gdir_phi );
      } /* for( idx = 0; idx < calc_data.lastf; idx++ ) */
    } /* if( isFlagSet(PLOT_GAIN_DIR) ) */

    fprintf( fp, "\n\n" );
  } /* if( isFlagSet(PLOT_GMAX) && isFlagSet(ENABLE_RDPAT) ) */

  /* Plot VSWR vs freq */
  if( isFlagSet(PLOT_VSWR) )
  {
    int idx;
    double vswr, gamma;
    double zrpro2, zrmro2, zimag2;

    /* Calculate VSWR */
    fprintf( fp, _("# VSWR vs Frequency\n") );
    for(idx = 0; idx <= calc_data.lastf; idx++ )
    {
      zrpro2 = impedance_data.zreal[idx] + calc_data.zo;
      zrpro2 *= zrpro2;
      zrmro2 = impedance_data.zreal[idx] - calc_data.zo;
      zrmro2 *= zrmro2;
      zimag2 = impedance_data.zimag[idx] * impedance_data.zimag[idx];
      gamma = sqrt( (zrmro2 + zimag2)/(zrpro2 + zimag2) );
      vswr = (1+gamma)/(1-gamma);
      if( vswr > 10.0 ) vswr = 10.0;
      fprintf( fp, "%13.6E %10.3E\n", save.freq[idx], vswr );
    }

    fprintf( fp, "\n\n" );
  } /* if( isFlagSet(PLOT_VSWR) ) */

  /* Plot z-real and z-imag */
  if( isFlagSet(PLOT_ZREAL_ZIMAG) )
  {
    int idx;
    fprintf( fp, _("# Z real & Z imaginary vs Frequency\n") );
    for(idx = 0; idx <= calc_data.lastf; idx++ )
      fprintf( fp, "%13.6E %10.3E %10.3E\n",
          save.freq[idx], impedance_data.zreal[idx], impedance_data.zimag[idx] );

    fprintf( fp, "\n\n" );
  } /* if( isFlagSet(PLOT_ZREAL_ZIMAG) ) */

  /* Plot z-magn and z-phase */
  if( isFlagSet(PLOT_ZMAG_ZPHASE) )
  {
    int idx;
    fprintf( fp, _("# Z magnitude & Z phase vs Frequency\n") );
    for(idx = 0; idx <= calc_data.lastf; idx++ )
      fprintf( fp, "%13.6E %10.3E %10.3E\n",
          save.freq[idx], impedance_data.zmagn[idx], impedance_data.zphase[idx] );
  } /* if( isFlagSet(PLOT_ZREAL_ZIMAG) ) */

  fclose(fp);
} /* Save_FreqPlots_Gnuplot_Data() */
void SGP4(float tsince, PredicThirteen::tle_t * tle, PredicThirteen::vector_t * pos, PredicThirteen::vector_t * vel)
{
    /* This function is used to calculate the position and velocity */
    /* of near-earth (period < 225 minutes) satellites. tsince is   */
    /* time since epoch in minutes, tle is a pointer to a tle_t     */
    /* structure with Keplerian orbital elements and pos and vel    */
    /* are vector_t structures returning ECI satellite position and */ 
    /* velocity. Use Convert_Sat_State() to convert to km and km/s. */

    static float aodp, aycof, c1, c4, c5, cosio, d2, d3, d4, delmo,
                 omgcof, eta, omgdot, sinio, xnodp, sinmo, t2cof, t3cof, t4cof,
                 t5cof, x1mth2, x3thm1, x7thm1, xmcof, xmdot, xnodcf, xnodot, xlcof;

    float cosuk, sinuk, rfdotk, vx, vy, vz, ux, uy, uz, xmy, xmx, cosnok,
          sinnok, cosik, sinik, rdotk, xinck, xnodek, uk, rk, cos2u, sin2u,
          u, sinu, cosu, betal, rfdot, rdot, r, pl, elsq, esine, ecose, epw,
          cosepw, x1m5th, xhdot1, tfour, sinepw, capu, ayn, xlt, aynl, xll,
          axn, xn, beta, xl, e, a, tcube, delm, delomg, templ, tempe, tempa,
          xnode, tsq, xmp, omega, xnoddf, omgadf, xmdf, a1, a3ovk2, ao,
          betao, betao2, c1sq, c2, c3, coef, coef1, del1, delo, eeta, eosq,
          etasq, perigee, pinvsq, psisq, qoms24, s4, temp, temp1, temp2,
          temp3, temp4, temp5, temp6, theta2, theta4, tsi;

    int i;

    DEBUG_PRINTLN("----------------------------------------");
    printTle(tle);


    /* Initialization */

    if (isFlagClear(SGP4_INITIALIZED_FLAG))
    {
        SetFlag(SGP4_INITIALIZED_FLAG);

        /* Recover original mean motion (xnodp) and   */
        /* semimajor axis (aodp) from input elements. */

        a1=pow(xke/tle->xno,tothrd);
        printVar("a1", a1);
        cosio=cos(tle->xincl);
        printVar("Tle->xincl", tle->xincl);
        theta2=cosio*cosio;
        x3thm1=3*theta2-1.0;
        printVar("theta2",theta2);
        printVar("cosio",cosio);
        eosq=tle->eo*tle->eo;
        betao2=1.0-eosq;
        betao=sqrt(betao2);
        del1=1.5*ck2*x3thm1/(a1*a1*betao*betao2);
        ao=a1*(1.0-del1*(0.5*tothrd+del1*(1.0+134.0/81.0*del1)));
        delo=1.5*ck2*x3thm1/(ao*ao*betao*betao2);
        xnodp=tle->xno/(1.0+delo);
        aodp=ao/(1.0-delo);

        printVar("aodp", aodp);
        DEBUG_PRINTLN("----------------------------------------");        


        /* For perigee less than 220 kilometers, the "simple"     */
        /* flag is set and the equations are truncated to linear  */
        /* variation in sqrt a and quadratic variation in mean    */
        /* anomaly.  Also, the c3 term, the delta omega term, and */
        /* the delta m term are dropped.                          */

        if ((aodp*(1-tle->eo)/ae)<(220/xkmper+ae))
            SetFlag(SIMPLE_FLAG);

        else
            ClearFlag(SIMPLE_FLAG);

        /* For perigees below 156 km, the      */
        /* values of s and qoms2t are altered. */

        s4=s;
        qoms24=qoms2t;
        perigee=(aodp*(1-tle->eo)-ae)*xkmper;
        printVar("perigee", perigee);

        if (perigee<156.0)
        {
            if (perigee<=98.0)
                s4=20;
            else
                s4=perigee-78.0;

            qoms24=pow((120-s4)*ae/xkmper,4);
            s4=s4/xkmper+ae;
        }
        DEBUG_PRINTLN("----------------------------------------");


        pinvsq=1/(aodp*aodp*betao2*betao2);
        tsi=1/(aodp-s4);
        eta=aodp*tle->eo*tsi;
        etasq=eta*eta;
        printVar("etasq",etasq);
        eeta=tle->eo*eta;
        psisq=fabs(1-etasq);
        coef=qoms24*pow(tsi,4);
        coef1=coef/pow(psisq,3.5);
        printVar("coef1",coef1);
        c2=coef1*xnodp*(aodp*(1+1.5*etasq+eeta*(4+etasq))+0.75*ck2*tsi/psisq*x3thm1*(8+3*etasq*(8+etasq)));
        printVar("xnodp", xnodp);
        printVar("etasq",etasq);
        printVar("eeta",eeta);
        printVar("ck2",ck2);
        printVar("tsi",tsi);
        printVar("psisq",psisq);
        printVar("x3thm1",x3thm1);
        printVar("c2",c2);
        c1=tle->bstar*c2;
        printVar("c1*1000000",c1*1000000);
        printVar("BSTAR: ", tle->bstar);
        sinio=sin(tle->xincl);
        a3ovk2=-xj3/ck2*pow(ae,3);
        c3=coef*tsi*a3ovk2*xnodp*ae*sinio/tle->eo;
        x1mth2=1-theta2;
        printVar("x1mth2", x1mth2);
        DEBUG_PRINTLN("----------------------------------------");
        DEBUG_PRINTLN("----------------------------------------");


        c4=2*xnodp*coef1*aodp*betao2*(eta*(2+0.5*etasq)+tle->eo*(0.5+2*etasq)-2*ck2*tsi/(aodp*psisq)*(-3*x3thm1*(1-2*eeta+etasq*(1.5-0.5*eeta))+0.75*x1mth2*(2*etasq-eeta*(1+etasq))*cos(2*tle->omegao)));
        c5=2*coef1*aodp*betao2*(1+2.75*(etasq+eeta)+eeta*etasq);

        theta4=theta2*theta2;
        temp1=3*ck2*pinvsq*xnodp;
        temp2=temp1*ck2*pinvsq;
        temp3=1.25*ck4*pinvsq*pinvsq*xnodp;
        xmdot=xnodp+0.5*temp1*betao*x3thm1+0.0625*temp2*betao*(13-78*theta2+137*theta4);
        x1m5th=1-5*theta2;
        omgdot=-0.5*temp1*x1m5th+0.0625*temp2*(7-114*theta2+395*theta4)+temp3*(3-36*theta2+49*theta4);
        xhdot1=-temp1*cosio;
        xnodot=xhdot1+(0.5*temp2*(4-19*theta2)+2*temp3*(3-7*theta2))*cosio;
        omgcof=tle->bstar*c3*cos(tle->omegao);
        xmcof=-tothrd*coef*tle->bstar*ae/eeta;
        xnodcf=3.5*betao2*xhdot1*c1;
        t2cof=1.5*c1;
        printVar("t2cof*1000000", t2cof*1000000);
        xlcof=0.125*a3ovk2*sinio*(3+5*cosio)/(1+cosio);
        aycof=0.25*a3ovk2*sinio;
        delmo=pow(1+eta*cos(tle->xmo),3);
        sinmo=sin(tle->xmo);
        x7thm1=7*theta2-1;
        printVar("x7thm1", x7thm1);

        if (isFlagClear(SIMPLE_FLAG))
        {
            c1sq=c1*c1;
            d2=4*aodp*tsi*c1sq;
            temp=d2*tsi*c1/3;
            d3=(17*aodp+s4)*temp;
            d4=0.5*temp*aodp*tsi*(221*aodp+31*s4)*c1;
            t3cof=d2+2*c1sq;
            t4cof=0.25*(3*d3+c1*(12*d2+10*c1sq));
            t5cof=0.2*(3*d4+12*c1*d3+6*d2*d2+15*c1sq*(2*d2+c1sq));
        }
    }

    /* Update for secular gravity and atmospheric drag. */
    xmdf=tle->xmo+xmdot*tsince;
    omgadf=tle->omegao+omgdot*tsince;
    xnoddf=tle->xnodeo+xnodot*tsince;
    omega=omgadf;
    xmp=xmdf;
    tsq=tsince*tsince;
    printVar("tsince*1000000", tsince*1000000);
    printVar("tsq", tsq);        

    xnode=xnoddf+xnodcf*tsq;
    tempa=1-c1*tsince;
    tempe=tle->bstar*c4*tsince;
    templ=t2cof*tsq;
    printVar("templ", templ);


    if (isFlagClear(SIMPLE_FLAG))
    {
        delomg=omgcof*tsince;
        delm=xmcof*(pow(1+eta*cos(xmdf),3)-delmo);
        temp=delomg+delm;
        xmp=xmdf+temp;
        omega=omgadf-temp;
        tcube=tsq*tsince;
        tfour=tsince*tcube;
        tempa=tempa-d2*tsq-d3*tcube-d4*tfour;
        tempe=tempe+tle->bstar*c5*(sin(xmp)-sinmo);
        templ=templ+t3cof*tcube+tfour*(t4cof+tsince*t5cof);
        printVar("templ", templ);
    }

    a=aodp*pow(tempa,2);
    e=tle->eo-tempe;
    xl=xmp+omega+xnode+xnodp*templ;
    beta=sqrt(1-e*e);
    xn=xke/pow(a,1.5);

    /* Long period periodics */
    axn=e*cos(omega);
    temp=1/(a*beta*beta);
    xll=temp*xlcof*axn;
    aynl=temp*aycof;
    xlt=xl+xll;
    ayn=e*sin(omega)+aynl;

    /* Solve Kepler's Equation */
    capu=FMod2p(xlt-xnode);
    temp2=capu;
    i=0;

    do
    {
        sinepw=sin(temp2);
        cosepw=cos(temp2);
        temp3=axn*sinepw;
        temp4=ayn*cosepw;
        temp5=axn*cosepw;
        temp6=ayn*sinepw;
        epw=(capu-temp4+temp3-temp2)/(1-temp5-temp6)+temp2;

        if (fabs(epw-temp2)<= e6a)
            break;

        temp2=epw;

    } while (i++<10);

    /* Short p2eriod preliminary quantities */
    ecose=temp5+temp6;
    esine=temp3-temp4;
    elsq=axn*axn+ayn*ayn;
    temp=1-elsq;
    pl=a*temp;
    r=a*(1-ecose);
    temp1=1/r;
    rdot=xke*sqrt(a)*esine*temp1;
    rfdot=xke*sqrt(pl)*temp1;
    temp2=a*temp1;
    betal=sqrt(temp);
    temp3=1/(1+betal);
    cosu=temp2*(cosepw-axn+ayn*esine*temp3);
    sinu=temp2*(sinepw-ayn-axn*esine*temp3);
    u=AcTan(sinu,cosu);
    sin2u=2*sinu*cosu;
    cos2u=2*cosu*cosu-1;
    temp=1/pl;
    temp1=ck2*temp;
    temp2=temp1*temp;

    /* Update for short periodics */
    rk=r*(1-1.5*temp2*betal*x3thm1)+0.5*temp1*x1mth2*cos2u;
    uk=u-0.25*temp2*x7thm1*sin2u;
    xnodek=xnode+1.5*temp2*cosio*sin2u;
    xinck=tle->xincl+1.5*temp2*cosio*sinio*cos2u;
    rdotk=rdot-xn*temp1*x1mth2*sin2u;
    rfdotk=rfdot+xn*temp1*(x1mth2*cos2u+1.5*x3thm1);

    /* Orientation vectors */
    sinuk=sin(uk);
    cosuk=cos(uk);
    sinik=sin(xinck);
    cosik=cos(xinck);
    sinnok=sin(xnodek);
    cosnok=cos(xnodek);
    xmx=-sinnok*cosik;
    xmy=cosnok*cosik;
    ux=xmx*sinuk+cosnok*cosuk;
    uy=xmy*sinuk+sinnok*cosuk;
    uz=sinik*sinuk;
    vx=xmx*cosuk-cosnok*sinuk;
    vy=xmy*cosuk-sinnok*sinuk;
    vz=sinik*cosuk;

    /* Position and velocity */
    pos->x=rk*ux;
    pos->y=rk*uy;
    pos->z=rk*uz;
    vel->x=rdotk*ux+rfdotk*vx;
    vel->y=rdotk*uy+rfdotk*vy;
    vel->z=rdotk*uz+rfdotk*vz;

    DEBUG_PRINTLN("----------------------------------------");
    DEBUG_PRINT("Position: ");
    printVector(pos);
    DEBUG_PRINT("Velocity; ");
    printVector(vel);

    /* Phase in radians */
    phase=xlt-xnode-omgadf+twopi;

    if (phase<0.0)
        phase+=twopi;

    phase=FMod2p(phase);
}
Exemple #7
0
///
/// MakeXPKPop
// creates a popup list of available XPK sublibraries
static Object *MakeXPKPop(Object **text, BOOL encrypt)
{
  Object *lv;
  Object *list;
  Object *po;
  Object *but;

  ENTER();

  if((po = PopobjectObject,
    MUIA_Popstring_String, *text = TextObject,
      TextFrame,
      MUIA_Background, MUII_TextBack,
      MUIA_FixWidthTxt, "MMMM",
    End,
    MUIA_Popstring_Button, but = PopButton(MUII_PopUp),
    MUIA_Popobject_StrObjHook, &PO_XPKOpenHook,
    MUIA_Popobject_ObjStrHook, &PO_XPKCloseHook,
    MUIA_Popobject_WindowHook, &PO_WindowHook,
    MUIA_Popobject_Object, lv = ListviewObject,
      MUIA_Listview_List, list = ListObject,
        InputListFrame,
        MUIA_List_AutoVisible,   TRUE,
        MUIA_List_ConstructHook, MUIV_List_ConstructHook_String,
        MUIA_List_DestructHook,  MUIV_List_DestructHook_String,
      End,
    End,
  End))
  {
    // disable the XPK popups if xpkmaster.library is not available
    if(XpkBase == NULL)
    {
      set(po, MUIA_Disabled, TRUE);
      set(but, MUIA_Disabled, TRUE);
    }
    else
    {
      struct xpkPackerNode *xpkNode;

      IterateList(G->xpkPackerList, struct xpkPackerNode *, xpkNode)
      {
        BOOL suits = TRUE;

        D(DBF_XPK, "XPK lib '%s' has flags %08lx", xpkNode->info.xpi_Name, xpkNode->info.xpi_Flags);

        if(encrypt == TRUE && isFlagClear(xpkNode->info.xpi_Flags, XPKIF_ENCRYPTION))
        {
          D(DBF_XPK, "'%s' has no encryption capabilities, excluded from encryption list", xpkNode->info.xpi_Name);
          suits = FALSE;
        }

        if(suits == TRUE)
          DoMethod(list, MUIM_List_InsertSingle, xpkNode->info.xpi_Name, MUIV_List_Insert_Sorted);
      }

      DoMethod(lv, MUIM_Notify, MUIA_Listview_DoubleClick, TRUE, po, 2, MUIM_Popstring_Close, TRUE);
    }
  }

  RETURN(po);
  return po;
}
Exemple #8
0
static IPTR mStorePrefs(struct IClass *cl, Object *obj, struct MUIP_Win_StorePrefs *msg)
{
    struct data *data = INST_DATA(cl,obj);
    struct URL_Prefs     up;
    ULONG                i;

    set(_app(obj),MUIA_Application_Sleep,TRUE);

    /* Copy settings from gadgets into structure */
    up.up_Version = PREFS_VERSION;
    NewList((struct List *)&up.up_BrowserList);
    NewList((struct List *)&up.up_MailerList);
    NewList((struct List *)&up.up_FTPList);

    /* Browsers */
    for (i = 0; ; i++)
    {
        struct URL_BrowserNode *bn;

        DoMethod(data->browserList,MUIM_List_GetEntry,i,(IPTR)&bn);
        if (!bn) break;

        if(isFlagClear(bn->ubn_Flags, UNF_NEW))
            AddTail((struct List *)&up.up_BrowserList,(struct Node *)bn);
    }

    /* Mailers */
    for (i = 0; ; i++)
    {
        struct URL_MailerNode *mn;

        DoMethod(data->mailerList,MUIM_List_GetEntry,i,(IPTR)&mn);
        if (!mn) break;

        if(isFlagClear(mn->umn_Flags, UNF_NEW))
            AddTail((struct List *)&up.up_MailerList,(struct Node *)mn);
    }

    /* FTPs */
    for (i = 0; ; i++)
    {
        struct URL_FTPNode *fn;

        DoMethod(data->FTPList,MUIM_List_GetEntry,i,(IPTR)&fn);
        if (!fn) break;

        if(isFlagClear(fn->ufn_Flags, UNF_NEW))
            AddTail((struct List *)&up.up_FTPList,(struct Node *)fn);
    }

    /* Miscellaneous */
    if (xget(data->prepend,MUIA_Selected))
        SET_FLAG(up.up_Flags, UPF_PREPENDHTTP);
    else
        CLEAR_FLAG(up.up_Flags, UPF_PREPENDHTTP);

    if (xget(data->mailto,MUIA_Selected))
        SET_FLAG(up.up_Flags, UPF_DOMAILTO);
    else
        CLEAR_FLAG(up.up_Flags, UPF_DOMAILTO);

    if (xget(data->useFTP,MUIA_Selected))
        SET_FLAG(up.up_Flags, UPF_DOFTP);
    else
        CLEAR_FLAG(up.up_Flags, UPF_DOFTP);

    up.up_DefShow         = (ULONG)xget(data->show,MUIA_Selected);
    up.up_DefBringToFront = (ULONG)xget(data->toFront,MUIA_Selected);
    up.up_DefNewWindow    = (ULONG)xget(data->newWin,MUIA_Selected);
    up.up_DefLaunch       = (ULONG)xget(data->launch,MUIA_Selected);

    /* Save to disk */
    if (!URL_SetPrefs(&up,URL_SetPrefs_Save,msg->How==MUIV_Win_StorePrefs_Save,TAG_DONE))
        MUI_RequestA(_app(obj),obj,0,getString(MSG_ErrReqTitle),getString(MSG_ErrReqGadget),getString(MSG_Err_FailedSave),NULL);

    set(_app(obj),MUIA_Application_Sleep,FALSE);

    /* Quit */
    if (msg->How!=MUIV_Win_StorePrefs_Apply)
        DoMethod(_app(obj),MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);

    return TRUE;
}
Exemple #9
0
IPTR Get(struct IClass *cl, Object *obj, struct opGet *msg)
{
  struct InstData *data = (struct InstData *)INST_DATA(cl, obj);
  IPTR ti_Data;

  switch(msg->opg_AttrID)
  {
    case MUIA_Font:
      ti_Data = (IPTR)(data->Font ? data->Font : muiAreaData(obj)->mad_Font);
    break;

    case MUIA_ControlChar:
      ti_Data = (IPTR)data->CtrlChar;
    break;

    case MUIA_String_AttachedList:
      ti_Data = (IPTR)data->ForwardObject;
    break;

    case MUIA_String_BufferPos:
      ti_Data = (IPTR)data->BufferPos;
    break;

    case MUIA_String_Acknowledge:
    case MUIA_String_Contents:
      ti_Data = (IPTR)data->Contents;
    break;

    case MUIA_String_DisplayPos:
      ti_Data = (IPTR)data->DisplayPos;
    break;

    case MUIA_String_Format:
      ti_Data = (IPTR)data->Alignment;
    break;

    case MUIA_String_Integer:
      StrToLong(data->Contents, (ULONG *)&ti_Data);
    break;

    case MUIA_String_MaxLen:
      ti_Data = (IPTR)data->MaxLength;
    break;

    case MUIA_String_Reject:
      ti_Data = (IPTR)data->Reject;
    break;

    case MUIA_String_Secret:
      ti_Data = isFlagSet(data->Flags, FLG_Secret) ? TRUE : FALSE;
    break;

    case MUIA_String_EditHook:
      ti_Data = (IPTR)data->EditHook;
    break;

    case MUIA_String_AdvanceOnCR:
      ti_Data = isFlagSet(data->Flags, FLG_AdvanceOnCr) ? TRUE : FALSE;
    break;

    case MUIA_BetterString_KeyUpFocus:
      ti_Data = (IPTR)data->KeyUpFocus;
    break;

    case MUIA_BetterString_KeyDownFocus:
      ti_Data = (IPTR)data->KeyDownFocus;
    break;

    case MUIA_BetterString_SelectSize:
      ti_Data = isFlagSet(data->Flags, FLG_BlockEnabled) ? data->BlockStop-data->BlockStart : 0;
    break;

    case MUIA_BetterString_StayActive:
      ti_Data = isFlagSet(data->Flags, FLG_StayActive) ? TRUE : FALSE;
    break;

    case MUIA_BetterString_NoInput:
      ti_Data = isFlagSet(data->Flags, FLG_NoInput) ? TRUE : FALSE;
    break;

    case MUIA_BetterString_InactiveContents:
      ti_Data = (IPTR)data->InactiveContents;
    break;

    case MUIA_BetterString_NoShortcuts:
      ti_Data = isFlagSet(data->Flags, FLG_NoShortcuts) ? TRUE : FALSE;
    break;

    case MUIA_BetterString_SelectOnActive:
    {
      if((data->SelectOnActive == TRUE && isFlagClear(data->Flags, FLG_ForceSelectOff)) ||
         isFlagSet(data->Flags, FLG_ForceSelectOn))
      {
         ti_Data = TRUE;
      }
      else
         ti_Data = FALSE;
    }
    break;

    case MUIA_Version:
      ti_Data = LIB_VERSION;
    break;

    case MUIA_Revision:
      ti_Data = LIB_REVISION;
    break;

    default:
      return DoSuperMethodA(cl, obj, (Msg)msg);
    break;
  }

  *msg->opg_Storage = ti_Data;

  return TRUE;
}