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