History

GSF: Updates to C++ projects, including improvements to TimeSeriesPlatformLibrary

J. Ritchie Carroll committed 8 years ago

Commit b18ee4d1 parent 8f4fe8b39 files · +24148 −603Browse files

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

Unified · Split

Source/Libraries/TimeSeriesPlatformLibrary/Samples/InstanceSubscribe.cpp+76−0
@@ -0,0 +1,76 @@
1+//******************************************************************************************************
2+// AdvancedSubscribe.cpp - Gbtc
3+//
4+// Copyright � 2010, Grid Protection Alliance. All Rights Reserved.
5+//
6+// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
7+// the NOTICE file distributed with this work for additional information regarding copyright ownership.
8+// The GPA licenses this file to you under the Eclipse Public License -v 1.0 (the "License"); you may
9+// not use this file except in compliance with the License. You may obtain a copy of the License at:
10+//
11+// http://www.opensource.org/licenses/eclipse-1.0.php
12+//
13+// Unless agreed to in writing, the subject software distributed under the License is distributed on an
14+// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
15+// License for the specific language governing permissions and limitations.
16+//
17+// Code Modification History:
18+// ----------------------------------------------------------------------------------------------------
19+// 04/06/2012 - Stephen C. Wills
20+// Generated original version of source code.
21+//
22+//******************************************************************************************************
23+
24+#include <iostream>
25+
26+#include "SubscriberHandler.h"
27+
28+SubscriberHandler* Subscriber1;
29+SubscriberHandler* Subscriber2;
30+
31+int main(int argc, char* argv[])
32+{
33+ string hostname;
34+ uint16_t port;
35+
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+ }
44+
45+ // Get hostname and port.
46+ hostname = argv[1];
47+ stringstream(argv[2]) >> port;
48+
49+ // Initialize the subscribers.
50+ Subscriber1 = new SubscriberHandler("Subscriber1");
51+ Subscriber2 = new SubscriberHandler("Subscriber2");
52+
53+ Subscriber1->Initialize(hostname, port);
54+ Subscriber2->Initialize(hostname, port);
55+
56+ Subscriber1->SetFilterExpression("FILTER TOP 5 ActiveMeasurements WHERE SignalType = 'FREQ'");
57+ Subscriber2->SetFilterExpression("FILTER TOP 10 ActiveMeasurements WHERE SignalType LIKE '%PHA'");
58+
59+ Subscriber1->Connect();
60+ Subscriber2->Connect();
61+
62+ // Wait until the user presses enter before quitting.
63+ string line;
64+ getline(cin, line);
65+
66+ Subscriber1->Disconnect();
67+ Subscriber2->Disconnect();
68+
69+ delete Subscriber1;
70+ delete Subscriber2;
71+
72+ // Disconnect the subscriber to stop background threads.
73+ cout << "Disconnected." << endl;
74+
75+ return 0;
76+}

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