示例#1
0
        public void StatusMessageEncodingTests()
        {
            StatusMessage testStatusMessageSize  = new StatusMessage();
            StatusMessage testStatusMessageIndex = new StatusMessage();

            MessageInitializers.StatusMessageFieldSizeInitializer(out testStatusMessageSize);
            MessageInitializers.StatusMessageFieldIndexInitializer(out testStatusMessageIndex);

            List <Byte> messageValuesList = new List <Byte>();

            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testStatusMessageSize.OpCode, (uint)2,
                                                                           messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testStatusMessageSize.MessageCounter,
                                                                           (uint)0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList((int)testStatusMessageSize.IDPart1,
                                                                           600, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList((int)testStatusMessageSize.IDPart2,
                                                                           700, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList((int)testStatusMessageSize.IDPart3,
                                                                           800, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testStatusMessageSize.TimeSource,
                                                                           (uint)2, messageValuesList);   //Accurate
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testStatusMessageSize.GPSYear,
                                                                           (uint)0, messageValuesList);   //Year
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testStatusMessageSize.GPSMonth,
                                                                           (uint)0, messageValuesList);   //Month
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testStatusMessageSize.GPSDay,
                                                                           (uint)0, messageValuesList);   //Day
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testStatusMessageSize.GPSHour,
                                                                           (uint)0, messageValuesList);   //Hour
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testStatusMessageSize.GPSMinute,
                                                                           (uint)0, messageValuesList);   //Min
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testStatusMessageSize.GPSSecond,
                                                                           (uint)0, messageValuesList);   //Sec
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testStatusMessageSize.GPSMiliSec,
                                                                           (uint)0, messageValuesList);   //Mili
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testStatusMessageSize.Mode,
                                                                           (uint)4, messageValuesList);   //Mode
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testStatusMessageSize.RTA,
                                                                           (uint)1, messageValuesList);   //Ready To Arm
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testStatusMessageSize.BCS,
                                                                           (uint)160, messageValuesList); //Battery LSB=0.1
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testStatusMessageSize.IMUStatus,
                                                                           (uint)1, messageValuesList);   //IMU
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testStatusMessageSize.FDS,
                                                                           (uint)3, messageValuesList);   //Flash
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testStatusMessageSize.RCChannels,
                                                                           (uint)1, messageValuesList);   //RC
            //Convert list to Array
            Byte[] messageinValues = messageValuesList.ToArray();
            Byte[] ExpectedArray   = { 2, 0, 0, 88, 2, 0, 0, 188, 2, 0, 0, 32, 3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 160, 0, 1, 3, 1 };
            Assert.AreEqual(Convert.ToBase64String(ExpectedArray), Convert.ToBase64String(messageinValues));
        }
