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.
381 lines
12 KiB
381 lines
12 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 System.ServiceModel;
|
||
|
using OPCClient;
|
||
|
using Opc.Ua;
|
||
|
using System.Net;
|
||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||
|
using System.Reflection.Emit;
|
||
|
using System.Linq;
|
||
|
using System.Security.Cryptography;
|
||
|
namespace wcfControlMonitorClient
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// Creator:Richard.liu and Jack.Ma
|
||
|
/// �豸ʵʱ״̬��ʾ
|
||
|
/// </summary>
|
||
|
public partial class FrmDeviceMS : Form
|
||
|
{
|
||
|
#region ��������
|
||
|
Model.MDevice _device = null;
|
||
|
int _deviceIndex;
|
||
|
DBFactory.DBOperator dboMan = CStaticClass.dboM;
|
||
|
DBFactory.DBOperator dbo = CStaticClass.dbo;
|
||
|
StringBuilder sql = new StringBuilder();
|
||
|
int count = 0;
|
||
|
/// <summary>
|
||
|
/// ����Ҫ��ʾ���豸����
|
||
|
/// </summary>
|
||
|
public int DeviceIndex
|
||
|
{
|
||
|
set { _deviceIndex = value; }
|
||
|
}
|
||
|
private static FrmDeviceMS _formInstance;
|
||
|
|
||
|
public static FrmDeviceMS FormInstance
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (_formInstance == null)
|
||
|
{
|
||
|
_formInstance = new FrmDeviceMS();
|
||
|
}
|
||
|
return _formInstance;
|
||
|
}
|
||
|
set { _formInstance = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region ���캯��/��ʼ��
|
||
|
public FrmDeviceMS()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
_formInstance = this;
|
||
|
}
|
||
|
|
||
|
private void FrmDeviceStatus_Load(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
|
||
|
|
||
|
btnRefresh_Click(null, EventArgs.Empty);
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region �����豸״̬
|
||
|
private void btnRefresh_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
_device = Model.CGetInfo.GetDeviceInfo(_deviceIndex);
|
||
|
//20100108
|
||
|
|
||
|
if (_device == null)
|
||
|
{
|
||
|
MessageBox.Show("��ѡ�����豸�����ݿ�û�м�¼��", "������ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
|
return;
|
||
|
|
||
|
}
|
||
|
|
||
|
//�豸����
|
||
|
this.F_DeviceIndex.Text = _device.DeviceIndex.ToString();
|
||
|
sql = new StringBuilder();
|
||
|
sql.Append("SELECT * from T_Base_Device where F_DeviceIndex=").Append(_deviceIndex);
|
||
|
DataView dvlane = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
if (dvlane.Count > 0)
|
||
|
{
|
||
|
switch (Convert.ToInt32(dvlane[0]["F_STATE"].ToString()))
|
||
|
{
|
||
|
case 0:
|
||
|
this.F_STATE.Text = "����";
|
||
|
break;
|
||
|
case 1:
|
||
|
this.F_STATE.Text = "����";
|
||
|
break;
|
||
|
case 2:
|
||
|
this.F_STATE.Text = "����";
|
||
|
break;
|
||
|
case 5:
|
||
|
this.F_STATE.Text = "��������";
|
||
|
break;
|
||
|
default:
|
||
|
this.F_STATE.Text = "δ֪״̬";
|
||
|
break;
|
||
|
}
|
||
|
//�豸״̬
|
||
|
|
||
|
//�豸������
|
||
|
this.F_LockedState.Text = dvlane[0]["F_LockedState"].ToString();
|
||
|
}
|
||
|
int dev1;
|
||
|
int dev2;
|
||
|
switch (_deviceIndex)
|
||
|
{
|
||
|
case 13001:
|
||
|
dev1 = 12011;
|
||
|
dev2 = 12014;
|
||
|
this.F_DeviceIndex3.Text = "12014";
|
||
|
this.F_DeviceIndex2.Text = "12011";
|
||
|
break;
|
||
|
case 13002:
|
||
|
dev1 = 12007;
|
||
|
dev2 = 12008;
|
||
|
this.F_DeviceIndex3.Text = "12008";
|
||
|
this.F_DeviceIndex2.Text = "12007";
|
||
|
break;
|
||
|
default:
|
||
|
dev1 = 0;
|
||
|
dev2 = 0;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
sql.Clear();
|
||
|
sql.Append(string.Format("SELECT * from ZH_pallet where Device={0}", dev1));
|
||
|
DataView qty1 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
sql.Clear();
|
||
|
sql.Append(string.Format("SELECT * from ZH_pallet where Device={0}", dev2));
|
||
|
DataView qty2 = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
|
||
|
dataGridView1.Rows.Clear();
|
||
|
dataGridView2.Rows.Clear();
|
||
|
if (qty1.Count > 0)
|
||
|
{
|
||
|
this.Mqty1.Text = qty1[0]["qty"].ToString();
|
||
|
this.tray1.Text = qty1[0]["STOCK_BARCODE"].ToString();
|
||
|
|
||
|
string[] SNList = qty1[0]["SN"].ToString().Split(',');
|
||
|
for (int i = 0; i < SNList.Length; i++)
|
||
|
{
|
||
|
dataGridView1.Rows.Add(SNList[i]);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
this.Mqty1.Text = "0";
|
||
|
this.tray1.Text = "";
|
||
|
|
||
|
}
|
||
|
if (qty2.Count > 0)
|
||
|
{
|
||
|
this.Mqty2.Text = qty2[0]["qty"].ToString();
|
||
|
this.tray2.Text = qty2[0]["STOCK_BARCODE"].ToString();
|
||
|
string[] SNList = qty2[0]["SN"].ToString().Split(',');
|
||
|
for (int i = 0; i < SNList.Length; i++)
|
||
|
{
|
||
|
dataGridView2.Rows.Add(SNList[i]);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
this.Mqty2.Text = "0";
|
||
|
this.tray2.Text = "";
|
||
|
}
|
||
|
|
||
|
sql.Clear();
|
||
|
sql.Append("SELECT * from IO_INTERFACE_TASK_STATE_LOG");
|
||
|
DataView its = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
||
|
if (its.Count > 0)
|
||
|
{
|
||
|
this.testingRandomPointCode.Text = its[0]["testingRandomPointCode"].ToString();
|
||
|
this.productCode.Text = its[0]["productCode"].ToString();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
this.testingRandomPointCode.Text = "";
|
||
|
this.productCode.Text = "�ƻ�����";
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
MessageBox.Show(ex.Message);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region �رմ���
|
||
|
private void btnClose_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
this.Close();
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
private void button3_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
|
||
|
if (MessageBox.Show("��ȷ��Ҫ���豸��" + this._deviceIndex + "���͡�����Ӧ��������", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
string errtext = string.Empty;
|
||
|
|
||
|
CStaticClass.WcfControl.BeginSendDeviceReset(this._deviceIndex, 2, new AsyncCallback(SendDeviceResetCallBack), 2);
|
||
|
|
||
|
}
|
||
|
|
||
|
void SendDeviceResetCallBack(IAsyncResult ar)
|
||
|
{
|
||
|
string errtext = string.Empty;
|
||
|
|
||
|
if (CStaticClass.WcfControl.EndSendDeviceReset(out errtext, ar) == false)
|
||
|
{
|
||
|
MessageBox.Show(errtext, "������ʾ", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (ar.AsyncState != null)
|
||
|
{
|
||
|
//if ((((int)ar.AsyncState) == 4)&&(_device.DeviceKind==4))
|
||
|
//{
|
||
|
// CStaticClass.WcfControl.BeginSendDeviceReset(_deviceIndex, 2, new AsyncCallback(SendDeviceResetCallBack), null);
|
||
|
//}
|
||
|
if (((int)ar.AsyncState) == 2)
|
||
|
{
|
||
|
CStaticClass.WcfControl.BeginSendDeviceReset(_deviceIndex, 0, new AsyncCallback(SendDeviceResetCallBack), null);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
private void FrmDeviceStatus_FormClosing(object sender, FormClosingEventArgs e)
|
||
|
{
|
||
|
_formInstance = null;
|
||
|
}
|
||
|
|
||
|
private void button4_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
if (MessageBox.Show("��ȷ��Ҫ���豸��" + this._deviceIndex + "���͡��豸��λ������", "������ʾ��", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
string errtext = string.Empty;
|
||
|
CStaticClass.WcfControl.BeginSendDeviceReset(this._deviceIndex, 4, new AsyncCallback(SendDeviceResetCallBack), 4);
|
||
|
|
||
|
}
|
||
|
int GetMonitorTaskIndexFromBarCode(StringBuilder BarCode)
|
||
|
{//20110216
|
||
|
string bc = BarCode.ToString();
|
||
|
|
||
|
DataView dv = dbo.ExceSQL(string.Format("SELECT T_Monitor_Task.F_MonitorIndex FROM T_Base_Device,T_Monitor_Task WHERE T_Base_Device.F_DeviceIndex = T_Monitor_Task.F_DeviceIndex and ((T_Base_Device.F_DeviceKindIndex = 13) OR (T_Base_Device.F_DeviceKindIndex = 31)) and (F_TxtParam = '{0}') and F_Status>0 order by F_MonitorIndex asc", bc)).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
return Convert.ToInt32(dv[0]["F_MonitorIndex"]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
void WriteDBDataCallback(IAsyncResult ar)
|
||
|
{
|
||
|
string errtext;
|
||
|
|
||
|
if (CStaticClass.WcfControl.EndWriteDBData(out errtext, ar) == false)
|
||
|
{
|
||
|
MessageBox.Show("������ʾ", errtext, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
void WriteBarcodeCallback(IAsyncResult ar)
|
||
|
{
|
||
|
|
||
|
|
||
|
if (CStaticClass.WcfControl.EndWriteBarcode(ar) == false)
|
||
|
{
|
||
|
MessageBox.Show("������ʾ", "����ʧ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("������ʾ", "�����ɹ�", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
void WriteGroupBarcodeCallback(IAsyncResult ar)
|
||
|
{
|
||
|
|
||
|
|
||
|
if (CStaticClass.WcfControl.EndWriteGroupBarcode(ar) == false)
|
||
|
{
|
||
|
MessageBox.Show("������ʾ", "��ʧ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("������ʾ", "�ijɹ�", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
void ClearFireAlarmCallback(IAsyncResult ar)
|
||
|
{
|
||
|
|
||
|
|
||
|
if (CStaticClass.WcfControl.EndClearFireAlarm(ar) == false)
|
||
|
{
|
||
|
MessageBox.Show("������ʾ", "������ͣ����ʧ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("������ʾ", "������ͣ�����ɹ�", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
void ClearPalletCallback(IAsyncResult ar)
|
||
|
{
|
||
|
|
||
|
|
||
|
if (CStaticClass.WcfControl.EndClearPallet(ar) == false)
|
||
|
{
|
||
|
MessageBox.Show("������ʾ", "������������ʧ��", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("������ʾ", "�������������ɹ�", MessageBoxButtons.OK, MessageBoxIcon.None);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
private void button6_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
//ǿ������
|
||
|
string strSQL = string.Format("update ZH_pallet set GOODS_COUNT=1 where Device={0}", _deviceIndex);
|
||
|
int bl = dboMan.ExecuteSql(strSQL);
|
||
|
if (bl == 1)
|
||
|
{
|
||
|
MessageBox.Show("������ʾ", "ǿ������һ�·���", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
MessageBox.Show("û����������");
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
private void button4_Click_1(object sender, EventArgs e)
|
||
|
{
|
||
|
sql.Clear();
|
||
|
sql.Append(string.Format("delete from ZH_pallet where Device={0}", F_DeviceIndex2.Text.ToString()));
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
|
||
|
private void button5_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
sql.Clear();
|
||
|
sql.Append(string.Format("delete from ZH_pallet where Device={0}", F_DeviceIndex3.Text.ToString()));
|
||
|
dbo.ExceSQL(sql.ToString());
|
||
|
}
|
||
|
}
|
||
|
}
|