本文整理汇总了Golang中github.com/skypies/adsb.Msg.GeneratedTimestampUTC方法的典型用法代码示例。如果您正苦于以下问题:Golang Msg.GeneratedTimestampUTC方法的具体用法?Golang Msg.GeneratedTimestampUTC怎么用?Golang Msg.GeneratedTimestampUTC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skypies/adsb.Msg
的用法示例。
在下文中一共展示了Msg.GeneratedTimestampUTC方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: msgs
func msgs(sbs string) (ret []adsb.Msg) {
scanner := bufio.NewScanner(strings.NewReader(sbs))
for scanner.Scan() {
m := adsb.Msg{}
text := scanner.Text()
if err := m.FromSBS1(text); err != nil {
panic(err)
}
m.GeneratedTimestampUTC = time.Now() // Fake this out
ret = append(ret, m)
}
return
}
示例2: generateData
func generateData() {
fmt.Printf("(launching mock dump0190 on localhost:%d; mlat=%v)\n", port, mlat)
ln, _ := net.Listen("tcp", fmt.Sprintf("localhost:%d", port))
outerLoop:
for {
conn, _ := ln.Accept()
fmt.Printf("(connection started)\n")
m := adsb.Msg{
Icao24: adsb.IcaoId("A81BD0"),
Callsign: "ABW123",
Type: "MSG",
Altitude: 12345,
GroundSpeed: 300,
Track: 315,
VerticalRate: 64,
Position: geo.Latlong{36.0, -122.0},
GeneratedTimestampUTC: time.Now().UTC(),
LoggedTimestampUTC: time.Now().UTC(),
}
// We need to prime the pump, and trick the msgbuffer
m.SubType = 3 // Get an entry in the sender table for our Icao, by proving we have pos data
conn.Write([]byte(fmt.Sprintf("%s\n", m.ToSBS1())))
m.SubType = 1 // Populate the sender table entry with a callsign (MSG,1 only)
conn.Write([]byte(fmt.Sprintf("%s\n", m.ToSBS1())))
m.SubType = 4 // Populate the sender table entry with velocity data (MSG,4 only)
conn.Write([]byte(fmt.Sprintf("%s\n", m.ToSBS1())))
m.SubType = 3 // All future messages are linear position updates (MSG,3 only)
for {
now := time.Now().UTC().Add(-1 * delay)
m.Position.Lat += 0.01
m.GeneratedTimestampUTC = now
m.LoggedTimestampUTC = now
if mlat {
m.Type = "MLAT"
}
if _, err := conn.Write([]byte(fmt.Sprintf("%s\n", m.ToSBS1()))); err != nil {
fmt.Printf("(connection ended)\n")
continue outerLoop
}
time.Sleep(time.Millisecond * 1000)
}
}
}