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 _d eviceStatus = new FrmDeviceStatus ( ) ;
DBFactory . DBOperator dbo = CStaticClass . dbo ;
DBFactory . DBOperator dbo1 = CStaticClass . dboM ;
private static FrmControlMonitor _f ormInstance ;
public static FrmControlMonitor FormInstance
{
get
{
if ( _f ormInstance = = null )
{
_f ormInstance = new FrmControlMonitor ( ) ;
}
return _f ormInstance ;
}
set { _f ormInstance = value ; }
}
public FrmControlMonitor ( )
{
InitializeComponent ( ) ;
_f ormInstance = 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;//�������IJ�ֵ
//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;//�������IJ�ֵ
//int boardboxHeight = 11;//̽��box�ĸ߶�
//int boardboxWidth = 14;//̽��box�Ŀ��ȶ�
int iStartColum = 2 ;
int iEndColum = 3 7 ;
//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 1 1 0 0 1 :
stack1 . Location =
new Point (
9 0 5 , 5 9 6 ) ;
tw1 . Location = new Point ( stack1 . Location . X + 1 9 , stack1 . Location . Y + 1 0 ) ;
break ;
case 1 1 0 0 2 :
stack2 . Location =
new Point (
9 0 5 , 3 2 0 ) ;
tw2 . Location = new Point ( stack2 . Location . X + 1 9 , stack2 . Location . Y + 1 0 ) ;
break ;
case 1 1 0 0 3 :
stack3 . Location =
new Point (
9 0 5 , 1 6 5 ) ;
tw3 . Location = new Point ( stack3 . Location . X + 1 9 , stack3 . Location . Y + 1 0 ) ;
break ;
}
}
else //����Ϊ0
{
//�����ж�X=1ʱ��
if ( device . XCoor = = 1 )
{
switch ( device . DeviceIndex )
{
case 1 1 0 0 1 :
stack1 . Location =
new Point (
9 0 5 , 5 9 6 ) ;
tw1 . Location = new Point ( stack1 . Location . X + 1 3 , stack1 . Location . Y + 8 ) ;
break ;
case 1 1 0 0 2 :
stack2 . Location =
new Point (
9 0 5 , 3 2 0 ) ;
tw2 . Location = new Point ( stack2 . Location . X + 1 3 , stack2 . Location . Y + 8 ) ;
break ;
case 1 1 0 0 3 :
stack3 . Location =
new Point (
9 0 5 , 1 6 5 ) ;
tw3 . Location = new Point ( stack3 . Location . X + 1 3 , stack3 . Location . Y + 8 ) ;
break ;
}
}
else if ( device . XCoor = = 3 8 )
{
switch ( device . DeviceIndex )
{
case 1 1 0 0 1 :
stack1 . Location =
new Point (
4 7 5 , 5 9 6 ) ;
tw1 . Location = new Point ( stack1 . Location . X + 1 3 , stack1 . Location . Y + 8 ) ;
break ;
case 1 1 0 0 2 :
stack2 . Location =
new Point (
4 7 5 , 3 2 0 ) ;
tw2 . Location = new Point ( stack2 . Location . X + 1 3 , stack2 . Location . Y + 8 ) ;
break ;
case 1 1 0 0 3 :
stack3 . Location =
new Point (
4 7 5 , 1 6 5 ) ;
tw3 . Location = new Point ( stack3 . Location . X + 1 3 , stack3 . Location . Y + 8 ) ;
break ;
}
}
else
{
switch ( device . DeviceIndex )
{
case 1 1 0 0 1 :
stack1 . Location =
new Point (
9 0 5 - ( 4 3 0 - 6 ) * ( device . XCoor - iStartColum ) /
( iEndColum - iStartColum ) , 5 9 6 ) ;
tw1 . Location = new Point ( stack1 . Location . X + 1 3 , stack1 . Location . Y + 8 ) ;
break ;
case 1 1 0 0 2 :
stack2 . Location =
new Point (
9 0 5 - ( 4 3 0 - 6 ) * ( device . XCoor - iStartColum ) /
( iEndColum - iStartColum ) , 3 2 0 ) ;
tw2 . Location = new Point ( stack2 . Location . X + 1 3 , stack2 . Location . Y + 8 ) ;
break ;
case 1 1 0 0 3 :
stack3 . Location =
new Point (
9 0 5 - ( 4 3 0 - 6 ) * ( device . XCoor - iStartColum ) /
( iEndColum - iStartColum ) , 1 6 5 ) ;
tw3 . Location = new Point ( stack3 . Location . X + 1 3 , 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 = = 3 0 0 0 3 | | device . DeviceIndex = = 3 0 0 0 4 | | device . DeviceIndex = = 3 0 0 0 5 ) )
{
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 = = 3 0 0 0 3 )
{
Converyor12031tips . Visible = true ;
}
else if ( device . DeviceIndex = = 3 0 0 0 4 )
{
Converyor12044tips . Visible = true ;
}
else if ( device . DeviceIndex = = 3 0 0 0 5 )
{
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 = = 3 0 0 0 3 )
{
Converyor12031tips . Visible = true ;
}
else if ( device . DeviceIndex = = 3 0 0 0 4 )
{
Converyor12044tips . Visible = true ;
}
else if ( device . DeviceIndex = = 3 0 0 0 5 )
{
Converyor12051tips . Visible = true ;
}
}
else
{
if ( device . DeviceIndex = = 3 0 0 0 3 )
{
Converyor12031tips . Visible = false ;
}
else if ( device . DeviceIndex = = 3 0 0 0 4 )
{
Converyor12044tips . Visible = false ;
}
else if ( device . DeviceIndex = = 3 0 0 0 5 )
{
Converyor12051tips . Visible = false ;
}
}
}
else
{
if ( device . DeviceIndex = = 3 0 0 0 3 )
{
Converyor12031tips . Visible = false ;
}
else if ( device . DeviceIndex = = 3 0 0 0 4 )
{
Converyor12044tips . Visible = false ;
}
else if ( device . DeviceIndex = = 3 0 0 0 5 )
{
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 = = 1 1 0 0 1 )
{
Converyor11001tips . Visible = true ;
}
else if ( device . DeviceIndex = = 1 1 0 0 2 )
{
Converyor11002tips . Visible = true ;
}
else if ( device . DeviceIndex = = 1 1 0 0 3 )
{
Converyor11003tips . Visible = true ;
}
}
else
{
if ( device . DeviceIndex = = 1 1 0 0 1 )
{
Converyor11001tips . Visible = false ;
}
else if ( device . DeviceIndex = = 1 1 0 0 2 )
{
Converyor11002tips . Visible = false ;
}
else if ( device . DeviceIndex = = 1 1 0 0 3 )
{
Converyor11003tips . Visible = false ;
}
}
}
}
else
{
if ( device . DeviceIndex = = 1 1 0 0 1 )
{
Converyor11001tips . Visible = false ;
}
else if ( device . DeviceIndex = = 1 1 0 0 2 )
{
Converyor11002tips . Visible = false ;
}
else if ( device . DeviceIndex = = 1 1 0 0 3 )
{
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 ( 1 1 ) + ":" + bar1 [ 0 ] [ "CONTROL_APPLY_REMARK" ] . ToString ( ) ;
if ( device . DeviceIndex = = 1 3 1 0 1 )
{
back1 . Text = erro ;
}
else if ( device . DeviceIndex = = 1 3 1 0 3 )
{
back2 . Text = erro ;
}
else if ( device . DeviceIndex = = 1 3 1 0 4 )
{
back3 . Text = erro ;
}
else if ( device . DeviceIndex = = 1 3 1 0 5 )
{
back4 . Text = erro ;
}
}
else
{
String erro = "" ;
if ( device . DeviceIndex = = 1 3 1 0 1 )
{
back1 . Text = erro ;
}
else if ( device . DeviceIndex = = 1 3 1 0 3 )
{
back2 . Text = erro ;
}
else if ( device . DeviceIndex = = 1 3 1 0 4 )
{
back3 . Text = erro ;
}
else if ( device . DeviceIndex = = 1 3 1 0 5 )
{
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 ;
_d eviceStatus . DeviceIndex = Convert . ToInt32 ( btn . Tag ) ;
_d eviceStatus . 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 ;
_d eviceStatus . DeviceIndex = Convert . ToInt32 ( label . Tag ) ;
_d eviceStatus . 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 = 1 2 0 1 8 ;
sqlstr = string . Format ( "select * from T_Base_TaskCount where F_DeviceIndex={0}" , EndDevice ) ; //�����յ��豸��Ӧ�ij���������ȡ������ִ������
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 ) {
}
}
}
}