package extract import "fmt" // 卫星时间起点 北京时间 2000-01-01 20:00:00 var ( ReferenceTime2000 = 946728000 ) // 焦面电箱辅助数据 128 字节 (每 16 行原始图像数据为一组) type AuxFocalBox struct { TransferTime float32 // 执行转移时间 0.5us/bit TrainingDone byte // 1B成功;0B失败 WorkMode byte // 工作模式 0B正常;1B故障 IntegralDirection byte // 积分方向 1B正向;0B反向 PGAGain byte // PGA增益 } func (ab *AuxFocalBox) Decode(data []byte) error { byte0 := data[0] & 0b00111111 ab.TransferTime = float32(uint32(byte0)<<16|uint32(data[1])<<8|uint32(data[2])) * 0.5 ab.TrainingDone = data[3] & 0b10000000 ab.WorkMode = data[3] & 0b01000000 ab.IntegralDirection = data[3] & 0b00100000 ab.PGAGain = data[3] & 0b00011111 return nil } func (ab AuxFocalBox) String() string { return fmt.Sprintf( `执行转移时间:%f us\n TrainingDone:%x\n 工作模式:%x\n 积分方向:%x\n PGA增益:%s `, ab.TransferTime, ab.TrainingDone, ab.WorkMode, ab.IntegralDirection, ab.PGAGainValue(), ) } func (ab AuxFocalBox) PGAGainValue() string { switch ab.PGAGain { case 0b0000: return "0.75x" case 0b0001: return "1.25x" case 0b0010: return "1.75x" case 0b0011: return "2.25x" case 0b0100: return "2.75x" case 0b0101: return "3.25x" case 0b0110: return "3.75x" case 0b0111: return "4.25x" case 0b1000: return "4.75x" case 0b1001: return "5.25x" case 0b1010: return "5.75x" case 0b10000: return "1x" case 0b10001: return "1.5x" case 0b10010: return "2x" case 0b10011: return "2.5x" case 0b10100: return "3x" case 0b10101: return "3.5x" case 0b10110: return "4x" case 0b10111: return "4.5x" case 0b11000: return "5x" case 0b11001: return "5.5x" case 0b11010: return "6x" default: return "unknown" } }