Ejemplo n.º 1
0
int32_t readNTCAN(NTCAN_HANDLE handle, CMSG *msg, int32_t len)
 {
   NTCAN_RESULT 	result;
   int32_t			i,j;
   int32_t 			timeout=0; 
/* Reading Object of NTCAN device */  
	do {
		result = canRead(handle,msg, &len, NULL); 
		timeout++;
/* If timeout error is recieved repeatly then read is aborted */
      if(timeout > MAX_TIMEOUT) 
			{
      	result = canIoctl(handle, NTCAN_IOCTL_ABORT_RX, NULL);
         if(errorCheck(CAN_IO_CTL,result != 0))
         	{ return 1; } 									// error check
            printf("Repeated Timeout, read aborted\n");
            return 2; 
			}
      } while(errorCheck(CAN_READ,result) == 2); 
	if(errorCheck(CAN_READ,result) != 0)
		{ return 1; }  										// error check
/* Printing read object of NTCAN device to screen */
	printf("readNTCAN() successfull\n") ;
	printf("Length of message recieved: %d\n", (len & 0x0F) );
	for(j=0;j<len;j++)
	{
		printf("ID of NTCAN device: %x\n", msg->id); 
   		for(i=0;i<(msg->len);i++) 
		{
			printf("Byte %d of recieved message: %d\n", i, msg->data[i]);
   		}  
 	}
	return 0; 
}
Ejemplo n.º 2
0
int32_t closeNTCAN(NTCAN_HANDLE handle, int32_t ID[])
{
   NTCAN_RESULT	result;
   int32_t 			timeout = 0;
   int32_t			i=0;  
/* Flushing system */  
   result = canIoctl(handle, NTCAN_IOCTL_FLUSH_RX_FIFO, NULL);   
   if(errorCheck(CAN_IO_CTL,result) != 0) 		// error check 
   	{ return 1; }
   printf("System Flushed\n");
/* Deleting ID */     
	for(i=1; i<ID[0]; i++) {
// Deletes all ids and retrys if timeout error       
   	do  { 
			result = canIdDelete(handle, ID[i]); 
            timeout++;
            if(timeout>MAX_TIMEOUT) {   // checks for max timeout
               printf("Max timeout reached, aborting\n");
               return 2; }
      } while( errorCheck(CAN_ID_DELETE,result) == 2);
      if(errorCheck(CAN_ID_DELETE,result) != 0)  // error check
         { return 1; }
      printf("Deleted NTCAN ID\n");
   }
/* Closing NTCAN device */
   result = canClose(handle);  // closes device 
   if(errorCheck(CAN_CLOSE,result) != 0) // error check
      { return 1; }
   printf("Deleted NTCAN device. Device successfully closed.\n");
   return 0;
}
Ejemplo n.º 3
0
void PersonEditorPane::fieldsToObject (Person &person)
{
	// Require "change medical data" permission if the medical data changed
	Person originalPerson=getOriginalObject ();
	if (getEffectiveMedicalValidity ()!=originalPerson.medicalValidity)
	{
		if (paneData && !paneData->changeMedicalDataPermission->permit (this))
		{
			throw AbortedException ();
		}
	}

	person.lastName             =ui.lastNameInput       ->text ().simplified ();
	person.firstName            =ui.firstNameInput      ->text ().simplified ();
	person.club                 =ui.clubInput           ->currentText ().simplified ();
	person.comments             =ui.commentsInput       ->text ().simplified ();
	person.checkMedical         =ui.checkMedicalInput   ->currentItemData ().toBool ();
	person.medicalValidity      =getEffectiveMedicalValidity ();
	person.clubId               =ui.clubIdInput         ->text ();

	// Error checks

	if (isNone (person.lastName))
		errorCheck (tr ("Last name not specified."),
			ui.lastNameInput);

	if (isNone (person.firstName))
		errorCheck (tr ("First name not specified."),
			ui.firstNameInput);
}
Ejemplo n.º 4
0
//////////////////////////////////////////////////////////////////////////
// EXPORTED FUNCTIONS
//////////////////////////////////////////////////////////////////////////
__declspec(dllexport) BYTE* CompileBuffer(BYTE* Buffer, char* Source, DWORD BufferSize, DWORD* CompiledSize){
	
	YY_BUFFER_STATE state;
	BYTE* ret = NULL;

	if(Buffer==NULL){
		if(CompiledSize)*CompiledSize = 0;
		return NULL;
	}

	state = yy_scan_bytes(Buffer, BufferSize);
	lineno=1;
	yyparse();
	yy_delete_buffer(state);
	if(errorCheck()) goto finish_error;

	weedSCRIPTCOLLECTION(thescriptcollection);
	if(errorCheck()) goto finish_error;
	
	symSCRIPTCOLLECTION(thescriptcollection);
	if(errorCheck()) goto finish_error;
	
	ret = opcodeSCRIPTCOLLECTION(thescriptcollection, Source, CompiledSize);
	if(errorCheck()) goto finish_error;

	FinalCleanup();
	return ret;


finish_error:
	if(ret!=NULL) free(ret);
	*CompiledSize = 0;
	FinalCleanup();
	return NULL;
}
Ejemplo n.º 5
0
void object2D::draw(){
    errorCheck("draw");

    this->shader->useShaderProgram(0);

    if(this->texture2D!=NULL){
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, this->texture2D);
        glUniform1i(glGetUniformLocation(this->shader->shaderProgram[0], "ourTexture1"), 0);
        errorCheck("texture_2D");
    }
    else{
        GLint vertexColorLocation = glGetUniformLocation(this->shader->shaderProgram[0], "uColor"); //Ustawiamy kolor przycisku, wykorzystywany przy wyborze
        glUniform4fv(vertexColorLocation,1,glm::value_ptr(this->kolor));
    }

    //Macierz Projekcji
    GLint viewport[4];
    glGetIntegerv(GL_VIEWPORT, viewport);
    //TODO: Sprawdzić czy dziala dla wielu rozdzielczosci
    glm::mat4 projection = glm::ortho((float) -1366.0f/2.0f,(float) 1366.0f/2.0f, (float) -768.0f/2.0f,  (float) 768.0f/2.0f,-1.0f,1.0f);
