History

TimeSeriesPlatformLibrary: Fixed sample applications.

J. Ritchie Carroll committed 8 years ago

Commit 3fb02031 parent b18ee4d4 files · +33 −33Browse files

Showing the changes to Source/Libraries/TimeSeriesPlatformLibrary/Samples/SimpleSubscribe.cpp (1 of 4 files). Show all

Unified · Split

Source/Libraries/TimeSeriesPlatformLibrary/Samples/SimpleSubscribe.cpp+10−10
@@ -35,9 +35,9 @@ using namespace GSF::TimeSeries::Transport; · 34 unmodified lines
35DataSubscriber Subscriber;35DataSubscriber Subscriber;
36 36
37void RunSubscriber(string hostname, uint16_t port);37void RunSubscriber(string hostname, uint16_t port);
38void ProcessMeasurements(DataSubscriber* source, vector<Measurement> newMeasurements);38void ProcessMeasurements(DataSubscriber* source, const vector<MeasurementPtr>& newMeasurements);
39void DisplayStatusMessage(DataSubscriber* source, string message);39void DisplayStatusMessage(DataSubscriber* source, const string& message);
40void DisplayErrorMessage(DataSubscriber* source, string message);40void DisplayErrorMessage(DataSubscriber* source, const string& message);
41 41
42// Sample application to demonstrate the most simple use of the subscriber API.42// Sample application to demonstrate the most simple use of the subscriber API.
43//43//
@@ -106,7 +106,7 @@ void RunSubscriber(string hostname, uint16_t port) · 62 unmodified lines
106 106
107// Callback which is called when the subscriber has107// Callback which is called when the subscriber has
108// received a new packet of measurements from the publisher.108// received a new packet of measurements from the publisher.
109void ProcessMeasurements(DataSubscriber* source, vector<Measurement> newMeasurements)109void ProcessMeasurements(DataSubscriber* source, const vector<MeasurementPtr>& newMeasurements)
110{110{
111 const string TimestampFormat = "%Y-%m-%d %H:%M:%S.%f";111 const string TimestampFormat = "%Y-%m-%d %H:%M:%S.%f";
112 const size_t MaxTimestampSize = 80;112 const size_t MaxTimestampSize = 80;
@@ -120,17 +120,17 @@ void ProcessMeasurements(DataSubscriber* source, vector<Measurement> newMeasurem · 7 unmodified lines
120 // seconds (assuming 30 calls per second).120 // seconds (assuming 30 calls per second).
121 if (processCount % 150 == 0)121 if (processCount % 150 == 0)
122 {122 {
123 cout << Subscriber.GetTotalMeasurementsReceived() << " measurements received so far..." << endl;123 cout << source->GetTotalMeasurementsReceived() << " measurements received so far..." << endl;
124 124
125 if (newMeasurements.size() > 0)125 if (!newMeasurements.empty())
126 {126 {
127 if (TicksToString(timestamp, MaxTimestampSize, TimestampFormat, newMeasurements[0].Timestamp))127 if (TicksToString(timestamp, MaxTimestampSize, TimestampFormat, newMeasurements[0]->Timestamp))
128 cout << "Timestamp: " << string(timestamp) << endl;128 cout << "Timestamp: " << string(timestamp) << endl;
129 129
130 cout << "Point\tValue" << endl;130 cout << "Point\tValue" << endl;
131 131
132 for (i = 0; i < newMeasurements.size(); ++i)132 for (i = 0; i < newMeasurements.size(); ++i)
133 cout << newMeasurements[i].ID << '\t' << newMeasurements[i].Value << endl;133 cout << newMeasurements[i]->ID << '\t' << newMeasurements[i]->Value << endl;
134 134
135 cout << endl;135 cout << endl;
136 }136 }
@@ -140,13 +140,13 @@ void ProcessMeasurements(DataSubscriber* source, vector<Measurement> newMeasurem · 3 unmodified lines
140}140}
141 141
142// Callback which is called to display status messages from the subscriber.142// Callback which is called to display status messages from the subscriber.
143void DisplayStatusMessage(DataSubscriber* source, string message)143void DisplayStatusMessage(DataSubscriber* source, const string& message)
144{144{
145 cout << message << endl << endl;145 cout << message << endl << endl;
146}146}
147 147
148// Callback which is called to display error messages from the connector and subscriber.148// Callback which is called to display error messages from the connector and subscriber.
149void DisplayErrorMessage(DataSubscriber* source, string message)149void DisplayErrorMessage(DataSubscriber* source, const string& message)
150{150{
151 cerr << message << endl << endl;151 cerr << message << endl << endl;
152}152}

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