get raw data
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const AuxPlatformFrmSize = 512 // 512 bytes
|
||||
@@ -90,7 +91,8 @@ type AuxPlatform struct {
|
||||
Reserved1 [4]byte // 预留字节
|
||||
Reserved2 [2]byte // 预留字节
|
||||
Reserved3 [2]byte // 预留字节
|
||||
// 241 - 311 暂不解析
|
||||
// 241.0 - 311.0 波道1参数
|
||||
// 241.1 - 311.1 波道2参数
|
||||
WGS84PosX float64 // [312-315]计算当前WGS 84位置X 单位:0.01米
|
||||
WGS84PosY float64 // [316-319]
|
||||
WGS84PosZ float64 // [320-323]
|
||||
@@ -191,6 +193,70 @@ func (e *Extractor) ParseAuxPlatform(auxfile string) ([]*AuxPlatform, error) {
|
||||
return aps, nil
|
||||
}
|
||||
|
||||
func (e *Extractor) ParseAuxPlatformWithHead(auxfile string) ([]*AuxPlatform, error) {
|
||||
data, err := os.ReadFile(auxfile)
|
||||
if err != nil {
|
||||
logrus.Println("read aux data from", auxfile, "error:", err.Error())
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fimg, _ := os.Create("demo/temp/ref_051622_aux_img.txt")
|
||||
defer fimg.Close()
|
||||
fimg.WriteString("index 流水号 文件号 时间秒 秒小数 utcTime\n")
|
||||
|
||||
var aps []*AuxPlatform
|
||||
rows := 0
|
||||
for i := 0; i < len(data); {
|
||||
if data[i] == 0xD1 && data[i+1] == 0x5B && data[i+2] == 0xD1 && data[i+3] == 0x5B {
|
||||
log.Debug("find package head: 0xD15BD15B")
|
||||
} else {
|
||||
i++
|
||||
// log.Println(i,"not find package head: 0xD15BD15B, skip 1 byte")
|
||||
continue
|
||||
}
|
||||
afh := &AuxFrameHead{}
|
||||
afh.Decode(data[i : i+24])
|
||||
|
||||
if !afh.IsValidFrmHead {
|
||||
log.Debugf("[%d] invalid frame head of original raw data %v", i, afh.FrmHead)
|
||||
i += 1
|
||||
continue
|
||||
}
|
||||
|
||||
if (afh.SerialNo-1)%16 == 0 {
|
||||
|
||||
ab := &AuxFocalBox{}
|
||||
ab.Decode(data[i+24 : i+32])
|
||||
fmt.Println(ab.String())
|
||||
|
||||
utcTime := binary.BigEndian.Uint32(data[i+32 : i+36])
|
||||
|
||||
// t := time.Unix(int64(afh.TimeSec+uint32(ReferenceTime2000)), int64(afh.TimeSecFrac)*1000)
|
||||
taux := time.Unix(int64(utcTime+uint32(ReferenceTime2000)), 0)
|
||||
|
||||
fimg.WriteString(
|
||||
fmt.Sprintf("%d %d %d %d %d %d %s\n",
|
||||
i,
|
||||
afh.SerialNo,
|
||||
afh.FileNo,
|
||||
afh.TimeSec,
|
||||
afh.TimeSecFrac,
|
||||
utcTime,
|
||||
taux.String(),
|
||||
))
|
||||
|
||||
rows++
|
||||
// if rows > 32 {
|
||||
// break
|
||||
// }
|
||||
}
|
||||
|
||||
i += 64
|
||||
|
||||
}
|
||||
return aps, nil
|
||||
}
|
||||
|
||||
func Time2000UTCSec() int64 {
|
||||
t, _ := time.ParseInLocation("2006-01-02 15:04:05", "2000-01-01 12:00:00", time.UTC)
|
||||
return t.Unix()
|
||||
|
||||
Reference in New Issue
Block a user