Exemple #1
0
 /// <summary>
 /// Set matching IDs to target map.
 /// </summary>
 void ProcessMessage(DataMessage msg)
 {
     lock (lockObject) {
         if (target != null && activeIds.Contains(msg.Id) && msg.Dimension >= 2 && target.Follow)
         {
             target.Invoke(new Action(() => {
                 if (msg.Dimension == 2)
                 {
                     target.Position = new GeoPoint(msg[0], msg[1], 0);
                 }
                 else
                 {
                     target.Position = new GeoPoint(msg[0], msg[1], msg[2]);
                 }
                 target.Refresh();
             }));
         }
     }
 }
        /// <summary>
        /// Append message if ID matches any record.
        /// </summary>
        private void ProcessMessage(DataMessage msg)
        {
            string error = null;

            try {
                int  pathId;
                Path path;
                lock (lockObject) {
                    pathId = appendIdToPathMapping[msg.Id];
                    path   = pathIdMapping[pathId];
                }

                if (msg.Dimension >= 3)
                {
                    target.Invoke(new Action(() => { path.Add(new GeoPoint(msg[0], msg[1], msg[2])); target.Refresh(); }));
                }
                else if (msg.Dimension == 2)
                {
                    target.Invoke(new Action(() => { path.Add(new GeoPoint(msg[0], msg[1], 0.0)); target.Refresh(); }));
                }
                else
                {
                    throw new ArgumentException("Message must be at least two-dimensional.");
                }
            }
            catch (KeyNotFoundException e) {
                // if message's id is not registered for path appending - not an error
                // if path corresponding to message's id does not have an assigned index in target - cannot happen
            }
            catch (ArgumentOutOfRangeException e) {
                error = "Invalid path index accessed on target form. Have you assigned multiple MessageProcessors that conflict?";
            }
            catch (Exception e) {
                error = e.Message;
            }
        }