void NScriptEngine::client_connected(){ connected=true; const common::URI script_engine_path("//Tools/Python/ScriptEngine", common::URI::Scheme::CPATH); SignalOptions options; SignalFrame frame = options.create_frame("get_completion", uri(), script_engine_path); NetworkQueue::global()->send( frame, NetworkQueue::IMMEDIATE ); }
void PDESolver::raise_iteration_done() { SignalOptions opts; const Uint iter = properties().value<Uint>("iteration"); opts.add( "iteration", iter ); SignalFrame frame = opts.create_frame("iteration_done", uri(), URI()); common::Core::instance().event_handler().raise_event( "iteration_done", frame); }
void NScriptEngine::request_documentation(QString &doc){ if (connected){ const common::URI script_engine_path("//Tools/Python/ScriptEngine", common::URI::Scheme::CPATH); SignalOptions options; options.add("expression", doc.toStdString()); SignalFrame frame = options.create_frame("get_documentation", uri(), script_engine_path); NetworkQueue::global()->send( frame, NetworkQueue::IMMEDIATE ); } }
void trigger_signal_print_message ( Component& receiver ) { SignalFrame signal_frame; SignalOptions options; options.add_option< OptionT<int> >( "Counter", 10 ); signal_frame = options.create_frame("Target", "//Root", "//Root"); receiver.call_signal( "print_message", signal_frame ); }
void TimeStepping::raise_timestep_done() { SignalOptions opts; opts.add_option( "time", m_time->current_time() ); opts.add_option( "dt", m_time->dt() ); opts.add_option( "iteration", properties().value<Uint>("iteration") ); SignalFrame frame = opts.create_frame("timestep_done", uri(), URI()); common::Core::instance().event_handler().raise_event( "timestep_done", frame); }
void NScriptEngine::emit_debug_command(debug_command command, int fragment, int line){ if (connected){ const common::URI script_engine_path("//Tools/Python/ScriptEngine", common::URI::Scheme::CPATH); SignalOptions options; options.add("command", static_cast<int>(command)); if (command == TOGGLE_BREAK_POINT){ options.add("fragment", fragment); options.add("line", line); } SignalFrame frame = options.create_frame("change_debug_state", uri(), script_engine_path); NetworkQueue::global()->send( frame, NetworkQueue::IMMEDIATE ); } }
void NScriptEngine::execute_line( const QString & line , int fragment_number, QVector<int> break_points){ if (connected){ const common::URI script_engine_path("//Tools/Python/ScriptEngine", common::URI::Scheme::CPATH); SignalOptions options; QString repl=QString(line); repl.replace(QString("\t"),QString(";")); repl.replace(QString("\n"),QString("?")); options.add("script", repl.toStdString()); options.add("fragment",fragment_number); options.add("breakpoints",break_points.toStdVector()); SignalFrame frame = options.create_frame("execute_script", uri(), script_engine_path); NetworkQueue::global()->send( frame, NetworkQueue::IMMEDIATE ); } }
void MeshGenerator::raise_mesh_loaded() { Mesh& mesh = *m_mesh; mesh.update_statistics(); mesh.elements().update(); // Raise an event to indicate that a mesh was loaded happened SignalOptions options; options.add_option("mesh_uri", mesh.uri()); SignalArgs f= options.create_frame(); Core::instance().event_handler().raise_event( "mesh_loaded", f ); }
void NetworkQueue::execute_script ( const QString & filename ) { if( m_script_file->isOpen() ) throw IllegalCall( FromHere(), "Another script is already in execution." ); m_script_file->setFileName( filename ); if( !m_script_file->exists() ) throw FileSystemError( FromHere(), "The file [" + filename.toStdString() + "] does not exist." ); BasicCommands::dispatcher = this; BasicCommands::tree_root = ThreadManager::instance().tree().root(); BasicCommands::current_component = ThreadManager::instance().tree().root(); if( !m_script_file->open( QIODevice::ReadOnly ) ) NLog::global()->add_error( m_script_file->errorString() ); else { NLog::global()->add_message("Running script: " + filename); m_script_stream->setDevice( m_script_file ); if(!filename.endsWith(".py")) // non-python, assume CFscript { send_next_command(); } else // python { const URI script_engine_path("//Tools/Python/ScriptEngine", common::URI::Scheme::CPATH); SignalOptions options; options.add("script", m_script_stream->readAll().toStdString()); SignalFrame frame = options.create_frame("execute_script", script_engine_path, script_engine_path); dispatch_signal("execute_script", script_engine_path, frame); } } }