Newer
Older
/* Copyright (c) Anglo-Australian Telescope Board, 1999.
Not to be used for commercial purposes without AATB permission. */
#include "DitsFix.h"
#include "Sdp.h"
#include "Git.h"
#include "dul_err.h"
/* externals */
extern void combine_image_(DitsArgType*,StatusType*);
extern void combine_spectra_(DitsArgType*,StatusType*);
/* extern void flx_calib_(DitsArgType*,StatusType*); */
/* extern void gen_calib_(DitsArgType*,StatusType*); */
extern void reduce_arc_(DitsArgType*,StatusType*);
extern void reduce_bias_(DitsArgType*,StatusType*);
extern void reduce_fflat_(DitsArgType*,StatusType*);
extern void reduce_lflat_(DitsArgType*,StatusType*);
extern void reduce_fflx_(DitsArgType*,StatusType*);
extern void reduce_object_(DitsArgType*,StatusType*);
extern void reduce_sky_(DitsArgType*,StatusType*);
extern void splice_aaomega_(DitsArgType*,StatusType*);
extern void detect_cosmic_streaks_(DitsArgType*,StatusType*);
static void combineImageAction(StatusType*);
static void combineSpectraAction(StatusType*);
/* static void flxCalibAction(StatusType*); */
/* static void genCalibAction(StatusType*); */
mnb
committed
static void plotKick(StatusType*);
static void reduceArcAction(StatusType*);
static void reduceBiasAction(StatusType*);
static void reduceFFlatAction(StatusType*);
static void reduceLFlatAction(StatusType*);
static void reduceFFluxAction(StatusType*);
static void reduceObjAction(StatusType*);
static void reduceSkyAction(StatusType*);
static void spliceAction(StatusType*);
static void detectCosmicStreaksAction(StatusType*);
mnb
committed
static void testAction(StatusType*);
static void testKick(StatusType*);
void SetPgplotRequest(char key, float x, float y);
void GetPgplotRequest(char* key, float* x, float* y);
/*---------------------------------------------------------------------------*/
* This task acts as an action server for 2dfdr. drcontrol acts as the client
* DRAMA task sending this task requests for 2dfdr processing.
* N.B. This task BREAKS one of the cardinal rules of DRAMA -
* 1. Tasks accepting and servicing actions shall reschedule immediately
* thereby being ready for any new actions (or kicks).
* Notice the DRAMA actions served by this task are quite CPU intensive,
* and the program does NOT reschedule until they complete.
StatusType status = DITS__OK;
char taskName[40];
{ combineImageAction, plotKick,0,0,0,0,"COMBINE_IMAGE"},
{ combineSpectraAction,plotKick,0,0,0,0,"COMBINE_SPECTRA"},
/* { flxCalibAction, 0,0,0,0,0,"FLX_CALIB"}, */
/* { genCalibAction, 0,0,0,0,0,"GEN_CALIB"}, */
{ find2dfFibresAction, plotKick,0,0,0,0,"GFIBPOS"},
mnb
committed
{ plotAction, plotKick,0,0,0,0,"PLOT"},
{ reduceArcAction, plotKick,0,0,0,0,"REDUCE_ARC"},
{ reduceBiasAction, plotKick,0,0,0,0,"REDUCE_BIAS"},
{ reduceDarkAction, plotKick,0,0,0,0,"REDUCE_DARK"},
{ reduceFFlatAction, plotKick,0,0,0,0,"REDUCE_FFLAT"},
{ reduceLFlatAction, plotKick,0,0,0,0,"REDUCE_LFLAT"},
{ reduceFFluxAction, plotKick,0,0,0,0,"REDUCE_FFLX"},
{ reduceObjAction, plotKick,0,0,0,0,"REDUCE_OBJECT"},
{ reduceSkyAction, plotKick,0,0,0,0,"REDUCE_SKY"},
{ spliceAction, plotKick,0,0,0,0,"SPLICE"},
{ detectCosmicStreaksAction,plotKick,0,0,0,0,"DETECT_CSTRKS"},
mnb
committed
{ exitAction, 0,0,0,0,0,"EXIT"},
{ testAction, plotKick, 0, 0, 0, 0, "TEST"}
mnb
committed
/* { testAction, 0,0,0,0,0,"TEST"}*/
/* The task name is normally given in argv[1]. Multiple copies of the
task can be started using different task names. A default name is
used if one is not given. */
strcpy(taskName,(argc > 1) ? argv[1] : "DREXEC");
/* initialise DRAMA
DITS_M_NOEXHAND => we will install exit handler */
DitsAppInit(taskName,300000,DITS_M_NOEXHAND,0,&status);
/* define supported actions */
DitsPutActions(DitsNumber(actions),actions,&status);
/* enter DRAMA main loop
This returns when action returns DITS_REQ_EXIT */
DitsMainLoop(&status);
/* here returned from DRAMA main loop, shutdown DRAMA and exit */
/*---------------------------------------------------------------------------*/
/* for debug print our argument structure on stdout
SdsList(args,pStatus); */
/*---------------------------------------------------------------------------*/
/* for debug print our argument structure on stdout
SdsList(args,pStatus);*/
/*---------------------------------------------------------------------------*/
*
* This action is not currently working. See flux_cal.f.
/* for debug print our argument structure on stdout
SdsList(args,pStatus); */
/* make copy so it can be changed (external SDS -> internal) */
/* SdsCopy(args,&localArgs,pStatus); */
/* flx_calib_(&args,pStatus); */
/* delete local SDS copy */
/*---------------------------------------------------------------------------*/
*
* This action is not currently working. See flux_cal.f.
/* get our SDS argument structure */
args = DitsGetArgument();
/* for debug print our argument structure on stdout
SdsList(args,pStatus);*/
/* make copy so it can be changed (external SDS -> internal) */
/* SdsCopy(args,&localArgs,pStatus); */
/* gen_calib_(&args,pStatus); */
/* delete local SDS copy */
/* SdsDelete(localArgs,pStatus); */
DitsPutRequest(DITS_REQ_END,pStatus);
/*---------------------------------------------------------------------------*/
*
* This action is not currently working. See find_fib_2df.f.
/* for debug print our argument structure on stdout
SdsList(args,pStatus);*/
/*---------------------------------------------------------------------------*/
SdsIdType inpArgs, outArgs;
SdsIdType id2;
/* Get our input SDS argument structure */
/* Note: This is an external SDS object and cannot be modified*/
SdsCopy(args,&inpArgs,pStatus);
/* Create a return sds object that can be written to*/
SdsNew(0,"retArgs",0,NULL,SDS_STRUCT,0,NULL,&outArgs,pStatus);
/* call the Fortran subroutine PLOT2() */
plot2_(&inpArgs,&outArgs,pStatus);
/* Set the return SDS object to be outArgs*/
DitsPutArgument (outArgs,DITS_ARG_DELETE, pStatus);
}
/*---------------------------------------------------------------------------*/
mnb
committed
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
void plotKick(
StatusType *pStatus)
/*
* Handler for kicking the "Plot" DRAMA action.
*/
{
DitsArgType args;
char key;
char Buffer[10];
float x,y;
if (*pStatus != DITS__OK) return;
/* get our SDS argument structure */
args = DitsGetArgument();
/* Obtain the KEY character and the X Y values*/
/* Note: ArgGetc(args,"KEY",&key,pStatus) doesn't appear to work so
we use ArgGetString instead */
ArgGetString(args,"KEY",10,Buffer,pStatus);
key=Buffer[0];
ArgGetf(args,"X",&x,pStatus);
ArgGetf(args,"Y",&y,pStatus);
/* Store these values with Pgplot Request Set Functions*/
SetPgplotRequest(key,x,y);
/* Now this is the bit I am not sure about but is supposed to unblock
the DitsActionWait command */
DitsPutRequest(DITS_REQ_STAGE,pStatus);
}
/*---------------------------------------------------------------------------*/
SdsIdType localArgs = 0;
StatusType ignore = STATUS__OK;
/* for debug print our argument structure on stdout
SdsList(args,pStatus); */
/* make copy so it can be changed (external SDS -> internal) */
SdsCopy(args,&localArgs,pStatus);
if (*pStatus!=DITS__OK) {
ErsRep(0,pStatus,"%s","reduce arc error");
}
/* delete local SDS copy and free id */
SdsDelete(localArgs,&ignore);
SdsFreeId(localArgs,&ignore);
DitsPutRequest(DITS_REQ_END,pStatus);
}
/*---------------------------------------------------------------------------*/
*/
{
DitsArgType args;
if (*pStatus != DITS__OK) return;
/* for debug print our argument structure on stdout
SdsList(args,pStatus); */
if (*pStatus!=DITS__OK) {
ErsRep(0,pStatus,"%s","reduce bias error");
}
DitsPutRequest(DITS_REQ_END,pStatus);
}
/*---------------------------------------------------------------------------*/
void reduceDarkAction(
StatusType* pStatus)
/*
* Handler for "REDUCE_DARK" DRAMA action.
*/
{
DitsArgType args;
if (*pStatus != DITS__OK) return;
/* get our SDS argument structure */
args = DitsGetArgument();
/* for debug print our argument structure on stdout
SdsList(args,pStatus); */
if (*pStatus!=DITS__OK) {
ErsRep(0,pStatus,"%s","reduce dark error");
}
DitsPutRequest(DITS_REQ_END,pStatus);
}
/*---------------------------------------------------------------------------*/
SdsIdType localArgs = 0;
StatusType ignore = STATUS__OK;
/* for debug print our argument structure on stdout
SdsList(args,pStatus); */
/* make copy so it can be changed (external SDS -> internal) */
SdsCopy(args,&localArgs,pStatus);
if (*pStatus!=DITS__OK) {
ErsRep(0,pStatus,"%s","reduce flat error");
}
/* delete local SDS copy and free id */
SdsDelete(localArgs,&ignore);
SdsFreeId(localArgs,&ignore);
DitsPutRequest(DITS_REQ_END,pStatus);
}
/*---------------------------------------------------------------------------*/
*/
{
DitsArgType args;
if (*pStatus != DITS__OK) return;
/* for debug print our argument structure on stdout
SdsList(args,pStatus); */
if (*pStatus!=DITS__OK) {
ErsRep(0,pStatus,"%s","reduce long flat error");
}
DitsPutRequest(DITS_REQ_END,pStatus);
}
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
/*---------------------------------------------------------------------------*/
void reduceFFluxAction(
StatusType* pStatus)
/*
* Handler for "REDUCE_FFLX" DRAMA action.
*/
{
DitsArgType args;
SdsIdType localArgs = 0;
StatusType ignore = STATUS__OK;
if (*pStatus != DITS__OK) return;
/* get our SDS argument structure */
args = DitsGetArgument();
/* for debug print our argument structure on stdout
SdsList(args,pStatus); */
/* make copy so it can be changed (external SDS -> internal) */
SdsCopy(args,&localArgs,pStatus);
/* call Fortran REDUCE_OBJECT() */
reduce_fflx_(&localArgs,pStatus);
if (*pStatus!=DITS__OK) {
ErsRep(0,pStatus,"%s","reduce object error");
}
/* delete local SDS copy and free its id*/
SdsDelete(localArgs,&ignore);
SdsFreeId(localArgs,&ignore);
DitsPutRequest(DITS_REQ_END,pStatus);
}
/*---------------------------------------------------------------------------*/
SdsIdType localArgs = 0;
StatusType ignore = STATUS__OK;
if (*pStatus != DITS__OK) return;
/* for debug print our argument structure on stdout
SdsList(args,pStatus); */
/* make copy so it can be changed (external SDS -> internal) */
SdsCopy(args,&localArgs,pStatus);
if (*pStatus!=DITS__OK) {
ErsRep(0,pStatus,"%s","reduce object error");
}
/* delete local SDS copy and free its id*/
SdsDelete(localArgs,&ignore);
SdsFreeId(localArgs,&ignore);
DitsPutRequest(DITS_REQ_END,pStatus);
}
/*---------------------------------------------------------------------------*/
SdsIdType localArgs = 0;
StatusType ignore = STATUS__OK;
/* for debug print our argument structure on stdout
SdsList(args,pStatus); */
/* make copy so it can be changed (external SDS -> internal) */
SdsCopy(args,&localArgs,pStatus);
if (*pStatus!=DITS__OK) {
ErsRep(0,pStatus,"%s","reduce sky error");
}
/* delete local SDS copy and free its id*/
SdsDelete(localArgs,&ignore);
SdsFreeId(localArgs,&ignore);
DitsPutRequest(DITS_REQ_END,pStatus);
}
/*---------------------------------------------------------------------------*/
*/
{
DitsArgType args;
if (*pStatus != DITS__OK) return;
/* get our SDS argument structure */
args = DitsGetArgument();
/* for debug print our argument structure on stdout
SdsList(args,pStatus); */
if (*pStatus != DITS__OK) {
ErsRep(0,pStatus,"%s","splice error");
}
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
/*---------------------------------------------------------------------------*/
void detectCosmicStreaksAction(
StatusType* pStatus)
/*
* Handler for "DETECT_CSTRKS" DRAMA action.
*/
{
DitsArgType args;
SdsIdType localArgs = 0;
StatusType ignore = STATUS__OK;
if (*pStatus != DITS__OK) return;
/* get our SDS argument structure */
args = DitsGetArgument();
/* for debug print our argument structure on stdout
SdsList(args,pStatus); */
/* make copy so it can be changed (external SDS -> internal) */
SdsCopy(args,&localArgs,pStatus);
/* call Fortran DETECT_COSMIC_STREAKS() */
detect_cosmic_streaks_(&args,pStatus);
if (*pStatus!=DITS__OK) {
ErsRep(0,pStatus,"%s","cosmic streak detection error error");
}
/* delete local SDS copy and free its id*/
SdsDelete(localArgs,&ignore);
SdsFreeId(localArgs,&ignore);
DitsPutRequest(DITS_REQ_END,pStatus);
}
/*---------------------------------------------------------------------------*/
mnb
committed
/*---------------------------------------------------------------------------*/
void testAction(
StatusType *pStatus)
/*
* Handler for "TEST" DRAMA action.
*/
{
printf("Test Drama Action Called\n");
DitsPutRequest(DITS_REQ_MESSAGE,pStatus);
mnb
committed
DitsPutRequest(DITS_REQ_END,pStatus);
}
/*---------------------------------------------------------------------------*/
mnb
committed
void testKick(
StatusType *pStatus)
/*
mnb
committed
*/
{
mnb
committed
DitsPutRequest(DITS_REQ_END,pStatus);
}