Ejemplo n.º 1
0
// ScraperSearchHandle
ScraperSearchHandle::ScraperSearchHandle()
{
	setStatus(ASYNC_IN_PROGRESS);
}
Ejemplo n.º 2
0
uint32_t com_ximeta_driver_NDASLogicalDevice::updateStatus()
{
	uint32_t prevStatus, newStatus;
	
	prevStatus = newStatus = Status();

	switch(prevStatus) {
		case kNDASUnitStatusNotPresent:
		case kNDASUnitStatusFailure:
		{
			newStatus = fUnitDevice->Status();
		}
			break;
		case kNDASUnitStatusDisconnected:
		{
			switch(fUnitDevice->Status()) {
				case kNDASUnitStatusConnectedRO:
				{
					newStatus = kNDASUnitStatusTryConnectRO;
				}
					break;
				case kNDASUnitStatusConnectedRW:
				{
					newStatus = kNDASUnitStatusTryConnectRW;
				}
					break;
				case kNDASUnitStatusFailure:
				case kNDASUnitStatusNotPresent:
				{
					newStatus = fUnitDevice->Status();
				}
					break;
			}
		}
			break;
		case kNDASUnitStatusTryConnectRO:
		{
			if (kNDASUnitStatusConnectedRO == fUnitDevice->Status()) {
				newStatus = kNDASUnitStatusConnectedRO;
			}
		}
			break;
		case kNDASUnitStatusTryConnectRW:
		{
			if (kNDASUnitStatusConnectedRW == fUnitDevice->Status()) {
				newStatus = kNDASUnitStatusConnectedRW;
			}
		}
			break;
		case kNDASUnitStatusConnectedRO:
		{
			switch(fUnitDevice->Status()) {
				case kNDASUnitStatusDisconnected:
				case kNDASUnitStatusFailure:
				case kNDASUnitStatusNotPresent:
					newStatus = kNDASUnitStatusTryDisconnectRO;
					break;
				case kNDASUnitStatusReconnectRO:
					newStatus = kNDASUnitStatusReconnectRO;
					break;
			}
		}
			break;
		case kNDASUnitStatusConnectedRW:
		{
			switch(fUnitDevice->Status()) {
				case kNDASUnitStatusDisconnected:
				case kNDASUnitStatusFailure:
				case kNDASUnitStatusNotPresent:
					newStatus = kNDASUnitStatusTryDisconnectRW;
					break;
				case kNDASUnitStatusReconnectRW:
					newStatus = kNDASUnitStatusReconnectRW;
					break;
			}
		}
			break;
		case kNDASUnitStatusTryDisconnectRO:
		case kNDASUnitStatusTryDisconnectRW:
		{
		
			com_ximeta_driver_NDASLogicalDeviceController *controller = OSDynamicCast(com_ximeta_driver_NDASLogicalDeviceController, getClient());
			DbgIOASSERT(controller);
			
			if (!controller->isProtocolTransportNubAttached()) {
				newStatus = kNDASUnitStatusDisconnected;
			}

		}
			break;
		case kNDASUnitStatusReconnectRO:
		{
			switch (fUnitDevice->Status()) {
			case kNDASUnitStatusConnectedRO:
				newStatus = kNDASUnitStatusConnectedRO;
				break;
			case kNDASUnitStatusDisconnected:
			case kNDASUnitStatusFailure:
			case kNDASUnitStatusNotPresent:
				newStatus = kNDASUnitStatusTryDisconnectRO;
				break;
			}
		}
			break;
		case kNDASUnitStatusReconnectRW:
		{
			switch (fUnitDevice->Status()) {
				case kNDASUnitStatusConnectedRW:
					newStatus = kNDASUnitStatusConnectedRW;
					break;
				case kNDASUnitStatusDisconnected:
				case kNDASUnitStatusFailure:
				case kNDASUnitStatusNotPresent:
					newStatus = kNDASUnitStatusTryDisconnectRW;
					break;
			}
		}
			break;
		default:
			break;
	}

	if (prevStatus != newStatus) {
		DbgIOLog(DEBUG_MASK_NDAS_INFO, ("Status changed from %d to %d. Status of Unit %d\n", Status(), newStatus, prevStatus));
		
		// Send Message to BunEnumerator.
		sendNDASFamilyIOMessage(kNDASFamilyIOMessageLogicalDeviceStatusWasChanged, UnitDevice()->ID(), sizeof(GUID));
	}
	
	setStatus(newStatus);
	
	return Status();
}
Ejemplo n.º 3
0
// ScraperHttpRequest
ScraperHttpRequest::ScraperHttpRequest(std::vector<ScraperSearchResult>& resultsWrite, const std::string& url) 
	: ScraperRequest(resultsWrite)
{
	setStatus(ASYNC_IN_PROGRESS);
	mReq = std::unique_ptr<HttpReq>(new HttpReq(url));
}
Ejemplo n.º 4
0
void ShellChannel::shellReady()
{
	setStatus(Open);
}
Ejemplo n.º 5
0
bool LLXMLRPCTransaction::Impl::process()
{
	switch(mStatus)
	{
		case LLXMLRPCTransaction::StatusComplete:
		case LLXMLRPCTransaction::StatusCURLError:
		case LLXMLRPCTransaction::StatusXMLRPCError:
		case LLXMLRPCTransaction::StatusOtherError:
		{
			return true;
		}
		
		case LLXMLRPCTransaction::StatusNotStarted:
		{
			setStatus(LLXMLRPCTransaction::StatusStarted);
			break;
		}
		
		default:
		{
			// continue onward
		}
	}
	
	const F32 MAX_PROCESSING_TIME = 0.05f;
	LLTimer timer;
	int count;
	
	while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(mCurlMulti, &count))
	{
		if (timer.getElapsedTimeF32() >= MAX_PROCESSING_TIME)
		{
			return false;
		}
	}
			 
	while(CURLMsg* curl_msg = curl_multi_info_read(mCurlMulti, &count))
	{
		if (CURLMSG_DONE == curl_msg->msg)
		{
			if (curl_msg->data.result != CURLE_OK)
			{
				setCurlStatus(curl_msg->data.result);
				llwarns << "LLXMLRPCTransaction CURL error "
					<< mCurlCode << ": " << mCurlErrorBuffer << llendl;
				llwarns << "LLXMLRPCTransaction request URI: "
					<< mURI << llendl;
					
				return true;
			}
			
			setStatus(LLXMLRPCTransaction::StatusComplete);

			mResponse = XMLRPC_REQUEST_FromXML(
				mResponseText.data(), mResponseText.size(), NULL);

			bool		hasError = false;
			bool		hasFault = false;
			int			faultCode = 0;
			std::string	faultString;

			LLXMLRPCValue error(XMLRPC_RequestGetError(mResponse));
			if (error.isValid())
			{
				hasError = true;
				faultCode = error["faultCode"].asInt();
				faultString = error["faultString"].asString();
			}
			else if (XMLRPC_ResponseIsFault(mResponse))
			{
				hasFault = true;
				faultCode = XMLRPC_GetResponseFaultCode(mResponse);
				faultString = XMLRPC_GetResponseFaultString(mResponse);
			}

			if (hasError || hasFault)
			{
				setStatus(LLXMLRPCTransaction::StatusXMLRPCError);
				
				llwarns << "LLXMLRPCTransaction XMLRPC "
					<< (hasError ? "error " : "fault ")
					<< faultCode << ": "
					<< faultString << llendl;
				llwarns << "LLXMLRPCTransaction request URI: "
					<< mURI << llendl;
			}
			
			return true;
		}
	}
	
	return false;
}
Ejemplo n.º 6
0
bool
MediaPluginGStreamer010::load()
{
	if (!mDoneInit)
		return false; // error

	setStatus(STATUS_LOADING);

	DEBUGMSG("setting up media...");

	mIsLooping = false;
	mVolume = 0.1234567; // minor hack to force an initial volume update

	// Create a pumpable main-loop for this media
	mPump = g_main_loop_new (NULL, FALSE);
	if (!mPump)
	{
		setStatus(STATUS_ERROR);
		return false; // error
	}

	// instantiate a playbin element to do the hard work
	mPlaybin = llgst_element_factory_make ("playbin", "play");
	if (!mPlaybin)
	{
		setStatus(STATUS_ERROR);
		return false; // error
	}

	// get playbin's bus
	GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin));
	if (!bus)
	{
		setStatus(STATUS_ERROR);
		return false; // error
	}
	mBusWatchID = llgst_bus_add_watch (bus,
					   llmediaimplgstreamer_bus_callback,
					   this);
	llgst_object_unref (bus);

