Пример #1
0
 public static void PhysicalMessageFieldIndexInitializer(out PhysicalMessage MessageFieldsIndex)
 {
     MessageFieldsIndex.OpCode             = 0;
     MessageFieldsIndex.MessageCounter     = 1;
     MessageFieldsIndex.IDPart1            = 3;
     MessageFieldsIndex.IDPart2            = 7;
     MessageFieldsIndex.IDPart3            = 11;
     MessageFieldsIndex.TimeSource         = 15;
     MessageFieldsIndex.GPSYear            = 16;
     MessageFieldsIndex.GPSMonth           = 18;
     MessageFieldsIndex.GPSDay             = 19;
     MessageFieldsIndex.GPSHour            = 20;
     MessageFieldsIndex.GPSMinute          = 21;
     MessageFieldsIndex.GPSSecond          = 22;
     MessageFieldsIndex.GPSMiliSec         = 23;
     MessageFieldsIndex.NumberOfSatellites = 24;
     MessageFieldsIndex.Latitude           = 28;
     MessageFieldsIndex.Longitude          = 32;
     MessageFieldsIndex.GPSAltitude        = 34;
     MessageFieldsIndex.GPSVelocity        = 36;
     MessageFieldsIndex.GPSAngle           = 38;
     MessageFieldsIndex.GPSGroundSpeed     = 40;
     MessageFieldsIndex.Temperature        = 42;
     MessageFieldsIndex.Humidity           = 44;
     MessageFieldsIndex.UVAUVB             = 46;
 }
Пример #2
0
 public static void PhysicalMessageParserFromByteArray(out PhysicalMessage messageToParse, PhysicalMessage MessageIndex, PhysicalMessage 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.NumberOfSatellites = ManualSerializer.ReturnSByteValueFromByteArray(MessageIndex.NumberOfSatellites, MessageSize.NumberOfSatellites, arraytoParse);
     messageToParse.Latitude           = (int)ManualSerializer.ReturnUint32ValueFromByteArray(MessageIndex.Latitude, MessageSize.Latitude, false, arraytoParse);
     messageToParse.Longitude          = (int)ManualSerializer.ReturnUint32ValueFromByteArray(MessageIndex.Longitude, MessageSize.Longitude, false, arraytoParse);
     messageToParse.GPSAltitude        = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.GPSAltitude, MessageSize.GPSAltitude, false, arraytoParse);
     messageToParse.GPSVelocity        = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.GPSVelocity, MessageSize.GPSVelocity, false, arraytoParse);
     messageToParse.GPSAngle           = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.GPSAngle, MessageSize.GPSAngle, false, arraytoParse);
     messageToParse.GPSGroundSpeed     = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.GPSGroundSpeed, MessageSize.GPSGroundSpeed, false, arraytoParse);
     messageToParse.Temperature        = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.Temperature, MessageSize.Temperature, false, arraytoParse);
     messageToParse.Humidity           = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.Humidity, MessageSize.Humidity, false, arraytoParse);
     messageToParse.UVAUVB             = ManualSerializer.ReturnInt16ValueFromByteArray(MessageIndex.UVAUVB, MessageSize.UVAUVB, false, arraytoParse);
 }
Пример #3
0
 public static void PhysicalMessageFieldSizeInitializer(out PhysicalMessage MessageFieldsSize)
 {
     MessageFieldsSize.OpCode             = 1;
     MessageFieldsSize.MessageCounter     = 2;
     MessageFieldsSize.IDPart1            = 4;
     MessageFieldsSize.IDPart2            = 4;
     MessageFieldsSize.IDPart3            = 4;
     MessageFieldsSize.TimeSource         = 1;
     MessageFieldsSize.GPSYear            = 2;
     MessageFieldsSize.GPSMonth           = 1;
     MessageFieldsSize.GPSDay             = 1;
     MessageFieldsSize.GPSHour            = 1;
     MessageFieldsSize.GPSMinute          = 1;
     MessageFieldsSize.GPSSecond          = 1;
     MessageFieldsSize.GPSMiliSec         = 2;
     MessageFieldsSize.NumberOfSatellites = 1;
     MessageFieldsSize.Latitude           = 4;
     MessageFieldsSize.Longitude          = 4;
     MessageFieldsSize.GPSAltitude        = 2;
     MessageFieldsSize.GPSVelocity        = 2;
     MessageFieldsSize.GPSAngle           = 2;
     MessageFieldsSize.GPSGroundSpeed     = 2;
     MessageFieldsSize.Temperature        = 2;
     MessageFieldsSize.Humidity           = 2;
     MessageFieldsSize.UVAUVB             = 2;
     //return MessageFieldsSize;
 }
