Example #1
0
void DebugCoreDumpDlg::OnButtonDebug(wxCommandEvent& event)
{
    wxUnusedVar(event);

    // save values
    const size_t MAX_NO_ITEMS = 10;
    DebugCoreDumpInfo info;
    info.SetCoreFilepaths(ReturnWithStringPrepended(m_Core->GetStrings(), GetCore(), MAX_NO_ITEMS));
    info.SetExeFilepaths(ReturnWithStringPrepended(m_ExeFilepath->GetStrings(), GetExe(), MAX_NO_ITEMS));
    info.SetWDs(ReturnWithStringPrepended(m_WD->GetStrings(), GetWorkingDirectory(), MAX_NO_ITEMS));
    info.SetSelectedDbg(m_choiceDebuggers->GetSelection());

    EditorConfigST::Get()->WriteObject(wxT("DebugCoreDumpDlg"), &info);

    EndModal(wxID_OK);
}
Example #2
0
bool SimSpark::InitApp(int argc, char** argv)
{
    //Add resources for current simulation
    for (int i = 0; i < (int)mResourceLocations.size(); i++)
    {
        GetCore()->GetFileServer()->AddResourceLocation(mResourceLocations.at(i));
    }

    // process command line
    /*if (! ProcessCmdLine(argc, argv))
    {
        return false;
    }*/

    mState = SSS_INITIALIZED;

    return true;
}
bool 
ACreatureCollectionActor::AreAllActorsReady() const
{
	for (auto& collection_data : collection_clips)
	{
		
		for (auto& cur_data : collection_data.second.actor_sequence)
		{
			auto cur_actor = cur_data.first;
			if (cur_actor->GetCore().GetIsReadyPlay() == false)
			{
				return false;
			}
		}
	}

	return true;
}
Example #4
0
void DebugCoreDumpDlg::OnButtonBrowseCore(wxCommandEvent& event)
{
    wxUnusedVar(event);

    wxString path, ans;
    wxFileName fn(GetCore());
    if(fn.FileExists()) {
        // Use the serialised path as the wxFileSelector default path
        path = fn.GetPath();
    } else {
        // Otherwise use any working dir entry, which might just have been altered
        path = GetWorkingDirectory();
    }

    ans = wxFileSelector(_("Select core dump:"), path);
    if(!ans.empty()) {
        m_Core->Insert(ans, 0);
        m_Core->SetSelection(0);
    }
}
Example #5
0
bool CAnimatedModelManager::Load(const string &_szFileName)
{
  LOGGER->AddNewLog(ELL_INFORMATION, "CAnimatedModelManager::Load Carregant el fitxer \"%s\"", _szFileName.c_str());
  m_vXMLFiles.insert(_szFileName);

  CXMLTreeNode l_treeAnimatedModels;
  if(l_treeAnimatedModels.LoadFile(_szFileName.c_str()))
  {
    int l_iNumChildren = l_treeAnimatedModels.GetNumChildren();
    for(int i = 0; i < l_iNumChildren; i++)
    {
      CXMLTreeNode l_treeAnimatedModel = l_treeAnimatedModels(i);
      if(strcmp(l_treeAnimatedModel.GetName(),"animatedModel") == 0)
      {
        const char* l_pcPath = l_treeAnimatedModel.GetPszProperty("path",0);
        const char* l_pcName = l_treeAnimatedModel.GetPszProperty("name",0);

        if(l_pcPath == 0)
        {
          LOGGER->AddNewLog(ELL_WARNING, "CAnimatedModelManager::Load No s'ha trobat la propietat \"path\" a una animatedModel.");
        } else if(l_pcName == 0)
        {
          LOGGER->AddNewLog(ELL_WARNING, "CAnimatedModelManager::Load No s'ha trobat la propietat \"name\" a una animatedModel.");
        } else {
          GetCore(l_pcName, l_pcPath);
        }
      } else if(!l_treeAnimatedModel.IsComment())
      {
        LOGGER->AddNewLog(ELL_WARNING, "CAnimatedModelManager::Load S'ha trobat un element desconegut \"%s\"", l_treeAnimatedModel.GetName());
      }
    }
  } else {
    LOGGER->AddNewLog(ELL_WARNING, "CAnimatedModelManager::Load No s'ha trobat el fitxer");
  }
  SetOk(true);
  return IsOk();
}
Example #6
0
int SimSpark::ExecuteRunScripts()
{
    if (mState == SSS_PREINIT)
    {
        LOG_INFO() << "Cant run simspark. It has to be initialized using Init() first.";
        return 1;
    }
    if (mState == SSS_RUNNING)
    {
        LOG_INFO() << "SimSpark already running.";
        return 0;
    }
    if (mState == SSS_PAUSED)
    {
        LOG_INFO() << "Unpause SimSpark with Continue()!";
        return 1;
    }

    if (mRunExecuted && !mReset)
    {
        LOG_WARNING() << "Spark has not been reset after last execution.";
    }

    //Init ruby variables from script value list
    boost::shared_ptr<zeitgeist::ScriptServer> scriptServer = GetCore()->GetScriptServer();
    if (scriptServer.get() == 0)
    {
        LOG_ERROR() << "Could not find ScriptServer. Aborting execution.";
        return 1;
    }
    for (auto it = mScriptValues.begin(); it != mScriptValues.end(); it++)
    {
        std::stringstream command;
        bool isString = (it->second.mType == RVT_STRING);
        command << "$" << it->first << " = " << it->second.toString();
        LOG_INFO() << "Setting script variable: " << command.str().c_str();
        scriptServer->Eval(command.str());
    }

    if (mRunExecuted == false)
    {
        //{#Spark-Reset#}
        //Can only execute main script once. When complete reset is possible, reset simspark in the "Reset()" function, and call the main script here every time.

        //Run main simulation initialization script
        GetCore()->GetScriptServer()->Run(mScriptPath);
    }
    bool ok = UpdateCached();

    if (!ok)
    {
        LOG_ERROR() << "Error in spark initialization (main script). Aborting execution.";
        return 1;
    }

    //Run additional scripts (even after restarting)
    for (auto it = mAdditionalScripts.begin(); it != mAdditionalScripts.end(); it++)
    {
        ok = RunScript(*it);

        if (!ok)
        {
            LOG_ERROR() << "Script execution failed. Aborting run.";
            return 1;
        }

        ok = UpdateCached();
        if (!ok)
        {
            LOG_ERROR() << "Error in spark initialization (updating cache after script '" << it->c_str() << "'). Aborting execution.";
            return 1;
        }
    }

    mReady = true; //Ready to call Run()
    return 0;
}
Example #7
0
int main(int argc, char *argv[]){
	if(argc >= 2 && (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0)){ // A stupid way to do this... for now.
		Unpacker *temp_core = GetCore();
		help(argv[0], temp_core);
		delete temp_core;
		return 0;
	}
	else if(argc >= 2 && (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-v") == 0)){ // Display version information
		std::cout << " " << PROG_NAME << "-------v" << SCAN_VERSION << " (" << SCAN_DATE << ")\n";
		std::cout << " |hribf_buffers-v" << HRIBF_BUFFERS_VERSION << " (" << HRIBF_BUFFERS_DATE << ")\n";
		std::cout << " |CTerminal-----v" << CTERMINAL_VERSION << " (" << CTERMINAL_DATE << ")\n";
		std::cout << " |poll2_socket--v" << POLL2_SOCKET_VERSION << " (" << POLL2_SOCKET_DATE << ")\n";
		return 0;
	}
	
	debug_mode = false;
	dry_run_mode = false;
	shm_mode = false;

	num_spills_recvd = 0;

	long file_start_offset = 0;

	// Fill the argument list.
	std::deque<std::string> scan_args;
	std::deque<std::string> core_args;
	int arg_index = 1;
	while(arg_index < argc){
		scan_args.push_back(std::string(argv[arg_index++]));
	}

	Unpacker *core = GetCore(); // Get a pointer to the main Unpacker object.
	
	// Loop through the arg list and extract ScanMain arguments.
	std::string current_arg;
	while(!scan_args.empty()){
		current_arg = scan_args.front();
		scan_args.pop_front();
	
		if(current_arg == "--debug"){ 
			core->SetDebugMode();
			debug_mode = true;
		}
		else if(current_arg == "--dry-run"){
			dry_run_mode = true;
		}
		else if(current_arg == "--fast-fwd"){
			if(scan_args.empty()){
				std::cout << " Error: Missing required argument to option '--fast-fwd'!\n";
				help(argv[0], core);
				return 1;
			}
			file_start_offset = atoll(scan_args.front().c_str());
			scan_args.pop_front();
		}
		else if(current_arg == "--quiet"){
			is_verbose = false;
		}
		else if(current_arg == "--shm"){ 
			file_format = 0;
			shm_mode = true;
			std::cout << " Using shm mode!\n";
		}
		else if(current_arg == "--ldf"){ 
			file_format = 0;
		}
		else if(current_arg == "--pld"){ 
			file_format = 1;
		}
		else if(current_arg == "--root"){ 
			file_format = 2;
		}
		else{ core_args.push_back(current_arg); } // Unrecognized option.
	}

	std::string input_filename = "";
	if(!core->SetArgs(core_args, input_filename)){ 
		help(argv[0], core);
		return 1; 
	}

	if(!shm_mode){
		extension = GetExtension(input_filename, prefix);
		if(file_format != -1){
			if(file_format == 0){ std::cout << sys_message_head << "Forcing ldf file readout.\n"; }
			else if(file_format == 1){ std::cout << sys_message_head << "Forcing pld file readout.\n"; }
			else if(file_format == 2){ std::cout << sys_message_head << "Forcing root file readout.\n"; }
		}
		else{
			if(prefix == ""){
				std::cout << " ERROR: Input filename was not specified!\n";
				return 1;
			}
		
			if(extension == "ldf"){ // List data format file
				file_format = 0;
			}
			else if(extension == "pld"){ // Pixie list data file format
				file_format = 1;
			}
			else if(extension == "root"){ // Pixie list data file format
				file_format = 2;
			}
			else{
				std::cout << " ERROR: Invalid file format '" << extension << "'\n";
				std::cout << "  The current valid data formats are:\n";
				std::cout << "   ldf - list data format (HRIBF)\n";
				std::cout << "   pld - pixie list data format\n";
				std::cout << "   root - root file containing raw pixie data\n";
				return 1;
			}
		}
	}

	// Initialize the Unpacker object.
	core->Initialize(sys_message_head);

	// Initialize the command terminal
	Terminal terminal;
	term_ = &terminal;

	if(!shm_mode){
		std::cout << sys_message_head << "Using file prefix " << prefix << ".\n";
		input_file.open((prefix+"."+extension).c_str(), std::ios::binary);
		if(!input_file.is_open() || !input_file.good()){
			std::cout << " ERROR: Failed to open input file '" << prefix+"."+extension << "'! Check that the path is correct.\n";
			input_file.close();
			return 1;
		}
	}
	else{
		if(!poll_server.Init(5555, 1)){
			std::cout << " ERROR: Failed to open shm socket 5555!\n";
			return 1;
		}

		std::string temp_name = std::string(PROG_NAME);
		
		// Only initialize the terminal if this is shared-memory mode
		terminal.Initialize(("."+temp_name+".cmd").c_str());
		terminal.SetPrompt((temp_name+" $ ").c_str());
		terminal.AddStatusWindow();

		std::cout << "\n " << PROG_NAME << " v" << SCAN_VERSION << "\n"; 
		std::cout << " ==  ==  ==  ==  == \n\n"; 
	}

	if(debug_mode){ std::cout << sys_message_head << "Using debug mode.\n"; }
	if(dry_run_mode){ std::cout << sys_message_head << "Doing a dry run.\n"; }
	if(shm_mode){ 
		std::cout << sys_message_head << "Using shared-memory mode.\n"; 
		std::cout << sys_message_head << "Listening on poll2 SHM port 5555\n";
	}

	if(!shm_mode){
		// Start reading the file
		// Every poll2 ldf file starts with a DIR buffer followed by a HEAD buffer
		int num_buffers;
		if(file_format == 0){
			dirbuff.Read(&input_file, num_buffers);
			headbuff.Read(&input_file);
			
			// Let's read out the file information from these buffers
			std::cout << "\n 'DIR ' buffer-\n";
			std::cout << "  Run number: " << dirbuff.GetRunNumber() << std::endl;
			std::cout << "  Number buffers: " << num_buffers << std::endl << std::endl;
	
			std::cout << " 'HEAD' buffer-\n";
			std::cout << "  Facility: " << headbuff.GetFacility() << std::endl;
			std::cout << "  Format: " << headbuff.GetFormat() << std::endl;
			std::cout << "  Type: " << headbuff.GetType() << std::endl;
			std::cout << "  Date: " << headbuff.GetDate() << std::endl;
			std::cout << "  Title: " << headbuff.GetRunTitle() << std::endl;
			std::cout << "  Run number: " << headbuff.GetRunNumber() << std::endl << std::endl;
		}
		else if(file_format == 1){
			pldHead.Read(&input_file);
			
			max_spill_size = pldHead.GetMaxSpillSize();
			
			// Let's read out the file information from these buffers
			std::cout << "\n 'HEAD' buffer-\n";
			std::cout << "  Facility: " << pldHead.GetFacility() << std::endl;
			std::cout << "  Format: " << pldHead.GetFormat() << std::endl;
			std::cout << "  Start: " << pldHead.GetStartDate() << std::endl;
			std::cout << "  Stop: " << pldHead.GetEndDate() << std::endl; 
			std::cout << "  Title: " << pldHead.GetRunTitle() << std::endl;
			std::cout << "  Run number: " << pldHead.GetRunNumber() << std::endl;
			std::cout << "  Max spill: " << pldHead.GetMaxSpillSize() << " words\n";
			std::cout << "  ACQ Time: " << pldHead.GetRunTime() << " seconds\n\n";
		}
		else if(file_format == 2){
		}
		
		// Fast forward in the file
		if(file_start_offset != 0){
			std::cout << " Skipping ahead to word no. " << file_start_offset << " in file\n";
			input_file.seekg(file_start_offset*4);
			std::cout << " Input file is now at " << input_file.tellg() << " bytes\n";
		}

		start_run_control(core);
	}
	else{ 
		// Start the run control thread
		std::cout << "\nStarting data control thread\n";
		std::thread runctrl(start_run_control, core);
	
		// Start the command control thread. This needs to be the last thing we do to
		// initialize, so the user cannot enter commands before setup is complete
		std::cout << "Starting command thread\n\n";
		std::thread comctrl(start_cmd_control);

		// Synchronize the threads and wait for completion
		comctrl.join();
		runctrl.join();
	
		// Close the socket and restore the terminal
		terminal.Close();
		poll_server.Close();
		
		//Reprint the leader as the carriage was returned
		std::cout << "Running " << PROG_NAME << " v" << SCAN_VERSION << " (" << SCAN_DATE << ")\n";
	}
	
	std::cout << sys_message_head << "Retrieved " << num_spills_recvd << " spills!\n";

	input_file.close();	

	// Clean up detector driver
	std::cout << "\nCleaning up...\n";
	
	core->PrintStatus(sys_message_head);
	core->Close();
	delete core;
	
	return 0;
}
Example #8
0
void Text::setText(const char* text)
{
	int length = strlen(text);
	if(length > 255) length = 255;

	memset(pTextBuffer, 0x00, 256);
	memcpy(pTextBuffer, text, length);

	const char* p;

	int width=0,height=0;

    /* calculate font scaling */
	LOCK_ACQUIRE(gFtLock);
    //float scale = stbtt_ScaleForPixelHeight(gFontInfo, pPixelSize);
    float scale = stbtt_ScaleForMappingEmToPixels(gFontInfo, pPixelSize);

    int ascent, descent, lineGap;
    stbtt_GetFontVMetrics(gFontInfo, &ascent, &descent, &lineGap);

    ascent *= scale;
    descent *= scale;

    height = ascent;
    // calculate bitmap size
    for (p = pTextBuffer; *p; p++)
    {
        /* how wide is this character */
        int ax;
        stbtt_GetCodepointHMetrics(gFontInfo, p[0], &ax, 0);
        width += ax * scale;

        /* add kerning */
        int kern;
        kern = stbtt_GetCodepointKernAdvance(gFontInfo, p[0], p[1]);
        width += kern * scale;
    }

    //check if old bitmap exists, and delete it
	uint8_t* oldBitmap = pBitmap;
	pBitmap = (uint8_t*)malloc(width*height);
	if(oldBitmap)
	{
		free(oldBitmap);
	}


	memset(pBitmap,0,width*height);

	pBitmapWidth = width;
	pBitmapHeight = height;

	setSizeN(
			2.f*((float)pBitmapWidth)/GetCore()->screen_width,
			2.f*((float)pBitmapHeight)/GetCore()->screen_width
	);

	int x=0,y=0;

	// render text to buffer
	for (p = pTextBuffer; *p; p++)
    {
        /* get bounding box for character (may be offset to account for chars that dip above or below the line */
        int c_x1, c_y1, c_x2, c_y2;
        stbtt_GetCodepointBitmapBox(gFontInfo, p[0], scale, scale, &c_x1, &c_y1, &c_x2, &c_y2);

        /* compute y (different characters have different heights */
        y = ascent + c_y1;

        /* render character (stride and offset is important here) */
        int byteOffset = x + (y  * width);
        stbtt_MakeCodepointBitmap(gFontInfo, pBitmap + byteOffset, c_x2 - c_x1, c_y2 - c_y1, width, scale, scale, p[0]);

        /* how wide is this character */
        int ax;
        stbtt_GetCodepointHMetrics(gFontInfo, p[0], &ax, 0);
        x += ax * scale;

        /* add kerning */
        int kern;
        kern = stbtt_GetCodepointKernAdvance(gFontInfo, p[0], p[1]);
        x += kern * scale;
    }
	LOCK_RELEASE(gFtLock);

	updateBitmap = true;
}
Example #9
0
void DebugCoreDumpDlg::OnDebugBtnUpdateUI(wxUpdateUIEvent& event)
{
    // gdb needs both a core and an exe for useful debugging
    event.Enable(!GetCore().empty() && !GetExe().empty());
}
Example #10
0
	void Init(CCore* Root) {
		const char * const *argv;

		CModuleImplementation::Init(Root);

		g_Bouncer = Root;

		const char *ConfigFile = g_Bouncer->BuildPathConfig("sbnc.tcl");
		struct stat statbuf;

		if (stat(ConfigFile, &statbuf) < 0) {
			FILE *ConfigFd = fopen(ConfigFile, "wb");

			if (ConfigFd == NULL) {
				g_Bouncer->Log("Could not create 'sbnc.tcl' file.");
				g_Bouncer->Fatal();
			}

			const char *ConfigDistFile = g_Bouncer->BuildPathShared("scripts/sbnc.tcl.dist");

			FILE *ConfigDistFd = fopen(ConfigDistFile, "rb");

			if (ConfigDistFd == NULL) {
				ConfigFile = g_Bouncer->BuildPathConfig("sbnc.tcl");
				unlink(ConfigFile);

				g_Bouncer->Log("Could not open 'sbnc.tcl.dist' file.");
				g_Bouncer->Fatal();
			}

			while (!feof(ConfigDistFd) && !ferror(ConfigDistFd)) {
				size_t Count;
				char Buffer[1024];

				Count = fread(Buffer, 1, sizeof(Buffer), ConfigDistFd);

				if (fwrite(Buffer, 1, Count, ConfigFd) < Count) {
					g_Bouncer->Log("Could not write to 'sbnc.tcl' file.");
					g_Bouncer->Fatal();
				}
			}

			fclose(ConfigDistFd);
			fclose(ConfigFd);
		}

		const char *ScriptsDir = g_Bouncer->BuildPathConfig("scripts");

		if (mkdir(ScriptsDir) < 0 && errno != EEXIST) {
			g_Bouncer->Log("Could not create 'scripts' directory.");
			g_Bouncer->Fatal();
		}

		g_TclListeners = new CHashtable<CTclSocket*, false>();
		g_TclClientSockets = new CHashtable<CTclClientSocket*, false>();

		argv = GetCore()->GetArgV();

		Tcl_FindExecutable(argv[0]);

		Tcl_SetSystemEncoding(NULL, "ISO8859-1");

		g_Encoding = Tcl_GetEncoding(g_Interp, "ISO8859-1");

		g_Interp = Tcl_CreateInterp();

		Tcl_InitMemory(g_Interp);

		Tcl_SetVar(g_Interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY);

		Tcl_AppInit(g_Interp);

		Tcl_Preserve(g_Interp);

		Tcl_Eval(g_Interp,
"rename source tcl_source\n"
"\n"
"# TODO: add support for -rsrc and -rsrcid\n"
"proc source {args} {\n"
"	set file [lindex $args end]\n"
"\n"
"	set has_shared_file [file isfile [file join [bncshareddir] $file]]\n"
"	set has_user_file [file isfile [file join [bncconfigdir] $file]]\n"
"\n"
"	if {!$has_user_file && $has_shared_file} {\n"
"		set file [file join [bncshareddir] $file]\n"
"	}\n"
"\n"
"	uplevel 1 tcl_source [lreplace $args end end $file]\n"
"}");

		Tcl_EvalFile(g_Interp, "./sbnc.tcl");
	}