You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
910 lines
44 KiB
910 lines
44 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using DBFactory;
|
|
using System.Net.Sockets;
|
|
using System.Threading;
|
|
using ICommLayer;
|
|
using CommLayerFactory;
|
|
using Microsoft.VisualBasic;
|
|
namespace ControlSystem
|
|
{
|
|
/// <summary>
|
|
/// Creator:Richard.liu
|
|
/// É豸ָÁî¶ÓÁйÜÀí
|
|
/// </summary>
|
|
public partial class FrmModifyMonitor : Form
|
|
{
|
|
string _monstatus = " F_Status<>-1 ";
|
|
private static FrmModifyMonitor _formInstance;
|
|
|
|
public static FrmModifyMonitor FormInstance
|
|
{
|
|
get
|
|
{
|
|
if (_formInstance == null)
|
|
{
|
|
_formInstance = new FrmModifyMonitor();
|
|
}
|
|
return _formInstance;
|
|
}
|
|
set { _formInstance = value; }
|
|
}
|
|
CGetState gs = new CGetState();
|
|
DBOperator dbo = CStaticClass.dbo;
|
|
DBOperator dboM = CStaticClass.dboM;
|
|
CCommonFunction ccf = new CCommonFunction();
|
|
Model.MDevice devinfo;
|
|
public FrmModifyMonitor()
|
|
{
|
|
InitializeComponent();
|
|
_formInstance = this;
|
|
}
|
|
|
|
private void cmMonitor_Opening(object sender, CancelEventArgs e)
|
|
{
|
|
if (this.dgvMonitor.CurrentRow == null)
|
|
{
|
|
TSMonitor.Visible = false;
|
|
TSMManager.Visible = false;
|
|
TSMSimulateRun.Visible = false;
|
|
TSMmonitorOK.Visible = false;
|
|
TSMRestore.Visible = false;
|
|
TSMmonitorDel.Visible = false;
|
|
toolStripSeparator2.Visible = false;
|
|
tsmAGV.Visible = false;
|
|
tsmAGVGet.Visible = false;
|
|
tsmAGVSend.Visible = false;
|
|
tsmAGVBank.Visible = false;
|
|
tsmAGVGoods.Visible = false;
|
|
return;
|
|
}
|
|
if (Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[0].Value) > 0)
|
|
{
|
|
TSMonitor.Visible = true;
|
|
TSMManager.Visible = true;
|
|
//TSMSimulateRun.Visible = true;
|
|
TSMmonitorOK.Visible = true;
|
|
TSMmonitorDel.Visible = true;
|
|
TSMRestore.Visible = true;
|
|
toolStripSeparator2.Visible = true;
|
|
|
|
TSMManager.Text = "ÈÎÎñÀàÐÍ£º" + this.dgvMonitor.CurrentRow.Cells[1].Value.ToString() +
|
|
"£»µ÷¶ÈÈÎÎñË÷Òý£º" + this.dgvMonitor.CurrentRow.Cells[0].Value.ToString();
|
|
TSMonitor.Text = "É豸ָÁîË÷Òý£º" + this.dgvMonitor.CurrentRow.Cells[2].Value.ToString();
|
|
//if (this.dgvMonitor.CurrentRow.Cells[3].Value.ToString() == "1001")
|
|
//{
|
|
// TSMSimulateRun.Visible = false;
|
|
// TSMmonitorOK.Visible = false;
|
|
|
|
// TSMRestore.Visible = true;
|
|
|
|
// toolStripSeparator2.Visible = false;
|
|
// tsmAGV.Visible = true;
|
|
// tsmAGVGet.Visible = true;
|
|
// tsmAGVSend.Visible = true;
|
|
// if (this.dgvMonitor.CurrentRow.Cells[5].Value.ToString() == "2")//1219¿ÕÍÐÅÌ»ØÊÕ
|
|
// {
|
|
// tsmAGVGoods.Visible = false;
|
|
// tsmAGVBank.Visible = true;
|
|
// tsmAGVSend.Visible = false;
|
|
// return;
|
|
// }
|
|
// else
|
|
// {
|
|
// tsmAGVSend.Visible = true;
|
|
// tsmAGVBank.Visible = false;
|
|
// }
|
|
// if (this.dgvMonitor.CurrentRow.Cells[5].Value.ToString() == "3")//1220²ÐÍÐÅÌ»ØÊÕ
|
|
// {
|
|
// tsmAGVBank.Visible = false;
|
|
// tsmAGVGoods.Visible = true;
|
|
// tsmAGVSend.Visible = false;
|
|
// return;
|
|
// }
|
|
// else
|
|
// {
|
|
// tsmAGVSend.Visible = true;
|
|
// tsmAGVGoods.Visible = false;
|
|
// }
|
|
//}
|
|
//else
|
|
//{
|
|
tsmAGV.Visible = false;
|
|
tsmAGVGet.Visible = false;
|
|
tsmAGVSend.Visible = false;
|
|
tsmAGVBank.Visible = false;
|
|
tsmAGVGoods.Visible = false;
|
|
//}
|
|
}
|
|
}
|
|
|
|
private void TSMmonitorOK_Click(object sender, EventArgs e)
|
|
{
|
|
char[] cc = new char[1] { '£º' };
|
|
string[] split = TSMonitor.Text.Split(cc);
|
|
if (split[1] == "") return;
|
|
|
|
|
|
DataView dv = dbo.ExceSQL("SELECT * FROM T_Monitor_Task Where F_MonitorIndex=" +
|
|
Convert.ToInt32(split[1])).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
//20100108ÖмäÖ¸Áî±»±¨¸æÍê³Éʱ¸øÓëÌáʾºÍ¾¯¸æ
|
|
|
|
DataView dv0 = dbo.ExceSQL("SELECT MIN(F_MonitorIndex) AS mmi FROM dbo.T_Monitor_Task WHERE (F_ManageTaskIndex = " + dv[0]["F_ManageTaskIndex"] + ") AND (F_ManageTASKKINDINDEX = " + dv[0]["F_ManageTASKKINDINDEX"] + ")").Tables[0].DefaultView;
|
|
if (dv0.Count > 0)
|
|
{
|
|
if ((dv0[0]["mmi"] != DBNull.Value) && (dv0[0]["mmi"].ToString() != split[1]))
|
|
{
|
|
if (MessageBox.Show("ÍÐÅÌÌõÂ룺" + dv[0]["F_TxtParam"].ToString() + "£¬É豸Ãû³Æ:¡°" + this.dgvMonitor.CurrentRow.Cells["É豸Ãû³Æ"].Value.ToString() + ";É豸ÃüÁî:" + this.dgvMonitor.CurrentRow.Cells["É豸ÃüÁîÃû³Æ"].Value.ToString() + "¡±Ö®Ç°»¹ÓÐûִÐÐÍê³ÉµÄµ÷¶ÈÈÎÎñ£¬Ìáǰ¡¾¶¯×÷Íê³É¡¿»áÔì³Éµ÷¶ÈÈÎÎñ»ìÂÒ£¬ÄúÈ·ÈÏÒª¼ÌÐø²Ù×÷Âð£¿", "²Ù×÷Ìáʾ£º", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
dv0 = null;
|
|
//20100108²Ù×÷ºÚÏ»×ÓÔö¼ÓÍÐÅÌÌõÂë
|
|
if (MessageBox.Show("ÄúÈ·ÈÏÍÐÅÌÌõÂ룺" + dv[0]["F_TxtParam"].ToString() + "£¬É豸Ãû³Æ:¡°" + this.dgvMonitor.CurrentRow.Cells["É豸Ãû³Æ"].Value.ToString() + ";É豸ÃüÁî:" + this.dgvMonitor.CurrentRow.Cells["É豸ÃüÁîÃû³Æ"].Value.ToString() + "¡±ÒѾ²Ù×÷Íê³ÉÁËÂð£¿", "²Ù×÷Ìáʾ£º", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
|
|
string sss = "É豸Ë÷Òý:" + dv[0]["F_DeviceIndex"].ToString() + ";É豸ָÁîË÷Òý:" + dv[0]["F_MonitorIndex"].ToString();
|
|
//20100108²Ù×÷ºÚÏ»×ÓÔö¼ÓÍÐÅÌÌõÂë
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("É豸ָÁî¹ÜÀí", "ÊÖ¹¤±¨¸æÍê³É", "ÍÐÅÌÌõÂ룺" + dv[0]["F_TxtParam"].ToString(), sss);
|
|
|
|
AssociateComplete(Convert.ToInt32(dv[0]["F_DeviceIndex"]), Convert.ToInt32(dv[0]["F_MonitorIndex"]), Convert.ToInt32(dv[0]["F_Status"]));
|
|
FrmControlMonitor.FormInstance.MonitorRefresh();//20110222
|
|
this.dgvMonitor.DataSource = dbo.ExceSQL("select * from V_Monitor_Task where " + _monstatus + " order by É豸ָÁîË÷Òý asc ").Tables[0].DefaultView;
|
|
}
|
|
}
|
|
|
|
private void TSMRestore_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
char[] cc = new char[1] { '£º' };
|
|
string[] split = TSMonitor.Text.Split(cc);
|
|
if (split[1] == "") return;
|
|
|
|
|
|
ISendDeviceOrder sdo;
|
|
int DeviceIdx;
|
|
int devKind;
|
|
int mindex = Convert.ToInt32(split[1]);
|
|
int fid = ccf.GetManageTaskIndexfromMonitor(mindex);
|
|
int mankind = ccf.GetManageTaskKindIndexFromMonitor(mindex);
|
|
|
|
|
|
//20100108¸ÄΪselect *
|
|
DataView dv = dbo.ExceSQL("select * from T_Monitor_Task where F_MonitorIndex=" + mindex).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
//20100108ÖмäÖ¸Áî±»¸´Î»Ê±¸øÓëÌáʾºÍ¾¯¸æ
|
|
DataView dv0 = dbo.ExceSQL("SELECT MIN(F_MonitorIndex) AS mmi FROM dbo.T_Monitor_Task WHERE (F_ManageTaskIndex = " + fid + ") AND (F_ManageTASKKINDINDEX = " + mankind + ")").Tables[0].DefaultView;
|
|
if (dv0.Count > 0)
|
|
{
|
|
if ((dv0[0]["mmi"] != DBNull.Value) && (dv0[0]["mmi"].ToString() != mindex.ToString()))
|
|
{
|
|
if (MessageBox.Show("ÍÐÅÌÌõÂ룺" + dv[0]["F_TxtParam"].ToString() + "£¬É豸Ãû³Æ:¡°" + this.dgvMonitor.CurrentRow.Cells["É豸Ãû³Æ"].Value.ToString() + ";É豸ÃüÁî:" + this.dgvMonitor.CurrentRow.Cells["É豸ÃüÁîÃû³Æ"].Value.ToString() + "¡±Ö®Ç°»¹ÓÐûִÐÐÍê³ÉµÄµ÷¶ÈÈÎÎñ£¬Ìáǰ¡¾¸´Î»¡¿»áÔì³Éµ÷¶ÈÈÎÎñ»ìÂÒ£¬ÄúÈ·ÈÏÒª¼ÌÐø²Ù×÷Âð£¿", "²Ù×÷Ìáʾ£º", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
dv0 = null;
|
|
|
|
//20100108²Ù×÷ºÚÏ»×ÓÔö¼ÓÍÐÅÌÌõÂë
|
|
if (MessageBox.Show("ÄúÈ·ÈÏÍÐÅÌÌõÂ룺" + dv[0]["F_TxtParam"].ToString() + "£¬É豸Ãû³Æ:¡°" + this.dgvMonitor.CurrentRow.Cells["É豸Ãû³Æ"].Value.ToString() + ";É豸ÃüÁî:" + this.dgvMonitor.CurrentRow.Cells["É豸ÃüÁîÃû³Æ"].Value.ToString() + "¡±ÐèÒª±»ÖØÐ·¢ËͺÍÉ豸ÇåÁãÂð£¿", "²Ù×÷Ìáʾ£º", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//20091107
|
|
devKind = ccf.GetDeviceKindIdx(Convert.ToInt32(dv[0]["F_DeviceIndex"]));
|
|
if ((devKind == 6) && (dv[0]["F_AgvNo"] != DBNull.Value))
|
|
{
|
|
if (MessageBox.Show("ÄúÒª¸´Î»µÄAGVÈÎÎñÒѾ·ÖÅäAGV³µºÅ£º" + dv[0]["F_AgvNo"].ToString() + "£¬È·ÈÏÒª¼ÌÐøÖØÐÂÏ´ïAGVÃüÁîÂð£¿", "²Ù×÷Ìáʾ£º", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
string sss = "É豸Ë÷Òý:" + dv[0]["F_DeviceIndex"].ToString() + ";É豸ָÁîË÷Òý:" + dv[0]["F_MonitorIndex"].ToString();
|
|
//20100108²Ù×÷ºÚÏ»×ÓÔö¼ÓÍÐÅÌÌõÂë
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("É豸ָÁî¹ÜÀí", "ÊÖ¹¤¸´Î»", "ÍÐÅÌÌõÂë:" + dv[0]["F_TxtParam"].ToString(), sss);
|
|
//¼ì²é¹ØÁªÃüÁîÒ»Æð¸´Î»
|
|
//Èç¹ûmindexÊÇÖ÷¶¯ÈÎÎñ£¨f_associatemonitorÓÐÊý¾Ý£©£¬Ïȸ´Î»±»¶¯µÄÈÎÎñ£»Èç¹ûmindexÊDZ»¶¯ÈÎÎñ£¬Ïȸ´Î»×Ô¼º£¬ÔÙ¸´Î»Ö÷¶¯ÈÎÎñ£»
|
|
DataView dv1 = dbo.ExceSQL("select F_DeviceIndex,F_Associate from T_Monitor_Task where F_Associate IS NOT NULL and F_MonitorIndex=" + mindex).Tables[0].DefaultView;
|
|
if (dv1.Count > 0)
|
|
{
|
|
DataView dv2 = dbo.ExceSQL("select F_DeviceIndex,F_MonitorIndex from T_Monitor_Task where F_MonitorIndex=" + Convert.ToInt32(dv1[0]["F_Associate"])).Tables[0].DefaultView;
|
|
if (dv2.Count > 0)//ÓйØÁªÃüÁÏȸ´Î»¹ØÁªÃüÁî
|
|
{
|
|
|
|
DeviceIdx = Convert.ToInt32(dv2[0]["F_DeviceIndex"]);
|
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
|
if ((devKind == 2) || (devKind == 4))
|
|
{//ÊäËÍ»ú¡¢RGVÇåÁã
|
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0);
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
|
devinfo.SendMessage = null;
|
|
Model.CGetInfo.SetDeviceInfo(devinfo);
|
|
}
|
|
if ((devKind == 1)) //¶Ñ¶â»ú
|
|
{
|
|
|
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
|
}
|
|
|
|
dbo.ExceSQL("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=" + Convert.ToInt32(dv2[0]["F_DeviceIndex"]));
|
|
dbo.ExceSQL("update T_Monitor_Task set F_SendCount=0,F_Status=0 where F_MonitorIndex=" + Convert.ToInt32(dv2[0]["F_MonitorIndex"]));
|
|
}
|
|
//ÔÙ¸´Î»×Ô¼º
|
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
|
if ((devKind == 2) || (devKind == 4))
|
|
{//ÊäËÍ»ú¡¢RGVÇåÁã
|
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0);
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
|
devinfo.SendMessage = null;
|
|
Model.CGetInfo.SetDeviceInfo(devinfo);
|
|
}
|
|
if ((devKind == 1)) //¶Ñ¶â»ú
|
|
{
|
|
|
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
|
}
|
|
//if ((devKind == 6)) //AGV
|
|
//{
|
|
// int agvtask = ccf.GetAGVTask(mindex);
|
|
// if (agvtask != -1)
|
|
// {
|
|
// sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
|
// sdo.SendDeviceOrder(1, agvtask, 65, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
|
|
|
// }
|
|
//}
|
|
dbo.ExceSQL("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=" + Convert.ToInt32(dv[0]["F_DeviceIndex"]));
|
|
dbo.ExceSQL("update T_Monitor_Task set F_SendCount=0,F_Status=0 where F_MonitorIndex=" + Convert.ToInt32(dv[0]["F_MonitorIndex"]));
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
//×Ô¼ºÊÇ·ñ±»¹ØÁª,Ïȸ´Î»×Ô¼º£¬ÔÙ¸´Î»Ö÷ÈÎÎñ
|
|
DataView dv3 = dbo.ExceSQL("select F_DeviceIndex,F_MonitorIndex from T_Monitor_Task where F_Associate ='" + mindex + "'").Tables[0].DefaultView;
|
|
if (dv3.Count > 0)
|
|
{ //Ïȸ´Î»×Ô¼º
|
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
|
if ((devKind == 2) || (devKind == 4))
|
|
{//ÊäËÍ»ú¡¢RGVÇåÁã
|
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0);
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
|
devinfo.SendMessage = null;
|
|
Model.CGetInfo.SetDeviceInfo(devinfo);
|
|
}
|
|
if ((devKind == 1)) //¶Ñ¶â»ú
|
|
{
|
|
|
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
|
}
|
|
//if ((devKind == 6)) //AGV
|
|
//{
|
|
// int agvtask = ccf.GetAGVTask(mindex);
|
|
// if (agvtask != -1)
|
|
// {
|
|
// sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
|
// sdo.SendDeviceOrder(1, agvtask, 65, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
|
|
|
// }
|
|
//}
|
|
dbo.ExceSQL("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=" + Convert.ToInt32(dv[0]["F_DeviceIndex"]));
|
|
dbo.ExceSQL("update T_Monitor_Task set F_SendCount=0,F_Status=0 where F_MonitorIndex=" + mindex);
|
|
//ÔÙ¸´Î»Ö÷ÈÎÎñ
|
|
DeviceIdx = Convert.ToInt32(dv3[0]["F_DeviceIndex"]);
|
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
|
if ((devKind == 2) || (devKind == 4))
|
|
{//ÊäËÍ»ú¡¢RGVÇåÁã
|
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0);
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
|
devinfo.SendMessage = null;
|
|
Model.CGetInfo.SetDeviceInfo(devinfo);
|
|
}
|
|
if ((devKind == 1)) //¶Ñ¶â»ú
|
|
{
|
|
|
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
|
}
|
|
dbo.ExceSQL("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=" + Convert.ToInt32(dv3[0]["F_DeviceIndex"]));
|
|
dbo.ExceSQL("update T_Monitor_Task set F_SendCount=0,F_Status=0 where F_MonitorIndex=" + Convert.ToInt32(dv3[0]["F_MonitorIndex"]));
|
|
}
|
|
else
|
|
{
|
|
//ÎÞ¹ØÁªÈÎÎñ£¬Ö»¸´Î»×Ô¼º
|
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
|
if ((devKind == 2) || (devKind == 4))
|
|
{//ÊäËÍ»ú¡¢RGVÇåÁã
|
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0);
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(DeviceIdx);
|
|
devinfo.SendMessage = null;
|
|
Model.CGetInfo.SetDeviceInfo(devinfo);
|
|
}
|
|
if ((devKind == 1)) //¶Ñ¶â»ú
|
|
{
|
|
|
|
sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
|
sdo.SendDeviceOrder(2, 0, 0, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
|
}
|
|
//if ((devKind == 6)) //AGV
|
|
//{
|
|
// int agvtask = ccf.GetAGVTask(mindex);
|
|
// if (agvtask != -1)
|
|
// {
|
|
// sdo = CommModeCreate.CreateSendDeviceOrder(DeviceIdx);
|
|
// sdo.SendDeviceOrder(1, agvtask, 65, DeviceIdx, 0, 0, 0, 0, 0, 0);
|
|
|
|
// }
|
|
//}
|
|
dbo.ExceSQL("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=" + Convert.ToInt32(dv[0]["F_DeviceIndex"]));
|
|
dbo.ExceSQL("update T_Monitor_Task set F_SendCount=0,F_Status=0 where F_MonitorIndex=" + mindex);
|
|
}
|
|
}
|
|
//¸ø¹ÜÀíFERRORCODEÇå¿Õ
|
|
if (mankind == 1)
|
|
{
|
|
dboM.ExceSQL("UPDATE IO_CONTROL SET ERROR_TEXT ='' WHERE CONTROL_ID=" + fid + "");
|
|
}
|
|
dbo.ExceSQL("UPDATE T_Manage_Task SET FERRORCODE ='' WHERE FID=" + fid + " and F_ManageTaskKindIndex=" + mankind + "");
|
|
|
|
}
|
|
|
|
FrmControlMonitor.FormInstance.MonitorRefresh();//20110222
|
|
FrmControlMonitor.FormInstance.ManagerRefresh();//20110222
|
|
|
|
this.dgvMonitor.DataSource = dbo.ExceSQL("select * from V_Monitor_Task where " + _monstatus + " order by É豸ָÁîË÷Òý asc ").Tables[0].DefaultView;
|
|
}
|
|
|
|
private void TSMSimulateRun_Click(object sender, EventArgs e)
|
|
{
|
|
char[] cc1 = new char[1] { '£º' };
|
|
string[] split = TSMonitor.Text.Split(cc1);
|
|
if (split[1] == "") return;
|
|
|
|
CCommonFunction ccf = new CCommonFunction();
|
|
DataSet ds = dbo.ExceSQL("SELECT F_ManageTaskIndex, F_ManageTaskKindIndex," +
|
|
" F_MonitorIndex, F_DeviceIndex,F_NumParam2,F_NumParam3 FROM T_Monitor_Task Where F_MonitorIndex=" +
|
|
Convert.ToInt32(split[1]));
|
|
DataView dv = ds.Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
ccf.SendOrderSuccess(Convert.ToInt32(dv[0]["F_ManageTaskKindIndex"]),
|
|
Convert.ToInt32(dv[0]["F_ManageTaskIndex"]), Convert.ToInt32(dv[0]["F_MonitorIndex"]),
|
|
Convert.ToInt32(dv[0]["F_DeviceIndex"]), 0);
|
|
CGetState cg = new CGetState();
|
|
cg._States = new int[14];
|
|
cg._States[1] = 2;//±¨×ø±ê
|
|
cg._States[2] = Convert.ToInt32(dv[0]["F_MonitorIndex"]);//ÈÎÎñºÅ
|
|
cg._States[3] = Convert.ToInt32(dv[0]["F_NumParam2"]);//X×ø±ê£¨Ë®Æ½£©
|
|
cg._States[4] = Convert.ToInt32(dv[0]["F_NumParam3"]);//Y×ø±ê£¨´¹Ö±£©
|
|
cg._States[5] = Convert.ToInt32(dv[0]["F_DeviceIndex"]);//É豸ºÅ
|
|
FrmControlMonitor.FormInstance.MonitorRefresh();//20110222
|
|
FrmControlMonitor.FormInstance.ManagerRefresh();//20110222
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void rbmonAll_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
RadioButton rb = (RadioButton)sender;
|
|
if (rb.Checked == true)
|
|
{
|
|
_monstatus = " F_Status<>-1 ";
|
|
}
|
|
TSMMonitorRefresh_Click(sender, e);
|
|
}
|
|
private void TSMMonitorRefresh_Click(object sender, EventArgs e)
|
|
{
|
|
CStaticClass.RealRefresh = true;
|
|
this.dgvMonitor.DataSource = dbo.ExceSQL("select * from V_Monitor_Task where " + _monstatus + " order by É豸ָÁîË÷Òý asc ").Tables[0].DefaultView;
|
|
}
|
|
|
|
private void rbmonRun_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
if (rbmonRun.Checked == true)
|
|
{
|
|
_monstatus = " (F_Status>=1) ";
|
|
}
|
|
TSMMonitorRefresh_Click(sender, e);
|
|
}
|
|
|
|
private void rbmonWait_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
RadioButton rb = (RadioButton)sender;
|
|
if (rb.Checked == true)
|
|
{
|
|
_monstatus = " F_Status=0 ";
|
|
}
|
|
TSMMonitorRefresh_Click(sender, e);
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.textBox1.Text.Trim().Length == 0) return;
|
|
if (this.comboBox1.Text == "ÍÐÅÌÌõÂë")
|
|
{
|
|
_monstatus = " ¸½¼ÓÐÅÏ¢='" + this.textBox1.Text.Trim() + "' ";
|
|
}
|
|
if (this.comboBox1.Text == "É豸ָÁîË÷Òý")
|
|
{
|
|
_monstatus = " É豸ָÁîË÷Òý='" + this.textBox1.Text.Trim() + "' ";
|
|
}
|
|
if (this.comboBox1.Text == "µ÷¶ÈÈÎÎñË÷Òý")
|
|
{
|
|
_monstatus = " µ÷¶ÈÈÎÎñË÷Òý='" + this.textBox1.Text.Trim() + "' ";
|
|
}
|
|
TSMMonitorRefresh_Click(sender, e);
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
_monstatus = " F_Status<>-1 ";
|
|
|
|
TSMMonitorRefresh_Click(sender, e);
|
|
}
|
|
|
|
private void dgvMonitor_DataSourceChanged(object sender, EventArgs e)
|
|
{
|
|
dgvMonitor.Columns["F_Status"].Visible = false;
|
|
}
|
|
|
|
private void FrmModifyMonitor_Load(object sender, EventArgs e)
|
|
{
|
|
rbmonRun_CheckedChanged(sender, e);
|
|
}
|
|
|
|
private void tsmAGVGet_Click(object sender, EventArgs e)
|
|
{
|
|
string sql = "";
|
|
//ÓÉT_Monitor_Task±íÖлñµÃF_NumParam2×Ö¶ÎÖµ Ìõ¼þ£ºÏûÏ¢·µ»ØµÄС³µÈÎÎñºÅ
|
|
DataTable tableMonitorTask = dbo.ExceSQL("SELECT F_NumParam2,F_AgvTask,F_AgvNo FROM T_MONITOR_TASK WHERE F_DeviceIndex=1001 and F_MonitorIndex=" + this.dgvMonitor.CurrentRow.Cells[2].Value + "").Tables[0];
|
|
if (tableMonitorTask.Rows.Count > 0)
|
|
{
|
|
if (MessageBox.Show("ÄúÈ·ÈÏÊÖ¹¤±¨¸æAGV²æ»õÍê³ÉÂð£¿", "²Ù×÷Ìáʾ£º", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
|
|
sql = "UPDATE T_Monitor_Task SET F_Status = 2 WHERE (F_MonitorIndex =" + this.dgvMonitor.CurrentRow.Cells[2].Value + ")";
|
|
dbo.ExceSQL(sql);
|
|
|
|
//ÓÉT_Base_AGV_Gate±íÖлñµÃF_AGVGateDeviceIndex×Ö¶ÎÖµ Ìõ¼þ£ºT_Base_AGV_Gate.F_Address = T_Monitor_Task.F_NumParam2
|
|
DataTable tableAGVGate = dbo.ExceSQL("SELECT F_AGVGateDeviceIndex FROM T_BASE_AGV_GATE WHERE F_ADDRESS = " + Convert.ToInt32(tableMonitorTask.Rows[0]["F_NumParam2"]) + "").Tables[0];
|
|
if (tableAGVGate.Rows.Count > 0)
|
|
{
|
|
if (MessageBox.Show("ÄúÈ·¶¨Òª°ÑÉ豸:" + tableAGVGate.Rows[0]["F_AGVGateDeviceIndex"] + "Öóɡ¾ÎÞÍÐÅÌ¡¿×´Ì¬Âð£¿", "²Ù×÷Ìáʾ£º", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
//¸ü¸ÄT_Base_Device±íÖеÄF_HaveGoods×Ö¶ÎֵΪ0¡£Ìõ¼þ£ºT_Base_Device.F_DeviceIndex = T_Base_AGV_Gate.F_AGVGateDeviceIndex
|
|
dbo.ExecuteSql("UPDATE T_BASE_DEVICE SET F_PALLETBARCODE='-',F_HAVEGOODS = 0 WHERE F_DEVICEINDEX = " + Convert.ToInt32(tableAGVGate.Rows[0]["F_AGVGateDeviceIndex"]) + "");
|
|
if (ccf.GetManageTaskKindIndexFromMonitor(Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[2].Value)) == 1)
|
|
{
|
|
//20090817¸ø¹ÜÀíÖÃÎÞÍÐÅÌÐÅÏ¢
|
|
dboM.ExecuteSql("UPDATE T_ITEMDEVICE SET devicestatus ='0' WHERE devicecode = '" + tableAGVGate.Rows[0]["F_AGVGateDeviceIndex"] + "'");
|
|
}
|
|
}
|
|
string sss = "AGV³µºÅ:" + tableMonitorTask.Rows[0]["F_AgvNo"].ToString() + ";É豸ָÁîË÷Òý:" + this.dgvMonitor.CurrentRow.Cells[2].Value.ToString();
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("É豸ָÁî¹ÜÀí", "ÊÖ¹¤±¨¸æAGV²æ»õÍê³É", tableMonitorTask.Rows[0]["F_AgvNo"].ToString() + "ºÅ³µ", sss);
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Ö»ÓÐAGVÈÎÎñ²Å¿ÉÒÔÊÖ¹¤±¨¸æAGV²æ»õÍê³É£¡", "Îó²Ù×÷Ìáʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
FrmControlMonitor.FormInstance.MonitorRefresh();//20110222
|
|
FrmControlMonitor.FormInstance.ManagerRefresh();//20110222
|
|
}
|
|
|
|
private void tsmAGVSend_Click(object sender, EventArgs e)
|
|
{
|
|
//ÓÉT_Monitor_Task±íÖлñµÃF_NumParam5×Ö¶ÎÖµ Ìõ¼þ£ºÏûÏ¢·µ»ØµÄС³µÈÎÎñºÅ
|
|
DataTable tableMonitorTask = dbo.ExceSQL("SELECT F_TxtParam,F_NumParam5,F_AgvTask,F_AgvNo FROM T_MONITOR_TASK WHERE F_DeviceIndex=1001 and F_MonitorIndex=" + this.dgvMonitor.CurrentRow.Cells[2].Value + "").Tables[0];
|
|
if (tableMonitorTask.Rows.Count > 0)
|
|
{
|
|
|
|
if (MessageBox.Show("ÄúÈ·ÈÏÊÖ¹¤±¨¸æAGVж»õÍê³ÉÂð£¿", "²Ù×÷Ìáʾ£º", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//ÓÉT_Base_AGV_Gate±íÖлñµÃF_AGVGateDeviceIndex×Ö¶ÎÖµ Ìõ¼þ£ºT_Base_AGV_Gate.F_Address = T_Monitor_Task.F_NumParam2
|
|
DataTable tableAGVGate = dbo.ExceSQL("SELECT F_AGVGateDeviceIndex FROM T_BASE_AGV_GATE WHERE F_ADDRESS = " + Convert.ToInt32(tableMonitorTask.Rows[0]["F_NumParam5"]) + "").Tables[0];
|
|
if (tableAGVGate.Rows.Count > 0)
|
|
{
|
|
if (MessageBox.Show("ÄúÈ·¶¨Òª°ÑÉ豸:" + tableAGVGate.Rows[0]["F_AGVGateDeviceIndex"] + "Öóɡ¾ÓÐÍÐÅÌ¡¿×´Ì¬Âð£¿", "²Ù×÷Ìáʾ£º", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
//¸ü¸ÄT_Base_Device±íÖеÄF_HaveGoods×Ö¶ÎֵΪ0¡£Ìõ¼þ£ºT_Base_Device.F_DeviceIndex = T_Base_AGV_Gate.F_AGVGateDeviceIndex
|
|
dbo.ExecuteSql("UPDATE T_BASE_DEVICE SET F_PALLETBARCODE='" + tableMonitorTask.Rows[0]["F_TxtParam"] + "',F_HAVEGOODS = 1 WHERE F_DEVICEINDEX = " + Convert.ToInt32(tableAGVGate.Rows[0]["F_AGVGateDeviceIndex"]) + "");
|
|
|
|
}
|
|
string sss = "AGV³µºÅ:" + tableMonitorTask.Rows[0]["F_AgvNo"].ToString() + ";É豸ָÁîË÷Òý:" + this.dgvMonitor.CurrentRow.Cells[2].Value.ToString();
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("É豸ָÁî¹ÜÀí", "ÊÖ¹¤±¨¸æAGVж»õÍê³É", tableMonitorTask.Rows[0]["F_AgvNo"].ToString() + "ºÅ³µ", sss);
|
|
gs.ActionComplete(1001, Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[2].Value), Model.CGeneralFunction.TASKFINISH);
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Ö»ÓÐAGVÈÎÎñ²Å¿ÉÒÔÊÖ¹¤±¨¸æAGV·Å»õÍê³É£¡", "Îó²Ù×÷Ìáʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
|
|
private void tsmAGVBank_Click(object sender, EventArgs e)
|
|
{
|
|
FrmControlMonitor.FormInstance.MonitorRefresh();//20110222
|
|
FrmControlMonitor.FormInstance.ManagerRefresh();//20110222
|
|
gs.ActionComplete(1001, Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[2].Value), Model.CGeneralFunction.TASKFINISH);
|
|
}
|
|
|
|
private void tsmAGVGoods_Click(object sender, EventArgs e)
|
|
{
|
|
gs.ActionComplete(1001, Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[2].Value), Model.CGeneralFunction.TASKFINISH);
|
|
FrmControlMonitor.FormInstance.MonitorRefresh();//20110222
|
|
FrmControlMonitor.FormInstance.ManagerRefresh();//20110222
|
|
}
|
|
|
|
//private void button3_Click(object sender, EventArgs e)
|
|
//{
|
|
// if (this.dgvMonitor.CurrentRow == null)
|
|
// {
|
|
|
|
// return;
|
|
// }
|
|
// if (Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[0].Value) > 0)
|
|
// {
|
|
|
|
// if (this.dgvMonitor.CurrentRow.Cells[3].Value.ToString() == "1001")
|
|
// {
|
|
// if (MessageBox.Show("ÄúÈ·ÈÏÊÖ¹¤Ç¿ÖÆ·ÖÅäÑ¡ÖжÓÁеÄAGVÈÎÎñºÅÂð£¿", "²Ù×÷Ìáʾ£º", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|
// {
|
|
// return;
|
|
// }
|
|
// dbo.ExceSQL("UPDATE T_Monitor_Task SET F_AgvNo = " + this.nudAGVtask.Value + " WHERE (F_MonitorIndex =" + this.dgvMonitor.CurrentRow.Cells[2].Value + ")");
|
|
// DataView dv = dbo.ExceSQL("SELECT * FROM T_Monitor_Task (F_MonitorIndex =" + this.dgvMonitor.CurrentRow.Cells[2].Value + ") and (F_AGVNextTask IS NOT NULL)").Tables[0].DefaultView;
|
|
// if (dv.Count > 0)
|
|
// {
|
|
// dbo.ExceSQL("UPDATE T_Monitor_Task SET F_AgvNo = " + this.nudAGVtask.Value + " WHERE (F_MonitorIndex =" + dv[0]["F_AGVNextTask"] + ")");
|
|
|
|
// }
|
|
// dv = dbo.ExceSQL("SELECT * FROM T_Monitor_Task (F_AGVNextTask =" + this.dgvMonitor.CurrentRow.Cells[2].Value + ")").Tables[0].DefaultView;
|
|
// if (dv.Count > 0)
|
|
// {
|
|
// dbo.ExceSQL("UPDATE T_Monitor_Task SET F_AgvNo = " + this.nudAGVtask.Value + " WHERE (F_MonitorIndex =" + dv[0]["F_MonitorIndex"] + ")");
|
|
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// MessageBox.Show("Ö»ÓÐAGVÈÎÎñ²Å¿ÉÒÔÊÖ¹¤Ç¿ÖÆ·ÖÅäÑ¡ÖжÓÁеÄAGVÈÎÎñºÅ£¡", "Îó²Ù×÷Ìáʾ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
// return;
|
|
// }
|
|
|
|
// }
|
|
//}
|
|
|
|
int GetDeviceKindIdx(int devIdx)
|
|
{
|
|
try
|
|
{
|
|
devinfo = Model.CGetInfo.GetDeviceInfo(devIdx);
|
|
return devinfo.DeviceKind;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
int GetManageTaskIndexfromMonitor(int monitorIdx)
|
|
{
|
|
DataView dv = dbo.ExceSQL("SELECT F_ManageTaskIndex FROM T_Monitor_Task WHERE (F_MonitorIndex = " + monitorIdx + ")").Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dv[0]["F_ManageTaskIndex"]);
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
int GetManageTaskKindIndexFromMonitor(int monitorIdx)
|
|
{
|
|
DataView dv = dbo.ExceSQL("SELECT F_ManageTaskKindIndex FROM T_Monitor_Task WHERE (F_MonitorIndex = " + monitorIdx + ")").Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dv[0]["F_ManageTaskKindIndex"]);
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
int GetDeviceOrderFromMonitor(int MonitorIndex)
|
|
{
|
|
try
|
|
{
|
|
string sql = "select F_DeviceCommandIndex from T_Monitor_Task where (F_DeviceCommandIndex IS NOT NULL) and F_MonitorIndex=" + MonitorIndex;
|
|
DataView dv = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dv[0]["F_DeviceCommandIndex"]);
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
void AssociateComplete(int deviceIdx, int mindex, int status)
|
|
{
|
|
int ClearZero = 0;
|
|
if (status >= 1)
|
|
{
|
|
ClearZero = 1;
|
|
}
|
|
else
|
|
{
|
|
ClearZero = Model.CGeneralFunction.TASKFINISH;
|
|
}
|
|
int DeviceIdx = deviceIdx;
|
|
int devKind;
|
|
//20091107
|
|
DataView dv = dbo.ExceSQL("select F_MonitorIndex,F_Status,F_DeviceIndex,F_DeviceCommandIndex,F_NumParam4 from T_Monitor_Task where F_MonitorIndex=" + mindex).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
//¼ì²é¹ØÁªÃüÁîÒ»Æð±¨¸æÍê³É
|
|
//Èç¹ûmindexÊÇÖ÷¶¯ÈÎÎñ£¨f_associatemonitorÓÐÊý¾Ý£©£¬Ïȱ¨¸æÍê³É±»¶¯µÄÈÎÎñ£»Èç¹ûmindexÊDZ»¶¯ÈÎÎñ£¬Ïȱ¨¸æÍê³É×Ô¼º£¬ÔÙ±¨¸æÍê³ÉÖ÷¶¯ÈÎÎñ£»
|
|
DataView dv1 = dbo.ExceSQL("select F_DeviceIndex,F_Associate from T_Monitor_Task where F_Associate IS NOT NULL and F_MonitorIndex=" + mindex).Tables[0].DefaultView;
|
|
if (dv1.Count > 0)
|
|
{
|
|
DataView dv2 = dbo.ExceSQL("select F_DeviceIndex,F_MonitorIndex from T_Monitor_Task where F_MonitorIndex=" + Convert.ToInt32(dv1[0]["F_Associate"])).Tables[0].DefaultView;
|
|
if (dv2.Count > 0)//ÓйØÁªÃüÁÏȱ¨¸æÍê³É¹ØÁªÃüÁî
|
|
{
|
|
|
|
DeviceIdx = Convert.ToInt32(dv2[0]["F_DeviceIndex"]);
|
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
|
|
|
gs.ActionComplete(DeviceIdx, Convert.ToInt32(dv2[0]["F_MonitorIndex"]), ClearZero);
|
|
}
|
|
//ÔÙ±¨¸æÍê³É×Ô¼º
|
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
|
|
|
gs.ActionComplete(DeviceIdx, mindex, ClearZero);
|
|
}
|
|
else
|
|
{
|
|
//×Ô¼ºÊÇ·ñ±»¹ØÁª,Ïȱ¨¸æÍê³É×Ô¼º£¬ÔÙ±¨¸æÍê³ÉÖ÷ÈÎÎñ
|
|
DataView dv3 = dbo.ExceSQL("select F_DeviceIndex,F_MonitorIndex from T_Monitor_Task where F_Associate ='" + mindex + "'").Tables[0].DefaultView;
|
|
if (dv3.Count > 0)
|
|
{ //Ïȱ¨¸æÍê³É×Ô¼º
|
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
|
|
|
gs.ActionComplete(DeviceIdx, mindex, ClearZero);
|
|
//ÔÙ±¨¸æÍê³ÉÖ÷ÈÎÎñ
|
|
DeviceIdx = Convert.ToInt32(dv3[0]["F_DeviceIndex"]);
|
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
|
gs.ActionComplete(DeviceIdx, Convert.ToInt32(dv3[0]["F_MonitorIndex"]), ClearZero);
|
|
}
|
|
else
|
|
{
|
|
//ÎÞ¹ØÁªÈÎÎñ£¬Ö»±¨¸æÍê³É×Ô¼º
|
|
DeviceIdx = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
|
|
devKind = ccf.GetDeviceKindIdx(DeviceIdx);
|
|
//20101219ÔËÐÐ״̬µÄ³¤ÊäËÍ»úÁ´ÐèÒª¸ø×îºóÒ»¸ö±¨¸æÍê³ÉµÄÇåÁã
|
|
if ((devKind == 2) && (Convert.ToInt32(dv[0]["F_NumParam4"]) > 0) && (dv[0]["F_DeviceCommandIndex"].ToString() == "6") && (Convert.ToInt32( dv[0]["F_Status"]) > 0))
|
|
{
|
|
DeviceIdx = Convert.ToInt32(dv[0]["F_NumParam4"]);
|
|
}
|
|
gs.ActionComplete(DeviceIdx, mindex, ClearZero);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void dgvMonitor_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
|
|
{
|
|
foreach (DataGridViewRow DGVRow in this.dgvMonitor.Rows)
|
|
{
|
|
if (DGVRow != null)
|
|
{
|
|
if (Convert.ToInt32(DGVRow.Cells["f_status"].Value) >= 30)
|
|
{
|
|
DGVRow.DefaultCellStyle.BackColor = Color.Red;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
private void TSMmonitorDel_Click(object sender, EventArgs e)
|
|
{
|
|
char[] cc = new char[1] { '£º' };
|
|
string[] split = TSMonitor.Text.Split(cc);
|
|
if (split[1] == "") return;
|
|
|
|
|
|
DataView dv = dbo.ExceSQL("SELECT * FROM T_Monitor_Task Where F_MonitorIndex=" +
|
|
Convert.ToInt32(split[1])).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
//20100108ÖмäÖ¸Áî±»±¨¸æÍê³Éʱ¸øÓëÌáʾºÍ¾¯¸æ
|
|
|
|
DataView dv0 = dbo.ExceSQL("SELECT MIN(F_MonitorIndex) AS mmi FROM dbo.T_Monitor_Task WHERE (F_ManageTaskIndex = " + dv[0]["F_ManageTaskIndex"] + ") AND (F_ManageTASKKINDINDEX = " + dv[0]["F_ManageTASKKINDINDEX"] + ")").Tables[0].DefaultView;
|
|
if (dv0.Count > 0)
|
|
{
|
|
if ((dv0[0]["mmi"] != DBNull.Value) && (dv0[0]["mmi"].ToString() != split[1]))
|
|
{
|
|
if (MessageBox.Show("ÍÐÅÌÌõÂ룺" + dv[0]["F_TxtParam"].ToString() + "£¬É豸Ãû³Æ:¡°" + this.dgvMonitor.CurrentRow.Cells["É豸Ãû³Æ"].Value.ToString() + ";É豸ÃüÁî:" + this.dgvMonitor.CurrentRow.Cells["É豸ÃüÁîÃû³Æ"].Value.ToString() + "¡±Ö®Ç°»¹ÓÐûִÐÐÍê³ÉµÄµ÷¶ÈÈÎÎñ£¬Ìáǰ¡¾É¾³ýÉ豸ָÁî¡¿»áÔì³Éµ÷¶ÈÈÎÎñ»ìÂÒ£¬ÄúÈ·ÈÏÒª¼ÌÐø²Ù×÷Âð£¿", "²Ù×÷Ìáʾ£º", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
dv0 = null;
|
|
//20100108²Ù×÷ºÚÏ»×ÓÔö¼ÓÍÐÅÌÌõÂë
|
|
if (MessageBox.Show("ÄúÈ·ÈÏÍÐÅÌÌõÂ룺" + dv[0]["F_TxtParam"].ToString() + "£¬É豸Ãû³Æ:¡°" + this.dgvMonitor.CurrentRow.Cells["É豸Ãû³Æ"].Value.ToString() + ";É豸ÃüÁî:" + this.dgvMonitor.CurrentRow.Cells["É豸ÃüÁîÃû³Æ"].Value.ToString() + "¡±ÒѾ²»ÐèÒªÉ豸ִÐÐÁËÂð£¿", "²Ù×÷Ìáʾ£º", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
|
|
string sss = "É豸Ë÷Òý:" + dv[0]["F_DeviceIndex"].ToString() + ";É豸ָÁîË÷Òý:" + dv[0]["F_MonitorIndex"].ToString();
|
|
//20100108²Ù×÷ºÚÏ»×ÓÔö¼ÓÍÐÅÌÌõÂë
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("É豸ָÁî¹ÜÀí", "ÊÖ¹¤É¾³ýÉ豸ָÁî", "ÍÐÅÌÌõÂ룺" + dv[0]["F_TxtParam"].ToString(), sss);
|
|
gs.ActionComplete(Convert.ToInt32(dv[0]["F_DeviceIndex"]), Convert.ToInt32(dv[0]["F_MonitorIndex"]), Model.CGeneralFunction.TASKDELETE);//20100905
|
|
FrmControlMonitor.FormInstance.MonitorRefresh();//20110222
|
|
this.dgvMonitor.DataSource = dbo.ExceSQL("select * from V_Monitor_Task where " + _monstatus + " order by É豸ָÁîË÷Òý asc ").Tables[0].DefaultView;
|
|
}
|
|
}
|
|
|
|
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string df = "";
|
|
|
|
switch (this.comboBox1.Text)
|
|
{
|
|
case "ÍÐÅÌÌõÂë":
|
|
df = "¸½¼ÓÐÅÏ¢";
|
|
break;
|
|
case "µ÷¶ÈÈÎÎñË÷Òý":
|
|
df = "µ÷¶ÈÈÎÎñË÷Òý";
|
|
break;
|
|
case "É豸ָÁîË÷Òý":
|
|
df = "É豸ָÁîË÷Òý";
|
|
break;
|
|
|
|
|
|
default:
|
|
return;
|
|
}
|
|
//20100208
|
|
string sql = "select distinct " + df + " from V_Monitor_Task ";
|
|
DataView dv = dbo.ExceSQL(sql).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
this.textBox1.DataSource = null;
|
|
this.textBox1.DisplayMember = df;
|
|
this.textBox1.ValueMember = df;
|
|
this.textBox1.DataSource = dv;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
private void dgvMonitor_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
|
|
{
|
|
if ((e.RowIndex >= 0))//&&(e.Button == MouseButtons.Right)
|
|
{
|
|
dgvMonitor.ClearSelection();
|
|
dgvMonitor.Rows[e.RowIndex].Selected = true;
|
|
dgvMonitor.CurrentCell = dgvMonitor.Rows[e.RowIndex].Cells[0];
|
|
|
|
}
|
|
if (e.RowIndex >= 0)
|
|
{
|
|
if (this.dgvMonitor.CurrentRow.Cells[3].Value.ToString() == "1001")
|
|
{
|
|
this.groupBox1.Visible = true;
|
|
int fid =ccf.GetManageTaskIndexfromMonitor(Convert.ToInt32( this.dgvMonitor.CurrentRow.Cells[2].Value));
|
|
int mti =ccf.GetManageTaskKindIndexFromMonitor( Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[2].Value));
|
|
DataView dv = dbo.ExceSQL("SELECT FSTARTDEVICE FROM T_Manage_Task WHERE (F_ManageTaskKindIndex = "+
|
|
mti+") AND (FID = "+fid+") and ((FSTARTDEVICE = '3801') or (FENDDEVICE = '3801'))").Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
cobAGVno.Items.Clear();
|
|
cobAGVno.Items.Add(3);
|
|
cobAGVno.Items.Add(4);
|
|
cobAGVno.Text = "3";
|
|
}
|
|
dv = dbo.ExceSQL("SELECT FSTARTDEVICE FROM T_Manage_Task WHERE (F_ManageTaskKindIndex = " +
|
|
mti + ") AND (FID = " + fid + ") and ((FSTARTDEVICE = '2801') or (FENDDEVICE = '2801'))").Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
cobAGVno.Items.Clear();
|
|
cobAGVno.Items.Add(1);
|
|
cobAGVno.Items.Add(2);
|
|
cobAGVno.Text = "1";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.groupBox1.Visible = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void btAGVNO_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
if (dgvMonitor.CurrentCell == null) return;
|
|
int agvno=0;
|
|
if (int.TryParse(cobAGVno.Text, out agvno) == true)
|
|
{
|
|
int fid =ccf.GetManageTaskIndexfromMonitor( Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[2].Value));
|
|
int mti =ccf.GetManageTaskKindIndexFromMonitor( Convert.ToInt32(this.dgvMonitor.CurrentRow.Cells[2].Value));
|
|
if (MessageBox.Show("ÄúÈ·ÈÏÒªÐ޸ġ¾" + this.dgvMonitor.CurrentRow.Cells[1].Value.ToString() + ",µ÷¶ÈÈÎÎñË÷Òý£º" + fid.ToString() + "¡¿µÄAGV³µºÅÂð£¿", "²Ù×÷Ìáʾ£º", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
object ob = dbo.GetSingle("SELECT FID FROM T_Manage_Task WHERE (F_ManageTaskKindIndex = "+mti+") AND (F_RELATIVECONTORLID = "+fid+")");
|
|
int rfid = 0;
|
|
if (ob == null) rfid = 0;
|
|
else
|
|
{
|
|
int.TryParse(ob.ToString(), out rfid);
|
|
}
|
|
dbo.ExecuteSql("update T_Monitor_Task set F_AgvNo=" + agvno + " where (F_DeviceIndex=1001) and (F_ManageTASKKINDINDEX=" + mti + ") and (F_ManageTaskIndex=" + fid + " or F_ManageTaskIndex=" + rfid + ") ");
|
|
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("AGV³µºÅÖ»ÄÜÊÇÊý×Ö£¡", "Îó²Ù×÷Ìáʾ£º", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|