コード例 #1
0
/*
 * Check the SetUniverseName method works
 */
void OlaServerServiceImplTest::testSetUniverseName() {
  UniverseStore store(NULL, NULL);
  OlaServerServiceImpl impl(&store,
                            NULL,
                            NULL,
                            NULL,
                            NULL,
                            NULL,
                            NULL,
                            m_uid);
  OlaClientService service(NULL, &impl);

  unsigned int universe_id = 0;
  string universe_name = "test 1";
  string universe_name2 = "test 1-2";

  GenericAckCheck<SetUniverseNameCheck> ack_check;
  GenericMissingUniverseCheck<SetUniverseNameCheck, ola::proto::Ack>
    missing_universe_check;

  // Check we get an error for a missing universe
  CallSetUniverseName(&service, universe_id, universe_name,
                      missing_universe_check);
  Universe *universe = store.GetUniverse(universe_id);
  OLA_ASSERT_FALSE(universe);

  // Check SetUniverseName works on an existing univserse
  universe = store.GetUniverseOrCreate(universe_id);
  CallSetUniverseName(&service, universe_id, universe_name, ack_check);
  OLA_ASSERT_EQ(universe_name, universe->Name());

  // Run it again with a new name
  CallSetUniverseName(&service, universe_id, universe_name2, ack_check);
  OLA_ASSERT_EQ(universe_name2, universe->Name());
}
コード例 #2
0
/*
 * Test that we can create universes and save their settings
 */
void UniverseTest::testLifecycle() {
  Universe *universe = m_store->GetUniverse(TEST_UNIVERSE);
  OLA_ASSERT_FALSE(universe);

  universe = m_store->GetUniverseOrCreate(TEST_UNIVERSE);
  OLA_ASSERT(universe);
  OLA_ASSERT_EQ(TEST_UNIVERSE, universe->UniverseId());
  OLA_ASSERT_EQ((unsigned int) 1, m_store->UniverseCount());
  OLA_ASSERT_EQ(Universe::MERGE_LTP, universe->MergeMode());
  OLA_ASSERT_FALSE(universe->IsActive());

  string universe_name = "New Name";
  universe->SetName(universe_name);
  universe->SetMergeMode(Universe::MERGE_HTP);

  OLA_ASSERT_EQ(universe_name, universe->Name());
  OLA_ASSERT_EQ(Universe::MERGE_HTP, universe->MergeMode());

  // delete it
  m_store->AddUniverseGarbageCollection(universe);
  m_store->GarbageCollectUniverses();
  OLA_ASSERT_EQ((unsigned int) 0, m_store->UniverseCount());
  universe = m_store->GetUniverse(TEST_UNIVERSE);
  OLA_ASSERT_FALSE(universe);

  // now re-create it
  universe = m_store->GetUniverseOrCreate(TEST_UNIVERSE);
  OLA_ASSERT(universe);
  OLA_ASSERT_EQ((unsigned int) 1, m_store->UniverseCount());
  OLA_ASSERT_EQ(TEST_UNIVERSE, universe->UniverseId());
  OLA_ASSERT_EQ(universe_name, universe->Name());
  OLA_ASSERT_EQ(Universe::MERGE_HTP, universe->MergeMode());

  m_store->DeleteAll();
  OLA_ASSERT_EQ((unsigned int) 0, m_store->UniverseCount());
}
コード例 #3
0
ファイル: OlaServerServiceImpl.cpp プロジェクト: basileus/ola
/*
 * Returns information on the active universes.
 */
void OlaServerServiceImpl::GetUniverseInfo(
    RpcController* controller,
    const OptionalUniverseRequest* request,
    UniverseInfoReply* response,
    ola::rpc::RpcService::CompletionCallback* done) {
  ClosureRunner runner(done);
  UniverseInfo *universe_info;

  if (request->has_universe()) {
    // return info for a single universe
    Universe *universe = m_universe_store->GetUniverse(request->universe());
    if (!universe)
      return MissingUniverseError(controller);

    universe_info = response->add_universe();
    universe_info->set_universe(universe->UniverseId());
    universe_info->set_name(universe->Name());
    universe_info->set_merge_mode(universe->MergeMode() == Universe::MERGE_HTP
        ? ola::proto::HTP: ola::proto::LTP);
    universe_info->set_input_port_count(universe->InputPortCount());
    universe_info->set_output_port_count(universe->OutputPortCount());
    universe_info->set_rdm_devices(universe->UIDCount());
  } else {
    // return all
    vector<Universe*> uni_list;
    m_universe_store->GetList(&uni_list);
    vector<Universe*>::const_iterator iter;

    for (iter = uni_list.begin(); iter != uni_list.end(); ++iter) {
      universe_info = response->add_universe();
      universe_info->set_universe((*iter)->UniverseId());
      universe_info->set_name((*iter)->Name());
      universe_info->set_merge_mode((*iter)->MergeMode() == Universe::MERGE_HTP
          ? ola::proto::HTP: ola::proto::LTP);
      universe_info->set_input_port_count((*iter)->InputPortCount());
      universe_info->set_output_port_count((*iter)->OutputPortCount());
      universe_info->set_rdm_devices((*iter)->UIDCount());
    }
  }
}