Example #1
0
void OlaServerServiceImpl::StreamDmxData(
    RpcController *controller,
    const ola::proto::DmxData* request,
    ola::proto::STREAMING_NO_RESPONSE*,
    ola::rpc::RpcService::CompletionCallback*) {
  Universe *universe = m_universe_store->GetUniverse(request->universe());

  if (!universe)
    return;

  Client *client = GetClient(controller);
  DmxBuffer buffer;
  buffer.Set(request->data());

  uint8_t priority = ola::dmx::SOURCE_PRIORITY_DEFAULT;
  if (request->has_priority()) {
    priority = request->priority();
    priority = std::max(static_cast<uint8_t>(ola::dmx::SOURCE_PRIORITY_MIN),
                        priority);
    priority = std::min(static_cast<uint8_t>(ola::dmx::SOURCE_PRIORITY_MAX),
                        priority);
  }
  DmxSource source(buffer, *m_wake_up_time, priority);
  client->DMXReceived(request->universe(), source);
  universe->SourceClientDataChanged(client);
}
Example #2
0
void OlaServerServiceImpl::UpdateDmxData(
    RpcController* controller,
    const DmxData* request,
    Ack*,
    ola::rpc::RpcService::CompletionCallback* done) {
  ClosureRunner runner(done);
  Universe *universe = m_universe_store->GetUniverse(request->universe());
  if (!universe)
    return MissingUniverseError(controller);

  Client *client = GetClient(controller);
  DmxBuffer buffer;
  buffer.Set(request->data());

  uint8_t priority = ola::dmx::SOURCE_PRIORITY_DEFAULT;
  if (request->has_priority()) {
    priority = request->priority();
    priority = std::max(static_cast<uint8_t>(ola::dmx::SOURCE_PRIORITY_MIN),
                        priority);
    priority = std::min(static_cast<uint8_t>(ola::dmx::SOURCE_PRIORITY_MAX),
                        priority);
  }
  DmxSource source(buffer, *m_wake_up_time, priority);
  client->DMXReceived(request->universe(), source);
  universe->SourceClientDataChanged(client);
}