Exemplo n.º 1
0
int CPST2ICALApp::ExtractSchemaFile(_TCHAR* tempDir)
{
	_TCHAR usage[256];
	HINSTANCE hInst = ::GetModuleHandle(NULL);
	_TCHAR current_method[] = _TEXT("CPST2ICALApp::ExtractSchemaFile");
	if (IsVerbose()){
		::LoadString(hInst, IDS_ENTER_METHOD, usage, 256);
		::_tprintf(_TEXT("%s %s\n"), usage, current_method);
	}
	int retCode = MIGRATION_STEP_SUCCESS;
	HRSRC hSchema = ::FindResourceEx(hInst, _T("Schema"), MAKEINTRESOURCE(IDR_SCHEMA), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL));
	HGLOBAL hResource;
	FILE *f;
	_TCHAR fullSchemaName[256];

	if (hSchema != NULL) {
		unsigned long schemaSize = SizeofResource(hInst, hSchema);
		// now get a handle to the resource
		if ((hResource = LoadResource(hInst, hSchema)) == NULL) {
			retCode = MIGRATION_ERR_FAILED;
			return retCode;
		}
		// finally get and return a pointer to the resource
		UCHAR* pResource = ((UCHAR*)LockResource(hResource));

		_tcscpy(fullSchemaName, tempDir);
		_tcscat(fullSchemaName, _T("\\"));
		_tcscat(fullSchemaName, DEFAULT_SCHEMA_FILE);
		f = _tfopen(fullSchemaName, _TEXT("w"));

		if (f == NULL) {
			retCode = MIGRATION_ERR_FAILED;
			return retCode;
		}

		unsigned int itemsWritten = fwrite(pResource, sizeof(UCHAR), schemaSize, f);
		if (itemsWritten < schemaSize) {
			fclose(f);
			retCode = MIGRATION_ERR_FAILED;
			return retCode;
		}

		fclose(f);
		m_xmlProc->SetSchemaName(DEFAULT_SCHEMA_PREFIX, fullSchemaName);

	}
	else {
//		_tprintf(_T("hSchema == NULL\n"));
		retCode = MIGRATION_ERR_FAILED;
		return retCode;
	}

	if (IsVerbose()){
		::LoadString(hInst, IDS_EXIT_METHOD, usage, 256);
		::_tprintf(_TEXT("%s %s\n"), usage, current_method);
	}
	return retCode;
}
void UAblSetShaderParameterTask::InternalSetShaderValue(UMaterialInstanceDynamic* DynMaterial, UAblSetParameterValue* Value, UAblSetParameterValue* PreviousValue, float BlendAlpha) const
{
	check(DynMaterial);
	check(Value);
	check(PreviousValue);

#if !(UE_BUILD_SHIPPING)
	if (IsVerbose())
	{
		PrintVerbose(FString::Printf(TEXT("Setting material parameter %s on Material %s to %s with a blend of %1.4f."), *m_ParameterName.ToString(), *DynMaterial->GetName(), *Value->ToString(), BlendAlpha));
	}
#endif

	if (UAblSetScalarParameterValue* ScalarValue = Cast<UAblSetScalarParameterValue>(Value))
	{
		UAblSetScalarParameterValue* PreviousScalarValue = CastChecked<UAblSetScalarParameterValue>(PreviousValue);
		float InterpolatedValue = FMath::Lerp(PreviousScalarValue->GetScalar(), ScalarValue->GetScalar(), BlendAlpha);
		DynMaterial->SetScalarParameterValue(m_ParameterName, InterpolatedValue);
	}
	else if (UAblSetVectorParameterValue* VectorValue = Cast<UAblSetVectorParameterValue>(Value))
	{
		UAblSetVectorParameterValue* PreviousVectorValue = CastChecked<UAblSetVectorParameterValue>(PreviousValue);
		FVector InterpolatedValue = FMath::Lerp(PreviousVectorValue->GetVector(), VectorValue->GetVector(), BlendAlpha);
		DynMaterial->SetVectorParameterValue(m_ParameterName, InterpolatedValue);
	}
	else if (UAblSetTextureParameterValue* TextureValue = Cast<UAblSetTextureParameterValue>(Value))
	{
		// No Lerping allowed.
		DynMaterial->SetTextureParameterValue(m_ParameterName, TextureValue->GetTexture());
	}
	else
	{
		checkNoEntry();
	}
}
Exemplo n.º 3
0
bool CMOOSSerialPort::GetTelegramOrAccumulate(std::string &sTelegram,double dfTimeOut,double *pTime)
{
    if(IsStreaming())
    {
        MOOSTrace("don't call GetTelegram on a streaming device!\n");
        return false;
    }
    
    static char telegramBuffer[TELEGRAM_LEN];
    static int nTelegramBufferRead = 0;              //total number of chars read
    
    double dfTimeWaited = 0.0;              //haven't waited any time yet
    double dfInterval = 0.01;             //10ms
    
    
    while ((dfTimeWaited<dfTimeOut) && nTelegramBufferRead<TELEGRAM_LEN)
    {
        int nGrabbed = 0;
        
        //try the read
        nGrabbed = GrabN(telegramBuffer+nTelegramBufferRead,1);
        
        if (nGrabbed == 0)
        {
            //OK wait a while...maybe it is on its way!
            dfTimeWaited+=dfInterval;
            
            MOOSPause((int)(dfInterval*1000.0));
        }
        else
        {
            if(nTelegramBufferRead==0 && pTime!=NULL)
            {
                //grab the time..                        
                *pTime = MOOSTime();
            }
            
            
            nTelegramBufferRead+=nGrabbed;
            
            //have we reached the end of the message?
            if(IsCompleteReply(telegramBuffer,TELEGRAM_LEN,nTelegramBufferRead))
            {
                telegramBuffer[nTelegramBufferRead]='\0';
                nTelegramBufferRead = 0;
                sTelegram = telegramBuffer;
                MOOSRemoveChars(sTelegram,"\r\n");
                
                if(IsVerbose())
                {
                    MOOSTrace("Telegram = %s\n",sTelegram.c_str());
                }
                //MOOSTrace("Required %d retries and %d accumulates\n",nRetries,nAccumulates);
                return true;
            }            
        }
    }
    
    return false;
}
Exemplo n.º 4
0
void
RPCProxy::Done(FRT_RPCRequest *req)
{
    PrintMethod(req, "RETURN");
    if (IsVerbose()) {
        req->GetReturn()->Print(8);
    }
    req->Return();
}
Exemplo n.º 5
0
int CPST2ICALApp::StartMigration(_TCHAR* exec)
{
	_TCHAR usage[256];
	HINSTANCE hInst = ::GetModuleHandle(NULL);
	_TCHAR current_method[] = _TEXT("CPST2ICALApp::StartMigration");
	if (IsVerbose()){
		::LoadString(hInst, IDS_ENTER_METHOD, usage, 256);
		::_tprintf(_TEXT("%s %s\n"), usage, current_method);
	}
	m_pstProc->SetVerbose(m_verbose);
	m_xmlProc->SetVerbose(m_verbose);
//	::_tprintf(L"GetServer2: %s\n", exec);
	int retCode = m_pstProc->Start(exec, this);
	if (IsVerbose()){
		::LoadString(hInst, IDS_EXIT_METHOD, usage, 256);
		::_tprintf(_TEXT("%s %s\n"), usage, current_method);
	}
	return retCode;
}
Exemplo n.º 6
0
bool csSCF::RegisterClass (const char *iClassID, const char *iLibraryName,
  const char *iFactoryClass, const char *iDesc, const char *Dependencies, 
  const char* context)
{
  CS::Threading::RecursiveMutexScopedLock lock (mutex);
  size_t idx;
  csStringID contextID = 
    context ? contexts.Request (context) : csInvalidStringID;

  if (IsVerbose(SCF_VERBOSE_CLASS_REGISTER))
    csPrintfErr("SCF_NOTIFY: registering class %s in context %s (from %s)\n",
      iClassID, CS::Quote::Single (GetContextName(context)), iLibraryName);

  if ((idx = ClassRegistry->FindClass(iClassID)) != (size_t)-1)
  {
    scfFactory *cf = (scfFactory *)ClassRegistry->Get (idx);
    if (ContextClash (cf->classContext, contextID))
    {
      csPrintfErr("SCF_WARNING: class %s (from %s) has already been "
        "registered in the same context %s (in %s)\n",
        iClassID, iLibraryName, CS::Quote::Single (GetContextName(context)),
	get_library_name(cf->LibraryName));
    }
    else
    {
      /*
        The user may want to override a standard CS plugin by putting
	a plugin exhibiting the same class ID into the e.g. app directory.
	In this case a warning is probably not desired. But for debugging
	purposes we emit something.
       */
    #ifdef CS_DEBUG
      // Don't report when the already registered class is static.
      if (cf->classContext != staticContextID)
      {
	// @@@ some way to have this warning in non-debug builds would be nice.
	csPrintfErr("SCF_NOTIFY: class %s (from %s) has already been "
	  "registered in a different context: %s vs. %s (from %s); this "
	  "message appears only in debug builds\n",
	  iClassID, iLibraryName,
	  CS::Quote::Single (GetContextName(context)),
	  CS::Quote::Single (GetContextName(cf->classContext)),
	  get_library_name(cf->LibraryName));
      }
    #endif
    }
    return false;
  }

  scfFactory* factory = new scfFactory (iClassID, iLibraryName, iFactoryClass,
    0, iDesc, Dependencies, contextID);
  ClassRegistry->Push (factory);
  SortClassRegistry = true;
  return true;
}
Exemplo n.º 7
0
int CMTDAdmOptions::CheckArguments(void)
{
    CActionRequest server_desc;
    server_desc.SetProtocolName("mtd");

    try {
        server_desc.SetQualifiedName(GetArgCommand());
    } catch(...) {
        if(IsVerbose()) {
            if(IsError == false) fprintf(stderr,"\n");
            fprintf(stderr,"%s: %s\n", (const char*)GetProgramName(), (const char*)ErrorSystem.GetLastError());
            IsError = true;
        }
        return(SO_OPTS_ERROR);
    }

    if(server_desc.GetAction() == NULL) {
        if(IsVerbose()) {
            if(IsError == false) fprintf(stderr,"\n");
            fprintf(stderr,"%s: no action is specified\n", (const char*)GetProgramName());
            IsError = true;
        }
        return(SO_OPTS_ERROR);
    }

    if((server_desc.GetAction() != "info") &&
            (server_desc.GetAction() != "shutdown") &&
            (server_desc.GetAction() != "errors") &&
            (server_desc.GetAction() != "get") &&
            (server_desc.GetAction() != "flush")) {
        if(IsVerbose()) {
            if(IsError == false) fprintf(stderr,"\n");
            fprintf(stderr,"%s: specified action '%s' is not supported\n", (const char*)GetProgramName(), (const char*)server_desc.GetAction());
            IsError = true;
        }
        return(SO_OPTS_ERROR);
    }

    return(SO_CONTINUE);
}
Exemplo n.º 8
0
Arquivo: scf.cpp Projeto: garinh/cs
void csSCF::RegisterClassesInt(char const* pluginPath, iDocumentNode* scfnode, 
			       const char* context)
{
  bool const seen = pluginPath != 0 && libraryNames->Contains(pluginPath);

  if (IsVerbose(SCF_VERBOSE_PLUGIN_REGISTER))
  {
    char const* s = pluginPath != 0 ? pluginPath : "{unknown}";
    char const* c = GetContextName(context);
    if (!seen)
      csPrintfErr("SCF_NOTIFY: registering plugin %s in context `%s'\n", s, c);
    else
      csPrintfErr("SCF_NOTIFY: ignoring duplicate plugin registration %s "
        "in context `%s'\n", s, c);
  }

  if (seen)
    return;			// *** RETURN: Do not re-register ***

  csRef<iDocumentNode> classesnode = scfnode->GetNode("classes");
  if (classesnode)
  {
    csRef<iDocumentNodeIterator> classiter = classesnode->GetNodes("class");
    csRef<iDocumentNode> classnode;
    while ((classnode = classiter->Next()))
    {
      csString classname = get_node_value(classnode, "name");
      csString imp = get_node_value(classnode, "implementation");
      csString desc = get_node_value(classnode, "description");

      // For backward compatibility, we build a comma-delimited dependency
      // string from the individual dependency nodes.  In the future,
      // iSCF::GetClassDependencies() should be updated to return an
      // iStringArray, rather than a simple comma-delimited string.
      csString depend;
      csRef<iDocumentNode> depnode = classnode->GetNode("requires");
      if (depnode)
      {
	csRef<iDocumentNodeIterator> depiter = depnode->GetNodes("class");
	csRef<iDocumentNode> depclassnode;
	while ((depclassnode = depiter->Next()))
	{
	  if (!depend.IsEmpty()) depend << ", ";
	  depend << depclassnode->GetContentsValue();
	}
      }

      char const* pdepend = (depend.IsEmpty() ? 0 : depend.GetData());
      RegisterClass(classname, pluginPath, imp, desc, pdepend, context);
    }
  }
}
Exemplo n.º 9
0
Arquivo: scf.cpp Projeto: garinh/cs
bool csSCF::RegisterPlugin (const char* path)
{
  csRef<iDocument> metadata;
  csRef<iString> msg;
  if (IsVerbose(SCF_VERBOSE_PLUGIN_REGISTER))
    csPrintfErr("SCF_NOTIFY: registering plugin %s (no context)\n", path);

  if ((msg = csGetPluginMetadata (path, metadata)) != 0)
  {
    csPrintfErr("SCF_ERROR: couldn't retrieve metadata for '%s': %s\n", 
      path, msg->GetData ());
    return false;
  }

  RegisterClasses (path, metadata);
  return true;
}
Exemplo n.º 10
0
void clAudioSubsystem_OpenAL::Start()
{
	m_AudioThread = std::make_shared<std::thread>(
		[this]()
		{
			m_Device = alcOpenDevice( nullptr );
			m_Context = alcCreateContext( m_Device, nullptr );
			alcMakeContextCurrent( m_Context );

			if ( IsVerbose() ) DebugPrintVersion();

			m_IsInitialized = true;

			while ( !m_IsPendingExit )
			{
				std::this_thread::sleep_for(std::chrono::milliseconds(10));

				{
					auto sources = this->GetLockedSources();

					for (auto i : sources)
					{
						i->UpdateBuffers();
					}
				}
			}

			// A dirty workaround for a possible bug in OpenAL Soft
			// http://openal.org/pipermail/openal/2015-January/000312.html
#if !defined(_WIN32)
			alcDestroyContext( m_Context );
			alcCloseDevice( m_Device );
#endif

			m_IsInitialized = false;

		}
	);

	// wait
	while ( !m_IsInitialized );
}
Exemplo n.º 11
0
void
RPCProxy::HOOK_Mismatch(FRT_RPCRequest *req)
{
    PrintMethod(req, "INVOKE");
    if (IsVerbose()) {
        req->GetParams()->Print(8);
    }
    req->Detach();
    req->SetError(FRTE_NO_ERROR, "");
    if (req->GetConnection()->IsServer() && GetSession(req)->server != nullptr)
    {
        GetSession(req)->server->InvokeAsync(req, 60.0, &req->getStash().create<ReqDone>(*this));
    } else if (req->GetConnection()->IsClient() && GetSession(req)->client != nullptr)
    {
        FRT_Supervisor::InvokeAsync(GetSession(req)->client->Owner(), GetSession(req)->client,
                                    req, 60.0, &req->getStash().create<ReqDone>(*this));
    } else {
        req->SetError(FRTE_RPC_CONNECTION);
        req->Return();
    }
}
void UAblSetCollisionChannelResponseTask::OnTaskEnd(const TWeakObjectPtr<const UAblAbilityContext>& Context, const EAblAbilityTaskResult result) const
{
	Super::OnTaskEnd(Context, result);

	if (m_RestoreOnEnd)
	{
		UAblSetCollisionChannelResponseTaskScratchPad* ScratchPad = Cast<UAblSetCollisionChannelResponseTaskScratchPad>(Context->GetScratchPadForTask(this));
		check(ScratchPad);

		for (const FCollisionLayerResponseEntry& Entry : ScratchPad->PreviousCollisionValues)
		{
			if (Entry.Primitive.IsValid())
			{
#if !(UE_BUILD_SHIPPING)
				if (IsVerbose())
				{
					PrintVerbose(FString::Printf(TEXT("Setting Collision Channel %s Response on Actor %s to %s."), *FAbleLogHelper::GetCollisionChannelEnumAsString(Entry.Channel), *Entry.Primitive->GetOwner()->GetName(), *FAbleLogHelper::GetCollisionResponseEnumAsString(Entry.Response)));
				}
#endif
				Entry.Primitive->SetCollisionResponseToChannel(Entry.Channel, Entry.Response);
			}
		}
	}
}
Exemplo n.º 13
0
Arquivo: scf.cpp Projeto: garinh/cs
void csSCF::ScanPluginsInt (csPathsList const* pluginPaths,
                            const char* context)
{
  if (pluginPaths)
  {
    // Search plugins in pluginpaths
    csRef<iStringArray> plugins;

    size_t i, j;
    for (i = 0; i < pluginPaths->Length(); i++)
    {
      csPathsList::Entry const& pathrec = (*pluginPaths)[i];
      if (IsVerbose(SCF_VERBOSE_PLUGIN_SCAN))
      {
        char const* x = scannedDirs.Contains(pathrec.path) ? "re-" : "";
        csPrintfErr("SCF_NOTIFY: %sscanning plugin directory: %s "
          "(context `%s'; recursive %s)\n", x, pathrec.path.GetData(),
          GetContextName(pathrec.type),
          pathrec.scanRecursive ? "yes" : "no");
      }

      if (plugins)
        plugins->Empty();

      csRef<iStringArray> messages =
        csScanPluginDir (pathrec.path, plugins, pathrec.scanRecursive);
      scannedDirs.Request(pathrec.path);

      if ((messages != 0) && (messages->GetSize () > 0))
      {
        csPrintfErr("SCF_WARNING: the following issue(s) arose while "
          "scanning '%s':", pathrec.path.GetData());
        for (j = 0; j < messages->GetSize (); j++)
          csPrintfErr(" %s\n", messages->Get (j));
      }

      csRef<iDocument> metadata;
      csRef<iString> msg;
      for (j = 0; j < plugins->GetSize (); j++)
      {
        char const* plugin = plugins->Get(j);
        msg = csGetPluginMetadata (plugin, metadata);
        if (msg != 0)
        {
          csPrintfErr("SCF_ERROR: metadata retrieval error for %s: %s\n",
            plugin, msg->GetData ());
        }
        // It is possible for an error or warning message to be generated even
        // when metadata is also obtained.  Likewise, it is possible for no
        // metadata to be obtained yet also to have no error message.  The
        // latter case is indicative of csScanPluginDir() returning "potential"
        // plugins which turn out to not be Crystal Space plugins after all.
        // For instance, on Windows, the scan might find a DLL which is not a
        // Crystal Space DLL; that is, which does not contain embedded
        // metadata.  This is a valid case, which we simply ignore since it is
        // legal for non-CS libraries to exist alongside CS plugins in the
        // scanned directories.
        if (metadata)
          RegisterClasses(plugin, metadata, 
          context ? context : pathrec.type.GetData());
      }
    }
  }
}
void UAblRayCastQueryTask::OnTaskStart(const TWeakObjectPtr<const UAblAbilityContext>& Context) const
{
	Super::OnTaskStart(Context);

	AActor* SourceActor = m_QueryLocation.GetSourceActor(*Context.Get());
	check(SourceActor);

	UWorld* World = SourceActor->GetWorld();

	FTransform QueryTransform;
	m_QueryLocation.GetTransform(*Context.Get(), QueryTransform);

	const FVector RayStart = QueryTransform.GetLocation();
	const FVector RayEnd = RayStart + QueryTransform.GetRotation().GetForwardVector() * m_Length;

	if (m_UseAsyncQuery && UAbleSettings::IsAsyncEnabled())
	{
		UAblRayCastQueryTaskScratchPad* ScratchPad = Cast<UAblRayCastQueryTaskScratchPad>(Context->GetScratchPadForTask(this));
		check(ScratchPad);
		if (m_OnlyReturnBlockingHit)
		{
			ScratchPad->AsyncHandle = World->AsyncLineTraceByChannel(EAsyncTraceType::Single, RayStart, RayEnd, m_CollisionChannel);
		}
		else
		{
			ScratchPad->AsyncHandle = World->AsyncLineTraceByChannel(EAsyncTraceType::Multi, RayStart, RayEnd, m_CollisionChannel);
		}
	}
	else
	{
		TArray<FHitResult> HitResults;
		FHitResult TraceResult;
		if (m_OnlyReturnBlockingHit)
		{
			if (World->LineTraceSingleByChannel(TraceResult, RayStart, RayEnd, m_CollisionChannel))
			{
				HitResults.Add(TraceResult);
			}
		}
		else
		{
			World->LineTraceMultiByChannel(HitResults, RayStart, RayEnd, m_CollisionChannel);		
		}

#if !(UE_BUILD_SHIPPING)
		if (IsVerbose())
		{
			PrintVerbose(FString::Printf(TEXT("Raycast found %d results."), HitResults.Num()));
		}
#endif

		if (HitResults.Num())
		{
#if !(UE_BUILD_SHIPPING)
			if (IsVerbose())
			{
				// Quick distance print help to see if we hit ourselves.
				float DistanceToBlocker = HitResults[HitResults.Num() - 1].Distance;
				PrintVerbose(FString::Printf(TEXT("Raycast blocking hit distance: %4.2f."), DistanceToBlocker));
			}
#endif

			if (m_CopyResultsToContext)
			{
#if !(UE_BUILD_SHIPPING)
				if (IsVerbose())
				{
					PrintVerbose(FString::Printf(TEXT("Copying %d results into Context."), HitResults.Num()));
				}
#endif
				CopyResultsToContext(HitResults, Context);
			}

			if (m_FireEvent)
			{
#if !(UE_BUILD_SHIPPING)
				if (IsVerbose())
				{
					PrintVerbose(FString::Printf(TEXT("Firing Raycast Event %s with %d results."), *m_Name.ToString(), HitResults.Num()));
				}
#endif
				Context->GetAbility()->OnRaycastEvent(Context.Get(), m_Name, HitResults);
			}
		}
	}

#if !UE_BUILD_SHIPPING
	if (FAblAbilityDebug::ShouldDrawQueries())
	{
		FAblAbilityDebug::DrawRaycastQuery(World, QueryTransform, m_Length);
	}
#endif
}
void UAblSetCollisionChannelResponseTask::OnTaskStart(const TWeakObjectPtr<const UAblAbilityContext>& Context) const
{
	Super::OnTaskStart(Context);

	UAblSetCollisionChannelResponseTaskScratchPad* ScratchPad = nullptr;
	
	if (m_RestoreOnEnd)
	{
		ScratchPad = Cast<UAblSetCollisionChannelResponseTaskScratchPad>(Context->GetScratchPadForTask(this));
		check(ScratchPad);
	}

	// We need to convert our Actors to primitive components.
	TArray<TWeakObjectPtr<AActor>> TargetArray;
	GetActorsForTask(Context, TargetArray);

	TArray<TWeakObjectPtr<UPrimitiveComponent>> PrimitiveComponents;

	for (TWeakObjectPtr<AActor>& Target : TargetArray)
	{
		if (UPrimitiveComponent* PrimitiveComponent = Cast<UPrimitiveComponent>(Target->GetRootComponent()))
		{
			PrimitiveComponents.AddUnique(PrimitiveComponent);
		}
	}

	for (TWeakObjectPtr<UPrimitiveComponent>& Component : PrimitiveComponents)
	{
		if (Component.IsValid())
		{
			if (m_RestoreOnEnd)
			{
				if (m_SetAllChannelsToResponse)
				{
					const FCollisionResponseContainer& Container = Component->GetCollisionResponseToChannels();
					for (ECollisionChannel Channel : TEnumRange<ECollisionChannel>())
					{
						ScratchPad->PreviousCollisionValues.Add(FCollisionLayerResponseEntry(Component.Get(), Channel, Container.GetResponse(Channel)));
					}
				}
				else
				{
					ScratchPad->PreviousCollisionValues.Add(FCollisionLayerResponseEntry(Component.Get(), m_Channel.GetValue(), Component->GetCollisionResponseToChannel(m_Channel)));
				}
			}

			if (m_SetAllChannelsToResponse)
			{
#if !(UE_BUILD_SHIPPING)
				if (IsVerbose())
				{
					PrintVerbose(FString::Printf(TEXT("Setting All Collision Responses on Actor %s to %s."), *Component->GetOwner()->GetName(), *FAbleLogHelper::GetCollisionResponseEnumAsString(m_Response.GetValue())));
				}
#endif
				Component->SetCollisionResponseToAllChannels(m_Response.GetValue());
			}
			else
			{
#if !(UE_BUILD_SHIPPING)
				if (IsVerbose())
				{
					PrintVerbose(FString::Printf(TEXT("Setting Collision Channel %s Response on Actor %s to %s."), *FAbleLogHelper::GetCollisionChannelEnumAsString(m_Channel.GetValue()), *Component->GetOwner()->GetName(), *FAbleLogHelper::GetCollisionResponseEnumAsString(m_Response.GetValue())));
				}
#endif
				Component->SetCollisionResponseToChannel(m_Channel.GetValue(), m_Response.GetValue());
			}
		}
	}
}
Exemplo n.º 16
0
bool CMOOSSerialPort::CommsLoop()
{
    
    
    char    pTmp[DEFAULT_COMMS_SPACE];
    char    pAccumulator[2*DEFAULT_COMMS_SPACE];
    int        nInStore = 0;
    
    double dfTimeOut = 0.1;
    
    while(!m_bQuit)
    {
        int nRead = ReadNWithTimeOut(pTmp,DEFAULT_COMMS_SPACE,dfTimeOut);
        
        if(nRead!=-1)
        {
            
            if((nInStore+nRead)>int(sizeof(pAccumulator)))
            {
                //oops...
                MOOSTrace("Comms Loop Accumulator Overflow, reseting\n");
                nInStore = 0;
                continue;
            }
            
            //append to the accumulator
            memcpy(pAccumulator+nInStore,pTmp,nRead);
            
            //we have more in the cupboard!
            nInStore+=nRead;
            
            //lock
            m_InBoxLock.Lock();
            
            char * pTelegramEnd = NULL;
            
            do    
            {
               
               
                //A device will by default use the termination character <CR>
                //But we now allow for setting of a termination character
                //to allow for flexibility in a reply.
                pTelegramEnd = (char*)memchr(pAccumulator,GetTermCharacter(),nInStore);
                
                if(pTelegramEnd!=NULL)
                {
                    //how long is the telegram?
                    int nTelegramLength = pTelegramEnd - pAccumulator + 1;
                    
                    //make a buffer that is one larger to preserve the last character
                    //in case we are interested in it.  
                    char bBiggerBuff[2*DEFAULT_COMMS_SPACE+1];
                    
                    
                    //copy the telegram to a buffer size that is 1 larger
                    memcpy(bBiggerBuff, pAccumulator, nTelegramLength);
                    
                    //terminate it as a string
                    //*pTelegramEnd = '\0';
                    bBiggerBuff[nTelegramLength] = '\0';
                    
                    
                    //copy it
                    //std::string sTelegram((char*)pAccumulator);
                    std::string sTelegram((char*)bBiggerBuff);
                    
                    MOOSRemoveChars(sTelegram,"\r\n");
                    
                    if(IsVerbose())
                    {
                        MOOSTrace("Telegram = %s\n",sTelegram.c_str());
                    }
                    
                    //shuffle accumulator
                    memmove(pAccumulator,
                        pAccumulator+nTelegramLength,
                        sizeof(pAccumulator)-nTelegramLength);
                    
                    //we have less in our store now!
                    nInStore-=nTelegramLength;
                    
                    //make a telegram
                    CMOOSSerialTelegram Tg(sTelegram,MOOSTime());
                    
                    //stuff it
                    m_InBox.push_front(Tg);        
                }
            }while(pTelegramEnd !=NULL);
            
            
            //whatch we don't exhibit disgraceful behaviour!
            while(m_InBox.size()>MOOS_SERIAL_INBOX_MAX_SIZE)
            {
                m_InBox.pop_back();
            }
            
            //and unlock
            
            m_InBoxLock.UnLock();
            
        }
        else
        {
        }
        
    }
    return true;
}
Exemplo n.º 17
0
ImageData IRLSMapSolver::Solve(const ImageData& initial_estimate) {
  const int num_pixels = GetNumPixels();
  const int num_channels = GetNumChannels();
  const cv::Size image_size = GetImageSize();
  CHECK_EQ(initial_estimate.GetNumPixels(), num_pixels);
  CHECK_EQ(initial_estimate.GetNumChannels(), num_channels);
  CHECK_EQ(initial_estimate.GetImageSize(), image_size);

  // If the split_channels option is set, loop over the channels here and solve
  // them independently. Otherwise, solve all channels at once.
  const int num_channels_per_split =
      solver_options_.split_channels ? 1 : num_channels;
  const int num_solver_rounds = num_channels / num_channels_per_split;
  const int num_data_points = num_channels_per_split * num_pixels;
  if (num_channels_per_split != num_channels) {
    LOG(INFO) << "Splitting up image into " << num_solver_rounds
              << " sections with " << num_channels_per_split
              << " channel(s) in each section.";
  }

  // Scale the option stop criteria parameters based on the number of
  // parameters and strength of the regularizers.
  IRLSMapSolverOptions solver_options_scaled = solver_options_;
  solver_options_scaled.AdjustThresholdsAdaptively(
      num_data_points, GetRegularizationParameterSum());

  if (IsVerbose()) {
    solver_options_scaled.PrintSolverOptions();
  }

  ImageData estimated_image;
  for (int i = 0; i < num_solver_rounds; ++i) {
    if (num_solver_rounds > 1) {
      LOG(INFO) << "Starting solver on image subset #" << (i + 1) << ".";
    }
    const int channel_start = i * num_channels_per_split;
    const int channel_end = channel_start + num_channels_per_split;

    // Copy the initial estimate data (within the appropriate channel range) to
    // the solver's array.
    alglib::real_1d_array solver_data;
    solver_data.setlength(num_data_points);
    for (int channel = 0; channel < num_channels_per_split; ++channel) {
      double* data_ptr = solver_data.getcontent() + (num_pixels * channel);
      const double* channel_ptr = initial_estimate.GetChannelData(
          channel_start + channel);
      std::copy(channel_ptr, channel_ptr + num_pixels, data_ptr);
    }

    // Set up the base objective function (just data term). The regularization
    // term depends on the IRLS weights, so it gets added in the IRLS loop.
    ObjectiveFunction objective_function_data_term_only(num_data_points);
    std::shared_ptr<ObjectiveTerm> data_term(new ObjectiveDataTerm(
        image_model_, observations_, channel_start, channel_end, image_size));
    objective_function_data_term_only.AddTerm(data_term);

    RunIRLSLoop(
        solver_options_scaled,
        objective_function_data_term_only,
        regularizers_,
        image_size,
        channel_start,
        channel_end,
        &solver_data);

    for (int channel = 0; channel < num_channels_per_split; ++channel) {
      const double* data_ptr =
          solver_data.getcontent() + (num_pixels * channel);
      estimated_image.AddChannel(data_ptr, image_size);
    }
  }

  return estimated_image;
}
int main( int argc, char **argv )
{
 APIRET      rc;
 COMMAND     cmd = {0,0};
 int         n;
 char       *cp;
 char        rc_string[12];
 CONNECTION  Connection;

 EXCEPTIONREGISTRATIONRECORD  reg_rec;

 ESP_QUE_ELEMENT Qelement;


 if( argc == 1 )
  SayMsg(HELP_INVOCATION_ESP);

 /****************************************************************************/
 /*                                                                          */
 /* Parse the invocation options.                                            */
 /*                                                                          */
 /* - If this is a child debugger, then these additional parameters will     */
 /*   precede the invocation parameters inherited from the parent.           */
 /*                                                                          */
 /*   - /child=xxxxx  where child  = child debugger and                      */
 /*                         xxxxx  = child pid (for serial connections only.)*/
 /*                                                                          */
 /*   - /handle=xxxxx where handle = switch for com handle( serial only )    */
 /*                         xxxxx  = parent's com handle - inherited by      */
 /*                                  the child.                              */
 /*                                                                          */
 /****************************************************************************/
 memset( &EspParms,   0, sizeof( ESP_PARMS ) );
 memset( &Connection, 0, sizeof(Connection) );
 if( strstr( argv[1], "/child" ) )
 {
  ParseEspChildOptions( argc, argv, &EspParms, &Connection );
 }
 else
 {
  ParseOptions( argc, argv, &EspParms, &Connection );
 }

 printf("\nESP Version 5.00 \n");fflush(0);

 /****************************************************************************/
 /* - Send connection info to the router.                                    */
 /****************************************************************************/
 SendConnectionToRouter( &Connection );

 /****************************************************************************/
 /* - Make the connection.                                                   */
 /****************************************************************************/
 {
  int RcMoreInfo = 0;

  rc = ConnectInit( &RcMoreInfo );

  if( rc != 0 )
  {
   char  BadConnectMsg[32] = "";
   int   MsgId;

   if( (Connection.ConnectType == _NETBIOS) && (RcMoreInfo != 0) )
   {
    /*************************************************************************/
    /* - handle netbios specific connect errors.                             */
    /*************************************************************************/
    n     = 1;
    MsgId = ERR_NB_INADEQUATE_RESOURCES;

    switch( RcMoreInfo )
    {
     case CANT_LOAD_NETB_DLL:
      n     = 0;
      MsgId = ERR_NB_CANT_LOAD_DLL;
      break;

     case INADEQUATE_SESSIONS:
      strcpy( BadConnectMsg,"sessions");
      break;

     case INADEQUATE_COMMANDS:
      strcpy( BadConnectMsg,"commands");
      break;

     case INADEQUATE_NAMES:
      strcpy( BadConnectMsg,"names");
      break;

     default:
      n = 1;
      MsgId = ERR_BAD_CONNECT;
      sprintf( BadConnectMsg, "NetBios error rc=%d", rc );
      break;
    }
   }
   else if( (Connection.ConnectType == SOCKET) && (RcMoreInfo != 0) )
   {
    /*************************************************************************/
    /* - handle tcpip specific connect errors.                               */
    /*************************************************************************/
    switch( RcMoreInfo )
    {
     case CANT_LOAD_TCPIP_DLL:
      n     = 1;
      MsgId = ERR_TCPIP_CANT_LOAD_DLL;

      sprintf( BadConnectMsg, "%d", rc );
      break;

     case TCPIP_NOT_RUNNING:
      n     = 0;
      MsgId = ERR_TCPIP_NOT_RUNNING;
      break;

     case TCPIP_ERROR:
      n     = 0;
      MsgId = ERR_TCPIP_ERROR;
      break;

     case TCPIP_NO_SERVICES_PORT:
      n     = 0;
      MsgId = ERR_TCPIP_NO_SERVICES_PORT;
      break;

     default:
      n = 1;
      MsgId = ERR_BAD_CONNECT;
      sprintf( BadConnectMsg, "tcpip error rc=%d", rc );
      break;
    }
   }
   else
   {
    /*************************************************************************/
    /* - handle generic connect errors.                                      */
    /*************************************************************************/
    n = 1;
    MsgId = ERR_BAD_CONNECT;
    sprintf( BadConnectMsg, "rc=%d", rc );
   }
   ErrorPrintf( MsgId, n, BadConnectMsg );
  }
 }

 /****************************************************************************/
 /* - register an exception handler for the probe.                           */
 /****************************************************************************/
 reg_rec.ExceptionHandler = Handler;
 DosSetExceptionHandler(&reg_rec);

 /****************************************************************************/
 /* - Add a connect sema4 for serial connections and wait to be posted.      */
 /****************************************************************************/
 if( (SerialParallel() == SERIAL) && ( IsParent() == FALSE ) )
 {
  USHORT   EspPid;
  TIB     *pTib;
  PIB     *pPib;
  ALLPIDS *p;

  SetComHandle( EspParms.handle );

  DosGetInfoBlocks(&pTib,&pPib);
  EspPid = (USHORT)pPib->pib_ulpid;
  CreateConnectSema4( EspPid, _ESP );
  SerialConnect( JUST_WAIT, 0, _ESP, SendMsgToEspQue );
  p = GetEspPid( EspPid );
  p->Connect = CONNECTED;
 }

 /****************************************************************************/
 /* - Each child debugger will have a termination que so we can kill the     */
 /*   child debuggers on quit/restart.                                       */
 /****************************************************************************/
 if( IsParent() == FALSE )
 {
  rc = StartEspTermQue( );
  if( rc != 0 )
  {
   sprintf(rc_string, "%d",rc);
   ErrorPrintf( ERR_CANT_START_QUE, TRUE, 1, rc_string );
  }
 }
 /****************************************************************************/
 /* - Now, start the command processing loop.                                */
 /****************************************************************************/
 for(;;)
 {
  memset(&cmd,0,sizeof(cmd) );
  RmtRecv(DEFAULT_HANDLE, (char*)&cmd, sizeof(cmd));
  if( IsVerbose() ) PrintCmdMessage( cmd.api ) ;
  switch( cmd.api )
  {
   case FINDEXE:
    RxFindExe(cmd);
    break;

   case STARTUSER:
    RxStartUser( cmd );
    break;

   case GOINIT:
    RxGoInit(cmd);
    break;

   case GOENTRY:
    RxGoEntry(cmd);
    break;

   case DEFBRK:
    RxDefBrk(cmd);
    break;

   case UNDBRK:
    RxUndBrk(cmd);
    break;

   case PUTINBRK:
    RxPutInBrk(cmd);
    break;

   case PULLOUTBRK:
    RxPullOutBrk(cmd);
    break;

   case INSERTALLBRK:
    RxInsertAllBrk();
    break;

   case REMOVEALLBRK:
    RxRemoveAllBrk();
    break;

   case SELECT_SESSION:
    /*************************************************************************/
    /* - Only the parent probe can select one of the debuggee sessions, so   */
    /*   we send a message and tell him to do it.                            */
    /*************************************************************************/
    Qelement.ChildPid = GetEspProcessID();
    SendMsgToEspQue( ESP_QMSG_SELECT_SESSION, &Qelement, sizeof(Qelement) );

    memset(&cmd,0,sizeof(cmd) );

    cmd.api = SELECT_SESSION;
    RmtSend( DEFAULT_HANDLE, &cmd, sizeof(cmd) );
    break;

   case GOSTEP:
    RxGoStep(cmd);
    break;

   case GOFAST:
    RxGoFast(cmd);
    break;

   case DOSDEBUG:
    RxDosDebug( cmd );
    break;

   case GETTHREADINFO:
    RxGetThreadInfo( cmd );
    break;

   case FREEZETHREAD:
    RxFreezeThread( cmd );
    break;

   case THAWTHREAD:
    RxThawThread( cmd );
    break;

   case GETCALLSTACK:
    RxGetCallStack(cmd);
    break;

   case GETEXEORDLLENTRY:
    RxGetExeOrDllEntryOrExitPt(cmd);
    break;

   case NORMALQUIT:
    RxNormalQuit(cmd);

    /*************************************************************************/
    /* - The que has to be up until after the normal quit because the        */
    /*   system will need to post an end session message to the queue.       */
    /*************************************************************************/
    if( IsParent() )
    {
     if( SingleMultiple() == MULTIPLE )
     {
      ALLPIDS *p;
      /***********************************************************************/
      /* - Send a message to all of the child probes telling them that       */
      /*   they are going to be killed.                                      */
      /***********************************************************************/
      for( p = GetAllpids(); p ; p = p->next )
      {
       if( (p->PidFlags.IsDebug) == TRUE && (p->pid != GetEspProcessID()) )
       {
        ESP_QUE_ELEMENT Qelement;

        Qelement.ChildPid = p->EspPid;

        SendMsgToEspTermQue(ESP_PROBE_TERM, &Qelement, sizeof(Qelement) );
       }
      }
      /***********************************************************************/
      /* - send a message to the que to kill all the child probes and        */
      /*   then wait until they are all dead.                                */
      /***********************************************************************/
      ResetAllProbesAreDeadFlag( );
      SendMsgToEspQue(ESP_QMSG_PARENT_TERM,NULL,0);
      while( AllProbesAreDead() == FALSE ){ DosSleep(100) ;}
     }
     SendMsgToEspQue(ESP_QMSG_QUE_TERM,NULL,0);
    }

    CloseConnectSema4();

    cmd.api  = NORMALQUIT;
    cmd.len  = sizeof(rc);

    /*************************************************************************/
    /* - Now, tell dbg that we're finished normal quitting.                  */
    /*************************************************************************/
    RmtSend(DEFAULT_HANDLE, &cmd , sizeof(cmd) );
    RmtSend(DEFAULT_HANDLE, &rc, cmd.len );
    break;

   case SETEXECADDR:
    RxSetExecAddr(cmd);
    break;

   case DEFWPS:
    RxDefWps(cmd);
    break;

   case PUTINWPS:
    RxPutInWps(cmd);
    break;

   case PULLOUTWPS:
    RxPullOutWps(cmd);
    break;

   case GETDATABYTES:
    RxGetDataBytes(cmd);
    break;

   case GETMEMBLKS:
    RxGetMemBlocks(cmd);
    break;

   case SETXCPTNOTIFY:
    RxSetExceptions(cmd);
    break;

   case SETEXECTHREAD:
    RxSetExecThread(cmd);
    break;

   case WRITEREGS:
    RxWriteRegs(cmd);
    break;

   case GETCOREGS:
    RxGetCoRegs(cmd);
    break;

   case SETESPRUNOPTS:
    RxSetEspRunOpts(cmd);
    break;

   case TERMINATEESP:
    if( IsParent() == FALSE )
    {
     memset( &Qelement, 0, sizeof(Qelement) );
     Qelement.ChildPid = GetEspProcessID();

     SendMsgToEspQue( ESP_QMSG_CHILD_TERM, &Qelement, sizeof(Qelement) );
    }
    DosUnsetExceptionHandler(&reg_rec);
    RmtSend(DEFAULT_HANDLE, &cmd , sizeof(cmd) );
    ConnectClose( DEFAULT_HANDLE );
    exit(0);
    break;

   case START_QUE_LISTEN:
    SendMsgToEspQue(ESP_QMSG_OPEN_CONNECT,NULL,0);
    break;

   case START_ESP_QUE:
    RxStartEspQue(cmd);
    break;

   case CONNECT_ESP:
    /*************************************************************************/
    /* - Serial connection only.                                             */
    /*************************************************************************/
    {
     USHORT   GoToPid;
     USHORT   YieldPid;
     ALLPIDS *pYield;
     ALLPIDS *pGoTo;
     BOOL     TorF;

     /************************************************************************/
     /* - Receive the pid to be connected and mark it connected.             */
     /* - If this pid has not yet been assigned to a probe, then pGoTo       */
     /*   will be NULL.                                                      */
     /* - There MUST be a probe with a pid==0, so we release that probe.     */
     /*   ( The pid will be stuffed into the structure at goinit() time.)    */
     /* - Post the connect sema4 for the goto pid.                           */
     /************************************************************************/
     RmtRecv( DEFAULT_HANDLE, &GoToPid, cmd.len );
     pGoTo          = GetPid( GoToPid );

     if( pGoTo == NULL )
      pGoTo = GetPid(0);

     pGoTo->Connect = CONNECTED;


     TorF = TRUE;
     if( GoToPid == GetEspProcessID() )
      TorF = FALSE;

     /************************************************************************/
     /* - Send back verification that the connection has been made.          */
     /************************************************************************/
     memset(&cmd,0,sizeof(cmd) );

     cmd.api = SERIAL_POLL;
     RmtSend( DEFAULT_HANDLE, &cmd, sizeof(cmd) );

     PostConnectSema4( &pGoTo->ConnectSema4, TorF );

     /************************************************************************/
     /* - Disconnect/block this probe.                                       */
     /************************************************************************/
     YieldPid        = (USHORT)GetEspProcessID();
     pYield          = GetPid( YieldPid );
     pYield->Connect = DISCONNECTED;

     SerialConnect( SET_WAIT, YieldPid, _ESP, SendMsgToEspQue );
    }
    break;

   case CTRL_BREAK:
    {
     USHORT          ThisPid;
     USHORT          CtrlBreakPid;

     RmtRecv( DEFAULT_HANDLE, &CtrlBreakPid, cmd.len );

     ThisPid = (USHORT)GetEspProcessID();

     Qelement.ChildPid = CtrlBreakPid;
     Qelement.ChildSid = ThisPid;

     SendMsgToEspQue(ESP_QMSG_CTRL_BREAK, &Qelement, sizeof(Qelement));

     SerialConnect( SET_WAIT, ThisPid,  _ESP, SendMsgToEspQue );
    }
    break;

   case SERIAL_POLL:
    ReportMessage();
    break;

   default:
    cp = (char*)&cmd;
    for( n=1; n<=sizeof(cmd); n++,cp++)
     printf("%c",*cp);
    AsyncFlushModem();
    break;
  }
 }
}