示例#1
0
void TestSite::setUpDxs()
{
    // Put some dxs on the list.
    // Their names should be the same as the
    // ones in the expected components configuration info.

    for (unsigned int i=0; i<DxCount; i++)
    {
        DxProxy *proxy;

        // create proxies
        proxy = new DxProxy(site_->dxManager());

        // give the dx a name
        stringstream name;
        name << "dxtest" << i;
        proxy->setName(name.str());

        cu_assert(proxy->getName() == name.str());

        // register with the site
        proxy->notifyInputConnected();

        dxList_.push_back(proxy);
    }

}
示例#2
0
void NssComponentTreeInternal::getDxsConnectedToIfc(IfcProxy *ifcProxy,
						     DxList &outputDxList)
{

    // First, use the name of the ifcProxy to look up the
    // names of the dxs that are associated with it.

    Assert(ifcProxy);
    string ifcName = ifcProxy->getName();

    Assert(expectedNssComponentsTree_);
    vector<string> expectedDxNames =
	expectedNssComponentsTree_->getDxsForIfc(ifcName);

#if 0
    // debug: print the names
    cout << "dxs expected to be attached to ifc: " << ifcName << endl;
    for (vector<string>::iterator it = expectedDxNames.begin();
	 it != expectedDxNames.end(); ++it)
    {
	cout << *it << " ";
    }
    cout << endl;
#endif 

    // Now go through the dx proxy list.
    // For each proxy whose name is on the expectedDxNames list, add
    // it to the output proxy list.

    DxList & dxProxyList = dxList_;
    for (DxList::iterator it = dxProxyList.begin();
	 it != dxProxyList.end(); ++it)
    {
	DxProxy *dxProxy = *it;
	if (find(expectedDxNames.begin(), expectedDxNames.end(),
		 dxProxy->getName()) != expectedDxNames.end())
	{
	    outputDxList.push_back(dxProxy);
	}    
    }


}
示例#3
0
string DxOperation::runThroughDxList(const string &dxName,
				       Site *site)
{
   Assert(site);
   DxList dxList;
   site->dxManager()->getProxyList(&dxList);
   dxList.sort(compareDxsByName);

   string resultString;

   bool found = false;
   for (DxList::iterator index = dxList.begin();
	index != dxList.end(); ++index)
   {
      DxProxy *dxProxy = *index;
      Assert(dxProxy);
      if ( (dxName == "all") || dxProxy->getName() == dxName)
      {
	 found = true;
	 resultString += callOperation(dxProxy);
      }
   }

   if (found)
   {
      // if the command had no output text of its own,
      // return a generic acknowledgement.
      if (resultString.empty())
      {
	 resultString =  "dx command sent.";
      }
   }
   else 
   {
      resultString = "The requested DX(s) are not connected: " + dxName;
   }

   return resultString;

}
示例#4
0
DxList NssComponentTree::getDxsForBeams(std::vector<std::string> beamNames)
{
    DxList localDxList;

    // Go through list of dx proxies.  For each one whose beam is
    // on the incoming beamNames argument, add it to the local list.

    for (DxList::iterator it = internal_->dxList_.begin();
	 it != internal_->dxList_.end(); ++it)
    {
	DxProxy *dxProxy = *it;

	string beamForDx = internal_->expectedNssComponentsTree_->getBeamForDx(dxProxy->getName());

	if (find(beamNames.begin(), beamNames.end(), beamForDx)
	    != beamNames.end())
	{
	    localDxList.push_back(dxProxy);
	}
    }

    return localDxList;
}
示例#5
0
void TestSite::tearDown()
{
    // clean up the dxs
    for (DxList::iterator it = dxList_.begin();
            it != dxList_.end(); ++it)
    {
        DxProxy *proxy = *it;

        // unregister from the site
        proxy->notifyInputDisconnected();
        delete proxy;
    }

    // clean up the ifcs
    for (IfcList::iterator it = ifcList_.begin();
            it != ifcList_.end(); ++it)
    {
        IfcProxy *proxy = *it;

        // unregister from the site
        proxy->notifyInputDisconnected();
        delete proxy;
    }

    // clean up the tscopes
    for (TscopeList::iterator it = tscopeList_.begin();
            it != tscopeList_.end(); ++it)
    {
        TscopeProxy *proxy = *it;

        // unregister from the site
        proxy->notifyInputDisconnected();
        delete proxy;
    }

    delete site_;
}
示例#6
0
void TestSite::testDxStatus()
{
    cout << "testDxStatus" << endl;

    DxProxy *proxy = dxList_.front();

    cout << "DxName: " << proxy->getName() << endl;
    cout << proxy->getCachedDxStatus() << endl;
    cout << proxy->getConfiguration();
    cout << proxy->getIntrinsics();
    cout << "Dx bandwidth: " << proxy->getBandwidthInMHz() << endl;

}
示例#7
0
void TestSite::testGetDxsForIfc()
{
    cout << "testGetDxsForIfc" << endl;

    // Test that the NssComponentTree correctly
    // uses the expectedNssComponentsTree information
    // to return the dx proxies that
    // are attached to each of the IFs.

    // expected ifc/dx configuration:
    // ifctest0: dxtest0 dxtest1
    // ifctest1: dxtest2

    // Note:
    // a proxy for ifctest2 exists, but it is not listed
    // in the configuration info, and so should have no
    // dxs attached.

    NssComponentTree * tree = site_->getAllComponents();

    IfcList &ifcList = tree->getIfcs();
    cu_assert(ifcList.size() == IfcCount);

    // Get the dx proxies for each of the ifcs
    // and make sure they are the right ones.

    unsigned int nIfcsPassed = 0;
    for(IfcList::iterator it = ifcList.begin();
            it != ifcList.end(); ++it)
    {
        IfcProxy *ifcProxy = *it;

        if (ifcProxy->getName() == "ifctest0")
        {
            DxList & dxList = tree->getDxsForIfc(ifcProxy);
            cu_assert(dxList.size() == 2);

            // make sure the names match
            DxList::iterator it;
            for (it = dxList.begin(); it != dxList.end(); ++it)
            {
                DxProxy *proxy = *it;
                cu_assert(proxy->getName() == "dxtest0" ||
                          proxy->getName() == "dxtest1");
            }

            nIfcsPassed++;
        }
        else if (ifcProxy->getName() == "ifctest1")
        {
            DxList & dxList = tree->getDxsForIfc(ifcProxy);
            cu_assert(dxList.size() == 1);

            nIfcsPassed++;
        }
        else if (ifcProxy->getName() == "ifctest2")
        {
            // this one should not have any dxs attached to it

            DxList & dxList = tree->getDxsForIfc(ifcProxy);
            cu_assert(dxList.size() == 0);

            nIfcsPassed++;
        }
        else {

            // unexpected ifc is on the list
            cout << "error: unexpected ifc on the list: "
                 << ifcProxy->getName() << endl;

            cu_assert(0);
        }

    }
    cu_assert(nIfcsPassed == IfcCount);

    delete tree;
}
示例#8
0
void TestSite::testGetNssComponentTree()
{
    cout << "testGetNssComponentTree" << endl;

    NssComponentTree * tree = site_->getAllComponents();

    DxList &dxList = tree->getDxs();
    cu_assert(dxList.size() == DxCount);

    // make sure all the dxs in the component tree are
    // on the original list used to create it
    for(DxList::iterator it = dxList.begin();
            it != dxList.end(); ++it)
    {
        DxProxy *proxy = *it;

        cout << proxy->getName() << endl;

        cu_assert(find(dxList_.begin(), dxList_.end(), proxy)
                  != dxList_.end());
    }


    IfcList &ifcList = tree->getIfcs();
    cu_assert(ifcList.size() == IfcCount);

    // make sure all the ifcs in the component tree are
    // on the original list used to create it
    for(IfcList::iterator it = ifcList.begin();
            it != ifcList.end(); ++it)
    {
        IfcProxy *proxy = *it;

        cout << proxy->getName() << endl;

        cu_assert(find(ifcList_.begin(), ifcList_.end(), proxy)
                  != ifcList_.end());
    }

    vector<string> beamNames;
    beamNames.push_back("beam0");
    beamNames.push_back("beam1");

    IfcList ifcsForBeams(tree->getIfcsForBeams(beamNames));
    cu_assert(ifcsForBeams.size() == 2);

    for (IfcList::iterator it = ifcsForBeams.begin();
            it != ifcsForBeams.end(); ++it)
    {
        IfcProxy *proxy = *it;
        cu_assert(proxy->getName() == "ifctest0" ||
                  proxy->getName() == "ifctest1");
    }

    DxList dxsForBeams(tree->getDxsForBeams(beamNames));
    cu_assert(dxsForBeams.size() == 3);
    for (DxList::iterator it = dxsForBeams.begin();
            it != dxsForBeams.end(); ++it)
    {
        DxProxy *proxy = *it;
        cu_assert(proxy->getName() == "dxtest0"
                  || proxy->getName() == "dxtest1"
                  || proxy->getName() == "dxtest2");
    }

    TscopeList &tscopeList = tree->getTscopes();
    cu_assert(tscopeList.size() == TscopeCount);

    TestSigList &testSigList = tree->getTestSigs();
    cu_assert(testSigList.size() == 0);

    delete tree;
}