IDevice.go 1005 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package lc
  2. import (
  3. "lc-smartX/util"
  4. )
  5. type Notifier interface {
  6. Notify()
  7. }
  8. // CorrectTimer 校时器接口
  9. type CorrectTimer interface {
  10. Correct()
  11. }
  12. func DoCorrectTime(a any) {
  13. if c, ok := a.(CorrectTimer); ok {
  14. c.Correct()
  15. }
  16. }
  17. // ReConnector 重连器接口
  18. type ReConnector interface {
  19. Reconnect()
  20. }
  21. func DoReconnect(a any) {
  22. if c, ok := a.(ReConnector); ok {
  23. c.Reconnect()
  24. }
  25. }
  26. // IDevice 抽象设备,包含屏和扬声器
  27. type IDevice interface {
  28. // Call 通知输出设备,输出信息。屏显示来车警告信息,扬声器语音提示
  29. Call()
  30. // Rollback 屏回滚到初始状态
  31. Rollback()
  32. ReConnector
  33. CorrectTimer
  34. }
  35. type IntersectionDevice struct {
  36. Info util.OutputDevice
  37. Screen Screener
  38. }
  39. func (id *IntersectionDevice) Call() {
  40. id.Screen.Display(1)
  41. }
  42. func (id *IntersectionDevice) Rollback() {
  43. id.Screen.Display(0)
  44. }
  45. func (id *IntersectionDevice) Reconnect() {
  46. DoReconnect(id.Screen)
  47. }
  48. func (id *IntersectionDevice) Correct() {
  49. DoCorrectTime(id.Screen)
  50. }