main_test.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #include "db_api/CDBSingletonDefine.h"
  3. #include"module_service/module_area.h"
  4. #include"module_service/module_mgr.h"
  5. void test_find_path(const point&p1,const point&p2)
  6. {
  7. printf("\nfind-path: from=(%.3lf,%.3lf),to=(%.3lf,%.3lf)\n",p1.x,p1.y,p2.x,p2.y);
  8. std::vector<point> rc=card_path::inst().find_path(p1,p2);
  9. for(uint32_t i=0;i<rc.size();i++)
  10. printf("x=%.3lf,y=%.3lf\n",rc[i].x,rc[i].y);
  11. }
  12. struct test_Sa{
  13. static void test_savedata2db(void * p)
  14. {
  15. while(true)
  16. {
  17. std::string sql = "CALL add_att_staff(0010000002323, 2323, '2018-12-14 14:00:14', '2018-12-14 14:00:14', 0, 0, 0.000);";
  18. sDBConnPool.PushAsync(sql.c_str());
  19. //boost::this_thread::sleep( boost::posix_time::microseconds( 10000 ) );
  20. usleep(1000*1000);
  21. }
  22. }
  23. static void test_query(void *p)
  24. {
  25. std::string sql = "SELECT ve.vehicle_id, ve.card_id, c.card_type_id, \
  26. ve.dept_id, ve.group_id, v.vehicle_type_id, vt.vehicle_level_id, \
  27. vt.is_railroad AS vt_is_railroad,ve.need_display ,ve.power_alarm,\
  28. vt.vehicle_category_id,v.bigger_car_flag,vc.over_speed \
  29. FROM dat_vehicle_extend ve \
  30. LEFT JOIN dat_vehicle v ON ve.vehicle_id = v.vehicle_id \
  31. LEFT JOIN dat_card c ON ve.card_id = c.card_id \
  32. LEFT JOIN dat_dept d ON ve.dept_id = d.dept_id \
  33. LEFT JOIN dat_group g ON ve.group_id = g.group_id \
  34. LEFT JOIN dat_vehicle_type vt ON v.vehicle_type_id = vt.vehicle_type_id \
  35. LEFT JOIN dat_vehicle_category vc ON vc.vehicle_category_id = vt.vehicle_category_id \
  36. WHERE c.state_id = 0";
  37. std::string Error;
  38. YADB::CDBResultSet DBRes;
  39. while(true)
  40. {
  41. if (!sDBConnPool.Query(sql.c_str(),DBRes,Error))
  42. {
  43. printf(" Error = %s \n",Error.c_str());
  44. }
  45. usleep(10);
  46. }
  47. }
  48. static void Test_JsonDataSend(void * p)
  49. {
  50. std::string text = "";
  51. FILE * pfile = fopen("message_error.json","r");
  52. if ( NULL != pfile)
  53. {
  54. char p[10240] = {0};
  55. while(!feof(pfile))
  56. {
  57. memset(p,0,sizeof(p));
  58. fread(p,1,sizeof(p) - 1,pfile);
  59. text += std::string(p);
  60. }
  61. fclose(pfile);
  62. }
  63. int count = 0;
  64. while(true)
  65. {
  66. swsClientMgr.send(JSON_CMD_VALUE_PUSH,text);
  67. usleep(1000*1000*2);
  68. printf("WSClient Send DataLen=%d count=%d \n",(int)text.length(),count++);
  69. }
  70. }
  71. };
  72. void test_createthread()
  73. {
  74. for (int i = 1 ; i < 1 ; i++)
  75. {
  76. new std::thread( std::bind( &test_Sa::Test_JsonDataSend, &i ) );
  77. }
  78. }