Example #1
0
// ###########################################################################
// MAIN
// ###########################################################################
int main(int argc, char *argv[])
{

  EVENT_INFO   event_info;
	WAVE_CONFIG  wave_config = {256,0,0,0,0,0,0,0, 1, "", "", NULL}; 
	BOARD_CONFIG board_config;
	VME_ACCESS   vme;


  /* Print program header and current version */
	WavePrintVersion(SwRelease);

  /* Initialize board and acquisition */
	WaveInit(argc, argv, &vme, &wave_config);

  /* Read Board configuration after initialisation */
	WaveReadBoardConfiguration(&vme, &board_config);

	/* Start Acquisition and stores events in memory */
	/* If dump to file is enabled, a copy of the     */
  /* acquired waveform is saved to file            */
  WaveRun(&vme, &event_info, &wave_config, &board_config);

	/* Close acquisition by deallocating open resources */
	WaveClose(&vme, &wave_config, &event_info);

  return 0;
}	
/*------------------------------------------------------------------------------*/
static BOOL InitAll( HWND hWnd, HINSTANCE hInst )
{
	// Prevent multiple start-up.
	SECURITY_DESCRIPTOR sd = {0};
	InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
	SetSecurityDescriptorDacl(&sd, TRUE, 0, FALSE);	    

	SECURITY_ATTRIBUTES secAttribute = {0};
	secAttribute.nLength = sizeof (secAttribute);
	secAttribute.lpSecurityDescriptor = &sd;
	secAttribute.bInheritHandle = TRUE; 

	multipleStartupMutex.reset(::CreateMutex(&secAttribute, FALSE, TEXT("RemoteJoyLite")));
	if (multipleStartupMutex == NULL) {
		LOG(LOG_LEVEL_ERROR, "Could not get mutex.");
		return FALSE;
	} else if (::GetLastError() == ERROR_ALREADY_EXISTS) {
		LOG(LOG_LEVEL_ERROR, "Already started.");
		return FALSE;
	}

	// Register device notification.
	DEV_BROADCAST_DEVICEINTERFACE filter;
	filter.dbcc_size       = sizeof(filter);
	filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
	filter.dbcc_classguid  = GUID_DEVINTERFACE_USB_DEVICE;
	pspDeviceNotify.reset(::RegisterDeviceNotification( hWnd, &filter, DEVICE_NOTIFY_WINDOW_HANDLE));

	if ( SettingInit( hWnd, hInst )     == FALSE ){ return( FALSE ); }
	if (!pAkindD3D->initialize()) {
		return FALSE;
	}
	if (!pAkindD3D->create(false)) {
		return FALSE;
	}
	if ( SettingData.InputBG != 0 ){
		if ( pAkindDI->Init( hWnd, TRUE )  == FALSE ){ return( FALSE ); }
	} else {
		if ( pAkindDI->Init( hWnd, FALSE )  == FALSE ){ return( FALSE ); }
	}
	WaveInit();
	return( TRUE );
}