Ejemplo n.º 1
0
        private Action_Data_List onActionListRead(string strmissionid)
        {
            Action_Data_List actiondatalist = new Action_Data_List();

            actiondatalist.action_data = new List <Action_Data>();
            try
            {
                string strworkfile = "..\\Ros_info\\" + strmissionid + ".xml";
                using (StreamReader sr1 = new System.IO.StreamReader(strworkfile, Encoding.Default))
                {
                    while (sr1.Peek() >= 0)
                    {
                        string strTemp = sr1.ReadLine();

                        if (strTemp.IndexOf('<') < 0 && strTemp != "")
                        {
                            Action_Data actiondata = new Action_Data();

                            string[] straction_sub = strTemp.Split('/');

                            actiondata.strWorkData = strTemp;
                            if (straction_sub.Length == 1)
                            {
                                actiondata.strActionType = "";
                            }
                            else
                            {
                                actiondata.strActionType = straction_sub[0].Split(':')[1];
                            }

                            actiondatalist.action_data.Add(actiondata);
                        }
                    }
                    sr1.Close();
                }
                return(actiondatalist);
            }
            catch (Exception ex)
            {
                Console.WriteLine("onActionListRead err=" + ex.Message.ToString());

                return(actiondatalist);
            }
        }
Ejemplo n.º 2
0
        //job table 추가함수
        private List <Job_MissionInfo> onJobTable_Add(string[] missionbuf)
        {
            List <Job_MissionInfo> jobmissionlist = new List <Job_MissionInfo>();

            try
            {
                if (missionbuf.Length > 0 && missionbuf[0] != "Not")
                {
                    for (int i = 0; i < missionbuf.Length; i++)
                    {
                        string missionid = missionbuf[i];
                        int    idx       = missionid.IndexOf("(");
                        int    idx2      = missionid.IndexOf(")");
                        missionid = missionid.Substring(idx + 1, idx2 - idx - 1);

                        //해당되는 missionid에 action정보 read
                        Action_Data_List actiondatalist = onActionListRead(missionid);

                        if (actiondatalist.action_data.Count > 0)
                        {
                            Job_MissionInfo jobmission = new Job_MissionInfo();
                            jobmission.actinfo   = new List <Job_Mission_ActInfo>();
                            jobmission.missionid = missionid;
                            Job_Mission_ActInfo jobmission_act = new Job_Mission_ActInfo();

                            for (int j = 0; j < actiondatalist.action_data.Count; j++)
                            {
                                if (j > 0)
                                {
                                    jobmission_act.actidx  = j - 1;
                                    jobmission_act.acttype = actiondatalist.action_data[j].strActionType;

                                    if (jobmission_act.acttype.Equals("Action_wait"))
                                    {
                                        jobmission_act.bXis_use = true;
                                    }

                                    string[] strgoal_sub = actiondatalist.action_data[j].strWorkData.Split('/');

                                    if (jobmission_act.acttype.Equals("Goal-Point"))
                                    {
                                        string[] strgoal_sub_act_param = strgoal_sub[1].Split(':');
                                        string   x = strgoal_sub_act_param[1];
                                        jobmission_act.xpos   = float.Parse(x);
                                        strgoal_sub_act_param = strgoal_sub[2].Split(':');
                                        string y = strgoal_sub_act_param[1];
                                        jobmission_act.ypos = float.Parse(y);
                                    }

                                    jobmission_act.robot_status = "wait";

                                    jobmission.actinfo.Add(jobmission_act);
                                }
                            }

                            jobmissionlist.Add(jobmission);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("onJobTable_Add err=" + ex.Message.ToString());
            }

            return(jobmissionlist);
        }