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.
263 lines
9.1 KiB
263 lines
9.1 KiB
3 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel;
|
||
|
using System.Data;
|
||
|
using System.Drawing;
|
||
|
using System.Text;
|
||
|
using System.Windows.Forms;
|
||
|
using ICommLayer;
|
||
|
using CommLayerFactory;
|
||
|
namespace ControlSystem
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// Creator:Richard.liu and Jack.Ma
|
||
|
/// �豸ʵʱ״̬��ʾ
|
||
|
/// </summary>
|
||
|
public partial class FrmDeviceStatus : Form
|
||
|
{
|
||
|
#region ��������
|
||
|
Model.MDevice _device = null;
|
||
|
int _deviceIndex;
|
||
|
ISendDeviceOrder sdo;
|
||
|
|
||
|
CCommonFunction ccf = new CCommonFunction();
|
||
|
DBFactory.DBOperator dbo = CStaticClass.dbo;
|
||
|
/// <summary>
|
||
|
/// ����Ҫ��ʾ���豸����
|
||
|
/// </summary>
|
||
|
public int DeviceIndex
|
||
|
{
|
||
|
set { _deviceIndex = value;}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region ���캯��/��ʼ��
|
||
|
public FrmDeviceStatus()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
}
|
||
|
|
||
|
private void FrmDeviceStatus_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
btnRefresh_Click(null, EventArgs.Empty);
|
||
|
if (_device.DeviceIndex == 22036 || _device.DeviceIndex == 22037)
|
||
|
{
|
||
|
this.btDown.Visible = false;
|
||
|
this.btUP.Visible = true;
|
||
|
}
|
||
|
else if ("12001,12003,12005,12007,12051,12053,12055,12057".IndexOf(_device.DeviceIndex.ToString()) >= 0)
|
||
|
{
|
||
|
this.btDown.Visible = true;
|
||
|
this.btUP.Visible = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
this.btDown.Visible = false;
|
||
|
this.btUP.Visible = false;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region �����豸״̬
|
||
|
private void btnRefresh_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
//timer1.Enabled = true;
|
||
|
_device = Model.CGetInfo.GetDeviceInfo(_deviceIndex);
|
||
|
//20100108
|
||
|
if (_device == null)
|
||
|
{
|
||
|
MessageBox.Show("��ѡ�����豸�����ݿ�û�м�¼��", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
|
return;
|
||
|
|
||
|
}
|
||
|
//�豸����
|
||
|
this.lblDeviceIndex.Text = _device.DeviceIndex.ToString();
|
||
|
//�豸����
|
||
|
this.lblDeviceName.Text = _device.DeviceName;
|
||
|
//�豸ָ������
|
||
|
this.lblTaskIndex.Text = _device.TaskNo.ToString();
|
||
|
//Ŀ��λ��
|
||
|
this.lblArrowLocation.Text = _device.ArrowLocation;
|
||
|
//�豸״̬
|
||
|
switch (_device.RunState)
|
||
|
{
|
||
|
case 0:
|
||
|
lblDeviceStatus.Text = "����";
|
||
|
break;
|
||
|
case 1:
|
||
|
lblDeviceStatus.Text = "����";
|
||
|
break;
|
||
|
case 2:
|
||
|
lblDeviceStatus.Text = "����";
|
||
|
break;
|
||
|
case 3:
|
||
|
lblDeviceStatus.Text = "����";
|
||
|
break;
|
||
|
case 4:
|
||
|
lblDeviceStatus.Text = "ͣ��";
|
||
|
break;
|
||
|
case 5://20090920
|
||
|
lblDeviceStatus.Text = "��������";
|
||
|
break;
|
||
|
}
|
||
|
//�л�/��
|
||
|
this.lblHaveGoods.Text = _device.HaveGoods == true ? "�л�" : "��";
|
||
|
//����������
|
||
|
this.lblBarcode.Text = _device.Barcode;
|
||
|
if (_device.ErrorCode >= 30)
|
||
|
{
|
||
|
Model.MError err = Model.CGetInfo.GetErrorInfo(Convert.ToInt32(_device.DeviceKind.ToString() + _device.ErrorCode.ToString()));
|
||
|
this.lblErrorName.Text = err.ErrorName;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
this.lblErrorName.Text = "";
|
||
|
}
|
||
|
if ((_device.DeviceKind == 1) || (_device.DeviceKind == 4))
|
||
|
{
|
||
|
this.lblNowX.Text = _device.XCoor.ToString();
|
||
|
this.lblNowY.Text = _device.YCoor.ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
this.lblNowX.Text ="";
|
||
|
this.lblNowY.Text = "";
|
||
|
}
|
||
|
//�Ƿ�������
|
||
|
DataView dv = dbo.ExceSQL("select F_DeviceIndex from T_Base_Device where F_HaveGoods = 1 and F_DeviceIndex =" + this._deviceIndex).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
lblGoods.Text = "������";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
lblGoods.Text = "������";
|
||
|
}
|
||
|
if ((_device.ErrorCode == 96) && ((_device.DeviceIndex == 1341) || (_device.DeviceIndex == 1342) || (_device.DeviceIndex == 1101)))
|
||
|
{
|
||
|
btQuitPallet.Visible = true;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
btQuitPallet.Visible = false;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region �رմ���
|
||
|
private void btnClose_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
this.Close();
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
private void timer1_Tick(object sender, EventArgs e)
|
||
|
{
|
||
|
btnRefresh_Click(sender, e);
|
||
|
}
|
||
|
|
||
|
private void button2_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
if (MessageBox.Show("��ȷ��Ҫ���豸��" + this._deviceIndex + "��������������", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
dbo.ExceSQL("UPDATE T_Base_Device SET F_HaveGoods = 0 where F_DeviceIndex =" + this._deviceIndex);
|
||
|
btnRefresh_Click(sender, e);
|
||
|
}
|
||
|
|
||
|
private void button1_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
if (MessageBox.Show("��ȷ��Ҫ���豸��" + this._deviceIndex + "��������������", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
dbo.ExceSQL("UPDATE T_Base_Device SET F_HaveGoods = 1 where F_DeviceIndex =" + this._deviceIndex);
|
||
|
btnRefresh_Click(sender, e);
|
||
|
}
|
||
|
|
||
|
private void button3_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
if (MessageBox.Show("��ȷ��Ҫ���豸��" + this._deviceIndex + "�Ľ���ָ������������", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
int deviceKind = ccf.GetDeviceKindIdx(this._deviceIndex);
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(this._deviceIndex);
|
||
|
if ((deviceKind == 1) || (deviceKind == 6))
|
||
|
{
|
||
|
sdo.SendDeviceOrder(2, 0, 0, this._deviceIndex, 0, 0, 0, 0, 0, 0);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
sdo.SendDeviceOrder(2, 0, 0, this._deviceIndex, 0);
|
||
|
_device.SendMessage = null;
|
||
|
Model.CGetInfo.SetDeviceInfo(_device);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void btQuitPallet_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
if (_device.ErrorCode != 96) return;
|
||
|
//���ɳ�������
|
||
|
DataView dvbc = dbo.ExceSQL("SELECT FID FROM T_Manage_Task WHERE (FSTARTDEVICE=" + _device.DeviceIndex + ") and (FPALLETBARCODE = '0000000000')").Tables[0].DefaultView;
|
||
|
if (dvbc.Count > 0)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
int fid = ccf.GetTempManageIdx();
|
||
|
string warehouse = "11"; string useAwayfork = "-";
|
||
|
DataView dvw = dbo.ExceSQL("SELECT F_WarehouseIndex FROM T_Warehouse").Tables[0].DefaultView;
|
||
|
if (dvw.Count > 0)
|
||
|
{
|
||
|
warehouse = dvw[0]["F_WarehouseIndex"].ToString();
|
||
|
}
|
||
|
string enddev = "";
|
||
|
if (_device.DeviceIndex == 1341)
|
||
|
{
|
||
|
enddev = "1442";
|
||
|
useAwayfork = "0";
|
||
|
}
|
||
|
else if ((_device.DeviceIndex == 1342) || (_device.DeviceIndex == 1101))
|
||
|
{
|
||
|
enddev = "1441";
|
||
|
useAwayfork = "1";
|
||
|
}
|
||
|
string sql = "INSERT INTO T_Manage_Task" +
|
||
|
"(FID, F_ManageTaskKindIndex,FPALLETBARCODE,FMANAGETASKTYPE,FCONTROLTASKTYPE, FTASKLEVEL, FISRETURN," +
|
||
|
"FSTARTWAREHOUSE, FSTARTCELL, FSTARTDEVICE, FENDDEVICE, FENDCELL, " +
|
||
|
"FSTATUS, FBEGTIME, FENDTIME,FIntoStepOK,FREMARK,FLANEWAY,FSTACK,FENDWAREHOUSE,FUseAwayFork)" +
|
||
|
"VALUES (" + fid + ",2,'0000000000','0','3','1','1','" + warehouse + "','-','"
|
||
|
+ _device.DeviceIndex + "','" + enddev + "','-','0','-','-','0','',0,0,'" + warehouse + "','" + useAwayfork + "')";
|
||
|
dbo.ExceSQL(sql);
|
||
|
|
||
|
|
||
|
|
||
|
Model.MDevice mdev;
|
||
|
mdev = Model.CGetInfo.GetDeviceInfo(_device.DeviceIndex);
|
||
|
mdev.ErrorCode = 0;
|
||
|
mdev.RunState = 0;
|
||
|
Model.CGetInfo.SetDeviceInfo(mdev);
|
||
|
|
||
|
}
|
||
|
|
||
|
private void btUP_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(this._deviceIndex);
|
||
|
sdo.SendDeviceOrder(1, 0, 9, this._deviceIndex, 0);
|
||
|
|
||
|
}
|
||
|
|
||
|
private void btDown_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
sdo = CommModeCreate.CreateSendDeviceOrder(this._deviceIndex);
|
||
|
sdo.SendDeviceOrder(1, 0, 8, this._deviceIndex, 0);
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|