#if 0 // not quite stable/correct yet
	// get a visualizer element (bonus feature!)
	char* vis_name = getenv("LL_GST_VIS_NAME");
	if (!vis_name ||
	    (vis_name && std::string(vis_name)!="none"))
	{
		if (vis_name)
		{
			mVisualizer = llgst_element_factory_make (vis_name, "vis");
		}
		if (!mVisualizer)
		{
			mVisualizer = llgst_element_factory_make ("libvisual_jess", "vis");
			if (!mVisualizer)
			{
				mVisualizer = llgst_element_factory_make ("goom", "vis");
				if (!mVisualizer)
				{
					mVisualizer = llgst_element_factory_make ("libvisual_lv_scope", "vis");
					if (!mVisualizer)
					{
						// That's okay, we don't NEED this.
					}
				}
			}
		}
	}
#endif

	if (NULL == getenv("LL_GSTREAMER_EXTERNAL")) {
		// instantiate a custom video sink
		mVideoSink =
			GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo"));
		if (!mVideoSink)
		{
			WARNMSG("Could not instantiate private-slvideo element.");
			// todo: cleanup.
			setStatus(STATUS_ERROR);
			return false; // error
		}

		// connect the pieces
		g_object_set(mPlaybin, "video-sink", mVideoSink, NULL);
	}

	if (mVisualizer)
	{
		g_object_set(mPlaybin, "vis-plugin", mVisualizer, NULL);
	}

	return true;
}
Ejemplo n.º 7
0
void *
restoreDbFromTape(void *param)
{
    afs_uint32 taskId = (intptr_t) param;
    afs_int32 code = 0;
    afs_int32 i;
    struct butm_tapeInfo tapeInfo;
    struct rstTapeInfo rstTapeInfo;
    struct budb_dumpEntry dumpEntry;

    extern struct tapeConfig globalTapeConfig;
    extern struct deviceSyncNode *deviceLatch;

    afs_pthread_setname_self("Db restore");
    setStatus(taskId, DRIVE_WAIT);
    EnterDeviceQueue(deviceLatch);	/* lock tape device */
    clearStatus(taskId, DRIVE_WAIT);

    printf("\n\n");
    TLog(taskId, "RestoreDb\n");

    tapeInfo.structVersion = BUTM_MAJORVERSION;
    code = butm_file_Instantiate(&tapeInfo, &globalTapeConfig);
    if (code) {
        ErrorLog(0, taskId, code, tapeInfo.error,
                 "Can't initialize tape module\n");
        ERROR_EXIT(code);
    }

    listEntryHead = NULL;

    rstTapeInfo.taskId = taskId;
    rstTapeInfo.tapeSeq = 1;
    rstTapeInfo.dumpid = 0;

    code = readDbTape(&tapeInfo, &rstTapeInfo, autoQuery);
    if (code)
        ERROR_EXIT(code);

    code = restoreDbEntries(&tapeInfo, &rstTapeInfo);
    if (code)
        ERROR_EXIT(code);

error_exit:
    /* Now put this dump into the database */
    /* Make a dump entry from first tape   */
    listEntryPtr = listEntryHead;
    if (listEntryPtr) {
        makeDbDumpEntry(tapeEntryPtr, &dumpEntry);
        if (dumpEntry.id != 0) {
            i = bcdb_CreateDump(&dumpEntry);
            if (i) {
                if (i == BUDB_DUMPIDEXISTS)
                    fprintf(stderr,
                            "Dump id %d not added to database - already exists\n",
                            dumpEntry.id);
                else
                    TapeLog(0, taskId, i, 0,
                            "Dump id %d not added to database\n",
                            dumpEntry.id);
            } else {
                i = addTapesToDb(taskId);
                if (!code)
                    code = i;

                i = bcdb_FinishDump(&dumpEntry);
                if (!code)
                    code = i;
            }
        }
        freeTapeList();
    }

    unmountTape(taskId, &tapeInfo);
    waitDbWatcher();

    if (code == TC_ABORTEDBYREQUEST) {
        TLog(taskId, "RestoreDb: Aborted by request\n");
        clearStatus(taskId, ABORT_REQUEST);
        setStatus(taskId, ABORT_DONE);
    } else if (code) {
        TapeLog(0, taskId, code, 0, "RestoreDb: Finished with errors\n");
        setStatus(taskId, TASK_ERROR);
    } else {
        TLog(taskId, "RestoreDb: Finished\n");
    }

    LeaveDeviceQueue(deviceLatch);
    setStatus(taskId, TASK_DONE);

    return (void *)(intptr_t)(code);
}
Ejemplo n.º 8
0
 void Stream::didPlay(const Timer& timer, Status previousStatus)
 {
     setStatus(Playing);
 }
