Exemple #1
0
        /*
         * Function: generatePacket(Telemetry tel, int packetNum)
         * Description: generate packet from the telemetry data
         */
        private static Packet generatePacket(Telemetry tel, int packetNum)
        {
            // generate packet head
            PacketHead head = new PacketHead(tel.TailNum, packetNum);

            // generate packet body
            // bild telemetry data string for body
            String     telData = $"{tel.TimeStamp},{tel.Accel_x},{tel.Accel_y},{tel.Accel_z},{tel.Weight},{tel.Altitude},{tel.Pitch},{tel.Bank}";
            PacketBody body    = new PacketBody(telData);

            // generate packet tail
            int           checkSum = Packet.calculateCheckSum(tel);
            PacketTrailer trailer  = new PacketTrailer(checkSum);

            // generate packet
            Packet packet = new Packet(head, body, trailer);

            return(packet);
        }
Exemple #2
0
 public Packet(PacketHead packetHeader, PacketBody packetBody, PacketTrailer packetTrailer)
 {
     head    = packetHeader;
     body    = packetBody;
     trailer = packetTrailer;
 }