コード例 #1
0
ファイル: Adaptor.cpp プロジェクト: Vivek-sagar/moose-1
void Adaptor::process( const Eref& e, ProcPtr p )
{
	static FuncId fid = handleInput()->getFid(); 
	requestInput()->send( e, p->threadIndexInGroup );
	requestField()->send( e, p->threadIndexInGroup, fid );
	innerProcess();
	outputSrc()->send( e, p->threadIndexInGroup, output_ );
}
コード例 #2
0
ファイル: Adaptor.cpp プロジェクト: Vivek-sagar/moose-1
const Cinfo* Adaptor::initCinfo()
{
	///////////////////////////////////////////////////////
	// Field definitions
	///////////////////////////////////////////////////////
	static ValueFinfo< Adaptor, double > inputOffset( 
			"inputOffset",
			"Offset to apply to input message, before scaling",
			&Adaptor::setInputOffset,
			&Adaptor::getInputOffset
		);
	static ValueFinfo< Adaptor, double > outputOffset( 
			"outputOffset",
			"Offset to apply at output, after scaling",
			&Adaptor::setOutputOffset,
			&Adaptor::getOutputOffset
		);
	static ValueFinfo< Adaptor, double > scale( 
			"scale",
			"Scaling factor to apply to input",
			&Adaptor::setScale,
			&Adaptor::getScale
		);
	static ReadOnlyValueFinfo< Adaptor, double > output( 
			"output",
			"This is the linearly transformed output.",
			&Adaptor::getOutput
		);

	///////////////////////////////////////////////////////
	// MsgDest definitions
	///////////////////////////////////////////////////////
	static DestFinfo input( 
			"input",
			"Input message to the adaptor. If multiple inputs are "
			"received, the system averages the inputs.",
		   	new OpFunc1< Adaptor, double >( &Adaptor::input )
		);
	/*
		new DestFinfo( "setup", 
			Ftype4< string, double, double, double >::global(), 
			RFCAST( &Adaptor::setup ),
			"Sets up adaptor in placeholder mode."
			"This is done when the kinetic model is yet to be built, "
			"so the adaptor is given the src/target molecule name as "
			"a placeholder. Later the 'build' function will complete "
			"setting up the adaptor.\n"
			"Args: moleculeName, scale, inputOffset, outputOffset. "
			"Note that the direction of the adaptor operation is given "
			"by whether the channel/Ca is connected as input or output."
		),
		new DestFinfo( "build", Ftype0::global(), 
			RFCAST( &Adaptor::build ),
			"Completes connection to previously specified molecule "
			"on kinetic model."
		),
		*/

	///////////////////////////////////////////////////////
	// Shared definitions
	///////////////////////////////////////////////////////
	static  DestFinfo process( "process", 
				"Handles 'process' call",
			new ProcOpFunc< Adaptor>( &Adaptor::process )
	);
	static  DestFinfo reinit( "reinit", 
				"Handles 'reinit' call",
			new ProcOpFunc< Adaptor>( &Adaptor::reinit )
	);

	static Finfo* processShared[] =
	{
			&process, &reinit
	};
	static SharedFinfo proc( "proc", 
		"This is a shared message to receive Process message "
		"from the scheduler. ",
		processShared, sizeof( processShared ) / sizeof( Finfo* )
	);

	/*
	static DestFinfo handleInput( "handleInput", 
			"Handle the returned value.",
			new OpFunc1< Adaptor, double >( &Adaptor::input )
	);
	*/

	static Finfo* inputRequestShared[] =
	{
		requestInput(),
		handleInput()
	};
	static SharedFinfo inputRequest( "inputRequest",
		"This is a shared message to request and handle value "
	   "messages from fields.",
		inputRequestShared, 
		sizeof( inputRequestShared ) / sizeof( Finfo* )
	);

	//////////////////////////////////////////////////////////////////////
	// Now set it all up.
	//////////////////////////////////////////////////////////////////////
	static Finfo* adaptorFinfos[] = 
	{
		&inputOffset,				// Value
		&outputOffset,				// Value
		&scale,						// Value
		&output,					// ReadOnlyValue
		&input,						// DestFinfo
		outputSrc(),				// SrcFinfo
		requestField(),				// SrcFinfo
		&proc,						// SharedFinfo
		&inputRequest,				// SharedFinfo
	};
	
	static string doc[] =
	{
		"Name", "Adaptor",
		"Author", "Upinder S. Bhalla, 2008, NCBS",
		"Description", "Averages and rescales values to couple different kinds of simulation",
	};

	static Cinfo adaptorCinfo(
		"Adaptor",
		Neutral::initCinfo(),
		adaptorFinfos,
		sizeof( adaptorFinfos ) / sizeof( Finfo * ),
		new Dinfo< Adaptor >(),
		doc,
		sizeof( doc ) / sizeof( string )
	);

	return &adaptorCinfo;
}
コード例 #3
0
/**
 * \brief Retrieve an image from the caemra
 *
 * This method completes the exposure on the main ccd and reads the field.
 * Depending on the exposure time, it then either starts a new exposure
 * (for short exposures, because the second field would otherwise be too
 * different), or reads out the already exposed second field (for long
 * exposures). In the latter case, the first field is rescaled to account
 * for the different exposure time.
 */
