简体   繁体   English

适用于Android应用的vb.net代码

[英]vb.net code for Android app

I am working on a BlackBerry app. 我正在开发一款BlackBerry应用程序。 This app has already been developed in Android in "Basic4Android" program. 此应用程序已在Android中的“Basic4Android”程序中开发。 The code for the android app is written in vb.net. Android应用程序的代码是用vb.net编写的。 I need to write the exact same code for BlackBerry. 我需要为BlackBerry编写完全相同的代码。 I am trying to understand this method but I am unable to since I am not an expert with vb.net. 我试图理解这种方法,但我无法,因为我不是vb.net的专家。 I will not paste the entire method but only parts which I need to clarify: 我不会粘贴整个方法,只会粘贴我需要澄清的部分:

Sub HEX_T24_SHORT_GPS(latitude_decimal_degrees As Double, longitude_decimal_degrees As Double, speed_knots As Int, heading_degrees As Int, time_seconds_since_midnight_gmt As Int, alert_on As Boolean, alert_ack As Boolean, external_interface_control As Boolean, send_extended As Boolean) As String
    Dim pBuffer(11) As Int
    pBuffer(0)=0 ' T24 MSGID 0
    Log("pBuffer(2)" & pBuffer(2))
    Dim t1 As Double
    'Get latitude sign
    Dim lat_south As Boolean
    lat_south=True
    If latitude_decimal_degrees<0 Then lat_south=False
    'Get Longitude sign 
    Dim lon_west As Boolean
    lon_west=True
    If longitude_decimal_degrees<0 Then lon_west=False
    'Get number of second since midnigh extra bit
    Dim num_of_second_extra_bit As Boolean 
    num_of_second_extra_bit=False
    If time_seconds_since_midnight_gmt > 0xFFFF Then num_of_second_extra_bit=True
    'Convert latitude in bytes 1 to 3
    latitude_decimal_degrees = Abs(latitude_decimal_degrees*60000)

What does "If time_seconds_since_midnight_gmt > 0xFFFF" mean? “如果time_seconds_since_midnight_gmt> 0xFFFF”是什么意思? What is happening here "latitude_decimal_degrees = Abs(latitude_decimal_degrees*60000)". 这里发生了什么“latitude_decimal_degrees = Abs(latitude_decimal_degrees * 60000)”。 I checked the "Basic4Android" documentation but could not find the Abs API. 我检查了“Basic4Android”文档,但找不到Abs API。

If num_of_second_extra_bit=True Then latitude_decimal_degrees=latitude_decimal_degrees + 0x800000
    pBuffer(1)=Bit.ShiftRight(Bit.And(latitude_decimal_degrees, 0xFF0000),16)
    pBuffer(2)=Bit.ShiftRight(Bit.And(latitude_decimal_degrees, 0x00FF00),8)
    pBuffer(3)=Bit.And(latitude_decimal_degrees, 0xFF)

How is the bit shift applied? 如何应用位移? Is the "AND" operation used between an int and hex value? 在int和十六进制值之间使用“AND”操作? What is the final value in pBuffer(1)? pBuffer(1)的最终值是多少? What is the purpose of steps pBuffer(1) to pBuffer(3). 步骤pBuffer(1)到pBuffer(3)的目的是什么。 What is it doing and what is the final value of latitude_decimal_degrees?Is the final value in bytes, byte array or hex?Please explain. 它在做什么以及latitude_decimal_degrees的最终值是什么?最终值是以字节,字节数组还是十六进制?请解释。

What does "If time_seconds_since_midnight_gmt > 0xFFFF" mean? “如果time_seconds_since_midnight_gmt> 0xFFFF”是什么意思?

What this does is checking if the time_seconds_since_midnight_gmt is bigger than 65,535 - this is probably some sort of compensation - remember there's 86,400 seconds in a day. 这样做是检查time_seconds_since_midnight_gmt是否大于65,535 - 这可能是某种补偿 - 记住一天有86,400秒。

What is happening here "latitude_decimal_degrees = Abs(latitude_decimal_degrees*60000)" 这里发生了什么“latitude_decimal_degrees = Abs(latitude_decimal_degrees * 60000)”

The decimal part of the latitude is being multiplied by 60,000 - this is pretty much context based what's going on - it's probably has something to do with the speed you are moving in - you should look into where this function is called from and try to figure out what the number range is that is going into this variable, and then try to deduce it from that. 纬度的小数部分乘以60,000 - 这几乎是基于上下文的内容 - 它可能与你移动的速度有关 - 你应该调查这个函数的调用位置并尝试计算输出该变量的数字范围,然后尝试从中推导出它。

How is the bit shift applied? 如何应用位移?

First 0x800000 is added (this is setting bit number 23 high) 首先添加0x800000(这是设置位数23高)

Is the "AND" operation used between an int and hex value? 在int和十六进制值之间使用“AND”操作?

Yes. 是。 It seems like you're mixing things up - an integer value can be repesented in base 2 (binary), base 8 (octal), base 10(the usual way) and base 16 (hexadecimal) - it's still the same value. 看起来你正在混淆 - 整数值可以在基数2(二进制),基数8(八进制),基数10(通常的方式)和基数16(十六进制)中重复 - 它仍然是相同的值。

What is the final value in pBuffer(1)? pBuffer(1)的最终值是多少? Please explain. 请解释。

Okay - let's run through an example: 好的 - 让我们来看一个例子:

latitude_decimal_degrees = 0xE653 (58,963) latitude_decimal_degrees = 0xE653(58,963)

then add 0x800000 然后添加0x800000

latitude = 0x80E653 纬度= 0x80E653

then and with 0xFF0000 然后和0xFF0000

latitude = 0x800000 纬度= 0x800000

and finally right shift by 16 最后右移16

latitude = 0x000080 纬度= 0x000080

What this means on the other hand, is up for your interpretation. 另一方面,这意味着你的解释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM