public virtual int SendWaypoints(IList <GlobalsatWaypoint> waypoints, IJobMonitor jobMonitor) { int nrSentWaypoints = 0; if (this.Open()) { try { GlobalsatPacket packet = PacketFactory.SendWaypoints(this.FitnessDevice.configInfo.MaxNrWaypoints, waypoints); GlobalsatPacket response = (GlobalsatPacket)this.SendPacket(packet); // km500 no out of memory- waypoint overwritten nrSentWaypoints = response.ResponseSendWaypoints(); if (nrSentWaypoints < waypoints.Count) { jobMonitor.ErrorText = string.Format("Could only send {0} out of {1} waypoints (Capacity {2}).", nrSentWaypoints, waypoints.Count, this.FitnessDevice.configInfo.MaxNrWaypoints); } } catch (Exception e) { jobMonitor.ErrorText = Properties.Resources.Device_SendWaypoints_Error + e; } finally { this.Close(); } } if (!this.DataRecieved) { NoCommunicationError(jobMonitor); nrSentWaypoints = 0; } return(nrSentWaypoints); }
public override int SendWaypoints(IList <GlobalsatWaypoint> waypoints, IJobMonitor jobMonitor) { int nrSentWaypoints = 0; if (this.Open()) { try { foreach (GlobalsatWaypoint g in waypoints) { GlobalsatPacket packet = PacketFactory.SendWaypoints(this.FitnessDevice.configInfo.MaxNrWaypoints, new List <GlobalsatWaypoint> { g }); GlobalsatPacket response = (GlobalsatPacket)this.SendPacket(packet); int resp = response.ResponseSendWaypoints(); nrSentWaypoints += resp; if (resp <= 0) { jobMonitor.ErrorText = string.Format("Could only send {0} out of {1} waypoints. (Capacity {2}).", nrSentWaypoints, waypoints.Count, this.FitnessDevice.configInfo.MaxNrWaypoints); break; } } } catch (Exception ex) { jobMonitor.ErrorText = Properties.Resources.Device_SendWaypoints_Error + ex; } finally { this.Close(); } } if (!this.DataRecieved) { //Normal case NoCommunicationError(jobMonitor); } return(nrSentWaypoints); }