μHAL (v2.6.5)
Part of the IPbus software repository
DummyHardwareTcp.cxx
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 
4  This file is part of uHAL.
5 
6  uHAL is a hardware access library and programming framework
7  originally developed for upgrades of the Level-1 trigger of the CMS
8  experiment at CERN.
9 
10  uHAL is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  uHAL is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with uHAL. If not, see <http://www.gnu.org/licenses/>.
22 
23  Marc Magrans de Abril, CERN
24  email: marc.magrans.de.abril <AT> cern.ch
25 
26  Andrew Rose, Imperial College, London
27  email: awr01 <AT> imperial.ac.uk
28 
29 ---------------------------------------------------------------------------
30 */
31 
34 
35 using namespace uhal;
36 using namespace uhal::tests;
37 
38 int main ( int argc, char* argv[] )
39 {
41 
42  if ( lOptions.version == 1 )
43  {
44  TCPDummyHardware<1,3> lDummyHardware ( lOptions.port , lOptions.delay , false );
45 
46  while ( true ) //Is this necessary with the nested "while(true)"'s in the run function?
47  {
48  lDummyHardware.run();
49  }
50  }
51  else if ( lOptions.version == 2 )
52  {
53  TCPDummyHardware<2,0> lDummyHardware ( lOptions.port , lOptions.delay, lOptions.bigendian );
54 
55  while ( true ) //Is this necessary with the nested "while(true)"'s in the run function?
56  {
57  lDummyHardware.run();
58  }
59  }
60  else
61  {
62  log ( Error() , "Unknown IPbus version, " , Integer ( lOptions.version ) );
63  return 1;
64  }
65 
66  return 0;
67 }
uint32_t delay
The delay in seconds between the request and response of the first IPbus transaction.
bool bigendian
Whether we use the big-endian hack.
static DummyHardwareOptions parseFromCommandLine(int argc, char *argv[])
Static function to parse the command line arguments into a struct containing the information.
ErrorLevel Error
Definition: LogLevels.cpp:61
Concrete implementation of emulator of hardware using TCP.
Struct to store the dummy hardware command line options.
int main(int argc, char *argv[])
uint32_t version
IPbus version number - 1 or 2.
uint16_t port
The port used by the dummy hardware.
void run()
Concrete implementation of the run function Starts the TCP server and runs indefinitely, until exception or user kills the server.
_Integer< T, IntFmt<> > Integer(const T &aT)
Forward declare a function which creates an instance of the ultra-lightweight wrapper from an integer...