示例#2
0
        public void KinematicMessageEncodingTests()
        {
            KinematicMessage testKinematicMessageSize  = new KinematicMessage();
            KinematicMessage testKinematicMessageIndex = new KinematicMessage();

            MessageInitializers.KinematicMessageFieldSizeInitializer(out testKinematicMessageSize);
            MessageInitializers.KinematicMessageFieldIndexInitializer(out testKinematicMessageIndex);

            List <Byte> messageValuesList = new List <Byte>();

            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.OpCode, 4, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.MessageCounter, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList((int)testKinematicMessageSize.IDPart1, 600, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList((int)testKinematicMessageSize.IDPart2, 700, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList((int)testKinematicMessageSize.IDPart3, 800, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.TimeSource, 2, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.GPSYear, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.GPSMonth, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.GPSDay, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.GPSHour, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.GPSMinute, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.GPSSecond, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.GPSMiliSec, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.BaroHeight, 17, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.Pressure, 3200, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.AccX, 3500, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.AccY, 3000, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.AccZ, 3, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.MagX, 5, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.MagY, 15, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.MagZ, 32, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.GyroX, 3000, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.GyroY, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.GyroZ, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.Heading, 10, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.Roll, 20, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.Pitch, 40, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.OrientationX, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.OrientationY, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.OrientationZ, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.OrientationW, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.LinearAccX, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.LinearAccY, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.LinearAccZ, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.GravX, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.GravY, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testKinematicMessageSize.GravZ, 0, messageValuesList);
            //Convert list to Array
            Byte[] messageinValues = messageValuesList.ToArray();
            Byte[] ExpectedArray   = { 4, 0, 0, 88, 2, 0, 0, 188, 2, 0, 0, 32, 3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 128, 12, 172, 13, 184, 11, 3, 0, 5, 0, 15, 0, 32, 0, 184, 11, 0, 0, 0, 0, 10, 0, 20, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            Assert.AreEqual(Convert.ToBase64String(ExpectedArray), Convert.ToBase64String(messageinValues));
        }
        // Save the users current state
        public override void SaveState()
        {
            string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
            Map    map      = GetMapObj(mapAlias);

            if (map != null)
            {
                SaveZoomCenterState(map);
                ManualSerializer.SaveMapXtremeObjectIntoHttpSession(map.Layers, "Layers");
                ManualSerializer.SaveMapXtremeObjectIntoHttpSession(MapInfo.Engine.Session.Current.Selections.DefaultSelection, "Selection");
                // Mark the users HTTPSession as dirty
                HttpContext.Current.Session["UserDirtyFlag"] = true;
            }
        }
示例#4
0
        // Save the state
        public override void SaveState()
        {
            string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
            Map    map      = MapInfo.Engine.Session.Current.MapFactory[mapAlias];

            if (map != null)
            {
                SaveZoomCenterState(map);
                ManualSerializer.SaveMapXtremeObjectIntoHttpSession(map.Layers, "Layers");
                ManualSerializer.SaveMapXtremeObjectIntoHttpSession(MapInfo.Engine.Session.Current.Selections.DefaultSelection, "Selection");
                //need to save map's Legends here
                ManualSerializer.SaveMapXtremeObjectIntoHttpSession(map.Legends, "Legends");
            }
        }
示例#5
0
        // When the session is not dirty these values are initial state of the session.
        private void SaveDefaultState(Map map)
        {
            HttpApplicationState application = HttpContext.Current.Application;

            if (application["Zoom"] == null)
            {
                // Store default selection
                application["Selection"] = ManualSerializer.BinaryStreamFromObject(MapInfo.Engine.Session.Current.Selections.DefaultSelection);
                // Store layers collection
                application["Layers"] = ManualSerializer.BinaryStreamFromObject(map.Layers);
                // Store the original zoom and center.
                application["Center"] = map.Center;
                application["Zoom"]   = map.Zoom;
            }
        }
        // When the MapXtreme Session is not dirty save the initial state of this session read from the
        // initial workspace from the web.config.
        private void SaveDefaultState(Map map)
        {
            HttpApplicationState application = HttpContext.Current.Application;

            if (application["DefaultZoom"] == null)
            {
                // Store default selection
                application["DefaultSelection"] = ManualSerializer.BinaryStreamFromObject(MapInfo.Engine.Session.Current.Selections.DefaultSelection);
                // Store layers collection
                application["DefaultLayers"] = ManualSerializer.BinaryStreamFromObject(map.Layers);
                // Store the original zoom and center.
                application["DefaultCenter"] = map.Center;
                application["DefaultZoom"]   = map.Zoom;
            }
            // This pooled MapXtreme Session instance should be marked as dirty
            MapInfo.Engine.Session.Current.CustomProperties["DirtyFlag"] = true;
        }
示例#7
0
        // When the session is not dirty these values are initial state of the session.
        private void SaveDefaultState(Map map)
        {
            HttpApplicationState application = HttpContext.Current.Application;

            if (application["DefaultZoom"] == null)
            {
                // Store default selection
                application["DefaultSelection"] = ManualSerializer.BinaryStreamFromObject(MapInfo.Engine.Session.Current.Selections.DefaultSelection);
                // Store layers collection
                application["DefaultLayers"] = ManualSerializer.BinaryStreamFromObject(map.Layers);
                // Store the original zoom and center.
                application["DefaultCenter"] = map.Center;
                application["DefaultZoom"]   = map.Zoom;
            }
            // Set the dirty flag in this MapXtreme Session Instance
            MapInfo.Engine.Session.Current.CustomProperties.Add("Dirty", true);
        }
示例#8
0
        // Restore the state
        public override void RestoreState()
        {
            string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
            Map    myMap    = GetMapObj(mapAlias);

            // If it was user's first time and the session was not dirty then save this default state to be applied later.
            // If it was a users's first time and the session was dirty then apply the default state  saved in above step to give users a initial state.
            if (IsUsersFirstTime())
            {
                if (IsDirtyMapXtremeSession())
                {
                    RestoreDefaultState(myMap);
                }
                else
                {
                    SaveDefaultState(myMap);
                }
            }
            else
            {
                AppStateManager.RestoreZoomCenterState(myMap);
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("mdb_table");
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("theme_table");
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("theme_layer");
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("group_layer");

                // Important Note:
                //   The saved theme layer, group layer and tables get restored automatically by ASP.NET serialization.
                //   By the time this method is called, this has already happened.

                // We need to move the GroupLayer to the Top, so the contents within it could be displayed.
                // This step is necessary since the GroupLayer is created on the fly and not loaded through pre-loaded workspace and
                // the position of the groupLayer inside the Layers collection is not guarantee when it get deserialized back
                // since we don't save the whole Layers collection for performance purpose in this sample.
                int indexOfGroupLayer = myMap.Layers.IndexOf(myMap.Layers[SampleConstants.GroupLayerAlias]);
                if (indexOfGroupLayer > 0)
                {
                    myMap.Layers.Move(indexOfGroupLayer, 0);
                    // Need to turn off other labellayer if we have a demo labellayer in the GroupLayer.
                    // This step is needed if "MapInfo.Engine.Session.Pooled" value="false" in the web.config,
                    // Otherwise you would see other LabelLayers show up on the map.
                    WebForm1.HandleLabelLayerVisibleStatus(myMap);
                }
            }
        }
        // Restore the users state
        public override void RestoreState()
        {
            string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
            Map    map      = GetMapObj(mapAlias);

            // If this is a clean pooled object save the default state for new users to
            // access later.
            if (!IsDirtyMapXtremeSession(map))
            {
                SaveDefaultState(map);
            }

            // If it was user's first time and the session is dirty, restore the default state.
            if (IsUsersFirstTime())
            {
                if (IsDirtyMapXtremeSession(map))
                {
                    RestoreDefaultState(map);
                }
            }
            else
            {
                // If this is an existing user then restore the last state they saved
                // Make sure to also check if this is a clean or dirty pooled object, you may
                // have to restore some base state or tables prior to restoring users state. The best
                // practice is to save all modified or added MapXtreme objects to the users state
                // and restore them in the correct order. But in some instances clean up or
                // initialization of the pooled MapXtreme Session may be necessary
                if (IsDirtyMapXtremeSession(map))
                {
                    // TODO: Manual work to prepare the dirty Pooled MapXtreme Session instance
                }
                else
                {
                    // TODO: Manual work to prepare the clean Pooled MapXtreme Session instance
                }
                RestoreZoomCenterState(map);

                // Just by deserializing the binary stream we reset the MapFactory Deault layers collection
                // Any MapXtreme class that supports the ISerializable interface will automatically be
                // restored to the current MapXtreme Session.
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Layers");
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Selection");
            }
        }
示例#10
0
        // Save the state
        public override void SaveState()
        {
            string mapAlias = this.ParamsDictionary[AppStateManager.ActiveMapAliasKey] as String;

            MapInfo.Mapping.Map map = GetMapObj(mapAlias);

            if (map == null)
            {
                return;
            }
            // 1. Only if the MapInfo.Engine.Session.State is set to "Manual" in the web.config,
            // We manually save objects below.
            // 2. The MapInfo Session object will be automatically saved and you need to do nothing,
            // if the MapInfo.Engine.Session.State is set to HttpSessionState.
            AppStateManager.SaveZoomCenterState(map);
            ManualSerializer.SaveMapXtremeObjectIntoHttpSession(MapInfo.Engine.Session.Current.Catalog, "Catalog");
            ManualSerializer.SaveMapXtremeObjectIntoHttpSession(map.Layers, "Layers");
        }
示例#11
0
        // When session is dirty but it is first time for user, this will be applied to give users it's initial state
        private void RestoreDefaultState(Map map)
        {
            HttpApplicationState application = HttpContext.Current.Application;

            // Get the default layers, center, and zoomfrom the Application. Clear Layers first,
            //this resets the zoom and center which we will set later
            map.Layers.Clear();

            //Just by deserializing the binary stream we reset the MapFactory Deault layers collection
            byte[] bytes = application["DefaultLayers"] as byte[];
            Object obj   = ManualSerializer.ObjectFromBinaryStream(bytes);

            // For default selection
            bytes = application["DefaultSelection"] as byte[];
            obj   = ManualSerializer.ObjectFromBinaryStream(bytes);

            // For zoom and center
            map.Zoom   = (MapInfo.Geometry.Distance)application["DefaultZoom"];
            map.Center = (MapInfo.Geometry.DPoint)application["DefaultCenter"];
        }
示例#12
0
 public static void StatusMessageParserFromByteArray(out StatusMessage messageToParse, StatusMessage statusMessageIndex, StatusMessage statusMessageSize, Byte[] arraytoParse)
 {
     messageToParse.OpCode = ManualSerializer.ReturnSByteValueFromByteArray(statusMessageIndex.OpCode,
                                                                            statusMessageSize.OpCode, arraytoParse);
     messageToParse.MessageCounter = ManualSerializer.ReturnInt16ValueFromByteArray(statusMessageIndex.MessageCounter,
                                                                                    statusMessageSize.MessageCounter, false, arraytoParse);
     messageToParse.IDPart1 = ManualSerializer.ReturnUint32ValueFromByteArray((int)statusMessageIndex.IDPart1,
                                                                              (int)statusMessageSize.IDPart1, false, arraytoParse);
     messageToParse.IDPart2 = ManualSerializer.ReturnUint32ValueFromByteArray((int)statusMessageIndex.IDPart2,
                                                                              (int)statusMessageSize.IDPart2, false, arraytoParse);
     messageToParse.IDPart3 = ManualSerializer.ReturnUint32ValueFromByteArray((int)statusMessageIndex.IDPart3,
                                                                              (int)statusMessageSize.IDPart3, false, arraytoParse);
     messageToParse.TimeSource = ManualSerializer.ReturnSByteValueFromByteArray(statusMessageIndex.TimeSource,
                                                                                statusMessageSize.TimeSource, arraytoParse);
     messageToParse.GPSYear = ManualSerializer.ReturnInt16ValueFromByteArray(statusMessageIndex.GPSYear,
                                                                             statusMessageSize.GPSYear, false, arraytoParse);
     messageToParse.GPSMonth = ManualSerializer.ReturnSByteValueFromByteArray(statusMessageIndex.GPSMonth,
                                                                              statusMessageSize.GPSMonth, arraytoParse);
     messageToParse.GPSDay = ManualSerializer.ReturnSByteValueFromByteArray(statusMessageIndex.GPSDay,
                                                                            statusMessageSize.GPSDay, arraytoParse);
     messageToParse.GPSHour = ManualSerializer.ReturnSByteValueFromByteArray(statusMessageIndex.GPSHour,
                                                                             statusMessageSize.GPSHour, arraytoParse);
     messageToParse.GPSMinute = ManualSerializer.ReturnSByteValueFromByteArray(statusMessageIndex.GPSMinute,
                                                                               statusMessageSize.GPSMinute, arraytoParse);
     messageToParse.GPSSecond = ManualSerializer.ReturnSByteValueFromByteArray(statusMessageIndex.GPSSecond,
                                                                               statusMessageSize.GPSSecond, arraytoParse);
     messageToParse.GPSMiliSec = ManualSerializer.ReturnInt16ValueFromByteArray(statusMessageIndex.GPSMiliSec,
                                                                                statusMessageSize.GPSMiliSec, false, arraytoParse);
     messageToParse.Mode = ManualSerializer.ReturnSByteValueFromByteArray(statusMessageIndex.Mode,
                                                                          statusMessageSize.Mode, arraytoParse);
     messageToParse.RTA = ManualSerializer.ReturnSByteValueFromByteArray(statusMessageIndex.RTA,
                                                                         statusMessageSize.RTA, arraytoParse);
     messageToParse.BCS = ManualSerializer.ReturnInt16ValueFromByteArray(statusMessageIndex.BCS,
                                                                         statusMessageSize.BCS, false, arraytoParse);
     messageToParse.IMUStatus = ManualSerializer.ReturnSByteValueFromByteArray(statusMessageIndex.IMUStatus,
                                                                               statusMessageSize.IMUStatus, arraytoParse);
     messageToParse.FDS = ManualSerializer.ReturnSByteValueFromByteArray(statusMessageIndex.FDS,
                                                                         statusMessageSize.FDS, arraytoParse);
     messageToParse.RCChannels = ManualSerializer.ReturnSByteValueFromByteArray(statusMessageIndex.RCChannels,
                                                                                statusMessageSize.RCChannels, arraytoParse);
 }
示例#13
0
 public static void KinematicMessageParserFromByteArray(out KinematicMessage messageToParse, KinematicMessage MessageIndex, KinematicMessage MessageSize, Byte[] arraytoParse)
 {
     messageToParse.OpCode         = ManualSerializer.ReturnSByteValueFromByteArray(MessageIndex.OpCode, MessageSize.OpCode, arraytoParse);
     messageToParse.MessageCounter = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.MessageCounter, MessageSize.MessageCounter, false, arraytoParse);
     messageToParse.IDPart1        = ManualSerializer.ReturnUint32ValueFromByteArray((int)MessageIndex.IDPart1, (int)MessageSize.IDPart1, false, arraytoParse);
     messageToParse.IDPart2        = ManualSerializer.ReturnUint32ValueFromByteArray((int)MessageIndex.IDPart2, (int)MessageSize.IDPart2, false, arraytoParse);
     messageToParse.IDPart3        = ManualSerializer.ReturnUint32ValueFromByteArray((int)MessageIndex.IDPart3, (int)MessageSize.IDPart3, false, arraytoParse);
     messageToParse.TimeSource     = ManualSerializer.ReturnSByteValueFromByteArray(MessageIndex.TimeSource, MessageSize.TimeSource, arraytoParse);
     messageToParse.GPSYear        = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.GPSYear, MessageSize.GPSYear, false, arraytoParse);
     messageToParse.GPSMonth       = ManualSerializer.ReturnSByteValueFromByteArray(MessageIndex.GPSMonth, MessageSize.GPSMonth, arraytoParse);
     messageToParse.GPSDay         = ManualSerializer.ReturnSByteValueFromByteArray(MessageIndex.GPSDay, MessageSize.GPSDay, arraytoParse);
     messageToParse.GPSHour        = ManualSerializer.ReturnSByteValueFromByteArray(MessageIndex.GPSHour, MessageSize.GPSHour, arraytoParse);
     messageToParse.GPSMinute      = ManualSerializer.ReturnSByteValueFromByteArray(MessageIndex.GPSMinute, MessageSize.GPSMinute, arraytoParse);
     messageToParse.GPSSecond      = ManualSerializer.ReturnSByteValueFromByteArray(MessageIndex.GPSSecond, MessageSize.GPSSecond, arraytoParse);
     messageToParse.GPSMiliSec     = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.GPSMiliSec, MessageSize.GPSMiliSec, false, arraytoParse);
     messageToParse.BaroHeight     = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.BaroHeight, MessageSize.BaroHeight, false, arraytoParse);
     messageToParse.Pressure       = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.Pressure, MessageSize.Pressure, false, arraytoParse);
     messageToParse.AccX           = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.AccX, MessageSize.AccX, false, arraytoParse);
     messageToParse.AccY           = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.AccY, MessageSize.AccY, false, arraytoParse);
     messageToParse.AccZ           = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.AccZ, MessageSize.AccZ, false, arraytoParse);
     messageToParse.MagX           = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.MagX, MessageSize.MagX, false, arraytoParse);
     messageToParse.MagY           = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.MagY, MessageSize.MagY, false, arraytoParse);
     messageToParse.MagZ           = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.MagZ, MessageSize.MagZ, false, arraytoParse);
     messageToParse.GyroX          = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.GyroX, MessageSize.GyroX, false, arraytoParse);
     messageToParse.GyroY          = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.GyroY, MessageSize.GyroY, false, arraytoParse);
     messageToParse.GyroZ          = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.GyroZ, MessageSize.GyroZ, false, arraytoParse);
     messageToParse.Heading        = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.Heading, MessageSize.Heading, false, arraytoParse);
     messageToParse.Roll           = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.Roll, MessageSize.Roll, false, arraytoParse);
     messageToParse.Pitch          = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.Pitch, MessageSize.Pitch, false, arraytoParse);
     messageToParse.OrientationX   = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.OrientationX, MessageSize.OrientationX, false, arraytoParse);
     messageToParse.OrientationY   = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.OrientationY, MessageSize.OrientationY, false, arraytoParse);
     messageToParse.OrientationZ   = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.OrientationZ, MessageSize.OrientationZ, false, arraytoParse);
     messageToParse.OrientationW   = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.OrientationW, MessageSize.OrientationW, false, arraytoParse);
     messageToParse.LinearAccX     = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.LinearAccX, MessageSize.LinearAccX, false, arraytoParse);
     messageToParse.LinearAccY     = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.LinearAccY, MessageSize.LinearAccY, false, arraytoParse);
     messageToParse.LinearAccZ     = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.LinearAccZ, MessageSize.LinearAccZ, false, arraytoParse);
     messageToParse.GravX          = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.GravX, MessageSize.GravX, false, arraytoParse);
     messageToParse.GravY          = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.GravY, MessageSize.GravY, false, arraytoParse);
     messageToParse.GravZ          = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.GravZ, MessageSize.GravZ, false, arraytoParse);
 }
        // When session is dirty but it is first time for user, this will be applied to give users it's initial state
        private void RestoreDefaultState(Map map)
        {
            HttpApplicationState application = HttpContext.Current.Application;

            // Get the default layers, center, and zoomfrom the Application. Clear Layers first,
            // this resets the zoom and center which we will set later
            map.Layers.Clear();

            // Just by deserializing the binary stream we reset the MapFactory Deault layers collection
            // Any MapXtreme class that supports the ISerializable interface will automatically be
            // restored to the current MapXtreme Session.
            byte[] bytes = application["DefaultLayers"] as byte[];
            Object obj   = ManualSerializer.ObjectFromBinaryStream(bytes);

            // Deserialzing rules are the same for the default selection
            bytes = application["DefaultSelection"] as byte[];
            obj   = ManualSerializer.ObjectFromBinaryStream(bytes);

            // For zoom and center, these are simple types and need to be assigned to the map object.
            map.Zoom   = (MapInfo.Geometry.Distance)application["DefaultZoom"];
            map.Center = (DPoint)application["DefaultCenter"];
        }
