本文整理汇总了C++中DmxBuffer::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ DmxBuffer::Get方法的具体用法?C++ DmxBuffer::Get怎么用?C++ DmxBuffer::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DmxBuffer
的用法示例。
在下文中一共展示了DmxBuffer::Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testStringGetSet
/*
* Check that the string set/get methods work
*/
void DmxBufferTest::testStringGetSet() {
const string data = "abcdefg";
DmxBuffer buffer;
uint8_t *result = new uint8_t[data.length()];
unsigned int size = data.length();
// Check that setting works
OLA_ASSERT_TRUE(buffer.Set(data));
OLA_ASSERT_EQ(data.length(), (size_t) buffer.Size());
OLA_ASSERT_EQ(data, buffer.Get());
buffer.Get(result, &size);
OLA_ASSERT_EQ(data.length(), (size_t) size);
OLA_ASSERT_EQ(0, memcmp(data.data(), result, size));
// Check the string constructor
DmxBuffer string_buffer(data);
OLA_ASSERT_TRUE(buffer == string_buffer);
// Set with an empty string
string data2;
size = data.length();
OLA_ASSERT_TRUE(buffer.Set(data2));
OLA_ASSERT_EQ(data2.length(), (size_t) buffer.Size());
OLA_ASSERT_EQ(data2, buffer.Get());
buffer.Get(result, &size);
OLA_ASSERT_EQ(data2.length(), (size_t) size);
OLA_ASSERT_EQ(0, memcmp(data2.data(), result, size));
delete[] result;
}
示例2:
/*
* Send 112 channels worth of data
* @param buf a DmxBuffer with the data
*/
int MilInstWidget1463::Send112(const DmxBuffer &buffer) const {
unsigned int channels = std::min((unsigned int) DMX_MAX_TRANSMIT_CHANNELS,
buffer.Size());
uint8_t msg[channels * 2];
for (unsigned int i = 0; i <= channels; i++) {
msg[i * 2] = i + 1;
msg[(i * 2) + 1] = buffer.Get(i);
OLA_DEBUG << "Setting " << (i + 1) << " to " <<
static_cast<int>(buffer.Get(i));
}
return m_socket->Send(msg, (channels * 2));
}
示例3: SendIndividualMessages
/**
* Send individual messages (one slot per message) to a set of targets.
* @param dmx_data the DmxBuffer to send
* @param group the OSCOutputGroup with the targets.
* @param osc_type the type of OSC message, either "i" or "f"
*/
bool OSCNode::SendIndividualMessages(const DmxBuffer &dmx_data,
OSCOutputGroup *group,
const string &osc_type) {
bool ok = true;
const OSCTargetVector &targets = group->targets;
vector<SlotMessage> messages;
// We only send the slots that have changed.
for (unsigned int i = 0; i < dmx_data.Size(); ++i) {
if (i > group->dmx.Size() || dmx_data.Get(i) != group->dmx.Get(i)) {
SlotMessage message = {i, lo_message_new()};
if (osc_type == "i") {
lo_message_add_int32(message.message, dmx_data.Get(i));
} else {
lo_message_add_float(message.message, dmx_data.Get(i) / 255.0f);
}
messages.push_back(message);
}
}
group->dmx.Set(dmx_data);
// Send all messages to each target.
OSCTargetVector::const_iterator target_iter = targets.begin();
for (; target_iter != targets.end(); ++target_iter) {
OLA_DEBUG << "Sending to " << (*target_iter)->socket_address;
vector<SlotMessage>::const_iterator message_iter = messages.begin();
for (; message_iter != messages.end(); ++message_iter) {
std::stringstream path;
path << (*target_iter)->osc_address << "/" << message_iter->slot + 1;
int ret = lo_send_message_from((*target_iter)->liblo_address,
m_osc_server,
path.str().c_str(),
message_iter->message);
ok &= (ret > 0);
}
}
// Clean up the messages.
vector<SlotMessage>::iterator message_iter = messages.begin();
for (; message_iter != messages.end(); ++message_iter) {
lo_message_free(message_iter->message);
}
return ok;
}
示例4: SendDmx
bool StreamingClient::SendDmx(unsigned int universe,
const DmxBuffer &data) {
if (!m_stub || !m_socket->ValidReadDescriptor())
return false;
// We select() on the fd here to see if the remove end has closed the
// connection. We could skip this and rely on the EPIPE delivered by the
// write() below, but that introduces a race condition in the unittests.
m_socket_closed = false;
m_ss->RunOnce(0, 0);
if (m_socket_closed) {
Stop();
return false;
}
ola::proto::DmxData request;
request.set_universe(universe);
request.set_data(data.Get());
m_stub->StreamDmxData(NULL, &request, NULL, NULL);
if (m_socket_closed) {
Stop();
return false;
}
return true;
}
示例5: SendDMX
bool SendDMX(unsigned int universe_id, uint8_t priority,
const DmxBuffer &buffer) {
OLA_ASSERT_EQ(TEST_UNIVERSE, universe_id);
OLA_ASSERT_EQ(ola::dmx::SOURCE_PRIORITY_MIN, priority);
OLA_ASSERT_EQ(string(TEST_DATA), buffer.Get());
m_dmx_set = true;
return true;
}
示例6: SendDMX
/**
* Send DMX
* @param buffer the DMX data
*/
bool RobeWidgetImpl::SendDMX(const DmxBuffer &buffer) {
// the data is 512 + an extra 4 bytes
uint8_t output_data[DMX_FRAME_DATA_SIZE];
memset(output_data, 0, DMX_FRAME_DATA_SIZE);
unsigned int length = DMX_UNIVERSE_SIZE;
buffer.Get(output_data, &length);
return SendMessage(CHANNEL_A_OUT,
reinterpret_cast<uint8_t*>(&output_data),
length + 4);
}
示例7: NewDMX
/**
* @brief Called when new DMX arrives.
*/
void DMXTrigger::NewDMX(const DmxBuffer &data) {
SlotVector::iterator iter = m_slots.begin();
for (; iter != m_slots.end(); iter++) {
uint16_t slot_number = (*iter)->SlotOffset();
if (slot_number >= data.Size()) {
// the DMX frame was too small
break;
}
(*iter)->TakeAction(m_context, data.Get(slot_number));
}
}
示例8: sizeof
/*
* Send data
* @param buffer a DmxBuffer with the data
*/
int MilInstWidget1553::Send(const DmxBuffer &buffer) const {
unsigned int channels = std::min(static_cast<unsigned int>(m_channels),
buffer.Size());
uint8_t msg[3 + channels];
msg[0] = MILINST_1553_LOAD_COMMAND;
ola::utils::SplitUInt16(1, &msg[1], &msg[2]);
buffer.Get(msg + 3, &channels);
return m_socket->Send(msg, sizeof(msg));
}
示例9: SendFloatArray
/**
* Send the DmxBuffer as an array of normalized floats.
*/
bool OSCNode::SendFloatArray(const DmxBuffer &dmx_data,
const OSCTargetVector &targets) {
lo_message message = lo_message_new();
for (size_t i = 0; i < dmx_data.Size(); ++i) {
lo_message_add_float(message, dmx_data.Get(i) / 255.0f);
}
bool ok = SendMessageToTargets(message, targets);
lo_message_free(message);
return ok;
}
示例10: Values
/*
* Update the screen with new values
*/
void DmxMonitor::Values() {
int i = 0, x, y, z = first_channel;
/* values */
for (y = 2; y < LINES && z < DMX_UNIVERSE_SIZE && i < channels_per_screen;
y+=2) {
move(y, 0);
for (x = 0; x < channels_per_line && z < DMX_UNIVERSE_SIZE &&
i < channels_per_screen; x++, z++, i++) {
const int d = m_buffer.Get(z);
switch (d) {
case 0:
(void) attrset(palette[ZERO]);
break;
case 255:
(void) attrset(palette[FULL]);
break;
default:
(void) attrset(palette[NORM]);
}
if (z == current_channel)
attron(A_REVERSE);
switch (display_mode) {
case DISP_MODE_HEX:
if (d == 0)
addstr(" ");
else
printw(" %02x ", d);
break;
case DISP_MODE_DEC:
if (d == 0)
addstr(" ");
else if (d < 100)
printw(" %02d ", d);
else
printw("%03d ", d);
break;
case DISP_MODE_DMX:
default:
switch (d) {
case 0:
addstr(" ");
break;
case 255:
addstr(" FL ");
break;
default:
printw(" %02d ", (d * 100) / 255);
}
}
}
}
}
示例11: WriteDMX
bool DummyPort::WriteDMX(const DmxBuffer &buffer,
uint8_t priority) {
(void) priority;
m_buffer = buffer;
ostringstream str;
string data = buffer.Get();
str << "Dummy port: got " << buffer.Size() << " bytes: ";
for (unsigned int i = 0; i < 10 && i < data.size(); i++)
str << "0x" << std::hex << 0 + (uint8_t) data.at(i) << " ";
OLA_INFO << str.str();
return true;
}
示例12: SendDataAndCheck
void OPCServerTest::SendDataAndCheck(uint8_t channel,
const DmxBuffer &buffer) {
unsigned int dmx_size = buffer.Size();
uint8_t data[dmx_size + 4];
data[0] = channel;
data[1] = SET_PIXELS_COMMAND;
ola::utils::SplitUInt16(static_cast<uint16_t>(dmx_size), &data[2], &data[3]);
buffer.Get(data + 4, &dmx_size);
m_client_socket->Send(data, dmx_size + 4);
m_ss.Run();
OLA_ASSERT_EQ(m_received_data, buffer);
}
示例13: SendDMXWithLabel
bool UltraDMXProWidget::SendDMXWithLabel(uint8_t label,
const DmxBuffer &data) {
struct {
uint8_t start_code;
uint8_t dmx[DMX_UNIVERSE_SIZE];
} widget_dmx;
widget_dmx.start_code = DMX512_START_CODE;
unsigned int length = DMX_UNIVERSE_SIZE;
data.Get(widget_dmx.dmx, &length);
return SendMessage(label,
reinterpret_cast<uint8_t*>(&widget_dmx),
length + 1);
}
示例14: GetDmx
/*
* Returns the current DMX values for a particular universe
*/
void OlaServerServiceImpl::GetDmx(
RpcController* controller,
const UniverseRequest* request,
DmxData* response,
ola::rpc::RpcService::CompletionCallback* done) {
ClosureRunner runner(done);
Universe *universe = m_universe_store->GetUniverse(request->universe());
if (!universe)
return MissingUniverseError(controller);
const DmxBuffer buffer = universe->GetDMX();
response->set_data(buffer.Get());
response->set_universe(request->universe());
}
示例15: SendEspData
/*
* Send an EspNet data packet
*/
bool EspNetNode::SendEspData(const IPV4Address &dst,
uint8_t universe,
const DmxBuffer &buffer) {
espnet_packet_union_t packet;
memset(&packet.dmx, 0, sizeof(packet.dmx));
packet.dmx.head = HostToNetwork((uint32_t) ESPNET_DMX);
packet.dmx.universe = universe;
packet.dmx.start = START_CODE;
packet.dmx.type = DATA_RAW;
unsigned int size = DMX_UNIVERSE_SIZE;
buffer.Get(packet.dmx.data, &size);
packet.dmx.size = HostToNetwork((uint16_t) size);
return SendPacket(dst, packet, sizeof(packet.dmx));
}