Пример #4
0
        public static string PhysicalMessageEncoder(PhysicalMessage MessageFields, PhysicalMessage MessageFieldsIndex)
        {
            string Message = "";

            Message += EncodeValues(MessageFieldsIndex.OpCode, (uint)MessageFields.OpCode);
            Message += EncodeValues(MessageFieldsIndex.MessageCounter, (uint)MessageFields.MessageCounter);
            Message += EncodeValues((int)MessageFieldsIndex.IDPart1, MessageFields.IDPart1);
            Message += EncodeValues((int)MessageFieldsIndex.IDPart2, MessageFields.IDPart2);
            Message += EncodeValues((int)MessageFieldsIndex.IDPart3, MessageFields.IDPart3);
            Message += EncodeValues(MessageFieldsIndex.TimeSource, (uint)MessageFields.TimeSource);
            Message += EncodeValues(MessageFieldsIndex.GPSYear, (uint)MessageFields.GPSYear);
            Message += EncodeValues(MessageFieldsIndex.GPSMonth, (uint)MessageFields.GPSMonth);
            Message += EncodeValues(MessageFieldsIndex.GPSDay, (uint)MessageFields.GPSDay);
            Message += EncodeValues(MessageFieldsIndex.GPSHour, (uint)MessageFields.GPSHour);
            Message += EncodeValues(MessageFieldsIndex.GPSMinute, (uint)MessageFields.GPSMinute);
            Message += EncodeValues(MessageFieldsIndex.GPSSecond, (uint)MessageFields.GPSSecond);
            Message += EncodeValues(MessageFieldsIndex.GPSMiliSec, (uint)MessageFields.GPSMiliSec);
            Message += EncodeValues(MessageFieldsIndex.NumberOfSatellites, (uint)MessageFields.NumberOfSatellites);
            Message += EncodeValues(MessageFieldsIndex.Latitude, (uint)MessageFields.Latitude);
            Message += EncodeValues(MessageFieldsIndex.Longitude, (uint)MessageFields.Longitude);
            Message += EncodeValues(MessageFieldsIndex.GPSAltitude, (uint)MessageFields.GPSAltitude);
            Message += EncodeValues(MessageFieldsIndex.GPSVelocity, (uint)MessageFields.GPSVelocity);
            Message += EncodeValues(MessageFieldsIndex.GPSAngle, (uint)MessageFields.GPSAngle);
            Message += EncodeValues(MessageFieldsIndex.GPSGroundSpeed, (uint)MessageFields.GPSGroundSpeed);
            Message += EncodeValues(MessageFieldsIndex.Temperature, (uint)MessageFields.Temperature);
            Message += EncodeValues(MessageFieldsIndex.Humidity, (uint)MessageFields.Humidity);
            Message += EncodeValues(MessageFieldsIndex.UVAUVB, (uint)MessageFields.UVAUVB);

            return(Message);
        }
