Esempio n. 1
0
int main(){ // the argument list is not used
  // but there is provision for it.

  printf("Welcome to the FIREBALL Guider. Please wait while we configure\n");

    fflush(NULL);

  StartLog();
  GtoM_StartCount(); 
  GtoT_StartCount();
  ResetReceivedMessageCounters();

  trackpointEL = CHIPHEIGHT/2;
  trackpointCE = CHIPWIDTH/2;

  QCamera camera; // open the camera.

  //  UniversalTime();
  //  printf("The Local Sidereal Time is: %lf\n",LST(31.761, -95.63));

  /*
  double ra1, ra2;
  double dec1, dec2;
  double alt1, alt2;
  double az1, az2;
  double del, dce;
  double lat, lon;
  */ 

  GtoT_CameraError(0);

  SetLatLon(31.761,-95.64);

  /*  lat = 31.761;
  lon = -95.64;
  ra1 = 0.50;
  ra2 = 0.51;
  dec1 = 0.41;
  dec2 = 0.41;
  RADEC_to_ALTAZ(ra1,dec1, lat,lon, &alt1,&az1);
  printf("the first alt-az I have found: %lf %lf\n",alt1,az1);
  RADEC_to_ALTAZ(ra2,dec2, lat,lon, &alt2,&az2);
  printf("the second alt-az I have found: %lf %lf\n",alt2,az2);
  ALTAZ_to_ELCE(alt1,az1,alt2,az2,&del,&dce); 
  printf("The difference I have found is: %lf %lf\n",del,dce);
  */
  InitDAC(); // prepare the dac.

  InitializeLEDs(); // turn off the Lamp.

  if(!ComSetup()) GtoT_TextError("COM working");


  //  RunSillyProg();

  StartDisplay(); // begin the display.

  turnOnGps();
  

  // starts some of the statistic quantities. Defaulting to 100 frames -- 10s in full chip mode, 3s in ROI mode. 





  InitMode.setCallback(InitModeCallback);
  AutocollimationMode.setCallback(AutocollimationModeCallback);
  AlignmentMode.setCallback(AlignmentModeCallback);
  AlignmentSubMode.setCallback(AlignmentModeCallback);
  SlewingMode.setCallback(SlewPointModeCallback);
  PointingMode.setCallback(SlewPointModeCallback);
  PointingModeRoi.setCallback(SlewPointModeCallback);
 
  camera.prepSettings(InitMode,0,0);
  if(camera.LoadQCamState()){
    switch(camera.nextMode.getModeID()){
    case INITMODE:{
      camera.nextMode.setCallback(InitModeCallback);
      break;
    };
    case ALIGNMENTMODE:{
      camera.nextMode.setCallback(AlignmentModeCallback);
      alignmentMD.winx = camera.getWinX();
      alignmentMD.winy = camera.getWinY();
      alignmentMD.wind = camera.getWinDX();
      WriteToLog("Stuff","%d %d %d",alignmentMD.winx,alignmentMD.winy,alignmentMD.wind);
      break;
    };
    case SLEWINGMODE:{
      camera.nextMode.setCallback(SlewPointModeCallback);
      break;
    };
    case POINTINGMODE:{
      camera.nextMode.setCallback(SlewPointModeCallback);
      break;
    };
    case AUTOCOLLIMATIONMODE:{
      camera.nextMode.setCallback(AutocollimationModeCallback);
      break;
    };  
    default:
      break;
    };
  };
  //  camera.prepSettings(SlewingMode,0,0);
  //  camera.prepSettings(PointingMode,0,0);
  //  camera.nowMode.setEqual(AlignmentMode);
 
  //    HomeCamera();
  
    //MoveStage(30000);

  // periodicmessages.h/c contains the variables and calls needed to 
  // set up periodic messages that have to be sent to the MPF and the 
  // ground in various modes. 
#include "periodicmessages.h"
  
  // processmessages.h/c contains the variables and calls needed to 
  // process the messages from the MPF and the ground.
#include "processmessages.h"


  //for every change of mode there will be a goto mainloop command
  //to exit a program there will be a goto loopexit command. 

  FillRSquared();
  //  if(camera.getActiveSensor() == GUIDERSENSOR){
  //    GtoM_SwitchingGuiderRequest();
  //  };
  //  HelloDither.DitherPattern1(10);
 MainLoop:
  
  camera.stopStreaming();  // stop camera streaming


  camera.changeSettings(); // adjust camera parameters, including 
                           // the trigger time.

  modeID = camera.getModeID();

  camera.startStreaming(); // restart camera streaming. 


  //  WriteToLog("Got Here! B ");
  loopcounter = 0;

  if(camera.getModeID() == POINTINGMODE || (camera.getModeID()==ALIGNMENTMODE && camera.getSubModeID()==ALIGNTRACKROI)){
    ClearScreen();
    FontOverwrite();
  } else {
    FontMask();
  };
  
  //  WriteToLog("Got Here A !");

  if(camera.getModeID()==ALIGNMENTMODE && (camera.getSubModeID() == ALIGNTRACKROI || camera.getSubModeID() == ALIGNTRACKFULLCHIP || camera.getSubModeID() == ALIGNDRAGFULLCHIP)){
    //    GtoM_SwitchingGuiderRequest();
    //    camera.setActiveSensor(GUIDERSENSOR);
  } else {
    //    GtoM_SwitchingDTURequest();
    //    camera.setActiveSensor(OTHERSENSOR);
  }

  //    WriteToLog("Got Here!");
  //    WriteToLog("FLOOD","%d %d %d" ,camera.getRoiX(), camera.getRoiY(),camera.getRoiDX());
  do{

    #include "periodicmessages.cpp"
    #include "processmessages.cpp"

    camera.queueFrame();
    


  } while(1);
  

  camera.~QCamera();
  CloseLog();

  return 0;
};