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.
477 lines
20 KiB
477 lines
20 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 Microsoft.VisualBasic;
|
|
using System.ServiceModel;
|
|
namespace wcfControlMonitorClient
|
|
{
|
|
/// <summary>
|
|
/// Creator:Richard.liu
|
|
/// 模仿管理下达自动任务
|
|
/// </summary>
|
|
public partial class FrmAutoCommand : Form
|
|
{
|
|
|
|
DBOperator dbo = CStaticClass.dbo;
|
|
|
|
int AutoManageIdx = 0;
|
|
#region ====变量定义
|
|
|
|
CommonClassLib.UCellPanel cellPanel = null;
|
|
|
|
#endregion
|
|
private static FrmAutoCommand _formInstance;
|
|
|
|
public static FrmAutoCommand FormInstance
|
|
{
|
|
get
|
|
{
|
|
if (_formInstance == null)
|
|
{
|
|
_formInstance = new FrmAutoCommand();
|
|
}
|
|
return _formInstance;
|
|
}
|
|
set { _formInstance = value; }
|
|
}
|
|
public FrmAutoCommand()
|
|
{
|
|
dbo.Open();
|
|
InitializeComponent();
|
|
_formInstance = this;
|
|
////特殊命令:堆垛机取坐标001,送坐标002;条码比对003;称重回传004;
|
|
////搬运木块码盘005(一个主搬运木块任务,拆分成多个单一搬运任务)
|
|
//this.cbKind.Items.Add("");
|
|
//this.cbKind.Items.Add("条码比对");
|
|
//this.cbKind.Items.Add("称重回传");
|
|
////this.cbKind.Items.Add("机器人码盘");
|
|
//this.cbKind.Text="条码比对";
|
|
////cbtasktype
|
|
DataSet ds = dbo.ExceSQL("select * from T_ITEMTASKTYPE where FCODE !='-'");
|
|
if (ds.Tables[0].DefaultView.Count > 0)
|
|
{
|
|
cbtasktype.ValueMember = "FCODE";
|
|
cbtasktype.DisplayMember = "FNAME";
|
|
cbtasktype.DataSource = ds.Tables[0].DefaultView;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
if (MessageBox.Show("您确认要增加自动任务吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) !=DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
if (tbFPALLETBARCODE.Text.Trim().Length < 1)
|
|
{
|
|
MessageBox.Show("请输入条码!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
return;
|
|
}
|
|
if (panelType.Visible)
|
|
{
|
|
if (this.comboBoxType.Text.Trim() == "")
|
|
{
|
|
MessageBox.Show("请选择托盘类型!", "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
this.comboBoxType.Focus();
|
|
return;
|
|
}
|
|
}
|
|
if ((this.cbtasktype.Text.Trim().Length == 0) || (this.cbstartposition.Text.Trim().Length == 0) || (this.cbendposition.Text.Trim().Length == 0))
|
|
{
|
|
MessageBox.Show("搬运任务类型、起点位置、终点位置都不允许保持空值!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if ((tbstartsite.Enabled == true) && (tbstartsite.Text.Trim().Length == 0))
|
|
{
|
|
MessageBox.Show("起点位置是巷道,所以必须指定货架位置!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if ((tbendsite.Enabled == true) && (tbendsite.Text.Trim().Length == 0))
|
|
{
|
|
MessageBox.Show("终点位置是巷道,所以必须指定货架位置!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if ((cbKind.Text.Trim().Length > 0) &&(txtparm.Text.Trim().Length==0))
|
|
{
|
|
MessageBox.Show("特殊命令如果不是空值,必须指定特殊参数!", "误操作提示", MessageBoxButtons.OK,MessageBoxIcon.Warning );
|
|
return;
|
|
}
|
|
if ((cbInWorkBench.Text.Trim().Length > 0) && (cbInWorkBench.Text.Trim().Length == 0))
|
|
{
|
|
MessageBox.Show("是否进工位必须选定!", "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
int tasktype= Convert.ToInt32(this.cbtasktype.SelectedValue);
|
|
int count = 0;////借用this.cbInWorkBench.Text传递count
|
|
int pallettype = 0;
|
|
if (tasktype == 5 || tasktype == 6||(tasktype == 4 && cbstartposition.SelectedValue.ToString() == "12008"))
|
|
{
|
|
if (int.TryParse(this.textBoxCount.Text.Trim(), out count) == false)
|
|
|
|
{
|
|
string message = string.Format("请输入正确的{0}信息!", labelCount.Text);
|
|
MessageBox.Show(message, "误操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (tasktype == 1)//入库时获取是否双叉入库
|
|
{
|
|
count = CheckBoxfork2.Checked ? 2 : 1;
|
|
|
|
}
|
|
if (panelType.Visible)
|
|
{
|
|
if (comboBoxType.SelectedIndex > -1)
|
|
{
|
|
pallettype = comboBoxType.SelectedIndex + 1;//用来保存单叉堆垛机的托盘类型(1小托盘,2大托盘)
|
|
}
|
|
}
|
|
//调用服务
|
|
string errtext=string.Empty;
|
|
string startcell=string.Empty,endcell=string.Empty;
|
|
if (tbstartsite.SelectedValue != null)
|
|
{
|
|
startcell = tbstartsite.SelectedValue.ToString();
|
|
}
|
|
else
|
|
{
|
|
startcell = tbstartsite.Text;
|
|
}
|
|
if (tbendsite.SelectedValue != null)
|
|
{
|
|
endcell = tbendsite.SelectedValue.ToString();
|
|
}
|
|
else
|
|
{
|
|
endcell = tbendsite.Text;
|
|
}
|
|
Model.AutoTask at = new Model.AutoTask(Convert.ToInt32(this.cbtasktype.SelectedValue), tbFPALLETBARCODE.Text, cbstartposition.SelectedValue.ToString(), startcell, cbendposition.SelectedValue.ToString(), endcell, this.tbstartsite.Enabled, this.tbendsite.Enabled, pallettype);//借用this.cbInWorkBench.Text传递pallettype
|
|
CStaticClass.WcfControl.BeginBuildAutoTask(at, new AsyncCallback(BuildAutoTaskCallBack), at);
|
|
//{
|
|
// MessageBox.Show(errtext, "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
// return;
|
|
//}
|
|
|
|
}
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
string Sql, _kind, _txtparm;
|
|
DataSet ds;
|
|
//dbo.TransBegin();
|
|
try
|
|
{
|
|
|
|
//插入IO_CONTROLDETAIL
|
|
//特殊命令:堆垛机取坐标001,送坐标002;条码比对003;称重回传004;
|
|
switch (this.cbKind.Text.Trim())
|
|
{
|
|
case "条码比对":
|
|
_kind = "003";
|
|
break;
|
|
case "称重回传":
|
|
_kind = "004";
|
|
break;
|
|
//case "机器人码盘":
|
|
// _kind = "005";
|
|
// break;
|
|
default:
|
|
_kind = "003";
|
|
break;
|
|
}
|
|
_txtparm = this.txtparm.Text.Trim();
|
|
if (_kind == "005")
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
int fid=GetIOControlDetailFid(1, AutoManageIdx);
|
|
Sql = "insert into IO_CONTROLDETAIL(FID,FCONTROLID,F_ManageTaskKindIndex,FKIND,FINDEX,FVALUE) " +
|
|
"values("+fid+"," + AutoManageIdx + ",1,'" + _kind + "',0,'" + _txtparm + "')";
|
|
ds = dbo.ExceSQL(Sql);
|
|
}
|
|
//dbo.TransCommit();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//dbo.TransRollback();
|
|
throw ex;
|
|
}
|
|
}
|
|
private void FrmAutoCommand_Load(object sender, EventArgs e)
|
|
{
|
|
cbInWorkBench.SelectedIndex = 2;
|
|
|
|
if (cellPanel == null)
|
|
{
|
|
cellPanel = new CommonClassLib.UCellPanel(this, tbstartsite, null,tbFPALLETBARCODE, string.Empty);
|
|
cellPanel.TaskType = "100";
|
|
cellPanel.GoodsName = "";
|
|
cellPanel.Dock = DockStyle.Fill;
|
|
cellPanel.AllowWareHouseChanged = false;
|
|
plCell.Controls.Add(cellPanel);
|
|
|
|
}
|
|
cellPanel.Visible = true;
|
|
}
|
|
|
|
private void cbtasktype_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.tbFPALLETBARCODE.Enabled = true;
|
|
this.tbFPALLETBARCODE.Text = "";
|
|
string StrSql = string.Format(" and F_WorkArea like '%{0}%'", CStaticClass.UserArea);
|
|
int IOtype =Convert.ToInt32(this.cbtasktype.SelectedValue.ToString());
|
|
DataView dvs = dbo.ExceSQL("SELECT DISTINCT F_StartDevice,F_DeviceName FROM T_Base_Route,T_Base_Device where F_StartDevice = F_DeviceIndex and T_Base_Route.F_RouteKind = " + IOtype+StrSql).Tables[0].DefaultView ;
|
|
//cbstartposition
|
|
cbstartposition.ValueMember = "F_StartDevice";
|
|
cbstartposition.DisplayMember = "F_DeviceName";
|
|
cbstartposition.DataSource = dvs;
|
|
|
|
DataView dvs1 = dbo.ExceSQL("SELECT DISTINCT F_EndDevice,F_DeviceName FROM T_Base_Route,T_Base_Device where F_EndDevice = F_DeviceIndex and T_Base_Route.F_RouteKind = " + IOtype + StrSql).Tables[0].DefaultView;
|
|
//cbendposition
|
|
cbendposition.ValueMember = "F_EndDevice";
|
|
cbendposition.DisplayMember = "F_DeviceName";
|
|
cbendposition.DataSource = dvs1;
|
|
|
|
labelCount.Visible = false;
|
|
textBoxCount.Visible = false;
|
|
labelCount.Text="数量";
|
|
labelBarcode.Text = "条码";
|
|
int type=Convert.ToInt32(this.cbtasktype.SelectedValue);
|
|
|
|
if (type == 5||type == 6||Convert.ToInt32(this.cbstartposition.SelectedValue)==12008)//离开绿色通道的任务
|
|
{
|
|
//labelCount.Visible = true;
|
|
//textBoxCount.Visible = true;//输入计划数量、绿色通道出库数量、申请出库的通知结果
|
|
}
|
|
|
|
|
|
if (type == 5)//出库计划
|
|
{
|
|
labelBarcode.Text="物料条码";
|
|
}
|
|
if (type == 6)//通知出库结果
|
|
{
|
|
labelCount.Text="结果";
|
|
}
|
|
//CheckBoxfork2.Visible = false;
|
|
//if (Convert.ToInt32(this.cbtasktype.SelectedValue) == 1)//生成双叉自动入库任务
|
|
//{
|
|
// CheckBoxfork2.Visible = true;
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
private void cbstartposition_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
tbstartsite.DataSource = null;
|
|
tbstartsite.Text = "";
|
|
//如果是巷道设备tbstartsite.enable=true
|
|
DataSet ds = dbo.ExceSQL("select FLaneWay from ST_CELL where FLaneWay=" + Convert.ToInt32(cbstartposition.SelectedValue) + "");
|
|
//DataSet ds = dbo.ExceSQL("select F_DeviceIndex,F_DeviceKindIndex from T_Base_Device where F_DeviceKindIndex=10 and F_DeviceIndex=" + Convert.ToInt32(cbstartposition.SelectedValue) + "");
|
|
|
|
if (ds.Tables[0].DefaultView.Count > 0)
|
|
{
|
|
|
|
tbstartsite.Enabled = true;
|
|
|
|
plCell.Enabled = true;
|
|
|
|
if (cellPanel == null)
|
|
{
|
|
cellPanel = new CommonClassLib.UCellPanel(this, tbstartsite, null,null, string.Empty);
|
|
cellPanel.TaskType = "100";
|
|
cellPanel.GoodsName = "";
|
|
cellPanel.Dock = DockStyle.Fill;
|
|
cellPanel.AllowWareHouseChanged = false ;
|
|
plCell.Controls.Add(cellPanel);
|
|
|
|
}
|
|
cellPanel.ControlCellCode = tbstartsite;
|
|
cellPanel.Laneway = this.cbstartposition.SelectedValue.ToString();
|
|
cellPanel.WareHouse = GetWarehouse(Convert.ToInt32(this.cbstartposition.SelectedValue));
|
|
cellPanel.Visible = plCell.Visible;
|
|
}
|
|
else
|
|
{
|
|
tbstartsite.Enabled = true;
|
|
DataView dv1 = dbo.ExceSQL("SELECT T_Base_Device.F_DeviceName, T_Base_Device.F_DeviceIndex FROM T_Base_Lane_Gate,T_Base_Device WHERE T_Base_Lane_Gate.F_LaneGateDeviceIndex = T_Base_Device.F_DeviceIndex and F_DeviceKindIndex=9 and F_LaneIndex=" + cbstartposition.SelectedValue + "").Tables[0].DefaultView;
|
|
if(dv1.Count>0)
|
|
{
|
|
tbstartsite.DisplayMember = "F_DeviceName";
|
|
tbstartsite.ValueMember = "F_DeviceIndex";
|
|
tbstartsite.DataSource = dv1;
|
|
}
|
|
else
|
|
{
|
|
|
|
plCell.Enabled = false;
|
|
tbstartsite.Enabled = false;
|
|
}
|
|
}
|
|
DataView dv = dbo.ExceSQL("select F_DeviceIndex,F_DeviceKindIndex from T_Base_Device where F_DeviceKindIndex=11 and F_DeviceIndex=" + Convert.ToInt32(cbstartposition.SelectedValue) + "").Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
tbstartsite.Enabled = true;
|
|
dv = dbo.ExceSQL("SELECT T_Base_Device.F_DeviceName, T_Base_Device.F_DeviceIndex FROM T_Base_AGV_Gate,T_Base_Device WHERE T_Base_AGV_Gate.F_AGVGateDeviceIndex = T_Base_Device.F_DeviceIndex and F_ChannelsIndex=" + cbstartposition.SelectedValue + "").Tables[0].DefaultView;
|
|
tbstartsite.DisplayMember = "F_DeviceName";
|
|
tbstartsite.ValueMember = "F_DeviceIndex";
|
|
tbstartsite.DataSource = dv;
|
|
}
|
|
|
|
|
|
labelCount.Visible = false;
|
|
textBoxCount.Visible = false;
|
|
|
|
//int type = Convert.ToInt32(this.cbtasktype.SelectedValue);
|
|
|
|
int startdevice = Convert.ToInt32(this.cbstartposition.SelectedValue);
|
|
int enddevice = Convert.ToInt32(this.cbendposition.SelectedValue);
|
|
//if ((startdevice >= 18001 && startdevice <= 18004) || (enddevice >= 18001 && enddevice <= 18004))
|
|
//{
|
|
// panelType.Visible = true;
|
|
//}
|
|
//else
|
|
//{
|
|
// panelType.Visible = false;
|
|
//}
|
|
comboBoxType.SelectedIndex = -1;
|
|
comboBoxType.Text = "";
|
|
#region 根据起点更新终点列表
|
|
//string StrSql = string.Format(" and F_WorkArea like '%{0}%'", CStaticClass.UserArea);
|
|
//int IOtype = Convert.ToInt32(this.cbtasktype.SelectedValue.ToString());
|
|
//dv = dbo.ExceSQL("SELECT DISTINCT F_EndDevice,F_DeviceName FROM T_Base_Route,T_Base_Device where F_EndDevice = F_DeviceIndex and T_Base_Route.F_RouteKind = " + IOtype + StrSql + "and F_StartDevice = " + Convert.ToInt32(cbstartposition.SelectedValue) + "").Tables[0].DefaultView;
|
|
|
|
//if (dv.Count > 0)
|
|
//{
|
|
// cbendposition.DisplayMember = "F_DeviceName";
|
|
// cbendposition.ValueMember = "F_DeviceIndex";
|
|
// cbendposition.DataSource = dv;
|
|
//}
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
private void cbendposition_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
tbendsite.DataSource = null;
|
|
tbendsite.Text = "";
|
|
//如果是巷道设备tbstartsite.enable=true
|
|
DataSet ds = dbo.ExceSQL("select FLaneWay from ST_CELL where FLaneWay=" + Convert.ToInt32(cbendposition.SelectedValue) + "");
|
|
|
|
//DataSet ds = dbo.ExceSQL("select F_DeviceIndex,F_DeviceKindIndex from T_Base_Device where F_DeviceKindIndex=10 and F_DeviceIndex= " +Convert.ToInt32( cbendposition.SelectedValue) + "");
|
|
if (ds.Tables[0].DefaultView.Count > 0)
|
|
{
|
|
tbendsite.Enabled = true;
|
|
|
|
plCell.Enabled = true;
|
|
|
|
if (cellPanel == null)
|
|
{
|
|
cellPanel = new CommonClassLib.UCellPanel(this, tbendsite, null, null,string.Empty);
|
|
cellPanel.TaskType = "100";
|
|
cellPanel.GoodsName = "";
|
|
cellPanel.Dock = DockStyle.Fill;
|
|
cellPanel.AllowWareHouseChanged = false;
|
|
plCell.Controls.Add(cellPanel);
|
|
|
|
}
|
|
cellPanel.ControlCellCode = tbendsite;
|
|
cellPanel.Laneway = this.cbendposition.SelectedValue.ToString();
|
|
cellPanel.WareHouse = GetWarehouse(Convert.ToInt32(this.cbendposition.SelectedValue));
|
|
cellPanel.Visible = plCell.Visible;
|
|
}
|
|
else
|
|
{
|
|
tbendsite.Enabled = true;
|
|
DataView dv1 = dbo.ExceSQL("SELECT T_Base_Device.F_DeviceName, T_Base_Device.F_DeviceIndex FROM T_Base_Lane_Gate,T_Base_Device WHERE T_Base_Lane_Gate.F_LaneGateDeviceIndex = T_Base_Device.F_DeviceIndex and F_DeviceKindIndex=9 and F_LaneIndex=" + cbendposition.SelectedValue + "").Tables[0].DefaultView;
|
|
if (dv1.Count > 0)
|
|
{
|
|
tbendsite.DisplayMember = "F_DeviceName";
|
|
tbendsite.ValueMember = "F_DeviceIndex";
|
|
tbendsite.DataSource = dv1;
|
|
}
|
|
else
|
|
{
|
|
|
|
plCell.Enabled = false;
|
|
tbendsite.Enabled = false;
|
|
}
|
|
}
|
|
DataView dv = dbo.ExceSQL("select F_DeviceIndex,F_DeviceKindIndex from T_Base_Device where F_DeviceKindIndex=11 and F_DeviceIndex=" + Convert.ToInt32(cbendposition.SelectedValue) + "").Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
tbendsite.Enabled = true;
|
|
dv = dbo.ExceSQL("SELECT T_Base_Device.F_DeviceName, T_Base_Device.F_DeviceIndex FROM T_Base_AGV_Gate,T_Base_Device WHERE T_Base_AGV_Gate.F_AGVGateDeviceIndex = T_Base_Device.F_DeviceIndex and F_ChannelsIndex=" + cbendposition.SelectedValue + "").Tables[0].DefaultView;
|
|
tbendsite.DisplayMember = "F_DeviceName";
|
|
tbendsite.ValueMember = "F_DeviceIndex";
|
|
tbendsite.DataSource = dv;
|
|
}
|
|
|
|
int startdevice = Convert.ToInt32(this.cbstartposition.SelectedValue);
|
|
int enddevice = Convert.ToInt32(this.cbendposition.SelectedValue);
|
|
//if ((startdevice >= 18001 && startdevice <= 18004) || (enddevice >= 18001 && enddevice <= 18004))
|
|
//{
|
|
// panelType.Visible = true;
|
|
//}
|
|
//else
|
|
//{
|
|
// panelType.Visible = false;
|
|
//}
|
|
|
|
}
|
|
|
|
int GetIOControlDetailFid(int ManageTaskKindIndex,int FCONTROLID)
|
|
{
|
|
|
|
DataSet ds = dbo.ExceSQL("SELECT MAX(FID) AS MaxFID FROM IO_CONTROLDETAIL GROUP BY F_ManageTaskKindIndex, FCONTROLID HAVING (F_ManageTaskKindIndex = " + ManageTaskKindIndex + ") AND (FCONTROLID = " + FCONTROLID + ")");
|
|
if (ds.Tables[0].DefaultView.Count > 0)
|
|
{
|
|
return (Convert.ToInt32(ds.Tables[0].DefaultView[0]["MaxFID"]) + 1);
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
}
|
|
|
|
void BuildAutoTaskCallBack(IAsyncResult ar)
|
|
{
|
|
string errtext=string.Empty;
|
|
if (CStaticClass.WcfControl.EndBuildAutoTask(out errtext, ar) == false)
|
|
{
|
|
MessageBox.Show(errtext, "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
|
|
}
|
|
|
|
private void FrmAutoCommand_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
_formInstance = null;
|
|
}
|
|
string GetWarehouse(int laneway)
|
|
{
|
|
DataView dv = dbo.ExceSQL(string.Format("SELECT DISTINCT FWAREHOUSE FROM ST_CELL WHERE (FLaneWay = {0})",laneway)).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return dv[0][0].ToString();
|
|
}
|
|
else
|
|
{
|
|
return "01";
|
|
}
|
|
}
|
|
}
|
|
}
|