예제 #1
0
void SubscribeService(mUpnpControlPoint *ctrlPoint)
{
	mUpnpDevice *selDev;
	mUpnpService *selService;
	bool subSuccess;
	
	printf("Subscribe Device\n");
	
	mupnp_controlpoint_lock(ctrlPoint);
	selDev = SelectDevice(ctrlPoint);
	if (selDev == NULL)
	{
		mupnp_controlpoint_unlock(ctrlPoint);
		return;
	}
	selService = SelectService(selDev);
	if (selService == NULL)
	{
		mupnp_controlpoint_unlock(ctrlPoint);
		return;
	}
	subSuccess = mupnp_controlpoint_subscribe(ctrlPoint, selService, 300);
	
	printf("Subscribe Result(%d) = %s\n",
		(int)subSuccess, 
		(subSuccess == true) ? mupnp_service_getsubscriptionsid(selService) : "");
	mupnp_controlpoint_unlock(ctrlPoint);
	
}
예제 #2
0
void QueryDevice(mUpnpControlPoint *ctrlPoint)
{
	mUpnpDevice *selDev;
	mUpnpService *selService;
	mUpnpStateVariable *selStateVar;
	bool querySuccess;
	char *stateValue;
	
	printf("Query Device\n");
	
	selDev = SelectDevice(ctrlPoint);
	if (selDev == NULL)
		return;
	selService = SelectService(selDev);
	if (selService == NULL)
		return;
	selStateVar = SelectStateVariable(selService);
	if (selStateVar == NULL)
		return;
	
	querySuccess = mupnp_statevariable_post(selStateVar);
	
	stateValue = mupnp_statevariable_getvalue(selStateVar);

	printf("Query Result(%d) = %s\n",
		(int)querySuccess, 
		(stateValue != NULL) ? stateValue : "");
}
예제 #3
0
BOOL
CDisk::SendIOCommand(
    DWORD dwStartSector,
    DWORD dwNumberOfSectors,
    BYTE bCmd
    )
{
    DEBUGMSG(ZONE_IO, (TEXT(
        "Atapi!CDisk::SendIOCommand> sector(%d), sectors left(%x), command(%x)\r\n"
        ), dwStartSector,dwNumberOfSectors,bCmd));

    if (ZONE_CELOG) CeLogData(TRUE, CELID_ATAPI_IOCOMMAND, &bCmd, sizeof(bCmd), 0, CELZONE_ALWAYSON, 0, FALSE);

    SelectDevice();

    if (WaitOnBusy(FALSE)) {
        DEBUGMSG(ZONE_IO, (TEXT(
            "Atapi!CDisk::SendIOCommand> Failed to send command; status(%x), error(%x)\r\n"
            ), GetAltStatus(),GetError()));
        return FALSE;
    }

    // to transfer 256 sectors, set number of sectors to 0
    if (dwNumberOfSectors == MAX_SECT_PER_COMMAND) {
        dwNumberOfSectors = 0;
    }

    WriteSectorCount((BYTE)dwNumberOfSectors);
    if (m_fLBAMode == TRUE) {
        WriteSectorNumber( (BYTE)dwStartSector);
        WriteLowCount((BYTE)(dwStartSector >> 8));
        WriteHighCount((BYTE)(dwStartSector >> 16));
        WriteDriveHeadReg((BYTE)((dwStartSector >> 24) | ATA_HEAD_LBA_MODE) | ((m_dwDevice == 0 ) ? ATA_HEAD_DRIVE_1 : ATA_HEAD_DRIVE_2));
    }
예제 #4
0
static
void
KitlDevice(
    void *pContext,
    handle_t hTerminal,
    void * pActionMenu
    )
{
    UNREFERENCED_PARAMETER(pActionMenu);
    SelectDevice(pContext, hTerminal, true);
}
예제 #5
0
  NS_IMETHOD
  Run()
  {
    NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");

    mManager = MediaManager::Get();

    // Was a backend provided?
    if (!mBackendChosen) {
      mBackend = mManager->GetBackend();
    }

    // Was a device provided?
    if (!mDeviceChosen) {
      nsresult rv = SelectDevice();
      if (rv != NS_OK) {
        return rv;
      }
    }

    // It is an error if audio or video are requested along with picture.
    if (mPicture && (mAudio || mVideo)) {
      NS_DispatchToMainThread(new ErrorCallbackRunnable(
        mSuccess, mError, NS_LITERAL_STRING("NOT_SUPPORTED_ERR"), mWindowID
      ));
      return NS_OK;
    }

    // XXX: Implement merging two streams (See bug 758391).
    if (mAudio && mVideo) {
      NS_DispatchToMainThread(new ErrorCallbackRunnable(
        mSuccess, mError, NS_LITERAL_STRING("NOT_IMPLEMENTED"), mWindowID
      ));
      return NS_OK;
    }

    if (mPicture) {
      ProcessGetUserMediaSnapshot(mDevice->GetSource(), 0);
      return NS_OK;
    }

    if (mVideo) {
      ProcessGetUserMedia(mDevice->GetSource(), kVideoTrack);
      return NS_OK;
    }

    if (mAudio) {
      ProcessGetUserMedia(mDevice->GetSource(), kAudioTrack);
      return NS_OK;
    }

    return NS_OK;
  }
예제 #6
0
BOOL
CDisk::SendIOCommand(
    DWORD dwStartSector,
    DWORD dwNumberOfSectors,
    BYTE bCmd
    )
{
    DEBUGMSG(ZONE_IO, (TEXT(
        "Atapi!CDisk::SendIOCommand> sector(%d), sectors left(%x), command(%x)\r\n"
        ), dwStartSector,dwNumberOfSectors,bCmd));

    RETAILMSG(0, (TEXT(
        "Atapi!CDisk::SendIOCommand> sector(%d), sectors left(%x), command(%x)\r\n"
        ), dwStartSector,dwNumberOfSectors,bCmd));        

    if (ZONE_CELOG) CeLogData(TRUE, CELID_ATAPI_IOCOMMAND, &bCmd, sizeof(bCmd), 0, CELZONE_ALWAYSON, 0, FALSE);

    SelectDevice();

    if (WaitOnBusy(FALSE)) {
        DEBUGMSG(ZONE_IO, (TEXT(
            "Atapi!CDisk::SendIOCommand> Failed to send command; status(%x), error(%x)\r\n"
            ), GetAltStatus(),GetError()));
        RETAILMSG(1, (TEXT(
            "Atapi!CDisk::SendIOCommand> Failed to send command; status(%x), error(%x)\r\n"
            ), GetAltStatus(),GetError()));            
        return FALSE;
    }

    if (m_fUseLBA48) {
        ASSERT(dwNumberOfSectors <= MAX_SECT_PER_EXT_COMMAND);
        // to transfer 65536 sectors, set number of sectors to 0
        if (dwNumberOfSectors == MAX_SECT_PER_EXT_COMMAND) {
            dwNumberOfSectors = 0;
        }

        WriteSectorCount((BYTE)(dwNumberOfSectors >> 8));   // Sector Count 15:8
        WriteSectorCount((BYTE)(dwNumberOfSectors));        // Sector Count 7:0

        // CE supports only 32-bit LBA as of now.  Therefore, clear the upper 16 bits of LBA.
        WriteHighCount(0);    // LBA 47:40
        WriteLowCount(0);     // LBA 39:32
        WriteSectorNumber((BYTE)(dwStartSector >> 24));   // LBA 31:24
        WriteHighCount((BYTE)(dwStartSector >> 16));  // LBA 23:16
        WriteLowCount((BYTE)(dwStartSector >> 8));    // LBA 15:8
        WriteSectorNumber((BYTE)dwStartSector);           // LBA 7:0
        WriteDriveHeadReg( ATA_HEAD_LBA_MODE | ((m_dwDevice == 0 ) ? ATA_HEAD_DRIVE_1 : ATA_HEAD_DRIVE_2));
    }
    else {
WaveOutPulseAudio::WaveOutPulseAudio(string pOutputName, string pDesiredDevice):
    WaveOut(pOutputName)
{
    mOutputStream = NULL;
    LOG(LOG_VERBOSE, "Creating wave out for %s on device %s", pOutputName.c_str(), pDesiredDevice.c_str());

    if ((pDesiredDevice != "") && (pDesiredDevice != "auto"))
    {
        bool tNewDeviceSelected = false;
        tNewDeviceSelected = SelectDevice(pDesiredDevice);
        if (!tNewDeviceSelected)
            LOG(LOG_INFO, "Haven't selected new PortAudio device when creating source object");
    }

    LOG(LOG_VERBOSE, "Created");
}
예제 #8
0
void UnsubscribeService(mUpnpControlPoint *ctrlPoint)
{
	mUpnpDevice *selDev;
	mUpnpService *selService;
	bool subSuccess;
	
	printf("Query Device\n");
	
	selDev = SelectDevice(ctrlPoint);
	if (selDev == NULL)
		return;
	selService = SelectService(selDev);
	if (selService == NULL)
		return;

	subSuccess = mupnp_controlpoint_unsubscribe(ctrlPoint, selService);

	printf("Unsubscribe Result(%d)\n",
		(int)subSuccess);
}
예제 #9
0
파일: KPmacC.cpp 프로젝트: japgo/mygithub
// 자주사용되는 함수들..
//
bool	KPmacC::Open( int num )		// num < 0, num > 7 : 디바이스 선택,  7 >= num >= 0 : 열기시도
{
	// Pmac OpenRuntimeLink의 핸들을 얻어온다.
	if(m_hLink == NULL)
	{
		m_hLink = OpenRuntimeLink();	//Pmac Dll Load
		if(m_hLink == NULL)
		{
			DebugLog(_T("Lib Load Error"));
			return false;
		}
	}
	else
		return false;

    if ((num >= 0) && (num <= 7))
        m_nDevice = num;

    if ((m_nDevice < 0) || (m_nDevice > 7))
        m_nDevice = SelectDevice(0);
     
    if ((m_nDevice >= 0) && (m_nDevice <= 7))
        m_bConnected = DeviceOpen((UINT)m_nDevice);		//OpenPmacDevice((DWORD)m_nDevice);
    else
        m_bConnected = FALSE;

    if (m_bConnected)
    {
        GetPmacType();
        GetFirmwareVersion();
        GetFirmwareDate();
        GetServoCycle();
    }
    else
    {
		DebugLog(_T("Open Comm Error"));
        return false;
    }

    return true;
}
  NS_IMETHOD
  Run()
  {
    NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");

    mManager = MediaManager::Get();

    // Was a backend provided?
    if (!mBackendChosen) {
      mBackend = mManager->GetBackend();
    }

    // Was a device provided?
    if (!mDeviceChosen) {
      nsresult rv = SelectDevice();
      if (rv != NS_OK) {
        return rv;
      }
    }

    // It is an error if audio or video are requested along with picture.
    if (mPicture && (mAudio || mVideo)) {
      NS_DispatchToMainThread(new ErrorCallbackRunnable(
        mSuccess, mError, NS_LITERAL_STRING("NOT_SUPPORTED_ERR"), mWindowID
      ));
      return NS_OK;
    }

    if (mPicture) {
      ProcessGetUserMediaSnapshot(mVideoDevice->GetSource(), 0);
      return NS_OK;
    }

    // There's a bug in the permission code that can leave us with mAudio but no audio device
    ProcessGetUserMedia((mAudio && mAudioDevice) ? mAudioDevice->GetSource() : nullptr,
                        (mVideo && mVideoDevice) ? mVideoDevice->GetSource() : nullptr);
    return NS_OK;
  }
예제 #11
0
void PleoraVideo::InitDevice(
        const char* model_name, const char* serial_num, size_t index
) {
    lPvSystem = new PvSystem();
    if ( !lPvSystem ) {
        throw pangolin::VideoException("Pleora: Unable to create PvSystem");
    }

    lDeviceInfo = SelectDevice(*lPvSystem, model_name, serial_num, index);
    if ( !lDeviceInfo ) {
        delete lPvSystem;
        throw pangolin::VideoException("Pleora: Unable to select device");
    }

    PvResult lResult;
    lDevice = PvDevice::CreateAndConnect( lDeviceInfo, &lResult );
    if ( !lDevice ) {
        delete lPvSystem;
        throw pangolin::VideoException("Pleora: Unable to connect to device", lResult.GetDescription().GetAscii() );
    }

    lDeviceParams = lDevice->GetParameters();
}
예제 #12
0
BOOL
CST202T_SATA::SetLookAhead(
    )
{
    BYTE bError = 0;
    BYTE bStatus = 0;

    // select device
    SelectDevice();

    // wait for device to acknowledge selection
    WaitForDisc(WAIT_TYPE_NOT_BUSY, 100);
    WaitForDisc(WAIT_TYPE_READY, 1000);
    WaitOnBusy(TRUE);

    // write command
    WriteFeature(ATA_ENABLE_LOOKAHEAD);
    WriteCommand(ATAPI_CMD_SET_FEATURES);

    // wait for device to respond to command
    WaitOnBusy(TRUE);
    WaitForDisc(WAIT_TYPE_NOT_BUSY, 200);

    // check response
    bStatus = GetBaseStatus();
    bError = GetError();
    if ((bStatus & ATA_STATUS_ERROR) && (bError & ATA_ERROR_ABORTED)) {
        DEBUGMSG(ZONE_ERROR, (_T(
            "Atapi!CDisk::SetLookAhead> Failed to enable read look-ahead; status(%02X), error(%02X)\r\n"
            ), bStatus, bError));
        ResetController(FALSE);
        return FALSE;
    }

    return TRUE;
}
예제 #13
0
/******************************************************************************
 *
 * Function   :  main
 *
 * Description:  The main entry point
 *
 *****************************************************************************/
int
main(
    void
    )
{
    S16               DeviceSelected;
    PLX_STATUS        rc;
    PLX_DEVICE_KEY    DeviceKey;
    PLX_DEVICE_OBJECT Device;


    ConsoleInitialize();

    Cons_clear();

    Cons_printf(
        "\n\n"
        "\t\t    PLX Local->PCI Interrupt Sample Application\n"
        "\t\t                 January 2008\n\n"
        );


    /************************************
    *         Select Device
    ************************************/
    DeviceSelected =
        SelectDevice(
            &DeviceKey
            );

    if (DeviceSelected == -1)
    {
        ConsoleEnd();
        exit(0);
    }

    rc =
        PlxPci_DeviceOpen(
            &DeviceKey,
            &Device
            );

    if (rc != ApiSuccess)
    {
        Cons_printf("\n   ERROR: Unable to find or select a PLX device\n");
        PlxSdkErrorDisplay(rc);
        _Pause;
        ConsoleEnd();
        exit(-1);
    }

    Cons_clear();

    Cons_printf(
        "\nSelected: %04x %04x [b:%02x  s:%02x  f:%x]\n\n",
        DeviceKey.DeviceId, DeviceKey.VendorId,
        DeviceKey.bus, DeviceKey.slot, DeviceKey.function
        );

    // Verify chip is supported
    switch (DeviceKey.PlxChip)
    {
        case 0x9050:
        case 0x9030:
        case 0x9080:
        case 0x9054:
        case 0x9056:
        case 0x9656:
        case 0x8311:
            break;

        default:
            Cons_printf(
                "ERROR: Device (%04X) does not support generic Local-to-PCI interrupt\n",
                DeviceKey.PlxChip
                );
            goto _Exit_App;
    }


    /************************************
     *        Perform the DMA
     ************************************/
    InterruptTest(
        &Device
        );


    /************************************
     *        Close the Device
     ***********************************/
_Exit_App:
    PlxPci_DeviceClose(
        &Device
        );

    _Pause;

    Cons_printf("\n\n");

    ConsoleEnd();

    exit(0);
}
예제 #14
0
파일: main.c 프로젝트: adamdempsey90/ssdisk
int main(int argc, char *argv[]) {
  
  int   i, OutputNumber = 0, d;
  int   ni, ntot;
  char  ParameterFile[MAXLINELENGTH];
  if (argc == 1) PrintUsage (argv[0]);
  strcpy (ParameterFile, "");
  for (i = 1; i < argc; i+=d) {
    d=1;
    if (*(argv[i]) == '+') {
      if (strspn (argv[i], \
		  "+S#D") \
	  != strlen (argv[i]))
	PrintUsage (argv[0]);
      if (strchr (argv[i], '#')) {
	d=2;
	ArrayNb = atoi(argv[i+1]);
	EarlyOutputRename = YES;
	if (ArrayNb <= 0) {
	  masterprint ("Incorrect Array number after +# flag\n");
	  PrintUsage (argv[0]);
	}
      }
      if (strchr (argv[i], 'D')) {
	d=2;
	strcpy (DeviceFile, argv[i+1]);
	DeviceFileSpecified = YES;
      }
      if (strchr (argv[i], 'S')) {
	d=2;
	StretchNumber = atoi(argv[i+1]);
	StretchOldOutput = YES;
      }
    }
    if (*(argv[i]) == '-') {
      if (strspn (argv[i], \
		  "-tofCmkspSVBD0#") \
	  != strlen (argv[i]))
	PrintUsage (argv[0]);
      if (strchr (argv[i], 't'))
	TimeInfo = YES;
      if (strchr (argv[i], 'f'))
	ForwardOneStep = YES;
      if (strchr (argv[i], '0'))
	OnlyInit = YES;
      if (strchr (argv[i], 'C')) {
	EverythingOnCPU = YES;
#ifdef GPU
	mastererr ("WARNING: Forcing execution of all functions on CPU\n");
#else
	mastererr ("WARNING: Flag -C meaningless for a CPU built\n");
#endif
      }
      if (strchr (argv[i], 'm')) {
	Merge = YES;
      }
      if (strchr (argv[i], 'k')) {
	Merge = NO;
      }
      if (strchr (argv[i], 'o')) {
	RedefineOptions = YES;
	ParseRedefinedOptions (argv[i+1]) ;
	d=2;
      }
      if (strchr (argv[i], 's')) {
	Restart = YES;
	d=2;
	NbRestart = atoi(argv[i+1]);
	if ((NbRestart < 0)) {
	  masterprint ("Incorrect restart number\n");
	  PrintUsage (argv[0]);
	}
      }
      if (strchr (argv[i], '#')) {
	d=2;
	ArrayNb = atoi(argv[i+1]);
	if (ArrayNb <= 0) {
	  masterprint ("Incorrect Array number after -# flag\n");
	  PrintUsage (argv[0]);
	}
      }
      if (strchr (argv[i], 'p')) {
	PostRestart = YES;
      }
      if (strchr (argv[i], 'S')) {
	Restart_Full = YES;
	d=2;
	NbRestart = atoi(argv[i+1]);
	if ((NbRestart < 0)) {
	  masterprint ("Incorrect restart number\n");
	  PrintUsage (argv[0]);
	}
      }
      if (strchr (argv[i], 'V')) {
	Dat2vtk = YES;
	Restart_Full = YES;
	d=2;
	NbRestart = atoi(argv[i+1]);
	if ((NbRestart < 0)) {
	  masterprint ("Incorrect output number\n");
	  PrintUsage (argv[0]);	  
	}
      }
      if (strchr (argv[i], 'B')) {
	Vtk2dat = YES;
	Restart_Full = YES;
	d=2;
	NbRestart = atoi(argv[i+1]);
	if ((NbRestart < 0)) {
	  masterprint ("Incorrect output number\n");
	  PrintUsage (argv[0]);	  
	}
      }
      if (strchr (argv[i], 'D')) {
	d=2;
	DeviceManualSelection = atoi(argv[i+1]);
      }
    }
    else strcpy (ParameterFile, argv[i]);
  }

#ifdef WRITEGHOSTS
  if (Merge == YES) {
	mastererr ("Cannot merge outputs when dumping ghost values.\n");
	mastererr ("'make nofulldebug' could fix this problem.\n");
	mastererr ("Using the -k flag could be another solution.\n");
	prs_exit (1);
  }
#endif
  
  if (ParameterFile[0] == 0) PrintUsage (argv[0]);

#ifdef MPICUDA
  EarlyDeviceSelection();
#endif
  MPI_Init (&argc, &argv);
  MPI_Comm_rank (MPI_COMM_WORLD, &CPU_Rank);
  MPI_Comm_size (MPI_COMM_WORLD, &CPU_Number);
  CPU_Master = (CPU_Rank == 0 ? 1 : 0);
  

#ifndef MPICUDA
  SelectDevice(CPU_Rank);
#endif
  InitVariables ();
  MPI_Barrier(MPI_COMM_WORLD);
  ReadDefaultOut ();
  ReadVarFile (ParameterFile);
  if (strcmp (PLANETCONFIG, "NONE") != 0)
    ThereArePlanets = YES;


  if (ORBITALRADIUS > 1.0e-30){
    YMIN *= ORBITALRADIUS;
    YMAX *= ORBITALRADIUS;
    DT   *= sqrt(ORBITALRADIUS*ORBITALRADIUS*ORBITALRADIUS);
  }


  SubsDef (OUTPUTDIR, DefaultOut);

  /* This must be placed ***BEFORE*** reading the input files in case of a restart */
  if ((ArrayNb) && (EarlyOutputRename == YES)) {
    i = strlen(OUTPUTDIR);
    if (OUTPUTDIR[i-1] == '/') OUTPUTDIR[i-1] = 0;//Remove trailing slash if any
    sprintf (OUTPUTDIR, "%s%06d/", OUTPUTDIR, ArrayNb); //Append numerical suffix
    /* There is no need to perform the wildcard (@) substitution. This has already been done */
    printf ("\n\n***\n\nNew Output Directory is %s\n\n***\n\n", OUTPUTDIR);
    MakeDir(OUTPUTDIR); /*Create the output directory*/
  }


  MakeDir(OUTPUTDIR); /*Create the output directory*/

#if !defined(X)
  NX = 1;
#endif
#if !defined(Y)
  NY = 1;
#endif
#if !defined(Z)
  NZ = 1;
#endif

  SelectWriteMethod();

#if !defined(Y) && !defined(Z)
  if (CPU_Rank==1){
    prs_error ("You cannot split a 1D mesh in x. Sequential runs only!");
  }
  if (CPU_Number > 1) {
    MPI_Finalize();
    prs_exit(EXIT_FAILURE);
  }
#endif
    
  ListVariables ("variables.par"); //Writes all variables defined in set up
  ListVariablesIDL ("IDL.var");
  ChangeArch(); /*Changes the name of the main functions
		  ChangeArch adds _cpu or _gpu if GPU is activated.*/
  split(&Gridd); /*Split mesh over PEs*/
  InitSpace();
  WriteDim();
  InitSurfaces();
  LightGlobalDev(); /* Copy light arrays to the device global memory */
  CreateFields(); // Allocate all fields.

  Sys = InitPlanetarySystem(PLANETCONFIG);
  ListPlanets();
  if(Corotating)
    OMEGAFRAME = GetPsysInfo(FREQUENCY);
  OMEGAFRAME0 = OMEGAFRAME;
  /* We need to keep track of initial azimuthal velocity to correct
the target velocity in Stockholm's damping prescription. We copy the
value above *after* rescaling, and after any initial correction to
OMEGAFRAME (which is used afterwards to build the initial Vx field. */

  
  if(Restart == YES || Restart_Full == YES) {
    CondInit (); //Needed even for restarts: some setups have custom
		 //definitions (eg potential for setup MRI) or custom
		 //scaling laws (eg. setup planetesimalsRT).
    begin_i = RestartSimulation(NbRestart);
    if (ThereArePlanets) {
      PhysicalTime  = GetfromPlanetFile (NbRestart, 9, 0);
      OMEGAFRAME  = GetfromPlanetFile (NbRestart, 10, 0);
      RestartPlanetarySystem (NbRestart, Sys);
    }
  }
  else {
    if (ThereArePlanets)
      EmptyPlanetSystemFiles ();
    CondInit(); // Initialize set up
    // Note: CondInit () must be called only ONCE (otherwise some
    // custom scaling laws may be applied several times).
  }

  if (StretchOldOutput == YES) {
    StretchOutput (StretchNumber);
  }

  FARGO_SAFE(comm(ENERGY)); //Very important for isothermal cases!

  /* This must be placed ***after*** reading the input files in case of a restart */
  if ((ArrayNb) && (EarlyOutputRename == NO)) {
    i = strlen(OUTPUTDIR);
    if (OUTPUTDIR[i-1] == '/') OUTPUTDIR[i-1] = 0;//Remove trailing slash if any
    sprintf (OUTPUTDIR, "%s%06d/", OUTPUTDIR, ArrayNb); //Append numerical suffix
    /* There is no need to perform the wildcard (@) substitution. This has already been done */
    printf ("\n\n***\n\nNew Output Directory is %s\n\n***\n\n", OUTPUTDIR);
    MakeDir(OUTPUTDIR); /*Create the output directory*/
    ListVariables ("variables.par"); //Writes all variables defined in set up
    ListVariablesIDL ("IDL.var");
    InitSpace();
    WriteDim ();
  }
  
  DumpToFargo3drc(argc, argv);

  FillGhosts(PrimitiveVariables()); 
#ifdef STOCKHOLM 
  FARGO_SAFE(init_stockholm());
#ifdef STOCKHOLMACC
  FARGO_SAFE(ComputeVymed(Vy));
  FARGO_SAFE(ComputeRhomed(Density));
  
  Write2D(Density0_avg, "density0_2d_avg.dat", OUTPUTDIR, GHOSTINC);
  Write2D(Vy0_avg, "vy0_2d_avg.dat", OUTPUTDIR, GHOSTINC);
#endif
#endif

#ifdef GHOSTSX
  masterprint ("\n\nNew version with ghost zones in X activated\n");
#else
  masterprint ("Standard version with no ghost zones in X\n");
#endif
#ifdef TIMER
    clock_t begin_timer_time, end_timer_time;
    real timer_time_elapsed;
#endif
  ntot = NTOTINIT;
  for (ni = 0; ni<NITER; ni++) { // Iteration loop
      ntot = (ni == 0) ? NTOTINIT : NTOT; 
      masterprint ("Start of %d iteration\n", ni);
      masterprint ("Evolving waves for %d DT (DT = %lg)\n", ntot,DT);
      for (i = begin_i; i<=ntot; i++) { // MAIN LOOP
    #ifdef TIMER
        if (i==begin_i) {
            begin_timer_time = clock();
        }
    #endif
        if (NINTERM * (TimeStep = (i / NINTERM)) == i) {

            TimeStepIter = ni;

    #if defined(MHD) && defined(DEBUG)
          FARGO_SAFE(ComputeDivergence(Bx, By, Bz));
    #endif
          if (ThereArePlanets)
        WritePlanetSystemFile(TimeStep, NO);
          
    #ifndef NOOUTPUTS
          WriteOutputsAndDisplay(ALL);


          if(CPU_Master) printf("OUTPUTS %d at date t = %f OK\n", TimeStep, PhysicalTime);
    #endif

          if (TimeInfo == YES)
        GiveTimeInfo (TimeStep);
        }

        if (NSNAP != 0) {
          if (NSNAP * (TimeStep = (i / NSNAP)) == i) {
        WriteOutputsAndDisplay(SPECIFIC);
          }
        }
        
        AlgoGas(FALSE);
        MonitorGlobal (MONITOR2D      | MONITORY | MONITORY_RAW|	\
               MONITORSCALAR  | MONITORZ | MONITORZ_RAW);
        
        if (ThereArePlanets) {
          WriteTorqueAndWork(TimeStep, 0);
          WritePlanetSystemFile(TimeStep, YES);
          SolveOrbits (Sys);
        }
    #ifdef TIMER
        if (i==begin_i) {
            end_timer_time = clock();
            timer_time_elapsed =( (double)(end_timer_time-begin_timer_time))/CLOCKS_PER_SEC;
            masterprint("time for time_step was %g s\n",timer_time_elapsed);
        }
    #endif

      }
      masterprint ("End of %d iteration\n", ni);
      AlgoGas(TRUE);
      masterprint ("Computing steady state\n");
      compute_steady_state();
      add_avgs();
      output_steady_state(ni);
      clear_averages();
  }

  MPI_Finalize();  
  printf("End of simulation!\n");
  return 0;  
}
예제 #15
0
파일: pleora.cpp 프로젝트: Anantak/Pangolin
PleoraVideo::PleoraVideo(const char* model_name, const char* serial_num, size_t index, size_t bpp,  size_t binX, size_t binY, size_t buffer_count,
                         size_t desired_size_x, size_t desired_size_y, size_t desired_pos_x, size_t desired_pos_y)
    : lPvSystem(0), lDevice(0), lStream(0)
{
    lPvSystem = new PvSystem();
    if ( !lPvSystem ) {
        throw pangolin::VideoException("Pleora: Unable to create PvSystem");
    }

    const PvDeviceInfo *lDeviceInfo = SelectDevice(*lPvSystem, model_name, serial_num, index);
    if ( !lDeviceInfo ) {
        throw pangolin::VideoException("Pleora: Unable to select device");
    }

    PvResult lResult;
    lDevice = PvDevice::CreateAndConnect( lDeviceInfo, &lResult );
    if ( !lDevice ) {
        throw pangolin::VideoException("Pleora: Unable to connect to device", lResult.GetDescription().GetAscii() );
    }

    lStream = PvStream::CreateAndOpen( lDeviceInfo->GetConnectionID(), &lResult );
    if ( !lStream ) {
        lDevice->Disconnect();
        PvDevice::Free(lDevice);
        throw pangolin::VideoException("Pleora: Unable to open stream", lResult.GetDescription().GetAscii() );
    }

    lDeviceParams = lDevice->GetParameters();
    lStart = dynamic_cast<PvGenCommand*>( lDeviceParams->Get( "AcquisitionStart" ) );
    lStop = dynamic_cast<PvGenCommand*>( lDeviceParams->Get( "AcquisitionStop" ) );

    if( bpp == 8) {
        lDeviceParams->SetEnumValue("PixelFormat", PvString("Mono8") );
    }else if(bpp == 10) {
        lDeviceParams->SetEnumValue("PixelFormat", PvString("Mono10p") );
    }else if(bpp == 12) {
        lDeviceParams->SetEnumValue("PixelFormat", PvString("Mono12p") );
    }

    // Height and width will fail if not multiples of 8.
    lDeviceParams->SetIntegerValue("Height", desired_size_y );
    if(lResult.IsFailure()){
        pango_print_error("Height %zu fail\n", desired_size_y);
        int64_t max, min;
        lDeviceParams->GetIntegerRange("Height", max, min );
        lDeviceParams->SetIntegerValue("Height", max );
    }
    lDeviceParams->SetIntegerValue("Width", desired_size_x );
    if(lResult.IsFailure()){
        pango_print_error("Width %zu fail\n", desired_size_x);
        int64_t max, min;
        lDeviceParams->GetIntegerRange("Width", max, min );
        lDeviceParams->SetIntegerValue("Width", max );
    }

    lDeviceParams = lDevice->GetParameters();
    const int w = DeviceParam<int64_t>("Width");
    const int h = DeviceParam<int64_t>("Height");

    // Offset will fail if not multiple of 8.
    lDeviceParams->SetIntegerValue("OffsetX", desired_pos_x );
    if(lResult.IsFailure()){
        pango_print_error("OffsetX %zu fail\n", desired_pos_x);
    }
    lDeviceParams->SetIntegerValue("OffsetX", desired_pos_y );
    if(lResult.IsFailure()){
        pango_print_error("OffsetY %zu fail\n", desired_pos_y);
    }

    lResult =lDeviceParams->SetIntegerValue("BinningHorizontal", binX );
    if(lResult.IsFailure()){
        pango_print_error("BinningHorizontal %zu fail\n", binX);
    }
    lResult =lDeviceParams->SetIntegerValue("BinningVertical", binY );
    if(lResult.IsFailure()){
        pango_print_error("BinningVertical %zu fail\n", binY);
    }

    lStreamParams = lStream->GetParameters();

    // Reading payload size from device
    const uint32_t lSize = lDevice->GetPayloadSize();

    // Use buffer_count or the maximum number of buffers, whichever is smaller
    const uint32_t lBufferCount = ( lStream->GetQueuedBufferMaximum() < buffer_count ) ?
        lStream->GetQueuedBufferMaximum() :
        buffer_count;

    // Allocate buffers and queue
    for ( uint32_t i = 0; i < lBufferCount; i++ )
    {
        PvBuffer *lBuffer = new PvBuffer;
        lBuffer->Alloc( static_cast<uint32_t>( lSize ) );
        lBufferList.push_back( lBuffer );
    }

    // Setup pangolin for stream
    PvGenEnum* lpixfmt = dynamic_cast<PvGenEnum*>( lDeviceParams->Get("PixelFormat") );
    const VideoPixelFormat fmt = PleoraFormat(lpixfmt);
    streams.push_back(StreamInfo(fmt, w, h, (w*fmt.bpp)/8));
    size_bytes = lSize;

    Start();
}
예제 #16
0
bool StartSlave()
{
	// Let the user select the device to receive from
	PvString lDeviceIP;
	if ( !SelectDevice( lDeviceIP ) )
	{
		return false;
	}
	
	// Create the PvStream object
	PvStream lStream;

	// Create the PvPipeline object
	PvPipeline lPipeline( &lStream );

    // Create a PvPipeline event sink (used to trap buffer too small events)
    PipelineEventSink lPipelineEventSink;
    lPipeline.RegisterEventSink( &lPipelineEventSink );

	// Open stream
	printf( "Opening stream\n" );
	lStream.Open( lDeviceIP, "239.192.1.1", 1042 );

	// IMPORTANT: the pipeline needs to be "armed", or started before 
	// we instruct the device to send us images
	printf( "Starting pipeline\n" );
    lPipeline.SetBufferCount( 16 );
	lPipeline.Start();

	// Get stream parameters/stats
	PvGenParameterArray *lStreamParams = lStream.GetParameters();
	PvGenInteger *lCount = dynamic_cast<PvGenInteger *>( lStreamParams->Get( "ImagesCount" ) );
	PvGenFloat *lFrameRate = dynamic_cast<PvGenFloat *>( lStreamParams->Get( "AcquisitionRateAverage" ) );
	PvGenFloat *lBandwidth = dynamic_cast<PvGenFloat *>( lStreamParams->Get( "BandwidthAverage" ) );
	PvGenBoolean *lIgnoreMissingPackets = dynamic_cast<PvGenBoolean *>( lStreamParams->Get( "IgnoreMissingPackets" ) );

	// Disabling resend packets
	lIgnoreMissingPackets->SetValue( true );

	char lDoodle[] = "|\\-|-/";
	int lDoodleIndex = 0;
	PvInt64 lImageCountVal = 0;
	double lFrameRateVal = 0.0;
	double lBandwidthVal = 0.0;

	// Acquire images until the user instructs us to stop
	printf( "\n<press a key to stop receiving>\n" );
	while ( !PvKbHit() )
	{
		// Retrieve next buffer		
		PvBuffer *lBuffer = NULL;
        PvResult  lOperationResult;
		PvResult lResult = lPipeline.RetrieveNextBuffer( &lBuffer, 1000, &lOperationResult );
		
        if ( lResult.IsOK() )
		{
            if (lOperationResult.IsOK())
            {
                //
                // We now have a valid buffer. This is where you would typically process the buffer.
                // -----------------------------------------------------------------------------------------
                // ...

			    lCount->GetValue( lImageCountVal );
			    lFrameRate->GetValue( lFrameRateVal );
			    lBandwidth->GetValue( lBandwidthVal );
			
				// If the buffer contains an image, display width and height
				PvUInt32 lWidth = 0, lHeight = 0;
				if ( lBuffer->GetPayloadType() == PvPayloadTypeImage )
				{
					// Get image specific buffer interface
					PvImage *lImage = lBuffer->GetImage();

					// Read width, height
					lWidth = lBuffer->GetImage()->GetWidth();
					lHeight = lBuffer->GetImage()->GetHeight();
				}
				
				printf( "%c BlockID: %016llX W: %i H: %i %.01f FPS %.01f Mb/s\r", 
                    lDoodle[ lDoodleIndex ],
                    lBuffer->GetBlockID(),
					lWidth,
					lHeight,
                    lFrameRateVal,
                    lBandwidthVal / 1000000.0 ); 
            }

            // We have an image - do some processing (...) and VERY IMPORTANT,
			// release the buffer back to the pipeline
			lPipeline.ReleaseBuffer( lBuffer );
		}
		else
		{
			// Timeout
			printf( "%c Timeout\r", lDoodle[ lDoodleIndex ] );
		}

		++lDoodleIndex %= 6;
	}

	PvGetChar(); // Flush key buffer for next stop
	printf( "\n\n" );

	// We stop the pipeline - letting the object lapse out of 
	// scope would have had the destructor do the same, but we do it anyway
	printf( "Stop pipeline\n" );
	lPipeline.Stop();

	// Now close the stream. Also optionnal but nice to have
	printf( "Closing stream\n" );
	lStream.Close();

    // Unregister pipeline event sink. Optional but nice to have.
    lPipeline.UnregisterEventSink( &lPipelineEventSink );

	return true;
}
예제 #17
0
void ControlDeviceAlter(mUpnpControlPoint *ctrlPoint, int alteration_mask)
{
	mUpnpDevice *selDev;
	mUpnpService *selService;
	mUpnpAction *selAction;
	bool actionSuccess;
	mUpnpArgument *arg;
	char argValue[2048];
	
	printf("Control Device\n");
	
	selDev = SelectDevice(ctrlPoint);
	if (selDev == NULL)
		return;
	selService = SelectService(selDev);
	if (selService == NULL)
		return;
	selAction = SelectAction(selService);
	if (selAction == NULL)
		return;
	
	for (arg = mupnp_action_getarguments(selAction); arg; arg = mupnp_argument_next(arg)) {
		if (mupnp_argument_isindirection(arg) == true) {
			printf("%s : ", mupnp_argument_getname(arg));
			if (scanf("%s", argValue) == 1)
				mupnp_argument_setvalue(arg, argValue);
		}
	}

	/* NOTE: Go through selAction memory management... */
	if (alteration_mask & CMD_LOOP_ACTION_CALLS)
	{
		int loop_count, i;

		printf("\nHow many times action should be sent?");
		
		if ( 1 == scanf("%d", &loop_count) )
		{
			printf("\n");
			for (i=0; i<loop_count; i++)
			{
				actionSuccess = mupnp_action_post(selAction);
				printf("Control Result(%d)\n", (int)actionSuccess);
			}

			mupnp_sleep(3000);

			for (	arg = mupnp_action_getarguments(selAction); 
				arg; 
				arg = mupnp_argument_next(arg)) 
			{
				if (mupnp_argument_isoutdirection(arg) == true)
					printf(" %s = %s\n", 
							mupnp_argument_getname(arg), 
							mupnp_argument_getvalue(arg));
			}

			mupnp_sleep(2000);
		}
	}

	if ((alteration_mask & CMD_NO_ALTERATIONS) == CMD_NO_ALTERATIONS)
	{	
		actionSuccess = mupnp_action_post(selAction);
		
		printf("Control Result(%d)\n", (int)actionSuccess);
		for (arg = mupnp_action_getarguments(selAction); arg; arg = mupnp_argument_next(arg)) {
			if (mupnp_argument_isoutdirection(arg) == true)
				printf(" %s = %s\n", mupnp_argument_getname(arg), mupnp_argument_getvalue(arg));
		}
	}
}