void PeerguardianInfo::updateDaemonState() {


	QString oldPID = m_ProcessPID;
	bool oldState = m_DaemonState;

	checkProcess();
	

	if ( m_ProcessPID != oldPID ) {
		emit processPIDChange( m_ProcessPID );
	}
	if ( m_DaemonState != oldState ) {
		emit processStateChange( m_DaemonState );
		if ( m_DaemonState == true ) {
			emit pgldStarted();
		}
		else {
			emit pgldStopped();
		}
	}


}
Exemple #2
0
bool CommonPort::processEvent( Event e )
{
	bool ret;

	switch( e )
	{
	default:
		// Unhandled event
		ret = _processEvent( e );
		break;

	case POWERUP:
	case INITIALIZE:
		GPTP_LOG_DEBUG("Received POWERUP/INITIALIZE event");

		// If port has been configured as master or slave, run media
		// specific configuration. If it hasn't been configured
		// start listening for announce messages
		if( clock->getPriority1() == 255 ||
		    port_state == PTP_SLAVE )
		{
			becomeSlave( true );
		}
		else if( port_state == PTP_MASTER )
		{
			becomeMaster( true );
		}
		else
		{
			clock->addEventTimerLocked(this, ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES,
				(uint64_t) ( ANNOUNCE_RECEIPT_TIMEOUT_MULTIPLIER * pow(2.0, getAnnounceInterval()) * 1000000000.0 ));
		}

		// Do any media specific initialization
		ret = _processEvent( e );
		break;

	case STATE_CHANGE_EVENT:
		ret = _processEvent( e );

		// If this event wasn't handled in a media specific way, call
		// the default action
		if( !ret )
			ret = processStateChange( e );
		break;

	case ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES:
	case SYNC_RECEIPT_TIMEOUT_EXPIRES:
		if (e == ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES) {
			incCounter_ieee8021AsPortStatAnnounceReceiptTimeouts();
		}
		else if (e == SYNC_RECEIPT_TIMEOUT_EXPIRES) {
			incCounter_ieee8021AsPortStatRxSyncReceiptTimeouts();
		}

		ret = _processEvent( e );

		// If this event wasn't handled in a media specific way, call
		// the default action
		if( !ret )
			ret = processSyncAnnounceTimeout( e );
		break;

	case ANNOUNCE_INTERVAL_TIMEOUT_EXPIRES:
		GPTP_LOG_DEBUG("ANNOUNCE_INTERVAL_TIMEOUT_EXPIRES occured");

		// Send an announce message
		if ( asCapable)
		{
			PTPMessageAnnounce *annc =
				new PTPMessageAnnounce(this);
			PortIdentity dest_id;
			PortIdentity gmId;
			ClockIdentity clock_id = clock->getClockIdentity();
			gmId.setClockIdentity(clock_id);
			getPortIdentity( dest_id );
			annc->setPortIdentity( &dest_id );
			annc->sendPort( this, NULL );
			delete annc;
		}

		startAnnounceIntervalTimer
			((uint64_t)( pow((double)2, getAnnounceInterval()) *
				     1000000000.0 ));
		ret = true;
		break;

	case SYNC_INTERVAL_TIMEOUT_EXPIRES:
		GPTP_LOG_DEBUG("SYNC_INTERVAL_TIMEOUT_EXPIRES occured");
		// If asCapable is true attempt some media specific action
		ret = true;
		if( asCapable )
			ret = _processEvent( e );

		/* Do getDeviceTime() after transmitting sync frame
		   causing an update to local/system timestamp */
		{
			Timestamp system_time;
			Timestamp device_time;
			uint32_t local_clock, nominal_clock_rate;
			FrequencyRatio local_system_freq_offset;
			int64_t local_system_offset;

			getDeviceTime
				( system_time, device_time,
				  local_clock, nominal_clock_rate );

			GPTP_LOG_VERBOSE
				( "port::processEvent(): System time: %u,%u "
				  "Device Time: %u,%u",
				  system_time.seconds_ls,
				  system_time.nanoseconds,
				  device_time.seconds_ls,
				  device_time.nanoseconds );

			local_system_offset =
				TIMESTAMP_TO_NS(system_time) -
				TIMESTAMP_TO_NS(device_time);
			local_system_freq_offset =
				clock->calcLocalSystemClockRateDifference
				( device_time, system_time );
			clock->setMasterOffset
				( this, 0, device_time, 1.0,
				  local_system_offset, system_time,
				  local_system_freq_offset, getSyncCount(),
				  pdelay_count, port_state, asCapable );
		}

		// Call media specific action for completed sync
		syncDone();

		// Restart the timer
		startSyncIntervalTimer
			((uint64_t)( pow((double)2, getSyncInterval()) *
				     1000000000.0 ));

		break;
	}

	return ret;
}