Ejemplo n.º 1
0
/*============================================================================
*    Long integer function S_solpos, adapted from the VAX solar libraries
*
*    This function calculates the apparent solar position and the
*    intensity of the sun (theoretical maximum solar energy) from
*    time and place on Earth.
*
*    Requires (from the struct posdata parameter):
*        Date and time:
*            year
*            daynum   (requirement depends on the S_DOY switch)
*            month    (requirement depends on the S_DOY switch)
*            day      (requirement depends on the S_DOY switch)
*            hour
*            minute
*            second
*            interval  DEFAULT 0
*        Location:
*            latitude
*            longitude
*        Location/time adjuster:
*            timezone
*        Atmospheric pressure and temperature:
*            press     DEFAULT 1013.0 mb
*            temp      DEFAULT 10.0 degrees C
*        Tilt of flat surface that receives solar energy:
*            aspect    DEFAULT 180 (South)
*            tilt      DEFAULT 0 (Horizontal)
*        Function Switch (codes defined in solpos.h)
*            function  DEFAULT S_ALL
*
*    Returns (via the struct posdata parameter):
*        everything defined in the struct posdata in solpos.h.
*----------------------------------------------------------------------------*/
long S_solpos(struct posdata *pdat)
{
    long int retval;

    struct trigdata trigdat, *tdat;

    tdat = &trigdat;		/* point to the structure */

    /* initialize the trig structure */
    tdat->sd = -999.0;		/* flag to force calculation of trig data */
    tdat->cd = 1.0;
    tdat->ch = 1.0;		/* set the rest of these to something safe */
    tdat->cl = 1.0;
    tdat->sl = 1.0;

    if ((retval = validate(pdat)) != 0)	/* validate the inputs */
	return retval;


    if (pdat->function & L_DOY)
	doy2dom(pdat);		/* convert input doy to month-day */
    else
	dom2doy(pdat);		/* convert input month-day to doy */

    if (pdat->function & L_GEOM)
	geometry(pdat);		/* do basic geometry calculations */

    if (pdat->function & L_ZENETR)	/* etr at non-refracted zenith angle */
	zen_no_ref(pdat, tdat);

    if (pdat->function & L_SSHA)	/* Sunset hour calculation */
	ssha(pdat, tdat);

    if (pdat->function & L_SBCF)	/* Shadowband correction factor */
	sbcf(pdat, tdat);

    if (pdat->function & L_TST)	/* true solar time */
	tst(pdat);

    if (pdat->function & L_SRSS)	/* sunrise/sunset calculations */
	srss(pdat);

    if (pdat->function & L_SOLAZM)	/* solar azimuth calculations */
	sazm(pdat, tdat);

    if (pdat->function & L_REFRAC)	/* atmospheric refraction calculations */
	refrac(pdat);

    if (pdat->function & L_AMASS)	/* airmass calculations */
	amass(pdat);

    if (pdat->function & L_PRIME)	/* kt-prime/unprime calculations */
	prime(pdat);

    if (pdat->function & L_ETR)	/* ETR and ETRN (refracted) */
	etr(pdat);

    if (pdat->function & L_TILT)	/* tilt calculations */
	tilt(pdat);

    return 0;
}
Ejemplo n.º 2
0
int main (int argc, char **argv)
{
Q330 q330;
Q330_ADDR addr;

    init(argc, argv, &q330);

    switch (q330.cmd.code) {

      case Q330_CMD_REBOOT:
        boot(&q330);
        break;

      case Q330_CMD_SAVE:
        save(&q330);
        break;

      case Q330_CMD_SAVEBOOT:
        save(&q330);
        sleep(5);
        boot(&q330);
        break;

      case Q330_CMD_RESYNC:
        resync(&q330);
        break;

      case Q330_CMD_GPS_ON:
        gpsON(&q330);
        break;

      case Q330_CMD_GPS_OFF:
        gpsOFF(&q330);
        break;

      case Q330_CMD_GPS_COLD:
        gpsColdStart(&q330);
        break;

      case Q330_CMD_GPS_CNF:
        gpsCnf(&q330);
        break;

      case Q330_CMD_GPS_ID:
        gpsId(&q330);
        break;

      case Q330_CMD_CAL_START:
        calStart(&q330);
        break;

      case Q330_CMD_CAL_STOP:
        calStop(&q330);
        break;

      case Q330_CMD_IFCONFIG:
        ifconfig(&q330);
        break;

      case Q330_CMD_STATUS:
        status(&q330);
        break;

      case Q330_CMD_FIX:
        fix(&q330);
        break;

      case Q330_CMD_GLOB:
        glob(&q330);
        break;

      case Q330_CMD_SC:
        sc(&q330);
        break;

      case Q330_CMD_PULSE:
        pulse(&q330);
        break;

      case Q330_CMD_AMASS:
        amass(&q330);
        break;

      case Q330_CMD_DCP:
        dcp(&q330);
        break;

      case Q330_CMD_SPP:
        spp(&q330);
        break;

      case Q330_CMD_MAN:
        man(&q330);
        break;

      case Q330_CMD_CO:
        checkout(&q330);
        break;

      default:
        fprintf(stderr, "ERROR: command '%s' is unsupported\n", q330.cmd.name);
        break;

    }

    if (q330.qdp != NULL) qdpDeregister(q330.qdp, TRUE);
}