Exemple #1
0
pwr_tStatus
time_SetTime(
  pwr_tTime *pt
)
{
  pwr_tStatus sts;

  pwr_tVaxTime vt;

  abs_to_vms(&sts, &vt, pt);
  if (ODD(sts))
    sts = sys$setime(&vt);

  return sts;
}
Exemple #2
0
void
pstime(double d)
{

    setime(d);

    semi = 0;
    motion = 0;
    rad = 1.e9;
    lambda = 0;
    beta = 0;

// uses lambda, beta, rad, motion
// sets alpha, delta, rp

    helio();

// uses alpha, delta, rp
// sets ra, decl, lha, decl2, az, el

    geo();

    print(" %R %D %D %4.0f", lha, nlat, awlong, elev/3.28084);
}
Exemple #3
0
void
main(int argc, char *argv[])
{
	int i, j;
	double d;

	pi = atan(1.0)*4;
	pipi = pi*2;
	radian = pi/180;
	radsec = radian/3600;
	converge = 1.0e-14;

	fmtinstall('R', Rconv);
	fmtinstall('D', Dconv);

	per = PER;
	deld = PER/NPTS;
	init();
	args(argc, argv);
	init();

loop:
	d = day;
	pdate(d);
	if(flags['p'] || flags['e']) {
		print(" ");
		ptime(d);
		pstime(d);
	}
	print("\n");
	for(i=0; i<=NPTS+1; i++) {
		setime(d);

		for(j=0; objlst[j]; j++) {
			(*objlst[j]->obj)();
			setobj(&objlst[j]->point[i]);
			if(flags['p']) {
				if(flags['m'])
					if(strcmp(objlst[j]->name, "Comet"))
						continue;
				output(objlst[j]->name, &objlst[j]->point[i]);
			}
		}
		if(flags['e']) {
			d = dist(&eobj1->point[i], &eobj2->point[i]);
			print("dist %s to %s = %.4f\n", eobj1->name, eobj2->name, d);
		}
//		if(flags['p']) {
//			pdate(d);
//			print(" ");
//			ptime(d);
//			print("\n");
//		}
		if(flags['p'] || flags['e'])
			break;
		d += deld;
	}
	if(!(flags['p'] || flags['e']))
		search();
	day += per;
	nperiods -= 1;
	if(nperiods > 0)
		goto loop;
	exits(0);
}
Exemple #4
0
void
occult(Obj2 *p1, Obj2 *p2, double d)
{
	int i, i1, N;
	double d1, d2, d3, d4;
	double x, di, dx, x1;

	d3 = 0;
	d2 = 0;
	occ.t1 = -100;
	occ.t2 = -100;
	occ.t3 = -100;
	occ.t4 = -100;
	occ.t5 = -100;
	for(i=0; i<=NPTS+1; i++) {
		d1 = d2;
		d2 = d3;
		d3 = dist(&p1->point[i], &p2->point[i]);
		if(i >= 2 && d2 <= d1 && d2 <= d3)
			goto found;
	}
	return;

found:
	N = 2880*PER/NPTS; /* 1 min steps */
	i -= 2;
	set3pt(p1, i, &o1);
	set3pt(p2, i, &o2);

	di = i;
	x = 0;
	dx = 2./N;
	for(i=0; i<=N; i++) {
		setpt(&o1, x);
		setpt(&o2, x);
		d1 = d2;
		d2 = d3;
		d3 = dist(&o1.act, &o2.act);
		if(i >= 2 && d2 <= d1 && d2 <= d3)
			goto found1;
		x += dx;
	}
	fprint(2, "bad 1 \n");
	return;

found1:
	if(d2 > o1.act.semi2+o2.act.semi2+50)
		return;
	di += x - 3*dx;
	x = 0;
	for(i=0; i<3; i++) {
		setime(day + deld*(di + x));
		(*p1->obj)();
		setobj(&xo1.point[i]);
		(*p2->obj)();
		setobj(&xo2.point[i]);
		x += 2*dx;
	}
	dx /= 60;
	x = 0;
	set3pt(&xo1, 0, &o1);
	set3pt(&xo2, 0, &o2);
	for(i=0; i<=240; i++) {
		setpt(&o1, x);
		setpt(&o2, x);
		d1 = d2;
		d2 = d3;
		d3 = dist(&o1.act, &o2.act);
		if(i >= 2 && d2 <= d1 && d2 <= d3)
			goto found2;
		x += 1./120.;
	}
	fprint(2, "bad 2 \n");
	return;

found2:
	if(d2 > o1.act.semi2 + o2.act.semi2)
		return;
	i1 = i-1;
	x1 = x - 1./120.;
	occ.t3 = di + i1 * dx;
	occ.e3 = o1.act.el;
	d3 = o1.act.semi2 - o2.act.semi2;
	if(d3 < 0)
		d3 = -d3;
	d4 = o1.act.semi2 + o2.act.semi2;
	for(i=i1,x=x1;; i++) {
		setpt(&o1, x);
		setpt(&o2, x);
		d1 = d2;
		d2 = dist(&o1.act, &o2.act);
		if(i != i1) {
			if(d1 <= d3 && d2 > d3) {
				occ.t4 = di + (i-.5) * dx;
				occ.e4 = o1.act.el;
			}
			if(d2 > d4) {
				if(d1 <= d4) {
					occ.t5 = di + (i-.5) * dx;
					occ.e5 = o1.act.el;
				}
				break;
			}
		}
		x += 1./120.;
	}
	for(i=i1,x=x1;; i--) {
		setpt(&o1, x);
		setpt(&o2, x);
		d1 = d2;
		d2 = dist(&o1.act, &o2.act);
		if(i != i1) {
			if(d1 <= d3 && d2 > d3) {
				occ.t2 = di + (i+.5) * dx;
				occ.e2 = o1.act.el;
			}
			if(d2 > d4) {
				if(d1 <= d4) {
					occ.t1 = di + (i+.5) * dx;
					occ.e1 = o1.act.el;
				}
				break;
			}
		}
		x -= 1./120.;
	}
}
Exemple #5
0
void rlTime::setLocalTime()
{
#ifdef RLUNIX
  struct timeval tv;
  struct tm t;

  t.tm_mday  = day;
  t.tm_mon   = month - 1;
  t.tm_year  = year - 1900;
  t.tm_hour  = hour;
  t.tm_min   = minute;
  t.tm_sec   = second;
  tv.tv_sec  = mktime(&t);
  tv.tv_usec = 1000 * millisecond;
  settimeofday(&tv,NULL);
#endif

#ifdef __VMS
  VAX_BIN_TIME vbt;
  struct dsc$descriptor_s  d_time;
  char smonth[12][4],buf[64];

  // Initialize month array
  memset (smonth   , 0, sizeof(smonth));
  memcpy (smonth  [0], "JAN", 3);
  memcpy (smonth  [1], "FEB", 3);
  memcpy (smonth  [2], "MAR", 3);
  memcpy (smonth  [3], "APR", 3);
  memcpy (smonth  [4], "MAY", 3);
  memcpy (smonth  [5], "JUN", 3);
  memcpy (smonth  [6], "JUL", 3);
  memcpy (smonth  [7], "AUG", 3);
  memcpy (smonth  [8], "SEP", 3);
  memcpy (smonth  [9], "OCT", 3);
  memcpy (smonth [10], "NOV", 3);
  memcpy (smonth [11], "DEC", 3);
  // Create time buffer
  sprintf(buf, "%02d-%3.3s-%04d %02d:%02d:%02d.%02d",
                day,
                smonth[month-1],
                year,
                hour,
                minute,
                second,
                millisecond / 10);

  // Fill string descriptor
  d_time.dsc$w_length  = strlen(buf);
  d_time.dsc$b_dtype   = DSC$K_DTYPE_T;
  d_time.dsc$b_class   = DSC$K_CLASS_S;
  d_time.dsc$a_pointer = buf;
  // Convert time buf to VAX bin time
  sys$bintim(&d_time, &vbt);
  // Set the system time
  sys$setime(&vbt);
#endif

#ifdef RLWIN32
  SYSTEMTIME st;
  st.wDay          = day;
  st.wMonth        = month;
  st.wYear         = year;
  st.wHour         = hour;
  st.wMinute       = minute;
  st.wSecond       = second;
  st.wMilliseconds = millisecond;
  SetSystemTime(&st);
#endif
}