Exemplo n.º 1
0
void mitk::USDevice::ActivateProbe(mitk::USProbe::Pointer probe){
  // currently, we may just add the probe. This behaviour should be changed, should more complicated SDK applications emerge
  AddProbe(probe);
  int index = -1;
  for(int i = 0; i < m_ConnectedProbes.size(); i++)
  {
    if (m_ConnectedProbes[i]->IsEqualToProbe(probe)) index = i;
  }
  // index now contains the position of the original instance of this probe
  m_ActiveProbe = m_ConnectedProbes[index];
}
Exemplo n.º 2
0
void
FileHelper::ConnectProbeToAggregator (const std::string &typeId,
                                      const std::string &matchIdentifier,
                                      const std::string &path,
                                      const std::string &probeTraceSource,
                                      const std::string &outputFileNameWithoutExtension,
                                      bool onlyOneAggregator)
{
  NS_LOG_FUNCTION (this << typeId << matchIdentifier << path << probeTraceSource
                        << outputFileNameWithoutExtension << onlyOneAggregator);

  // Increment the total number of file probes that have been created.
  m_fileProbeCount++;

  // Create a unique name for this probe.
  std::ostringstream probeNameStream;
  probeNameStream << "FileProbe-" << m_fileProbeCount;
  std::string probeName = probeNameStream.str ();

  // Create a unique dataset context string for this probe.
  std::string probeContext = probeName
    + "/" + matchIdentifier + "/" + probeTraceSource;

  // Add the probe to the map of probes, which will keep the probe in
  // memory after this function ends.
  AddProbe (typeId, probeName, path);

  // Because the callbacks to the probes' trace sources don't use the
  // probe's context, a unique adaptor needs to be created for each
  // probe context so that information is not lost.
  AddTimeSeriesAdaptor (probeContext);

  // Connect the probe to the adaptor.
  if (m_probeMap[probeName].second == "ns3::DoubleProbe")
    {
      m_probeMap[probeName].first->TraceConnectWithoutContext
        (probeTraceSource,
        MakeCallback (&TimeSeriesAdaptor::TraceSinkDouble,
                      m_timeSeriesAdaptorMap[probeContext]));
    }
  else if (m_probeMap[probeName].second == "ns3::BooleanProbe")
    {
      m_probeMap[probeName].first->TraceConnectWithoutContext
        (probeTraceSource,
        MakeCallback (&TimeSeriesAdaptor::TraceSinkBoolean,
                      m_timeSeriesAdaptorMap[probeContext]));
    }
  else if (m_probeMap[probeName].second == "ns3::PacketProbe")
    {
      m_probeMap[probeName].first->TraceConnectWithoutContext
        (probeTraceSource,
        MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger32,
                      m_timeSeriesAdaptorMap[probeContext]));
    }
  else if (m_probeMap[probeName].second == "ns3::ApplicationPacketProbe")
    {
      m_probeMap[probeName].first->TraceConnectWithoutContext
        (probeTraceSource,
        MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger32,
                      m_timeSeriesAdaptorMap[probeContext]));
    }
  else if (m_probeMap[probeName].second == "ns3::Ipv4PacketProbe")
    {
      m_probeMap[probeName].first->TraceConnectWithoutContext
        (probeTraceSource,
        MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger32,
                      m_timeSeriesAdaptorMap[probeContext]));
    }
  else if (m_probeMap[probeName].second == "ns3::Ipv6PacketProbe")
    {
      m_probeMap[probeName].first->TraceConnectWithoutContext
        (probeTraceSource,
        MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger32,
                      m_timeSeriesAdaptorMap[probeContext]));
    }
  else if (m_probeMap[probeName].second == "ns3::Uinteger8Probe")
    {
      m_probeMap[probeName].first->TraceConnectWithoutContext
        (probeTraceSource,
        MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger8,
                      m_timeSeriesAdaptorMap[probeContext]));
    }
  else if (m_probeMap[probeName].second == "ns3::Uinteger16Probe")
    {
      m_probeMap[probeName].first->TraceConnectWithoutContext
        (probeTraceSource,
        MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger16,
                      m_timeSeriesAdaptorMap[probeContext]));
    }
  else if (m_probeMap[probeName].second == "ns3::Uinteger32Probe")
    {
      m_probeMap[probeName].first->TraceConnectWithoutContext
        (probeTraceSource,
        MakeCallback (&TimeSeriesAdaptor::TraceSinkUinteger32,
                      m_timeSeriesAdaptorMap[probeContext]));
    }
  else
    {
      NS_FATAL_ERROR ("Unknown probe type " << m_probeMap[probeName].second << "; need to add support in the helper for this");
    }

  // Add the aggregator to the map of aggregators, which will keep the
  // aggregator in memory after this function ends.
  std::string outputFileName = outputFileNameWithoutExtension + ".txt";
  AddAggregator (probeContext, outputFileName, onlyOneAggregator);

  // Connect the adaptor to the aggregator.
  std::string adaptorTraceSource = "Output";
  m_timeSeriesAdaptorMap[probeContext]->TraceConnect
    (adaptorTraceSource,
    probeContext,
    MakeCallback (&FileAggregator::Write2d,
                  m_aggregatorMap[probeContext]));
}