Ejemplo n.º 9
0
 void Stream::didPause(const Timer& timer, Status previousStatus)
 {
     setStatus(Paused);
 }
Ejemplo n.º 10
0
void RS_ActionDrawLineParallel::commandEvent(RS_CommandEvent* e) {
    QString c = e->getCommand().toLower();

    if (checkCommand("help", c)) {
        if (RS_DIALOGFACTORY) {
            RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
                                             + getAvailableCommands().join(", "));
        }
        return;
    }

    switch (getStatus()) {
    case SetEntity: {
        if (checkCommand("through", c)) {
            finish(false);
            graphicView->setCurrentAction(
                new RS_ActionDrawLineParallelThrough(*container,
                        *graphicView));
        } else if (checkCommand("number", c)) {
            deletePreview();
            setStatus(SetNumber);
        } else {
            bool ok;
            double d = RS_Math::eval(c, &ok);
            if(ok) e->accept();
            if (ok && d>1.0e-10) {
                distance = d;
            } else {
                if (RS_DIALOGFACTORY) {
                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
                }
            }
            if (RS_DIALOGFACTORY) {
                RS_DIALOGFACTORY->requestOptions(this, true, true);
            }
            updateMouseButtonHints();
            //setStatus(SetEntity);
        }
    }
    break;

    case SetNumber: {
        bool ok;
        int n = c.toInt(&ok);
        if (ok) {
            e->accept();
            if (n>0 && n<100) {
                number = n;
            } else {
                if (RS_DIALOGFACTORY) {
                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid number. "
                                                        "Try 1..99"));
                }
            }
        } else {
            if (RS_DIALOGFACTORY) {
                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
            }
        }
        if (RS_DIALOGFACTORY) {
            RS_DIALOGFACTORY->requestOptions(this, true, true);
        }
        setStatus(SetEntity);
    }
    break;

    default:
        break;
    }
}
Ejemplo n.º 11
0
void Interface::doCommand(QString command_string, char type)
{
    QString command = request.extractCommand(command_string);
    QString id = request.extractId(command_string);

    clearConsole();
    printLines();


    if(type == 'p') //PERSON
    {
        if(request.getPerson(id).getId().isEmpty()) //needed to prevent crashes
        {
            setStatus("Person #" + id.toStdString() + " does not exist or is omitted!");
            return;
        }

        printMenuHead(command.toUpper().toStdString() + " PERSON");

        if(command == "edit")
        {
            editPerson(id);
        }
        else if(command == "delete")
        {
            deletePerson(id);
        }
        else if(command == "addr")
        {
            addPersonRelation(id);
        }
        else if(command == "viewr")
        {
            viewPersonXComputers(id);
        }
    }
    else if(type == 'c') //COMPUTER
    {
        if(request.getComputer(id).getId().isEmpty()) //needed to prevent crashes
        {
            setStatus("Computer #" + id.toStdString() + " does not exist!");
            return;
        }

        printMenuHead(command.toUpper().toStdString() + " COMPUTER");

        if(command == "edit")
        {
            editComputer(id);
        }
        else if(command == "delete")
        {
            deleteComputer(id);
        }
        else if(command == "addr")
        {
            addComputerRelation(id);
        }
        else if(command == "viewr")
        {
            viewComputerXPersons(id);
        }
    }
}
Ejemplo n.º 12
0
	void RuleWgt::lineEditRegExp_changed(const QString& text)
	{
		m_strPattern = text;
		m_regExp.setPattern(m_strPattern);
		setStatus(this->isValid());
	}
