Beispiel #1
0
void CPlotXY::convergence_history( SignalArgs & args )
{
  if( is_not_null(m_data.get()) )
  {
    SignalFrame reply = args.create_reply( uri() );
    SignalFrame& options = reply.map( Protocol::Tags::key_options() );
//    std::vector<Real> data(8000);
    CTable<Real>& table = *m_data.get();
    std::vector<std::string> labels =
        list_of<std::string>("x")("y")("z")("u")("v")("w")("p")("t");

    add_multi_array_in(options.main_map, "Table", m_data->array(), ";", labels);

//    for(Uint row = 0 ; row < 1000 ; ++row)
//    {
//      for(Uint col = 0 ; col < 8 ; ++col)
//        data[ (row * 8) + col ] = table[row][col];
//    }

//    XmlNode node = options.add("Table", data, " ; ");

//    node.set_attribute("dimensions", "8");
  }
  else
    throw SetupError( FromHere(), "Data to plot not setup" );
}
Beispiel #2
0
SignalRet SignalHandler::call_signal ( const SignalID& sname, std::vector<std::string>& sinput )
{
  SignalFrame frame;
  SignalFrame& options = frame.map( Protocol::Tags::key_options() );

  options.insert( sinput );

  call_signal(sname, frame);
}
Beispiel #3
0
void CLink::change_link( SignalArgs & args )
{
  SignalOptions options( args );
  SignalFrame reply = args.create_reply();

  std::string path = options.value<std::string>("target_path");
  Component::Ptr target = m_root.lock()->access_component_ptr(path);

  link_to (target);

  reply.map("options").set_option("target_path", path);
}
Beispiel #4
0
void Link::change_link( SignalArgs & args )
{
  SignalOptions options( args );
  SignalFrame reply = args.create_reply();

  std::string path = options.value<std::string>("target_path");
  Handle<Component> target = access_component(path);

  link_to (*target);

  reply.map("options").set_option("target_path", class_name<std::string>(), path);
}
void ServerNetworkComm::callback_read( TCPConnection::Ptr conn,
                                       const boost::system::error_code & error )
{
  if( !error )
  {
    std::string error_msg;
    ClientInfo& info = m_clients[conn];
    SignalFrame & buffer = info.buffer;

    std::string target = buffer.node.attribute_value( "target" );
    std::string receiver = buffer.node.attribute_value( "receiver" );
    std::string clientid = buffer.node.attribute_value( "clientid" );
    std::string frameid = buffer.node.attribute_value( "frameid" );

    // check if the client is attempting to register
    if( target == "client_registration" )
    {
      if( !info.uuid.empty() )
        error_msg = "This client has already been registered.";
      else
      {
        info.uuid = clientid;

        // Build and send the reply
        SignalFrame reply = buffer.create_reply();
        SignalOptions & roptions = reply.options();

        roptions.add("accepted", true);
        roptions.flush();

        this->init_send(conn, buffer );

        // tell listeners a new client has arrived
        SignalFrame frame("new_client_connected", "cpath:/", "cpath:/");
        frame.options().add( "clientid", clientid );
        call_signal( "new_client_connected", frame );
      }
    }
    else
    {
      if( info.uuid.empty() )
        error_msg = "The signal came from an unregistered client.";
      else if( info.uuid != clientid )
        error_msg = "The client id '" + info.uuid + "' (used for registration) "
            + "and '" + clientid + "' (used for identification) do not match.";
      else
        ServerRoot::instance().process_signal(target, receiver, clientid, frameid, buffer);
    }

    if( !error_msg.empty() )
      this->send_frame_rejected( conn, frameid, SERVER_CORE_PATH, error_msg );

    init_read( info );
  }
  else if( error != boost::asio::error::eof )
    CFerror << "Could not read from [" << conn->socket().remote_endpoint()
            << "]: " << error.message() << CFendl;

  if( error )
  {
    std::string uuid = m_clients[conn].uuid;
    conn->disconnect();
    m_clients.erase( conn );

    if( error == boost::asio::error::eof )
      CFinfo << "Cliemt [" << uuid << "] has disconnected. ("
             << m_clients.size() << " left)." << CFendl;
  }

}
std::string get_message( const SignalFrame & frame )
{
  return frame.options().value<std::string>( "text" );;
}