山东时代原料后WCS代码
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.

1175 lines
48 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 System.Linq;
using Microsoft.VisualBasic;
using System.IO.Ports;
using System.Resources;
using System.Drawing.Drawing2D;
namespace wcfControlMonitorClient
{
/// <summary>
/// Creator:Richard.liu
/// µ÷¶È³ÌÐòÖ÷´°¿Ú
/// </summary>
public partial class FrmControlMonitor : WeifenLuo.WinFormsUI.Docking.DockContent
{
StringBuilder sql = new StringBuilder();
Model.MDevice devinfo;
FrmDeviceStatus _deviceStatus = new FrmDeviceStatus();
DBFactory.DBOperator dbo = CStaticClass.dbo;
DBFactory.DBOperator dbo1 = CStaticClass.dboM;
private static FrmControlMonitor _formInstance;
public static FrmControlMonitor FormInstance
{
get
{
if (_formInstance == null)
{
_formInstance = new FrmControlMonitor();
}
return _formInstance;
}
set { _formInstance = value; }
}
public FrmControlMonitor()
{
InitializeComponent();
_formInstance = this;
}
#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
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000;//WS_CLIPCHILDREN Á½¸ö´°Ìåµþ¼Óʱ£¬Öصþ²¿·Ö²»ÖØ»æ
return cp;
}
}
private void timerFlash_Tick(object sender, EventArgs e)
{
string[] DS; char[] dd = new char[1] { '.' };
Model.MDevice device;
Model.MDevice devicedaocha;//add by lyj 20171205
TimeSpan ts = DateTime.Now.TimeOfDay;
DataView dv; DataView dvJY;DataView dvlt;
DataView bar1; DataView bar2;
DataView device1;
DataView devicestation1;
this.SuspendLayout(); //richard.liu20140806
try
{
if (CStaticClass.WCFOK == true)
{
#region add by lyj20190311Ë¢ÐÂÑÝʾģʽ±êǩָʾ
//sql.Remove(0, sql.Length);
//sql.Append("select * from T_WareHouse_DemoSet");
//dvlt = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
//if (dvlt.Count > 0)
//{
// for (int i = 0; i < dvlt.Count; i++)
// {
// try
// {
// string warehouseType = dvlt[i]["FWarehouseType"].ToString();
// switch (warehouseType)
// {
// case "B":
// if (Convert.ToInt32(dvlt[i]["FDemoFlag"]) == 1)
// {
// liaoxianglb.Visible = true;
// }
// else
// {
// liaoxianglb.Visible = false;
// }
// break;
// case "T":
// if (Convert.ToInt32(dvlt[i]["FDemoFlag"]) == 1)
// {
// tuopanlv.Visible = true;
// }
// else
// {
// tuopanlv.Visible = false;
// }
// break;
// }
// }
// catch (Exception ee) { }
// }
//}
#endregion
sql.Remove(0, sql.Length);//richard.liu20140806
sql.Append("SELECT F_DeviceIndex FROM T_Base_Device WHERE (F_LockedState = - 1) ");
dvJY = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;//richard.liu20140806
dvJY.Sort = "F_DeviceIndex";
//Button ShuttleBorad1 = bt1_10001;
//Button ShuttleBorad2 = bt1_10002;
//Button ShuttleBorad3 = bt1_10003;
Button stack1 = bt_11001;
Button stack2 = bt_11002;
Button stack3 = bt_11003;
TextBox tw1 = tb_11001;
TextBox tw2 = tb_11002;
TextBox tw3 = tb_11003;
//TextBox boradtw1 = tb1_10001;
//TextBox boradtw2 = tb1_10002;
//TextBox boradtw3 = tb1_10003;
Panel pp = plAccessorial1;
if (this.tabControl1.SelectedIndex == 0)
{
pp = plAccessorial1;
}
#region ÿ²ãÂ¥¼àÊÓ»­Ãæ
foreach (Button ctrl in pp.Controls.OfType<Button>())
{
if (ctrl.Enabled == false) continue;
device = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(ctrl.Tag));
//if (device.DeviceIndex.ToString().IndexOf("13") == 0) continue;
//if (device.DeviceIndex.ToString().IndexOf("11") == 0) continue;
if (device == null)
{//20100108
if (tsStatus.Text.IndexOf(ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!") < 0)
{
tsStatus.ForeColor = Color.Red;
this.tsStatus.Text += ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!";
}
continue;
}
#region ¶¯»­
if (device.DeviceKind == 1)
{//¶Ñ¶â»ú
//double a = 2.9423;//3.9423=(49-41.1153)/2(58:¶Ñ¶â»úͼÉÏ¿í¶È£¬44.1152£ºÁ½Áлõ¼ÜͼÉÏ¿í¶È£¬a:×ø±êÆ«²î)
//ctrl.BringToFront();//add by lyj 20171122
//double startadd = 136;//»õ¼ÜÆðÊ¼×ø±ê
//double width = 22.025;//881/40=22.025 £¨µ¥Áлõ¼Ü¿í¶È£©
//int locationX = 1;
//int locationY = 75;//µÚÒ»ÏïµÀ¶Ñ¶â»úµÄ×Ý×ø±ê
//int differY = 115;//ÏïµÀ¼äµÄ²îÖµ
//int boxHeight = 9;//̽ÎïboxµÄ¸ß¶È
//int daochaLocationX = 94;
//int daochaLocationY = 151;
//int daochaLocationDifferY = 115;
//if (device.XCoor == 0)
//{
// locationX = 1010;
//}
//else
//{
// locationX = (int)(startadd + 881 - 13.5 - 25 - width * (device.XCoor - 1));
//}
#region ¶Ñ¶â»úʵʱÏÔʾ
if (device.DeviceKind == 1)
{
//ctrl.BringToFront();//add by lyj 20171122
//double boardwidth = 12.0921;//919/76=22.025 £¨µ¥Áлõ¼Ü¿í¶È£©
//int boardlocationX = 1;
//int boardlocationY1=1;
//int boardlocationY2 = 1;
//int boardlocationY3 = 1;
//int boardlocationY4 = 1;
//int boardlocationY5 = 1;
//int boarddifferY = 42;//ÏïµÀ¼äµÄ²îÖµ
//int boardboxHeight = 11;//̽ÎïboxµÄ¸ß¶È
//int boardboxWidth = 14;//̽ÎïboxµÄ¿í¶È¶È
int iStartColum = 2;
int iEndColum = 37;
//device.XCoor = 1;
// device.XCoor = 38;
// device.YCoor = 1;
//device.XCoor = DateTime.Now.Second % 38 + 1;
if ((device.XCoor == 0) || device.YCoor == 0)
{
switch (device.DeviceIndex)
{
case 11001:
stack1.Location =
new Point(
905, 596);
tw1.Location = new Point(stack1.Location.X + 19, stack1.Location.Y + 10);
break;
case 11002:
stack2.Location =
new Point(
905, 320);
tw2.Location = new Point(stack2.Location.X + 19, stack2.Location.Y + 10);
break;
case 11003:
stack3.Location =
new Point(
905,165);
tw3.Location = new Point(stack3.Location.X + 19, stack3.Location.Y + 10);
break;
}
}
else //¾ù²»Îª0
{
//Ê×ÏÈÅжÏX=1ʱºò
if (device.XCoor == 1)
{
switch (device.DeviceIndex)
{
case 11001:
stack1.Location =
new Point(
905, 596);
tw1.Location = new Point(stack1.Location.X + 13, stack1.Location.Y + 8);
break;
case 11002:
stack2.Location =
new Point(
905,320);
tw2.Location = new Point(stack2.Location.X + 13, stack2.Location.Y + 8);
break;
case 11003:
stack3.Location =
new Point(
905, 165);
tw3.Location = new Point(stack3.Location.X + 13, stack3.Location.Y + 8);
break;
}
}
else if (device.XCoor == 38)
{
switch (device.DeviceIndex)
{
case 11001:
stack1.Location =
new Point(
475, 596);
tw1.Location = new Point(stack1.Location.X + 13, stack1.Location.Y + 8);
break;
case 11002:
stack2.Location =
new Point(
475, 320);
tw2.Location = new Point(stack2.Location.X + 13, stack2.Location.Y + 8);
break;
case 11003:
stack3.Location =
new Point(
475, 165);
tw3.Location = new Point(stack3.Location.X + 13, stack3.Location.Y + 8);
break;
}
}
else
{
switch (device.DeviceIndex)
{
case 11001:
stack1.Location =
new Point(
905 - (430 - 6) * (device.XCoor - iStartColum) /
(iEndColum - iStartColum),596);
tw1.Location = new Point(stack1.Location.X + 13, stack1.Location.Y + 8);
break;
case 11002:
stack2.Location =
new Point(
905 - (430 - 6) * (device.XCoor - iStartColum) /
(iEndColum - iStartColum), 320);
tw2.Location = new Point(stack2.Location.X + 13, stack2.Location.Y + 8);
break;
case 11003:
stack3.Location =
new Point(
905 - (430 - 6) * (device.XCoor - iStartColum) /
(iEndColum - iStartColum), 165);
tw3.Location = new Point(stack3.Location.X + 13, stack3.Location.Y + 8);
break;
}
}
}
}
#endregion
}
#endregion
#region 20210402_ÉϺ£êɵú£¬´©Ëó°å³äµç״̬
int iRunState = device.RunState;
#endregion
#region ÉèÖÃÉ豸״̬
if (device.DeviceIndex.ToString().StartsWith("151"))
{
switch (iRunState)
{
case 0:
ctrl.BackColor = Color.LightSkyBlue;//À¶É«Èë¿â
ctrl.Text = "Èë¿âģʽ";
break;
case 1:
ctrl.BackColor = Color.Yellow;//»ÆÉ«³ö¿â
ctrl.Text = "³ö¿âģʽ";
break;
}
}
//else if (device.DeviceIndex.ToString().StartsWith("300")) {
// switch (iRunState)
// {
// }
//}
else if (device.DeviceIndex.ToString().StartsWith("300"))
{
switch (iRunState)
{
case 0:
ctrl.BackColor = Color.Gray;//ÎÞ
break;
case 1:
ctrl.BackColor = Color.Green;//È¡»õÖÐ(È¡»õÉêÇë)
break;
case 2:
ctrl.BackColor = Color.LightSkyBlue;//È¡»õÍê³É
break;
case 3:
ctrl.BackColor = Color.Gray;//ÎÞ
break;
case 4:
ctrl.BackColor = Color.Green;//·Å»õÖÐ(·Å»õÉêÇë)
break;
case 5:
ctrl.BackColor = Color.LightSkyBlue;//·Å»õÍê³É
break;
case 6:
ctrl.BackColor = Color.Orange;//È¡»õÉêÇë
break;
case 7:
ctrl.BackColor = Color.Orange;//·Å»õÉêÇë
break;
case 9:
ctrl.BackColor = Color.Gray;//AGVÀ뿪
break;
}
#region AGVÈ¡»õɨÂëÒì³£Ìáʾ
if ((device.DeviceIndex == 30003 || device.DeviceIndex == 30004 || device.DeviceIndex == 30005))
{
bar1 = dbo.ExceSQL($"select F_AGVStatus,F_AGVTaskBarCode,F_DeviceIndex from T_AGVIOStation where F_PLCOtherDevice={device.DeviceIndex}").Tables[0].DefaultView;
bar2 = dbo.ExceSQL($"select F_BarCode from T_Base_PLC_Ask where F_BindingDevice={bar1[0]["F_DeviceIndex"]}").Tables[0].DefaultView;
var deviceStation = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(bar1[0]["F_DeviceIndex"]));
if (bar2[0]["F_BarCode"].ToString() == "111111111" || bar2[0]["F_BarCode"].ToString() == "000000000") {
ctrl.BackColor = Color.Red;
if (device.DeviceIndex == 30003)
{
Converyor12031tips.Visible = true;
}
else if (device.DeviceIndex == 30004)
{
Converyor12044tips.Visible = true;
}
else if (device.DeviceIndex == 30005)
{
Converyor12051tips.Visible = true;
}
}
else if (bar1[0]["F_AGVStatus"].ToString() == "6" && bar1[0]["F_AGVTaskBarCode"].ToString() != bar2[0]["F_BarCode"].ToString() && deviceStation.SplitByte_0 == 1)
{
ctrl.BackColor = Color.Red;
if (device.DeviceIndex == 30003)
{
Converyor12031tips.Visible = true;
}
else if (device.DeviceIndex == 30004)
{
Converyor12044tips.Visible = true;
}
else if (device.DeviceIndex == 30005)
{
Converyor12051tips.Visible = true;
}
}
else
{
if (device.DeviceIndex == 30003)
{
Converyor12031tips.Visible = false;
}
else if (device.DeviceIndex == 30004)
{
Converyor12044tips.Visible = false;
}
else if (device.DeviceIndex == 30005)
{
Converyor12051tips.Visible = false;
}
}
}
else
{
if (device.DeviceIndex == 30003)
{
Converyor12031tips.Visible = false;
}
else if (device.DeviceIndex == 30004)
{
Converyor12044tips.Visible = false;
}
else if (device.DeviceIndex == 30005)
{
Converyor12051tips.Visible = false;
}
}
#endregion
}
else
{
switch (iRunState)
{
//¿ÕÏÐ
case 0:
if (device.DeviceKind == 1)
{
ctrl.BackColor = Color.Orange;
}
else
{
ctrl.BackColor = Color.LightSkyBlue; ;
}
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:
ctrl.BackColor = Color.SeaGreen;//MediumOrchid;
break;
case 6:
ctrl.BackColor = Color.Aqua;
break;
}
#region ¶Ñ¶â»úɨÂëÒì³£Ìáʾ
//devicestation1 = dbo.ExceSQL($"select F_ManTaskReserve from T_Base_Device where F_DeviceIndex={device.DeviceIndex}").Tables[0].DefaultView;
if (device.DeviceKind == 1 && iRunState == 0 && device.SplitByte_0 == 1)
{
var FManTaskReserve = dbo.ExceSQL($"select F_ManTaskReserve from T_Base_Device where F_DeviceIndex={device.DeviceIndex} ").Tables[0].DefaultView;
if (FManTaskReserve[0]["F_ManTaskReserve"].ToString() != "" && FManTaskReserve[0]["F_ManTaskReserve"].ToString().Length > 1)
{
bar1 = dbo.ExceSQL($"select FPALLETBARCODE from T_Manage_Task where FID={FManTaskReserve[0]["F_ManTaskReserve"].ToString().Substring(1)}").Tables[0].DefaultView;
bar2 = dbo.ExceSQL($"select F_BarCode from T_Base_PLC_Ask where F_BindingDevice={device.DeviceIndex.ToString()}").Tables[0].DefaultView;
if (bar1[0]["FPALLETBARCODE"].ToString() != bar2[0]["F_BarCode"].ToString())
{
ctrl.BackColor = Color.Red;
if (device.DeviceIndex == 11001)
{
Converyor11001tips.Visible = true;
}
else if (device.DeviceIndex == 11002)
{
Converyor11002tips.Visible = true;
}
else if (device.DeviceIndex == 11003)
{
Converyor11003tips.Visible = true;
}
}
else
{
if (device.DeviceIndex == 11001)
{
Converyor11001tips.Visible = false;
}
else if (device.DeviceIndex == 11002)
{
Converyor11002tips.Visible = false;
}
else if (device.DeviceIndex == 11003)
{
Converyor11003tips.Visible = false;
}
}
}
}
else
{
if (device.DeviceIndex == 11001)
{
Converyor11001tips.Visible = false;
}
else if (device.DeviceIndex == 11002)
{
Converyor11002tips.Visible = false;
}
else if (device.DeviceIndex == 11003)
{
Converyor11003tips.Visible = false;
}
}
#endregion
}
#endregion
#region É豸±»½ûÓÃ
//richar.liu20140806
if (dvJY.Find(device.DeviceIndex) >= 0)
{
ctrl.BackColor = Color.Maroon;
}
#endregion
#region Èë¿âɨÂëÒì³£Ìáʾ
if (device.DeviceIndex.ToString() == "13101" || device.DeviceIndex.ToString() == "13103" || device.DeviceIndex.ToString() == "13104" || device.DeviceIndex.ToString() == "13105")
{
bar1 = dbo.ExceSQL($" select top 1 CONTROL_APPLY_REMARK,STOCK_BARCODE, CREATE_TIME,DEVICE_CODE from IO_CONTROL_APPLY_HIS where DEVICE_CODE ='{device.DeviceIndex}' order by CREATE_TIME desc").Tables[0].DefaultView;
if (bar1.Count > 0)
{
if (bar1[0]["CONTROL_APPLY_REMARK"].ToString() != null && bar1[0]["CONTROL_APPLY_REMARK"].ToString() != "")
{
// bool times = DateTime.TryParse( bar1[0]["CREATE_TIME"].ToString(),out DateTime time);
String erro = bar1[0]["CREATE_TIME"].ToString().Substring(11) + ":" + bar1[0]["CONTROL_APPLY_REMARK"].ToString();
if (device.DeviceIndex == 13101)
{
back1.Text = erro;
}
else if (device.DeviceIndex == 13103)
{
back2.Text = erro;
}
else if (device.DeviceIndex == 13104)
{
back3.Text = erro;
}
else if (device.DeviceIndex == 13105)
{
back4.Text = erro;
}
}
else
{
String erro = "";
if (device.DeviceIndex == 13101)
{
back1.Text = erro;
}
else if (device.DeviceIndex == 13103)
{
back2.Text = erro;
}
else if (device.DeviceIndex == 13104)
{
back3.Text = erro;
}
else if (device.DeviceIndex == 13105)
{
back4.Text = erro;
}
}
}
}
#endregion
}
#region »õÎï̽²â
foreach (TextBox ctrl in pp.Controls.OfType<TextBox>())
{
DS = ctrl.Tag.ToString().Split(dd);
int devicebyte = 0; int devbit = 0;
int.TryParse(DS[0], out devicebyte);
int.TryParse(DS[1], out devbit);
device = Model.CGetInfo.GetDeviceInfo(devicebyte);
if (device == null)
{//20100108
if (tsStatus.Text.IndexOf(ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!") < 0)
{
tsStatus.ForeColor = Color.Red;
this.tsStatus.Text += ctrl.Name + "¿Ø¼þ¶ÔÓ¦µÄÉ豸Ë÷Òý£º" + ctrl.Tag + "ÔÚÊý¾Ý¿âûÓмǼ!";
}
continue;
}
switch (devbit)
{
case 0:
ctrl.Visible = device.SplitByte_0 == 1 ? true : false;
break;
case 1:
ctrl.Visible = device.SplitByte_1 == 1 ? true : false;
break;
case 2:
ctrl.Visible = device.SplitByte_2 == 1 ? true : false;
break;
case 3:
ctrl.Visible = device.SplitByte_3 == 1 ? true : false;
break;
case 4:
ctrl.Visible = device.SplitByte_4 == 1 ? true : false;
break;
case 5:
ctrl.Visible = device.SplitByte_5 == 1 ? true : false;
break;
case 6:
ctrl.Visible = device.SplitByte_6 == 1 ? true : false;
ctrl.BackColor = Color.Goldenrod;
break;
case 7:
ctrl.Visible = device.SplitByte_7 == 1 ? true : false;
break;
}
ctrl.BringToFront();
}
#endregion
var a = 1;
#region Âß¼­ÓÐÎïÏÔʾ
foreach (RadioButton ctrl in pp.Controls.OfType<RadioButton>())
{
//20100108DataView dvh;
dv = dbo.ExceSQL("SELECT F_DeviceIndex FROM T_Base_Device WHERE (F_DeviceIndex = " + ctrl.Tag + ") AND (F_HaveGoods >0)").Tables[0].DefaultView;
if (dv.Count > 0)
{
ctrl.Visible = true;
ctrl.BackColor = Color.Blue;
}
else
{
ctrl.Visible = false;
}
}
#endregion
#region ¼±Í£°´Å¥ÏÔʾ
foreach (PictureBox ctrl in pp.Controls.OfType<PictureBox>())
{
//20100108DataView dvh;
// string aa = ctrl.Name;
// int a = 0;
//string aaa= ctrl.Tag.ToString();
// //if(ctrl.Enabled ==true)
if (ctrl.Tag != null && !ctrl.Tag.ToString().StartsWith("190"))
{
if (!string.IsNullOrEmpty(ctrl.Tag.ToString()))
{
//if (int.TryParse(ctrl.Tag.ToString(), out a) == true)
//{
dv = dbo.ExceSQL("SELECT F_DeviceIndex FROM T_Base_Device WHERE (F_DeviceIndex = " + ctrl.Tag + ")").Tables[0].DefaultView;
if (dv.Count > 0)
{
device = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(ctrl.Tag));
if (device.SplitByte_6 == 0) // °´Ï°´Å¥
{
ctrl.Image = wcfControlMonitorClient.Properties.Resources.stop_1;
}
else //û°´ÏÂ
{
ctrl.Image = wcfControlMonitorClient.Properties.Resources.stop_0;
}
}
//}
}
}
else {
if (!string.IsNullOrEmpty(ctrl.Tag.ToString()))
{
int runstate= Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(ctrl.Tag)).RunState;
if (runstate == 1)
{
ctrl.Visible = true;
}
else if (runstate == 0) {
ctrl.Visible = false;
}
}
}
}
#endregion
#endregion
}
}
catch (Exception ex)
{//20100108
if (tsStatus.Text.IndexOf("ˢнçÃæ¶¯»­Ê±£º" + ex.Message) < 0)
{
tsStatus.ForeColor = Color.Red;
this.tsStatus.Text += "ˢнçÃæ¶¯»­Ê±£º" + ex.Message;
}
}
finally
{//20100108
TimeSpan ts1 = DateTime.Now.TimeOfDay;
device = null;
this.ResumeLayout();//richard.liu20140806
}
}
private void ctrl_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
_deviceStatus.DeviceIndex = Convert.ToInt32(btn.Tag);
_deviceStatus.ShowDialog();
}
private void Btn_MouseEnter(object sender, EventArgs e)
{
int deviceindex;
string[] DS; char[] dd = new char[1] { '.' };
string msg = (sender as Control).Tag.ToString();
DS = msg.Split(dd);
if (DS.Length > 0)
{
if (int.TryParse(DS[0], out deviceindex))
{
devinfo = Model.CGetInfo.GetDeviceInfo(deviceindex);
if (devinfo != null)
{
msg = devinfo.DeviceName;
}
}
}
toolTip_DeviceIndex.SetToolTip(sender as Control, msg);
}
private void ctrl_ClickLabel(object sender, EventArgs e)
{
Label label = (Label)sender;
_deviceStatus.DeviceIndex = Convert.ToInt32(label.Tag);
_deviceStatus.ShowDialog();
}
private void FrmControlMonitor_Load(object sender, EventArgs e)
{
try
{
#region Ìí¼ÓÊäËÍ»ú¡¢´©Ë󳵺ͶѶâ»úµÄµ¥»÷ʼþ
//foreach (Control ctrl in this.plAccessorial2.Controls)
//{
// if ((ctrl.GetType().ToString() == "System.Windows.Forms.Button") && (ctrl.Tag != null))
// {
// ctrl.Click += new EventHandler(ctrl_Click);
// ctrl.MouseEnter += new EventHandler(Btn_MouseEnter);
// }
// //if ((ctrl.GetType().ToString() == "System.Windows.Forms.Label") && (ctrl.Tag != null) && (ctrl.ForeColor == Color.Red))
// //{
// // ctrl.Click += new EventHandler(ctrl_ClickLabel);
// // ctrl.MouseEnter += new EventHandler(Btn_MouseEnter);
// //}
// //if ((ctrl.GetType().ToString() == "System.Windows.Forms.PictureBox") && (ctrl.Tag != null) && (ctrl.Enabled == true))
// //{
// // ctrl.MouseEnter += new EventHandler(Btn_MouseEnter);
// //}
//}
foreach (Control ctrl in this.plAccessorial1.Controls)
{
if ((ctrl.GetType().ToString() == "System.Windows.Forms.Button") && (ctrl.Tag != null))
{
ctrl.Click += new EventHandler(ctrl_Click);
ctrl.MouseEnter += new EventHandler(Btn_MouseEnter);
}
if ((ctrl.GetType().ToString() == "System.Windows.Forms.Label") && (ctrl.Tag != null) && (ctrl.ForeColor == Color.Red))
{
ctrl.Click += new EventHandler(ctrl_ClickLabel);
ctrl.MouseEnter += new EventHandler(Btn_MouseEnter);
}
//if ((ctrl.GetType().ToString() == "System.Windows.Forms.Label") && (ctrl.Tag != null) && (ctrl.BackColor == Color.LightSteelBlue))
//{
// ctrl.MouseEnter += new EventHandler(Btn_MouseEnter);
//}
if ((ctrl.GetType().ToString() == "System.Windows.Forms.PictureBox") && (ctrl.Tag != null) && (ctrl.Enabled == true)&&!ctrl.Tag.ToString().StartsWith("190"))
{
ctrl.Click += new EventHandler(ctrl_ClickPic);//Ãñº½¶þËù
ctrl.MouseEnter += new EventHandler(Btn_MouseEnter);
}
}
#endregion
}
catch (Exception ex)
{
throw (ex);
}
}
private void ctrl_ClickPic(object sender, EventArgs e)//½ðºÅ picturebox µã»÷Òª¸øµçÆøÐ´×Ö½Ú
{
try
{
if (MessageBox.Show("ÄãÈ·¶¨ÒªÐÞ¸ÄÉ豸½ûÓÃ״̬Âð£¿", "È·ÈÏ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
PictureBox btn = (PictureBox)sender;
int DeviceIndex = Convert.ToInt32(btn.Tag);
Model.MDevice device;
device = Model.CGetInfo.GetDeviceInfo(DeviceIndex);
string bost = "";
if (device.SplitByte_6 == 1)
{
bost = "0"; //
}
else
{
bost = "1";//
}
string errtxt = string.Empty;
var isOK=CStaticClass.WcfControl.WriteDBData(out errtxt, DeviceIndex, "DB1", bost);
if (!isOK)
{
MessageBox.Show("·¢ËÍʧ°Ü£¬·µ»ØÏûÏ¢:"+errtxt);
}
}
else
{
}
}
catch (Exception ex)
{
}
}
private void tsStatus_ForeColorChanged(object sender, EventArgs e)
{
FrmErrorMessage.FormInstance.NewForeColor((sender as TextBox).ForeColor);
}
private void tsStatus_TextChanged(object sender, EventArgs e)
{
//throw new System.Exception("The method or operation is not implemented.");
string msg = (sender as TextBox).Text;
if (msg != "")
{
//msg = string.Format("{0}\r\n", msg);
//msg=msg+"\r\n";
CommonClassLib.CCarryConvert.WriteDarkCasket("Error", msg, "", "", "");
FrmErrorMessage.FormInstance.NewMessage(msg);
}
}
private void tabPage1_Click(object sender, EventArgs e)
{
}
private void button6_Click(object sender, EventArgs e)
{
string enddevices, startsdevices, strinfo = string.Empty;//²ð¶âÈÎÎñÖÕµã
string sqlstr = string.Empty;
DataView dvdv = new DataView();
int EndDevice = 12018;
sqlstr = string.Format("select * from T_Base_TaskCount where F_DeviceIndex={0}", EndDevice);//²éÕÒÖÕµãÉ豸¶ÔÓ¦µÄ³ö¿âÈÎÎñ»ñÈ¡ÊýÁ¿ºÍÖ´ÐÐÊýÁ¿
dvdv = dbo.ExceSQL(sqlstr).Tables[0].DefaultView;
if (dvdv.Count > 0)
{
int getcount, execount;
getcount = Convert.ToInt32(dvdv[0]["F_MAXCOUNT"]);
execount = Convert.ToInt32(dvdv[0]["F_EXECOUNT"]);
//checkdevice = Convert.ToInt32(dvdv[0]["F_CHECKDEVICE"]);//
enddevices = Convert.ToString(dvdv[0]["F_CHECKENDDEVICE"]);//ÒªÅжÁÊÇ·ñ´æÔÚ¸ÃÖÕµãµÄÉ豸
startsdevices = Convert.ToString(dvdv[0]["F_CHECKSTARTDEVICE"]);//ÒªÅжÏÊÇ·ñ´æÔÚ¸ÃÆðµãµÄÉ豸
if (startsdevices != "0" || enddevices != "0")//±íʾͬʱִÐÐʱ
{
sqlstr = string.Format("SELECT FID,F_ManageTaskKindIndex FROM T_Manage_Task WHERE (FSTARTDEVICE in({0})) OR (FENDDEVICE in({1}))", startsdevices, enddevices);
dvdv = dbo.ExceSQL(sqlstr).Tables[0].DefaultView;
if (dvdv.Count > 0)//´æÔÚÏ໥¸ÉÈŵijöÈë¿âÈÎÎñʱ£¬°´³ö¿âÊýÁ¿ÏÞÖÆ
{
// outcount = execount;
}
else//Ö»´æÔÚµ±Ç°ÖÕµãµÄÈÎÎñʱ£¬°´»ñÈ¡ÊýÁ¿ÏÞÖÆ£¬Ò»°ãÇé¿ö »ñÈ¡ÊýÁ¿Òª´óÓÚÖ´ÐÐÊýÁ¿
{
//outcount = getcount;
}
}
}
}
private void button6_Click_1(object sender, EventArgs e)
{
//bool a = GetTransDeviceIfFull("11003;11004;11005");
}
public bool GetTransDeviceIfFull(string Devices)
{
try
{
char[] cc = new char[1] { ';' };
string[] sp;
sp = Devices.Split(cc);
int count = sp.Length;//É豸ÊýÁ¿
int goodscount = 0;//»õÎïÊýÁ¿
for (int i = 0; i < count; i++)
{
int deviceindex = Convert.ToInt32(sp[i]);
devinfo = Model.CGetInfo.GetDeviceInfo(deviceindex);
if (devinfo != null)
{
goodscount += devinfo.SplitByte_0;
goodscount += devinfo.SplitByte_1;
}
}
if (goodscount >= count)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
return false;
}
}
private void refreshData(object sender, EventArgs e)
{
try
{
if (CStaticClass.WcfControl == null) return;
CStaticClass.WcfControl.BeginSendAllDeviceStates(CStaticClass.client.devlist[0].DeviceIndex, new AsyncCallback(CStaticClass.client.SendAllDeviceStatesCallback), null);
}
catch (Exception ex) {
}
}
}
}