proc_text.go 907 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package mcu_ctrl_board
  2. /*
  3. #include "mcu_ctrl_board.h"
  4. */
  5. import "C"
  6. import (
  7. "path/filepath"
  8. "strings"
  9. "hnyfkj.com.cn/rtu/linux/baseapp"
  10. "hnyfkj.com.cn/rtu/linux/rtu/cbd/utils"
  11. )
  12. func playTextAudio(text string) bool {
  13. audioFile := ""
  14. switch text {
  15. case "button":
  16. audioFile = "voices/button.wav"
  17. case "reset":
  18. audioFile = "voices/reset.wav"
  19. case "save":
  20. audioFile = "voices/save.wav"
  21. case "takephoto.mp3":
  22. audioFile = "voices/takephoto.wav"
  23. case "workdone":
  24. audioFile = "voices/workdone.wav"
  25. case "workstart.mp3":
  26. audioFile = "voices/workstart.wav"
  27. default:
  28. return false
  29. }
  30. utils.PlayAudioAsync(filepath.Join(baseapp.EXEC_DIR, audioFile))
  31. return true
  32. }
  33. // 处理TEXT报文 支持老版协议
  34. func processText(textStr string) *C.char {
  35. text := strings.TrimSpace(textStr)
  36. if !playTextAudio(text) {
  37. baseapp.Logger.Warnf("未知的TEXT命令: %s", text)
  38. }
  39. return nil
  40. }