void
nest::music_message_in_proxy::calibrate()
{
  // only publish the port once,
  if ( !S_.published_ )
  {
    MUSIC::Setup* s = nest::Communicator::get_music_setup();
    if ( s == 0 )
      throw MUSICSimulationHasRun( get_name() );

    V_.MP_ = s->publishMessageInput( P_.port_name_ );

    if ( !V_.MP_->isConnected() )
      throw MUSICPortUnconnected( get_name(), P_.port_name_ );

    if ( !V_.MP_->hasWidth() )
      throw MUSICPortHasNoWidth( get_name(), P_.port_name_ );

    S_.port_width_ = V_.MP_->width();

    // MUSIC wants seconds, NEST has miliseconds
    double_t acceptable_latency = P_.acceptable_latency_ / 1000.0;

    V_.MP_->map( &B_.message_handler_, acceptable_latency );
    S_.published_ = true;

    std::string msg =
      String::compose( "Mapping MUSIC input port '%1' with width=%2 and acceptable latency=%3 ms.",
        P_.port_name_,
        S_.port_width_,
        P_.acceptable_latency_ );
    net_->message( SLIInterpreter::M_INFO, "music_message_in_proxy::calibrate()", msg.c_str() );
  }
}