Ejemplo n.º 13
0
int GSM::begin(long baud_rate){
	int response=-1;
	int cont=0;
	boolean norep=false;
	boolean turnedON=false;
	SetCommLineStatus(CLS_ATCMD);
	_cell.begin(baud_rate);
	setStatus(IDLE); 

	
	for (cont=0; cont<3; cont++){
		if (AT_RESP_ERR_NO_RESP == SendATCmdWaitResp("AT", 500, 100, "OK", 5)&&!turnedON) {		//check power
	    // there is no response => turn on the module
			#ifdef DEBUG_ON
				Serial.println("DB:NO RESP");
			#endif
			// generate turn on pulse
			digitalWrite(GSM_ON, HIGH);
			delay(1200);
			digitalWrite(GSM_ON, LOW);
			delay(10000);
			norep=true;
		}
		else{
			#ifdef DEBUG_ON
				Serial.println("DB:ELSE");
			#endif
			norep=false;
		}
	}
	
	if (AT_RESP_OK == SendATCmdWaitResp("AT", 500, 100, "OK", 5)){
		#ifdef DEBUG_ON
			Serial.println("DB:CORRECT BR");
		#endif
		turnedON=true;
	}
	if(cont==3&&norep){
		Serial.println("Trying to force the baud-rate to 9600\n");
		for (int i=0;i<8;i++){
		switch (i) {
			case 0:
			  _cell.begin(1200);
			  _cell.print(F("AT+IPR=9600\r"));
			  break;
			  
			case 1:
			  _cell.begin(2400);
			  _cell.print(F("AT+IPR=9600\r"));
			  break;
			  
			case 2:
			  _cell.begin(4800);
			  _cell.print(F("AT+IPR=9600\r"));
			  break;
			  
			case 3:
			  _cell.begin(9600);
			  _cell.print(F("AT+IPR=9600\r"));
			  break;
			   
			case 4:
			  _cell.begin(19200);
			  _cell.print(F("AT+IPR=9600\r"));
			  break;
			  
			case 5:
			  _cell.begin(38400);
			  _cell.print(F("AT+IPR=9600\r"));
			  break;
			  
			case 6:
			  _cell.begin(57600);
			  _cell.print(F("AT+IPR=9600\r"));
			  break;
			  
			case 7:
			  _cell.begin(115200);
			  _cell.print(F("AT+IPR=9600\r"));
			  break;
			}	
		}
		Serial.println("ERROR: SIM900 doesn't answer. Check power and serial pins in GSM.cpp");
		return 0;
	}


	if (AT_RESP_ERR_DIF_RESP == SendATCmdWaitResp("AT", 500, 100, "OK", 5)&&!turnedON){		//check OK
		#ifdef DEBUG_ON
			Serial.println("DB:DIFF RESP");
		#endif
		for (int i=0;i<8;i++){
			switch (i) {
			case 0:
			  _cell.begin(1200);
			  break;
			  
			case 1:
			  _cell.begin(2400);
			  break;
			  
			case 2:
			  _cell.begin(4800);
			  break;
			  
			case 3:
			  _cell.begin(9600);
			  break;
			   
			case 4:
			  _cell.begin(19200);
			  break;
			  
			case 5:
			  _cell.begin(38400);
			  break;
			  
			case 6:
			  _cell.begin(57600);
			  break;
			  
			case 7:
			  _cell.begin(115200);
			  _cell.print(F("AT+IPR=9600\r"));
			  _cell.begin(9600);
			  delay(500);
			  break;
  
			// if nothing else matches, do the default
			// default is optional
			}
					
			delay(100);

			#ifdef DEBUG_PRINT
				// parameter 0 - because module is off so it is not necessary 
				// to send finish AT<CR> here
				DebugPrint("DEBUG: Stringa ", 0);
				DebugPrint(buff, 0);
			#endif
				

			if (AT_RESP_OK == SendATCmdWaitResp("AT", 500, 100, "OK", 5)){
				#ifdef DEBUG_ON
					Serial.println("DB:FOUND PREV BR");
				#endif
				_cell.print(F("AT+IPR="));
				_cell.print(baud_rate);    
				_cell.print("\r"); // send <CR>
				delay(500);
				_cell.begin(baud_rate);
				delay(100);
				if (AT_RESP_OK == SendATCmdWaitResp("AT", 500, 100, "OK", 5)){
					#ifdef DEBUG_ON
						Serial.println("DB:OK BR");
					#endif
				}
				turnedON=true;
				break;					
			}
			#ifdef DEBUG_ON
				Serial.println("DB:NO BR");
			#endif			
		}
		// communication line is not used yet = free
		SetCommLineStatus(CLS_FREE);
		// pointer is initialized to the first item of comm. buffer
		p_comm_buf = &comm_buf[0];
	}

	SetCommLineStatus(CLS_FREE);

	if(turnedON){
		WaitResp(50, 50);
		InitParam(PARAM_SET_0);
		InitParam(PARAM_SET_1);//configure the module  
		Echo(0);               //enable AT echo
		setStatus(READY);
		return(1);

	}
	else{
		//just to try to fix some problems with 115200 baudrate
		_cell.begin(115200);
		delay(1000);
		_cell.print(F("AT+IPR="));
		_cell.print(baud_rate);    
		_cell.print("\r"); // send <CR>		
		return(0);
	}
}
Ejemplo n.º 14
0
void *
saveDbToTape(void *param)
{
    struct saveDbIf *saveDbIfPtr = (struct saveDbIf *)param;
    afs_int32 code;
    afs_int32 i;
    int wroteLabel;
    afs_uint32 taskId;
    Date expires;

    struct butm_tapeInfo tapeInfo;
    struct budb_dumpEntry dumpEntry;

    extern struct deviceSyncNode *deviceLatch;
    extern struct tapeConfig globalTapeConfig;

    afs_pthread_setname_self("Db save");
    expires = (saveDbIfPtr->archiveTime ? NEVERDATE : 0);
    taskId = saveDbIfPtr->taskId;
    dumpEntry.id = 0;

    setStatus(taskId, DRIVE_WAIT);
    EnterDeviceQueue(deviceLatch);	/* lock tape device */
    clearStatus(taskId, DRIVE_WAIT);

    printf("\n\n");
    TLog(taskId, "SaveDb\n");

    tapeInfo.structVersion = BUTM_MAJORVERSION;
    code = butm_file_Instantiate(&tapeInfo, &globalTapeConfig);
    if (code) {
        ErrorLog(0, taskId, code, tapeInfo.error,
                 "Can't initialize tape module\n");
        ERROR_EXIT(code);
    }

    /* Determine what the last database dump was */
    memset(&lastDump, 0, sizeof(lastDump));
    code = bcdb_FindLatestDump("", "", &lastDump);
    if (code) {
        if (code != BUDB_NODUMPNAME) {
            ErrorLog(0, taskId, code, 0, "Can't read backup database\n");
            ERROR_EXIT(code);
        }
        memset(&lastDump, 0, sizeof(lastDump));
    }

    code = CreateDBDump(&dumpEntry);	/* Create a dump for this tape */
    if (code) {
        ErrorLog(0, taskId, code, 0, "Can't create dump in database\n");
        ERROR_EXIT(code);
    }


    listEntryHead = NULL;

    /* Get the tape and write a new label to it */
    code =
        GetDBTape(taskId, expires, &tapeInfo, dumpEntry.id, 1, autoQuery,
                  &wroteLabel);

    /*
     * If did not write the label, remove created dump
     * Else if wrote the label, remove old dump from db so it's not saved.
     */
    if (!wroteLabel) {
        i = bcdb_deleteDump(dumpEntry.id, 0, 0, 0);
        dumpEntry.id = 0;
        if (i && (i != BUDB_NOENT))
            ErrorLog(0, taskId, i, 0, "Unable to delete DB entry %u.\n",
                     dumpEntry.id);
    } else if (listEntryHead->oldDumpId) {
        i = bcdb_deleteDump(listEntryHead->oldDumpId, 0, 0, 0);
        listEntryHead->oldDumpId = 0;
        if (i && (i != BUDB_NOENT)) {
            ErrorLog(0, taskId, i, 0, "Unable to delete old DB entry %u.\n",
                     listEntryHead->oldDumpId);
            ERROR_EXIT(i);
        }
    }
    if (code)
        ERROR_EXIT(code);

    TapeLog(1, taskId, 0, 0, "Tape accepted - now dumping database\n");

    /* we have a writable tape */
    code = writeDbDump(&tapeInfo, taskId, expires, dumpEntry.id);
    if (code)
        ERROR_EXIT(code);

    /* Now delete the entries between time 0 and archive-time */
    if (saveDbIfPtr->archiveTime)
        code = bcdb_deleteDump(0, 0, saveDbIfPtr->archiveTime, 0);

error_exit:
    unmountTape(taskId, &tapeInfo);

    /* Add this dump's tapes to the database and mark it finished */
    if (dumpEntry.id) {
        i = addTapesToDb(taskId);
        if (!code)
            code = i;

        i = bcdb_FinishDump(&dumpEntry);
        if (!code)
            code = i;
    }
    freeTapeList();

    if (code == TC_ABORTEDBYREQUEST) {
        TLog(taskId, "SaveDb: Aborted by request\n");
        clearStatus(taskId, ABORT_REQUEST);
        setStatus(taskId, ABORT_DONE);
    } else if (code) {
        TapeLog(0, taskId, code, 0, "SaveDb: Finished with errors\n");
        setStatus(taskId, TASK_ERROR);
    } else {
        TLog(taskId, "SaveDb: Finished\n");
    }
    setStatus(taskId, TASK_DONE);

    free(saveDbIfPtr);
    LeaveDeviceQueue(deviceLatch);
    return (void *)(intptr_t)(code);
}
Ejemplo n.º 15
0
void TestLinkItr::cancel()
{
    setStatus(m_oldStatus);
}
Ejemplo n.º 16
0
 void Stream::didStop(const Timer& timer, Status previousStatus)
 {
     setStatus(Stopped);
 }
