ACT-CV - Machine Vision for Cognitive Modeling
ActCvClient.cpp
Go to the documentation of this file.
1 // -*- mode: c++; indent-tabs-mode: nil; c-basic-offset: 4; coding: iso-8859-1; -*-
2 
3 
4 /*
5 ACT-CV - Machine Vision for Cognitive Modeling
6 Copyright (c) 2008 Marc Halbruegge
7 
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22 
27 #if HAVE_ICE
28 
29 #include <iostream>
30 #include <Ice/Ice.h>
31 #include "ActCV.h"
32 
33 using namespace std;
34 using namespace ActCV;
35 
36 int
37 main(int argc, char* argv[])
38 {
39  int status = EXIT_SUCCESS;
40  Ice::CommunicatorPtr communicator;
41 
42  try
43  {
44  communicator = Ice::initialize(argc, argv);
45  VisionPrx vision = VisionPrx::checkedCast(
46  communicator->stringToProxy("vision:tcp -p 34985"));
47  KeyboardPrx keyboard = KeyboardPrx::checkedCast(
48  //communicator->stringToProxy("keyboard:tcp -h localhost -p 34985"));
49  communicator->stringToProxy("keyboard:tcp -p 34985"));
50 
51  if(!vision)
52  {
53  cerr << argv[0] << ": invalid proxy" << endl;
54  status = EXIT_FAILURE;
55  }
56  else
57  {
58  cout << vision->GetCurrent() << endl;
59  }
60 
61  if(!keyboard)
62  {
63  cerr << argv[0] << ": invalid proxy" << endl;
64  status = EXIT_FAILURE;
65  }
66  else
67  {
68  // 33 -> VK_PAGE_UP
69  // 38 -> VK_UP
70  keyboard->PressKey(38);
71  cout << "sent key 38" << endl;
72  }
73  }
74  catch(const Ice::Exception& ex)
75  {
76  cerr << ex << endl;
77  status = EXIT_FAILURE;
78  }
79 
80  if(communicator)
81  {
82  try
83  {
84  communicator->destroy();
85  }
86  catch(const Ice::Exception& ex)
87  {
88  cerr << ex << endl;
89  status = EXIT_FAILURE;
90  }
91  }
92 
93  return status;
94 }
95 
96 #else
97 // nothing here
98 int main() {
99  return 0;
100 };
101 #endif


ACT-CV - Machine Vision for Cognitive Modeling
© 2015 Marc Halbruegge (actcvlibrary@googlemail.com)