Exemplo n.º 1
0
        public int CompareTo(object obj)
        {
            if (!(obj is GlobalsatWaypoint))
            {
                return(-1);
            }
            GlobalsatWaypoint g = obj as GlobalsatWaypoint;

            if (this._waypointName.CompareTo(g._waypointName) < 0 ||
                this._iconNr < g._iconNr ||
                this.Latitude < g.Latitude ||
                this.Longitude < g.Longitude ||
                this.Altitude < g.Altitude)
            {
                return(-1);
            }
            else if (this._waypointName.CompareTo(g._waypointName) > 0 ||
                     this._iconNr > g._iconNr ||
                     this.Latitude > g.Latitude ||
                     this.Longitude > g.Longitude ||
                     this.Altitude > g.Altitude)
            {
                return(1);
            }
            return(0);
        }
Exemplo n.º 2
0
        public virtual GlobalsatPacket SendWaypoints(int MaxNrWaypoints, IList <GlobalsatWaypoint> waypoints)
        {
            int nrWaypointsLength  = 2;
            int waypointNameLength = 6;

            int nrWaypoints = Math.Min(MaxNrWaypoints, waypoints.Count);

            //Same WptLatLonOffset is used when padding - could differ in other devices
            Int16 totalLength = (Int16)(nrWaypointsLength + WptLatLonOffset + nrWaypoints * LocationLength);

            this.InitPacket(CommandSendWaypoint, totalLength);

            int offset = 0;

            offset += this.Write(offset, (short)nrWaypoints);

            offset += WptLatLonOffset; //pad -some only

            int waypOffset = offset;

            for (int i = 0; i < nrWaypoints; i++)
            {
                GlobalsatWaypoint waypoint = waypoints[i];
                offset = waypOffset + i * LocationLength;

                //Points to be added requires names
                if (string.IsNullOrEmpty(waypoint.WaypointName))
                {
                    waypoint.WaypointName = "WR" + sendIdentification++;
                }

                offset += this.Write(offset, waypointNameLength + 1, waypoint.WaypointName);

                this.PacketData[offset++] = (byte)waypoint.IconNr;

                offset += this.Write(offset, waypoint.Altitude);

                offset += WptLatLonOffset; //pad
                offset += this.Write32(offset, ToGlobLatLon(waypoint.Latitude));
                offset += this.Write32(offset, ToGlobLatLon(waypoint.Longitude));
            }
            CheckOffset(totalLength, offset);
            return(this);
        }
Exemplo n.º 3
0
        public virtual IList <GlobalsatWaypoint> ResponseGetWaypoints()
        {
            //No reasonable CheckOffset()
            int nrWaypoints = PacketLength / LocationLength;
            IList <GlobalsatWaypoint> waypoints = new List <GlobalsatWaypoint>(nrWaypoints);

            for (int i = 0; i < nrWaypoints; i++)
            {
                int index = i * LocationLength;

                string waypointName = ByteArr2String(index, 6);
                int    iconNr       = (int)PacketData[index + 7];
                short  altitude     = ReadInt16(index + 8);
                double latitude     = ReadLatLon(index + 10 + WptLatLonOffset);
                double longitude    = ReadLatLon(index + 14 + WptLatLonOffset);

                GlobalsatWaypoint waypoint = new GlobalsatWaypoint(waypointName, iconNr, altitude, latitude, longitude);
                waypoints.Add(waypoint);
            }

            return(waypoints);
        }
Exemplo n.º 4
0
        // tree list don't acept objects with the same id - not needed anymore?
        //public GlobalsatWaypoint ChangeNameRef()
        //{
        //    //this.WaypointName = this.WaypointName + "";
        //    return this;
        //}

        public GlobalsatWaypoint Clone()
        {
            GlobalsatWaypoint waypoint = new GlobalsatWaypoint(this.WaypointName + "", this.IconNr, this.Altitude, this.Latitude, this.Longitude);

            return(waypoint);
        }