void	SxCcdM26C::getImage0() {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "get an image from the camera");

	// read the right number of pixels from the IN endpoint
	Field	*field0 = readField();
	debug(LOG_DEBUG, DEBUG_LOG, 0, "field 0 transferred");
	if (debuglevel == LOG_DEBUG) {
		debug(LOG_DEBUG, DEBUG_LOG, 0, "writing field 0");
		std::ofstream	out("field0.raw", std::ofstream::binary);
		out << *field0;
		out.close();
	}

	// for long exposures, we just read the second field.
	Field	*field1 = NULL;
	if (exposure.exposuretime() > EXPOSURE_FIELD_CUTOVER) {
		debug(LOG_DEBUG, DEBUG_LOG, 0, "request second field 1");
		timer.end();
		requestField(1);
	} else {
		debug(LOG_DEBUG, DEBUG_LOG, 0, "expose second field 1");
		exposeField(1);
	}

	// read the second field
	debug(LOG_DEBUG, DEBUG_LOG, 0, "read field 1");
	field1 = readField();
	if (debuglevel == LOG_DEBUG) {
		debug(LOG_DEBUG, DEBUG_LOG, 0, "writing field 1");
		std::ofstream	out("field1.raw", std::ofstream::binary);
		out << *field1;
		out.close();
	}

	// rescale the first field, if we did only one exposure
	if (exposure.exposuretime() > EXPOSURE_FIELD_CUTOVER) {
		//double	deadtime = 3.37; // exposuretime = 11
		//double	deadtime = 3.99; // exposuretime = 20
		double	deadtime = 1.2;
		double	scalefactor
			= (timer.elapsed() - deadtime) / exposure.exposuretime();
		debug(LOG_DEBUG, DEBUG_LOG, 0, "scalefactor = %f", scalefactor);
		// rescale the field. We have to multiply the first field
		// with the scaling factor, because of overflows
		if (scalefactor > 0) {
			field0->rescale(scalefactor);
		} else {
			debug(LOG_DEBUG, DEBUG_LOG, 0, "no rescaling");
		}
		//field0->rescale(1.1283);
	}

	// prepare a new image, this now needs binned pixels
	Image<unsigned short>	*_image = new Image<unsigned short>(
		exposure.frame().size() / exposure.mode());
	_image->setOrigin(exposure.frame().origin());
	_image->setMosaicType(MosaicType::BAYER_RGGB);

	// now we have to demultiplex the two fields
	debug(LOG_DEBUG, DEBUG_LOG, 0, "demultiplex the fields");
	if (1 == exposure.mode().x()) {
		DemuxerUnbinned	demuxer;
		demuxer(*_image, *field0, *field1);
	} else {
		DemuxerBinned	demuxer;
		demuxer(*_image, *field0, *field1);
	}

	// remove the data
	delete field0;
	delete field1;

	// return the demultiplexed image
	image = ImagePtr(_image);
	state = Exposure::exposed;
}