Esempio n. 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;
            }
        }
Esempio n. 3
0
        public static bool Test()
        {
            LayoutMessage layoutMsg = new LayoutMessage();

            layoutMsg.Count = 3;

            layoutMsg[0].Name              = "GPS";
            layoutMsg[0].Id                = 0;
            layoutMsg[0].AppendPathId      = 1;
            layoutMsg[0].UpdateMap         = true;
            layoutMsg[0].AppendPathEnabled = false;
            layoutMsg[0].Dimension         = 3;
            layoutMsg[0][0]                = "Latitude";
            layoutMsg[0][1]                = "Longitude";
            layoutMsg[0][2]                = "Altitude";

            layoutMsg[1].Name              = "Velocity";
            layoutMsg[1].Id                = 1;
            layoutMsg[1].AppendPathId      = 16;
            layoutMsg[1].UpdateMap         = true;
            layoutMsg[1].AppendPathEnabled = true;
            layoutMsg[1].Dimension         = 3;
            layoutMsg[1][0]                = "X";
            layoutMsg[1][1]                = "Y";
            layoutMsg[1][2]                = "Z";

            layoutMsg[2].Name              = "Temperature";
            layoutMsg[2].Id                = 2;
            layoutMsg[2].AppendPathId      = 0;
            layoutMsg[2].UpdateMap         = false;
            layoutMsg[2].AppendPathEnabled = true;
            layoutMsg[2].Dimension         = 1;
            layoutMsg[2][0]                = "Value";

            byte[]        layoutMsgBytes    = layoutMsg.Serialize();
            LayoutMessage layoutMsgRestored = (LayoutMessage)Message.Deserialize(layoutMsgBytes);


            PathMessage pathMsg = new PathMessage();

            pathMsg.action = PathMessage.eAction.UPDATE_POINT;
            pathMsg.index  = 5;
            pathMsg.path   = 9;
            pathMsg.point  = new GeoPoint(47.5, 19, 120);

            byte[]      pathMsgBytes   = pathMsg.Serialize();
            PathMessage pathMsgRestore = (PathMessage)Message.Deserialize(pathMsgBytes);


            DataMessage dataMsg = new DataMessage();

            dataMsg.Dimension = 3;
            dataMsg.Id        = 12345;
            dataMsg[0]        = 3.1415926f;
            dataMsg[1]        = 2.7182818f;
            dataMsg[2]        = 0.5772156f;

            byte[]      dataMsgBytes    = dataMsg.Serialize();
            DataMessage dataMsgRestored = (DataMessage)Message.Deserialize(dataMsgBytes);

            return(true);
        }