예제 #1
0
//=====================================================================
//=====================================================================
//=================================================================================================
//=================================================================================================
void Camera::_set_shutter_rolling_edge(DWORD dwRolling, int &error)
{
		
	DEB_MEMBER_FUNCT();
	error = 0;

	if(!_isValid_rollingShutter(dwRolling)) 
	{
		DEB_ALWAYS() << "ERROR requested Rolling Shutter not allowed " << DEB_VAR1(dwRolling);
		error = -1;
		return;
	}

	m_pcoData->dwRollingShutter = dwRolling;

	DEB_TRACE() << "requested Rolling Shutter OK " << DEB_VAR1(dwRolling);

	_beginthread( _pco_shutter_thread_edge, 0, (void*) this);

	return;

}
예제 #2
0
static int
mlib_store_meta_event (mlib_desc * desc, mlib_track * track, int *optr,
		       unsigned char *evbuf, int len)
{
  int type = evbuf[0];
  int i;

/*
 * The event is stored at the end of this function. If there is no 
 * need to store the event, the case entry should return (return 1).
 */

  switch (type)
    {
    case 0x00:			/* Extension events ?????????????? */
      /* Not supported yet */
      break;

    case 0x01:			/* Descriptive text */
    case 0x02:			/* Copyright notice */
    case 0x03:			/* Sequence/track name */
    case 0x04:			/* Instrument name */
    case 0x05:			/* Lyric */
    case 0x06:			/* Marker */
    case 0x07:			/* Cue point */
#if 0
      for (i = 0; i < len - 1; i++)
	printf ("%c", evbuf[1 + i]);
      printf ("\n");
#endif
      break;

    case 0x21:			/* What is this */
      break;

/*	Here is a big hole in the known meta event space */

    case 0x2f:			/* End of track */
      break;

/*	Here is a big hole in the known meta event space */

    case 0x51:			/* Set tempo (usec per MIDI quarter-note) */
      {
	int tempo_bpm = 120;
	unsigned int usecs_per_qn;

	usecs_per_qn = (evbuf[1] << 16) | (evbuf[2] << 8) | evbuf[3];
	tempo_bpm = (60000000 + (usecs_per_qn / 2)) / usecs_per_qn;

	STORE (SEQ_SET_TEMPO (tempo_bpm));
	return 1;
      }
      break;

    case 0x54:			/* SMPTE offset */
      break;

    case 0x58:			/* Time signature */
      {
	unsigned sig;

	sig = evbuf[1] << 24;
	sig |= evbuf[2] << 16;
	sig |= evbuf[3] << 8;
	sig |= evbuf[4];

	if (!desc->timesig)
	  desc->timesig = sig;
	STORE (SEQ_TIME_SIGNATURE (sig));
      }
      break;

    case 0x59:			/* Key signature */
      break;

    case 0x7f:			/* Vendor specific meta event */
      if (evbuf[1] == 0 && evbuf[2] == 0 && evbuf[3] == 0x41)
	{			/* Microsoft ?? */
	  if (len == 4)
	    DEB_ALWAYS (printf ("GM file flag \n"));

/* Don't forget to add more code here */
	}
      else
	{
	  DEB_ALWAYS (printf ("Private meta event:\n"));
	  for (i = 0; i < len; i++)
	    DEB_ALWAYS (printf ("%02x ", evbuf[i]));
	  DEB_ALWAYS (printf ("\n"));
	  for (i = 0; i < len; i++)
	    DEB_ALWAYS (printf ("%c", (evbuf[i] >= ' ' && evbuf[i] < 127) ?
				evbuf[i] : '.'));
	  DEB_ALWAYS (printf ("\n"));
	}
      break;

    default:
      DEB_ALWAYS (printf ("Meta event: 0x%02x???\n", type));
      for (i = 0; i < len; i++)
	DEB_ALWAYS (printf ("%02x ", evbuf[i]));
      DEB_ALWAYS (printf ("\n"));
      for (i = 0; i < len; i++)
	DEB_ALWAYS (printf ("%c", (evbuf[i] >= ' ' && evbuf[i] < 127) ?
			    evbuf[i] : '.'));
      DEB_ALWAYS (printf ("\n"));
    }

  STORE (META_EVENT (type, evbuf, len));

  return 1;
}
예제 #3
0
//=================================================================================================
//=================================================================================================
void Camera::startAcq()
{
    DEB_MEMBER_FUNCT();

	m_acq_frame_nb = -1;
	m_pcoData->pcoError = 0;
	m_pcoData->pcoErrorMsg[0] = 0;

	m_pcoData->traceAcqClean();

	TIME_USEC tStart;
	msElapsedTimeSet(tStart);


//=====================================================================
	DEF_FNID;
    HANDLE hEvent= NULL;

	DEB_ALWAYS() << _sprintComment(false, fnId, "[ENTRY]") << _checkLogFiles();

	int error;


	//------------------------------------------------- start acquisition

	m_pcoData->traceAcq.msStartAcqStart = msElapsedTime(tStart);

	m_sync->setStarted(true);
	//m_sync->setExposing(pcoAcqRecordStart);
	m_sync->setExposing(pcoAcqStart);
	
    int iRequestedFrames;
    m_sync->getNbFrames(iRequestedFrames);


	int forced = 0;
	getRecorderForcedFifo(forced);

	int iPending;
	PCO_GetPendingBuffer(m_handle, &iPending);
	if(iPending < m_pco_buffer_nrevents)
	{
		PCO_CancelImages(m_handle);
		DEB_ALWAYS() << "PCO_CancelImages "<< DEB_VAR1(iPending);
	}


	unsigned long ulFramesMaxInSegment = _pco_GetNumberOfImagesInSegment_MaxCalc(m_pcoData->wActiveRamSegment);
	unsigned long ulRequestedFrames = (unsigned long) iRequestedFrames;

	if(ulRequestedFrames > 0)
	{
		WORD wDoubleImage;
		int err;

		// Double Image -> requested images will be the total nr of images (basic + primary)
		//      must be even and twice of the nr of images for pco
		_pco_GetDoubleImageMode(wDoubleImage, err);

		bool bOutOfRange = false;

		if( (wDoubleImage) && ((ulRequestedFrames % 2) != 0) ) 
		{
			DEB_ALWAYS() << "\nERROR odd nr of frames in DoubleImage";
			bOutOfRange = true;
		}
			
		if((ulFramesMaxInSegment > 0) && (ulRequestedFrames > ulFramesMaxInSegment) && (!forced) )
		{
			DEB_ALWAYS() << "\nERROR many frames in record mode";
			bOutOfRange = true;
		}

		if(bOutOfRange)
		{
			char msg[MSG1K];
			__sprintfSExt(msg, sizeof(msg)-1,
				"ERROR frames OUT OF RANGE ulRequestedFrames[%ld], ulFramesMaxInSegment[%ld], wDoubleImage[%d], forced[%d]",
				ulRequestedFrames, ulFramesMaxInSegment, wDoubleImage, forced);

			DEB_ALWAYS() << msg;
			m_sync->setStarted(false);
			m_sync->setExposing(pcoAcqError);

			throw LIMA_EXC(CameraPlugin, InvalidValue, msg);
			return;
		}
	}

	if(!_isRunAfterAssign())
	{
		DEB_TRACE() << "========================= recordingState 1 - BEFORE ASSIGN (startAcq)";
		_pco_SetRecordingState(1, error);
	}

	if(_isCameraType(Edge)){

		_beginthread( _pco_acq_thread_edge, 0, (void*) this);

#if 0
		AutoMutex lock(m_cond.mutex());

		bool resWait;
		int retry = 3;
		int val, val0; val0 = pcoAcqRecordStart;

		while( ((val =  m_sync->getExposing()) != val0) && retry--)
		{
			DEB_TRACE() << "+++ getExposing / pcoAcqRecordStart - WAIT - " << DEB_VAR3(val, val0, retry);
			resWait = m_cond.wait(2.);
		}
		DEB_TRACE() << "+++ getExposing / pcoAcqRecordStart - EXIT - " << DEB_VAR3(val, val0, retry);
		lock.unlock();
#endif

		m_pcoData->traceAcq.msStartAcqEnd = msElapsedTime(tStart);
		return;
	}

#if 0
	if(_isCameraType(Pco2k | Pco4k)){
		_beginthread( _pco_acq_thread_ringBuffer, 0, (void*) this);
		m_pcoData->traceAcq.msStartAcqEnd = msElapsedTime(tStart);
		return;
	}
#endif

	if(_isCameraType(Dimax | Pco2k | Pco4k)){
	    int iRequestedFrames;
		m_sync->getNbFrames(iRequestedFrames);

	    TrigMode trig_mode;
		m_sync->getTrigMode(trig_mode);
		_pco_SetRecordingState(1, error);

		int forcedFifo = 0;
		getRecorderForcedFifo(forcedFifo);

		if((iRequestedFrames > 0 ) && (forcedFifo == 0) ){
			if((trig_mode  == ExtTrigSingle) ) {
				_beginthread( _pco_acq_thread_dimax_trig_single, 0, (void*) this);
			} else {
				_beginthread( _pco_acq_thread_dimax, 0, (void*) this);	// normal mode
			}
		} else {
			_beginthread( _pco_acq_thread_dimax_live, 0, (void*) this);
		}
		m_pcoData->traceAcq.msStartAcqEnd = msElapsedTime(tStart);
		return;
	}

	throw LIMA_HW_EXC(Error, "unkown camera type");
	return;
}
예제 #4
0
Camera::Camera(const char *params) :
	m_cam_connected(false),
	m_acq_frame_nb(1),
	m_sync(NULL),
	m_buffer(NULL),
	m_handle(NULL),
	m_Roi_lastFixed_time(0),
	m_pco_buffer_nrevents(PCO_BUFFER_NREVENTS),
	bRecorderForcedFifo(false)
{
	DEF_FNID;
	DEB_CONSTRUCTOR();

	int error=0;
	m_config = TRUE;
	DebParams::checkInit();

	
	m_msgLog = new ringLog(300) ;
	m_tmpLog = new ringLog(300) ;
	if(m_msgLog == NULL)
		throw LIMA_HW_EXC(Error, "m_msgLog > creation error");
	if(m_tmpLog == NULL)
		throw LIMA_HW_EXC(Error, "m_tmpLog > creation error");

	m_pcoData =new stcPcoData();
	if(m_pcoData == NULL)
		throw LIMA_HW_EXC(Error, "m_pcoData > creation error");


	m_checkImgNr = new CheckImgNr(this);


	// properties: params 
	paramsInit(params);

	char *value;
	const char  *key;
	bool ret;
	int iValue;

	/***
	key = "test";
	key = "withConfig";
	key = "testMode";
	key = "debugPco";
	***/
	key = "testMode";
	ret = paramsGet(key, value);
	if(ret) {m_pcoData->testCmdMode = _atoi64(value);}

	key = "acqTimeoutRetry";
	ret = paramsGet(key, value);
	iValue = ret ? atoi(value) : 3;
	m_pcoData->acqTimeoutRetry = (iValue < 0 ) ? 0 : iValue;

	// patch in xMinSize meanwhile firmware for CLHS 1.19 is fixed
	key = "xMinSize";
	m_pcoData->params_xMinSize = !!paramsGet(key, value);

	// ignore the nbMaxImages calculated for dimax HS
	key = "ignoreMaxImages";
	m_pcoData->params_ignoreMaxImages = !!paramsGet(key, value);


	DEB_ALWAYS()
		<< ALWAYS_NL << DEB_VAR1(m_pcoData->version) 
		<< ALWAYS_NL << _checkLogFiles(true);

	//m_bin.changed = Invalid;
	
	_init();
	m_config = FALSE;
	_setActionTimestamp(tsConstructor);
}