Ejemplo n.º 17
0
gboolean
MediaPluginGStreamer010::processGSTEvents(GstBus     *bus,
					  GstMessage *message)
{
	if (!message) 
		return TRUE; // shield against GStreamer bug

	if (GST_MESSAGE_TYPE(message) != GST_MESSAGE_STATE_CHANGED &&
	    GST_MESSAGE_TYPE(message) != GST_MESSAGE_BUFFERING)
	{
		DEBUGMSG("Got GST message type: %s",
			LLGST_MESSAGE_TYPE_NAME (message));
	}
	else
	{
		// TODO: grok 'duration' message type
		DEBUGMSG("Got GST message type: %s",
			 LLGST_MESSAGE_TYPE_NAME (message));
	}

	switch (GST_MESSAGE_TYPE (message)) {
	case GST_MESSAGE_BUFFERING: {
		// NEEDS GST 0.10.11+
		if (llgst_message_parse_buffering)
		{
			gint percent = 0;
			llgst_message_parse_buffering(message, &percent);
			DEBUGMSG("GST buffering: %d%%", percent);
		}
		break;
	}
	case GST_MESSAGE_STATE_CHANGED: {
		GstState old_state;
		GstState new_state;
		GstState pending_state;
		llgst_message_parse_state_changed(message,
						&old_state,
						&new_state,
						&pending_state);
#ifdef LL_GST_REPORT_STATE_CHANGES
		// not generally very useful, and rather spammy.
		DEBUGMSG("state change (old,<new>,pending): %s,<%s>,%s",
			 get_gst_state_name(old_state),
			 get_gst_state_name(new_state),
			 get_gst_state_name(pending_state));
#endif // LL_GST_REPORT_STATE_CHANGES

		switch (new_state) {
		case GST_STATE_VOID_PENDING:
			break;
		case GST_STATE_NULL:
			break;
		case GST_STATE_READY:
			setStatus(STATUS_LOADED);
			break;
		case GST_STATE_PAUSED:
			setStatus(STATUS_PAUSED);
			break;
		case GST_STATE_PLAYING:
			setStatus(STATUS_PLAYING);
			break;
		}
		break;
	}
	case GST_MESSAGE_ERROR: {
		GError *err = NULL;
		gchar *debug = NULL;

		llgst_message_parse_error (message, &err, &debug);
		WARNMSG("GST error: %s", err?err->message:"(unknown)");
		if (err)
			g_error_free (err);
		g_free (debug);

		mCommand = COMMAND_STOP;

		setStatus(STATUS_ERROR);

		break;
	}
	case GST_MESSAGE_INFO: {
		if (llgst_message_parse_info)
		{
			GError *err = NULL;
			gchar *debug = NULL;
			
			llgst_message_parse_info (message, &err, &debug);
			INFOMSG("GST info: %s", err?err->message:"(unknown)");
			if (err)
				g_error_free (err);
			g_free (debug);
		}
		break;
	}
	case GST_MESSAGE_WARNING: {
		GError *err = NULL;
		gchar *debug = NULL;

		llgst_message_parse_warning (message, &err, &debug);
		WARNMSG("GST warning: %s", err?err->message:"(unknown)");
		if (err)
			g_error_free (err);
		g_free (debug);

		break;
	}
	case GST_MESSAGE_EOS:
		/* end-of-stream */
		DEBUGMSG("GST end-of-stream.");
		if (mIsLooping)
		{
			DEBUGMSG("looping media...");
			double eos_pos_sec = 0.0F;
			bool got_eos_position = getTimePos(eos_pos_sec);

			if (got_eos_position && eos_pos_sec < MIN_LOOP_SEC)
			{
				// if we know that the movie is really short, don't
				// loop it else it can easily become a time-hog
				// because of GStreamer spin-up overhead
				DEBUGMSG("really short movie (%0.3fsec) - not gonna loop this, pausing instead.", eos_pos_sec);
				// inject a COMMAND_PAUSE
				mCommand = COMMAND_PAUSE;
			}
			else
			{
#undef LLGST_LOOP_BY_SEEKING
// loop with a stop-start instead of a seek, because it actually seems rather
// faster than seeking on remote streams.
#ifdef LLGST_LOOP_BY_SEEKING
				// first, try looping by an explicit rewind
				bool seeksuccess = seek(0.0);
				if (seeksuccess)
				{
					play(1.0);
				}
				else
#endif // LLGST_LOOP_BY_SEEKING
				{  // use clumsy stop-start to loop
					DEBUGMSG("didn't loop by rewinding - stopping and starting instead...");
					stop();
					play(1.0);
				}
			}
		}
		else // not a looping media
		{
			// inject a COMMAND_STOP
			mCommand = COMMAND_STOP;
		}
		break;
	default:
		/* unhandled message */
		break;
	}

	/* we want to be notified again the next time there is a message
	 * on the bus, so return true (false means we want to stop watching
	 * for messages on the bus and our callback should not be called again)
	 */
	return TRUE;
}
Ejemplo n.º 18
0
void RS_ActionDrawArc::commandEvent(RS_CommandEvent* e) {
    QString c = e->getCommand().toLower();

    if (RS_COMMANDS->checkCommand("help", c)) {
        if (RS_DIALOGFACTORY!=NULL) {
            RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
                                             + getAvailableCommands().join(", "));
        }
        return;
    }

    if (RS_COMMANDS->checkCommand("reversed", c)) {
        e->accept();
        setReversed(!isReversed());

        if (RS_DIALOGFACTORY!=NULL) {
            RS_DIALOGFACTORY->requestOptions(this, true, true);
        }
        return;
    }

    switch (getStatus()) {

    case SetRadius: {
            bool ok;
            double r = RS_Math::eval(c, &ok);
            if (ok) {
				data->radius = r;
                setStatus(SetAngle1);
                e->accept();
            } else {
                if (RS_DIALOGFACTORY!=NULL) {
                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
                }
            }
        }
        break;

    case SetAngle1: {
            bool ok;
            double a = RS_Math::eval(c, &ok);
            if (ok) {
				data->angle1 = RS_Math::deg2rad(a);
                e->accept();
                setStatus(SetAngle2);
            } else {
                if (RS_DIALOGFACTORY!=NULL) {
                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
                }
            }
        }
        break;

    case SetAngle2: {
            if (RS_COMMANDS->checkCommand("angle", c)) {
                setStatus(SetIncAngle);
            } else if (RS_COMMANDS->checkCommand("chord length", c)) {
                setStatus(SetChordLength);
            } else {
                bool ok;
                double a = RS_Math::eval(c, &ok);
                if (ok) {
					data->angle2 = RS_Math::deg2rad(a);
                    e->accept();
                    trigger();
                } else {
                    if (RS_DIALOGFACTORY!=NULL) {
                        RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
                    }
                }
            }
        }
        break;

    case SetIncAngle: {
            bool ok;
            double a = RS_Math::eval(c, &ok);
            if (ok) {
				data->angle2 = data->angle1 + RS_Math::deg2rad(a);
                e->accept();
                trigger();
            } else {
                if (RS_DIALOGFACTORY!=NULL) {
                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
                }
            }
        }
        break;

    case SetChordLength: {
            bool ok;
            double l = RS_Math::eval(c, &ok);
            if (ok) {
				if (fabs(l/(2*data->radius))<=1.0) {
					data->angle2 = data->angle1 + asin(l/(2*data->radius)) * 2;
                    trigger();
                } else {
                    if (RS_DIALOGFACTORY!=NULL) {
                        RS_DIALOGFACTORY->commandMessage(
                            tr("Not a valid chord length"));
                    }
                }
                e->accept();
            } else {
                if (RS_DIALOGFACTORY!=NULL) {
                    RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
                }
            }
        }
        break;

    default:
        break;
    }
}
Ejemplo n.º 19
0
void *ICQSearchResult::processEvent(Event *e)
{
    if ((e->type() > EventUser) && m_id && (m_id != SEARCH_FAIL)){
        ICQPlugin *plugin = static_cast<ICQPlugin*>(m_client->protocol()->plugin());
        if (e->type() == plugin->EventSearch){
            SearchResult *result = (SearchResult*)(e->param());
            if ((result->id == m_id) && (result->client == m_client)){
                new UserTblItem(tblUser, m_client, &result->data);
                m_nFound++;
                setStatus();
            }
        }
        if (e->type() == plugin->EventSearchDone){
            SearchResult *result = (SearchResult*)(e->param());
            if ((result->id == m_id) && (result->client == m_client))
                setRequestId(0);
        }
    }
    if (e->type() == EventCommandExec){
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->menu_id == static_cast<ICQPlugin*>(m_client->protocol()->plugin())->MenuSearchResult){
            Contact *contact;
            if (cmd->id == static_cast<ICQPlugin*>(m_client->protocol()->plugin())->CmdSendMessage){
                contact = createContact(CONTACT_TEMP);
                if (!contact) return NULL;
                Message msg(MessageGeneric);
                msg.setContact(contact->id());
                Event e(EventOpenMessage, &msg);
                e.process();
            }
            if (cmd->id == CmdInfo){
                contact = createContact(CONTACT_TEMP);
                if (!contact) return NULL;
                m_client->addFullInfoRequest(atol(tblUser->currentItem()->text(0).latin1()), true);
                Command cmd;
                cmd->id = CmdInfo;
                cmd->menu_id = MenuContact;
                cmd->param   = (void*)contact->id();
                Event e(EventCommandExec, cmd);
                e.process();
            }
            return e->param();
        }
        if (cmd->menu_id == static_cast<ICQPlugin*>(m_client->protocol()->plugin())->MenuGroups){
            Contact *contact = createContact(0);
            if (!contact) return NULL;
            contact->setGroup(cmd->id - 1);
            Event eContact(EventContactChanged, contact);
            eContact.process();
            return e->param();
        }
    }
    if (e->type() == EventCheckState){
        CommandDef *cmd = (CommandDef*)(e->param());
        if ((cmd->menu_id == static_cast<ICQPlugin*>(m_client->protocol()->plugin())->MenuGroups) &&
                (cmd->id == static_cast<ICQPlugin*>(m_client->protocol()->plugin())->CmdGroups)){
            unsigned n = 1;
            ContactList::GroupIterator it;
            while (++it)
                n++;
            CommandDef *cmds = new CommandDef[n];
            memset(cmds, 0, sizeof(CommandDef) * n);
            n = 0;
            it.reset();
            Group *grp;
            while ((grp = ++it) != NULL){
                cmds[n].id		 = grp->id() + 1;
                cmds[n].text	 = "_";
                QString name = grp->getName();
                if (grp->id() == 0)
                    name = i18n("Not in list");
                cmds[n].text_wrk = strdup(name.utf8());
                n++;
            }
            cmd->param = cmds;
            cmd->flags |= COMMAND_RECURSIVE;
            return e->param();
        }
    }
    return NULL;
}
Ejemplo n.º 20
0
  void FootstepDisplay::processMessage(const jsk_footstep_msgs::FootstepArray::ConstPtr& msg)
  {
    if (!validateFloats(*msg)) {
      setStatus(rviz::StatusProperty::Error, "Topic", "message contained invalid floating point values (nans or infs)");
      return;
    }
    latest_footstep_ = msg;
    Ogre::Quaternion orientation;
    Ogre::Vector3 position;
    if(!context_->getFrameManager()->getTransform( msg->header.frame_id,
                                                    msg->header.stamp,
                                                   position, orientation)) {
      ROS_DEBUG( "Error transforming from frame '%s' to frame '%s'",
                 msg->header.frame_id.c_str(), qPrintable( fixed_frame_ ));
      return;
    }

    // check thhe length of the shapes_
    allocateCubes(msg->footsteps.size());
    allocateTexts(msg->footsteps.size());
    line_->clear();
    line_->setLineWidth(0.01);
    line_->setNumLines(1);
    line_->setMaxPointsPerLine(1024);

    for (size_t i = 0; i < msg->footsteps.size(); i++)
    {
      ShapePtr shape = shapes_[i];
      rviz::MovableText* text = texts_[i];
      Ogre::SceneNode* node = text_nodes_[i];
      jsk_footstep_msgs::Footstep footstep = msg->footsteps[i];
      Ogre::Vector3 step_position;
      Ogre::Quaternion step_quaternion;
      if( !context_->getFrameManager()->transform( msg->header, footstep.pose,
                                                   step_position,
                                                   step_quaternion ))
      {
        ROS_ERROR( "Error transforming pose '%s' from frame '%s' to frame '%s'",
                   qPrintable( getName() ), msg->header.frame_id.c_str(), qPrintable( fixed_frame_ ));
        return;
      }
      shape->setPosition(step_position);
      shape->setOrientation(step_quaternion);
      // size of shape
      Ogre::Vector3 scale;
      if (footstep.dimensions.x == 0 &&
          footstep.dimensions.y == 0 &&
          footstep.dimensions.z == 0) {
        scale[0] = depth_;
        scale[1] = width_;
        scale[2] = height_;
      }
      else {
        scale[0] = footstep.dimensions.x;
        scale[1] = footstep.dimensions.y;
        scale[2] = footstep.dimensions.z;
      }
      shape->setScale(scale);      
      // update the size of text
      if (footstep.leg == jsk_footstep_msgs::Footstep::LEFT) {
        text->setCaption("L");
      }
      else if (footstep.leg == jsk_footstep_msgs::Footstep::RIGHT) {
        text->setCaption("R");
      }
      else {
        text->setCaption("unknown");
      }
      text->setCharacterHeight(estimateTextSize(footstep));
      node->setPosition(step_position);
      node->setOrientation(step_quaternion);
      text->setVisible(show_name_); // TODO
      line_->addPoint(step_position);
      
    }
    //updateFootstepSize();
    updateAlpha();
    context_->queueRender();
  }