History

GSF.TimeSeries: Added a handler for a new ServerCommand so that the DataPublisher may receive measurements from a DataSubscriber.

StephenCWills committed 9 years ago

Commit 4d2b00a1 parent bf057666 files · +197 −7Browse files

Showing the changes to Source/Libraries/TimeSeriesPlatformLibrary/Transport/DataSubscriber.cpp (1 of 6 files). Show all

Unified · Split

Source/Libraries/TimeSeriesPlatformLibrary/Transport/DataSubscriber.cpp+32−0
@@ -852,6 +852,38 @@ void gsfts::Transport::DataSubscriber::SendServerCommand(uint8_t commandCode) · 851 unmodified lines
852852 SendServerCommand(commandCode, 0, 0, 0);
853853 }
854854
855+// Sends a command along with the given message to the server.
856+void gsfts::Transport::DataSubscriber::SendServerCommand(uint8_t commandCode, std::string message)
857+{
858+ const std::size_t CharSize = sizeof(char);
859+
860+ uint32_t bufferSize;
861+ std::vector<uint8_t> buffer;
862+
863+ uint8_t* messagePtr;
864+ uint32_t messageSize;
865+ uint32_t bigEndianMessageSize;
866+ uint8_t* bigEndianMessageSizePtr;
867+
868+ messagePtr = (uint8_t*)&message[0];
869+ messageSize = (uint32_t)(message.size() * CharSize);
870+ bigEndianMessageSize = m_endianConverter.ConvertBigEndian(messageSize);
871+ bigEndianMessageSizePtr = (uint8_t*)&bigEndianMessageSize;
872+
873+ bufferSize = 4 + messageSize;
874+ buffer.reserve(bufferSize);
875+
876+ buffer[0] = bigEndianMessageSizePtr[0];
877+ buffer[1] = bigEndianMessageSizePtr[1];
878+ buffer[2] = bigEndianMessageSizePtr[2];
879+ buffer[3] = bigEndianMessageSizePtr[3];
880+
881+ for (i = 0; i < messageSize; ++i)
882+ buffer[4 + i] = messagePtr[i];
883+
884+ SendServerCommand(commandCode, &buffer[0], 0, bufferSize);
885+}
886+
855887 // Sends a command along with the given data to the server.
856888 void gsfts::Transport::DataSubscriber::SendServerCommand(uint8_t commandCode, uint8_t* data, std::size_t offset, std::size_t length)
857889 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t