Exemple #1
0
 //编辑事件
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         if (Label2.Text.Trim() == "")
         {
             Response.Write("<script>alert('照片不能为空!')</script>");
         }
         else
         {
             NT_Models.Action action = new NT_Models.Action();
             action.Act_Title   = txtTitle.Text.Trim();
             action.Act_Img     = Label2.Text;
             action.Act_Content = CKEditorControl1.Text.Trim();
             action.Act_Time    = DateTime.Now;
             int result = ActionServer.insert(action);
             if (result >= 1)
             {
                 Response.Write("<script>alert('发布成功!')</script>");
                 Label2.Text = "Img\\ActionImg\\";
             }
         }
     }
     catch (Exception ex)
     {
         Response.Write("<script>alert('上传失败');</script> 原因是:" + ex);
     }
 }
        private void BindBC()
        {
            DataTable dt = ActionServer.selectAll();

            if (dt != null && dt.Rows.Count != 0)
            {
                action.DataSource = dt;
                action.DataBind();
            }
        }
Exemple #3
0
        //数据绑定
        private void BindAct()
        {
            DataTable dt = ActionServer.selectAll();

            if (dt != null && dt.Rows.Count > 0)
            {
                ListView1.DataSource = dt;
                ListView1.DataBind();
            }
        }
Exemple #4
0
        //删除事件
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            Button bt = (Button)sender;
            int    id = Convert.ToInt32(((HiddenField)(bt.Parent.FindControl("HiddenField1"))).Value);

            if (ActionServer.DeleteAction(id) > 0)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "message", "<script language='javascript' >alert('删除成功!');</script>");
                BindAct();
            }
        }
Exemple #5
0
        static void Main(string[] args)
        {
#if (DEBUG)
            Environment.SetEnvironmentVariable("ROS_MASTER_URI", "http://localhost:11311/");
#endif
            Console.WriteLine("Start ROS");
            ROS.Init(ref args, "ActionServerClientSlowDummy");

            ICallbackQueue callbackQueue = new CallbackQueue();

            var asyncSpinner = new AsyncSpinner(callbackQueue);
            asyncSpinner.Start();

            NodeHandle nodeHandle = new NodeHandle(callbackQueue);

            ActionClient <Messages.actionlib.TestGoal, Messages.actionlib.TestResult,
                          Messages.actionlib.TestFeedback> actionClient = null;

            // setup action server start
            Console.WriteLine("Create server");
            var actionServer = new ActionServer <Messages.actionlib.TestGoal, Messages.actionlib.TestResult,
                                                 Messages.actionlib.TestFeedback>(nodeHandle, "test_action");
            Param.Set("status_list_timeout", 999.9);
            actionServer.RegisterGoalCallback((sgoalHandle) =>
            {
                Thread thread = new Thread(() => serverGoalCallback(sgoalHandle, actionServer, actionClient));
                thread.Start();
            });
            Console.WriteLine("Start Server");
            actionServer.Start();
            Console.WriteLine("Server Started");
            // setup action server finish


            // setup client
            actionClient = new ActionClient <Messages.actionlib.TestGoal, Messages.actionlib.TestResult,
                                             Messages.actionlib.TestFeedback>("test_action_slow", nodeHandle);
            // send action request to serverslowdummy
            Console.WriteLine("Wait for client and server to negotiate connection");
            bool started = actionClient.WaitForActionServerToStart(new TimeSpan(0, 0, 3));

            if (!started)
            {
                Console.WriteLine("Negotiation with server failed!");
            }

            Console.ReadLine();

            actionServer.Shutdown();
            nodeHandle.shutdown();
            ROS.shutdown();
        }
        //轮播图片
        private void BindLunbo()
        {

            DataTable dt = ActionServer.selectAll();
            if (dt != null && dt.Rows.Count != 0)
            {
                lunbo1.DataSource = dt;
                lunbo1.DataBind();
                lunbo2.DataSource = dt;
                lunbo2.DataBind();
            }


        }