Пример #5
0
        public void PhysicalMessageSize()
        {
            PhysicalMessage testPhysicalMessageSize = new PhysicalMessage();

            MessageInitializers.PhysicalMessageFieldSizeInitializer(out testPhysicalMessageSize);

            int physicalMessageSize = (int)(testPhysicalMessageSize.OpCode + testPhysicalMessageSize.MessageCounter
                                            + testPhysicalMessageSize.IDPart1
                                            + testPhysicalMessageSize.IDPart2
                                            + testPhysicalMessageSize.IDPart3
                                            + testPhysicalMessageSize.TimeSource
                                            + testPhysicalMessageSize.GPSYear
                                            + testPhysicalMessageSize.GPSMonth
                                            + testPhysicalMessageSize.GPSDay
                                            + testPhysicalMessageSize.GPSHour
                                            + testPhysicalMessageSize.GPSMinute
                                            + testPhysicalMessageSize.GPSSecond
                                            + testPhysicalMessageSize.GPSMiliSec
                                            + testPhysicalMessageSize.NumberOfSatellites
                                            + testPhysicalMessageSize.Latitude
                                            + testPhysicalMessageSize.Longitude
                                            + testPhysicalMessageSize.GPSAltitude
                                            + testPhysicalMessageSize.GPSVelocity
                                            + testPhysicalMessageSize.GPSAngle
                                            + testPhysicalMessageSize.GPSGroundSpeed
                                            + testPhysicalMessageSize.Temperature
                                            + testPhysicalMessageSize.Humidity
                                            + testPhysicalMessageSize.UVAUVB);

            Assert.AreEqual(48, physicalMessageSize);
        }
Пример #6
0
        public void dataPlayerPhysicalMessageParseFromByteArray()
        {
            PhysicalMessage physicalMessagetoParse   = new PhysicalMessage();
            PhysicalMessage physicalMessagetoCompare = new PhysicalMessage();

            PhysicalMessage PhysicalMessageFieldsSize = new PhysicalMessage();

            MessageInitializers.PhysicalMessageFieldSizeInitializer(out PhysicalMessageFieldsSize);

            PhysicalMessage PhysicalMessageFieldsIndex = new PhysicalMessage();

            MessageInitializers.PhysicalMessageFieldIndexInitializer(out PhysicalMessageFieldsIndex);

            Byte[] statusbyteArray = Encoding.UTF8.GetBytes("03280126003f001751353235363633020000000000183bc00200000000000000000000000000000000003b0e5a020000");

            MessageParser.PhysicalMessageParserFromByteArray(out physicalMessagetoParse, PhysicalMessageFieldsIndex, PhysicalMessageFieldsSize, statusbyteArray);

            physicalMessagetoCompare.OpCode             = 3;
            physicalMessagetoCompare.MessageCounter     = 296;
            physicalMessagetoCompare.IDPart1            = 4128806;
            physicalMessagetoCompare.IDPart2            = 842354967;
            physicalMessagetoCompare.IDPart3            = 859190837;
            physicalMessagetoCompare.TimeSource         = 2;
            physicalMessagetoCompare.GPSYear            = 0;
            physicalMessagetoCompare.GPSMonth           = 0;
            physicalMessagetoCompare.GPSDay             = 0;
            physicalMessagetoCompare.GPSHour            = 0;
            physicalMessagetoCompare.GPSMinute          = 24;
            physicalMessagetoCompare.GPSSecond          = 59;
            physicalMessagetoCompare.GPSMiliSec         = 704;
            physicalMessagetoCompare.NumberOfSatellites = 2;
            physicalMessagetoCompare.Latitude           = 0;
            physicalMessagetoCompare.Longitude          = 0;
            physicalMessagetoCompare.GPSAltitude        = 0;
            physicalMessagetoCompare.GPSVelocity        = 0;
            physicalMessagetoCompare.GPSAngle           = 0;
            physicalMessagetoCompare.GPSGroundSpeed     = 0;
            physicalMessagetoCompare.Temperature        = 3643;
            physicalMessagetoCompare.Humidity           = 602;
            physicalMessagetoCompare.UVAUVB             = 0;

            Assert.AreEqual(physicalMessagetoCompare, physicalMessagetoParse);
        }
Пример #7
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));
        }
Пример #8
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);
                        }
                    }
                }
            }
        }
Пример #9
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!");
        }