修改语音调试
This commit is contained in:
@@ -246,7 +246,6 @@ func (t *TcpClient) doPrint(key string) (err error) {
|
|||||||
close(t.TimeoutMap[key])
|
close(t.TimeoutMap[key])
|
||||||
} else {
|
} else {
|
||||||
globals.SugarLogger.Debugf("handleTcpMessages success, data: %v", hex.EncodeToString(data))
|
globals.SugarLogger.Debugf("handleTcpMessages success, data: %v", hex.EncodeToString(data))
|
||||||
globals.SugarLogger.Debugf("data================: %v", "1e00140200ff50bc147df3d71b401B59415515ff")
|
|
||||||
//等待回调
|
//等待回调
|
||||||
dataStr := <-t.CallBackMap[printMsg.PrintNo]
|
dataStr := <-t.CallBackMap[printMsg.PrintNo]
|
||||||
if dataStr != "" {
|
if dataStr != "" {
|
||||||
|
|||||||
@@ -494,30 +494,30 @@ func replaceContent(content string, printMsg *model.PrintMsg) (result string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 自动合成语音功能
|
// 自动合成语音功能
|
||||||
if strings.Contains(result, byteSignSound) && strings.Contains(result, byteSignSoundE) {
|
//if strings.Contains(result, byteSignSound) && strings.Contains(result, byteSignSoundE) {
|
||||||
if sounds := regexpSound.FindStringSubmatch(result); len(sounds) > 0 {
|
// if sounds := regexpSound.FindStringSubmatch(result); len(sounds) > 0 {
|
||||||
sound := sounds[1]
|
// sound := sounds[1]
|
||||||
if printer, _ := dao.GetPrinter(dao.GetDB(), printMsg.PrintNo); printer != nil {
|
// if printer, _ := dao.GetPrinter(dao.GetDB(), printMsg.PrintNo); printer != nil {
|
||||||
//先把结束标签消了
|
// //先把结束标签消了
|
||||||
result = strings.ReplaceAll(result, byteSignSoundE, "")
|
// result = strings.ReplaceAll(result, byteSignSoundE, "")
|
||||||
soundPrefix := ""
|
// soundPrefix := ""
|
||||||
if printer.Sound != "" {
|
// if printer.Sound != "" {
|
||||||
soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]" + printer.Sound
|
// soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]" + printer.Sound
|
||||||
} else {
|
// } else {
|
||||||
soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]"
|
// soundPrefix = "[v" + utils.Int2Str(printer.Volume*2) + "]"
|
||||||
}
|
// }
|
||||||
hexPrefix, _ := jxutils.Utf8ToGbk([]byte(soundPrefix))
|
// hexPrefix, _ := jxutils.Utf8ToGbk([]byte(soundPrefix))
|
||||||
hexPrefixStr := hex.EncodeToString(hexPrefix)
|
// hexPrefixStr := hex.EncodeToString(hexPrefix)
|
||||||
realSound := hexPrefixStr + sound
|
// realSound := hexPrefixStr + sound
|
||||||
allLen := fmt.Sprintf("%x", (len("fd001a0101")+len(realSound))/2)
|
// allLen := fmt.Sprintf("%x", (len("fd001a0101")+len(realSound))/2)
|
||||||
if len(allLen) < 2 {
|
// if len(allLen) < 2 {
|
||||||
allLen = "0" + allLen
|
// allLen = "0" + allLen
|
||||||
}
|
// }
|
||||||
soundLenH, soundLenX := int2h8l8(int64((len(realSound) + len("0101")) / 2))
|
// soundLenH, soundLenX := int2h8l8(int64((len(realSound) + len("0101")) / 2))
|
||||||
result = strings.ReplaceAll(result, byteSignSound, hexSignSound+allLen+"fd"+soundLenH+soundLenX+"0100"+hexPrefixStr)
|
// result = strings.ReplaceAll(result, byteSignSound, hexSignSound+allLen+"fd"+soundLenH+soundLenX+"0100"+hexPrefixStr)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
main.go
2
main.go
@@ -128,10 +128,8 @@ func main() {
|
|||||||
http.ListenAndServe("0.0.0.0:6060", nil)
|
http.ListenAndServe("0.0.0.0:6060", nil)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
globals.SugarLogger.Debug("=========1========1============", globals.IsPrintEnv())
|
|
||||||
|
|
||||||
if globals.IsPrintEnv() {
|
if globals.IsPrintEnv() {
|
||||||
globals.SugarLogger.Debug("=========2========2============", globals.IsPrintEnv())
|
|
||||||
event.ListenTcp()
|
event.ListenTcp()
|
||||||
}
|
}
|
||||||
beego.Run()
|
beego.Run()
|
||||||
|
|||||||
Reference in New Issue
Block a user