|
@@ -12,7 +12,7 @@ import (
|
|
|
|
|
|
// Screener 屏接口
|
|
// Screener 屏接口
|
|
type Screener interface {
|
|
type Screener interface {
|
|
- Display(string)
|
|
|
|
|
|
+ Display(int)
|
|
}
|
|
}
|
|
|
|
|
|
type Screen struct {
|
|
type Screen struct {
|
|
@@ -35,11 +35,11 @@ func NewScreen(name string, ip, port string) *Screen {
|
|
return s
|
|
return s
|
|
}
|
|
}
|
|
|
|
|
|
-func (s *Screen) Display(str string) {
|
|
|
|
|
|
+func (s *Screen) Display(id int) {
|
|
if !s.getLiveState() {
|
|
if !s.getLiveState() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- s.Lock(1, str)
|
|
|
|
|
|
+ s.SendRam(id)
|
|
}
|
|
}
|
|
|
|
|
|
// Correct 校正时间
|
|
// Correct 校正时间
|
|
@@ -109,8 +109,32 @@ const (
|
|
White
|
|
White
|
|
)
|
|
)
|
|
|
|
|
|
-// TextRam 发送动态区节目
|
|
|
|
-func (s *Screen) TextRam(ff FlashFile) {
|
|
|
|
|
|
+const (
|
|
|
|
+ Normal = 0
|
|
|
|
+ Warn = 1
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+// 发送动态区节目 0正常页面 1红色提醒页面
|
|
|
|
+func (s *Screen) SendRam(id int) {
|
|
|
|
+ file := FlashFile{}
|
|
|
|
+ if id == 0 {
|
|
|
|
+ file.SetMsg("减速慢行", Yellow)
|
|
|
|
+ file.SetMode(DefaultRunMode, DefaultDisplayMode)
|
|
|
|
+ file.SetOrigin(0, true, 0)
|
|
|
|
+ file.SetArea(64, true, 16)
|
|
|
|
+ s.TextRam(file, false)
|
|
|
|
+ } else {
|
|
|
|
+ file.SetMsg("支路来车", Red)
|
|
|
|
+ file.SetSoundData("支路来车,请减速")
|
|
|
|
+ file.SetMode(DefaultRunMode, DefaultDisplayMode)
|
|
|
|
+ file.SetOrigin(0, true, 0)
|
|
|
|
+ file.SetArea(64, true, 16)
|
|
|
|
+ s.TextRam(file, true)
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// TextRam 发送动态区节目实现
|
|
|
|
+func (s *Screen) TextRam(ff FlashFile, needSpeak bool) {
|
|
if !s.getLiveState() {
|
|
if !s.getLiveState() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -122,16 +146,29 @@ func (s *Screen) TextRam(ff FlashFile) {
|
|
} else {
|
|
} else {
|
|
bytes, _ = encoder.Bytes([]byte("\\C" + strconv.Itoa(int(ff.color)) + ff.msg))
|
|
bytes, _ = encoder.Bytes([]byte("\\C" + strconv.Itoa(int(ff.color)) + ff.msg))
|
|
}
|
|
}
|
|
- area := bx.NewBxAreaDynamic(s.StateInfo.DynaAreaNum, 0, byte(ff.dispMode), ff.originX, ff.originY, ff.width, ff.height, bytes, false)
|
|
|
|
- areas = append(areas, area)
|
|
|
|
|
|
+ if needSpeak {
|
|
|
|
+ soundData, _ := encoder.Bytes([]byte(ff.soundData))
|
|
|
|
+ area := bx.NewBxAreaDynamic(0, 1, byte(ff.dispMode), ff.originX, ff.originY, ff.width,
|
|
|
|
+ ff.height, bytes, soundData, false)
|
|
|
|
+ areas = append(areas, area)
|
|
|
|
+ } else {
|
|
|
|
+ area := bx.NewBxAreaProgram(0, 1, byte(ff.dispMode), ff.originX, ff.originY, ff.width,
|
|
|
|
+ ff.height, bytes, false)
|
|
|
|
+ areas = append(areas, area)
|
|
|
|
+ }
|
|
|
|
+
|
|
//
|
|
//
|
|
cmd := bx.NewBxCmdSendDynamicArea(areas)
|
|
cmd := bx.NewBxCmdSendDynamicArea(areas)
|
|
pack := bx.NewBxDataPackCmd(cmd)
|
|
pack := bx.NewBxDataPackCmd(cmd)
|
|
pack.SetDisplayType(1) //动态显示模式
|
|
pack.SetDisplayType(1) //动态显示模式
|
|
d := pack.Pack()
|
|
d := pack.Pack()
|
|
s.Send(d)
|
|
s.Send(d)
|
|
- s.ReadResp()
|
|
|
|
- s.StateInfo.DynaAreaNum++
|
|
|
|
|
|
+ resp := s.ReadResp()
|
|
|
|
+ if !resp.IsAck() {
|
|
|
|
+ println("设备拒绝写文件! error:", resp.Error().Description)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //s.StateInfo.DynaAreaNum++
|
|
}
|
|
}
|
|
|
|
|
|
// DelRamText 删除动态区,不传删除所有
|
|
// DelRamText 删除动态区,不传删除所有
|
|
@@ -177,14 +214,15 @@ const (
|
|
)
|
|
)
|
|
|
|
|
|
type FlashFile struct {
|
|
type FlashFile struct {
|
|
- msg string
|
|
|
|
- color Color
|
|
|
|
- runMode RunMode
|
|
|
|
- dispMode DisplayMode
|
|
|
|
- originX uint16
|
|
|
|
- originY uint16
|
|
|
|
- width uint16
|
|
|
|
- height uint16
|
|
|
|
|
|
+ msg string
|
|
|
|
+ soundData string
|
|
|
|
+ color Color
|
|
|
|
+ runMode RunMode
|
|
|
|
+ dispMode DisplayMode
|
|
|
|
+ originX uint16
|
|
|
|
+ originY uint16
|
|
|
|
+ width uint16
|
|
|
|
+ height uint16
|
|
}
|
|
}
|
|
|
|
|
|
func (ft *FlashFile) SetMsg(msg string, color Color) {
|
|
func (ft *FlashFile) SetMsg(msg string, color Color) {
|
|
@@ -195,6 +233,9 @@ func (ft *FlashFile) SetMode(runMode RunMode, displayMode DisplayMode) {
|
|
ft.runMode = runMode
|
|
ft.runMode = runMode
|
|
ft.dispMode = displayMode
|
|
ft.dispMode = displayMode
|
|
}
|
|
}
|
|
|
|
+func (ft *FlashFile) SetSoundData(soundData string) {
|
|
|
|
+ ft.soundData = soundData
|
|
|
|
+}
|
|
|
|
|
|
// SetOrigin xIsPixel=true表示x坐标为像素单位, =false表示以字节(8像素)为单位;y只有像素单位
|
|
// SetOrigin xIsPixel=true表示x坐标为像素单位, =false表示以字节(8像素)为单位;y只有像素单位
|
|
func (ft *FlashFile) SetOrigin(x uint16, xIsPixel bool, y uint16) {
|
|
func (ft *FlashFile) SetOrigin(x uint16, xIsPixel bool, y uint16) {
|
|
@@ -217,12 +258,11 @@ func (ft *FlashFile) SetArea(w uint16, yIsPixel bool, h uint16) {
|
|
}
|
|
}
|
|
|
|
|
|
// TextFlash 发送静态文件节目,掉电保存,文件名格式"P000","P001"
|
|
// TextFlash 发送静态文件节目,掉电保存,文件名格式"P000","P001"
|
|
-func (s *Screen) TextFlash(ft []FlashFile, isLogo bool) {
|
|
|
|
|
|
+func (s *Screen) TextFlash(ft []FlashFile, name string, isLogo bool) {
|
|
if !s.getLiveState() {
|
|
if !s.getLiveState() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
encoder := simplifiedchinese.GB18030.NewEncoder()
|
|
encoder := simplifiedchinese.GB18030.NewEncoder()
|
|
- name := fmt.Sprintf("P%03d", s.StateInfo.ProgramNum)
|
|
|
|
if isLogo {
|
|
if isLogo {
|
|
name = "LOGO"
|
|
name = "LOGO"
|
|
}
|
|
}
|
|
@@ -234,7 +274,7 @@ func (s *Screen) TextFlash(ft []FlashFile, isLogo bool) {
|
|
} else {
|
|
} else {
|
|
bytes, _ = encoder.Bytes([]byte("\\C" + strconv.Itoa(int(i.color)) + i.msg))
|
|
bytes, _ = encoder.Bytes([]byte("\\C" + strconv.Itoa(int(i.color)) + i.msg))
|
|
}
|
|
}
|
|
- area := bx.NewBxAreaDynamic(0xff, byte(i.runMode), byte(i.dispMode), i.originX, i.originY, i.width, i.height, bytes, false)
|
|
|
|
|
|
+ area := bx.NewBxAreaProgram(0xff, byte(i.runMode), byte(i.dispMode), i.originX, i.originY, i.width, i.height, bytes, false)
|
|
areas = append(areas, area)
|
|
areas = append(areas, area)
|
|
}
|
|
}
|
|
|
|
|