task_communication(7382).c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "task_communication.h"
  2. // 定义测试函数
  3. void test_isPointInPolygon() {
  4. // 定义多边形的经纬度坐标集合
  5. double polygonLat[] = {34.34934, 34.25916, 34.36221, 34.21619};
  6. double polygonLng[] = {108.84569, 108.80257, 109.03829, 109.05611};
  7. // 测试点在多边形内部的情况
  8. double point1Lat = 34.33312;
  9. double point1Lng = 108.8531;
  10. bool result1 = isPointInPolygon(point1Lat, point1Lng, polygonLat, polygonLng);
  11. printf("Test case 1: Point (%f, %f) is%s inside the polygon.\n", point1Lat, point1Lng, result1 ? "" : " not");
  12. double point2Lat = 34.20520;
  13. double point2Lng = 108.93078;
  14. bool result2 = isPointInPolygon(point2Lat, point2Lng, polygonLat, polygonLng);
  15. printf("Test case 2: Point (%f, %f) is%s inside the polygon.\n", point2Lat, point2Lng, result2 ? "" : " not");
  16. // 测试点在多边形边上的情况
  17. double point3Lat = 34.23195;
  18. double point3Lng = 108.81235;
  19. bool result3 = isPointInPolygon(point3Lat, point3Lng, polygonLat, polygonLng);
  20. printf("Test case 3: Point (%f, %f) is%s on the polygon edge.\n", point3Lat, point3Lng, result3 ? "" : " not");
  21. // 测试点在多边形外部的情况
  22. double point4Lat = 34.26728;
  23. double point4Lng = 108.78992;
  24. bool result4 = isPointInPolygon(point4Lat, point4Lng, polygonLat, polygonLng);
  25. printf("Test case 4: Point (%f, %f) is%s outside the polygon.\n", point4Lat, point4Lng, result4 ? "" : " not");
  26. }
  27. /* USER CODE BEGIN Header_Task_communication */
  28. /**
  29. * @brief Function implementing the communication thread.
  30. * @param argument: Not used
  31. * @retval None
  32. */
  33. /* USER CODE END Header_Task_communication */
  34. void task_communication_content(void)
  35. {
  36. // unsigned long times = 0;
  37. LED0_TOGGLE(); // 灯翻转
  38. EC800_FTP_OTA_Upgrade(); // OTA升级
  39. // test_isPointInPolygon(); // 电子围栏
  40. rs485_poll_sendReceive(); // 与车进行通信
  41. // times = getRunTimeCounterValue();
  42. // printf("test_isPointInPolygon:%ld\r\n", times);
  43. osDelay(1000);
  44. }