当前位置: 首页>>代码示例>>Golang>>正文


Golang Msg.HasCallsign方法代码示例

本文整理汇总了Golang中github.com/skypies/adsb.Msg.HasCallsign方法的典型用法代码示例。如果您正苦于以下问题:Golang Msg.HasCallsign方法的具体用法?Golang Msg.HasCallsign怎么用?Golang Msg.HasCallsign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/skypies/adsb.Msg的用法示例。


在下文中一共展示了Msg.HasCallsign方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: updateFromMsg

// Some subtype packets have data we don't get in the bulk of position packets (those of subtype:3),
// so just cache their interesting data and inject it into next position packet.
// http://woodair.net/SBS/Article/Barebones42_Socket_Data.htm
func (s *ADSBSender) updateFromMsg(m *adsb.Msg) {
	s.LastSeen = time.Now().UTC()

	// If the message had any of the optional fields, cache the value for later
	if m.HasCallsign() {
		if len(m.Callsign) > 0 {
			s.LastCallsign = m.Callsign
		} else {
			s.LastCallsign = "_._._._." // Our nil value :/
		}
	}
	if m.HasSquawk() {
		s.LastSquawk = m.Squawk
	}
	if m.HasGroundSpeed() {
		s.LastGroundSpeed = m.GroundSpeed
	}
	if m.HasTrack() {
		s.LastTrack = m.Track
	}
	if m.HasVerticalRate() {
		s.LastVerticalSpeed = m.VerticalRate
	}

	if m.Type == "MSG_foooo" {
		if m.SubType == 1 {
			// TODO: move this to m.hasCallsign()
			// MSG,1 - the callsign/ident subtype - is sometimes blank. But we
			// don't really want to confuse flights that have a purposefully
			// blank callsign with those for yet we've yet to receive a MSG,1.
			// So we use a magic string instead.
			if m.Callsign == "" {
				s.LastCallsign = "_._._._."
			}
			if m.Callsign != "" {
				s.LastCallsign = m.Callsign
			}

		} else if m.SubType == 2 {
			if m.HasGroundSpeed() {
				s.LastGroundSpeed = m.GroundSpeed
			}
			if m.HasTrack() {
				s.LastTrack = m.Track
			}

		} else if m.SubType == 4 {
			if m.HasGroundSpeed() {
				s.LastGroundSpeed = m.GroundSpeed
			}
			if m.HasVerticalRate() {
				s.LastVerticalSpeed = m.VerticalRate
			}
			if m.HasTrack() {
				s.LastTrack = m.Track
			}

		} else if m.SubType == 6 {
			if m.Squawk != "" {
				s.LastSquawk = m.Squawk
			}
		}
	}
}
开发者ID:skypies,项目名称:adsb,代码行数:67,代码来源:msgbuffer.go


注:本文中的github.com/skypies/adsb.Msg.HasCallsign方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。