Example #1
0
int Camera::setExposureTime(int whichSide, float expTime)
{
#ifdef _WIN32
	int retCode= eSPAEAWB_SetExposureTime(whichSide, expTime);
	return retCode;
#elif __APPLE__
    int retCode = setExposureTime(whichSide, expTime);
    return retCode;
#endif
}
Example #2
0
/** Called when asyn clients call pasynFloat64->write().
  * For all  parameters it  sets the value in the parameter library and calls any registered callbacks.
  * \param[in] pasynUser pasynUser structure that encodes the reason and address.
  * \param[in] value Value to write. */
asynStatus mythen::writeFloat64(asynUser *pasynUser, epicsFloat64 value)
{
    int function = pasynUser->reason;
    int status = asynSuccess;
    int addr = 0;
    const char* functionName = "writeFloat64";

    status = getAddress(pasynUser, &addr); 
    if (status != asynSuccess) return((asynStatus)status);

    /* Reject any call to the detector if it is running */
    if (acquiring_) {
        asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR, 
        "%s:%s: detector is busy\n", driverName, functionName);
        return asynError;
    }

    /* Set the parameter in the parameter library. */
    status = (asynStatus) setDoubleParam(addr, function, value);

    if (function == ADAcquireTime) {
      status |= setExposureTime(value);
    } else if (function == SDDelayTime) {
      status |= setDelayAfterTrigger(value);
    } else if (function == SDThreshold) {
        /* note down user's set value and recover it when settings change */
        // threshold = value;
        status |= setKthresh(value);
    } else if (function == SDEnergy) {
        status |= setEnergy(value);
    } else if (function == SDTau) {
        status |= setTau(value);
    } else {
        /* If this is not a parameter we have handled call the base class */
        if (function < NUM_SD_PARAMS) status = ADDriver::writeFloat64(pasynUser, value);
    }

 
    status |= getSettings();
   
    /* Update any changed parameters */
    status |= callParamCallbacks();

    if (status) 
        asynPrint(pasynUser, ASYN_TRACE_ERROR, 
              "%s:%s: error, status=%d function=%d, value=%g\n", 
              driverName, functionName, status, function, value);
    else        
        asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, 
              "%s:%s: function=%d, value=%g\n", 
              driverName, functionName, function, value);
    return((asynStatus)status); 
}
ANDOR885_Camera::ANDOR885_Camera()
{
	debugging = false;

	initialized = false;
	notDestructed = false;
	extension = ".tif";

	eventMetadata = NULL;

	pauseCameraMutex = new omni_mutex();
	pauseCameraCondition = new omni_condition(pauseCameraMutex);
	stopEventMutex = new omni_mutex();
	stopEventCondition = new omni_condition(stopEventMutex);
	stopEvent = false;
	numAcquiredMutex = new omni_mutex();
	numAcquiredCondition = new omni_condition(numAcquiredMutex);
	waitForEndOfAcquisitionMutex = new omni_mutex();
	waitForEndOfAcquisitionCondition = new omni_condition(waitForEndOfAcquisitionMutex);
	waitForCleanupEventMutex = new omni_mutex();
	waitForCleanupEventCondition = new omni_condition(waitForCleanupEventMutex);
	bool cleanupEvent = false;

	//Initialize necessary parameters
	readMode_t.name = "Read mode"; //If ever there is more than one read mode, be sure to properly initialize this for playing events!
	readMode_t.choices[READMODE_IMAGE] = "Image";

	shutterMode_t.name = "Shutter mode";
	shutterMode_t.choices[SHUTTERMODE_AUTO] = "Auto";
	shutterMode_t.choices[SHUTTERMODE_OPEN] = "Open";
	shutterMode_t.choices[SHUTTERMODE_CLOSE] = "Closed";

	acquisitionMode_t.name = "**Acquisition mode (RTA)";
	acquisitionMode_t.choices[ACQMODE_SINGLE_SCAN] = "Single scan";
	acquisitionMode_t.choices[ACQMODE_KINETIC_SERIES] = "Kinetic series";
	acquisitionMode_t.choices[ACQMODE_RUN_TILL_ABORT] = "Run 'til abort";

	triggerMode_t.name = "**Trigger mode (EE)";
	triggerMode_t.choices[TRIGGERMODE_EXTERNAL] = "External";
	triggerMode_t.choices[TRIGGERMODE_EXTERNAL_EXPOSURE] = "External exposure";
	triggerMode_t.choices[TRIGGERMODE_INTERNAL] = "Internal";

	preAmpGain_t.name = "*Preamp Gain";
//	preAmpGain_t.choices.push_back("");
//	preAmpGain_t.choiceFlags.push_back(PREAMP_BLANK);
	preAmpGain = NOT_AVAILABLE;
//	preAmpGainPos = PREAMP_BLANK;

	verticalShiftSpeed_t.name = "*Vertical Shift Speed (us/px)";
	verticalClockVoltage_t.name = "*Vertical Clock Voltage";
	horizontalShiftSpeed_t.name = "*Horizontal Shift Speed (us)";

//	pImageArray = NULL;

	cameraStat		=	ANDOR_ON;
	acquisitionMode	=	ACQMODE_RUN_TILL_ABORT;
	readMode		=	READMODE_IMAGE;
	exposureTime	=	(float) 0.05; // in seconds
	accumulateTime	=	0;
	kineticTime		=	0;
	ttl				=	TTL_OPEN_HIGH;
	shutterMode		=	SHUTTERMODE_OPEN;
	closeTime		=	SHUTTER_CLOSE_TIME;
	openTime		=	SHUTTER_OPEN_TIME;
//	triggerMode		=	TRIGGERMODE_EXTERNAL_EXPOSURE; //will be set by InitializeCamera
	frameTransfer	=	ANDOR_OFF;
//	spoolMode		=	ANDOR_OFF;				
	coolerSetpt		=  -90;
	coolerStat		=	ANDOR_ON;
	cameraTemp		=	20;
	EMCCDGain		=	NOT_AVAILABLE;

	verticalShiftSpeed = 0;
	verticalClockVoltage = 0;
	horizontalShiftSpeed = 0;

	readMode_t.initial = readMode_t.choices.find(readMode)->second;
	shutterMode_t.initial = shutterMode_t.choices.find(shutterMode)->second;
//	triggerMode_t.initial = triggerMode_t.choices.find(triggerMode)->second;
	acquisitionMode_t.initial = acquisitionMode_t.choices.find(acquisitionMode)->second;

	//Name of path to which files should be saved
	filePath		=	createFilePath();
	logPath			=	"C:\\Documents and Settings\\EP Lab\\Desktop\\";
	palPath			=	"C:\\Documents and Settings\\User\\My Documents\\My Pictures\\Andor_iXon\\GREY.PAL";

	initialized = !InitializeCamera();

	if (initialized){
		notDestructed = true;

		omni_thread::create(playCameraWrapper, (void*) this, omni_thread::PRIORITY_HIGH);
	

		try {
			setExposureTime(exposureTime);
			setTriggerMode(triggerMode);
		} catch (ANDOR885_Exception& e){
			std::cerr << e.printMessage() << std::endl;
			initialized = false;
		}
		


		if (debugging) {
			try {
				setAcquisitionMode(acquisitionMode);
				setReadMode(readMode);
			} catch (ANDOR885_Exception& e){
				std::cerr << e.printMessage() << std::endl;
				initialized = false;
			}
		} 
	}
}
Example #4
0
int main(int argc, char *argv[])
{
	/* definition of basic variables */
	int state;

	/* Handle signals. This is useful to intercept accidental Ctrl+C
	 * which would otherwise just kill the process without any cleanup.
	 * This could also be useful when the process is managed by some
	 * other program, e.g. systemD.
	 * - SIGINT will be send by pressing Ctrl+C
	 * - SIGTERM will be send by process managers, e.g. systemD
	 *   wishing to stop the process
	 *
	 * Windows has its own ctrl handlers, we only really care about
	 * Ctrl+C, but others could be implemented as well (see above).
	 */
#ifdef POSIX
	struct sigaction sa, osa;
	memset(&sa, 0, sizeof(sa));
	sa.sa_handler = &stop_program;
	sigaction(SIGINT, &sa, &osa);
	sigaction(SIGTERM, &sa, &osa);
#else
	if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE)) {
		log_error("Control handler could not be installed, Ctrl+C won't work");
	}
