示例#1
0
        private void RobotWorkstatus_Updatetimer_Tick(object sender, EventArgs e)
        {
            try
            {
                using (StreamWriter sw = new System.IO.StreamWriter(m_strRobot_Status_File, false, Encoding.Default))
                {
                    sw.WriteLine("robot_id,ip,work id,work status,work cnt,curr work cnt,actionidx,lift");

                    foreach (KeyValuePair <string, string> info in Data.Instance.Robot_status_info)
                    {
                        string key   = info.Key;
                        string value = info.Value;

                        sw.WriteLine(value);
                    }

                    sw.Close();
                }

                if (G_robotList.Count > 0)
                {
                    for (int i = 0; i < G_robotsLiveStatus_File_List.Count; i++)
                    {
                        string strfile = "";

                        if (G_robotsLiveStatus_File_List.ContainsKey(G_robotList[i]))
                        {
                            strfile = G_robotsLiveStatus_File_List[G_robotList[i]];

                            if (G_robots_live_status.ContainsKey(G_robotList[i]))
                            {
                                RobotLive_Status value = G_robots_live_status[G_robotList[i]];

                                using (StreamWriter sw = new System.IO.StreamWriter(strfile, false, Encoding.Default))
                                {
                                    sw.WriteLine("robot_id,livestatus,jobstatus,actionidx,missionid,missionname,submissionid,submissioname");
                                    string strdata = string.Format("{0},{1},{2},{3},{4},{5},{6},{7}", value.strRobotID, value.strRobotLiveStatus, value.strJobing, value.strActionidx, value.strMissionID, value.strMissionNum, value.strsubMissionID, value.strsubMissionNum);
                                    sw.WriteLine(strdata);

                                    sw.Close();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine("RobotWorkstatus_Updatetimer_Tick err :={0}", ex.Message.ToString());
            }
        }
示例#2
0
        /// <summary>
        /// 등록된 로봇별로 live상태, job 상태 를 읽어온다.
        /// </summary>
        public void onRobots_LiveStatus_Check_Open()
        {
            try
            {
                if (G_robotList.Count > 0)
                {
                    G_robots_live_status.Clear();
                    for (int i = 0; i < G_robotsLiveStatus_File_List.Count; i++)
                    {
                        string strfile = "";

                        if (G_robotsLiveStatus_File_List.ContainsKey(G_robotList[i]))
                        {
                            strfile = G_robotsLiveStatus_File_List[G_robotList[i]];

                            if (!File.Exists(strfile))
                            {
                                using (StreamWriter sw = new System.IO.StreamWriter(strfile, false, Encoding.Default))
                                {
                                    sw.WriteLine("robot_id,livestatus,jobstatus,actionidx,missionid,missionname,submissionid,submissioname");
                                    sw.WriteLine(string.Format("{0},dead,wait,0,0,0,0,0", G_robotList[i]));
                                    sw.Close();
                                }
                                //  return;
                            }

                            using (StreamReader sr1 = new System.IO.StreamReader(strfile, Encoding.Default))
                            {
                                int ncnt = 0; //파일에 첫줄은 항목명으로 빼고 읽기 위해 선언

                                RobotLive_Status robotlive_status = new RobotLive_Status();


                                while (sr1.Peek() >= 0)
                                {
                                    string strTemp = sr1.ReadLine();
                                    if (ncnt != 0)
                                    {
                                        string[] strRobotlivestatus = strTemp.Split(',');

                                        robotlive_status.strRobotID         = strRobotlivestatus[0];
                                        robotlive_status.strRobotLiveStatus = strRobotlivestatus[1];
                                        robotlive_status.strJobing          = strRobotlivestatus[2];
                                        robotlive_status.strActionidx       = strRobotlivestatus[3];
                                        robotlive_status.strMissionID       = strRobotlivestatus[4];
                                        robotlive_status.strMissionNum      = strRobotlivestatus[5];

                                        G_robots_live_status.Add(strRobotlivestatus[0], robotlive_status);
                                    }
                                    ncnt++;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine("onRobots_LiveStatus_Check_Open err :={0}", ex.Message.ToString());
            }
        }