926 lines
35 KiB
C#
926 lines
35 KiB
C#
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;
|
||
using System.IO.Ports;
|
||
using System.Resources;
|
||
using System.Drawing.Drawing2D;
|
||
using RFIDReaderJilin.Common;
|
||
using System.Linq;
|
||
using System.Net.NetworkInformation;
|
||
|
||
namespace ControlSystem
|
||
{
|
||
|
||
/// <summary>
|
||
/// Creator:Richard.liu
|
||
/// µ÷¶È³ÌÐòÖ÷´°¿Ú
|
||
/// </summary>
|
||
|
||
public partial class FrmControlMonitor : WeifenLuo.WinFormsUI.Docking.DockContent
|
||
{
|
||
FrmDeviceStatus _deviceStatus = new FrmDeviceStatus();
|
||
FrmWorkstationStatus _worstation = new FrmWorkstationStatus();
|
||
#region ·½·¨
|
||
public void FlashPanit(string obj, bool visible)
|
||
{
|
||
this.Controls[obj].Visible = visible;
|
||
}
|
||
public void FlashPanit(string obj, Image backgroundImage)
|
||
{
|
||
this.Controls[obj].BackgroundImage = backgroundImage;
|
||
}
|
||
public void FlashPanit(string obj, ImageLayout backgroundImageLayout)
|
||
{
|
||
this.Controls[obj].BackgroundImageLayout = backgroundImageLayout;
|
||
}
|
||
|
||
public void FlashPanit(string obj, int top, int left)
|
||
{
|
||
this.Controls[obj].Top = top;
|
||
this.Controls[obj].Left = left;
|
||
}
|
||
|
||
public void FlashPanit(string obj, string text, bool append)
|
||
{
|
||
if (append == true)
|
||
{
|
||
this.Controls[obj].Text += text;
|
||
}
|
||
else
|
||
{
|
||
this.Controls[obj].Text = text;
|
||
}
|
||
}
|
||
public string GetObjectText(string obj)
|
||
{
|
||
return this.Controls[obj].Text;
|
||
}
|
||
public void MonitorRefresh(object dataSource)
|
||
{
|
||
#region Added by DingXiaoxu for Dock TaskList on 20101219
|
||
FrmTaskList.FormInstance.MonitorRefresh(dataSource);
|
||
#endregion
|
||
|
||
//this.dgvMonitor.DataSource = dataSource;
|
||
////20100108
|
||
//dataSource = null;
|
||
}
|
||
public void ManagerRefresh(object dataSource)
|
||
{
|
||
#region Added by DingXiaoxu for Dock TaskList on 20101219
|
||
FrmTaskList.FormInstance.ManagerRefresh(dataSource);
|
||
#endregion
|
||
|
||
//this.dgvManager.DataSource = dataSource;
|
||
////20100108
|
||
//dataSource = null;
|
||
}
|
||
#endregion
|
||
private static FrmControlMonitor _formInstance;
|
||
public static FrmControlMonitor FormInstance
|
||
{
|
||
get
|
||
{
|
||
if (_formInstance == null)
|
||
{
|
||
_formInstance = new FrmControlMonitor();
|
||
|
||
}
|
||
return _formInstance;
|
||
}
|
||
set { _formInstance = value; }
|
||
}
|
||
//IGetDeviceState gds;
|
||
CGetState gs = new CGetState();
|
||
CControl cc = new CControl();
|
||
CListenPLCAsk cplc = new CListenPLCAsk();
|
||
CCommonFunction ccf = new CCommonFunction();
|
||
DBOperator dbo = CStaticClass.dbo;
|
||
DBOperator dbo1 = CStaticClass.dbo1;
|
||
DBOperator dboM =CStaticClass.dboM;
|
||
|
||
|
||
// static ICommLayer.ISendDeviceOrder sdo;
|
||
string[] wv = new string[1] { "2" };
|
||
string[] witemnames = new string[1];
|
||
//20110108 ³õʼ»¯Ë¢ÐÂ
|
||
|
||
Panel pp;
|
||
Button stack1, stack2, stack3 ,stack4, stack5;//¶Ñ¶â»ú
|
||
|
||
TextBox twj1, twj2, twj3, twj4, twj5;//¹âµç¿ª¹Ø
|
||
//TextBox twy1, twy2, twy3, twy4, twy5, twy6;//Ô¶²æ¹âµç¿ª¹Ø
|
||
|
||
public FrmControlMonitor()
|
||
{
|
||
|
||
InitializeComponent();
|
||
_formInstance = this;
|
||
|
||
}
|
||
protected override CreateParams CreateParams
|
||
{
|
||
|
||
get
|
||
{
|
||
|
||
CreateParams cp = base.CreateParams;
|
||
|
||
cp.ExStyle |= 0x02000000;//WS_CLIPCHILDREN Á½¸ö´°Ìåµþ¼Óʱ£¬Öصþ²¿·Ö²»ÖØ»æ
|
||
return cp;
|
||
|
||
}
|
||
|
||
}
|
||
|
||
private void FrmControlMonitor_Load(object sender, EventArgs e)
|
||
{
|
||
// CStaticClass.GetBackStackStatus();
|
||
|
||
#region Ìí¼ÓÊäËÍ»ú¡¢´©Ë󳵺ͶѶâ»úµÄµ¥»÷ʼþ
|
||
|
||
|
||
foreach (Control ctrl in this.panel1.Controls)
|
||
{
|
||
if (ctrl.GetType().ToString() == "System.Windows.Forms.Button" || ctrl.GetType().ToString() == "CommonClassLib.tButton")
|
||
{
|
||
ctrl.Click += new EventHandler(ctrl_Click);
|
||
ctrl.MouseEnter += new EventHandler(Btn_MouseEnter);
|
||
}
|
||
if ((ctrl.GetType().ToString() == "System.Windows.Forms.Label") && (ctrl.Tag != null))
|
||
{
|
||
ctrl.Click += new EventHandler(ctrl_ClickLabel);
|
||
ctrl.MouseEnter += new EventHandler(Btn_MouseEnter);
|
||
}
|
||
|
||
|
||
}
|
||
//foreach (Control ctrl in this.panel2.Controls)
|
||
//{
|
||
// if (ctrl.GetType().ToString() == "System.Windows.Forms.Button")
|
||
// {
|
||
// ctrl.Click += new EventHandler(ctrl_Click);
|
||
// ctrl.MouseEnter += new EventHandler(Btn_MouseEnter);
|
||
// }
|
||
|
||
// if ((ctrl.GetType().ToString() == "System.Windows.Forms.Label") && (ctrl.Tag != null))
|
||
// {
|
||
// ctrl.Click += new EventHandler(ctrl_ClickLabel);
|
||
// ctrl.MouseEnter += new EventHandler(Btn_MouseEnter);
|
||
// }
|
||
|
||
//}
|
||
|
||
|
||
#endregion
|
||
|
||
//³õʼ»¯É䯵
|
||
//CRfidHelper.OpenReader();
|
||
}
|
||
|
||
private void ctrl_Click(object sender, EventArgs e)
|
||
{
|
||
Button btn = (Button)sender;
|
||
_deviceStatus.DeviceIndex = Convert.ToInt32(btn.Tag);
|
||
_deviceStatus.ShowDialog();
|
||
}
|
||
private void ctrl_ClickTxt(object sender, EventArgs e)
|
||
{
|
||
TextBox txt = (TextBox)sender;
|
||
_worstation.DeviceIndex = Convert.ToInt32(txt.Tag);
|
||
_worstation.ShowDialog();
|
||
}
|
||
private void ctrl_ClickLabel(object sender, EventArgs e)
|
||
{
|
||
Label label = (Label)sender;
|
||
_deviceStatus.DeviceIndex = Convert.ToInt32(label.Tag);
|
||
_deviceStatus.ShowDialog();
|
||
}
|
||
private void ctrl_ClickPic(object sender, EventArgs e)
|
||
{
|
||
PictureBox btn = (PictureBox)sender;
|
||
_deviceStatus.DeviceIndex = Convert.ToInt32(btn.Tag );
|
||
_deviceStatus.ShowDialog();
|
||
}
|
||
private void timer1_Tick(object sender, EventArgs e)
|
||
{
|
||
|
||
|
||
if (CStaticClass.Order == true )
|
||
{
|
||
// string ss = DateTime.Now.Second.ToString() + "-" + DateTime.Now.Millisecond.ToString();
|
||
//20090920
|
||
// CStaticClass.GetAllReturns();
|
||
DateTime dt1 = DateTime.Now;
|
||
gs.GetDeviceState();
|
||
DateTime dt2 = DateTime.Now;
|
||
// CommonClassLib.CCarryConvert.WriteDarkCasket("GetDeviceState¼ä¸ô", dt1.ToString("u"), dt2.ToString("u"), (dt2 - dt1).ToString());
|
||
// System.Diagnostics.Trace.WriteLine("GetDeviceState" + Convert.ToString(dt2 - dt1));
|
||
if (tsStatus.Text.Length > 300)
|
||
tsStatus.Text = "";
|
||
|
||
|
||
}
|
||
|
||
}
|
||
|
||
private void TSMrefresh_Click(object sender, EventArgs e)
|
||
{
|
||
//CStaticClass.RealRefresh = true;
|
||
//this.dgvManager.DataSource = dbo.ExceSQL("select * from V_Manage_Task where " + CStaticClass.Manstatus).Tables[0].DefaultView;
|
||
}
|
||
private void TSMMonitorRefresh_Click(object sender, EventArgs e)
|
||
{
|
||
//CStaticClass.RealRefresh = true;
|
||
//this.dgvMonitor.DataSource = dbo.ExceSQL("select * from V_Monitor_Task where " + CStaticClass.Monstatus + " order by É豸ָÁîË÷Òý asc ").Tables[0].DefaultView;
|
||
}
|
||
private void rbmanAll_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
RadioButton rb = (RadioButton)sender;
|
||
if (rb.Checked == true)
|
||
{
|
||
CStaticClass.Manstatus = " F_Status<>-1 ";
|
||
}
|
||
TSMrefresh_Click(sender, e);
|
||
}
|
||
|
||
private void rbmanRun_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
RadioButton rb = (RadioButton)sender;
|
||
if (rb.Checked == true)
|
||
{
|
||
CStaticClass.Manstatus = " F_Status=1 ";
|
||
}
|
||
TSMrefresh_Click(sender, e);
|
||
}
|
||
|
||
private void rbmanWait_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
RadioButton rb = (RadioButton)sender;
|
||
if (rb.Checked == true)
|
||
{
|
||
CStaticClass.Manstatus = " F_Status=0 ";
|
||
}
|
||
TSMrefresh_Click(sender, e);
|
||
}
|
||
|
||
private void rbmonAll_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
RadioButton rb = (RadioButton)sender;
|
||
if (rb.Checked == true)
|
||
{
|
||
CStaticClass.Monstatus = " F_Status<>-1 ";
|
||
}
|
||
TSMMonitorRefresh_Click(sender, e);
|
||
}
|
||
|
||
private void rbmonRun_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
RadioButton rb = (RadioButton)sender;
|
||
if (rb.Checked == true)
|
||
{
|
||
CStaticClass.Monstatus = " (F_Status>=1) ";
|
||
}
|
||
TSMMonitorRefresh_Click(sender, e);
|
||
}
|
||
|
||
private void rbmonWait_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
RadioButton rb = (RadioButton)sender;
|
||
if (rb.Checked == true)
|
||
{
|
||
CStaticClass.Monstatus = " F_Status=0 ";
|
||
}
|
||
TSMMonitorRefresh_Click(sender, e);
|
||
}
|
||
|
||
|
||
|
||
private void button2_Click(object sender, EventArgs e)
|
||
{
|
||
CStaticClass.Monstatus = " F_Status<>-1 ";
|
||
|
||
TSMMonitorRefresh_Click(sender, e);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
private void timer2_Tick(object sender, EventArgs e)
|
||
{
|
||
|
||
//DataTable dt; string ss1;
|
||
//string ss12; string ss13; string ss14;
|
||
try
|
||
{
|
||
//ss12 = DateTime.Now.Second.ToString() + "-" + DateTime.Now.Millisecond.ToString();
|
||
if ((CStaticClass.RealRefresh == true) && (CStaticClass.Order == true))
|
||
{
|
||
|
||
bool ifflash = false;
|
||
if (FrmMain.FormInstance.dockPanel1.ActiveAutoHideContent != null)
|
||
{
|
||
if (FrmMain.FormInstance.dockPanel1.ActiveAutoHideContent.ToString().IndexOf("FrmTaskList") < 0)
|
||
{
|
||
ifflash = false;
|
||
}
|
||
else
|
||
{
|
||
ifflash = true;
|
||
}
|
||
//System.Diagnostics.Trace.WriteLine("1.ActiveAutoHideContent:" + FrmMain.FormInstance.dockPanel1.ActiveAutoHideContent.ToString());
|
||
}
|
||
else
|
||
{
|
||
if (FrmTaskList.FormInstance.DockState == WeifenLuo.WinFormsUI.Docking.DockState.DockBottom)
|
||
{
|
||
ifflash = true;
|
||
}
|
||
else
|
||
{
|
||
ifflash = false;
|
||
}
|
||
|
||
}
|
||
|
||
//ÏÔʾÉ豸ָÁî
|
||
//20100108
|
||
if(ifflash==true)
|
||
{
|
||
FrmControlMonitor.FormInstance.MonitorRefresh(dbo1.ExceSQL("select * from V_Monitor_Task where " + CStaticClass.Monstatus + " order by É豸ָÁîË÷Òý asc ").Tables[0].DefaultView);
|
||
//ÏÔʾµ÷¶ÈÈÎÎñ
|
||
FrmControlMonitor.FormInstance.ManagerRefresh(
|
||
dbo1.ExceSQL("select * from V_Manage_Task where " + CStaticClass.Manstatus).Tables[0].DefaultView);
|
||
}
|
||
}
|
||
|
||
//»ñÈ¡µ÷¶ÈÈÎÎñ
|
||
if (CStaticClass.ObtainManageTask == true)
|
||
{
|
||
//CObtainTask.GetWebManageTask();
|
||
DateTime dt1 = DateTime.Now;
|
||
|
||
if (CObtainTask.GetManagerTask() == 0)
|
||
{
|
||
this.tsStatus.ForeColor = Color.Red;
|
||
if (this.tsStatus.Text.IndexOf(CObtainTask.CObtainTaskError) < 0)
|
||
{
|
||
this.tsStatus.Text += CObtainTask.CObtainTaskError;
|
||
}
|
||
}
|
||
if (CObtainTask.CObtainTaskError.Length > 0)
|
||
{
|
||
if (this.tsStatus.Text.IndexOf(CObtainTask.CObtainTaskError) < 0)
|
||
{
|
||
this.tsStatus.ForeColor = Color.Red;
|
||
this.tsStatus.Text += CObtainTask.CObtainTaskError;
|
||
}
|
||
}
|
||
DateTime dt2 = DateTime.Now;
|
||
//CommonClassLib.CCarryConvert.WriteDarkCasket("ObtainTask¼ä¸ô", dt1.ToString("u"), dt2.ToString("u"), (dt2 - dt1).ToString());
|
||
CObtainTask.CObtainTaskError = "";
|
||
|
||
}
|
||
|
||
//ss13 = DateTime.Now.Second.ToString() + "-" + DateTime.Now.Millisecond.ToString();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
if (tsStatus.Text.IndexOf("»ñÈ¡µ÷¶ÈÈÎÎñ»ñÈ¡µ÷¶ÈÈÎÎñʱ£º" + ex.Message) < 0)
|
||
{
|
||
tsStatus.Text += "»ñÈ¡µ÷¶ÈÈÎÎñʱ£º" + ex.Message;
|
||
}
|
||
}
|
||
finally
|
||
{
|
||
//dt = null;
|
||
}
|
||
|
||
}
|
||
|
||
private void timer3_Tick(object sender, EventArgs e)
|
||
{
|
||
if (CStaticClass.Order == true || CStaticClass.isDisassembleTask)
|
||
{
|
||
|
||
string ss1 = DateTime.Now.Second.ToString() + "-" + DateTime.Now.Millisecond.ToString();
|
||
DateTime dt1 = DateTime.Now;
|
||
|
||
//Æô¶¯²ð·Ö½ø³ÌMyTaskIntoSteps();
|
||
|
||
CDisassembleTask.MyTaskIntoSteps();
|
||
|
||
DateTime dt2 = DateTime.Now;
|
||
System.Diagnostics.Trace.WriteLine("MyTaskIntoSteps" + Convert.ToString(dt2 - dt1));
|
||
// CommonClassLib.CCarryConvert.WriteDarkCasket("MyTaskIntoSteps¼ä¸ô", dt1.ToString("u"), dt2.ToString("u"), (dt2 - dt1).ToString());
|
||
|
||
if (CDisassembleTask .DisassembleTaskError!= "")
|
||
{
|
||
if (tsStatus.Text.IndexOf(CDisassembleTask.DisassembleTaskError) < 0)
|
||
{
|
||
tsStatus.ForeColor = Color.Red;
|
||
tsStatus.Text += CDisassembleTask.DisassembleTaskError;
|
||
}
|
||
CDisassembleTask.DisassembleTaskError = "";
|
||
}
|
||
if (CStaticClass.ObtainManageTask)
|
||
{
|
||
DateTime dt3 = DateTime.Now;
|
||
|
||
cplc.DealwithPLCAsk();
|
||
DateTime dt4 = DateTime.Now;
|
||
// CommonClassLib.CCarryConvert.WriteDarkCasket("DealwithPLCAsk¼ä¸ô", dt1.ToString("u"), dt2.ToString("u"), (dt4 - dt3).ToString());
|
||
if (cplc.ListenPLCAskError != "")
|
||
{
|
||
if (tsStatus.Text.IndexOf(cplc.ListenPLCAskError) < 0)
|
||
{
|
||
tsStatus.ForeColor = Color.Red;
|
||
tsStatus.Text += cplc.ListenPLCAskError;
|
||
}
|
||
}
|
||
cplc.ListenPLCAskError = "";
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
private void timer4_Tick(object sender, EventArgs e)
|
||
{
|
||
if (CStaticClass.Order == true)
|
||
{
|
||
#region ¶ÁÈ¡ËùÓÐPLCÊý¾Ý
|
||
DateTime dt1 = DateTime.Now;
|
||
//System.Diagnostics.Trace.WriteLine("------------------------------------------" + Convert.ToString(dt1.ToLongTimeString));
|
||
//string ss1 = DateTime.Now.Second.ToString() + "-" + DateTime.Now.Millisecond.ToString();
|
||
//System.Diagnostics.Trace.WriteLine(ss1);
|
||
CStaticClass.GetAllReturns();//20100610
|
||
|
||
//string ss11 = DateTime.Now.Second.ToString() + "-" + DateTime.Now.Millisecond.ToString();
|
||
DateTime dt2 = DateTime.Now;
|
||
// CommonClassLib.CCarryConvert.WriteDarkCasket("GetAllReturns¼ä¸ô", dt1.ToString("u"), dt2.ToString("u"), (dt2 - dt1).ToString());
|
||
//System.Diagnostics.Trace.WriteLine("GetAllReturns"+Convert.ToString(dt2 - dt1));
|
||
|
||
#endregion
|
||
}
|
||
}
|
||
|
||
private void timer5_Tick(object sender, EventArgs e)
|
||
{
|
||
if (CStaticClass.Order == true ) // ×Ô¶¯¼àÌýplc
|
||
{
|
||
string ss1 = DateTime.Now.Second.ToString() + "-" + DateTime.Now.Millisecond.ToString();
|
||
DateTime dt1 = DateTime.Now;
|
||
cc.StartOrder(); //δÁ¬PLC²»·¢ËÍÃüÁî
|
||
DateTime dt2 = DateTime.Now;
|
||
// CommonClassLib.CCarryConvert.WriteDarkCasket("StartOrder¼ä¸ô", dt1.ToString("u"), dt2.ToString("u"), (dt2 - dt1).ToString());
|
||
System.Diagnostics.Trace.WriteLine("StartOrder" + Convert.ToString(dt2 - dt1));
|
||
if (cc.CControlError != "")
|
||
{
|
||
if (tsStatus.Text.IndexOf(cc.CControlError) < 0)
|
||
{
|
||
tsStatus.ForeColor = Color.Red;
|
||
tsStatus.Text += cc.CControlError;
|
||
}
|
||
}
|
||
cc.CControlError = "";
|
||
}
|
||
|
||
}
|
||
|
||
private void timerFlash_Tick(object sender, EventArgs e)
|
||
{
|
||
//return;
|
||
//20100108
|
||
DateTime dt1 = DateTime.Now;
|
||
DataView dvh;
|
||
Model.MDevice device = null;
|
||
|
||
try
|
||
{
|
||
if (CStaticClass.Order == true)
|
||
{
|
||
|
||
if (!CStaticClass.LIKUSTATUS)
|
||
{
|
||
//this.label40.Text = "×Ô¶¯Ð£±íÏ߻ؿâ¿ÚÉèÖÃΪ²»ÔÊÐí»Ø¿â";
|
||
//this.label40.ForeColor = Color.Red;
|
||
}
|
||
else
|
||
{
|
||
//this.label40.Text = string.Empty;
|
||
}
|
||
|
||
pp = this.panel1 ;
|
||
stack1 = bt1_11001;
|
||
stack2 = bt1_11002;
|
||
twj1 = t1_110010;
|
||
twj2 = t1_110020;
|
||
|
||
#region ÿ²ãÂ¥¼àÊÓ»Ãæ
|
||
|
||
foreach (Control ctrl in pp.Controls)
|
||
{
|
||
if (((ctrl.GetType().ToString() == "System.Windows.Forms.Button") ||
|
||
(ctrl.GetType().ToString() == "System.Windows.Forms.PictureBox")) &&
|
||
(ctrl.Enabled == true))
|
||
{
|
||
if (ctrl.Tag == null)
|
||
{
|
||
continue;
|
||
}
|
||
device = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(ctrl.Tag));
|
||
|
||
if (device == null)
|
||
{//20100108
|
||
if (tsStatus.Text.IndexOf("É豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!") < 0)
|
||
{
|
||
tsStatus.ForeColor = Color.Red;
|
||
this.tsStatus.Text += "É豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!";
|
||
}
|
||
|
||
|
||
continue;
|
||
|
||
}
|
||
#region ÉèÖÃÉ豸״̬
|
||
switch (device.RunState)
|
||
{
|
||
//¿ÕÏÐ
|
||
case 0:
|
||
if (device.DeviceKind == 1 || device.DeviceKind == 3 || device.DeviceKind == 4)
|
||
{
|
||
|
||
ctrl.BackColor = Color.DarkOrange;
|
||
}
|
||
else
|
||
{
|
||
ctrl.BackColor = Color.Silver;
|
||
}
|
||
|
||
break;
|
||
//ÔËÐÐ
|
||
case 1:
|
||
ctrl.BackColor = Color.Lime;
|
||
break;
|
||
//¹ÊÕÏ
|
||
case 2:
|
||
ctrl.BackColor = Color.Red;
|
||
break;
|
||
//ÀëÏß
|
||
case 3:
|
||
ctrl.BackColor = Color.LightYellow;
|
||
break;
|
||
//Í£ÓÃ
|
||
case 4:
|
||
ctrl.BackColor = Color.Maroon;
|
||
break;
|
||
//20090920¶¯×÷Íê³É
|
||
case 5:
|
||
if (device.DeviceKind == 1 || device.DeviceKind == 4)
|
||
{
|
||
ctrl.BackColor = Color.MediumSlateBlue;//MediumOrchid;
|
||
}
|
||
else
|
||
{
|
||
ctrl.BackColor = Color.Silver;
|
||
}
|
||
//if (device.DeviceKind != 18)
|
||
//{
|
||
// ctrl.BackColor = Color.Gray;
|
||
//}
|
||
|
||
break;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region ÒÆ¶¯Éè±¸×ø±ê¸üÐÂ
|
||
//¶Ñ¶â»ú
|
||
|
||
if (device.DeviceKind == 1)// && device.XCoor != 0)
|
||
{
|
||
//¶Ñ¶â»ú
|
||
if (device.DeviceKind == 1)
|
||
{
|
||
|
||
double TempX = device.XCoor;
|
||
double TempY = device.YCoor;
|
||
switch (device.DeviceIndex)
|
||
{
|
||
case 11001:
|
||
stack1.Location = new Point(pictureBox1.Location.X + (int)((TempX - 1) * pictureBox1.Size.Width / 20 - bt1_11001.Width), 263);
|
||
twj1.Location = new Point(stack1.Location.X + 38, stack1.Location.Y + 10);
|
||
textBox23.Location = new Point(stack1.Location.X + 11, stack1.Location.Y + 31);
|
||
textBox22.Location = new Point(stack1.Location.X + 11, stack1.Location.Y - 10);
|
||
//label83.Location = new Point(stack1.Location.X + stack1.Width + 5, stack1.Location.Y + 2);
|
||
//label83.Text = "ÁУº" + TempX;
|
||
//label84.Location = new Point(stack1.Location.X + stack1.Width + 5, stack1.Location.Y + 2 + stack1.Height / 2);
|
||
//label84.Text = "²ã£º" + Convert.ToInt32(TempY);
|
||
break;
|
||
case 11002:
|
||
stack2.Location = new Point(pictureBox1.Location.X + (int)((TempX - 1) * pictureBox1.Size.Width / 20 - bt1_11001.Width), 433);
|
||
twj2.Location = new Point(stack2.Location.X + 38, stack2.Location.Y + 10);
|
||
textBox20.Location = new Point(stack2.Location.X + 11, stack2.Location.Y + 31);
|
||
textBox21.Location = new Point(stack2.Location.X + 11, stack2.Location.Y - 10);
|
||
//label86.Location = new Point(stack2.Location.X + stack2.Width + 5, stack2.Location.Y + 2);
|
||
//label86.Text = "ÁУº" + TempX;
|
||
//label85.Location = new Point(stack2.Location.X + stack2.Width + 5, stack2.Location.Y + 2 + stack2.Height / 2);
|
||
//label85.Text = "²ã£º" + Convert.ToInt32(TempY);
|
||
break;
|
||
}
|
||
}
|
||
|
||
|
||
//double startadd = 436;
|
||
//double k = 0.019062;
|
||
//double p = 0.0192387;
|
||
|
||
//if (device.XCoor < 1800)
|
||
//{
|
||
// //startadd = 841.719528208;
|
||
// //k = 0.033530776;
|
||
//}
|
||
|
||
//int locationX = (int)(startadd + (k) * (device.XCoor - 635));
|
||
//if (device.DeviceIndex == 11005)
|
||
//{
|
||
// locationX = (int)(startadd + (p) * (62370 - device.XCoor));
|
||
//}
|
||
//switch (device.DeviceIndex)
|
||
//{
|
||
|
||
// case 11001:
|
||
// if (stack1.Location.X != locationX)
|
||
// {
|
||
// stack1.Location = new Point(locationX, stack1.Location.Y);
|
||
// twj1.Location = new Point(locationX + 15, twj1.Location.Y);
|
||
|
||
// }
|
||
// break;
|
||
|
||
// case 11002:
|
||
// locationX = (int)(startadd + (k) * (device.XCoor - 6305));
|
||
// if (stack2.Location.X != locationX)
|
||
// {
|
||
|
||
// stack2.Location = new Point(locationX, stack2.Location.Y);
|
||
// twj2.Location = new Point(locationX + 15, twj2.Location.Y);
|
||
|
||
// }
|
||
// break;
|
||
// case 11003:
|
||
// if (stack3.Location.X != locationX)
|
||
// {
|
||
// stack3.Location = new Point(locationX, stack3.Location.Y);
|
||
// twj3.Location = new Point(locationX + 15, twj3.Location.Y);
|
||
|
||
// }
|
||
// break;
|
||
// case 11004:
|
||
// if (stack4.Location.X != locationX)
|
||
// {
|
||
// stack4.Location = new Point(locationX, stack4.Location.Y);
|
||
// twj4.Location = new Point(locationX + 15, twj4.Location.Y);
|
||
|
||
// }
|
||
// break;
|
||
// case 11005:
|
||
// {
|
||
// stack5.Location = new Point(locationX, stack5.Location.Y);
|
||
// twj5.Location = new Point(locationX + 15, twj5.Location.Y);
|
||
|
||
// }
|
||
|
||
// break;
|
||
|
||
//}
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
|
||
else
|
||
if ((ctrl.GetType().ToString() == "System.Windows.Forms.TextBox") || ((ctrl.GetType().ToString() == "System.Windows.Forms.PictureBox") && (ctrl.Name.Substring(0, 1) == "t")))
|
||
{
|
||
#region »õÎï̽²â
|
||
if (ctrl.Tag ==null || ctrl.Tag.ToString() == string.Empty)
|
||
{
|
||
ctrl.Visible = true;
|
||
}
|
||
else
|
||
{
|
||
ctrl.Visible = CStaticClass.GetDevicePhotoelectric(ctrl.Tag.ToString()) == 1 ? true : false;
|
||
}
|
||
if (ctrl.Visible == true)
|
||
{
|
||
|
||
}
|
||
#endregion
|
||
}
|
||
#region Âß¼ÓÐÎïÏÔʾ
|
||
|
||
|
||
else if (ctrl.GetType().ToString() == "System.Windows.Forms.RadioButton")
|
||
{
|
||
//20100108DataView dvh;
|
||
dvh = dbo.ExceSQL("SELECT F_DeviceIndex FROM T_Base_Device WHERE (F_DeviceIndex = " + ctrl.Tag + ") AND (F_HaveGoods = 1)").Tables[0].DefaultView;
|
||
if (dvh.Count > 0)
|
||
{
|
||
ctrl.Visible = true;
|
||
// ctrl.BackColor = Color.Blue;
|
||
}
|
||
else
|
||
{
|
||
ctrl.Visible = false;
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
#endregion
|
||
|
||
|
||
|
||
}
|
||
DateTime dt2 = DateTime.Now;
|
||
|
||
System.Diagnostics.Trace.WriteLine("REFLASH" + (dt2 - dt1).ToString());
|
||
|
||
|
||
#endregion
|
||
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{//20100108
|
||
if (tsStatus.Text.IndexOf("ˢнçÃæ¶¯»Ê±£º" + ex.Message) < 0)
|
||
{
|
||
tsStatus.ForeColor = Color.Red;
|
||
this.tsStatus.Text += "ˢнçÃæ¶¯»Ê±£º" + ex.Message;
|
||
}
|
||
}
|
||
finally
|
||
{//20100108
|
||
dvh = null;
|
||
device = null;
|
||
}
|
||
|
||
}
|
||
|
||
private void button35_Click(object sender, EventArgs e)
|
||
{
|
||
//if (CRfidHelper.rdr !=null)
|
||
//{
|
||
// CRfidHelper.tags.Clear();
|
||
// CRfidHelper.rdr.StartReading();
|
||
//}
|
||
//else
|
||
//{
|
||
|
||
//}
|
||
CreateMonitor.WcsToManageTaskOver(2088);
|
||
//string dtime = DateTime.Now.ToString("u");
|
||
//dtime = dtime.Substring(0, dtime.Length - 1);
|
||
//int ControlID = 0;
|
||
//int CONTROL_APPLY_TYPE = 1;
|
||
//string dcode = "12002";
|
||
//string barcode = "1111122222";
|
||
|
||
//string sql = "INSERT INTO IO_CONTROL_APPLY(CONTROL_ID ,CONTROL_APPLY_TYPE,WAREHOUSE_CODE, DEVICE_CODE, STOCK_BARCODE, APPLY_TASK_STATUS, CREATE_TIME,CONTROL_APPLY_REMARK)VALUES " +
|
||
//"(" + ControlID + "," + CONTROL_APPLY_TYPE + ",'1'," + dcode + ",'" + barcode + "',0,'" + dtime + "','')";
|
||
|
||
//dboM.ExceSQL(sql);
|
||
//CreateMonitor.CreateMove(12002,12001,6);
|
||
}
|
||
public Dictionary<string,string> keyValuePairs = new Dictionary<string,string>();
|
||
public int taskIndex = 0;
|
||
private void timerCamera_Tick(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
DataView dv = dbo.ExceSQL("select * from T_Manage_Task ").Tables[0].DefaultView;
|
||
keyValuePairs.Clear();
|
||
for (int i = 0; i < dv.Count; i++)
|
||
{
|
||
if (dv[i]["FSTATUS"].ToString() == "1")
|
||
{
|
||
string type = dv[i]["FCONTROLTASKTYPE"].ToString();
|
||
if (type == "1")//Èë¿â
|
||
{
|
||
string code = dv[i]["FENDCELL"].ToString();
|
||
keyValuePairs[code] = "Èë¿â";
|
||
}
|
||
if (type == "2")//³ö¿â
|
||
{
|
||
string code = dv[i]["FSTARTCELL"].ToString();
|
||
keyValuePairs[code] = "³ö¿â";
|
||
}
|
||
if (type == "0")//³ö¿â
|
||
{
|
||
string code = "ÎÞ´¢Î»ºÅ";
|
||
keyValuePairs[code] = "ÎÞÈÎÎñ";
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
// ÂÖѯÏÔʾ keyValuePairs µÄÊý¾Ý
|
||
if (keyValuePairs.Count > 0)
|
||
{
|
||
var keys = keyValuePairs.Keys.ToList();
|
||
string key = keys[taskIndex];
|
||
string value = keyValuePairs[key];
|
||
|
||
// µ÷Óà LED ÏÔʾ·½·¨
|
||
LEDHelper.RefreshCount("192.168.0.7", value, key);
|
||
|
||
// ¸üРtaskIndex£¬È·±£Ñ»·±éÀú
|
||
taskIndex = (taskIndex + 1) % keyValuePairs.Count;
|
||
}
|
||
else
|
||
{
|
||
//// µ÷Óà LED ÏÔʾ·½·¨
|
||
LEDHelper.RefreshCount("192.168.0.7", "ÎÞÈÎÎñ", "ÎÞ´¢Î»ºÅ");
|
||
//taskIndex = 0;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
|
||
}
|
||
}
|
||
|
||
|
||
private void FrmControlMonitor_Resize(object sender, EventArgs e)
|
||
{
|
||
//if (this.WindowState == FormWindowState.Maximized)//20100610zl
|
||
//{
|
||
// this.FormBorderStyle = FormBorderStyle.None;
|
||
//}
|
||
//else
|
||
//{
|
||
// this.FormBorderStyle = FormBorderStyle.Sizable;
|
||
//}
|
||
}
|
||
|
||
|
||
|
||
|
||
private void button6_Click_2(object sender, EventArgs e)
|
||
{
|
||
dboM = CStaticClass.dboM;
|
||
dboM.GetManageTableIndex("IO_CONTROL_APPLY");
|
||
}
|
||
|
||
#region Added by DingXiaoxu for tooltip on 20101219
|
||
private void Btn_MouseEnter(object sender, EventArgs e)
|
||
{
|
||
toolTip_DeviceIndex.SetToolTip(sender as Control, Convert.ToString((sender as Control).Tag));
|
||
}
|
||
#endregion
|
||
|
||
public void tsStatus_TextChanged(object sender, System.EventArgs e)
|
||
{
|
||
//throw new System.Exception("The method or operation is not implemented.");
|
||
|
||
FrmErrorMessage.FormInstance.NewMessage((sender as TextBox).Text);
|
||
}
|
||
|
||
public void tsStatus_ForeColorChanged(object sender, System.EventArgs e)
|
||
{
|
||
FrmErrorMessage.FormInstance.NewForeColor((sender as TextBox).ForeColor);
|
||
}
|
||
|
||
private void timerTransDeviceStatus_Tick(object sender, EventArgs e)
|
||
{
|
||
if (CStaticClass.Order == true)//ÃüÁ¹Ø´ò¿ª
|
||
{
|
||
ccf.ReportDeviceState();
|
||
|
||
}
|
||
}
|
||
|
||
private void timerLight_Tick(object sender, EventArgs e)
|
||
{
|
||
if (CStaticClass.Order == true) // ×Ô¶¯¼àÌýplc
|
||
{
|
||
//ÔÚÎÞ³ö¿âÈÎÎñÖ´ÐÐʱ£¬Èë¿â¿Ú¿ÕÏÐÎÞ»õʱ µÆÁÁ
|
||
|
||
CStaticClass.SetInLightOnOff();
|
||
}
|
||
}
|
||
|
||
}
|
||
} |