Merge branch 'develop' into local-test
All checks were successful
local-test分支打包构建docker并发布运行 / Docker-Build (push) Successful in 1m55s
All checks were successful
local-test分支打包构建docker并发布运行 / Docker-Build (push) Successful in 1m55s
This commit is contained in:
commit
5d232cf4e8
File diff suppressed because it is too large
Load Diff
@ -1 +1 @@
|
|||||||
Subproject commit aac1484a6f64cc43146cabd89784b92c933a0298
|
Subproject commit 189cabea725167f98c15d0971ee20d01b044ce05
|
4
third_party/interlock/beijing12/interlock.go
vendored
4
third_party/interlock/beijing12/interlock.go
vendored
@ -53,7 +53,7 @@ type interlockProxy struct {
|
|||||||
|
|
||||||
// 驱动信息进行转发
|
// 驱动信息进行转发
|
||||||
func (i *interlockProxy) handleDriverInfo(b []byte) {
|
func (i *interlockProxy) handleDriverInfo(b []byte) {
|
||||||
slog.Info("收到联锁驱动继电器数据:", fmt.Sprintf("%x", b))
|
slog.Info(fmt.Sprintf("收到联锁驱动继电器数据:%x", b))
|
||||||
handler := i.manager
|
handler := i.manager
|
||||||
if handler != nil {
|
if handler != nil {
|
||||||
handler.HandleInterlockDriverInfo(i.runConfig.Code, b)
|
handler.HandleInterlockDriverInfo(i.runConfig.Code, b)
|
||||||
@ -106,7 +106,7 @@ func (i *interlockProxy) collectInfoStateTask(ctx context.Context) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("向联锁发送继电器状态失败:", err)
|
slog.Error("向联锁发送继电器状态失败:", err)
|
||||||
} else {
|
} else {
|
||||||
slog.Error("向联锁发送继电器数据成功:", fmt.Sprintf("%x", collectInfoState.Encode()))
|
slog.Error(fmt.Sprintf("向联锁发送继电器数据成功:%x", collectInfoState.Encode()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
time.Sleep(time.Millisecond * InterlockMessageSendInterval)
|
time.Sleep(time.Millisecond * InterlockMessageSendInterval)
|
||||||
|
29
third_party/message/interlock.go
vendored
29
third_party/message/interlock.go
vendored
@ -1,6 +1,9 @@
|
|||||||
package message
|
package message
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
)
|
||||||
|
|
||||||
// 消息包头解析
|
// 消息包头解析
|
||||||
type interlockMsgPkgHeader struct {
|
type interlockMsgPkgHeader struct {
|
||||||
@ -81,15 +84,25 @@ func (m *InterlockSendMsgPkg) SetSerialNumber(serialNumber uint8) {
|
|||||||
func (m *InterlockSendMsgPkg) Encode() []byte {
|
func (m *InterlockSendMsgPkg) Encode() []byte {
|
||||||
var data []byte
|
var data []byte
|
||||||
data = append(data, m.header.encode()...)
|
data = append(data, m.header.encode()...)
|
||||||
for index, length, cycles := 0, len(m.info), len(m.info)/boolsToByteArrLen; index < cycles; index++ {
|
bitLen := len(m.info)
|
||||||
startIndex := index * boolsToByteArrLen
|
byteLen := int(math.Ceil(float64(bitLen) / 8))
|
||||||
toByteArr := [8]bool{}
|
infoBytes := make([]byte, byteLen)
|
||||||
for i := 0; i < boolsToByteArrLen && startIndex < length; i++ {
|
for i, b := range m.info {
|
||||||
startIndex = startIndex + i
|
if b {
|
||||||
toByteArr[i] = m.info[startIndex+i]
|
infoBytes[i/8] = infoBytes[i/8] + (1 << (i % 8))
|
||||||
}
|
}
|
||||||
data = append(data, boolsToByte(toByteArr))
|
|
||||||
}
|
}
|
||||||
|
data = append(data, infoBytes...)
|
||||||
|
|
||||||
|
//for index, length, cycles := 0, len(m.info), len(m.info)/boolsToByteArrLen; index < cycles; index++ {
|
||||||
|
// startIndex := index * boolsToByteArrLen
|
||||||
|
// toByteArr := [8]bool{}
|
||||||
|
// for i := 0; i < boolsToByteArrLen && startIndex < length; i++ {
|
||||||
|
// startIndex = startIndex + i
|
||||||
|
// toByteArr[i] = m.info[startIndex+i]
|
||||||
|
// }
|
||||||
|
// data = append(data, boolsToByte(toByteArr))
|
||||||
|
//}
|
||||||
data = append(data, m.tail.encode()...)
|
data = append(data, m.tail.encode()...)
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user