#endif

	/* initiate the logfile and start logging */
	state = log_init();
	if (state != 0) {
		/*
		 * if creating a logfile fails we have to terminate the program.
		 * The error message then has to go directly to the screen
		 */
		printf("creating a logfile failed. Program is aborting...\n");
		stop_program(state);
		return state;
	}

	/*
	 * set default values, read config file and process cli arguments,
	 * which override settings in the config file
	 */
	config.dHistMinInterval = 350;
	config.dHistPercentage = 5;
	config.dInterFrameDelay = 10;
	config.dBufferlength = 1376256;

	state = load_config("configurations//SO2Config.conf", &config);
	if (state != 0) {
		log_error("loading configuration failed");
		stop_program(1);
		return 1;
	}

	state = process_cli_arguments(argc, argv, &config);
	if (state != 0) {
		log_error("Could not handle command line arguments");
		return state;
	}

	/* Initialise parameter structures */
	structInit(&sParameters_A, &config, 'a');
	structInit(&sParameters_B, &config, 'b');

	/* initialize IO */
	state = io_init(&config);
	if (state != 0) {
		log_error("io_init failed");
		stop_program(1);
		return state;
	}

	/* init filterwheel */
	state = filterwheel_init(&config);
	if (state != 0) {
		log_error("failed to initialize filterwheel");
		stop_program(1);
		return state;
	}
	log_message("filterwheel initialized");

	/* open filterwheel */
	state = filterwheel_send(FILTERWHEEL_OPENED_A);
	if (state != 0) {
		/* this is critical if this function fails no camera handle is returned */
		log_error("failed to open filterwheel");
		stop_program(1);
		return state;
	}
	log_message("filterwheel opened");

	/* initiate camera */
	state = camera_init(&sParameters_A);
	if (state != 0) {
		/* this is critical if this function fails no camera handle is returned */
		log_error("camera_init for Camera A failed");
		stop_program(1);
		return state;
	}
	log_message("camera A initialized");

	state = camera_init(&sParameters_B);
	if (state != 0) {
		/* this is critical if this function fails no camera handle is returned */
		log_error("camera_init for Camera B failed");
		stop_program(1);
		return state;
	}
	log_message("camera B initialized");

	/* configure camera */
	state = camera_config(&sParameters_A);
	if (state != 0) {
		log_error("config camera A failed");
		stop_program(1);
		return 1;
	}
	log_message("camera A configured");

	state = camera_config(&sParameters_B);
	if (state != 0) {
		log_error("config camera B failed");
		stop_program(1);
		return 1;
	}
	log_message("camera B configured");

	/* set exposure */
	state = setExposureTime(&sParameters_A, &config);
	if (state != 0) {
		log_error("setExposureTime for cam B failed");
		stop_program(1);
		return 1;
	}
	log_message("exposure time for cam A set");

	state = setExposureTime(&sParameters_B, &config);
	if (state != 0) {
		log_error("setExposureTime for cam B failed");
		stop_program(1);
		return 1;
	}
	log_message("exposure time for cam B set");

	/*
	 * Starting the acquisition with the exposure parameter set in
	 * configurations.c and exposureTimeControl.c
	 */
	state = startAquisition(&sParameters_A, &sParameters_B, &config);
	log_message("Aquisition stopped");
	if (state != 0) {
		log_error("Aquisition failed");
		stop_program(1);
		return 1;
	}

	/* we're done! */
	stop_program(0);

	return 0;
}