//    glm::mat4 projection = glm::ortho((float) -viewport[2]/2.0f,(float) viewport[2]/2.0f, (float) -viewport[3]/2.0f,  (float) viewport[3]/2.0f,-1.0f,1.0f);
    glUniformMatrix4fv(this->getUniform("P"),1,GL_FALSE,glm::value_ptr(projection));
    GLint M = glGetUniformLocation(this->shader->shaderProgram[0], "M");
    glUniformMatrix4fv(M, 1, GL_FALSE, glm::value_ptr(this->posM*this->sclM*this->rotM));
    errorCheck("Matrixs");
    this->inUniform();

    glBindVertexArray(this->currentVAO());
    glDrawElements(GL_TRIANGLE_STRIP, 5, GL_UNSIGNED_INT, 0);
    glBindVertexArray(0);

    //Rysowanie napisów, jeżeli są jakieś dodane do tablicy
    this->drawText();
}
Ejemplo n.º 6
0
/*******************************************************
 *
 * Reading iNotify events is tricky. The structure itself
 * is dynamically sized - the name field is whatever the
 * name of the file is, so of course it can be any length
 * (up to the system-defined limit for filesizes.)
 *
 * This means you can't just do a blocking read(), because you
 * don't know how many bytes you need to read, and so you don't
 * know how many bytes you have to allocate. And we're trying
 * to be efficient here :)
 *
 * Safely getting an iNotify event requires 3 steps:
 * 1. poll() the inotify fd, with infinite timeout (wait for something to read)
 * 2. ioctl() to get the number of bytes available to be read
 * 3. Allocate a char* buffer and read() the proper number of bytes into the buffer.
 *
 * If this works, cast the char* into a struct inotify_event* and return it.
 q*
 * This function dynamically allocates the storage for the event. It is the responsibility
 * of the caller to free the allocated memory.
 */
struct inotify_event* getNotifyEvent (int fd)
{
	int rc;

	// poll() on the inotify fd, to wait for an event
	struct pollfd pfd;
	pfd.fd = fd;
	pfd.events = POLLIN;
	rc = poll(&pfd, 1, -1);
	errorCheck("poll()");

	// ioctl() to get the number of bytes to read
	unsigned int nToRead;
	rc = ioctl(fd, FIONREAD, &nToRead);
	errorCheck("ioctl()");

	// allocate that many bytes and read them
	char* buf = malloc(nToRead);
	rc = read(fd, buf, nToRead);
	errorCheck("read()");

	// cast result & return it
	struct inotify_event* event = (struct inotify_event*)buf;

