コード例 #1
0
 /// <summary>
 /// 加载数据表格
 /// </summary>
 /// <param name="paraworkline"></param>
 /// <param name="paralinenum"></param>
 private void LoadDataGrid(string paraworkline, int paralinenum)
 {
     if (paralinenum > 0)
     {
         DAL.ZSql sql1 = new DAL.ZSql();
         sql1.Open("select l.*,m.Mark,m.WorkLine,m.XPos,m.YPos  from T_Line as l LEFT OUTER JOIN T_Mark as m ON l.MarkID = m.ID where l.MarkID IS NOT NULL and l.MarkOrder IS NOT NULL and l.LineNum=" + Convert.ToString(paralinenum) + " and WorkLine=" + paraworkline + " order by l.MarkOrder");
         canvas.Children.Remove(path);
         if (sql1.Rows.Count > 1)
         {
             route.Points.Clear();
             for (int i = 0; i < sql1.Rows.Count; i++)
             {
                 if (!string.IsNullOrEmpty(sql1.Rows[i]["XPos"].ToString()) && !string.IsNullOrEmpty(sql1.Rows[i]["YPos"].ToString()))
                 {
                     route.Points.Add(new Point(Convert.ToDouble(sql1.Rows[i]["XPos"]), Convert.ToDouble(sql1.Rows[i]["YPos"])));
                 }
             }
             if (route.Points.Count >= 2)
             {
                 pFigure.StartPoint = route.Points[0];
                 canvas.Children.Add(path);
             }
         }
         dataGrid1.ItemsSource = sql1.m_table.DefaultView;
         sql1.Close();
         linenum = paralinenum;
     }
     else
     {
         dataGrid1.ItemsSource = null;
     }
 }
コード例 #2
0
 /// <summary>
 /// Execute shutdown tasks
 /// </summary>
 /// <param name="sender">Object sending the event</param>
 /// <param name="e">Event arguments</param>
 private void Window_Closing(object sender, CancelEventArgs e)
 {
     // Stop Com,Unregister SPComCall data received event
     if (null != SPComCall)
     {
         SPComCall.Close();
         SPComCall.OnDataReceived -= this.SPComCall_OnDataReceived;
     }
     //close & clear SQL
     if (null != callSql)
     {
         callSql.Close();
         callSql = null;
     }
     //clear collection
     if (null != memberData)
     {
         memberData.Clear();
         memberData = null;
     }
     if (null != buf_callctl)
     {
         buf_callctl = null;
     }
     if (null != buf_callret)
     {
         buf_callret = null;
     }
 }
コード例 #3
0
ファイル: AGVTraffic.cs プロジェクト: yy1244/AGV_Server
        /// <summary>
        /// 路口初始化,读取数据表T_Traffic
        /// </summary>
        /// <returns>初始化true成功orfalse失败(没有设置管制区)</returns>
        public bool Init()
        {
            DAL.ZSql trafficSql = new DAL.ZSql();
            bool     flag       = false;

            try
            {
                trafficSql.Open("SELECT MAX(TrafficNum) AS MaxTrafficNum FROM T_Traffic");
                if (trafficSql.rowcount < 1 || string.IsNullOrEmpty(trafficSql.Rows[0]["MaxTrafficNum"].ToString()))
                {
                    trafficSql.Close();
                    return(false);
                }
                trafficCount = Convert.ToInt32(trafficSql.Rows[0]["MaxTrafficNum"]);
                if (trafficCount > 0)
                {
                    DAL.ZSql SqlLineNum = new DAL.ZSql();
                    for (int i = 0; i < trafficCount; i++)
                    {
                        agvTrafficList.Add(new AGVTraffic());
                        trafficSql.Open("SELECT COUNT(TrafficNum) AS MarkSum FROM T_Traffic WHERE TrafficNum =" + (i + 1).ToString()); //一定会有一行数据,不存在的管制区为iMarkSum=0
                        if (string.IsNullOrEmpty(trafficSql.Rows[0]["MarkSum"].ToString()))                                            //存在一行数据,但是字段里面是空的,什么都没有
                        {
                            continue;
                        }
                        agvTrafficList[i].trafficMarkCount = Convert.ToInt32(trafficSql.Rows[0]["MarkSum"]);
                        if (agvTrafficList[i].trafficMarkCount == 0)
                        {
                            continue;
                        }
                        else
                        {
                            agvTrafficList[i].trafficNum       = i + 1;
                            agvTrafficList[i].trafficName      = "管制路口" + (i + 1).ToString();
                            agvTrafficList[i].trafficMarkArray = new TrafficMark[agvTrafficList[i].trafficMarkCount];
                            SqlLineNum.Open("Select T_Mark.WorkLine,T_Mark.Mark,T_Traffic.MarkID from T_Traffic Left Join T_Mark ON T_Traffic.MarkID = T_Mark.ID Where TrafficNum=" + Convert.ToString(i + 1));
                            for (int j = 0; j < SqlLineNum.Rows.Count; j++)
                            {
                                if (!string.IsNullOrEmpty(SqlLineNum.Rows[j]["WorkLine"].ToString().Trim()) && !string.IsNullOrEmpty(SqlLineNum.Rows[j]["Mark"].ToString().Trim()))
                                {
                                    agvTrafficList[i].trafficMarkArray[j].workLineNum = Convert.ToInt32(SqlLineNum.Rows[j]["WorkLine"]);
                                    agvTrafficList[i].trafficMarkArray[j].markNum     = Convert.ToInt32(SqlLineNum.Rows[j]["Mark"]);
                                }
                            }
                        }
                    }
                    flag = true;
                }
            }
            catch (System.Exception ex)
            {
                flag = false;
            }
            trafficSql.Close();
            return(flag);
        }
コード例 #4
0
 /// <summary>
 /// 线路号绑定
 /// </summary>
 /// <param name="worklinenum">生产区</param>
 private void BindLineCombox(string worklinenum)
 {
     if (!string.IsNullOrEmpty(worklinenum))
     {
         DAL.ZSql sql1 = new DAL.ZSql();
         sql1.Open("select DISTINCT LineNum from T_Line LEFT OUTER JOIN T_Mark ON T_Line.MarkID = T_Mark.ID where LineNum > 0 AND WorkLine=" + worklinenum + " order by LineNum");
         cbRoute.ItemsSource       = sql1.m_table.DefaultView;
         cbRoute.DisplayMemberPath = "LineNum";
         cbRoute.SelectedValuePath = "LineNum";
         sql1.Close();
     }
 }
