Esempio n. 1
0
        /// <summary>
        /// Encode the frame and send it over to the transmitter.
        /// </summary>
        /// <param name="frame"></param>
        private void SendFrame(Frame frame)
        {
            // Prepare the frame to be sent on the wire (converts to BitArray and encode for error control with Hamming)
            BitArray frameBitArray = frame.GetFrameAsByteArray();
            Tuple <BitArray, HammingHelper.Status> tuple = HammingHelper.EncryptManager(frameBitArray, CorrectionMode, EncodedFramePadding);
            BitArray encodedFrameBitArray = tuple.Item1;

            // Notify subscriber that frame is being sent
            sendFrameDelegate(frame, Constants.FrameEvent.FrameSent, StationId);

            Console.WriteLine("{4, 11} {0, 12} : id={1, 2}, type={2, 4}, ack={3, 2}, data lenght={5, 3}", "SendFrame", frame.Id, frame.Type.ToString(), frame.Ack, StationId == Constants.StationId.Station1 ? "Station 1" : "Station 2", frame.DataSize);

            // Send the data
            transmitter.SendData(encodedFrameBitArray, StationId);
        }