diff --git a/api/simulation.go b/api/simulation.go index a9f5ef0..34dc47f 100644 --- a/api/simulation.go +++ b/api/simulation.go @@ -302,7 +302,7 @@ func signalOperation(c *gin.Context) { // @Success 200 {object} string // @Failure 500 {object} dto.ErrorDto // @Router /api/v1/simulation/axleSection/operation [post] -func axleSectionOperation(c *gin.Context) { +func axleSectionOperation(c *gin.Context) { //操作:设置故障占用、取消故障占用、计轴直接复位、计轴预复位 req := &dto.AxleSectionOperationReqDto{} if err := c.ShouldBind(&req); err != nil { panic(sys_error.New("输入参数格式错误", err)) diff --git a/third_party/message/rssp_crc.go b/third_party/message/rssp_crc.go index e28415b..f51e8fc 100644 --- a/third_party/message/rssp_crc.go +++ b/third_party/message/rssp_crc.go @@ -189,3 +189,40 @@ func CrcBitOrientedMsbFirst(data []byte, polynomial uint32, width int) uint32 { } return register1 & significant_mask } +func Crc(data []byte, + polynomial uint32, + width int, + initial_value uint32, + input_reflected bool, + result_reflected bool, + final_xor_value uint32) uint32 { + length := len(data) + var register1 uint32 = initial_value + var significant_mask uint32 = 0xffffffff >> (32 - width) + var register_lsb_mask uint32 = 0xff + + if input_reflected { + register1 = reflect(register1, width) + } + + for i := 0; i < length; i++ { + var byteData uint32 = uint32(data[i]) + var shift_out uint32 = 0 + var value uint32 = 0 + + if input_reflected { + shift_out = register1 & register_lsb_mask + value = Lookup(shift_out^byteData, polynomial, width, input_reflected) + register1 = (register1 >> 8) ^ value + } else { + shift_out = (register1 >> (width - 8)) & register_lsb_mask + value = Lookup(shift_out^byteData, polynomial, width, input_reflected) + register1 = (register1 << 8) ^ value + } + } + + if input_reflected != result_reflected { + register1 = reflect(register1, width) + } + return (register1 ^ final_xor_value) & significant_mask +}