History

TimeSeriesPlatformLibrary: (1) Fixed issue with SignalReference parser, (2) converted tabs to spaces, (3) tested 64-bit compilation

J. Ritchie Carroll committed 8 years ago

Commit 3dfa6731 parent dab518924 files · +3167 −3043Browse files

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

Unified · Split

Source/Libraries/TimeSeriesPlatformLibrary/Samples/InstanceSubscribe.cpp+55−37
@@ -1,5 +1,5 @@
11 //******************************************************************************************************
2−// AdvancedSubscribe.cpp - Gbtc
2+// InstanceSubscribe.cpp - Gbtc
33 //
44 // Copyright � 2010, Grid Protection Alliance. All Rights Reserved.
55 //
@@ -16,7 +16,7 @@ · 10 unmodified lines
1616 //
1717 // Code Modification History:
1818 // ----------------------------------------------------------------------------------------------------
19−// 04/06/2012 - Stephen C. Wills
19+// 03/27/2018 - J. Ritchie Carroll
2020 // Generated original version of source code.
2121 //
2222 //******************************************************************************************************
@@ -25,52 +25,70 @@ · 2 unmodified lines
2525
2626 #include "SubscriberHandler.h"
2727
28−SubscriberHandler* Subscriber1;
29−SubscriberHandler* Subscriber2;
28+#define TotalInstances 3
29+
30+SubscriberHandler* Subscriber[TotalInstances];
3031
3132 int main(int argc, char* argv[])
3233 {
33− string hostname;
34− uint16_t port;
34+ string hostname;
35+ uint16_t port;
36+
37+ // Ensure that the necessary
38+ // command line arguments are given.
39+ if (argc < 3)
40+ {
41+ cout << "Usage:" << endl;
42+ cout << " InstanceSubscribe HOSTNAME PORT" << endl;
43+ return 0;
44+ }
45+
46+ // Get hostname and port.
47+ hostname = argv[1];
48+ stringstream(argv[2]) >> port;
3549
36− // Ensure that the necessary
37− // command line arguments are given.
38− if (argc < 3)
39− {
40− cout << "Usage:" << endl;
41− cout << " AdvancedSubscribe HOSTNAME PORT" << endl;
42− return 0;
43− }
50+ // Initialize the subscribers.
51+ for (size_t i = 0; i < TotalInstances; i++)
52+ {
53+ stringstream name;
54+
55+ name << "Subscriber" << (i + 1);
4456
45− // Get hostname and port.
46− hostname = argv[1];
47− stringstream(argv[2]) >> port;
57+ SubscriberHandler* subscriber = new SubscriberHandler(name.str());
4858
49− // Initialize the subscribers.
50− Subscriber1 = new SubscriberHandler("Subscriber1");
51− Subscriber2 = new SubscriberHandler("Subscriber2");
59+ subscriber->Initialize(hostname, port);
5260
53− Subscriber1->Initialize(hostname, port);
54− Subscriber2->Initialize(hostname, port);
61+ switch (i)
62+ {
63+ case 1:
64+ subscriber->SetFilterExpression("FILTER TOP 5 ActiveMeasurements WHERE SignalType = 'FREQ'");
65+ break;
66+ case 2:
67+ subscriber->SetFilterExpression("FILTER TOP 10 ActiveMeasurements WHERE SignalType LIKE '%PHA'");
68+ break;
69+ default:
70+ subscriber->SetFilterExpression("FILTER TOP 10 ActiveMeasurements WHERE SignalType LIKE '%PHM'");
71+ break;
72+ }
5573
56− Subscriber1->SetFilterExpression("FILTER TOP 5 ActiveMeasurements WHERE SignalType = 'FREQ'");
57− Subscriber2->SetFilterExpression("FILTER TOP 10 ActiveMeasurements WHERE SignalType LIKE '%PHA'");
74+ subscriber->Connect();
5875
59− Subscriber1->Connect();
60− Subscriber2->Connect();
76+ Subscriber[i] = subscriber;
77+ }
6178
62− // Wait until the user presses enter before quitting.
63− string line;
64− getline(cin, line);
79+ // Wait until the user presses enter before quitting.
80+ string line;
81+ getline(cin, line);
6582
66− Subscriber1->Disconnect();
67− Subscriber2->Disconnect();
83+ // Shutdown subscriber instances
84+ for (size_t i = 0; i < TotalInstances; i++)
85+ {
86+ Subscriber[i]->Disconnect();
87+ delete Subscriber[i];
88+ }
6889
69− delete Subscriber1;
70− delete Subscriber2;
71−
72− // Disconnect the subscriber to stop background threads.
73− cout << "Disconnected." << endl;
90+ // Disconnect the subscriber to stop background threads.
91+ cout << "Disconnected." << endl;
7492
75− return 0;
93+ return 0;
7694 }

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