示例#15
0
        // Restore the state
        public override void RestoreState()
        {
            string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
            Map    map      = GetMapObj(mapAlias);

            if (map == null)
            {
                return;
            }

            // If it was user's first time and the session was not dirty then save this default state to be applied later.
            // If it was a users's first time and the session was dirty then apply the default state  saved in above step to give users a initial state.
            if (IsUsersFirstTime())
            {
                if (IsDirtyMapXtremeSession(map))
                {
                    RestoreDefaultState(map);
                }
                else
                {
                    SaveDefaultState(map);
                }
            }
            else
            {
                // If it is not user's first time then restore the last state they saved
                RestoreZoomCenterState(map);
                //ManualSerializer.RestoreMapXtremeObjectFromHttpSession("Layers");
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession(GetKey("Selection"));

                // Just by setting it to temp variables the objects are serialized into session. There is no need to set them explicitly.
                if (StateManager.IsManualState())
                {
                    ManualSerializer.RestoreMapXtremeObjectFromHttpSession("tempTable");
                    ManualSerializer.RestoreMapXtremeObjectFromHttpSession("tempLayer");
                }
            }
        }
示例#16
0
        public void PhysicalMessageEncodingTests()
        {
            PhysicalMessage testPhysicalMessageSize  = new PhysicalMessage();
            PhysicalMessage testPhysicalMessageIndex = new PhysicalMessage();

            MessageInitializers.PhysicalMessageFieldSizeInitializer(out testPhysicalMessageSize);
            MessageInitializers.PhysicalMessageFieldIndexInitializer(out testPhysicalMessageIndex);

            List <Byte> messageValuesList = new List <Byte>();

            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.OpCode, 3, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.MessageCounter, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList((int)testPhysicalMessageSize.IDPart1, 600, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList((int)testPhysicalMessageSize.IDPart2, 700, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList((int)testPhysicalMessageSize.IDPart3, 800, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.TimeSource, 2, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.GPSYear, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.GPSMonth, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.GPSDay, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.GPSHour, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.GPSMinute, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.GPSSecond, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.GPSMiliSec, 0, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.NumberOfSatellites, 17, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.Latitude, 32100000, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.Longitude, 35200000, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.GPSAltitude, 3000, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.GPSVelocity, 3, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.GPSAngle, 5, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.GPSGroundSpeed, 15, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.Temperature, 32, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.Humidity, 3000, messageValuesList);
            messageValuesList = ManualSerializer.EncodeValuesAsBytesInList(testPhysicalMessageSize.UVAUVB, 0, messageValuesList);
            //Convert list to Array
            Byte[] messageinValues = messageValuesList.ToArray();
            Byte[] ExpectedArray   = { 3, 0, 0, 88, 2, 0, 0, 188, 2, 0, 0, 32, 3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 160, 206, 233, 1, 0, 28, 25, 2, 184, 11, 3, 0, 5, 0, 15, 0, 32, 0, 184, 11, 0, 0 };
            Assert.AreEqual(Convert.ToBase64String(ExpectedArray), Convert.ToBase64String(messageinValues));
        }
示例#17
0
        // Save the state
        public override void SaveState()
        {
            string mapAlias = this.ParamsDictionary[AppStateManager.ActiveMapAliasKey] as String;

            MapInfo.Mapping.Map myMap = GetMapObj(mapAlias);

            if (myMap == null)
            {
                return;
            }

            // Note: for performance reasons, only save the map's center and zoom.
            AppStateManager.SaveZoomCenterState(myMap);

            // Get the workingLayerName saved in WebForm1.aspx page_load.
            string workingLayerName = this.ParamsDictionary["WorkingLayerName"] as String;

            // Save the map's Working table and layer
            MapInfo.Mapping.FeatureLayer workingLayer = (MapInfo.Mapping.FeatureLayer)myMap.Layers[workingLayerName];
            MapInfo.Data.Table           workingTable = workingLayer != null ? workingLayer.Table : null;
            ManualSerializer.SaveMapXtremeObjectIntoHttpSession(workingTable, "WorkingTable");
            ManualSerializer.SaveMapXtremeObjectIntoHttpSession(workingLayer, "WorkingLayer");
        }
示例#18
0
        public void TestManualSerializer()
        {
            var testList = new List <TestObj>()
            {
                new TestObj()
                {
                    FooString = "Test\"St\\ring", BarDecimal = 9.23m, BazInt = 77
                },
                new TestObj()
                {
                    FooString = "OtherTestString", BarDecimal = 113m, BazInt = -44
                },
            };

            var knownGood = JsonSerializer.Serialize(testList);

            var memoryStream = new MemoryStream();

            ManualSerializer.Serialize(testList, new Utf8JsonWriter(memoryStream));
            var serializedOutput = Encoding.UTF8.GetString(memoryStream.ToArray());

            Assert.AreEqual(knownGood, serializedOutput);
        }
示例#19
0
        // Save the state
        public override void SaveState()
        {
            string mapAlias = this.ParamsDictionary[AppStateManager.ActiveMapAliasKey] as String;

            MapInfo.Mapping.Map map = GetMapObj(mapAlias);

            if (map != null)
            {
                MapInfo.WebControls.StateManager.SaveZoomCenterState(map);
                // Note: Please be aware of the order of assigning below objects to HttpContext.Current.Session.
                // The order matters in this case since theme_table contains some temp columns constructed from mdb_table.
                // and some themes/modifiers in the theme_layer are based on the theme_table.
                ManualSerializer.SaveMapXtremeObjectIntoHttpSession(MapInfo.Engine.Session.Current.Catalog[SampleConstants.EWorldAlias], "mdb_table");
                //HttpContext.Current.Session["mdb_table"] = MapInfo.Engine.Session.Current.Catalog[SampleConstants.EWorldAlias];
                ManualSerializer.SaveMapXtremeObjectIntoHttpSession(MapInfo.Engine.Session.Current.Catalog[SampleConstants.ThemeTableAlias], "theme_table");
                //HttpContext.Current.Session["theme_table"] = MapInfo.Engine.Session.Current.Catalog[SampleConstants.ThemeTableAlias];
                ManualSerializer.SaveMapXtremeObjectIntoHttpSession(map.Layers[SampleConstants.ThemeLayerAlias], "theme_layer");
                //HttpContext.Current.Session["theme_layer"] = map.Layers[SampleConstants.ThemeLayerAlias];
                // Group Layer holds temp object theme or label layers which varies with requests.
                ManualSerializer.SaveMapXtremeObjectIntoHttpSession(map.Layers[SampleConstants.GroupLayerAlias], "group_layer");
                //HttpContext.Current.Session["group_layer"] = map.Layers[SampleConstants.GroupLayerAlias];
            }
        }
示例#20
0
        // Save the state
        public override void SaveState()
        {
            string mapAlias = this.ParamsDictionary[AppStateManager.ActiveMapAliasKey] as String;

            // Get the map
            MapInfo.Mapping.Map myMap = GetMapObj(mapAlias);
            if (myMap == null)
            {
                return;
            }

            // 1. Only if the MapInfo.Engine.Session.State is set to "Manual" in the web.config,
            // We manually save objects below.
            // 2. The MapInfo Session object will be automatically saved and you need to do nothing,
            // if the MapInfo.Engine.Session.State is set to HttpSessionState.
            AppStateManager.SaveZoomCenterState(myMap);
            ManualSerializer.SaveMapXtremeObjectIntoHttpSession(myMap.Layers, GetKey("Layers"));

            // Save NorthArrowAdornment.
            if (myMap.Adornments["north_arrow"] != null)
            {
                ManualSerializer.SaveMapXtremeObjectIntoHttpSession(myMap.Adornments["north_arrow"], "north_adornment");
            }
        }
示例#21
0
        // Restore the state
        public override void RestoreState()
        {
            string mapAlias = ParamsDictionary[ActiveMapAliasKey] as string;
            Map    myMap    = GetMapObj(mapAlias);

            // If it was user's first time and the session was not dirty then save this default state to be applied later.
            // If it was a users's first time and the session was dirty then apply the default state  saved in above step to give users a initial state.
            if (IsUsersFirstTime())
            {
                if (IsDirtyMapXtremeSession())
                {
                    RestoreDefaultState(myMap);
                }
                else
                {
                    SaveDefaultState(myMap);
                }
            }
            else
            {
                if (myMap == null)
                {
                    return;
                }
                // Restore everything we saved explictly.
                AppStateManager.RestoreZoomCenterState(myMap);
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("WorkingTable");
                ManualSerializer.RestoreMapXtremeObjectFromHttpSession("WorkingLayer");

                // Get the workingLayerName saved in WebForm1.aspx page_load.
                string workingLayerName = this.ParamsDictionary["WorkingLayerName"] as String;
                int    indexOfLayer     = myMap.Layers.IndexOf(myMap.Layers[workingLayerName]);
                // Move the working layer to the Top, so it can be displayed.
                myMap.Layers.Move(indexOfLayer, 0);
            }
        }
示例#22
0
 public AppStateManager()
 {
     _session = new ManualSerializer();
 }
        static void Main(string[] args)
        {
            Student student = new Student()
            {
                FirstName = "Risto",
                LastName  = "Panchevski",
                Age       = 32,
                Active    = true,
                Subjects  = new List <Subject>()
                {
                    new Subject()
                    {
                        Name    = "C#",
                        Classes = 40
                    },
                    new Subject()
                    {
                        Name    = "C# Advance",
                        Classes = 60
                    }
                }
            };

            #region Manual Serialization

            //Expected Result (JSON)
            //{"FirstName": "Risto", "LastName": "Panchevski", "Age": "32", "Active": "true"}
            Console.WriteLine("--------------------Manual--------------------");
            string manualSerialization = ManualSerializer.SerializeStudent(student);
            Console.WriteLine(manualSerialization);

            Student manualDeserialization = ManualSerializer.DeserializeStudent(manualSerialization);
            Console.WriteLine(manualDeserialization.FullName);

            #endregion

            #region System.Text.Json

            Console.WriteLine("--------------------System.Text.Json--------------------");

            string jsonSerialization = System.Text.Json.JsonSerializer.Serialize(student);
            Console.WriteLine(jsonSerialization);

            Student jsonDeserialization = System.Text.Json.JsonSerializer.Deserialize <Student>(jsonSerialization);
            Console.WriteLine(jsonDeserialization.FullName);

            #endregion

            #region Newtonsoft.JSON

            Console.WriteLine("--------------------Newtonsoft.JSON--------------------");
            string newtonsoftSerialization = JsonConvert.SerializeObject(student);
            Console.WriteLine(newtonsoftSerialization);

            Student newtonsoftDeserialization = JsonConvert.DeserializeObject <Student>(newtonsoftSerialization);
            Console.WriteLine(newtonsoftDeserialization?.FullName);


            //{"Ime": "Risto", "Prezime": "Panchevski", "Godini": "32", "Aktiven": "true"} => Uncomment the comments in Student.cs

            #endregion
        }
示例#24
0
        static void Main(string[] args)
        {
            /*Some Hack to Make MQTT messaging Work, Otherwise next messages are not sent*/
            //Publ publisher = new Publ();
            //publisher.Publish();
            const string     IotEndpoint             = "a28g8imipibhcw.iot.us-east-1.amazonaws.com";
            const int        BrokerPort              = 8883;
            const string     DeviceStatusTopic       = "DeviceStatus";
            const string     PhysicalDataTopic       = "PhysicalData";
            const string     KinematicDataTopic      = "KinematicData";
            const string     InitializationDataTopic = "InitData";
            X509Certificate2 clientCert              = new X509Certificate2("YOURPFXFILE.pfx", "1");
            X509Certificate  caCert = X509Certificate.CreateFromSignedFile("rootCA.pem");

            // create the client
            MqttClient client = new MqttClient(IotEndpoint, BrokerPort, true, caCert, clientCert, MqttSslProtocols.TLSv1_2);

            //message to publish - could be anything
            //client naming has to be unique if there was more than one publisher
            client.Connect("clientid1");

            //publish to the topic
            Byte[] A = { 2 };
            client.Publish("hello", A, 0, false);

            //string Message = "";
            Console.WriteLine("Hello World!");

            //For Future use when Export form DB will have millisecond

            /* StreamReader reader = new StreamReader(@"/Users/nadavguy/Downloads/physical-data-messages-2018-04-08.csv");
             * while (!reader.EndOfStream)
             * {
             *   var line = reader.ReadLine();
             *   var values = line.Split(',');
             *   Convert.ToDateTime(values[6].Substring(0,19))
             * }*/

            //Play old data capured from IoT (not DB export)
            //DataPlayer.playerFromIoTCapture(@"/Users/nadavguy/Downloads/subscription2.csv", client);

//Initialize messages
            //Status message
            StatusMessage StatusMessageFieldsSize = new StatusMessage();

            MessageInitializers.StatusMessageFieldSizeInitializer(out StatusMessageFieldsSize);

            StatusMessage StatusMessageFieldsIndex = new StatusMessage();

            MessageInitializers.StatusMessageFieldIndexInitializer(out StatusMessageFieldsIndex);

            //Physical message
            PhysicalMessage PhysicalMessageFieldsSize = new PhysicalMessage();

            MessageInitializers.PhysicalMessageFieldSizeInitializer(out PhysicalMessageFieldsSize);

            PhysicalMessage PhysicalMessageFieldsIndex = new PhysicalMessage();

            MessageInitializers.PhysicalMessageFieldIndexInitializer(out PhysicalMessageFieldsIndex);

            //Kinematic message
            KinematicMessage KinematicMessageFieldsSize = new KinematicMessage();

            MessageInitializers.KinematicMessageFieldSizeInitializer(out KinematicMessageFieldsSize);

            KinematicMessage KinematicMessageFieldsIndex = new KinematicMessage();

            MessageInitializers.KinematicMessageFieldIndexInitializer(out KinematicMessageFieldsIndex);

            //Initialization message
            InitializtionMessage InitMessageFieldsSize = new InitializtionMessage();

            MessageInitializers.InitMessageFieldSizeInitializer(out InitMessageFieldsSize);

            InitializtionMessage InitMessageFieldsIndex = new InitializtionMessage();

            MessageInitializers.InitMessageFieldIndexInitializer(out InitMessageFieldsIndex);
            //Start Application part

            WriteDefaultValues(fileName);
            //Parse old string message form IoT Core export to actual vlaues
            //will be used later for testing I guess

            /*
             * SByte OpCode = ManualSerializer.ReturnSByteValue(0, 1);
             * Int16 MessageCounter = ManualSerializer.ReturnInt16Value(1, 2, false);
             * UInt32 IDPart1 = ManualSerializer.ReturnUint32Value(3, 4, false);
             * UInt32 IDPart2 = ManualSerializer.ReturnUint32Value(7, 4, false);
             * UInt32 IDPart3 = ManualSerializer.ReturnUint32Value(11, 4, false);
             * SByte TimeSource = ManualSerializer.ReturnSByteValue(15, 1);
             * Int16 GPSYear = ManualSerializer.ReturnInt16Value(16, 2,false);
             * SByte GPSMonth = ManualSerializer.ReturnSByteValue(18, 1);
             * SByte GPSDay = ManualSerializer.ReturnSByteValue(19, 1);
             * SByte GPSHour = ManualSerializer.ReturnSByteValue(20, 1);
             * SByte GPSMinute = ManualSerializer.ReturnSByteValue(21, 1);
             * SByte GPSSecond = ManualSerializer.ReturnSByteValue(22, 1);
             * Int16 GPSMiliSecond = ManualSerializer.ReturnInt16Value(23, 2, false);
             * SByte Mode = ManualSerializer.ReturnSByteValue(25, 1);
             * SByte RTA = ManualSerializer.ReturnSByteValue(26, 1);
             * Int16 BCS = ManualSerializer.ReturnInt16Value(27, 2, false);
             * SByte IMUStatus = ManualSerializer.ReturnSByteValue(29, 1);
             * SByte FDS = ManualSerializer.ReturnSByteValue(30, 1);
             * SByte RCChannels = ManualSerializer.ReturnSByteValue(31, 1);
             */

            /*
             * StatusMessage ParsedStatusMessage = new StatusMessage();
             * MessageParser.StatusMessageParser(out ParsedStatusMessage, StatusMessageFieldsIndex, StatusMessageFieldsSize);
             */
            /* Part of the try to create a Byte array manuall and sending it using external MQTT applicaiton
             * it did not work. apperantly MQTT does so weird stuff to the payload.
             * added MQTT library.
             * Code is obsolete
             * Message += ManualSerializer.EncodeValuesAsBytes(1, (uint)2) + ",";
             * Message += ManualSerializer.EncodeValuesAsBytes(2, (uint)0) + ",";
             * Message += ManualSerializer.EncodeValuesAsBytes(4, 300) + ",";
             * Message += ManualSerializer.EncodeValuesAsBytes(4, 400) + ",";
             * Message += ManualSerializer.EncodeValuesAsBytes(4, 500) + ",";
             * Message += ManualSerializer.EncodeValuesAsBytes(1, (uint)2) + ",";//Accurate
             * Message += ManualSerializer.EncodeValuesAsBytes(2, (uint)0) + ",";//Year
             * Message += ManualSerializer.EncodeValuesAsBytes(1, (uint)0) + ",";//Month
             * Message += ManualSerializer.EncodeValuesAsBytes(1, (uint)0) + ",";//Day
             * Message += ManualSerializer.EncodeValuesAsBytes(1, (uint)0) + ",";//Hour
             * Message += ManualSerializer.EncodeValuesAsBytes(1, (uint)0) + ",";//Min
             * Message += ManualSerializer.EncodeValuesAsBytes(1, (uint)0) + ",";//Sec
             * Message += ManualSerializer.EncodeValuesAsBytes(2, (uint)0) + ",";//Mili
             * Message += ManualSerializer.EncodeValuesAsBytes(1, (uint)6) + ",";//Mode
             * Message += ManualSerializer.EncodeValuesAsBytes(1, (uint)1) + ",";//Ready To Arm
             * Message += ManualSerializer.EncodeValuesAsBytes(2, (uint)10) + ",";//Battery LSB=0.1
             * Message += ManualSerializer.EncodeValuesAsBytes(1, (uint)1) + ",";//IMU
             * Message += ManualSerializer.EncodeValuesAsBytes(1, (uint)3) + ",";//Flash
             * Message += ManualSerializer.EncodeValuesAsBytes(1, (uint)1);//RC*/

            //Encode Byte Array using list.
            List <Byte> termsList = new List <Byte>();

            //termsList = EncodeValuesAsBytesInList(4, 400, termsList);

            //Generate Status message
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.OpCode, (uint)2,
                                                                   termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.MessageCounter,
                                                                   (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)StatusMessageFieldsSize.IDPart1,
                                                                   600, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)StatusMessageFieldsSize.IDPart2,
                                                                   700, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)StatusMessageFieldsSize.IDPart3,
                                                                   800, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.TimeSource,
                                                                   (uint)2, termsList);   //Accurate
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSYear,
                                                                   (uint)0, termsList);   //Year
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSMonth,
                                                                   (uint)0, termsList);   //Month
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSDay,
                                                                   (uint)0, termsList);   //Day
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSHour,
                                                                   (uint)0, termsList);   //Hour
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSMinute,
                                                                   (uint)0, termsList);   //Min
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSSecond,
                                                                   (uint)0, termsList);   //Sec
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSMiliSec,
                                                                   (uint)0, termsList);   //Mili
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.Mode,
                                                                   (uint)2, termsList);   //Mode
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.RTA,
                                                                   (uint)2, termsList);   //Ready To Arm
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.BCS,
                                                                   (uint)160, termsList); //Battery LSB=0.1
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.IMUStatus,
                                                                   (uint)2, termsList);   //IMU
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.FDS,
                                                                   (uint)3, termsList);   //Flash
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.RCChannels,
                                                                   (uint)0, termsList);   //RC
            //2,0,0,3,0,0,0,4,0,0,0,5,0,0,0,0  ,0    ,0    ,0   ,0  ,0   ,0  ,0  ,0    ,0    ,0   ,0  ,255 ,0   ,1  ,1  ,3
            //2,0,0,3,0,0,0,4,0,0,0,5,0,0,0,Acc,YearL,YearH,Mnth,Day,Hour,Min,Sec,MiliL,MiliH,Mode,RTA,BCSL,BCSH,IMU,FSD,RC
            //2,0,0,3,0,0,0,4,0,0,0,5,0,0,0,1  ,0    ,0    ,0   ,0  ,0   ,0  ,0  ,0    ,0    ,6   ,1  ,10  ,0   ,1  ,3  ,1
            //Convert list to Array
            Byte[] terms = termsList.ToArray();
            //client.Connect("clientid1");
            //Publish message
            client.Publish(DeviceStatusTopic, terms, 0, false);

            termsList.Clear();
            //Generate Physical data message
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.OpCode, 3, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.MessageCounter, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)PhysicalMessageFieldsSize.IDPart1, 600, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)PhysicalMessageFieldsSize.IDPart2, 700, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)PhysicalMessageFieldsSize.IDPart3, 800, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.TimeSource, 2, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSYear, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSMonth, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSDay, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSHour, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSMinute, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSSecond, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSMiliSec, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.NumberOfSatellites, 17, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.Latitude, 32100000, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.Longitude, 35200000, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSAltitude, 3000, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSVelocity, 3, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSAngle, 5, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSGroundSpeed, 15, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.Temperature, 32, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.Humidity, 3000, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.UVAUVB, 0, termsList);
            Byte[] terms2 = termsList.ToArray();
            //client.Connect("clientid1");
            client.Publish(PhysicalDataTopic, terms2, 0, false);

            //Generate Kinematic message
            termsList.Clear();
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.OpCode, 4, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.MessageCounter, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)KinematicMessageFieldsSize.IDPart1, 600, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)KinematicMessageFieldsSize.IDPart2, 700, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)KinematicMessageFieldsSize.IDPart3, 800, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.TimeSource, 2, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSYear, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSMonth, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSDay, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSHour, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSMinute, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSSecond, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSMiliSec, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.BaroHeight, 17, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.Pressure, 3200, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.AccX, 3500, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.AccY, 3000, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.AccZ, 3, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.MagX, 5, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.MagY, 15, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.MagZ, 32, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GyroX, 3000, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GyroY, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GyroZ, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.Heading, 10, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.Roll, 20, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.Pitch, 40, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.OrientationX, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.OrientationY, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.OrientationZ, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.OrientationW, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.LinearAccX, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.LinearAccY, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.LinearAccZ, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GravX, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GravY, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GravZ, 0, termsList);

            Byte[] terms3 = termsList.ToArray();
            //client.Connect("clientid1");
            client.Publish(KinematicDataTopic, terms3, 0, false);

            //Generate Initialization message
            termsList.Clear();
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.OpCode, (uint)1, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.MessageCounter, (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)InitMessageFieldsSize.IDPart1, (uint)600, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)InitMessageFieldsSize.IDPart2, (uint)700, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)InitMessageFieldsSize.IDPart3, (uint)800, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.TimeSource, (uint)1, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.GPSYear, (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.GPSMonth, (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.GPSDay, (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.GPSHour, (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.GPSMinute, (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.GPSSecond, (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.GPSMiliSec, (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.SWVersionID, (uint)1000, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.HWVersionID, (uint)1000, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.ArmHeight, (uint)5, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.DisarmHeight, (uint)3, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.VibrationsValue, (uint)2, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.NoVibrationTime, (uint)250, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.VibrationFrequency, (uint)5, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.RollCalibration, (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.PitchCalibration, (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.RollInitMargin, (uint)5, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.PitchInitMargin, (uint)5, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.IMUConfiguration, (uint)15, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.RCConfiguration, (uint)3, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.BatteryCells, (uint)4, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.MotorDelay, (uint)50, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.RollAttitudeLimit, (uint)65, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.PitchAttitudeLimit, (uint)65, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.FreefallDuration, (uint)250, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.FreefallLimit, (uint)3, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.AngularSpeedRateLimit, (uint)150, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.AngularSpeedLimit, (uint)65, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.YawRateLimit, (uint)150, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.ActiveHeightSource, (uint)1, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.MaximumHeight, (uint)1, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.LandingGear, (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.ArmMode, (uint)1, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.PyroSensorCalib, (uint)35, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.PyroSensorMeasurement, (uint)19, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.PyroTestRate, (uint)15, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.EmergencyBattery, (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.Destination, (uint)1, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.SDCard, (uint)1, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.TriggeringMode, (uint)1, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.FiveVoltIndication, (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.EmergencyBatteryVoltageIndication, (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.TwelveVoltageIndication, (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(InitMessageFieldsSize.CapacitorVoltageIndication, (uint)0, termsList);

            //Convert list to Array
            Byte[] terms7 = termsList.ToArray();
            //client.Connect("clientid1");
            //Publish message
            client.Publish(InitializationDataTopic, terms7, 0, false);


            termsList.Clear();
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.OpCode, (uint)2,
                                                                   termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.MessageCounter,
                                                                   (uint)0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)StatusMessageFieldsSize.IDPart1,
                                                                   600, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)StatusMessageFieldsSize.IDPart2,
                                                                   700, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)StatusMessageFieldsSize.IDPart3,
                                                                   900, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.TimeSource,
                                                                   (uint)2, termsList);   //Accurate
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSYear,
                                                                   (uint)0, termsList);   //Year
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSMonth,
                                                                   (uint)0, termsList);   //Month
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSDay,
                                                                   (uint)0, termsList);   //Day
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSHour,
                                                                   (uint)0, termsList);   //Hour
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSMinute,
                                                                   (uint)0, termsList);   //Min
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSSecond,
                                                                   (uint)0, termsList);   //Sec
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSMiliSec,
                                                                   (uint)0, termsList);   //Mili
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.Mode,
                                                                   (uint)6, termsList);   //Mode
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.RTA,
                                                                   (uint)1, termsList);   //Ready To Arm
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.BCS,
                                                                   (uint)160, termsList); //Battery LSB=0.1
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.IMUStatus,
                                                                   (uint)1, termsList);   //IMU
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.FDS,
                                                                   (uint)3, termsList);   //Flash
            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.RCChannels,
                                                                   (uint)0, termsList);   //RC
            //2,0,0,3,0,0,0,4,0,0,0,5,0,0,0,0  ,0    ,0    ,0   ,0  ,0   ,0  ,0  ,0    ,0    ,0   ,0  ,255 ,0   ,1  ,1  ,3
            //2,0,0,3,0,0,0,4,0,0,0,5,0,0,0,Acc,YearL,YearH,Mnth,Day,Hour,Min,Sec,MiliL,MiliH,Mode,RTA,BCSL,BCSH,IMU,FSD,RC
            //2,0,0,3,0,0,0,4,0,0,0,5,0,0,0,1  ,0    ,0    ,0   ,0  ,0   ,0  ,0  ,0    ,0    ,6   ,1  ,10  ,0   ,1  ,3  ,1
            //Convert list to Array
            Byte[] terms6 = termsList.ToArray();
            //client.Connect("clientid1");
            //Publish message
            client.Publish(DeviceStatusTopic, terms6, 0, false);

            termsList.Clear();
            //Generate Physical data message
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.OpCode, 3, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.MessageCounter, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)PhysicalMessageFieldsSize.IDPart1, 600, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)PhysicalMessageFieldsSize.IDPart2, 700, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)PhysicalMessageFieldsSize.IDPart3, 900, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.TimeSource, 2, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSYear, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSMonth, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSDay, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSHour, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSMinute, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSSecond, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSMiliSec, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.NumberOfSatellites, 17, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.Latitude, 32000000, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.Longitude, 35000000, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSAltitude, 3000, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSVelocity, 3, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSAngle, 5, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSGroundSpeed, 15, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.Temperature, 32, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.Humidity, 3000, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.UVAUVB, 0, termsList);
            Byte[] terms5 = termsList.ToArray();
            //client.Connect("clientid1");
            client.Publish(PhysicalDataTopic, terms5, 0, false);

            //Generate Kinematic message
            termsList.Clear();
            //Generate Physical data message
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.OpCode, 4, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.MessageCounter, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)KinematicMessageFieldsSize.IDPart1, 600, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)KinematicMessageFieldsSize.IDPart2, 700, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)KinematicMessageFieldsSize.IDPart3, 900, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.TimeSource, 2, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSYear, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSMonth, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSDay, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSHour, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSMinute, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSSecond, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSMiliSec, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.BaroHeight, 17, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.Pressure, 3200, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.AccX, 3500, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.AccY, 3000, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.AccZ, 3, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.MagX, 5, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.MagY, 15, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.MagZ, 32, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GyroX, 3000, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GyroY, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GyroZ, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.Heading, 10, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.Roll, 20, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.Pitch, 40, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.OrientationX, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.OrientationY, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.OrientationZ, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.OrientationW, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.LinearAccX, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.LinearAccY, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.LinearAccZ, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GravX, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GravY, 0, termsList);
            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GravZ, 0, termsList);

            Byte[] terms4 = termsList.ToArray();
            //client.Connect("clientid1");
            client.Publish(KinematicDataTopic, terms4, 0, false);


            //client.Disconnect();

            /*
             * StatusMessage NewMessage = new StatusMessage();
             * NewMessage.OpCode = OpCode;
             * NewMessage.MessageCounter = MessageCounter;
             * NewMessage.IDPart1 = IDPart1;
             * NewMessage.IDPart2 = IDPart2;
             * NewMessage.IDPart3 = IDPart3;
             * NewMessage.TimeSource = TimeSource;
             * NewMessage.GPSYear = 2018;
             * NewMessage.GPSMonth = 4;
             * NewMessage.GPSDay = 4;
             * NewMessage.GPSHour = 14;
             * NewMessage.GPSMinute = 5;
             * NewMessage.GPSSecond = 0;
             * NewMessage.GPSMiliSec = 0;
             * NewMessage.Mode = Mode;
             * NewMessage.RTA = RTA;
             * NewMessage.BCS = BCS;
             * NewMessage.IMUStatus = IMUStatus;
             * NewMessage.FDS = FDS;
             * NewMessage.RCChannels = RCChannels;
             *
             * string Message2 = Encoders.MessageEncoder.StatusMessageEncoder(NewMessage, StatusMessageFieldsSize);
             */
