Exemplo n.º 1
0
        public void Initialize()
        {
            Ros.MasterUri = new Uri("http://localhost:11311/");
            Ros.HostName = "localhost";
            Ros.TopicTimeout = 1000;
            Ros.XmlRpcTimeout = 1000;

            _masterServer = new MasterServer(11311);

            _masterClient = new MasterClient(_masterServer.MasterUri);
            _parameterServerClient = new ParameterServerClient(_masterServer.MasterUri);
        }
        public void DeleteParam_Success()
        {
            var result = new object[3]
            {
                1,
                "parameter /test_param deleted",
                0
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MParameterServerProxy.AllInstances.BeginDeleteParamStringStringAsyncCallbackObject= (t1, t2, t3, t4, t5) => { t4(null); return null; };
            MParameterServerProxy.AllInstances.EndDeleteParamIAsyncResult= (t1, t2) => result;

            var client = new ParameterServerClient(new Uri("http://localhost"));
            client.DeleteParamAsync("test", "test_param").Wait();
        }
        public void DeleteParam_NotSet()
        {
            var result = new object[3]
            {
                -1,
                "parameter [/aaa] is not set",
                0
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MParameterServerProxy.AllInstances.BeginDeleteParamStringStringAsyncCallbackObject = (t1, t2, t3, t4, t5) => { t4(null); return null; };
            MParameterServerProxy.AllInstances.EndDeleteParamIAsyncResult = (t1, t2) => result;

            var client = new ParameterServerClient(new Uri("http://localhost"));

            var ex = AssertEx.Throws<AggregateException>(
                () => client.DeleteParamAsync("test", "aaa").Wait());
            ex.InnerException.Message.Is("parameter [/aaa] is not set");
        }
        public void GetParamNames_Success()
        {
            var result = new object[3]
            {
                1,
                "Parameter names",
                new string[4]
                {
                    "/roslaunch/uris/host_192_168_11_6__51664",
                    "/rosversion",
                    "/rosdistro",
                    "/run_id"
                }
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MParameterServerProxy.AllInstances.BeginGetParamNamesStringAsyncCallbackObject = (t1, t2, t3, t4) => { t3(null); return null; };
            MParameterServerProxy.AllInstances.EndGetParamNamesIAsyncResult= (t1, t2) => result;

            var client = new ParameterServerClient(new Uri("http://localhost"));
            client.GetParamNamesAsync("test").Result.Is(
                new string[] {"/roslaunch/uris/host_192_168_11_6__51664","/rosversion","/rosdistro","/run_id"});
        }
Exemplo n.º 5
0
        Task IParameter.InitializeAsync(string nodeId, string paramName, Uri slaveUri, ParameterServerClient client)
        {
            NodeId  = nodeId;
            _logger = RosOutLogManager.GetCurrentNodeLogger(NodeId);

            Name      = paramName;
            _slaveUri = slaveUri;

            _parameterServerClient = client;

            return(_parameterServerClient.HasParamAsync(NodeId, Name)
                   .ContinueWith(task =>
            {
                if (task.Result)
                {
                    return _parameterServerClient.GetParamAsync(NodeId, Name);
                }
                else
                {
                    return _parameterServerClient.SetParamAsync(NodeId, Name, new XmlRpcStruct());
                }
            })
                   .Unwrap());
        }
        public void UnsubscribeParam_Success()
        {
            var result = new object[3]
            {
                1,
                "Unsubscribe to parameter [/rosversion]",
                1
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MParameterServerProxy.AllInstances.BeginUnsubscribeParamStringStringStringAsyncCallbackObject = (t1, t2, t3, t4, t5, t6) => { t5(null); return null; };
            MParameterServerProxy.AllInstances.EndUnsubscribeParamIAsyncResult= (t1, t2) => result;

            var client = new ParameterServerClient(new Uri("http://localhost"));
            client.UnsubscribeParamAsync("test", new Uri("http://localhost:11311"), "rosversion").Result.Is(1);
        }
        public void SetParam_Success()
        {
            var result = new object[3]
            {
                1,
                "Parameter [/rosversion]",
                "1.6.5"
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MParameterServerProxy.AllInstances.BeginSetParamStringStringObjectAsyncCallbackObject = (t1, t2, t3, t4, t5, t6) => { t5(null); return null; };
            MParameterServerProxy.AllInstances.EndSetParamIAsyncResult= (t1, t2) => result;

            var client = new ParameterServerClient(new Uri("http://localhost"));
            client.SetParamAsync("test", "/test_param", 1234).Wait();
        }
        public void SearchParam_Failure()
        {
            var result = new object[3]
            {
                0,
                "Internal failure: namespace must be global",
                0
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MParameterServerProxy.AllInstances.BeginSearchParamStringStringAsyncCallbackObject= (t1, t2, t3, t4, t5) => { t4(null); return null; };
            MParameterServerProxy.AllInstances.EndSearchParamIAsyncResult= (t1, t2) => result;

            var client = new ParameterServerClient(new Uri("http://localhost"));

            var ex = AssertEx.Throws<AggregateException>(
                () => client.SearchParamAsync("test", "rosversion").Wait());
            ex.InnerException.Message.Is("Internal failure: namespace must be global");
        }
        public void HasParam_SuccessTrue()
        {
            var result = new object[3]
            {
                1,
                "/rosversion",
                true
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MParameterServerProxy.AllInstances.BeginHasParamStringStringAsyncCallbackObject = (t1, t2, t3, t4, t5) => { t4(null); return null; };
            MParameterServerProxy.AllInstances.EndHasParamIAsyncResult= (t1, t2) => result;

            var client = new ParameterServerClient(new Uri("http://localhost"));
            client.HasParamAsync("test", "/rosversion").Result.Is(true);
        }
Exemplo n.º 10
0
        public void GetParam_SuccessList()
        {
            // > rosparam set /foo "['1', 1, 1.0]"

            var result = new object[3]
            {
                1,
                "Parameter [/foo]",
                new object[3]
                {
                    "1",
                    1,
                    1.0
                }
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MParameterServerProxy.AllInstances.BeginGetParamStringStringAsyncCallbackObject = (t1, t2, t3, t4, t5) => { t4(null); return null; };
            MParameterServerProxy.AllInstances.EndGetParamIAsyncResult = (t1, t2) => result;

            var client = new ParameterServerClient(new Uri("http://localhost"));
            var ret = client.GetParamAsync("test", "foo").Result as object[];
            ret[0].Is("1");
            ret[1].Is(1);
            ret[2].Is(1.0);
        }
Exemplo n.º 11
0
        public void GetParam_SuccessDictionary()
        {
            // rosparam set /gains "p: 1.0
            // i: 1.0
            // d: 1.0"

            var result = new object[3]
            {
                1,
                "Parameter [/gains]",
                new object[3]
                {
                    "1",
                    1,
                    1.0
                }
            };

            MXmlRpcClientProtocol.AllInstances.UrlSetString = (t1, t2) => { };
            MParameterServerProxy.AllInstances.BeginGetParamStringStringAsyncCallbackObject = (t1, t2, t3, t4, t5) => { t4(null); return null; };
            MParameterServerProxy.AllInstances.EndGetParamIAsyncResult = (t1, t2) => result;

            var client = new ParameterServerClient(new Uri("http://localhost"));
            client.GetParamAsync("test", "gains").Wait();
        }