568 lines
25 KiB
C#
568 lines
25 KiB
C#
using System;
|
|||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using System.Windows.Forms;
|
||
|
|
using System.Drawing;
|
||
|
|
using System.Net.NetworkInformation;
|
||
|
|
using System.Data;
|
||
|
|
using System.Threading;
|
||
|
|
using Agv_Info;
|
||
|
|
using Agv_Control;
|
||
|
|
|
||
|
|
namespace AGVSystem
|
||
|
|
{
|
||
|
|
public class Func
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// 表示每个AGV的btn
|
||
|
|
/// </summary>
|
||
|
|
public static AgvCar.Agv[] agvcar;
|
||
|
|
public static AgvCar.Agv[] agvcar2;//总图使用
|
||
|
|
public static Cls.AgvInfo[] AgvInfo;
|
||
|
|
|
||
|
|
public static Panel[] Map;
|
||
|
|
|
||
|
|
public static ClsDBConn_sql db_conn = new ClsDBConn_sql();
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
///AGV位置变更时,记录位置信息的Temp
|
||
|
|
/// </summary>
|
||
|
|
public static int[] Agv_Location_Temp;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 创建地标容器
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="id">地标编号</param>
|
||
|
|
/// <param name="b">1.左端(后退) 2.右端(前进) 3.顶部(向上) 4.底部(向下)</param>
|
||
|
|
/// <param name="x">容器放置坐标x</param>
|
||
|
|
/// <param name="y">容器放置坐标y</param>
|
||
|
|
///
|
||
|
|
|
||
|
|
public static void CreatePanelLocation(string id, int direction, int x, int y, int area, string Assembly_ID)
|
||
|
|
{
|
||
|
|
Panel pl = new Panel();
|
||
|
|
pl.Parent = Map[area];
|
||
|
|
pl.BackColor = Color.Transparent;
|
||
|
|
Label lab = new Label();
|
||
|
|
|
||
|
|
//Button lab = new Button();
|
||
|
|
lab.Visible = Cls.Param.Location_ID_Dispaly;
|
||
|
|
lab.Text = id;
|
||
|
|
if (Assembly_ID != "0" || Assembly_ID != "")
|
||
|
|
{
|
||
|
|
lab.Tag = Assembly_ID + "-" + id;
|
||
|
|
lab.DoubleClick += new System.EventHandler(Cls.Path_Reset.label12_DoubleClick);
|
||
|
|
lab.MouseClick += new MouseEventHandler(label_MouseClick);
|
||
|
|
}
|
||
|
|
lab.AutoSize = false;
|
||
|
|
lab.Height = Cls.Param.Icon_Size;
|
||
|
|
lab.Width = Cls.Param.Icon_Size;
|
||
|
|
|
||
|
|
pl.Width = Cls.Param.Icon_Size;
|
||
|
|
pl.Height = Cls.Param.Icon_Size;
|
||
|
|
lab.Parent = pl;
|
||
|
|
lab.BackColor = Color.Transparent;
|
||
|
|
lab.Font = new Font("宋体", 9, FontStyle.Regular);
|
||
|
|
lab.TextAlign = ContentAlignment.MiddleCenter;
|
||
|
|
if (direction==1)
|
||
|
|
{
|
||
|
|
pl.Location = new Point(x, y-Cls.Param.Icon_Size/2);
|
||
|
|
pl.Tag = id + "-" + "1";
|
||
|
|
lab.Dock = DockStyle.Left;
|
||
|
|
}
|
||
|
|
else if (direction == 2)
|
||
|
|
{
|
||
|
|
pl.Location = new Point(x, y - Cls.Param.Icon_Size / 2);
|
||
|
|
pl.Tag = id + "-" + "2";
|
||
|
|
lab.Dock = DockStyle.Left;
|
||
|
|
}
|
||
|
|
else if (direction == 3)
|
||
|
|
{
|
||
|
|
pl.Location = new Point(x - Cls.Param.Icon_Size / 2, y);
|
||
|
|
pl.Tag = id + "-" + "3";
|
||
|
|
lab.Dock = DockStyle.Top;
|
||
|
|
}
|
||
|
|
else if (direction == 4)
|
||
|
|
{
|
||
|
|
pl.Location = new Point(x - Cls.Param.Icon_Size / 2, y);
|
||
|
|
pl.Tag = id + "-" + "4";
|
||
|
|
lab.Dock = DockStyle.Top;
|
||
|
|
}
|
||
|
|
pl.Name = "Contain"+id.ToString();
|
||
|
|
}
|
||
|
|
|
||
|
|
public static int loc_flag = 0;
|
||
|
|
private static void label_MouseClick(object sender, MouseEventArgs e)
|
||
|
|
{
|
||
|
|
if (e.Button == System.Windows.Forms.MouseButtons.Right)
|
||
|
|
{
|
||
|
|
loc_flag = Convert.ToInt16(((Label)sender).Text);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
private static object obj_dgvupdate = new object();
|
||
|
|
public static void DgvUpdate(DataGridView dgv, int row, string columnname, bool value)
|
||
|
|
{
|
||
|
|
lock (obj_dgvupdate)
|
||
|
|
{
|
||
|
|
dgvUpdate(dgv, row, columnname, value);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
private static void dgvUpdate(DataGridView dgv , int row , string columnname ,bool value)
|
||
|
|
{
|
||
|
|
dgv.Rows[row].Cells[columnname].Value = value;
|
||
|
|
if (columnname == "Status")
|
||
|
|
{
|
||
|
|
if (value)
|
||
|
|
{
|
||
|
|
dgv.Rows[row].DefaultCellStyle.ForeColor = Color.Red;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
dgv.Rows[row].Cells["联网状态"].Value = value;
|
||
|
|
dgv.Rows[row].DefaultCellStyle.ForeColor = Color.Gray;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if (columnname == "联网状态")
|
||
|
|
{
|
||
|
|
if (value)
|
||
|
|
{
|
||
|
|
dgv.Rows[row].DefaultCellStyle.ForeColor = Color.Black;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
dgv.Rows[row].DefaultCellStyle.ForeColor = Color.Red;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private static object obj_AgvIpToId = new object();
|
||
|
|
public static int AgvIpToId(string IP)
|
||
|
|
{
|
||
|
|
lock (obj_AgvIpToId)
|
||
|
|
{
|
||
|
|
string ip = IP;
|
||
|
|
int ID = 0; ;
|
||
|
|
DataView rowfilter = new DataView(mainfrm.ds_Agvlist.Tables[0]);
|
||
|
|
rowfilter.RowFilter = "IPAddress='" + ip + "'";
|
||
|
|
rowfilter.RowStateFilter = DataViewRowState.OriginalRows;
|
||
|
|
DataTable dt = rowfilter.ToTable();
|
||
|
|
try
|
||
|
|
{
|
||
|
|
ID = Convert.ToInt16(dt.Rows[0]["ID"].ToString());
|
||
|
|
}
|
||
|
|
catch
|
||
|
|
{
|
||
|
|
}
|
||
|
|
return ID;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private static int run_time;
|
||
|
|
private static int run_model;
|
||
|
|
private static int next_loc = 0;
|
||
|
|
/// <summary>
|
||
|
|
/// 显示AGV位置状态
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="agv_id">AGV编号</param>
|
||
|
|
/// <param name="run_status">运动状态:运行/停止</param>
|
||
|
|
/// <param name="warn_level">报警等级</param>
|
||
|
|
/// <param name="current_location">当前位置</param>
|
||
|
|
/// <param name="map_id">所属地图编号</param>
|
||
|
|
/// <param name="run_fx">运动方向:直行/左转/右转</param>
|
||
|
|
public static void Agv_Car_Status(int agv_id ,
|
||
|
|
bool run_status,
|
||
|
|
int warn_level ,
|
||
|
|
int current_location,
|
||
|
|
int map_id,
|
||
|
|
int run_fx)
|
||
|
|
{
|
||
|
|
Func.agvcar[agv_id - 1].Car_Warn_Level = warn_level;
|
||
|
|
|
||
|
|
if (current_location != Agv_Location_Temp[agv_id - 1])
|
||
|
|
{
|
||
|
|
Func.agvcar[agv_id - 1].Run_Status = false;
|
||
|
|
Agv_Location_Temp[agv_id - 1] = current_location;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
Func.agvcar[agv_id - 1].Run_Status = run_status;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (current_location == 0) return;
|
||
|
|
run_time = 0;
|
||
|
|
run_model = 0;
|
||
|
|
next_loc = 0;
|
||
|
|
Panel pl_new_parent = new Panel();//xin panel
|
||
|
|
Panel pl_old_parent = new Panel();//jiu panel
|
||
|
|
Panel parent_pnl = new Panel();
|
||
|
|
|
||
|
|
parent_pnl = Func.Map[map_id ];
|
||
|
|
|
||
|
|
foreach (System.Windows.Forms.Control ctl in parent_pnl.Controls)
|
||
|
|
{
|
||
|
|
if (ctl.GetType().Name == "Panel")
|
||
|
|
{
|
||
|
|
if (Convert.ToInt16(ctl.Tag.ToString().Split('-')[0]) == current_location)
|
||
|
|
{
|
||
|
|
pl_new_parent = (Panel)ctl;
|
||
|
|
|
||
|
|
//AGV移动到新的管控停止位
|
||
|
|
if (pl_new_parent != (Panel)Func.agvcar[agv_id - 1].Parent && !Func.agvcar[agv_id - 1].Run_Status )
|
||
|
|
{
|
||
|
|
Func.agvcar[agv_id - 1].Refresh();
|
||
|
|
pl_old_parent = (Panel)Func.agvcar[agv_id - 1].Parent;
|
||
|
|
Func.agvcar[agv_id - 1].Parent = pl_new_parent;
|
||
|
|
Func.agvcar[agv_id - 1].BringToFront();
|
||
|
|
if (pl_new_parent.Tag.ToString().Split('-')[1] == "1")
|
||
|
|
{
|
||
|
|
Func.agvcar[agv_id - 1].Dock = DockStyle.Left;
|
||
|
|
}
|
||
|
|
else if (pl_new_parent.Tag.ToString().Split('-')[1] == "2")
|
||
|
|
{
|
||
|
|
Func.agvcar[agv_id - 1].Dock = DockStyle.Right;
|
||
|
|
}
|
||
|
|
else if (pl_new_parent.Tag.ToString().Split('-')[1] == "3")
|
||
|
|
{
|
||
|
|
Func.agvcar[agv_id - 1].Dock = DockStyle.Top;
|
||
|
|
}
|
||
|
|
else if (pl_new_parent.Tag.ToString().Split('-')[1] == "4")
|
||
|
|
{
|
||
|
|
Func.agvcar[agv_id - 1].Dock = DockStyle.Bottom;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//AGV从停止位出发
|
||
|
|
else if (pl_new_parent == (Panel)Func.agvcar[agv_id - 1].Parent &&
|
||
|
|
Func.agvcar[agv_id - 1].Run_Status )
|
||
|
|
{
|
||
|
|
if (Func.agvcar[agv_id - 1].Parent != parent_pnl)
|
||
|
|
{
|
||
|
|
pl_old_parent = (Panel)Func.agvcar[agv_id - 1].Parent;
|
||
|
|
Func.agvcar[agv_id - 1].Dock = DockStyle.None;
|
||
|
|
Func.agvcar[agv_id - 1].Parent = parent_pnl;
|
||
|
|
string ss = parent_pnl.Name;
|
||
|
|
|
||
|
|
Func.agvcar[agv_id - 1].Location = pl_old_parent.Location;
|
||
|
|
Func.agvcar[agv_id - 1].BringToFront();
|
||
|
|
|
||
|
|
nextStation(Convert.ToInt16((Func.agvcar[agv_id - 1].Tag.ToString().Split('-'))[1]), current_location, run_fx, out run_time, out run_model,out next_loc);
|
||
|
|
Func.agvcar[agv_id - 1].TimeLong = run_time;
|
||
|
|
Func.agvcar[agv_id - 1].Run_Model = run_model;
|
||
|
|
if (next_loc != 0)
|
||
|
|
{
|
||
|
|
foreach (System.Windows.Forms.Control c in parent_pnl.Controls)
|
||
|
|
{
|
||
|
|
if (c.GetType().Name == "Panel")
|
||
|
|
{
|
||
|
|
if (Convert.ToInt16(c.Tag.ToString().Split('-')[0]) == next_loc)
|
||
|
|
{
|
||
|
|
Func.agvcar[agv_id - 1].NextLocation = c.Location;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
//以下设置新容器大小
|
||
|
|
int i = 0;
|
||
|
|
foreach (System.Windows.Forms.Control ctl in pl_new_parent.Controls)
|
||
|
|
{
|
||
|
|
i = i + Cls.Param.Icon_Size;
|
||
|
|
}
|
||
|
|
try
|
||
|
|
{
|
||
|
|
if (pl_new_parent.Tag.ToString().Split('-')[1] == "3" || pl_new_parent.Tag.ToString().Split('-')[1] == "4")
|
||
|
|
{
|
||
|
|
pl_new_parent.Height = i;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
pl_new_parent.Width = i;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
catch
|
||
|
|
{
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// 获取下一个站点
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="Assembly_ID">线体编号</param>
|
||
|
|
/// <param name="Landmark_ID">位置编号</param>
|
||
|
|
/// <param name="flag">区分</param>
|
||
|
|
/// <param name="p">返回下一个站点坐标</param>
|
||
|
|
/// <param name="run_time">返回到下一个站点的时间</param>
|
||
|
|
/// <param name="run_model">返回AGV图标运动模式</param>
|
||
|
|
private static void nextStation(int Assembly_ID, int Landmark_ID, int flag, out int run_time1, out int run_model1, out int next_loc1)
|
||
|
|
{
|
||
|
|
run_time1 = 0;
|
||
|
|
run_model1 = 0;
|
||
|
|
next_loc1 = 0;
|
||
|
|
DataView rowfilter = new DataView(mainfrm.ds_linelandmark.Tables[0]);
|
||
|
|
rowfilter.RowFilter = "Assembly_Line=" + Assembly_ID + " and LOC_ID= " + Landmark_ID;
|
||
|
|
rowfilter.RowStateFilter = DataViewRowState.OriginalRows;
|
||
|
|
DataTable dt = rowfilter.ToTable();
|
||
|
|
try
|
||
|
|
{
|
||
|
|
if (dt.Rows.Count == 1)
|
||
|
|
{
|
||
|
|
if (flag == 1)
|
||
|
|
{
|
||
|
|
next_loc1 = Convert.ToInt16(dt.Rows[0]["Next_Station1"]);
|
||
|
|
run_time1 = Convert.ToInt16(dt.Rows[0]["LongTime1"]);
|
||
|
|
run_model1 = Convert.ToInt16(dt.Rows[0]["Drict1"]);
|
||
|
|
}
|
||
|
|
else if (flag == 2)
|
||
|
|
{
|
||
|
|
next_loc1 = Convert.ToInt16(dt.Rows[0]["Next_Station1"]);
|
||
|
|
run_time1 = Convert.ToInt16(dt.Rows[0]["LongTime2"]);
|
||
|
|
run_model1 = Convert.ToInt16(dt.Rows[0]["Drict2"]);
|
||
|
|
}
|
||
|
|
else if (flag == 3)
|
||
|
|
{
|
||
|
|
next_loc1 = Convert.ToInt16(dt.Rows[0]["Next_Station1"]);
|
||
|
|
run_time1 = Convert.ToInt16(dt.Rows[0]["LongTime2"]);
|
||
|
|
run_model1 = Convert.ToInt16(dt.Rows[0]["Drict2"]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
catch
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// AGV实时故障显示
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="del_agv_no"></param>
|
||
|
|
/// <param name="Assembly_Name"></param>
|
||
|
|
/// <param name="Assembly_Id"></param>
|
||
|
|
/// <param name="AGV_Internal_No"></param>
|
||
|
|
/// <param name="AlarmInfo"></param>
|
||
|
|
/// <param name="agv_no"></param>
|
||
|
|
public static void Agv_Alarm_Insert(int del_agv_no, string Assembly_Name, string Assembly_Id, int AGV_Internal_No, string AlarmInfo, int agv_no)
|
||
|
|
{
|
||
|
|
lock (obj_agv_alarm_insert)
|
||
|
|
{
|
||
|
|
agv_alarm_insert(del_agv_no, Assembly_Name, Assembly_Id, AGV_Internal_No, AlarmInfo, agv_no);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
private static object obj_agv_alarm_insert = new object();
|
||
|
|
private static void agv_alarm_insert(int del_agv_no, string Assembly_Name, string Assembly_Id, int AGV_Internal_No, string AlarmInfo, int agv_no)
|
||
|
|
{
|
||
|
|
if (del_agv_no == 0)
|
||
|
|
{
|
||
|
|
bool update_flag = false;
|
||
|
|
if (mainfrm.ds_AgvWarn.Tables[0].Rows.Count > 0)
|
||
|
|
{
|
||
|
|
for (int i = 0; i < mainfrm.ds_AgvWarn.Tables[0].Rows.Count; i++)
|
||
|
|
{
|
||
|
|
if (Convert.ToInt16(mainfrm.ds_AgvWarn.Tables[0].Rows[i][3].ToString()) == agv_no &&
|
||
|
|
mainfrm.ds_AgvWarn.Tables[0].Rows[i][5].ToString().Trim() == AlarmInfo.Trim())
|
||
|
|
{
|
||
|
|
//ds_aGVWarn.Tables[0].Rows[i][0] = DateTime.Now.ToString();
|
||
|
|
//ds_aGVWarn.Tables[0].Rows[i][1] = Assembly_Id;
|
||
|
|
//ds_aGVWarn.Tables[0].Rows[i][2] = Assembly_Name;
|
||
|
|
//ds_aGVWarn.Tables[0].Rows[i][3] = agv_no;
|
||
|
|
//ds_aGVWarn.Tables[0].Rows[i][4] = AGV_Internal_No;
|
||
|
|
//ds_aGVWarn.Tables[0].Rows[i][5] = AlarmInfo;
|
||
|
|
//update_flag = true;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (!update_flag)
|
||
|
|
{
|
||
|
|
DataRow dr = mainfrm.ds_AgvWarn.Tables[0].NewRow();
|
||
|
|
dr[0] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");// 时间
|
||
|
|
dr[1] = Assembly_Id; // 线体编号
|
||
|
|
dr[2] = Assembly_Name; // 线体名称
|
||
|
|
dr[3] = agv_no; // 设备编号
|
||
|
|
dr[4] = AGV_Internal_No; // 内部编号
|
||
|
|
dr[5] = AlarmInfo; // 报警信息
|
||
|
|
mainfrm.ds_AgvWarn.Tables[0].Rows.Add(dr);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
for (int i = 0; i < mainfrm.ds_AgvWarn.Tables[0].Rows.Count; i++)
|
||
|
|
{
|
||
|
|
if (AlarmInfo == "正常")
|
||
|
|
{
|
||
|
|
if (Convert.ToInt16(mainfrm.ds_AgvWarn.Tables[0].Rows[i][3]) == del_agv_no)
|
||
|
|
{
|
||
|
|
if (!mainfrm.ds_AgvWarn.Tables[0].Rows[i][5].ToString().Contains("障碍物"))
|
||
|
|
{
|
||
|
|
//db_conn.Command("INSERT INTO [Warn_Log] ([Dt] ,[Agv_id] ,[Type] ,[Reset]) VALUES ('" +
|
||
|
|
// mainfrm.ds_AgvWarn.Tables[0].Rows[i][0] + "'," +
|
||
|
|
// mainfrm.ds_AgvWarn.Tables[0].Rows[i][3] + ",'" +
|
||
|
|
// mainfrm.ds_AgvWarn.Tables[0].Rows[i][5] + "','" +
|
||
|
|
// DateTime.Now.ToString() + "')");
|
||
|
|
db_conn.Command("INSERT INTO [Warn_Log] ([Dt] ,[Agv_id] ,[Type] ,[Reset] ,[Internal_ID] ,[Line_ID] ,[Line_Name]) VALUES ('" +
|
||
|
|
mainfrm.ds_AgvWarn.Tables[0].Rows[i][0] + "'," +
|
||
|
|
mainfrm.ds_AgvWarn.Tables[0].Rows[i][3] + ",'" +
|
||
|
|
mainfrm.ds_AgvWarn.Tables[0].Rows[i][5] + "','" +
|
||
|
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'," +
|
||
|
|
Func.AgvInfo[Convert.ToInt16(mainfrm.ds_AgvWarn.Tables[0].Rows[i][3]) - 1].Internal_ID + "," +
|
||
|
|
Func.AgvInfo[Convert.ToInt16(mainfrm.ds_AgvWarn.Tables[0].Rows[i][3]) - 1].AssemblyLine + ",'" +
|
||
|
|
Func.AgvInfo[Convert.ToInt16(mainfrm.ds_AgvWarn.Tables[0].Rows[i][3]) - 1].AssemblyName + "')");
|
||
|
|
}
|
||
|
|
mainfrm.ds_AgvWarn.Tables[0].Rows.RemoveAt(i);
|
||
|
|
i--;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
if (Convert.ToInt16(mainfrm.ds_AgvWarn.Tables[0].Rows[i][3]) == del_agv_no &&
|
||
|
|
mainfrm.ds_AgvWarn.Tables[0].Rows[i][5].ToString() == AlarmInfo)
|
||
|
|
{
|
||
|
|
if (!mainfrm.ds_AgvWarn.Tables[0].Rows[i][5].ToString().Contains("障碍物"))
|
||
|
|
{
|
||
|
|
db_conn.Command("INSERT INTO [Warn_Log] ([Dt] ,[Agv_id] ,[Type] ,[Reset] ,[Internal_ID] ,[Line_ID] ,[Line_Name]) VALUES ('" +
|
||
|
|
mainfrm.ds_AgvWarn.Tables[0].Rows[i][0] + "'," +
|
||
|
|
mainfrm.ds_AgvWarn.Tables[0].Rows[i][3] + ",'" +
|
||
|
|
mainfrm.ds_AgvWarn.Tables[0].Rows[i][5] + "','" +
|
||
|
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "',"+
|
||
|
|
Func.AgvInfo[Convert.ToInt16(mainfrm.ds_AgvWarn.Tables[0].Rows[i][3])-1].Internal_ID+","+
|
||
|
|
Func.AgvInfo[Convert.ToInt16(mainfrm.ds_AgvWarn.Tables[0].Rows[i][3]) - 1].AssemblyLine+",'"+
|
||
|
|
Func.AgvInfo[Convert.ToInt16(mainfrm.ds_AgvWarn.Tables[0].Rows[i][3]) - 1].AssemblyName+"')");
|
||
|
|
}
|
||
|
|
mainfrm.ds_AgvWarn.Tables[0].Rows.RemoveAt(i);
|
||
|
|
i--;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
///
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="Assembly_Name"></param>
|
||
|
|
/// <param name="Assembly_Id"></param>
|
||
|
|
/// <param name="AGV_Internal_No"></param>
|
||
|
|
/// <param name="LandMark"></param>
|
||
|
|
/// <param name="Info"></param>
|
||
|
|
/// <param name="agv_no"></param>
|
||
|
|
public static void CrossInfo_Insert(string Assembly_Name,
|
||
|
|
string Assembly_Id,
|
||
|
|
int AGV_Internal_No,
|
||
|
|
int LandMark,
|
||
|
|
string Info,
|
||
|
|
int agv_no,
|
||
|
|
int plc_value,
|
||
|
|
int internal_id,
|
||
|
|
int line_id,
|
||
|
|
string line_name)
|
||
|
|
{
|
||
|
|
lock (obj_crossinfo_insert)
|
||
|
|
{
|
||
|
|
crossInfo_Insert(Assembly_Name, Assembly_Id, AGV_Internal_No, LandMark, Info, agv_no, plc_value, internal_id, line_id,line_name);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
private static object obj_crossinfo_insert = new object();
|
||
|
|
public static void crossInfo_Insert(string Assembly_Name,
|
||
|
|
string Assembly_Id,
|
||
|
|
int AGV_Internal_No,
|
||
|
|
int LandMark,
|
||
|
|
string Info,
|
||
|
|
int agv_no,
|
||
|
|
int plc_value,
|
||
|
|
int internal_id,
|
||
|
|
int line_id,
|
||
|
|
string line_name)
|
||
|
|
{
|
||
|
|
string strsql = "";
|
||
|
|
strsql = "INSERT INTO [Go_Log] ([Dt] ,[Agv_id] ,[Type] ,[Location],[plc_value] ,[Internal_ID],[Line_ID] ,[Line_Name]) VALUES " +
|
||
|
|
"('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "'," +
|
||
|
|
agv_no + ",'" +
|
||
|
|
Info + "'," +
|
||
|
|
LandMark + "," +
|
||
|
|
plc_value +","+
|
||
|
|
internal_id+","+
|
||
|
|
line_id + ",'"+
|
||
|
|
line_name + "')";
|
||
|
|
db_conn.Command(strsql);
|
||
|
|
}
|
||
|
|
|
||
|
|
private static object obj_GetLandMarkId = new object();
|
||
|
|
/// <summary>
|
||
|
|
/// 根据地标值读取地标编号
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="value"></param>
|
||
|
|
/// <returns></returns>
|
||
|
|
public static int GetLandMarkId(int assemblyline_id, int value)
|
||
|
|
{
|
||
|
|
lock (obj_GetLandMarkId)
|
||
|
|
{
|
||
|
|
int markid = 0;
|
||
|
|
DataView rowfilter = new DataView(mainfrm.ds_linelandmark.Tables[0]);
|
||
|
|
rowfilter.RowFilter = "Flag_Value=" + value + " and Assembly_Line= " + assemblyline_id;
|
||
|
|
rowfilter.RowStateFilter = DataViewRowState.OriginalRows;
|
||
|
|
DataTable dt = rowfilter.ToTable();
|
||
|
|
try
|
||
|
|
{
|
||
|
|
markid = Convert.ToInt16(dt.Rows[0]["Loc_ID"].ToString());
|
||
|
|
}
|
||
|
|
catch
|
||
|
|
{
|
||
|
|
}
|
||
|
|
return markid;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private static object obj_change = new object();
|
||
|
|
public static void Change_Rec(int agv_id ,int current_loc,int histroy_loc,DateTime dt,int internal_id,int line_id,string line_name)
|
||
|
|
{
|
||
|
|
lock (obj_change)
|
||
|
|
{
|
||
|
|
if (mainfrm.ds_Change.Tables[0].Rows.Count == 0) return;
|
||
|
|
if (histroy_loc == 0) return;
|
||
|
|
|
||
|
|
bool current_loc_res = false;
|
||
|
|
bool histroy_loc_res = false;
|
||
|
|
if (mainfrm.ds_Change.Tables[0].Rows.Count > 0)
|
||
|
|
{
|
||
|
|
foreach (DataRow dr in mainfrm.ds_Change.Tables[0].Rows)
|
||
|
|
{
|
||
|
|
if (Convert.ToInt16(dr[0].ToString()) == current_loc)
|
||
|
|
{
|
||
|
|
current_loc_res = true;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (Convert.ToInt16(dr[0].ToString()) == histroy_loc)
|
||
|
|
{
|
||
|
|
histroy_loc_res = true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (current_loc_res == false && histroy_loc_res == true)
|
||
|
|
{
|
||
|
|
db_conn.Command("INSERT INTO [Change_Log]([Agv_ID] ,[Start_time],[Finish_time] ,[Location_ID],internal_id, line_id, line_name) VALUES(" +
|
||
|
|
agv_id + ",'" +
|
||
|
|
dt + "','" +
|
||
|
|
DateTime.Now.ToString() + "'," +
|
||
|
|
histroy_loc + ","+
|
||
|
|
internal_id +","+
|
||
|
|
line_id +",'"+
|
||
|
|
line_name+"')");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|