本文整理汇总了C++中DmxBuffer::SetFromString方法的典型用法代码示例。如果您正苦于以下问题:C++ DmxBuffer::SetFromString方法的具体用法?C++ DmxBuffer::SetFromString怎么用?C++ DmxBuffer::SetFromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DmxBuffer
的用法示例。
在下文中一共展示了DmxBuffer::SetFromString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testReceiveDmx
void OPCServerTest::testReceiveDmx() {
DmxBuffer buffer;
buffer.SetFromString("1,2,3,4");
SendDataAndCheck(CHANNEL, buffer);
buffer.SetFromString("5,6");
SendDataAndCheck(CHANNEL, buffer);
buffer.SetFromString("5,6,7,8,89,9,5,6,7,8,3");
SendDataAndCheck(CHANNEL, buffer);
}
示例2: backend
/**
* Test DMX writes in the individual P9813 mode.
*/
void SPIOutputTest::testIndividualP9813Control() {
FakeSPIBackend backend(2);
SPIOutput::Options options(0, "Test SPI Device");
options.pixel_count = 2;
SPIOutput output(m_uid, &backend, options);
output.SetPersonality(5);
DmxBuffer buffer;
unsigned int length = 0;
const uint8_t *data = NULL;
buffer.SetFromString("1, 10, 100");
output.WriteDMX(buffer);
data = backend.GetData(0, &length);
const uint8_t EXPECTED0[] = { 0, 0, 0, 0, 0xEF, 0x64, 0x0A, 0x01,
0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
OLA_ASSERT_DATA_EQUALS(EXPECTED0, arraysize(EXPECTED0), data, length);
OLA_ASSERT_EQ(1u, backend.Writes(0));
buffer.SetFromString("255,128,0,10,20,30");
output.WriteDMX(buffer);
data = backend.GetData(0, &length);
const uint8_t EXPECTED1[] = { 0, 0, 0, 0, 0xF4, 0, 0x80, 0xFF,
0xFF, 0x1E, 0x14, 0x0A, 0, 0, 0, 0, 0, 0, 0, 0};
OLA_ASSERT_DATA_EQUALS(EXPECTED1, arraysize(EXPECTED1), data, length);
OLA_ASSERT_EQ(2u, backend.Writes(0));
buffer.SetFromString("34,56,78");
output.WriteDMX(buffer);
data = backend.GetData(0, &length);
const uint8_t EXPECTED2[] = { 0, 0, 0, 0, 0xEF, 0x4E, 0x38, 0x22,
0xFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
OLA_ASSERT_DATA_EQUALS(EXPECTED2, arraysize(EXPECTED2), data, length);
OLA_ASSERT_EQ(3u, backend.Writes(0));
buffer.SetFromString("7, 9");
output.WriteDMX(buffer);
data = backend.GetData(0, &length);
OLA_ASSERT_DATA_EQUALS(EXPECTED2, arraysize(EXPECTED2), data, length);
OLA_ASSERT_EQ(3u, backend.Writes(0));
output.SetStartAddress(3);
buffer.SetFromString("1,2,3,4,5,6,7,8");
output.WriteDMX(buffer);
data = backend.GetData(0, &length);
const uint8_t EXPECTED4[] = { 0, 0, 0, 0, 0xFF, 0x05, 0x04, 0x03,
0xFF, 0x08, 0x07, 0x06, 0, 0, 0, 0, 0, 0, 0, 0};
OLA_ASSERT_DATA_EQUALS(EXPECTED4, arraysize(EXPECTED4), data, length);
OLA_ASSERT_EQ(4u, backend.Writes(0));
// Check nothing changed on the other output.
OLA_ASSERT_EQ(reinterpret_cast<const uint8_t*>(NULL),
backend.GetData(1, &length));
OLA_ASSERT_EQ(0u, backend.Writes(1));
}
示例3: backend
/**
* Test DMX writes in the individual LPD8806 mode.
*/
void SPIOutputTest::testIndividualLPD8806Control() {
FakeSPIBackend backend(2);
SPIOutput::Options options(0);
options.pixel_count = 2;
SPIOutput output(m_uid, &backend, options);
output.SetPersonality(3);
DmxBuffer buffer;
unsigned int length = 0;
const uint8_t *data = NULL;
buffer.SetFromString("1, 10, 100");
output.WriteDMX(buffer);
data = backend.GetData(0, &length);
const uint8_t EXPECTED0[] = { 0x85, 0x80, 0xb2, 0, 0, 0, 0};
ASSERT_DATA_EQUALS(__LINE__, EXPECTED0, arraysize(EXPECTED0), data, length);
OLA_ASSERT_EQ(1u, backend.Writes(0));
buffer.SetFromString("255,128,0,10,20,30");
output.WriteDMX(buffer);
data = backend.GetData(0, &length);
const uint8_t EXPECTED1[] = { 0xc0, 0xff, 0x80, 0x8a, 0x85, 0x8f, 0 };
ASSERT_DATA_EQUALS(__LINE__, EXPECTED1, arraysize(EXPECTED1), data, length);
OLA_ASSERT_EQ(2u, backend.Writes(0));
buffer.SetFromString("34,56,78");
output.WriteDMX(buffer);
data = backend.GetData(0, &length);
const uint8_t EXPECTED2[] = { 0x9c, 0x91, 0xa7, 0x8a, 0x85, 0x8f, 0 };
ASSERT_DATA_EQUALS(__LINE__, EXPECTED2, arraysize(EXPECTED2), data, length);
OLA_ASSERT_EQ(3u, backend.Writes(0));
buffer.SetFromString("7, 9");
output.WriteDMX(buffer);
data = backend.GetData(0, &length);
ASSERT_DATA_EQUALS(__LINE__, EXPECTED2, arraysize(EXPECTED2), data, length);
OLA_ASSERT_EQ(3u, backend.Writes(0));
output.SetStartAddress(3);
buffer.SetFromString("1,2,3,4,5,6,7,8");
output.WriteDMX(buffer);
data = backend.GetData(0, &length);
const uint8_t EXPECTED4[] = { 0x82, 0x81, 0x82, 0x83, 0x83, 0x84, 0 };
ASSERT_DATA_EQUALS(__LINE__, EXPECTED4, arraysize(EXPECTED4), data, length);
OLA_ASSERT_EQ(4u, backend.Writes(0));
// Check nothing changed on the other output.
OLA_ASSERT_EQ(reinterpret_cast<const uint8_t*>(NULL),
backend.GetData(1, &length));
OLA_ASSERT_EQ(0u, backend.Writes(1));
}
示例4: testSendDMX
/*
* Check that we can send DMX
*/
void RobeWidgetTest::testSendDMX() {
// dmx data
DmxBuffer buffer;
buffer.SetFromString("0,1,2,3,4");
// expected message
uint8_t dmx_frame_data[] = {0, 1, 2, 3, 4, 0, 0, 0, 0};
// add the expected data, run and verify.
m_endpoint->AddExpectedRobeMessage(
DMX_FRAME_LABEL,
dmx_frame_data,
sizeof(dmx_frame_data),
ola::NewSingleCallback(this, &RobeWidgetTest::Terminate));
m_widget->SendDMX(buffer);
m_ss.Run();
m_endpoint->Verify();
// now test an empty frame
DmxBuffer buffer2;
uint8_t empty_frame_data[] = {0, 0, 0, 0}; // null frames still have 4 bytes
// add the expected data, run and verify.
m_endpoint->AddExpectedRobeMessage(
DMX_FRAME_LABEL,
empty_frame_data,
sizeof(empty_frame_data),
ola::NewSingleCallback(this, &RobeWidgetTest::Terminate));
m_widget->SendDMX(buffer2);
m_ss.Run();
m_endpoint->Verify();
}
示例5: testSendDMX
/**
* Check that we can send DMX
*/
void BaseUsbProWidgetTest::testSendDMX() {
// dmx data
DmxBuffer buffer;
buffer.SetFromString("0,1,2,3,4");
// expected message
uint8_t dmx_frame_data[] = {DMX512_START_CODE, 0, 1, 2, 3, 4};
m_endpoint->AddExpectedUsbProMessage(
DMX_FRAME_LABEL,
dmx_frame_data,
sizeof(dmx_frame_data),
ola::NewSingleCallback(this, &BaseUsbProWidgetTest::Terminate));
m_widget->SendDMX(buffer);
m_ss.Run();
m_endpoint->Verify();
// now test an empty frame
DmxBuffer buffer2;
uint8_t empty_frame_data[] = {DMX512_START_CODE}; // just the start code
m_endpoint->AddExpectedUsbProMessage(
DMX_FRAME_LABEL,
empty_frame_data,
sizeof(empty_frame_data),
ola::NewSingleCallback(this, &BaseUsbProWidgetTest::Terminate));
m_widget->SendDMX(buffer2);
m_ss.Run();
m_endpoint->Verify();
}
示例6: testReceive
/*
* Test receiving works.
*/
void RobeWidgetTest::testReceive() {
DmxBuffer buffer;
buffer.SetFromString("0,1,2,3,4");
// change to recv mode & setup the callback
m_endpoint->AddExpectedRobeMessage(
DMX_IN_REQUEST_LABEL,
NULL,
0,
ola::NewSingleCallback(this, &RobeWidgetTest::Terminate));
m_widget->ChangeToReceiveMode();
m_ss.Run();
m_endpoint->Verify();
m_widget->SetDmxCallback(
ola::NewCallback(this, &RobeWidgetTest::NewDMXData));
CPPUNIT_ASSERT(!m_new_dmx_data);
// now send some data
m_endpoint->SendUnsolicitedRobeData(DMX_IN_RESPONSE_LABEL,
buffer.GetRaw(),
buffer.Size());
m_ss.Run();
CPPUNIT_ASSERT(m_new_dmx_data);
const DmxBuffer &new_data = m_widget->FetchDMX();
CPPUNIT_ASSERT(buffer == new_data);
}
示例7: testRisingEdgeTrigger
/**
* Check that triggering on a rising edge works correctly.
*/
void DMXTriggerTest::testRisingEdgeTrigger() {
// setup the actions
vector<Slot*> slots;
Slot slot(2);
MockAction *action = new MockAction();
BadAction *bad_action = new BadAction();
ValueInterval interval(10, 20);
slot.AddAction(interval, action, bad_action);
slots.push_back(&slot);
Context context;
DMXTrigger trigger(&context, slots);
DmxBuffer buffer;
// this shouldn't trigger
buffer.SetFromString("0,0,0");
trigger.NewDMX(buffer);
OLA_ASSERT(action->NoCalls());
// trigger rising edge
buffer.SetFromString("0,0,10");
trigger.NewDMX(buffer);
action->CheckForValue(__LINE__, 10);
// now send the same again
OLA_ASSERT(action->NoCalls());
trigger.NewDMX(buffer);
OLA_ASSERT(action->NoCalls());
// shorten the frame
buffer.SetFromString("0,0");
trigger.NewDMX(buffer);
OLA_ASSERT(action->NoCalls());
// lengthen again
buffer.SetFromString("0,0,10,0");
trigger.NewDMX(buffer);
OLA_ASSERT(action->NoCalls());
// change everything else
buffer.SetFromString("10,100,10,20");
trigger.NewDMX(buffer);
OLA_ASSERT(action->NoCalls());
}
示例8: testToString
/*
* Test ToString()
*/
void DmxBufferTest::testToString() {
DmxBuffer buffer;
OLA_ASSERT_EQ(string(""), buffer.ToString());
buffer.SetFromString("1,2,3,4");
OLA_ASSERT_EQ(string("1,2,3,4"), buffer.ToString());
buffer.SetRangeToValue(0, 255, 5);
OLA_ASSERT_EQ(string("255,255,255,255,255"), buffer.ToString());
}
示例9: testUnknownCommand
void OPCServerTest::testUnknownCommand() {
uint8_t data[] = {1, 1, 0, 2, 3, 4};
m_client_socket->Send(data, arraysize(data));
m_ss.Run();
DmxBuffer buffer;
buffer.SetFromString("3,4");
OLA_ASSERT_EQ(static_cast<uint8_t>(1), m_command);
OLA_ASSERT_EQ(m_received_data, buffer);
}
示例10: testFallingEdgeTrigger
/**
* Test that falling edges trigger
*/
void DMXTriggerTest::testFallingEdgeTrigger() {
// setup the actions
vector<Slot*> slots;
Slot slot(2);
MockAction *rising_action = new MockAction();
MockAction *falling_action = new MockAction();
ValueInterval interval(10, 20);
slot.AddAction(interval, rising_action, falling_action);
slots.push_back(&slot);
Context context;
DMXTrigger trigger(&context, slots);
DmxBuffer buffer;
// trigger
buffer.SetFromString("0,0,20");
trigger.NewDMX(buffer);
rising_action->CheckForValue(__LINE__, 20);
OLA_ASSERT(falling_action->NoCalls());
// trigger a falling edge
buffer.SetFromString("0,0,19");
trigger.NewDMX(buffer);
OLA_ASSERT(rising_action->NoCalls());
falling_action->CheckForValue(__LINE__, 19);
// now send the same again
trigger.NewDMX(buffer);
OLA_ASSERT(rising_action->NoCalls());
OLA_ASSERT(falling_action->NoCalls());
// shorten the frame
buffer.SetFromString("0,0");
trigger.NewDMX(buffer);
OLA_ASSERT(rising_action->NoCalls());
OLA_ASSERT(falling_action->NoCalls());
// lengthen again
buffer.SetFromString("0,0,19,0");
trigger.NewDMX(buffer);
OLA_ASSERT(rising_action->NoCalls());
OLA_ASSERT(falling_action->NoCalls());
// change everything else
buffer.SetFromString("10,100,19,20");
trigger.NewDMX(buffer);
OLA_ASSERT(rising_action->NoCalls());
OLA_ASSERT(falling_action->NoCalls());
// change once more
buffer.SetFromString("10,100,20,20");
trigger.NewDMX(buffer);
rising_action->CheckForValue(__LINE__, 20);
OLA_ASSERT(falling_action->NoCalls());
}
示例11: setUp
void OSCNodeTest::setUp() {
// Init logging
ola::InitLogging(ola::OLA_LOG_INFO, ola::OLA_LOG_STDERR);
// Setup and register the Timeout.
m_timeout_id = m_ss.RegisterSingleTimeout(
ABORT_TIMEOUT_IN_MS,
ola::NewSingleCallback(this, &OSCNodeTest::Timeout));
OLA_ASSERT_TRUE(m_timeout_id);
// Init our UDP socket.
OLA_ASSERT_TRUE(m_udp_socket.Init());
// Put some data into the DMXBuffer
m_dmx_data.SetFromString("0,1,2,3,4,5,6,7,8,9,10");
// Initialize the OSCNode
OLA_ASSERT_TRUE(m_osc_node->Init());
}
示例12: HandleSetDmx
/*
* Handle the set dmx command
* @param request the HTTPRequest
* @param response the HTTPResponse
* @returns MHD_NO or MHD_YES
*/
int OladHTTPServer::HandleSetDmx(const HTTPRequest *request,
HTTPResponse *response) {
if (request->CheckParameterExists(HELP_PARAMETER))
return ServeUsage(response,
"POST u=[universe], d=[DMX data (a comma separated list of values)]");
string dmx_data_str = request->GetPostParameter("d");
string uni_id = request->GetPostParameter("u");
unsigned int universe_id;
if (!StringToInt(uni_id, &universe_id))
return ServeHelpRedirect(response);
DmxBuffer buffer;
buffer.SetFromString(dmx_data_str);
if (!buffer.Size())
return m_server.ServeError(response, "Invalid DMX string");
ola::client::SendDMXArgs args(
NewSingleCallback(this, &OladHTTPServer::HandleBoolResponse, response));
m_client.SendDMX(universe_id, buffer, args);
return MHD_YES;
}
示例13: HandleSetDmx
/*
* Handle the set dmx command
* @param request the HttpRequest
* @param response the HttpResponse
* @returns MHD_NO or MHD_YES
*/
int OlaHttpServer::HandleSetDmx(const HttpRequest *request,
HttpResponse *response) {
string dmx_data_str = request->GetPostParameter("d");
string uni_id = request->GetPostParameter("u");
unsigned int universe_id;
if (!StringToInt(uni_id, &universe_id))
return m_server.ServeNotFound(response);
DmxBuffer buffer;
buffer.SetFromString(dmx_data_str);
if (!buffer.Size())
return m_server.ServeError(response, "Invalid DMX string");
bool ok = m_client.SendDmx(
universe_id,
buffer,
NewSingleCallback(this, &OlaHttpServer::HandleBoolResponse, response));
if (!ok)
return m_server.ServeError(response, K_BACKEND_DISCONNECTED_ERROR);
return MHD_YES;
}
示例14: SetSpacelight
/**
* @brief Handle the set DMX command
* @param request the HTTPRequest
* @param response the HTTPResponse
* @returns MHD_NO or MHD_YES
*/
int OladHTTPServer::SetSpacelight(const HTTPRequest *request,
HTTPResponse *response) {
if (request->CheckParameterExists(HELP_PARAMETER)) {
return ServeUsage(response,
"POST u=[universe], d=[DMX data (a comma separated list of values)]");
}
string dmx_data_str = request->GetPostParameter("d");
string uni_id = request->GetPostParameter("u");
DebugSumo(dmx_data_str);
curr_Intensity = dmx2sumo(dmx_data_str, 0);
curr_ColorTemperature = dmx2sumo(dmx_data_str, 1);
curr_DMX = dmx2sumo(dmx_data_str, 2);
cout << curr_Intensity << endl;
cout << curr_ColorTemperature << endl;
cout << curr_DMX << endl;
unsigned int universe_id;
if (!StringToInt(uni_id, &universe_id)) {
return ServeHelpRedirect(response);
}
DmxBuffer buffer;
buffer.SetFromString(dmx_data_str);
if (!buffer.Size()) {
return m_server.ServeError(response, "Invalid DMX string");
}
ola::client::SendDMXArgs args(
NewSingleCallback(this, &OladHTTPServer::HandleBoolResponse, response));
m_client.SendDMX(universe_id, buffer, args);
return MHD_YES;
}
示例15: HandleSetDmx
/*
* Handle the set dmx command
* @param request the HTTPRequest
* @param response the HTTPResponse
* @returns MHD_NO or MHD_YES
*/
int OladHTTPServer::HandleSetDmx(const HTTPRequest *request,
HTTPResponse *response) {
if (request->CheckParameterExists(HELP_PARAMETER))
return ServeUsage(response, "POST u=[universe], d=[DMX data]");
string dmx_data_str = request->GetPostParameter("d");
string uni_id = request->GetPostParameter("u");
unsigned int universe_id;
if (!StringToInt(uni_id, &universe_id))
return ServeHelpRedirect(response);
DmxBuffer buffer;
buffer.SetFromString(dmx_data_str);
if (!buffer.Size())
return m_server.ServeError(response, "Invalid DMX string");
bool ok = m_client.SendDmx(
universe_id,
buffer,
NewSingleCallback(this, &OladHTTPServer::HandleBoolResponse, response));
if (!ok)
return m_server.ServeError(response, K_BACKEND_DISCONNECTED_ERROR);
return MHD_YES;
}