ICP  1
Qxtrm_test_server.cpp
Go to the documentation of this file.
1 // Qxtrm_test_server.cpp : Defines the entry point for the console application.
2 //
3 
4 #include "stdafx.h"
5 #include "Poco/Util/Application.h"
6 #include "Poco/Util/ServerApplication.h"
7 #include "Poco/String.h"
8 #include "Poco/Environment.h"
9 #include "Poco/Format.h"
10 
11 #include "../Qxtrm_driver/Qxtrm_driver.h"
12 #include "../newicp/icptimer.h"
13 
14 class MyServerApp : public Poco::Util::ServerApplication
15 {
16  virtual int main(const std::vector<std::string>& args);
17 };
18 
19 int MyServerApp::main(const std::vector<std::string>& args)
20 {
21  if (config().getBool("application.runAsService", false))
22  {
23  // we are a windows service
24  }
25  std::cerr << "press a key";
26  getc(stdin);
27  try
28  {
29  std::string app_dir = config().getString("application.dir");
30  std::string config_file = app_dir + "..\\..\\..\\qxtrm_config.xml";
31  if ( access(config_file.c_str(), 04) == -1 )
32  {
33  config_file = app_dir + "qxtrm_config.xml";
34  }
35  std::cerr << "Using config file " << config_file << std::endl;
36  std::cerr << "Initialising Qxtrm connection ... ";
37  int nwords = 25*1024*1024;
38 #if 1
39  Qxtrm_driver qx_driver(config_file, "host", 0, 1, true);
40 #else
41  Qxtrm_driver qx_driver(config_file, "host_loopback", "process1");
42  std::cerr << "Creating channel eth1_RDMA1_loop ... ";
43  Poco::SharedPtr<Qxtrm_channel> rdma_mem_loop = qx_driver.createChannel("eth1_RDMA1_loop");
44  std::cerr << "Creating channel eth1_RDMA2_loop ... ";
45  Poco::SharedPtr<Qxtrm_channel> rdma_reg_loop = qx_driver.createChannel("eth1_RDMA2_loop");
46  uint32_t* local_mem = new uint32_t[nwords];
47  uint32_t* local_reg = new uint32_t[nwords];
48  rdma_mem_loop->RDMARegisterMemory(local_mem, nwords * 4, 0x0);
49  rdma_reg_loop->RDMARegisterMemory(local_reg, nwords * 4, 0x0);
50 #endif
51  std::cerr << "DONE" << std::endl;
52  std::cerr << "Creating channel eth1_RDMA1 ... ";
53  Poco::SharedPtr<Qxtrm_channel> rdma_mem = qx_driver.createChannel("eth1_RDMA1");
54  std::cerr << "DONE" << std::endl;
55  std::cerr << "Creating channel eth1_RDMA2 ... ";
56  Poco::SharedPtr<Qxtrm_channel> rdma_reg = qx_driver.createChannel("eth1_RDMA2");
57  std::cerr << "DONE" << std::endl;
58  // reset interface
59 // rdma_reg->RDMAWrite(1, 0x00030010);
60 // rdma_reg->RDMAWrite(1, 0x00030014);
61 // rdma_reg->RDMAWrite(1, 0x00030018);
62 // rdma_reg->RDMAWrite(1, 0x0003001C);
63  uint32_t raw_frames;
64 // rdma_reg->RDMARead(raw_frames, 0x0);
65 // std::cerr << "reg " << local_reg[0x00000230 / 4] << std::endl;
66 
67  rdma_reg->RDMAWrite(53, 0x00000230);
68 // std::cerr << "reg " << local_reg[0x00000230 / 4] << std::endl;
69  char* mem_buffer = new char[nwords * 4];
70 // ICPTimer tim("READ tests");
71 // rdma_mem->RDMARead(mem_buffer, nbytes, 0x0);
72 // tim.info("100Mb", std::cerr);
73  ICPTimer tim("WRITE tests");
74  rdma_mem->RDMAWrite(mem_buffer, nwords * 4, 0x0);
75  tim.info("100Mb", std::cerr);
76  qx_driver.channelStatus(std::cerr);
77  qx_driver.channelTransferStats(std::cerr);
78  delete[] mem_buffer;
79 // waitForTerminationRequest();
80  }
81  catch(const std::exception& ex)
82  {
83  std::cerr << ex.what() << std::endl;
84  }
85  return EXIT_OK;
86 }
87 
88 int _tmain(int argc, _TCHAR* argv[])
89 {
90  MyServerApp app;
91  return app.run(argc, argv);
92 }
Poco::SharedPtr< Qxtrm_channel > createChannel(const std::string &chan_name)
std::ostream & channelTransferStats(std::ostream &os) const
std::ostream & channelStatus(std::ostream &os) const
virtual int main(const std::vector< std::string > &args)
double info(const char *title, std::ostream &os, bool add_nl=true)
Definition: icptimer.h:83
int _tmain(int argc, _TCHAR *argv[])
Definition: newicp.cpp:11