/// <summary>Transmit stop video streaming command request.</summary>
        /// <exception cref="FaultException">Thrown when a Fault error condition occurs.</exception>
        /// <param name="client">The emebedded web service client.</param>
        /// <param name="request">The request to send to embedded.</param>
        private static void TransmitStopVideoStreamingCommandRequest(LiveVideoControlServiceClient client, ProcessStopVideoStreamingCommandRequestContext request)
        {
            LiveVideoControlRspEnumType result = LiveVideoControlRspEnumType.StartVideoStreamingCommandReceived;

            try
            {
                result = client.StopVideoStreamingCommand(request.RequestId.ToString());
            }
            catch (FaultException)
            {
                // When there is a SOAP fault while sending, we still notify that we sent the request
                RequestProcessor.SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.LiveVideoControlDistributionSent, request.ElementId);
                throw;
            }

            RequestProcessor.SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.LiveVideoControlDistributionSent, request.ElementId);

            if (result == LiveVideoControlRspEnumType.StopVideoStreamingCommandReceived)
            {
                RequestProcessor.SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.LiveVideoControlDistributionReceived, request.ElementId);
            }
            else
            {
                RequestProcessor.SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.LiveVideoControlErrorUndefined, request.ElementId);
            }

            request.TransmissionStatus = true;
        }
 /// <summary>Transmit start video streaming command request.</summary>
 /// <param name="client">The emebedded web service client.</param>
 /// <param name="request">The request to send to embedded.</param>
 private static void TransmitSendVideoStreamingStatusRequest(LiveVideoControlServiceClient client, ProcessSendVideoStreamingStatusRequestContext request)
 {
     client.SendVideoStreamingStatusCommand();
 }
        /// <summary>Transmit request to embedded system.</summary>
        /// <param name="request">The request to send to embedded.</param>
        private static void TransmitRequest(RequestContext request)
        {
            bool requestIsTransmitted = false;

            ServiceInfo serviceInfo;

            // Check if target element is online
            bool elementIsOnline;
            T2GManagerErrorEnum rqstResult = _train2groundManager.IsElementOnline(request.ElementId, out elementIsOnline);

            switch (rqstResult)
            {
            case T2GManagerErrorEnum.eSuccess:
                if (elementIsOnline == true)
                {
                    T2GManagerErrorEnum result = _train2groundManager.GetAvailableServiceData(request.ElementId, (int)eServiceID.eSrvSIF_LiveVideoControlServer, out serviceInfo);
                    switch (result)
                    {
                    case T2GManagerErrorEnum.eSuccess:
                    {
                        string endpoint = "http://" + serviceInfo.ServiceIPAddress + ":" + serviceInfo.ServicePortNumber;
                        try
                        {
                            // Call LiveVideoControl train service
                            using (LiveVideoControlServiceClient trainClient = new LiveVideoControlServiceClient("LiveVideoControlEndpoint", endpoint))
                            {
                                try
                                {
                                    if (request is ProcessStopVideoStreamingCommandRequestContext)
                                    {
                                        RequestProcessor.TransmitStopVideoStreamingCommandRequest(trainClient, request as ProcessStopVideoStreamingCommandRequestContext);
                                    }
                                    else if (request is ProcessStartVideoStreamingCommandRequestContext)
                                    {
                                        RequestProcessor.TransmitStartVideoStreamingCommandRequest(trainClient, request as ProcessStartVideoStreamingCommandRequestContext);
                                    }
                                    else if (request is ProcessSendVideoStreamingStatusRequestContext)
                                    {
                                        RequestProcessor.TransmitSendVideoStreamingStatusRequest(trainClient, request as ProcessSendVideoStreamingStatusRequestContext);
                                    }
                                    else
                                    {
                                        // No other request type supported
                                    }

                                    requestIsTransmitted = true;
                                }
                                catch (Exception ex)
                                {
                                    if (!RequestProcessor.ShouldContinueOnTransmissionError(ex))
                                    {
                                        // Assume transmitted (no reason to retry)
                                        requestIsTransmitted = true;
                                    }
                                }
                                finally
                                {
                                    if (trainClient.State == CommunicationState.Faulted)
                                    {
                                        trainClient.Abort();
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            if (!RequestProcessor.ShouldContinueOnTransmissionError(ex))
                            {
                                // Assume transmitted (no reason to retry)
                                requestIsTransmitted = true;
                            }
                        }
                    }

                    break;

                    case T2GManagerErrorEnum.eT2GServerOffline:
                        RequestProcessor.SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.LiveVideoControlT2GServerOffline, string.Empty);
                        break;

                    case T2GManagerErrorEnum.eElementNotFound:
                        RequestProcessor.SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.LiveVideoControlElementNotFound, request.ElementId);
                        break;

                    case T2GManagerErrorEnum.eServiceInfoNotFound:
                        RequestProcessor.SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.LiveVideoControlServiceNotFound, request.ElementId);
                        break;

                    default:
                        break;
                    }
                }

                break;

            case T2GManagerErrorEnum.eT2GServerOffline:
                RequestProcessor.SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.LiveVideoControlT2GServerOffline, string.Empty);
                break;

            case T2GManagerErrorEnum.eElementNotFound:
                requestIsTransmitted = true;
                RequestProcessor.SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.LiveVideoControlElementNotFound, request.ElementId);
                break;

            default:
                break;
            }

            request.TransmissionStatus = requestIsTransmitted;

            if (request.State == RequestState.WaitingRetry && request.TransferAttemptsDone == 1)
            {
                // first attempt failed, send notification
                RequestProcessor.SendNotificationToGroundApp(request.RequestId, PIS.Ground.GroundCore.AppGround.NotificationIdEnum.LiveVideoControlDistributionWaitingToSend, request.ElementId);
            }
        }