Exemple #7
0
        private static void serverGoalCallback(ServerGoalHandle <TestGoal, TestResult, TestFeedback> sgoalHandle,
                                               ActionServer <TestGoal, TestResult, TestFeedback> actionServer,
                                               ActionClient <TestGoal, TestResult, TestFeedback> actionClient)
        {
            // got goal to reach from clientsample
            Console.WriteLine($"Goal registered callback. Goal: {sgoalHandle.Goal.goal}");

            var goal = new Messages.actionlib.TestGoal();

            Console.WriteLine($"Send goal {goal.goal} from client");
            var cts = new CancellationTokenSource();

            actionClient.SendGoalAsync(goal,
                                       (cgoalHandle) =>
            {
                if (cgoalHandle.State == CommunicationState.DONE)
                {
                    int g      = cgoalHandle.Goal.Goal.goal;
                    var result = cgoalHandle.Result;
                    if (result != null)
                    {
                        Console.WriteLine($"Got Result for goal {g}: {cgoalHandle.Result.result}");
                        var aresult = new Messages.actionlib.TestResult
                        {
                            result = 999
                        };
                        sgoalHandle.SetGoalStatus(Messages.actionlib_msgs.GoalStatus.SUCCEEDED, "done");
                        actionServer.PublishResult(sgoalHandle.GoalStatus, result);
                    }
                    else
                    {
                        Console.WriteLine($"Result for goal {g} is NULL!");
                    }
                }
            },
                                       (cgoalHandle, feedback) =>
            {
                Console.WriteLine($"Feedback: {feedback}");
                var fb = new Messages.actionlib.TestFeedback
                {
                    feedback = feedback.Feedback.feedback
                };
                sgoalHandle.PublishFeedback(fb);
            },
                                       cts.Token
                                       ).GetAwaiter().GetResult();
        }
Exemple #8
0
        public void Should_CreateGoalAndGetItDone()
        {
            NodeHandle serverNodeHandle = new NodeHandle();
            NodeHandle clientNodeHandle = new NodeHandle();

            Console.WriteLine("Create server");
            var actionServer = new ActionServer <FollowJointTrajectoryGoal, FollowJointTrajectoryResult,
                                                 FollowJointTrajectoryFeedback>(serverNodeHandle, "SimpleTest");

            Console.WriteLine("Create client");
            var actionClient = new ActionClient <FollowJointTrajectoryGoal, FollowJointTrajectoryResult,
                                                 FollowJointTrajectoryFeedback>("SimpleTest", clientNodeHandle);

            Console.WriteLine("Start Server");
            actionServer.Start();

            bool goalRegistered = false;

            actionServer.RegisterGoalCallback((goalHandle) =>
            {
                Console.WriteLine($"Goal registered callback. Joint Name {goalHandle.Goal.trajectory.joint_names[0]}");
                goalRegistered = true;
            });

            Console.WriteLine("Wait for client and server to negotiate connection");
            bool started = actionClient.WaitForActionServerToStart(new TimeSpan(0, 0, 20));

            Assert.Equal(true, started);

            var goal = new FollowJointTrajectoryGoal();

            goal.trajectory             = new Messages.trajectory_msgs.JointTrajectory();
            goal.trajectory.joint_names = new string[] { "Hallo Welt!" };

            Console.WriteLine("Send goal from client");
            var cts = new CancellationTokenSource();

            actionClient.SendGoalAsync(goal, cts.Token).GetAwaiter().GetResult();

            Console.WriteLine("Wait for action server receiving the goal");
            while (!goalRegistered)
            {
                Thread.Sleep(1);
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         BindBC();
         #region 详细新闻信息
         if (Request.QueryString["act_id"] != null)
         {
             SqlDataReader dt = ActionServer.selectaction(int.Parse(Request.QueryString["act_id"].ToString()));
             dt.Read();
             if (dt != null)
             {
                 newstime.Text    = dt["Act_Time"].ToString();
                 newstitle.Text   = dt["Act_Title"].ToString();
                 newscontent.Text = dt["Act_Content"].ToString();
             }
         }
         #endregion
     }
 }
Exemple #10
0
        static void Main(string[] args)
        {
#if (DEBUG)
            Environment.SetEnvironmentVariable("ROS_MASTER_URI", "http://192.168.200.32:11311/");
#endif
            Console.WriteLine("Start ROS");
            ROS.Init(ref args, "ActionServer");

            var asyncSpinner = new AsyncSpinner();
            asyncSpinner.Start();

            NodeHandle serverNodeHandle = new NodeHandle();

            Console.WriteLine("Create server");
            var actionServer = new ActionServer <Messages.actionlib.TestGoal, Messages.actionlib.TestResult,
                                                 Messages.actionlib.TestFeedback>(serverNodeHandle, "test_action");
            Console.WriteLine("Start Server");
            actionServer.Start();

            actionServer.RegisterGoalCallback((goalHandle) =>
            {
                Console.WriteLine($"Goal registered callback. Goal: {goalHandle.Goal.goal}");
                var fb      = new Messages.actionlib.TestFeedback();
                fb.feedback = 10;
                goalHandle.PublishFeedback(fb);
                Thread.Sleep(100);
                var result    = new Messages.actionlib.TestResult();
                result.result = 123;
                goalHandle.SetGoalStatus(Messages.actionlib_msgs.GoalStatus.SUCCEEDED, "done");
                actionServer.PublishResult(goalHandle.GoalStatus, result);
            });


            while (!Console.KeyAvailable)
            {
                Thread.Sleep(1);
            }
            actionServer.Shutdown();
            serverNodeHandle.shutdown();
            ROS.shutdown();
        }
