Showing the changes to Source/Libraries/TimeSeriesPlatformLibrary/Samples/SimpleSubscribe.cpp (1 of 4 files). Show all
Unified · Split
| @@ -35,9 +35,9 @@ using namespace GSF::TimeSeries::Transport; · 34 unmodified lines | |||
| 35 | DataSubscriber Subscriber; | 35 | DataSubscriber Subscriber; |
| 36 | 36 | ||
| 37 | void RunSubscriber(string hostname, uint16_t port); | 37 | void RunSubscriber(string hostname, uint16_t port); |
| 38 | void ProcessMeasurements(DataSubscriber* source, vector<Measurement> newMeasurements); | 38 | void ProcessMeasurements(DataSubscriber* source, const vector<MeasurementPtr>& newMeasurements); |
| 39 | void DisplayStatusMessage(DataSubscriber* source, string message); | 39 | void DisplayStatusMessage(DataSubscriber* source, const string& message); |
| 40 | void DisplayErrorMessage(DataSubscriber* source, string message); | 40 | void 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 has | 107 | // 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. |
| 109 | void ProcessMeasurements(DataSubscriber* source, vector<Measurement> newMeasurements) | 109 | void 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. |
| 143 | void DisplayStatusMessage(DataSubscriber* source, string message) | 143 | void 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. |
| 149 | void DisplayErrorMessage(DataSubscriber* source, string message) | 149 | void DisplayErrorMessage(DataSubscriber* source, const string& message) |
| 150 | { | 150 | { |
| 151 | cerr << message << endl << endl; | 151 | cerr << message << endl << endl; |
| 152 | } | 152 | } |