コード例 #5
0
        private void Loginbutton_Click(object sender, RoutedEventArgs e)
        {
            string UserName = this.UserNametextBox.Text.ToLower().Trim();
            string PassWord = this.passwordBox.Password.ToLower().Trim();

            DAL.ZSql sql = new DAL.ZSql();
            int      i   = sql.Open("select * from T_UserInfo where UserName=@username and Pwd=@password", new SqlParameter[] { new SqlParameter("username", UserName), new SqlParameter("password", PassWord) });

            if (i < 0)
            {
                sql.Close();
                MessageBox.Show("数据库连接失败,请检查是否开启数据库服务或正确配置系统连接字符串", "登录错误", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (sql.Rows.Count > 0)
            {
                if (sql.Rows[0]["IsManager"].ToString() == "True")
                {
                    GlobalPara.IsManager = true;
                }
                else
                {
                    GlobalPara.IsManager = false;
                }
                GlobalPara.strName = UserName;
                GlobalPara.userid  = sql.Rows[0]["ID"].ToString();
                sql.Close();
                try
                {
                    MainWindow mn = new MainWindow();
                    mn.Show();
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "系统发生严重错误!!!即将退出系统!!!", "系统异常", MessageBoxButton.OK, MessageBoxImage.Error);
                    Application.Current.Shutdown();
                }
            }
            else
            {
                MessageBox.Show("用户名或密码错误,请检查", "警告");
                this.UserNametextBox.Clear();
                this.passwordBox.Clear();
                this.UserNametextBox.Focus();
            }
            sql.Close();
        }
コード例 #6
0
 /// <summary>
 /// 修改密码
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnModify_Click(object sender, RoutedEventArgs e)
 {
     if (pwdboxNew.Password.ToLower().Trim() == string.Empty)
     {
         MessageBox.Show("密码不能为空");
         return;
     }
     else if (pwdboxNew.Password.ToLower().Trim() != pwdboxNewagain.Password.ToLower().Trim())
     {
         MessageBox.Show("两次输入密码不一致");
         return;
     }
     DAL.ZSql sql = new DAL.ZSql();
     sql.Open("update T_UserInfo set Pwd='" + pwdboxNew.Password.ToLower().Trim() + "' where ID=" + GlobalPara.userid);
     MessageBox.Show("修改密码成功!");
 }
コード例 #7
0
 private void btnModify_Click(object sender, RoutedEventArgs e)
 {
     if (pwdboxNew.Password.ToLower().Trim() == string.Empty)
     {
         MessageBox.Show("密码不能为空");
         return;
     }
     else if (pwdboxNew.Password.ToLower().Trim() != pwdboxNewagain.Password.ToLower().Trim())
     {
         MessageBox.Show("两次输入密码不一致");
         return;
     }
     DAL.ZSql sql = new DAL.ZSql();
     sql.Open("update T_UserInfo set Pwd='" + pwdboxNew.Password.ToLower().Trim() + "' where ID=" + GlobalPara.userid);
     MessageBox.Show("修改密码成功!");
 }
コード例 #8
0
        //修改日期:2013-12-1
        /// <summary>
        /// 生产区下拉框绑定
        /// </summary>
        private void BindWorkLineCombox()
        {
            DAL.ZSql sql1 = new DAL.ZSql();
            sql1.Open("Select DISTINCT WorkLine from T_Mark");
            cbWorkLine.ItemsSource       = sql1.m_table.DefaultView;
            cbWorkLine.DisplayMemberPath = "WorkLine";
            cbWorkLine.SelectedValuePath = "WorkLine";
            sql1.Close();

            //修改日期:2013-12-30
            DAL.ZSql sql2 = new DAL.ZSql();
            sql2.Open("Select DISTINCT WorkLine from T_Mark");
            cbRoute_WorkLine.ItemsSource       = sql2.m_table.DefaultView;
            cbRoute_WorkLine.DisplayMemberPath = "WorkLine";
            cbRoute_WorkLine.SelectedValuePath = "WorkLine";
            sql2.Close();
        }
コード例 #9
0
ファイル: Login.xaml.cs プロジェクト: qq5013/AGV_Server
 private void Loginbutton_Click(object sender, RoutedEventArgs e)
 {
     string UserName = this.UserNametextBox.Text.ToLower().Trim();
     string PassWord = this.passwordBox.Password.ToLower().Trim();
     DAL.ZSql sql = new DAL.ZSql();
     int i = sql.Open("select * from T_UserInfo where UserName=@username and Pwd=@password", new SqlParameter[] { new SqlParameter("username", UserName), new SqlParameter("password", PassWord) });
     if (i < 0)
     {
         sql.Close();
         MessageBox.Show("数据库连接失败,请检查是否开启数据库服务或正确配置系统连接字符串", "登录错误", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     if (sql.Rows.Count > 0)
     {
         if (sql.Rows[0]["IsManager"].ToString() == "True")
         {
             GlobalPara.IsManager = true;
         }
         else
         {
             GlobalPara.IsManager = false;
         }
         GlobalPara.strName = UserName;
         GlobalPara.userid = sql.Rows[0]["ID"].ToString();
         sql.Close();
         try
         {
             MainWindow mn = new MainWindow();
             mn.Show();
             this.Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message + "系统发生严重错误!!!即将退出系统!!!", "系统异常", MessageBoxButton.OK, MessageBoxImage.Error);
             Application.Current.Shutdown();
         }
     }
     else
     {
         MessageBox.Show("用户名或密码错误,请检查", "警告");
         this.UserNametextBox.Clear();
         this.passwordBox.Clear();
         this.UserNametextBox.Focus();
     }
     sql.Close();
 }
コード例 #10
0
        /// <summary>
        /// 加载表格中数据
        /// </summary>
        private void LoadData()
        {
            DAL.ZSql sql1 = new DAL.ZSql();
            sql1.Open("select * from T_Mark Order by WorkLine,Mark");
            //加载地图中地标
            canvas.Children.Clear();
            double x = 0, y = 0;

            for (int i = 0; i < sql1.Rows.Count; i++)
            {
                x = Convert.ToDouble(sql1.Rows[i]["XPos"]);
                y = Convert.ToDouble(sql1.Rows[i]["YPos"]);
                Ellipse markellipse = new Ellipse();
                markellipse.Height  = MarkDiameter;
                markellipse.Width   = MarkDiameter;
                markellipse.ToolTip = "ID:" + sql1.Rows[i]["ID"].ToString() + "\r\nWorkLine:" + sql1.Rows[i]["WorkLine"].ToString() + "  Mark:" + sql1.Rows[i]["Mark"];
                Canvas.SetLeft(markellipse, x - MarkDiameter / 2);
                Canvas.SetTop(markellipse, y - MarkDiameter / 2);
                //设置虚拟点颜色
                if (Convert.ToBoolean(sql1.Rows[i]["VirtualMark"]))
                {
                    markellipse.Fill = IsVirtualMark;
                }
                else
                {
                    //非虚拟点加入ID显示
                    markellipse.Fill = NotVirtualMark;
                    Label marklable = new Label();
                    marklable.FontSize   = 10;
                    marklable.Foreground = Brushes.Black;
                    marklable.Content    = sql1.Rows[i]["ID"].ToString();
                    Canvas.SetLeft(marklable, x - 14);
                    Canvas.SetTop(marklable, y - 20);
                    canvas.Children.Add(marklable);
                }
                //地标都显示出来
                canvas.Children.Add(markellipse);
            }
            //加载表格
            dataGrid1.ItemsSource = sql1.m_table.DefaultView;
            sql1.Close();
        }
コード例 #11
0
ファイル: MarkManage.xaml.cs プロジェクト: qq5013/AGV_Server
 /// <summary>
 /// 加载表格中数据
 /// </summary>
 private void LoadData()
 {
     DAL.ZSql sql1 = new DAL.ZSql();
     sql1.Open("select * from T_Mark Order by WorkLine,Mark");
     //加载地图中地标
     canvas.Children.Clear();
     double x = 0, y = 0;
     for (int i = 0; i < sql1.Rows.Count; i++)
     {
         x = Convert.ToDouble(sql1.Rows[i]["XPos"]);
         y = Convert.ToDouble(sql1.Rows[i]["YPos"]);
         Ellipse markellipse = new Ellipse();
         markellipse.Height = MarkDiameter;
         markellipse.Width = MarkDiameter;
         markellipse.ToolTip = "ID:" + sql1.Rows[i]["ID"].ToString() + "\r\nWorkLine:" + sql1.Rows[i]["WorkLine"].ToString() + "  Mark:" + sql1.Rows[i]["Mark"];
         Canvas.SetLeft(markellipse, x - MarkDiameter/2);
         Canvas.SetTop(markellipse, y - MarkDiameter/2);
         //设置虚拟点颜色
         if (Convert.ToBoolean(sql1.Rows[i]["VirtualMark"]))
         {
             markellipse.Fill = IsVirtualMark;
         }
         else
         {
            //非虚拟点加入ID显示
             markellipse.Fill = NotVirtualMark;
             Label marklable = new Label();
             marklable.FontSize = 10;
             marklable.Foreground = Brushes.Black;
             marklable.Content = sql1.Rows[i]["ID"].ToString();
             Canvas.SetLeft(marklable, x - 14);
             Canvas.SetTop(marklable, y - 20);
             canvas.Children.Add(marklable);
         }
         //地标都显示出来
         canvas.Children.Add(markellipse);
     }
     //加载表格
     dataGrid1.ItemsSource=sql1.m_table.DefaultView;
     sql1.Close();
 }
コード例 #12
0
ファイル: MainWindow1.xaml.cs プロジェクト: qq5013/AGV_Server
 /// <summary>
 /// 控制面板中数据初始化
 /// </summary>
 private void ControlAreaInit()
 {
     //小车编号加载初始化
     for (int i = 0; i < AGVNUM_MAX; i++)
     {
         cb_AgvNum.Items.Add("AGV" + (i + 1).ToString());
     }
     //线路加载初始化
     DAL.ZSql sql1 = new DAL.ZSql();
     sql1.Open("select DISTINCT LineNum from T_Line order by LineNum");
     cb_LineNum.ItemsSource = sql1.m_table.DefaultView;
     cb_LineNum.DisplayMemberPath = "LineNum";
     cb_LineNum.SelectedValuePath = "LineNum";
     cb_LineNum.SelectedValue = "0";
     sql1.Close();
 }
コード例 #13
0
ファイル: RouteManage.xaml.cs プロジェクト: qq5013/AGV_Server
        //修改日期:2013-12-1
        /// <summary>
        /// 生产区下拉框绑定
        /// </summary>
        private void BindWorkLineCombox()
        {
            DAL.ZSql sql1 = new DAL.ZSql();
            sql1.Open("Select DISTINCT WorkLine from T_Mark");
            cbWorkLine.ItemsSource = sql1.m_table.DefaultView;
            cbWorkLine.DisplayMemberPath = "WorkLine";
            cbWorkLine.SelectedValuePath = "WorkLine";
            sql1.Close();

            //修改日期:2013-12-30
            DAL.ZSql sql2 = new DAL.ZSql();
            sql2.Open("Select DISTINCT WorkLine from T_Mark");
            cbRoute_WorkLine.ItemsSource = sql2.m_table.DefaultView;
            cbRoute_WorkLine.DisplayMemberPath = "WorkLine";
            cbRoute_WorkLine.SelectedValuePath = "WorkLine";
            sql2.Close();
        }
コード例 #14
0
ファイル: MainWindow1.xaml.cs プロジェクト: qq5013/AGV_Server
 /// <summary>
 /// 自定义初始化
 /// </summary>
 private void CustomInit()
 {
     DAL.ZSql sql1 = new DAL.ZSql();
     //地标功能定义
     sql1.Open("select CmdFunction from T_Custom where CustomType=1 order by CmdNum");
     if (sql1.rowcount > 0)
     {
         MarkFuncOpt = new string[sql1.rowcount];
         for (int i = 0; i < sql1.rowcount; i++)
         {
             MarkFuncOpt[i] = sql1.Rows[i]["CmdFunction"].ToString();
         }
     }
     else
     {
         MessageBox.Show("警告:请在“自定义设置”中设置地标功能!");
     }
     //运行状态定义
     sql1.Open("select CmdFunction from T_Custom where CustomType=2 order by CmdNum");
     if (sql1.rowcount > 0)
     {
         StatusOpt = new string[sql1.rowcount];
         for (int i = 0; i < sql1.rowcount; i++)
         {
             StatusOpt[i] = sql1.Rows[i]["CmdFunction"].ToString();
         }
     }
     else
     {
         MessageBox.Show("警告:请在“自定义设置”中设置AGV运行状态!");
     }
     sql1.Close();
 }
コード例 #15
0
ファイル: RouteManage.xaml.cs プロジェクト: qq5013/AGV_Server
 /// <summary>
 /// 加载数据表格
 /// </summary>
 /// <param name="paraworkline"></param>
 /// <param name="paralinenum"></param>
 private void LoadDataGrid(string paraworkline, int paralinenum)
 {
     if (paralinenum > 0)
     {
         DAL.ZSql sql1 = new DAL.ZSql();
         sql1.Open("select l.*,m.Mark,m.WorkLine,m.XPos,m.YPos  from T_Line as l LEFT OUTER JOIN T_Mark as m ON l.MarkID = m.ID where l.MarkID IS NOT NULL and l.MarkOrder IS NOT NULL and l.LineNum=" + Convert.ToString(paralinenum) + " and WorkLine=" + paraworkline + " order by l.MarkOrder");
         canvas.Children.Remove(path);
         if (sql1.Rows.Count > 1)
         {
             route.Points.Clear();
             for (int i = 0; i < sql1.Rows.Count; i++)
             {
                 if (!string.IsNullOrEmpty(sql1.Rows[i]["XPos"].ToString()) && !string.IsNullOrEmpty(sql1.Rows[i]["YPos"].ToString()))
                 {
                     route.Points.Add(new Point(Convert.ToDouble(sql1.Rows[i]["XPos"]), Convert.ToDouble(sql1.Rows[i]["YPos"])));
                 }
             }
             if (route.Points.Count >= 2)
             {
                 pFigure.StartPoint = route.Points[0];
                 canvas.Children.Add(path);
             }
         }
         dataGrid1.ItemsSource = sql1.m_table.DefaultView;
         sql1.Close();
         linenum = paralinenum;
     }
     else
     {
         dataGrid1.ItemsSource = null;
     }
 }
コード例 #16
0
ファイル: RouteManage.xaml.cs プロジェクト: qq5013/AGV_Server
 /// <summary>
 /// 线路号绑定
 /// </summary>
 /// <param name="worklinenum">生产区</param>
 private void BindLineCombox(string worklinenum)
 {
     if (!string.IsNullOrEmpty(worklinenum))
     {
         DAL.ZSql sql1 = new DAL.ZSql();
         sql1.Open("select DISTINCT LineNum from T_Line LEFT OUTER JOIN T_Mark ON T_Line.MarkID = T_Mark.ID where LineNum > 0 AND WorkLine=" + worklinenum + " order by LineNum");
         cbRoute.ItemsSource = sql1.m_table.DefaultView;
         cbRoute.DisplayMemberPath = "LineNum";
         cbRoute.SelectedValuePath = "LineNum";
         sql1.Close();
     }
 }
コード例 #17
0
ファイル: MainWindow.xaml.cs プロジェクト: qq5013/AGV_Server
        /// <summary>
        /// 地标属性更改时触发的事件
        /// 移除上次动画,显示下一动画
        /// </summary>
        /// <param name="temp1">AGV_DisMember类</param>
        private void MarkChangeAction(AGVCar temp1)
        {
            IEnumerable<AGVCar> member = AGVStatus.Where<AGVCar>(p => p.AGVNum == temp1.AGVNum);
            AGVCar member1 = member.First<AGVCar>();
            int listindex = AGVStatus.IndexOf(member1);
            Point pStart = new Point(), pVirtual = new Point();

            //待测试
            //if (agvDock != null && agvCharge != null && agvCall != null)
            //{
            //    if (Convert.ToInt32(temp1.txtDockNum) == 0)
            //    {
            //        if (agvDock.dockStartStop.Equals(new WorkMarkStr(Convert.ToInt32(temp1.txtWorkLine), Convert.ToInt32(temp1.txtMarkNum))))
            //        {
            //            //充电返回后,清除状态
            //            if (temp1.txtagvCharge == 4) { AGVStatus[iagvnum - 1].agvCharge = 0; }
            //            CarLine carline = agvDock.Add(iagvnum);
            //            if (carline != null)
            //            {
            //                temp1.txtDockNum = carline.dockNum.ToString();
            //                temp1.txtLineNum = carline.lineNum.ToString();
            //                AGVStatus[iagvnum - 1].dockNum = carline.dockNum;
            //                //启动车辆,发送变更为待装停靠区路线
            //                //进入待装区时,起始地标的功能为暂停,结束地标不能为停止或暂停,一定为agv运行的地标功能,也不能在交通管制点内
            //                AGVControlCommand(iagvnum, 3, 0, Convert.ToByte(carline.lineNum));
            //            }
            //            else
            //            {
            //                //这是在排队队列中,此时需要车辆停止(发送停止命令)
            //                AGVControlCommand(iagvnum, 2, 0, 0);
            //            }
            //        }
            //    }
            //    else
            //    {
            //        if (agvDock.dockEndStop.Equals(new WorkMarkStr(Convert.ToInt32(temp1.txtWorkLine), Convert.ToInt32(temp1.txtMarkNum))))
            //        {
            //            //移除待装区排队
            //            CarLine carline = agvDock.Delete(iagvnum);
            //            if (carline != null)
            //            {
            //                //只有停靠区和管制区在这边需要软件更新,其他的更新可以发送控制命令,下位机更改AGV状态,上位机接收数据驱动更新
            //                AGVStatus[carline.agvNum - 1].dockNum = carline.dockNum;
            //                //如果在等待排队中有车辆,启动等待的车辆
            //                AGVControlCommand(carline.agvNum, 3, 0, Convert.ToByte(carline.lineNum));
            //            }
            //            temp1.txtDockNum = "0";
            //            AGVStatus[iagvnum - 1].dockNum = 0;
            //            //此时需要变换路线agvDock.outDockLine[iagvnum-1],发出控制命令,变更路线
            //            //1.当监测到temp1.txtagvCharge ==1时,outDockLine[iagvnum-1]为充电路线
            //            //2.当temp1.txtagvCharge ==0时,为执行任务的路线
            //            if (temp1.txtagvCharge == 1)
            //            {
            //                AGVStatus[iagvnum - 1].agvCharge = 2;
            //            }
            //            AGVControlCommand(iagvnum, 0, 0, Convert.ToByte(agvDock.outDockLine[iagvnum - 1]));
            //            agvDock.outDockLine[iagvnum - 1] = 0;
            //        }
            //    }

            //    if (temp1.txtagvCharge == 2)
            //    {
            //        if (agvCharge.dockStartStop.Equals(new WorkMarkStr(Convert.ToInt32(temp1.txtWorkLine), Convert.ToInt32(temp1.txtMarkNum))))
            //        {
            //            CarLine carline = agvCharge.Add(iagvnum);
            //            if (carline != null)
            //            {
            //                temp1.txtagvCharge = 3;//充电状态
            //                AGVStatus[iagvnum - 1].agvCharge = 3;//充电状态
            //                temp1.txtLineNum = carline.lineNum.ToString();
            //                //启动车辆,发送变更路线
            //                AGVControlCommand(iagvnum, 3, 0, Convert.ToByte(carline.lineNum));
            //            }
            //            else
            //            {
            //                //这是在排队队列中,此时需要车辆停止(发送停止命令)
            //                AGVControlCommand(iagvnum, 2, 0, 0);
            //            }
            //        }
            //    }//注意:充电完成,车辆不会自行启动,需要人工拔掉充电线,然后启动车辆
            //    else if (temp1.txtagvCharge == 3)
            //    {
            //        if (agvCharge.dockEndStop.Equals(new WorkMarkStr(Convert.ToInt32(temp1.txtWorkLine), Convert.ToInt32(temp1.txtMarkNum))))
            //        {
            //            //移除待装区排队
            //            CarLine carline = agvCharge.Delete(iagvnum);
            //            if (carline != null)
            //            {
            //                //只有停靠区和管制区在这边需要软件更新,其他的更新可以发送控制命令,下位机更改AGV状态,上位机接收数据驱动更新
            //                AGVStatus[carline.agvNum - 1].dockNum = carline.dockNum;
            //                //如果在等待排队(此时AGV车辆在待装区中排队,不是在充电区的起始地标排队)中有车辆,启动等待的车辆
            //                AGVControlCommand(carline.agvNum, 3, 0, 0);
            //                agvDock.outDockLine[iagvnum - 1] = agvCharge.chargeLine;//在出待装区的时候改变路线使用
            //            }
            //            temp1.txtagvCharge = 4;
            //            AGVStatus[iagvnum - 1].agvCharge = 4;
            //        }
            //    }
            //}

            #region 停靠区
            if (agvDock != null)
            {
                // 判断是否进入停靠区
                if (temp1.DockNum == 0)
                {
                    if (agvDock.dockStartStop.Equals(new WorkMarkStr(temp1.WorklineNum, temp1.MarkNum)))
                    {
                        //已经进入停靠区:1.更新AGV的停靠区参数 2.更新AGV的路线

                        //车辆进入停靠区
                        CarLine carline = agvDock.Add(temp1.AGVNum);
                        if (carline != null)
                        {
                            temp1.DockNum = carline.dockNum;
                            temp1.LineNum = carline.lineNum;
                            //更新停靠区参数
                            AGVStatus[listindex].DockNum = carline.dockNum;
                            //启动车辆,发送变更为待装停靠区路线
                            //进入待装区时,起始地标的功能为暂停,结束地标不能为停止或暂停,一定为agv运行的地标功能,也不能在交通管制点内
                            AGVControlCommand(temp1.AGVNum, 3, 0, carline.lineNum);
                        }
                        else
                        {
                            //这是在排队队列中,此时需要车辆停止(发送停止命令)
                            AGVControlCommand(temp1.AGVNum, 2, 0, 0);
                        }
                        //启用充电区
                        if (agvCharge != null)
                        {
                            //充电返回后,清除状态
                            if (temp1.AGVCharge == 4) { AGVStatus[listindex].AGVCharge = 0; }
                        }
                        else//不启用充电区
                        {
                        }
                    }
                    else
                    {
                        //未进入停靠区,一直处于停靠区外面;暂不做处理
                    }
                }
                else//判断是否出停靠区
                {
                    if (agvDock.dockEndStop.Equals(new WorkMarkStr(temp1.WorklineNum, temp1.MarkNum)))
                    {
                        //离开停靠区:1.更新AGV的停靠区参数 2.更新AGV的路线

                        //移除待装区排队
                        CarLine carline = agvDock.Delete(temp1.AGVNum);
                        //更新AGV停靠区参数
                        temp1.DockNum = 0;
                        AGVStatus[listindex].DockNum = 0;
                        //更新AGV路线
                        //有车辆等待排队
                        if (carline != null)
                        {
                            //只有停靠区和管制区在这边需要软件更新,其他的更新可以发送控制命令,下位机更改AGV状态,上位机接收数据驱动更新
                            IEnumerable<AGVCar> dockmember = AGVStatus.Where<AGVCar>(p => p.AGVNum == carline.agvNum);
                            int indexfind = AGVStatus.IndexOf(dockmember.First());
                            AGVStatus[indexfind].DockNum = carline.dockNum;
                            //如果在等待排队中有车辆,启动等待的车辆
                            AGVControlCommand(carline.agvNum, 3, 0, carline.lineNum);
                        }
                        //启用充电区
                        if (agvCharge != null)
                        {
                            if (temp1.AGVCharge == 1)
                            {
                                byte linenum = agvCharge.GetChargeLine(temp1.LineNum);
                                //充电路线,当linenum=0,说明用户没有定义
                                agvDock.outDockLine[temp1.AGVNum - 1] = linenum;//充电路线
                                if (linenum > 0)
                                {
                                    AGVStatus[listindex].AGVCharge = 2;
                                }
                            }
                        }
                        else
                        {
                            //不启动充电区
                        }

                        //车辆驶出停靠区后变更路线
                        //此时需要变换路线agvDock.outDockLine[iagvnum-1],发出控制命令,变更路线
                        //1.当监测到temp1.txtagvCharge ==1时,outDockLine[iagvnum-1]为充电路线
                        //2.当temp1.txtagvCharge ==0时,为执行任务的路线
                        if (agvDock.outDockLine[temp1.AGVNum - 1] > 0)
                        {
                            AGVControlCommand(temp1.AGVNum, 0, 0, agvDock.outDockLine[temp1.AGVNum - 1]);
                            agvDock.outDockLine[temp1.AGVNum - 1] = 0;
                        }

                    }
                    else
                    {
                        //已经进入停靠区,但一直在停靠区内;暂不做处理
                    }
                }
            }
            #endregion

            #region 充电区
            if (agvCharge != null)
            {
                if (temp1.AGVCharge == 2)
                {
                    if (agvCharge.dockStartStop.Equals(new WorkMarkStr(temp1.WorklineNum, temp1.MarkNum)))
                    {
                        CarLine carline = agvCharge.Add(temp1.AGVNum, temp1.LineNum);
                        if (carline != null)
                        {
                            temp1.AGVCharge = 3;//充电状态
                            AGVStatus[listindex].AGVCharge = 3;//充电状态
                            temp1.LineNum = carline.lineNum;
                            //启动车辆,发送变更路线
                            AGVControlCommand(temp1.AGVNum, 3, 0, carline.lineNum);
                        }
                        else
                        {
                            //这是在排队队列中,此时需要车辆停止(发送停止命令)
                            AGVControlCommand(temp1.AGVNum, 2, 0, 0);
                        }
                    }
                }//注意:充电完成,车辆不会自行启动,需要人工拔掉充电线,然后启动车辆
                else if (temp1.AGVCharge == 3)
                {
                    if (agvCharge.dockEndStop.Equals(new WorkMarkStr(temp1.WorklineNum, temp1.MarkNum)))
                    {
                        //移除待装区排队
                        CarLine carline = agvCharge.Delete(temp1.AGVNum);
                        if (carline != null)
                        {
                            //只有停靠区和管制区在这边需要软件更新,其他的更新可以发送控制命令,下位机更改AGV状态,上位机接收数据驱动更新
                            IEnumerable<AGVCar> dockmember = AGVStatus.Where<AGVCar>(p => p.AGVNum == carline.agvNum);
                            int indexfind = AGVStatus.IndexOf(dockmember.First());
                            AGVStatus[indexfind].DockNum = carline.dockNum;
                            //如果在等待排队(此时AGV车辆在待装区中排队,不是在充电区的起始地标排队)中有车辆,启动等待的车辆
                            temp1.LineNum = carline.lineNum;
                            AGVControlCommand(carline.agvNum, 3, 0, carline.lineNum);
                        }
                        temp1.AGVCharge = 4;
                        AGVStatus[listindex].AGVCharge = 4;
                        AGVControlCommand(temp1.AGVNum, 0, 0, agvCharge.beforeEnterLine[temp1.DockNum]);
                    }
                }
            }
            #endregion


            DAL.ZSql TrafficPara = new DAL.ZSql();

            TrafficPara.Open("select T_Line.MarkOrder, T_Mark.XPos, T_Mark.YPos FROM T_Line LEFT OUTER JOIN T_Mark ON T_Mark.ID = T_Line.MarkID where WorkLine=" + temp1.WorklineNum.ToString() + " and Mark=" + temp1.MarkNum.ToString() + " and LineNum=" + temp1.LineNum.ToString());
            if (TrafficPara.Rows.Count > 0)
            {
                pStart.X = Convert.ToDouble(TrafficPara.Rows[0]["XPos"]);
                pStart.Y = Convert.ToDouble(TrafficPara.Rows[0]["YPos"]);
                List<Point> pointcollection1 = new List<Point>();
                pointcollection1.Add(pStart);
                int currentOrder = Convert.ToInt16(TrafficPara.Rows[0]["MarkOrder"]) + 1;
                //线路起点处检测电量
                if (currentOrder == 2)
                {
                    //AGV到达起点位置,空闲状态;当检测到AGV状态为运行时,为执行任务
                    AGVStatus[listindex].AGVTask = 0;
                    //启用充电区
                    if (agvCharge != null)
                    {
                        if (temp1.AGVCharge == 1)
                        {
                            byte linenum = agvCharge.GetChargeLine(temp1.LineNum);
                            //当linenum=0时,说明管理员没有设置充电路线,不会启动自动充电
                            if (linenum > 0)
                            {
                                AGVControlCommand(temp1.AGVNum, 1, 0, linenum);
                                AGVStatus[listindex].AGVCharge = 2;
                            }
                        }
                    }
                }
                bool isvirtualpoint = true;
                double dMarkdistance = 0;
                do
                {
                    TrafficPara.Open("select XPos,YPos,T_Line.Distance,VirtualMark from T_Mark Left join T_Line on T_Mark.ID = T_Line.MarkID where T_Line.MarkOrder=" + currentOrder.ToString() +
                    "and LineNum=" + temp1.LineNum.ToString());
                    if (TrafficPara.Rows.Count > 0)
                    {
                        pVirtual.X = Convert.ToDouble(TrafficPara.Rows[0]["XPos"]);
                        pVirtual.Y = Convert.ToDouble(TrafficPara.Rows[0]["YPos"]);
                        pointcollection1.Add(pVirtual);
                        dMarkdistance += Convert.ToDouble(TrafficPara.Rows[0]["Distance"]);
                        isvirtualpoint = Convert.ToBoolean(TrafficPara.Rows[0]["VirtualMark"]);
                        currentOrder++;
                    }
                    else
                    {
                        isvirtualpoint = false;
                        break;
                    }
                }
                while (isvirtualpoint);
                if (pointcollection1.Count >= 2)
                {
                    double dAgvspeed = SpeedOpt[temp1.AGVSpeed].Speed / 60.0;
                    if (dAgvspeed == 0)
                    {
                        dAgvspeed = dMarkdistance;
                    }
                    AGVStatus[listindex].agvAnimation.DrawCarLine(pointcollection1, ColorOpt[temp1.AGVNum % ColorOpt.Length], dMarkdistance / dAgvspeed);
                }
            }
            TrafficPara.Close();
        }
コード例 #18
0
ファイル: MainWindow.xaml.cs プロジェクト: qq5013/AGV_Client
         /// <summary>
 /// 地标属性更改时触发的事件
 /// 移除上次动画,显示下一动画
 /// </summary>
 /// <param name="temp1">AGV_DisMember类</param>
 private void MarkChangeAction(AGVCar temp1)
 {
     IEnumerable<AGVCar> member = AGVStatus.Where<AGVCar>(p => p.AGVNum == temp1.AGVNum);
     AGVCar member1 = member.First<AGVCar>();
     int listindex = AGVStatus.IndexOf(member1);
     Point pStart = new Point(), pVirtual = new Point();
     DAL.ZSql TrafficPara = new DAL.ZSql();
     try
     {
         TrafficPara.Open("select T_Line.MarkOrder, T_Mark.XPos, T_Mark.YPos FROM T_Line LEFT OUTER JOIN T_Mark ON T_Mark.ID = T_Line.MarkID where WorkLine=" + temp1.WorklineNum.ToString() + " and Mark=" + temp1.MarkNum.ToString() + " and LineNum=" + temp1.LineNum.ToString());
         if (TrafficPara.Rows.Count > 0)
         {
             pStart.X = Convert.ToDouble(TrafficPara.Rows[0]["XPos"]);
             pStart.Y = Convert.ToDouble(TrafficPara.Rows[0]["YPos"]);
             List<Point> pointcollection1 = new List<Point>();
             pointcollection1.Add(pStart);
             int currentOrder = Convert.ToInt16(TrafficPara.Rows[0]["MarkOrder"]) + 1;
             bool isvirtualpoint = true;
             double dMarkdistance = 0;
             do
             {
                 TrafficPara.Open("select XPos,YPos,T_Line.Distance,VirtualMark from T_Mark Left join T_Line on T_Mark.ID = T_Line.MarkID where T_Line.MarkOrder=" + currentOrder.ToString() +
                 "and LineNum=" + temp1.LineNum.ToString());
                 if (TrafficPara.Rows.Count > 0)
                 {
                     pVirtual.X = Convert.ToDouble(TrafficPara.Rows[0]["XPos"]);
                     pVirtual.Y = Convert.ToDouble(TrafficPara.Rows[0]["YPos"]);
                     pointcollection1.Add(pVirtual);
                     dMarkdistance += Convert.ToDouble(TrafficPara.Rows[0]["Distance"]);
                     isvirtualpoint = Convert.ToBoolean(TrafficPara.Rows[0]["VirtualMark"]);
                     currentOrder++;
                 }
                 else
                 {
                     isvirtualpoint = false;
                     break;
                 }
             }
             while (isvirtualpoint);
             if (pointcollection1.Count >= 2)
             {
                 double dAgvspeed = SpeedOpt[temp1.AGVSpeed].Speed / 60.0;
                 if (dAgvspeed == 0)
                 {
                     dAgvspeed = dMarkdistance;
                 }
                 App.Current.Dispatcher.Invoke((Action)(() =>
                 {
                     AGVStatus[listindex].agvAnimation.DrawCarLine(pointcollection1, ColorOpt[temp1.AGVNum % ColorOpt.Length], dMarkdistance / dAgvspeed);
                 }));
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         TrafficPara.Close();
     }
 }
コード例 #19
0
ファイル: MainWindow.xaml.cs プロジェクト: qq5013/AGV_Server
 /// <summary>
 /// 运行状态属性更改时触发的事件
 /// </summary>
 /// <param name="temp1">AGV_DisMember类</param>
 private void StatusChangeAction(AGVCar temp1)
 {
     IEnumerable<AGVCar> member = AGVStatus.Where<AGVCar>(p => p.AGVNum == temp1.AGVNum);
     AGVCar member1 = member.First<AGVCar>();
     int listindex = AGVStatus.IndexOf(member1);
     AGVStatus[listindex].agvAnimation.StatusChangeAnimation(temp1.AGVStatus, temp1.AGVNum, temp1.DockNum);
     switch (temp1.AGVStatus)
     {
         case 0x40://"运行":
             AGVStatus[listindex].AGVTask = 1;
             break;
         case 0x41://"暂停":
             break;
         case 0x42://"结束地标停止":
             //if (agvCall.lineNum.Count > 0)//有叫料信息,需要车辆运送
             //{
             //    if (agvCall.lineNum[0] > 0)
             //    {
             //        agvDock.outDockLine[iagvnum - 1] = agvCall.lineNum[0];
             //        AGVControlCommand(iagvnum, 3, 0, 0);
             //    }
             //}
             break;
         default:
             {
                 //将报警记录写入到数据库
                 string txttimer = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                 DAL.ZSql TrafficPara = new DAL.ZSql();
                 TrafficPara.Open("Insert into T_Ex (CarID,ExTimer,ExType,ExRouteNum,ExMarkNum,ExWorkLine) VALUES (" + temp1.AGVNum.ToString() + ",'" + txttimer + "','" + StatusOpt[temp1.AGVStatus] + "'," + temp1.LineNum.ToString() + "," + temp1.MarkNum.ToString() + "," + temp1.WorklineNum.ToString() + ")");
                 TrafficPara.Close();
                 break;
             }
     }
 }
コード例 #20
0
 /// <summary>
 /// 自定义初始化
 /// </summary>
 private void CustomInit()
 {
     DAL.ZSql sql1 = new DAL.ZSql();
     try
     {
         //地标功能定义
         sql1.Open("select CmdFunction from T_Custom where CustomType=1 order by CmdNum");
         if (sql1.rowcount > 0)
         {
             MarkFuncOpt = new string[sql1.rowcount];
             for (int i = 0; i < sql1.rowcount; i++)
             {
                 MarkFuncOpt[i] = sql1.Rows[i]["CmdFunction"].ToString();
             }
         }
         else
         {
             MessageBox.Show("警告:请在“自定义设置”中设置地标功能!");
         }
         //运行状态定义
         sql1.Open("select CmdFunction from T_Custom where CustomType=2 order by CmdNum");
         if (sql1.rowcount > 0)
         {
             StatusOpt = new string[sql1.rowcount];
             for (int i = 0; i < sql1.rowcount; i++)
             {
                 StatusOpt[i] = sql1.Rows[i]["CmdFunction"].ToString();
             }
         }
         else
         {
             MessageBox.Show("警告:请在“自定义设置”中设置AGV运行状态!");
         }
         //速度定义
         sql1.Open("select SpeedGrade,Speed,CmdNum from T_Speed order by CmdNum");
         if (sql1.rowcount > 0)
         {
             SpeedOpt = new SortedList <int, SpeedStr>();
             for (int i = 0; i < sql1.rowcount; i++)
             {
                 string speedgrade = sql1.Rows[i]["SpeedGrade"].ToString();
                 int    cmdnum;
                 Int32.TryParse(sql1.Rows[i]["CmdNum"].ToString(), out cmdnum);
                 double speed;
                 Double.TryParse(sql1.Rows[i]["Speed"].ToString(), out speed);
                 SpeedOpt.Add(cmdnum, new SpeedStr(cmdnum, speed, speedgrade));
             }
         }
         else
         {
             MessageBox.Show("请在“速度设置”中设置AGV速度信息!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     catch (Exception ex)
     {
         throw new Exception("初始化定义读取数据库失败!" + ex.Message);
     }
     finally
     {
         sql1.Close();
         sql1 = null;
     }
 }
コード例 #21
0
ファイル: MainWindow.xaml.cs プロジェクト: qq5013/AGV_Server
 /// <summary>
 /// 生产区初始化
 /// </summary>
 private byte DrvWlConWorkLineInit(byte agvid)
 {
     DAL.ZSql TrafficPara = new DAL.ZSql();
     try
     {
         Object workline = TrafficPara.GetScalar("select WorkLine from T_WorkLine Where CarID = " + agvid.ToString());
         if (workline == null)
         {
             MessageBox.Show("AGV" + agvid.ToString() + "车辆未设置生产区号,启动系统前请设置后再重启软件!");
             return 0;
         }
         return Convert.ToByte(workline);
     }
     catch (System.Exception ex)
     {
         MessageBox.Show("数据库连接异常,请检查后再重启软件!");
         return 0;
     }
     finally
     {
         TrafficPara.Close();
     }
 }
コード例 #22
0
        /// <summary>
        /// 地标属性更改时触发的事件
        /// 移除上次动画,显示下一动画
        /// </summary>
        /// <param name="temp1">AGV_DisMember类</param>
        private void MarkChangeAction(AGVCar temp1)
        {
            IEnumerable <AGVCar> member = AGVStatus.Where <AGVCar>(p => p.AGVNum == temp1.AGVNum);
            AGVCar member1 = member.First <AGVCar>();
            int    listindex = AGVStatus.IndexOf(member1);
            Point  pStart = new Point(), pVirtual = new Point();

            DAL.ZSql TrafficPara = new DAL.ZSql();
            try
            {
                TrafficPara.Open("select T_Line.MarkOrder, T_Mark.XPos, T_Mark.YPos FROM T_Line LEFT OUTER JOIN T_Mark ON T_Mark.ID = T_Line.MarkID where WorkLine=" + temp1.WorklineNum.ToString() + " and Mark=" + temp1.MarkNum.ToString() + " and LineNum=" + temp1.LineNum.ToString());
                if (TrafficPara.Rows.Count > 0)
                {
                    pStart.X = Convert.ToDouble(TrafficPara.Rows[0]["XPos"]);
                    pStart.Y = Convert.ToDouble(TrafficPara.Rows[0]["YPos"]);
                    List <Point> pointcollection1 = new List <Point>();
                    pointcollection1.Add(pStart);
                    int    currentOrder   = Convert.ToInt16(TrafficPara.Rows[0]["MarkOrder"]) + 1;
                    bool   isvirtualpoint = true;
                    double dMarkdistance  = 0;
                    do
                    {
                        TrafficPara.Open("select XPos,YPos,T_Line.Distance,VirtualMark from T_Mark Left join T_Line on T_Mark.ID = T_Line.MarkID where T_Line.MarkOrder=" + currentOrder.ToString() +
                                         "and LineNum=" + temp1.LineNum.ToString());
                        if (TrafficPara.Rows.Count > 0)
                        {
                            pVirtual.X = Convert.ToDouble(TrafficPara.Rows[0]["XPos"]);
                            pVirtual.Y = Convert.ToDouble(TrafficPara.Rows[0]["YPos"]);
                            pointcollection1.Add(pVirtual);
                            dMarkdistance += Convert.ToDouble(TrafficPara.Rows[0]["Distance"]);
                            isvirtualpoint = Convert.ToBoolean(TrafficPara.Rows[0]["VirtualMark"]);
                            currentOrder++;
                        }
                        else
                        {
                            isvirtualpoint = false;
                            break;
                        }
                    }while (isvirtualpoint);
                    if (pointcollection1.Count >= 2)
                    {
                        double dAgvspeed = SpeedOpt[temp1.AGVSpeed].Speed / 60.0;
                        if (dAgvspeed == 0)
                        {
                            dAgvspeed = dMarkdistance;
                        }
                        App.Current.Dispatcher.Invoke((Action)(() =>
                        {
                            AGVStatus[listindex].agvAnimation.DrawCarLine(pointcollection1, ColorOpt[temp1.AGVNum % ColorOpt.Length], dMarkdistance / dAgvspeed);
                        }));
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                TrafficPara.Close();
            }
        }
コード例 #23
0
ファイル: MainWindow.xaml.cs プロジェクト: qq5013/AGV_Client
        /// <summary>
        /// 自定义初始化
        /// </summary>
        private void CustomInit()
        {
            DAL.ZSql sql1 = new DAL.ZSql();
            try
            {
                //地标功能定义
                sql1.Open("select CmdFunction from T_Custom where CustomType=1 order by CmdNum");
                if (sql1.rowcount > 0)
                {
                    MarkFuncOpt = new string[sql1.rowcount];
                    for (int i = 0; i < sql1.rowcount; i++)
                    {
                        MarkFuncOpt[i] = sql1.Rows[i]["CmdFunction"].ToString();
                    }
                }
                else
                {
                    MessageBox.Show("警告:请在“自定义设置”中设置地标功能!");
                }
                //运行状态定义
                sql1.Open("select CmdFunction from T_Custom where CustomType=2 order by CmdNum");
                if (sql1.rowcount > 0)
                {
                    StatusOpt = new string[sql1.rowcount];
                    for (int i = 0; i < sql1.rowcount; i++)
                    {
                        StatusOpt[i] = sql1.Rows[i]["CmdFunction"].ToString();
                    }
                }
                else
                {
                    MessageBox.Show("警告:请在“自定义设置”中设置AGV运行状态!");
                }
                //速度定义
                sql1.Open("select SpeedGrade,Speed,CmdNum from T_Speed order by CmdNum");
                if (sql1.rowcount > 0)
                {
                    SpeedOpt = new SortedList<int, SpeedStr>();
                    for (int i = 0; i < sql1.rowcount; i++)
                    {
                        string speedgrade = sql1.Rows[i]["SpeedGrade"].ToString();
                        int cmdnum;
                        Int32.TryParse(sql1.Rows[i]["CmdNum"].ToString(),out cmdnum);
                        double speed;
                        Double.TryParse(sql1.Rows[i]["Speed"].ToString(),out speed);
                        SpeedOpt.Add(cmdnum,new SpeedStr(cmdnum,speed,speedgrade));
                    }
                }
                else
                {
                    MessageBox.Show("请在“速度设置”中设置AGV速度信息!","错误",MessageBoxButton.OK,MessageBoxImage.Error);
                }

            }
            catch (Exception ex)
            {              
                throw new Exception("初始化定义读取数据库失败!"+ ex.Message);
            }
            finally 
            {
                sql1.Close();
                sql1 = null;
            }
        }
コード例 #24
0
ファイル: AGVTraffic.cs プロジェクト: qq5013/AGV_Server
 /// <summary>
 /// 路口初始化,读取数据表T_Traffic
 /// </summary>
 /// <returns>初始化true成功orfalse失败(没有设置管制区)</returns>
 public bool Init()
 {
     DAL.ZSql trafficSql = new DAL.ZSql();
     bool flag = false;
     try
     {
         trafficSql.Open("SELECT MAX(TrafficNum) AS MaxTrafficNum FROM T_Traffic");
         if (trafficSql.rowcount < 1 || string.IsNullOrEmpty(trafficSql.Rows[0]["MaxTrafficNum"].ToString()))
         {
             trafficSql.Close();
             return false;
         }
         trafficCount = Convert.ToInt32(trafficSql.Rows[0]["MaxTrafficNum"]);
         if (trafficCount > 0)
         {
             DAL.ZSql SqlLineNum = new DAL.ZSql();
             for (int i = 0; i < trafficCount; i++)
             {
                 agvTrafficList.Add(new AGVTraffic());
                 trafficSql.Open("SELECT COUNT(TrafficNum) AS MarkSum FROM T_Traffic WHERE TrafficNum =" + (i + 1).ToString());//一定会有一行数据,不存在的管制区为iMarkSum=0                    
                 if (string.IsNullOrEmpty(trafficSql.Rows[0]["MarkSum"].ToString()))//存在一行数据,但是字段里面是空的,什么都没有
                 {
                     continue;
                 }
                 agvTrafficList[i].trafficMarkCount = Convert.ToInt32(trafficSql.Rows[0]["MarkSum"]);
                 if (agvTrafficList[i].trafficMarkCount == 0)
                 {
                     continue;
                 }
                 else
                 {
                     agvTrafficList[i].trafficNum = i + 1;
                     agvTrafficList[i].trafficName = "管制路口" + (i + 1).ToString();
                     agvTrafficList[i].trafficMarkArray = new TrafficMark[agvTrafficList[i].trafficMarkCount];
                     SqlLineNum.Open("Select T_Mark.WorkLine,T_Mark.Mark,T_Traffic.MarkID from T_Traffic Left Join T_Mark ON T_Traffic.MarkID = T_Mark.ID Where TrafficNum=" + Convert.ToString(i + 1));
                     for (int j = 0; j < SqlLineNum.Rows.Count; j++)
                     {
                         if (!string.IsNullOrEmpty(SqlLineNum.Rows[j]["WorkLine"].ToString().Trim()) && !string.IsNullOrEmpty(SqlLineNum.Rows[j]["Mark"].ToString().Trim()))
                         {
                             agvTrafficList[i].trafficMarkArray[j].workLineNum = Convert.ToInt32(SqlLineNum.Rows[j]["WorkLine"]);
                             agvTrafficList[i].trafficMarkArray[j].markNum = Convert.ToInt32(SqlLineNum.Rows[j]["Mark"]);
                         }
                     }
                 }
             }
             flag = true;
         }
     }
     catch (System.Exception ex)
     {
         flag = false;
     }
     trafficSql.Close();
     return flag;
 }
コード例 #25
0
ファイル: MainWindow.xaml.cs プロジェクト: qq5013/AGV_Call
 /// <summary>
 /// Execute shutdown tasks
 /// </summary>
 /// <param name="sender">Object sending the event</param>
 /// <param name="e">Event arguments</param>
 private void Window_Closing(object sender, CancelEventArgs e)
 {
     // Stop Com,Unregister SPComCall data received event
     if (null != SPComCall)
     {
         SPComCall.Close();
         SPComCall.OnDataReceived -= this.SPComCall_OnDataReceived;
     }
     //close & clear SQL
     if (null != callSql)
     {
         callSql.Close();
         callSql = null;
     }
     //clear collection
     if (null != memberData)
     {
         memberData.Clear();
         memberData = null;
     }
     if (null != buf_callctl)
     {
         buf_callctl = null;
     }
     if (null != buf_callret)
     {
         buf_callret = null;
     }
 }