lineDetection.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package isapi
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "io/ioutil"
  6. "lc-fangdaosha/isapi"
  7. )
  8. // 越界侦测
  9. type LineDetectionApi struct {
  10. }
  11. // GetLineDetectionCap 获取越界侦测能力
  12. func (api *LineDetectionApi) GetLineDetectionCap(c *gin.Context) {
  13. host, err := GetHost(c)
  14. if err != nil {
  15. logrus.Errorf("获取host失败:%s", err.Error())
  16. return
  17. }
  18. isapi.TouChuan(host, isapi.GetLineDetectionCap, nil, c)
  19. }
  20. // GetSizeLd 获取越界侦测目标的尺寸
  21. func (api *LineDetectionApi) GetSizeLd(c *gin.Context) {
  22. host, err := GetHost(c)
  23. if err != nil {
  24. logrus.Errorf("获取host失败:%s", err.Error())
  25. return
  26. }
  27. isapi.TouChuan(host, isapi.GetLineDetectionCal, nil, c)
  28. }
  29. // PutSizeLd 配置越界侦测目标尺寸
  30. func (api *LineDetectionApi) PutSizeLd(c *gin.Context) {
  31. defer c.Request.Body.Close()
  32. all, err := ioutil.ReadAll(c.Request.Body)
  33. if err != nil {
  34. logrus.Errorf("读取数据失败:%e\n", err)
  35. }
  36. host, err := GetHost(c)
  37. if err != nil {
  38. logrus.Errorf("获取设备连接失败:%e\n", err)
  39. return
  40. }
  41. isapi.TouChuan(host, isapi.PutLineDetectionCal, all, c)
  42. }
  43. // GetLineDetection 获取越界侦测能力
  44. func (api *LineDetectionApi) GetLineDetection(c *gin.Context) {
  45. host, err := GetHost(c)
  46. if err != nil {
  47. logrus.Errorf("获取host失败:%s", err.Error())
  48. return
  49. }
  50. isapi.TouChuan(host, isapi.GetLineDetection, nil, c)
  51. }
  52. // PutLineDetection 配置越界侦测能力
  53. func (api *LineDetectionApi) PutLineDetection(c *gin.Context) {
  54. defer c.Request.Body.Close()
  55. all, err := ioutil.ReadAll(c.Request.Body)
  56. if err != nil {
  57. logrus.Errorf("读取数据失败:%e\n", err)
  58. }
  59. host, err := GetHost(c)
  60. if err != nil {
  61. logrus.Errorf("获取设备连接失败:%e\n", err)
  62. return
  63. }
  64. isapi.TouChuan(host, isapi.PutLineDetection, all, c)
  65. }