File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed
src/dds.net-connector-cpp.app Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change 99using namespace std ;
1010using namespace dds ::net::connector;
1111
12+
1213void wait_for_exit_key ();
14+ void my_double_consumer (std::string& variableName, double variableValue);
15+
1316
1417int main ()
1518{
@@ -27,20 +30,43 @@ int main()
2730 appName,
2831 serverIP, serverPort,
2932 new ConsoleLogger ());
33+
34+ connector.registerDoubleConsumer (" TESTX" , my_double_consumer, ON_CHANGE);
35+ connector.registerDoubleConsumer (" TESTY" , my_double_consumer, ON_CHANGE);
36+
37+ connector.start ();
38+
39+ wait_for_exit_key ();
3040 }
3141 catch (exception& ex)
3242 {
3343 cout << " Error! " << ex.what () << endl;
3444 }
3545
36- wait_for_exit_key ();
37-
3846 cout << endl << endl << endl;
3947}
4048
49+
4150void wait_for_exit_key ()
4251{
4352 char ch;
4453 while ((ch = getc (stdin)) != ' C' );
4554}
4655
56+
57+ static double x, y;
58+
59+ void my_double_consumer (std::string& variableName, double variableValue)
60+ {
61+ if (variableName == " TESTX" )
62+ {
63+ x = variableValue;
64+ }
65+ else if (variableName == " TESTY" )
66+ {
67+ y = variableValue;
68+
69+ cout << " TESTX, TESTY = " << x << " , " << y << endl;
70+ }
71+ }
72+
You can’t perform that action at this time.
0 commit comments