public void GetChannelInfoIterative()
        {
            Assert.IsTrue(client.GetChannelsCount() == 4);

            ChannelInfo channel;

            channel = client.GetChannel(0);
            Assert.IsNotNull(channel);
            Assert.IsTrue(channel.Name == "phase");

            channel = client.GetChannel(1);
            Assert.IsNotNull(channel);
            Assert.IsTrue(channel.Name == "delta");

            channel = client.GetChannel(2);
            Assert.IsNotNull(channel);
            Assert.IsTrue(channel.Name == "ball_position");

            channel = client.GetChannel(3);
            Assert.IsNotNull(channel);
            Assert.IsTrue(channel.Name == "ball_height");

            channel = client.GetChannel(4);
            Assert.IsNull(channel);
        }
Exemple #2
0
        public void GetChannels(string serverAddress)
        {
            List <ChannelInfo> channels = new List <ChannelInfo>();
            ChannelInformationRetrieverClient client = null;

            try
            {
                WriteStatus("Connecting to server...");
                EndpointAddress epAddress = new EndpointAddress(serverAddress);
                client = new ChannelInformationRetrieverClient(new WSDualHttpBinding(WSDualHttpSecurityMode.None), epAddress);

                WriteStatus("Getting channel data...");
                if (client != null)
                {
                    long channelCount = client.GetChannelsCount();
                    SetProgressBarLimits((int)channelCount);
                    for (long i = 0; i < channelCount; i++)
                    {
                        channels.Add(client.GetChannel(i));
                        SetProgressBarValue((int)i);
                    }
                }
                client.Close();
            }
            catch (Exception exception)
            {
                string message = string.Format("Error during connection to server: {0}", exception.Message);
                if (client != null && client.State == CommunicationState.Opened)
                {
                    client.Close();
                }
                NotifyOperationComplete(false, channels.ToArray(), message);
                return;
            }

            NotifyOperationComplete(true, channels.ToArray(), "");
        }