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 @@
1//******************************************************************************************************1//******************************************************************************************************
2// AdvancedSubscribe.cpp - Gbtc2// InstanceSubscribe.cpp - Gbtc
3//3//
4// Copyright � 2010, Grid Protection Alliance. All Rights Reserved.4// Copyright � 2010, Grid Protection Alliance. All Rights Reserved.
5//5//
@@ -16,7 +16,7 @@ · 10 unmodified lines
16//16//
17// Code Modification History:17// Code Modification History:
18// ----------------------------------------------------------------------------------------------------18// ----------------------------------------------------------------------------------------------------
19// 04/06/2012 - Stephen C. Wills19// 03/27/2018 - J. Ritchie Carroll
20// Generated original version of source code.20// Generated original version of source code.
21//21//
22//******************************************************************************************************22//******************************************************************************************************
@@ -25,52 +25,70 @@ · 2 unmodified lines
25 25
26#include "SubscriberHandler.h"26#include "SubscriberHandler.h"
27 27
28SubscriberHandler* Subscriber1;28#define TotalInstances 3
29SubscriberHandler* Subscriber2;29
30SubscriberHandler* Subscriber[TotalInstances];
30 31
31int main(int argc, char* argv[])32int main(int argc, char* argv[])
32{33{
33 string hostname;34 string hostname;
34 uint16_t port;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;
35 49
36 // Ensure that the necessary50 // Initialize the subscribers.
37 // command line arguments are given.51 for (size_t i = 0; i < TotalInstances; i++)
38 if (argc < 3)52 {
39 {53 stringstream name;
40 cout << "Usage:" << endl;54
41 cout << " AdvancedSubscribe HOSTNAME PORT" << endl;55 name << "Subscriber" << (i + 1);
42 return 0;
43 }
44 56
45 // Get hostname and port.57 SubscriberHandler* subscriber = new SubscriberHandler(name.str());
46 hostname = argv[1];
47 stringstream(argv[2]) >> port;
48 58
49 // Initialize the subscribers.59 subscriber->Initialize(hostname, port);
50 Subscriber1 = new SubscriberHandler("Subscriber1");
51 Subscriber2 = new SubscriberHandler("Subscriber2");
52 60
53 Subscriber1->Initialize(hostname, port);61 switch (i)
54 Subscriber2->Initialize(hostname, port);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 }
55 73
56 Subscriber1->SetFilterExpression("FILTER TOP 5 ActiveMeasurements WHERE SignalType = 'FREQ'");74 subscriber->Connect();
57 Subscriber2->SetFilterExpression("FILTER TOP 10 ActiveMeasurements WHERE SignalType LIKE '%PHA'");
58 75
59 Subscriber1->Connect();76 Subscriber[i] = subscriber;
60 Subscriber2->Connect();77 }
61 78
62 // Wait until the user presses enter before quitting.79 // Wait until the user presses enter before quitting.
63 string line;80 string line;
64 getline(cin, line);81 getline(cin, line);
65 82
66 Subscriber1->Disconnect();83 // Shutdown subscriber instances
67 Subscriber2->Disconnect();84 for (size_t i = 0; i < TotalInstances; i++)
85 {
86 Subscriber[i]->Disconnect();
87 delete Subscriber[i];
88 }
68 89
69 delete Subscriber1;90 // Disconnect the subscriber to stop background threads.
70 delete Subscriber2;91 cout << "Disconnected." << endl;
71
72 // Disconnect the subscriber to stop background threads.
73 cout << "Disconnected." << endl;
74 92
75 return 0;93 return 0;
76}94}

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