Exemple #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("Start ROS");
            ROS.Init(new string[0], "ActionServer");
            var asyncSpinner = new AsyncSpinner();

            asyncSpinner.Start();
            NodeHandle serverNodeHandle = new NodeHandle();

            Console.WriteLine("Create server");
            var actionServer = new ActionServer <Messages.actionlib.TestGoal, Messages.actionlib.TestResult,
                                                 Messages.actionlib.TestFeedback>(serverNodeHandle, "test_action");

            Console.WriteLine("Start Server");
            actionServer.Start();

            actionServer.RegisterGoalCallback((goalHandle) =>
            {
                Console.WriteLine($"Goal registered callback. Goal: {goalHandle.Goal.goal}");
                var fb      = new Messages.actionlib.TestFeedback();
                fb.feedback = 10;
                goalHandle.PublishFeedback(fb);
                Thread.Sleep(100);
                var result    = new Messages.actionlib.TestResult();
                result.result = 123;
                goalHandle.SetGoalStatus(Messages.actionlib_msgs.GoalStatus.SUCCEEDED, "done");
                actionServer.PublishResult(goalHandle.GoalStatus, result);
            });


            while (!Console.KeyAvailable)
            {
                Thread.Sleep(1);
            }

            actionServer.Shutdown();
            serverNodeHandle.Shutdown();
            ROS.Shutdown();
        }
Exemple #12
0
 protected internal virtual void Initialize(Uri serviceUrl)
 {
     description_server = new DescriptionServer (controller, new Uri (serviceUrl, "description/"));
     action_server = new ActionServer (controller, new Uri (serviceUrl, "control/"));
     event_server = new EventServer (controller, new Uri (serviceUrl, "event/"));
 }
Exemple #13
0
 protected internal virtual void Initialize(Uri serviceUrl)
 {
     description_server = new DescriptionServer(controller, new Uri(serviceUrl, "description/"));
     action_server      = new ActionServer(controller, new Uri(serviceUrl, "control/"));
     event_server       = new EventServer(controller, new Uri(serviceUrl, "event/"));
 }
Exemple #14
0
        static void Main(string[] args)
        {
            //#if (DEBUG)
            //      Environment.SetEnvironmentVariable("ROS_HOSTNAME", "");
            //      Environment.SetEnvironmentVariable("ROS_IP", "192.168.200.32");
            //      Environment.SetEnvironmentVariable("ROS_MASTER_URI", "http://192.168.200.231:11311/");
            //#endif
            Environment.SetEnvironmentVariable("ROS_HOSTNAME", "localhost");
            Environment.SetEnvironmentVariable("ROS_IP", "127.0.0.1");
            Environment.SetEnvironmentVariable("ROS_MASTER_URI", "http://localhost:11311/");
            Console.WriteLine("Start ROS");
            ROS.Init(ref args, "ActionServerSlowDummy");

            ICallbackQueue callbackQueue = new CallbackQueue();

            var asyncSpinner = new AsyncSpinner(callbackQueue);

            asyncSpinner.Start();

            //var spinner = new SingleThreadSpinner(callbackQueue);


            NodeHandle serverNodeHandle = new NodeHandle(callbackQueue);

            Console.WriteLine("Create server");
            var actionServer = new ActionServer <Messages.actionlib.TestGoal, Messages.actionlib.TestResult,
                                                 Messages.actionlib.TestFeedback>(serverNodeHandle, "test_action_slow");

            Console.WriteLine("Start Server");
            Param.Set("status_list_timeout", 999.9);
            actionServer.Start();

            actionServer.RegisterGoalCallback((goalHandle) =>
            {
                Console.WriteLine($"Goal registered callback. Goal: {goalHandle.Goal.goal}");
                goalHandle.SetAccepted("accepted");

                new Thread(() =>
                {
                    for (int x = 0; x < 77; x++)
                    {
                        var fb = new Messages.actionlib.TestFeedback
                        {
                            feedback = x
                        };
                        goalHandle.PublishFeedback(fb);
                        Thread.Sleep(100);
                    }

                    var result = new Messages.actionlib.TestResult
                    {
                        result = 123
                    };
                    goalHandle.SetGoalStatus(Messages.actionlib_msgs.GoalStatus.SUCCEEDED, "done");
                    actionServer.PublishResult(goalHandle.GoalStatus, result);
                }).Start();
            });

            Console.ReadLine();

            actionServer.Shutdown();
            serverNodeHandle.shutdown();
            ROS.shutdown();
        }