//            client.Disconnect();
            Console.WriteLine("Its the End of the world as we know it!");
        }
示例#25
0
        static public void playerFromIoTCapture(string fileToPlay, MqttClient client)
        {
            Stopwatch stopWatch   = new Stopwatch();
            TimeSpan  startTime   = new TimeSpan();
            TimeSpan  currentTime = new TimeSpan();

            //StreamReader reader = new StreamReader(@"/Users/nadavguy/Downloads/subscription.csv");
            StreamReader reader = new StreamReader(fileToPlay);

            StatusMessage statusMessagetoParse = new StatusMessage();

            KinematicMessage kinematicMessagetoParse = new KinematicMessage();

            PhysicalMessage physicalMessagetoParse = new PhysicalMessage();

            StatusMessage StatusMessageFieldsSize = new StatusMessage();

            MessageInitializers.StatusMessageFieldSizeInitializer(out StatusMessageFieldsSize);

            StatusMessage StatusMessageFieldsIndex = new StatusMessage();

            MessageInitializers.StatusMessageFieldIndexInitializer(out StatusMessageFieldsIndex);

            //Kinematic message
            KinematicMessage KinematicMessageFieldsSize = new KinematicMessage();

            MessageInitializers.KinematicMessageFieldSizeInitializer(out KinematicMessageFieldsSize);

            KinematicMessage KinematicMessageFieldsIndex = new KinematicMessage();

            MessageInitializers.KinematicMessageFieldIndexInitializer(out KinematicMessageFieldsIndex);

            //Physical message
            PhysicalMessage PhysicalMessageFieldsSize = new PhysicalMessage();

            MessageInitializers.PhysicalMessageFieldSizeInitializer(out PhysicalMessageFieldsSize);

            PhysicalMessage PhysicalMessageFieldsIndex = new PhysicalMessage();

            MessageInitializers.PhysicalMessageFieldIndexInitializer(out PhysicalMessageFieldsIndex);

            List <string> listHex       = new List <string>();
            List <string> listPayload   = new List <string>();
            List <string> listQoS       = new List <string>();
            List <string> listTimestamp = new List <string>();
            List <string> listTopic     = new List <string>();

            while (!reader.EndOfStream)
            {
                var line   = reader.ReadLine();
                var values = line.Split(',');

                listHex.Add(values[0]);
                listPayload.Add(values[1]);
                listQoS.Add(values[2]);
                listTimestamp.Add(values[3]);
                listTopic.Add(values[4]);
            }
            double baseTimestamp = Convert.ToDouble(listTimestamp[0]);

            startTime = DateTime.Now.TimeOfDay;
            //stopWatch.Start();
            int i = 0;

            while (i < listHex.Count)
            {
                currentTime = DateTime.Now.TimeOfDay;
                //stopWatch.Stop();
                // Get the elapsed time as a TimeSpan value.
                //ts = stopWatch.Elapsed;
                // Using ID 600-700-800 for the data playerso it hard coded
                for (int j = i; j < listHex.Count; j++)
                {
                    if ((double)(currentTime - startTime).TotalMilliseconds > (Convert.ToDouble(listTimestamp[j]) - baseTimestamp))
                    {
                        i++;
                        if (listTopic[j].Equals(DeviceStatusTopic))
                        {
                            byte[] statusbyteArray = Encoding.UTF8.GetBytes(listPayload[j]);
                            MessageParser.StatusMessageParserFromByteArray(out statusMessagetoParse, StatusMessageFieldsIndex, StatusMessageFieldsSize, statusbyteArray);

                            List <Byte> termsList = new List <Byte>();

                            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.OpCode, (uint)statusMessagetoParse.OpCode, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.MessageCounter, (uint)statusMessagetoParse.MessageCounter, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)StatusMessageFieldsSize.IDPart1, 600, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)StatusMessageFieldsSize.IDPart2, 700, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)StatusMessageFieldsSize.IDPart3, 800, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.TimeSource, (uint)statusMessagetoParse.TimeSource, termsList); //Accurate
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSYear, (uint)0, termsList);                                  //Year
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSMonth, (uint)0, termsList);                                 //Month
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSDay, (uint)0, termsList);                                   //Day
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSHour, (uint)0, termsList);                                  //Hour
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSMinute, (uint)0, termsList);                                //Min
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSSecond, (uint)0, termsList);                                //Sec
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.GPSMiliSec, (uint)0, termsList);                               //Mili
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.Mode, (uint)statusMessagetoParse.Mode, termsList);             //Mode
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.RTA, (uint)statusMessagetoParse.RTA, termsList);               //Ready To Arm
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.BCS, (uint)statusMessagetoParse.BCS, termsList);               //Battery LSB=0.1
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.IMUStatus, (uint)statusMessagetoParse.IMUStatus, termsList);   //IMU
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.FDS, (uint)statusMessagetoParse.FDS, termsList);               //Flash
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(StatusMessageFieldsSize.RCChannels, (uint)statusMessagetoParse.RCChannels, termsList); //RC
                            Byte[] terms = termsList.ToArray();
                            client.Publish(DeviceStatusTopic, terms, 0, false);
                        }

                        if (listTopic[j].Equals(KinematicDataTopic))
                        {
                            byte[] statusbyteArray = Encoding.UTF8.GetBytes(listPayload[j]);
                            MessageParser.KinematicMessageParserFromByteArray(out kinematicMessagetoParse, KinematicMessageFieldsIndex, KinematicMessageFieldsSize, statusbyteArray);

                            List <Byte> termsList = new List <Byte>();

                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.OpCode, (uint)kinematicMessagetoParse.OpCode, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.MessageCounter, (uint)kinematicMessagetoParse.MessageCounter, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)KinematicMessageFieldsSize.IDPart1, 600, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)KinematicMessageFieldsSize.IDPart2, 700, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)KinematicMessageFieldsSize.IDPart3, 800, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.TimeSource, (uint)statusMessagetoParse.TimeSource, termsList); //Accurate
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSYear, (uint)0, termsList);                                  //Year
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSMonth, (uint)0, termsList);                                 //Month
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSDay, (uint)0, termsList);                                   //Day
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSHour, (uint)0, termsList);                                  //Hour
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSMinute, (uint)0, termsList);                                //Min
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSSecond, (uint)0, termsList);                                //Sec
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GPSMiliSec, (uint)0, termsList);                               //Mili
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.BaroHeight, (uint)kinematicMessagetoParse.BaroHeight, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.Pressure, (uint)kinematicMessagetoParse.Pressure, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.AccX, (uint)kinematicMessagetoParse.AccX, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.AccY, (uint)kinematicMessagetoParse.AccY, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.AccZ, (uint)kinematicMessagetoParse.AccZ, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.MagX, (uint)kinematicMessagetoParse.MagX, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.MagY, (uint)kinematicMessagetoParse.MagY, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.MagZ, (uint)kinematicMessagetoParse.MagZ, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GyroX, (uint)kinematicMessagetoParse.GyroX, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GyroY, (uint)kinematicMessagetoParse.GyroY, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GyroZ, (uint)kinematicMessagetoParse.GyroZ, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.Heading, (uint)kinematicMessagetoParse.Heading, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.Roll, (uint)kinematicMessagetoParse.Roll, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.Pitch, (uint)kinematicMessagetoParse.Pitch, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.OrientationX, (uint)kinematicMessagetoParse.OrientationX, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.OrientationY, (uint)kinematicMessagetoParse.OrientationY, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.OrientationZ, (uint)kinematicMessagetoParse.OrientationZ, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.OrientationW, (uint)kinematicMessagetoParse.OrientationW, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.LinearAccX, (uint)kinematicMessagetoParse.LinearAccX, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.LinearAccY, (uint)kinematicMessagetoParse.LinearAccY, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.LinearAccZ, (uint)kinematicMessagetoParse.LinearAccZ, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GravX, (uint)kinematicMessagetoParse.GravX, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GravY, (uint)kinematicMessagetoParse.GravY, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(KinematicMessageFieldsSize.GravZ, (uint)kinematicMessagetoParse.GravZ, termsList);
                            Byte[] terms = termsList.ToArray();
                            client.Publish(KinematicDataTopic, terms, 0, false);
                        }

                        if (listTopic[j].Equals(PhysicalDataTopic))
                        {
                            byte[] statusbyteArray = Encoding.UTF8.GetBytes(listPayload[j]);
                            MessageParser.PhysicalMessageParserFromByteArray(out physicalMessagetoParse, PhysicalMessageFieldsIndex, PhysicalMessageFieldsSize, statusbyteArray);

                            List <Byte> termsList = new List <Byte>();

                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.OpCode, (uint)physicalMessagetoParse.OpCode, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.MessageCounter, (uint)physicalMessagetoParse.MessageCounter, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)PhysicalMessageFieldsSize.IDPart1, 600, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)PhysicalMessageFieldsSize.IDPart2, 700, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList((int)PhysicalMessageFieldsSize.IDPart3, 800, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.TimeSource, (uint)physicalMessagetoParse.TimeSource, termsList); //Accurate
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSYear, (uint)0, termsList);                                    //Year
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSMonth, (uint)0, termsList);                                   //Month
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSDay, (uint)0, termsList);                                     //Day
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSHour, (uint)0, termsList);                                    //Hour
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSMinute, (uint)0, termsList);                                  //Min
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSSecond, (uint)0, termsList);                                  //Sec
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSMiliSec, (uint)0, termsList);                                 //Mili
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.NumberOfSatellites, (uint)physicalMessagetoParse.NumberOfSatellites, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.Latitude, (uint)physicalMessagetoParse.Latitude, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.Longitude, (uint)physicalMessagetoParse.Longitude, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSAltitude, (uint)physicalMessagetoParse.GPSAltitude, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSVelocity, (uint)physicalMessagetoParse.GPSVelocity, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSAngle, (uint)physicalMessagetoParse.GPSAngle, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.GPSGroundSpeed, (uint)physicalMessagetoParse.GPSGroundSpeed, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.Temperature, (uint)physicalMessagetoParse.Temperature, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.Humidity, (uint)physicalMessagetoParse.Humidity, termsList);
                            termsList = ManualSerializer.EncodeValuesAsBytesInList(PhysicalMessageFieldsSize.UVAUVB, (uint)physicalMessagetoParse.UVAUVB, termsList);
                            Byte[] terms = termsList.ToArray();
                            client.Publish(PhysicalDataTopic, terms, 0, false);
                        }
                    }
                }
            }
        }
示例#26
0
 public void ManualSerializerBench()
 {
     using var writer = new Utf8JsonWriter(Stream.Null, Options);
     ManualSerializer.Serialize(TestObjects, writer);
 }