分类 默认分类 下的文章

关于时间

Unix时间戳:是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数

DateTime dt = new DateTime(1970,1,1).AddSeconds(1625718612); //获取到的是UTC时间
UTC时间,转换为本地时间
DateTime dt = new DateTime(1970, 1, 1,0,0,0,DateTimeKind.Utc).ToLocalTime();
dt = dt.AddSeconds(1625718612);

参考资料:
http://tool.chinaz.com/Tools/unixtime.aspx

跨域问题Access-Control-Allow-Origin

Access-Control-Allow-Origin是HTML5中定义的一种解决资源跨域的策略。

他是通过服务器端返回带有Access-Control-Allow-Origin标识的Response header,用来解决资源的跨域权限问题。

add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';

最好不跨

speedtest网络测速

https://github.com/sivel/speedtest-cli/

python speed.py --csv-header
Server ID,Sponsor,Server Name,Timestamp,Distance,Ping,Download,Upload,Share,IP Address
python speed.py --csv
5145,Beijing Unicom,Beijing,2021-01-11T04:49:04.392496Z,1.673922445212346,5.547,628723539.378605,55826659.160589784,,公网IP

python speed.py
Retrieving speedtest.net configuration...
Testing from China Unicom Beijing (公网IP)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Beijing Unicom (Beijing) [1.67 km]: 6.337 ms
Testing download speed................................................................................
Download: 625.72 Mbit/s
Testing upload speed................................................................................................
Upload: 56.08 Mbit/s

python speed.py --json
{
"client": {"rating": "0", "loggedin": "0", "isprating": "3.7", "ispdlavg": "0", "ip": "公网IP", "isp": "China Unicom Beijing", "lon": "经度", "ispulavg": "0", "country": "CN", "lat": "纬度"},
"bytes_sent": 70762496, "download": 596758926.7716337, "timestamp": "2021-01-11T04:56:33.105784Z", "share": null, "bytes_received": 409373932, "ping": 5.535, "upload": 55883940.61967305,
"server": {"latency": 5.535, "name": "Beijing", "url": "http://bj3.unicomtest.com:8080/speedtest/upload.php", "country": "China", "lon": "经度", "cc": "CN", "host": "bj3.unicomtest.com:8080", "sponsor": "Beijing Broadband Network", "lat": "纬度", "id": "5505", "d": 1.673922445212346}
}

GPS和地图

光速30万公里/秒,地球七圈半,一圈4万公里;一圈360度,3万6公里,一度10万米(100公里)
0.00001度,万分之一度,就是10米,应该也够用了,还是用四舍五入吧
实际好像4位东西向10米,南北向20米,哪里算错了?五位小数应该是十万分之一1米,名址10米,轨迹1米(或者2-2.5米)
https://tool.yovisun.com/longlat/
两点距离:11.11946465529米
点1:纬度:40,经度:116,点2:纬度:40.0001,经度:116
两点距离:8.5184132726564米
点1:纬度:40,经度:116,点2:纬度:40,经度:116.0001

经度0.0001=8.5米,纬度0.0001=11.1米

关于四舍五入
https://www.cnblogs.com/renzhiwei/p/4229384.html

CRC16有很多种

CRC-16/MODBUS

//数据(16进制):01 03 61 00 00 02 CRC校验:F7 DB
string str = "01 03 61 00 00 02";
str = str.Replace(" ", "");
int l = str.Length / 2;
uint crc = 0xFFFF;
for(int i=0;i<l;i++)
{
    crc = crc ^ Convert.ToUInt32(str.Substring(i * 2, 2), 16);
    for(int j=0;j<8;j++)
    {

        if ((crc & 0x01)>0)
        {
            crc = crc >> 1;
            crc = crc ^ 0xa001;
        }
        else
        {
            crc = crc >> 1;
        }
    }
}
Console.WriteLine(string.Format("{0:X4}", crc));

参考文献
https://blog.csdn.net/u013625451/article/details/81239572
参考了一个在线工具
http://www.ip33.com/crc.html