Example #1
0
/********************************************************************************************

>	virtual BOOL CamLaunchProcess::Execute(const wxString& cmd)

	Author:		Phil_Martin (Xara Group Ltd) <*****@*****.**>
	Created:	19/May/2006
	Inputs:		cmd - The command string including parameters
	Outputs:	-
	Returns:	TRUE if the command was launched successfully
				FALSE otherwise
	Purpose:	Execute a command which should launch a long-running process

********************************************************************************************/
BOOL CamLaunchProcess::Execute(const wxString& cmd)
{
	m_ReturnCode = 0;		// Assume success until we find otherwise

	// Make sure redirection happens
	Redirect();

	TRACEUSER("Phil", _T("Executing %s\n"), (LPCTSTR) cmd);
	m_pid = wxExecute(cmd, wxEXEC_ASYNC, this);
	if (m_pid==0)
	{
		// Couldn't even create a process for the command!
		m_bDead = true;
		return FALSE;
	}

	// We're now running
	m_bDead = false;
	m_bConnected = true;

	// Give the command 100 milliseconds to return an error condition or die...
	// After that we will either use the return code it passed back to OnTerminate
	// or assume it is running successfully...
	MonotonicTime graceperiod;
	while (!m_bDead && m_ReturnCode==0 && !graceperiod.Elapsed(100))
	{
		ProcessStdErr();		// Process any output on stderr
		wxMilliSleep(1);
		wxYield();
	}

	TRACEUSER("Phil", _T("Exiting with %d\n"), m_ReturnCode);
	return (m_ReturnCode==0);
}
Example #2
0
void TransferReceiver::updateTransferTimings()
{
    UAVCAN_ASSERT(!this_transfer_ts_.isZero());

    const MonotonicTime prev_prev_ts = prev_transfer_ts_;
    prev_transfer_ts_ = this_transfer_ts_;

    if ((!prev_prev_ts.isZero()) && (!prev_transfer_ts_.isZero()) && (prev_transfer_ts_ >= prev_prev_ts))
    {
        uint64_t interval_usec = uint64_t((prev_transfer_ts_ - prev_prev_ts).toUSec());
        interval_usec = min(interval_usec, uint64_t(MaxTransferIntervalUSec));
        interval_usec = max(interval_usec, uint64_t(MinTransferIntervalUSec));
        transfer_interval_usec_ = static_cast<uint32_t>((uint64_t(transfer_interval_usec_) * 7 + interval_usec) / 8);
    }
}
Example #3
0
int TransferSender::send(const uint8_t* payload, unsigned payload_len, MonotonicTime tx_deadline,
                         MonotonicTime blocking_deadline, TransferType transfer_type, NodeID dst_node_id) const
{
    /*
     * TODO: TID is not needed for anonymous transfers, this part of the code can be skipped?
     */
    const OutgoingTransferRegistryKey otr_key(data_type_id_, transfer_type, dst_node_id);

    UAVCAN_ASSERT(!tx_deadline.isZero());
    const MonotonicTime otr_deadline = tx_deadline + max(max_transfer_interval_ * 2,
                                                         OutgoingTransferRegistry::MinEntryLifetime);

    TransferID* const tid = dispatcher_.getOutgoingTransferRegistry().accessOrCreate(otr_key, otr_deadline);
    if (tid == UAVCAN_NULLPTR)
    {
        UAVCAN_TRACE("TransferSender", "OTR access failure, dtid=%d tt=%i",
                     int(data_type_id_.get()), int(transfer_type));
        return -ErrMemory;
    }

    const TransferID this_tid = tid->get();
    tid->increment();

    return send(payload, payload_len, tx_deadline, blocking_deadline, transfer_type,
                dst_node_id, this_tid);
}
Example #4
0
int TransferSender::send(const uint8_t* payload, int payload_len, MonotonicTime tx_deadline,
                         MonotonicTime blocking_deadline, TransferType transfer_type, NodeID dst_node_id)
{
    const OutgoingTransferRegistryKey otr_key(data_type_.getID(), transfer_type, dst_node_id);

    assert(!tx_deadline.isZero());
    const MonotonicTime otr_deadline = tx_deadline + max_transfer_interval_;

    TransferID* const tid = dispatcher_.getOutgoingTransferRegistry().accessOrCreate(otr_key, otr_deadline);
    if (tid == NULL)
    {
        UAVCAN_TRACE("TransferSender", "OTR access failure, dtd=%s tt=%i",
                     data_type_.toString().c_str(), int(transfer_type));
        return -ErrMemory;
    }

    const TransferID this_tid = tid->get();
    tid->increment();

    return send(payload, payload_len, tx_deadline, blocking_deadline, transfer_type,
                dst_node_id, this_tid);
}
Example #5
0
BOOL SGThumbs::GetThumbnail(UINT32 ID, BOOL Urgent, KernelBitmap **Result, PathName *File, LP_SGTHUMBS_MOREINFO MoreInfo)
{
	PORTNOTETRACE("dialog","SGThumbs::GetThumbnail - do nothing");
#ifndef EXCLUDE_FROM_XARALX
#ifndef EXCLUDE_GALS
	// File can be NULL, and signifies that we need to generate the thumbnail - fonts
	if(Result == NULL)
	{
		ERROR3("SGThumbs::GetThumbnail - NULL result parameters are illegal");
		return FALSE;
	}																				 
	
	*Result = NULL;

	if(!ThumbnailsInitialised) return FALSE;

	BOOL ok = TRUE;
	UINT32 Slot = 0;

	ok = OffsetInCache(ID, &Slot);

	// Not in cache and not urgent
	if(!ok && !Urgent)
		return FALSE;

	MonotonicTime TempTime;

	if(!ok) 
	{
		ok = FindNewSlotInBuffer(&Slot);
		if(!ok) return FALSE;

		if(Directory == NULL)
		{
			if(MoreInfo == NULL)
			{
				ERROR3("SGThumbs::GetThumbnail MoreInfo is NULL as is Directory. Can't generate the thumbnail");
				return FALSE;
			}

			if(Thumbnails[Slot].Valid && Thumbnails[Slot].buffer)
			{
				delete Thumbnails[Slot].buffer;
				Thumbnails[Slot].buffer=NULL;
			}

			// Just in case we jump out in a state of unhappy rampantness
			Thumbnails[Slot].Valid = FALSE;

			switch(ThumbnailsLibType)
			{
				case SGLib_Font:
					ok = ((SGDisplayPreviewFonts *)MoreInfo)->CreateThumbnail(&Thumbnails[Slot].buffer);					
					break;
					
				default:
					TRACEUSER( "Richard", _T("Cannot create thumbnails of this type"));
					return FALSE;
			}

			if(ok)
			{
				// Set the cache entries so the thing works
				Thumbnails[Slot].Valid = TRUE;
				Thumbnails[Slot].ID = ID;
				Thumbnails[Slot].Usage = 0;
				Thumbnails[Slot].Size = ThumbnailsSize;
			}
		}
		else
		{
			if(File != NULL)
			{
				ok = LoadThumbnailIntoSlot(Slot, ID, File);
				if(!ok)
				{
					TRACEUSER( "Richard", _T("PROBLEMS loading thumbnail"));
					return FALSE;
				}

// WEBSTER-Martin-09/01/97
#ifndef WEBSTER
#ifndef STANDALONE
				if(ThumbnailsLibType == SGLib_Font)
				{
					StringToBitmap::ContoneFontBitmap(Thumbnails[Slot].buffer);
				}
#endif
#endif //WEBSTER
			}
			else
			{
				ERROR3("SGThumbs::GetThumbnail - No filename given for the thumbnail");
				return FALSE;
			}
		}
	}

	// Adds the monotonic time to the cached item
	Thumbnails[Slot].Usage = TempTime.Sample();
	*Result = Thumbnails[Slot].buffer;	
#endif
#endif
	return TRUE;
}