public GPSData ModifyLaLon(ref GPSData data, double lonOffset, double latOffset)
        {
            GPSData temp = data;

            temp.lon = temp.lon + lonOffset;
            temp.lat = temp.lat + latOffset;
            return(temp);
        }
Example #2
0
        private byte[] PacketForNeiMeng(GPSData temp)
        {
            neimengTBody.lat = temp.lat;
            neimengTBody.lon = temp.lon;

            neimengTBody.speed = (ushort)System.Net.IPAddress.HostToNetworkOrder(temp.speed);

            neimengTBody.height    = (ushort)System.Net.IPAddress.HostToNetworkOrder(temp.height);
            neimengTBody.precision = 0;



            neimengTBody.dir = (ushort)System.Net.IPAddress.HostToNetworkOrder(temp.dir);
            neimengTBody.id  = new char[20];
            now = DateTime.Now;

            neimengTBody.year   = (ushort)System.Net.IPAddress.HostToNetworkOrder(Convert.ToInt16(now.Year));
            neimengTBody.month  = Convert.ToByte(now.Month);
            neimengTBody.day    = Convert.ToByte(now.Day);
            neimengTBody.hour   = Convert.ToByte(now.Hour);
            neimengTBody.minute = Convert.ToByte(now.Minute);
            neimengTBody.second = Convert.ToByte(now.Second);

            int leng = temp.id.Length;

            for (int i = 0; i < 20; i++)
            {
                if (i < leng)
                {
                    neimengTBody.id[i] = temp.id.ElementAt <char>(i);
                }
                else
                {
                    neimengTBody.id[i] = '\0';
                }
            }
            byte[] result  = null;
            string content = "";

            neimengGPS.neimengTHead = neimengTHead;
            neimengGPS.neimengTBody = neimengTBody;
            result = neimengpro.GetByte(neimengGPS);
            for (int i = 0; i < result.Length; i++)
            {
                content = content + result[i] + "\r\n";
            }

            return(result);
        }
        //cloen a GPSData
        public GPSData GPSDataClone(GPSData data)
        {
            GPSData temp = new GPSData();

            temp.id       = data.id;
            temp.lat      = data.lat;
            temp.lon      = data.lon;
            temp.speed    = data.speed;
            temp.dir      = data.dir;
            temp.state    = data.state;
            temp.nMsgtype = data.nMsgtype;
            temp.time     = data.time;
            temp.height   = data.height;
            return(temp);
        }
        //convert to type of GPSData from TBody
        public GPSData ToGPSData(TBody body)
        {
            GPSData data = new GPSData();

            data.id       = GetIssi(body);
            data.lat      = body.lat;
            data.lon      = body.lon;
            data.speed    = body.speed;
            data.dir      = body.dir;
            data.state    = body.state;
            data.nMsgtype = body.nMsgtype;
            data.time     = Convert.ToString(body.time);
            data.height   = body.height;

            return(data);
        }
 //get issi from GPSData object
 public string GetIssi(GPSData data)
 {
     return(data.id);
 }