	return event;
}
Ejemplo n.º 7
0
HRESULT 
recChannel_t::set_rate(float FR)
{
     __CONTEXT("recChannel_t::set_rate");
	if (FR<1)
    {
        return S_OK;
    }
	float factorRate = FR/30;
	int hr = 0;

	if (factorRate<0.1) factorRate = 0.1;
	frameRate = factorRate;

	IAMStreamConfig *pConfig = NULL;		
				
	if ((camInfo->getKind() == SHARED ||
         camInfo->getKind() == CAM)   && 
		actualFormat.pbFormat != NULL)
	{
			VIDEOINFOHEADER *pVih = (VIDEOINFOHEADER*) actualFormat.pbFormat;
            double newFR = 10000000.0/FR;
			pVih->AvgTimePerFrame = newFR;
            camInfo->setRate(pVih->AvgTimePerFrame);
            if (camInfo->getKind() == CAM)
            {
                IPin * pInput = NULL;
                get_camInfo()->output->ConnectedTo(&pInput);
                if (mapping)
                {
                    pControl->Stop();
                }
                if (pInput)
                {
                    get_camInfo()->output->Disconnect();
                    pInput->Disconnect();
                }
             	hr = get_camInfo()->output->QueryInterface(IID_IAMStreamConfig, (void**)&pConfig);
                if (pConfig)
                {
                    int hr = pConfig->SetFormat(&actualFormat);
                    errorCheck(hr);
                    pConfig->Release();
                }
                if (pInput)
                {
                    hr = pGraph->Connect(get_camInfo()->output,pInput);
                    errorCheck(hr);
                }
                errorCheck(hr);
                if (mapping)
                {
                    pControl->Run();
                }
			}
    }
    return hr;
	
}
int main(int argc, char** argv)
{
    QApplication app(argc, argv);
    //    qApp = &app;

    float window_min = 0, window_max = 0;

    for( int i=1 ; i<argc ; i++ )
    {
      if( !strcmp( argv[i], "--help") ) {
        printUsage();
        return 0;
      }
      else if( !strcmp( argv[i], "--window_min") ) {
        i++;
        errorCheck( i < argc, "expected parameter after --window_min" );
        char *checkPtr;
        window_min = (float)strtod( argv[i], &checkPtr );
        errorCheck( checkPtr != NULL && checkPtr[0] == 0 &&
          window_min < 100 && window_min > -100,
          "--window_min expects floating point value between -100 and 100" );  
      }
      else if( !strcmp( argv[i], "--window_max") ) {
        i++;
        errorCheck( i < argc, "expected parameter after --window_max" );
        char *checkPtr;
        window_max = (float)strtod( argv[i], &checkPtr );
        errorCheck( checkPtr != NULL && checkPtr[0] == 0 &&
          window_max < 100 && window_max > -100,
          "--window_max expects floating point value between -100 and 100" );
      } else {
        fprintf( stderr, PROGNAME " error: not recognized parameter '%s'\n", argv[i] );
        printUsage();
        return -1;
      }
    }

    errorCheck( window_min <= window_max, "window_min must be less than window_max" );


    try {
      
      PFSViewMainWin pfsViewMW( window_min, window_max );
//      app.setMainWidget(&pfsViewMW);    
      pfsViewMW.show();
      pfsViewMW.updateViewSize();
      
      return app.exec();
      
    }
    catch( PFSViewException ex )
    {
      QMessageBox::critical( NULL, "pfsview error", "Can not open the first PFS frame. Quitting." );
      return -1;
    }
    
    
}
Ejemplo n.º 9
0
void AudioEngine::update (std::vector<glm::mat4> listenerModelMatrices)
{
	for(unsigned int i = 0; i < listenerModelMatrices.size(); i++)
	{
		glm::vec3 forward(glm::normalize(listenerModelMatrices.at(i) * glm::vec4(0,0,-1,0)));
		glm::vec3 pos(listenerModelMatrices.at(i) * glm::vec4(0,0,0,1));
		glm::vec3 up(glm::normalize(listenerModelMatrices.at(i) * glm::vec4(0,1,0,0)));

		FMOD_VECTOR p = {pos.x, pos.y, pos.z};
		FMOD_VECTOR f = {forward.x, forward.y, forward.z};
		FMOD_VECTOR u = {up.x, up.y, up.z};

		fmodSystem->set3DListenerAttributes(i, &p, nullptr, &f, &u);
	}

	update3DPositions();

	result = fmodSystem->update();
	errorCheck();

	unsigned int ms = 0;
    unsigned int lenms = 0;
	bool		 isPlaying = false;
    bool         paused = false;


	// This section is for errorchecking / data only and is not actually
	// necessary for playing the music. Should probably make a list of
	// sounds that are playing so we can check all of them
    if (backgroundChannel)
    {
        result = backgroundChannel->isPlaying(&isPlaying);
        if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
        {
            errorCheck();
        }

        result = backgroundChannel->getPaused(&paused);
        if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
        {
            errorCheck();
        }

        result = backgroundChannel->getPosition(&ms, FMOD_TIMEUNIT_MS);
        if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
        {
            errorCheck();
        }
               
        result = backgroundSongs[backgroundSongChoice]->getLength(&lenms, FMOD_TIMEUNIT_MS);
        if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE))
        {
            errorCheck();
        }
    }

}
Ejemplo n.º 10
0
void AudioEngine::startBackgroundMusic()
{
	std::uniform_int_distribution<int> dist(0, backgroundSongs.size()-1);
	backgroundSongChoice = dist(generator);
    result = fmodSystem->playSound(backgroundSongs[backgroundSongChoice], 0, false, &backgroundChannel);
    errorCheck();
	result = backgroundChannel->setVolume(0.3f);
	errorCheck();
}
Ejemplo n.º 11
0
/**
	Procedure: handler_display_mpx

	Purpose: Displays Directory of Available MPX Process Files

	Parameters: None  

	Return value: None

	Calls: sizeOfPointer, sys_open_dir, sys_close_dir, sys_get_entry

	Globals: error

	Errors: Invalid Directory, Directory Not Open, No More Directory Entries, Read Failed, Name To Long For Buffer, No Directory Is Open.
**/
void handler_display_mpx(){
	char *Buffer= NULL;
	char BufferArray[80] = {0};
	char currentFile[40];
	long j = 0;
	int error, i = 0;
	int nameSize = 40;
	printf("\nWelcome to mpx");
	printf("\nPlease enter the directory to be opened it cannot contain spaces\n");
	Buffer = keyboardInput(0);
	
	while(i<sizeOfPointer(Buffer)){
		//printf("%c",Buffer[i]);
		BufferArray[i] = Buffer[i];
		i++;
	}
	if(sizeOfPointer(Buffer)==0){
		//printf("success");
		getcwd(BufferArray,80);
	}
	error = sys_open_dir(BufferArray);
	errorCheck(error);
	//printf("%s",BufferArray);
	if(error ==0){
		i = 0;
		printConstant =0;
		while(error == 0){
			error = sys_get_entry(currentFile,nameSize,&j);
			if(error == 0){
				i++;
				printf("\nFilename:%s       \tBuffersize:%d\tFile Size:%ld",currentFile,nameSize,j);
				printInterrupt();
			}
			//printf("\n%d",error);
		}
		if(error != -113){
			errorCheck(error);
		}
		else{
			error = sys_close_dir();
			errorCheck(error);
			//printf("\n%d",error);
			if(i == 0){
				if(Buffer[0] == 10){
					printf("The current directory contains no mpx files\n");
				}
				else{
					printf("No mpx files are in that directory\n");
				}
			}
			
		}
	}
	printf("\n");
}
Ejemplo n.º 12
0
int32_t initNTCAN(uint32_t baud,  uint32_t flags,
                  int32_t ID[], 	 int32_t net,
                  int32_t rxSize, int32_t rxTime,
                  int32_t txSize, int32_t txTime)
{
    NTCAN_HANDLE		handle;    	//
    NTCAN_RESULT		result;    	// Used for checking for error
    int32_t		i;       	  		// Index for multiple objects
    int32_t		timeout=0;   		// Current number of timeouts
    /* Open can */
    result = canOpen(net,flags,txSize,rxSize,   // Opens device
                     txTime,rxTime,&handle);
    if(errorCheck(CAN_OPEN,result) != 0)  			// Error check
    {
        return 0xFFFF;    // returns 1 if error
    }
//   printf("canOpen() success\n");
    /* Setting baudrate */
    result = canSetBaudrate(handle,baud);   		// sets baudrate
    if(errorCheck(CAN_SET_BAUDRATE,result) != 0) // Error check
    {
        return 0xFFFF;    // returns 1 if error
    }
    result = canGetBaudrate(handle,&baud);  		// Reads buadrate
//   printf("canSetBaudrate() success. Baudrate is %d\n",baud);
    /* Adding an ID */
    for(i=1; i<ID[0]; i++) {
        do  {
            result = canIdAdd(handle,ID[i]); 	// Adds ID to handle
            timeout++; 									// reapeat if Timeout
            if(timeout>MAX_TIMEOUT) {
                printf("Max timeout out reached, Aborting addID\n");
                return 0xFFFF;
            }  // return if repeated error
        } while( errorCheck(CAN_ID_ADD,result) == 2);
        if(errorCheck(CAN_ID_ADD,result) != 0) 	// error check
        {
            return 0xFFFF;
        }
//   printf("canIdAdd() successful\n");
    }
    printf("Initializing sucessfull\n");
    /* Flushing FIFO buffer */
    result = canIoctl(handle,NTCAN_IOCTL_FLUSH_RX_FIFO,NULL);
    if(errorCheck(CAN_IO_CTL,result) != 0) 		// flushing FIFO
    {
        return 0xFFFF;    // error check
    }
//   printf("System flushed, device ready to use\n");
    return handle; // returns handle for NTCAN device
}
Ejemplo n.º 13
0
void resume(){

	char *tempPtr = NULL;											//Temporary Input Character Pointer
	PCBitem *tempPCB;												//Temporary PCB Item
	int charCount = 0;	
	
	// Get PCB name from the user
	printf("Please enter the name of the PCB to resume: ");
	tempPtr = keyboardInput(0);										//Gets process name from User
	tempPtr = pointer2Str(tempPtr);									//Convert Character Pointer to Character String
	charCount = sizeOfPointer(tempPtr);								//Get Name Size
	
	if((charCount >= 8)){											//Check that Name is Valid (Check to see if at least 8 chars. + Null Terminator)
		tempPCB = find_PCB(tempPtr);
		if(tempPCB != NULL){										//Check if Name Exists
			if(tempPCB->state == RUNNING){
				printf("Error: There is no need to resume an already running process.\n");
			} else if(tempPCB->state == READY){
				printf("Error: This process is READY but not suspended.\n");
			} else if(tempPCB->state == BLOCKED){
				printf("Error: This process is Blocked but not suspended.\n");
			} else{
			
				// Should remove the process from the SUSREADY or SUSBLOCKED queue (by calling remove_PCB)
				error = remove_PCB(tempPCB->state, tempPCB);
				error = errorCheck(error);
				
				// Puts the PCB in the unsuspended state
				if(tempPCB->state == SUSREADY){
					tempPCB->state = READY;
				} else if(tempPCB->state == SUSBLOCKED){
					tempPCB->state = BLOCKED;
				}//end if
	
			    // Might require changing queues (from ready to suspended ready, for example) if 4 queues are used
				error = insert_PCB(tempPCB->state, tempPCB);
				error = errorCheck(error);
				
				// Display appropriate error or success message
				if(error == 0){
					printf("The PCB Process has been successfully resumed.\n");
				}//end if
			}//end if
		}else{
			printf("Process Name does not exist.\n");
		}//end if
	}else{
		printf("Process Name is Invalid. Process Name must be at least 8 characters in length.\n");
	}//end if
}//end resume
Ejemplo n.º 14
0
char *
PyUnicode_AsPgString(PyObject *p_unicode)
{
	Py_ssize_t	unicode_size = PyUnicode_GET_SIZE(p_unicode);
	char	   *message = NULL;
	PyObject   *pTempStr = PyUnicode_Encode(PyUnicode_AsUnicode(p_unicode),
											unicode_size,
											GetDatabaseEncodingName(), NULL);

	errorCheck();
	message = strdup(PyBytes_AsString(pTempStr));
	errorCheck();
	Py_DECREF(pTempStr);
	return message;
}
Ejemplo n.º 15
0
void setPriority(){
	char *tempPtr = NULL;											//Temporary Input Character Pointer for PCB Name
	char *tempPtr2 = NULL;											//Temporary Input Character Pointer for New Priority
	PCBitem *tempPCB;												//Temporary PCB Item
	int charCount = 0;												//Number of Characters in Process Name
	int newPriority = 0;											//New Priority value
	
	//Get PCB name
	printf("Please enter the name of the PCB to Set the Priority: ");
	tempPtr = keyboardInput(0);										//Gets process name from User
	tempPtr = pointer2Str(tempPtr);									//Convert Character Pointer to Character String
	charCount = sizeOfPointer(tempPtr);								//Get Name Size
	
	
	if((charCount >= 8)){											//Check that the Name is Valid (Check to see if at least 8 chars. + Null Terminator)
		tempPCB = find_PCB(tempPtr);
		if(tempPCB != NULL){										//Check that the PCB Exists
			
			//Get New Priority from User
			printf("Please enter a number between -128 & +127 to set the new Priority: ");
			tempPtr = keyboardInput(0);									//Gets process name from User
			newPriority = pointer2Int(tempPtr);							//Convert Character Pointer to Int
			
			
			if((new_pPriority >= -128) || (new_pPriority <= 127)){		//Check that the new priority is valid (-128 to 127)
				tempPCB->pPriority = new_pPriority;						//Set new PCB Priority
				
				//If the PCB is in the ready state, you will need to change the position of the PCB in the queue based upon its new priority
				if(tempPCB->state == READY){
					error = remove_PCB(tempPCB->state, tempPCB);						//Remove PCB from Ready Queue
					error = errorCheck(error);							//Perform Error Check
					error = insert_PCB(tempPCB->state, tempPCB);						//Insert PCB into Ready Queue (so as to adjust for new Priority)
					error = errorCheck(error);							//Perform Error Check
				}//end if
			}//end if
			
			//Display appropriate error or success message.
			if(error == 0){
				printf("The PCB Process has been successfully blocked.\n");
			}//end if
			
		} else{
			printf("Process Name does not exist.\n");
		}//end if
	} else{
		printf("Process Name is Invalid. Process Name must be at least 8 characters in length.\n");
	}//end if
}//end setPriority
Ejemplo n.º 16
0
void
MooseApp::run()
{
  Moose::perf_log.push("Full Runtime", "Application");

  Moose::perf_log.push("Application Setup", "Setup");
  try
  {
    setupOptions();
    runInputFile();
  }
  catch (std::exception & err)
  {
    mooseError(err.what());
  }
  Moose::perf_log.pop("Application Setup", "Setup");

  if (!_check_input)
    executeExecutioner();
  else
  {
    errorCheck();
    // Output to stderr, so it is easier for peacock to get the result
    Moose::err << "Syntax OK" << std::endl;
  }

  Moose::perf_log.pop("Full Runtime", "Application");
}
Ejemplo n.º 17
0
ClState::Buffer ClState::createFromGLTexture(
		const Context& c,
		BufferFlag flag,
		uint32 gl_target,
		uint32 gl_id){
	ensure(gl_id != 0);
	cl_int err= 0;
	Buffer b;
	// clCreateFromGLTexture*D is deprecated, but OpenCL 1.1 is what we use
	if (gl_target == GL_TEXTURE_2D){
		b.id= clCreateFromGLTexture2D(	c.id,
										flag,
										gl_target,
										0, // miplevel
										gl_id,
										&err);
	}
	else if (gl_target == GL_TEXTURE_3D){
		b.id= clCreateFromGLTexture3D(	c.id,
										flag,
										gl_target,
										0, // miplevel
										gl_id,
										&err);
	}
	else {
		// OpenCL 1.2 has clCreateFromGLTexture which would allow tex arrays
		throw global::Exception(
				"ClState::createFromGLTexture(..): unsupported tex target");
	}
	
	errorCheck("ClState::createFromGLTexture(..): clCreateFromGLTexture failed: ", err);
	return b;
}
Ejemplo n.º 18
0
HRESULT
recChannel_t::remap(void)
{
     __CONTEXT("recChannel_t::remap");
	IBaseFilter * pFilter = NULL;
	int hr = 0;	
	pControl->StopWhenReady();
	IPin * pin = NULL;

	hr = pGraph->FindFilterByName(L"AVI Decompressor",&pFilter);
	
	if (!hr) 
	{
		hr = pGraph->RemoveFilter(pFilter);
		errorCheck(hr);
		pFilter->Release();
	}

	hr = pGraph->FindFilterByName(L"Video Renderer",&pFilter);
	if (!hr)
	{
	
		while ((hr = GetConnectedPin(pFilter,PINDIR_INPUT,&pin))==0)
		{
			pin->Disconnect();
		}
	}

	if (pOutput) pOutput->Disconnect();

	remaped = true;
	return 0;

}
Ejemplo n.º 19
0
HRESULT 
recChannel_t::unmap(void)
{
     __CONTEXT("recChannel_t::unmap");
	
	IBaseFilter * pFilter = NULL;
	int hr =0;
	hr = pGraph->FindFilterByName(L"Video Renderer",&pFilter);
	
	if (!hr)
	{
	 	IVideoWindow *pWindowInfo = NULL;
		hr = pFilter->QueryInterface(IID_IVideoWindow, (void **)&pWindowInfo);
		errorCheck(hr);
		pWindowInfo->put_Visible(OAFALSE);
		pWindowInfo->put_AutoShow(OAFALSE);
		pWindowInfo->Release();
	}
	
	pControl->StopWhenReady();
#ifdef _WINDOWS
    if (fControl)
    {
        fControl->CWnd::ShowWindow(SW_HIDE);
    }
#endif
	mapping = false;
	return 0;
}
Ejemplo n.º 20
0
void ClState::enqueueWork(const Work& w, const CommandQueue& q){
	ensure(q.id != 0);
	size_t g_w_s= w.globalSize;
	size_t l_w_s= w.localSize;
	cl_int err= clEnqueueNDRangeKernel(q.id, w.kernel.id, (cl_uint)1, NULL, &g_w_s, &l_w_s, 0, NULL, NULL);
	errorCheck("clEnqueueNDRangeKernel", err);
}
void RSSI_MODEL_Tasks() {
  switch (rssi_modelData.state) {
  case RSSI_MODEL_INIT: {
    rssi_modelData.state = RSSI_MODEL_RECEIVE;
    rssi_modelData.beginning = std::chrono::system_clock::now();
    rssi_modelData.total_num = 0;
    rssi_modelData.rate_per_min = 0.0;
  } break;
  case RSSI_MODEL_RECEIVE: {
    auto receivedData = rssi_modelData.input_queue.dequeue();

    {
      std::lock_guard<std::mutex> guard(rssi_modelData.data_mutex);
      if (rssi_modelData.data_vec.size() == 50) {
        rssi_modelData.data_vec.erase(rssi_modelData.data_vec.begin());
      }
      rssi_modelData.data_vec.push_back(receivedData);
      rssi_modelData.total_num++;
      auto seconds = std::chrono::duration_cast<std::chrono::seconds>(
                         std::chrono::system_clock::now() -
                         rssi_modelData.beginning).count();
      rssi_modelData.rate_per_min =
          60 * ((float)rssi_modelData.total_num / seconds);
    }
  } break;
  default: { errorCheck(); } break;
  }
}
Ejemplo n.º 22
0
/* Playing */
void Sound::play()
{
	FMOD_RESULT result;
	result = system->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
	channel->setVolume(volume);
	errorCheck(result);
}
Ejemplo n.º 23
0
void extractChannels( int argc, char* argv[] )
{
  pfs::DOMIO pfsio;

  static struct option cmdLineOptions[] = {
    { "help", no_argument, NULL, 'h' },
    { NULL, 0, NULL, 0 }
  };

  std::set<const char*, ltstr> keepChannels;

  int optionIndex = 0;
  while( 1 ) {
    int c = getopt_long (argc, argv, "h", cmdLineOptions, &optionIndex);
    if( c == -1 ) break;
    switch( c ) {
    case 'h':
      printHelp();
      throw QuietException();
    case '?':
      throw QuietException();
    case ':':
      throw QuietException();
    }
  }

  errorCheck( optind < argc, "At least one channel must be specified" );

  for( ;optind < argc; optind++ )
    keepChannels.insert( argv[optind] );

  
  while( true ) {
    pfs::Frame *frame = pfsio.readFrame( stdin );
    if( frame == NULL ) break; // No more frames

    {                           // Check if the listed channels exist
      std::set<const char*, ltstr>::iterator it;
      for( it = keepChannels.begin(); it != keepChannels.end(); it++ )
        if( frame->getChannel( *it ) == NULL ) {
          fprintf( stderr, PROG_NAME " error: Channel %s does not exist\n", *it );
          throw QuietException();
        }
      
    }
    
    {                           // Remoe not listed channels
      pfs::ChannelIterator *it = frame->getChannels();
      while( it->hasNext() ) {
        pfs::Channel *channel = it->getNext();
        if( keepChannels.find(channel->getName() ) == keepChannels.end() )
          frame->removeChannel( channel );
      }
    }    
    
    pfsio.writeFrame( frame, stdout );
    pfsio.freeFrame( frame );        
  }
}
Ejemplo n.º 24
0
/* The main function for the symbol checking phase. */
void symSCRIPTCOLLECTION(SCRIPTCOLLECTION *s)
{
	sym1PassSCRIPTCOLLECTION(s);
	/* call errorCheck to make sure that parsetree is valid */
	if(errorCheck()) return;

	sym2PassSCRIPTCOLLECTION(s);
}
Ejemplo n.º 25
0
void ClState::destroyProgram(Program& p){
	ensure(p.id);
	
	cl_int err= clReleaseProgram(p.id);
	errorCheck("ClState::destroyProgram(..): clReleaseProgram failed: ", err);

	p.id= 0;
}
Ejemplo n.º 26
0
/**
	Procedure: handler_help_function

	Purpose: Displays information on specified command

	Parameters: funName(The command name that more information is desired on.) 

	Return value: None

	Calls: errorCheck    

	Globals: None

	Errors: Invalid help_ command
**/	
void handler_help_function(char funName[]){
	printf("\n");
	if(strcmp(funName,"version")==0){
		printf("The version command simply displays the current working version number and the date it was finalized on. This command is called by typing \"version\". Possible Error: Invalid help_ command.");
	}
	else if(strcmp(funName,"display_mpx")==0){
		printf("The display_mpx command is used to locate mpx files in a directory. The directory can be specified or the current directory can be selected by pressing enter once the prompt for directory has come up. Then all mpx files will be displayed with name, buffer size used, and file size. This command may be called by typing \"display_mpx\" in the command prompt. Possible Errors: Invalid Directory, Directory Not Open, No More Directory Entries, Read Failed, Name To Long For Buffer, No Directory Is Open.");
	}
	else if(strcmp(funName,"get_date")==0){
		printf("The get_date command grabs the set date and displays it. If there is no set date then the system date is acquired and displayed. This command can be accessed by typing \"get_date\" in the command prompt.");
	}
	else if(strcmp(funName,"set_date")==0){
		printf("The set_date command takes in user input in the form of a string of numbers(MMDDYYYY) and sets that as the current date. The set_date command can be accessed by typing \"set_date\" in the command prompt. Possible Errors: Invalid Date, Date Not Changed.");
	}
	else if(strcmp(funName,"change_prompt")==0){
		printf("The change_prompt command replaces the standard :> prompt with any prompt that is desired and is 4 characters or less. This command is initiated by typing \"change_prompt\"in the command prompt.");
	}
	else if(strcmp(funName,"terminate_mpx")==0){
		printf("The terminate_mpx command exits the mpx os after it confirms with the user that the os is desired to exit. After confirmation allocated memory is cleared and the os terminates. This command may be called by typing either \"quit\",\"exit\", or \"terminate_mpx\"in the command prompt.");
	}
	else if(strcmp(funName,"create_pcb")==0){
		printf("The create_pcb command initializes a new PCB structure. After the command is entered, the user is prompted to input in a unique PCB name, the PCB class, and the PCB priority level. This command is called by typing \"create_pcb\" in the command prompt.");
	}
	else if(strcmp(funName,"delete_pcb")==0){
		printf("The delete_pcb command deletes a defined PCB structure. Initially, the user is prompted to input the name of a current PCB structure. If the PCB exists, it is removed from its current queue, and its assigned memory is deallocated. This command is called by typing \"delete_pcb\" in the command prompt.");
	}
	else if(strcmp(funName,"block")==0){
		printf("The block command blocks a defined PCB structure. Initially, the user is prompted to input the name of a current PCB structure. If the name is valid and the PCB exists, the PCB is removed from its current queue, updates its current state, and inserted into its new queue. This command is called by typing \"block\" in the command prompt.");
	}
	else if(strcmp(funName,"unblock")==0){
		printf("The unblock command unblocks a blocked PCB structure. Initially, the user is prompted to input the name of the current PCB structure. If the name is valid and the PCB exists, the PCB is removed from its current queue, updates its current state, and inserted into its new queue. This command is called by typing \"unblock\" in the command prompt.");
	}
	else if(strcmp(funName,"suspend")==0){
		printf("The suspend command suspends a defined PCB structure. Initially, the user is prompted to input the name of the current PCB structure. If the name is valid and the PCB exists, the PCB is removed from its current queue, updates its current state, and inserted into its new queue. This command is called by typing \"suspend\" in the command prompt.");
	}
	else if(strcmp(funName,"resume")==0){
		printf("The resume command suspends a defined PCB structure. Initially, the user is prompted to input the name of the current PCB structure. If the name is valid and the PCB exists, the PCB is removed from its current queue, updates its current state, and inserted into its new queue. This command is called by typing \"resume\" in the command prompt.");
	}
	else if(strcmp(funName,"set_priority")==0){
		printf("The set_priority command changes the priority of a defined PCB structure. Initially, the user is prompted to input the name of the current PCB structure. If the name is valid and the PCB exists, the user is prompted to enter in the new PCB priority. If the new priority is valid, the PCB priority is updated, and the PCB position is adjusted, if the PCB is in the Ready queue. This command is called by typing \"set_priority\" in the command prompt.");
	}
	else if(strcmp(funName,"show_pcb")==0){
		printf("The show_pcb command shows all the stored information within a PCB structure. Initially, the user is prompted to input the name of the current PCB structure. If the name is valid and the PCB exists, the PCB Name, Class, Priority, State, and Memory Size is displayed. This command is called by typing \"show_pcb\" in the command prompt.");
	}
	else if(strcmp(funName,"show_all")==0){
		printf("The show_all command shows all the stored information for all PCB structures. This command is initiated by typing \"show_all\"in the command prompt.");
	}
	else if(strcmp(funName,"show_ready")==0){
		printf("The show_ready command shows all the stored information for each PCB structure in the Ready queues. This command is initiated by typing \"show_ready\"in the command prompt.");
	}
	else if(strcmp(funName,"show_blocked")==0){
		printf("The show_blocked command shows all the stored information for each PCB structure in the Blocked queues. This command is initiated by typing \"show_blocked\"in the command prompt.");
	}
	else{
		errorCheck(-124);
	}
	printf("\n");
}
Ejemplo n.º 27
0
FMOD::Channel * AudioEngine::playSound(FMOD::Sound * sound, glm::vec3 pos, PhysicsEntity * source, float volume = 1)
{

	FMOD::Channel * playingOn = nullptr;

	result = fmodSystem->playSound(sound, 0, false, &playingOn);
	errorCheck();
	result = playingOn->setVolumeRamp(false); // For fixing popping noise at low volume.
	errorCheck();
	result = playingOn->set3DAttributes(&glmVec3ToFmodVec(pos), 0);
	errorCheck();
	result = playingOn->setPaused(false);
	errorCheck();
	result = playingOn->setVolume(volume);
	errorCheck();
	result = playingOn->setCallback(channelCallback);
	errorCheck();
	result = playingOn->setUserData((void*)this);
	errorCheck();

	currentlyPlaying[playingOn] = source;
	if(currentlyPlaying.size() > numChannels)
	{
		numChannels = currentlyPlaying.size();
		printf("%d/%d channels used\n", numChannels, MAX_CHANNELS);
	}

	return playingOn;
}
Ejemplo n.º 28
0
recChannel_t::recChannel_t(
		int ID,			//channel ID
        const char *title, //Window Title
        windowInfo_t *geom //Window info
		):channel_t(ID,title,geom){

    __CONTEXT("recChannel_t::recChannel_t");
   
    int hr = 0;
	frameRate = 0;
	pSource  = NULL;
	pSender  = NULL;
#ifdef _WINDOWS
    fControl = NULL;
    hThread = 0;
    hThreadPos = 0;
#endif
	frameRate = 1.0;
	all = true;


	looper = new looper_t(this);

	Kind = REC;
	
	camInfo = NULL;
	capInfo.heigth = DEFAULT_CAPTURE_HEIGTH;
	capInfo.width  = DEFAULT_CAPTURE_WIDTH;

	if (freeSources())
	{
		for (int j = 0; j < camArray.size(); j++)
		{
			camInfo_t *camInfo= camArray.elementAt(j);
			if (camInfo->getFree() && camInfo->getKind() == CAM)
			{
				sourceId = camInfo->getID();
				memset(sourceFormat, 0, 100);
				all = true;
				hr = select_source(camInfo);
				camInfo->setFree(false);
				break;
			}
		}
	}
	else
	{
		set_file_source(NULL);
	}

	errorCheck(hr);	

	pSender = new sender_t(this);
	channelList->insert(getId(),this);

	rtpSession->assignSender(getId(), false, static_cast<sched_t*>(NULL));
}
Ejemplo n.º 29
0
/* Loading */
bool Sound::load(const char *filename, const char *ext, bool loop, float volume)
{
	std::stringstream ss;
	ss << filename << ext;
	this->volume = volume;

	FMOD_RESULT result;
	channel = NULL;
	result = FMOD::System_Create(&system);
	errorCheck(result);
	result = system->init(32, FMOD_INIT_NORMAL, 0);
	errorCheck(result);
	if (loop) result = system->createSound(ss.str().c_str(), FMOD_HARDWARE | FMOD_LOOP_NORMAL, 0, &sound);
	else result = system->createSound(ss.str().c_str(), FMOD_HARDWARE, 0, &sound);
	errorCheck(result);

	return true;
}
Ejemplo n.º 30
0
SplineInterpolation::SplineInterpolation(const std::vector<double> & x, const std::vector<double> & y, double yp1/* = 1e30*/, double ypn/* = 1e30*/) :
    _x(x),
    _y(y),
    _yp1(yp1),
    _ypn(ypn)
{
  errorCheck();
  solve();
}