339 lines
17 KiB
C#
339 lines
17 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace AGVSystem
|
|
{
|
|
public partial class Control_Point : Form
|
|
{
|
|
private ClsDBConn_sql db = new ClsDBConn_sql();
|
|
private System.Data.DataSet ds = new System.Data.DataSet();
|
|
string str_sql = "";
|
|
public Control_Point( int w , int h)
|
|
{
|
|
InitializeComponent();
|
|
this.Width = w;
|
|
this.Height = h;
|
|
ds = db.connDt("select CONVERT( VARCHAR(10),id) +' . '+ line_name as info from Assembly_Line order by id");
|
|
if (ds.Tables.Count > 0)
|
|
{
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
foreach (DataRow dr in ds.Tables[0].Rows)
|
|
{
|
|
cmb_linelist.Items.Add(dr[0].ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Control_Point_Load(object sender, EventArgs e)
|
|
{
|
|
ds.Tables.Clear();
|
|
str_sql = "SELECT CONVERT( VARCHAR(10),Assembly_Line.ID)+' . '+Line_name as 线体" +
|
|
",[Assembly_Line] as 线体编号" +
|
|
",[Loc_ID] as 位置编号" +
|
|
",[Flag_Value] as 标记值" +
|
|
",[Loc_X] as 坐标x" +
|
|
",[Loc_Y] as 坐标y" +
|
|
",CONVERT( VARCHAR(10),Loc_X)+','+CONVERT( VARCHAR(10),Loc_Y) as 位置坐标" +
|
|
",[Binding] as 绑定方式" +
|
|
",LandMarkInfo.[Area] as 地图编号" +
|
|
",(Case when LandMarkInfo.Assembly_ID >0 THEN '管控停止点' ELSE '管控复位点' END) as 位置类型" +
|
|
",[Bank] as 障碍物模式" +
|
|
",[Speed] as 速度" +
|
|
",[Next_Station1] as 下一站点1" +
|
|
",[Drict1] as 运动模式1" +
|
|
",[LongTime1] as 运动时间1" +
|
|
",[Next_Station2] as 下一站点2" +
|
|
",[Drict2] as 运动模式2" +
|
|
",[LongTime2] as 运动时间2" +
|
|
",[Next_Station3] as 下一站点3" +
|
|
",[Drict3] as 运动模式3" +
|
|
",[LongTime3] as 运动时间3" +
|
|
" FROM LandMarkInfo ,Assembly_Line" +
|
|
" WHERE LandMarkInfo.Assembly_Line = Assembly_Line.ID";
|
|
ds = db.connDt(str_sql);
|
|
if (ds.Tables.Count > 0)
|
|
dataGridView1.DataSource = ds.Tables[0];
|
|
groupBox1.Enabled = false;
|
|
groupBox2.Enabled = false;
|
|
groupBox3.Enabled = false;
|
|
}
|
|
|
|
private void dataGridView1_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
if (dataGridView1.RowCount > 0)
|
|
{
|
|
groupBox1.Enabled = false;
|
|
groupBox2.Enabled = false;
|
|
groupBox3.Enabled = false;
|
|
cmb_linelist.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["线体"].Value.ToString();
|
|
num_id.Value = Convert.ToDecimal(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["位置编号"].Value);
|
|
num_plcvalue.Value = Convert.ToDecimal(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["标记值"].Value);
|
|
cmb_map.SelectedIndex =Convert.ToInt16( dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["地图编号"].Value.ToString());
|
|
cmb_bd.SelectedIndex = Convert.ToInt16(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["绑定方式"].Value.ToString());
|
|
txt_zb.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["位置坐标"].Value.ToString();
|
|
cmb_type.Text = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["位置类型"].Value.ToString();
|
|
cmb_zhangaiwu.SelectedIndex = Convert.ToInt16(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["障碍物模式"].Value.ToString());
|
|
num_speed.Value = Convert.ToDecimal(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["速度"].Value);
|
|
next_loc1.Value = Convert.ToDecimal(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["下一站点1"].Value);
|
|
next_loc2.Value = Convert.ToDecimal(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["下一站点2"].Value);
|
|
next_longtime1.Value = Convert.ToDecimal(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["运动时间1"].Value);
|
|
next_longtime2.Value = Convert.ToDecimal(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["运动时间2"].Value);
|
|
cmb_run1.SelectedIndex = Convert.ToInt16(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["运动模式1"].Value);
|
|
cmb_run2.SelectedIndex = Convert.ToInt16(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["运动模式2"].Value);
|
|
}
|
|
}
|
|
|
|
private void btn_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
private string delete_point(string line_id, string point_id)
|
|
{
|
|
string rowcount = "0";
|
|
DataSet ds = new DataSet();
|
|
rowcount = db.Command("delete from LandMarkInfo where Assembly_Line = " + line_id + " and Loc_ID = " + point_id);
|
|
|
|
return rowcount;
|
|
}
|
|
|
|
private void dataGridView1_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
|
|
{
|
|
e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);
|
|
}
|
|
|
|
private void toolStripButton1_Click(object sender, EventArgs e)
|
|
{
|
|
groupBox1.Enabled = true;
|
|
groupBox2.Enabled = true;
|
|
groupBox3.Enabled = true;
|
|
|
|
num_plcvalue.Value = 0;
|
|
cmb_map.SelectedIndex = 0;
|
|
cmb_bd.SelectedIndex = 0;
|
|
cmb_type.SelectedIndex = 0;
|
|
cmb_zhangaiwu.SelectedIndex = 0;
|
|
num_speed.Value = 0;
|
|
next_loc1.Value = 0;
|
|
next_loc2.Value = 0;
|
|
next_longtime1.Value = 0;
|
|
next_longtime2.Value = 0;
|
|
cmb_run1.SelectedIndex = 0;
|
|
cmb_run2.SelectedIndex = 0;
|
|
txt_zb.Text = "0,0";
|
|
DataSet ds1 = db.connDt("Select max(loc_id)+1 from LandMarkInfo " );
|
|
if (ds1.Tables[0].Rows[0][0].ToString() != "")
|
|
num_id.Value = Convert.ToInt16(ds1.Tables[0].Rows[0][0].ToString());
|
|
else
|
|
num_id.Value = 1;
|
|
}
|
|
|
|
private string add_point(int Assembly_Line, int Loc_ID, int Flag_Value, int Binding, int Area, int Assembly_ID, int Bank, int Speed, int Next_Station1, int Drict1, int LongTime1, int Next_Station2, int Drict2, int LongTime2,int loc_x,int loc_y)
|
|
{
|
|
string rowcount = "0", strsql;
|
|
strsql = "INSERT INTO [LandMarkInfo]" +
|
|
"([Assembly_Line] ,[Loc_ID] ,[Flag_Value] ,[Binding]" +
|
|
",[Area] ,[Assembly_ID] ,[Bank] ,[Speed] " +
|
|
",[Next_Station1],[Drict1] ,[LongTime1] ,[Next_Station2]" +
|
|
",[Drict2] ,[LongTime2] ,loc_x ,loc_y ) VALUES (" +
|
|
Assembly_Line + " ," + Loc_ID + " ," + Flag_Value + " ," + Binding +
|
|
"," + Area + " ," + Assembly_ID + " ," + Bank + " ," + Speed +
|
|
"," + Next_Station1 + "," + Drict1 + " ," + LongTime1 + " ," + Next_Station2 +
|
|
"," + Drict2 + " ," + LongTime2+","+loc_x+","+loc_y+")";
|
|
rowcount = db.Command(strsql);
|
|
return rowcount;
|
|
}
|
|
|
|
private void toolStripButton3_Click(object sender, EventArgs e)
|
|
{
|
|
if (Cls.Param.UserName_temp == "")
|
|
{
|
|
MessageBox.Show("请登录管理员权限!", "AGV调度管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
if (num_id.Value == 0 || cmb_linelist.Text == "")
|
|
{
|
|
return;
|
|
}
|
|
if (add_point(Convert.ToInt16( cmb_linelist.Text.Split('.')[0]), Convert.ToInt16( num_id.Value), Convert.ToInt16( num_plcvalue.Value), cmb_bd.SelectedIndex,
|
|
cmb_map.SelectedIndex,Convert.ToInt16( (cmb_type.SelectedIndex == 1) ? cmb_linelist.Text.Split('.')[0] : "0"),cmb_zhangaiwu.SelectedIndex,Convert.ToInt16( num_speed.Value),
|
|
Convert.ToInt16( next_loc1.Value), cmb_run1.SelectedIndex, Convert.ToInt16( next_longtime1.Value), Convert.ToInt16( next_loc2.Value),
|
|
cmb_run2.SelectedIndex, Convert.ToInt16(next_longtime2.Value), Convert.ToInt16(txt_zb.Text.Split(',')[0]), Convert.ToInt16(txt_zb.Text.Split(',')[1])) == "1")
|
|
{
|
|
MessageBox.Show("添加成功!");
|
|
Control_Point_Load(null, null);
|
|
}
|
|
else
|
|
return;
|
|
}
|
|
|
|
private void toolStripButton4_Click(object sender, EventArgs e)
|
|
{
|
|
if (Cls.Param.UserName_temp == "")
|
|
{
|
|
MessageBox.Show("请登录管理员权限!", "AGV调度管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
|
|
if (delete_point(cmb_linelist.Text.Split('.')[0], num_id.Value.ToString()) == "1")
|
|
{
|
|
MessageBox.Show("删除成功!");
|
|
Control_Point_Load(null, null);
|
|
}
|
|
else
|
|
return;
|
|
}
|
|
|
|
private void toolStripButton5_Click(object sender, EventArgs e)
|
|
{
|
|
groupBox1.Enabled = true;
|
|
groupBox2.Enabled = true;
|
|
groupBox3.Enabled = true;
|
|
}
|
|
|
|
private void toolStripButton2_Click(object sender, EventArgs e)
|
|
{
|
|
if (cmb_linelist.Text != "" || num_id.Value != 0 || num_plcvalue.Value != 0)
|
|
{
|
|
ds.Tables.Clear();
|
|
str_sql = "SELECT CONVERT( VARCHAR(10),Assembly_Line.ID)+' . '+Line_name as 线体" +
|
|
",[Assembly_Line] as 线体编号" +
|
|
",[Loc_ID] as 位置编号" +
|
|
",[Flag_Value] as 标记值" +
|
|
",[Loc_X] as 坐标x" +
|
|
",[Loc_Y] as 坐标y" +
|
|
",CONVERT( VARCHAR(10),Loc_X)+','+CONVERT( VARCHAR(10),Loc_Y) as 位置坐标" +
|
|
",[Binding] as 绑定方式" +
|
|
",LandMarkInfo.[Area] as 地图编号" +
|
|
",(Case when LandMarkInfo.Assembly_ID >0 THEN '管控停止点' ELSE '管控复位点' END) as 位置类型" +
|
|
",[Bank] as 障碍物模式" +
|
|
",[Speed] as 速度" +
|
|
",[Next_Station1] as 下一站点1" +
|
|
",[Drict1] as 运动模式1" +
|
|
",[LongTime1] as 运动时间1" +
|
|
",[Next_Station2] as 下一站点2" +
|
|
",[Drict2] as 运动模式2" +
|
|
",[LongTime2] as 运动时间2" +
|
|
",[Next_Station3] as 下一站点3" +
|
|
",[Drict3] as 运动模式3" +
|
|
",[LongTime3] as 运动时间3" +
|
|
" FROM LandMarkInfo ,Assembly_Line" +
|
|
" WHERE LandMarkInfo.Assembly_Line = Assembly_Line.ID";
|
|
ds = db.connDt(str_sql);
|
|
if (cmb_linelist.Text != "" && cmb_linelist.Text != "所有线体")
|
|
str_sql = str_sql + " and LandMarkInfo.Assembly_Line = " + cmb_linelist.Text.Split('.')[0];
|
|
if (num_id.Value != 0)
|
|
str_sql = str_sql + " and Landmarkinfo.Loc_id = " + num_id.Value.ToString();
|
|
if (num_plcvalue.Value != 0)
|
|
str_sql = str_sql + " and Landmarkinfo.flag_value = " + num_plcvalue.Value.ToString();
|
|
ds = db.connDt(str_sql);
|
|
if (ds.Tables.Count > 0)
|
|
dataGridView1.DataSource = ds.Tables[0];
|
|
}
|
|
}
|
|
|
|
DataSet ds1;
|
|
private void num_id_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
string strsql;
|
|
if (groupBox1.Enabled==true && num_id.Value != 0)
|
|
{
|
|
strsql = "SELECT top 1 [Flag_Value] ,[Loc_X] ,[Loc_Y] ,[Binding] ,[Area] ,[Assembly_ID] ,[Bank] " +
|
|
",[Speed] ,[Next_Station1] ,[Drict1] ,[LongTime1] ,[Next_Station2] ,[Drict2] ,[LongTime2] " +
|
|
" FROM [LandMarkInfo] where loc_id =" + num_id.Value;
|
|
ds1 = db.connDt(strsql);
|
|
if (ds1.Tables[0].Rows.Count == 1)
|
|
button1.Visible = true;
|
|
else
|
|
button1.Visible = false;
|
|
}
|
|
if (!groupBox1.Enabled) button1.Visible = false;
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
if (ds1.Tables[0].Rows.Count == 1)
|
|
{
|
|
num_plcvalue.Value = Convert.ToInt16(ds1.Tables[0].Rows[0]["Flag_Value"].ToString());
|
|
cmb_map.SelectedIndex = Convert.ToInt16(ds1.Tables[0].Rows[0]["Area"].ToString());
|
|
cmb_bd.SelectedIndex = Convert.ToInt16(ds1.Tables[0].Rows[0]["Binding"].ToString());
|
|
txt_zb.Text = ds1.Tables[0].Rows[0]["Loc_X"].ToString() + "," + ds1.Tables[0].Rows[0]["Loc_Y"].ToString();
|
|
cmb_type.SelectedIndex = ds1.Tables[0].Rows[0]["Assembly_ID"].ToString() == "0" ? 0 : 1;
|
|
cmb_zhangaiwu.SelectedIndex = Convert.ToInt16(ds1.Tables[0].Rows[0]["Bank"].ToString());
|
|
num_speed.Value = Convert.ToDecimal(ds1.Tables[0].Rows[0]["Speed"].ToString());
|
|
next_loc1.Value = Convert.ToDecimal(ds1.Tables[0].Rows[0]["Next_Station1"].ToString());
|
|
next_loc2.Value = Convert.ToDecimal(ds1.Tables[0].Rows[0]["Next_Station2"].ToString());
|
|
next_longtime1.Value = Convert.ToDecimal(ds1.Tables[0].Rows[0]["LongTime1"].ToString());
|
|
next_longtime2.Value = Convert.ToDecimal(ds1.Tables[0].Rows[0]["LongTime2"].ToString());
|
|
cmb_run1.SelectedIndex = Convert.ToInt16(ds1.Tables[0].Rows[0]["Drict1"].ToString());
|
|
cmb_run2.SelectedIndex = Convert.ToInt16(ds1.Tables[0].Rows[0]["Drict2"].ToString());
|
|
}
|
|
}
|
|
|
|
private string update_point(int Assembly_Line, int Loc_ID, int Flag_Value, int Binding, int Area, int Assembly_ID, int Bank, int Speed, int Next_Station1, int Drict1, int LongTime1, int Next_Station2, int Drict2, int LongTime2, int Loc_X, int Loc_Y)
|
|
{
|
|
string rowcount = "0" ,strsql;
|
|
strsql = "UPDATE [LandMarkInfo] "+
|
|
" SET [Flag_Value] = "+Flag_Value+
|
|
" ,[Loc_X] = "+Loc_X+
|
|
" ,[Loc_Y] = "+Loc_Y +
|
|
" ,[Binding] = "+Binding+
|
|
" ,[Area] = "+Area+
|
|
" ,[Assembly_ID] = "+Assembly_ID+
|
|
" ,[Bank] = "+Bank+
|
|
" ,[Speed] = "+Speed+
|
|
" ,[Next_Station1] = "+Next_Station1+
|
|
" ,[Drict1] = "+Drict1+
|
|
" ,[LongTime1] = "+LongTime1+
|
|
" ,[Next_Station2] = "+Next_Station2+
|
|
" ,[Drict2] = "+Drict2+
|
|
" ,[LongTime2] = "+LongTime2+
|
|
" WHERE [Assembly_Line] = "+Assembly_Line+
|
|
" and [Loc_ID] ="+Loc_ID;
|
|
rowcount = db.Command(strsql);
|
|
return rowcount;
|
|
}
|
|
|
|
private void toolStripButton6_Click(object sender, EventArgs e)
|
|
{
|
|
if (Cls.Param.UserName_temp == "")
|
|
{
|
|
MessageBox.Show("请登录管理员权限!", "AGV调度管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
if (update_point(Convert.ToInt16(cmb_linelist.Text.Split('.')[0]),
|
|
Convert.ToInt16(num_id.Value),
|
|
Convert.ToInt16(num_plcvalue.Value),
|
|
cmb_bd.SelectedIndex,
|
|
cmb_map.SelectedIndex,
|
|
Convert.ToInt16((cmb_type.SelectedIndex == 1) ? cmb_linelist.Text.Split('.')[0] : "0"),
|
|
cmb_zhangaiwu.SelectedIndex,
|
|
Convert.ToInt16(num_speed.Value),
|
|
Convert.ToInt16(next_loc1.Value),
|
|
cmb_run1.SelectedIndex,
|
|
Convert.ToInt16(next_longtime1.Value),
|
|
Convert.ToInt16(next_loc2.Value),
|
|
cmb_run2.SelectedIndex,
|
|
Convert.ToInt16(next_longtime2.Value),
|
|
Convert.ToInt16(txt_zb.Text.Split(',')[0]),
|
|
Convert.ToInt16(txt_zb.Text.Split(',')[1])) == "1")
|
|
{
|
|
MessageBox.Show("更新成功!");
|
|
Control_Point_Load(null, null);
|
|
}
|
|
else
|
|
return;
|
|
}
|
|
}
|
|
}
|