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.

3648 lines
201 KiB

using System;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using CommonLib;
using System.Speech.Synthesis;
using System.ServiceModel;
using System.Collections.Generic;
using System.Collections;
namespace wcfControlMonitorClient
{
public partial class FrmClient : Form, WcfControlMonitor.IControlMonitorCallback
{
//protected override CreateParams CreateParams
//{
// get
// {
// CreateParams cp = base.CreateParams;
// cp.ExStyle |= 0x02000000;//WS_CLIPCHILDREN 两个窗体叠加时,重叠部分不重绘
// return cp;
// }
//}
int timersum = 0;//20150103增加断网恢复
Model.MDevice devinfo;
FrmDeviceStatus _deviceStatus = new FrmDeviceStatus();
FrmWorkstationStatus _worstation = new FrmWorkstationStatus();
StringBuilder sql = new StringBuilder();
DBFactory.DBOperator dbo = CStaticClass.dbo;
DBFactory.DBOperator dbo1 = new DBFactory.DBOperator();
string EmStop = "stop11201, stop11202, stop11203, stop11204,11003,11004,11006,11008,11010";
//string[] EmStop = new string[40] { "stop15401", "stop15402", "stop15403", "stop11201", "stop11202", "stop11203", "stop11204", "stop11205", "stop11206", "stop11207" };
//SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync;
//public SpVoice Voice = new SpVoice();
private static SpeechSynthesizer speak = new SpeechSynthesizer();
public Model.MDevice[] devlist;
public int devsn = 0;
private static FrmClient _formInstance;
public static FrmClient FormInstance
{
get
{
if (_formInstance == null)
{
_formInstance = new FrmClient();
}
return _formInstance;
}
set { _formInstance = value; }
}
#region 控件大小随窗体大小等比例缩放
private float x;//定义当前窗体的宽度
private float y;//定义当前窗体的高度
private void setControls_Location_Size(Control cons)
{
foreach (Control con in cons.Controls)
{
con.AccessibleName = con.Width + ";" + con.Height + ";" + con.Left + ";" + con.Top + ";" + con.Font.Size;
if (con.Controls.Count > 0)
{
setControls_Location_Size(con);
}
}
}
private void setControls(float newx, float newy, Control cons)
{ //遍历窗体中的控件,重新设置控件的值
foreach (Control con in cons.Controls)
{ //获取控件的Tag属性值,并分割后存储字符串数组
if (con.AccessibleName != null)
{
string[] mytag = con.AccessibleName.ToString().Split(new char[] { ';' });
//根据窗体缩放的比例确定控件的值
con.Width = Convert.ToInt32(System.Convert.ToSingle(mytag[0]) * newx);//宽度
con.Height = Convert.ToInt32(System.Convert.ToSingle(mytag[1]) * newy);//高度
con.Left = Convert.ToInt32(System.Convert.ToSingle(mytag[2]) * newx);//左边距
con.Top = Convert.ToInt32(System.Convert.ToSingle(mytag[3]) * newy);//顶边距
//如果不需要字体的缩放可自行注释掉下面两行代码。
Single currentSize = System.Convert.ToSingle(mytag[4]) * newy;//字体大小
con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit);
if (con.Controls.Count > 0)
{ setControls(newx, newy, con); }
}
}
}
private void FrmClient_Resize(object sender, EventArgs e)
{
float newx = (this.Width) / x;
float newy = (this.Height) / y;
setControls(newx, newy, this);
}
//禁止通过拖动,双击标题栏改变窗体大小。
public const int WM_NCLBUTTONDBLCLK = 0xA3;
const int WM_NCLBUTTONDOWN = 0x00A1;
const int HTCAPTION = 2;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_NCLBUTTONDOWN && m.WParam.ToInt32() == HTCAPTION)
return;
if (m.Msg == WM_NCLBUTTONDBLCLK)
return;
base.WndProc(ref m);
}
#endregion
public FrmClient()
{
CommonClassLib.CCarryConvert.WriteDarkCasket("Login", "操作日志", "FrmClient()", "", "");
InitializeComponent();
x = this.Width;
y = this.Height;
setControls_Location_Size(this);
try
{
//初始化管理和调度交互状态
Model.CGetInfo.AddIOControlStatus();
Model.CGetInfo.AddDeviceKindInfo();
Model.CGetInfo.AddDeviceInfo();
Model.CGetInfo.AddDeviceErrors();
devlist = Model.CGetInfo.DeviceInfo.Values.ToArray<Model.MDevice>();
DataView dv0 = dbo.ExceSQL("SELECT distinct F_S7Connection,F_DBWGetLength FROM T_Base_Device WHERE (F_DeviceKindIndex = 28)").Tables[0].DefaultView;
if (dv0.Count > 0)
{
for (int i = 0; i < dv0.Count; i++)
{
if (CStaticClass.MutiS7ConnReturns.ContainsKey(dv0[i]["F_S7Connection"].ToString()) == false)
{
CStaticClass.MutiS7ConnReturns.Add(dv0[i]["F_S7Connection"].ToString(), new int[Convert.ToInt32(dv0[i]["F_DBWGetLength"])]);
}
}
}
CStaticClass.SystemName = CommonClassLib.AppSettings.GetValue("SystemName");
this.notifyIcon1.Text = CStaticClass.SystemName;
this.Text = CStaticClass.SystemName;
OPCClient.CCommonOPCClient.Hostname = CommonClassLib.AppSettings.GetValue("HostName");
OPCClient.CCommonOPCClient.ProgID = CommonClassLib.AppSettings.GetValue("OPCProgID");
#region 客户端订阅初始化20120428
DataView dvx;
DataView dv = dbo.ExceSQL("SELECT F_ReadSubscription, F_DeviceIndex, F_DBW2Address, F_DBWGetLength, F_S7Connection, F_SplitByte FROM T_Base_Device WHERE (F_ReadSubscription IS NOT NULL) AND (F_ReadSubscription =F_DeviceIndex) ORDER BY F_ReadSubscription").Tables[0].DefaultView;
for (int i = 0; i < dv.Count; i++)
{
dvx = dbo.ExceSQL(string.Format("SELECT (MAX(F_DBW2Address) + F_DBWGetLength) AS maxdbw2 FROM T_Base_Device WHERE (F_ReadSubscription = '{0}') AND (F_DeviceKindIndex <> 33) GROUP BY F_DBWGetLength ORDER BY maxdbw2 DESC", dv[i]["F_ReadSubscription"])).Tables[0].DefaultView;
if (dvx.Count > 0)
{
if (CStaticClass.MutiReadSubscriptionDeviceStateReturns.ContainsKey(dv[i]["F_ReadSubscription"].ToString()) == false)
{
CStaticClass.MutiReadSubscriptionDeviceStateReturns.Add(dv[i]["F_ReadSubscription"].ToString(), new int[Convert.ToInt32(dvx[0]["maxdbw2"]) - Convert.ToInt32(dv[i]["F_DBW2Address"])]);
}
}
}
dv = dbo.ExceSQL("SELECT F_ReadSubscription, F_DeviceIndex, F_DBW2Address, F_DBWGetLength, F_S7Connection, F_SplitByte FROM T_Base_Device WHERE (F_ReadSubscription IS NOT NULL) AND (F_DeviceKindIndex=33) ORDER BY F_ReadSubscription").Tables[0].DefaultView;
for (int i = 0; i < dv.Count; i++)
{
if (CStaticClass.MutiReadSubscriptionDeviceSplitReturns.ContainsKey(dv[i]["F_ReadSubscription"].ToString()) == false)
{
CStaticClass.MutiReadSubscriptionDeviceSplitReturns.Add(dv[i]["F_ReadSubscription"].ToString(), new int[Convert.ToInt32(dv[i]["F_DBWGetLength"])]);
}
}
CommonClassLib.CCarryConvert.WriteDarkCasket("Login", "操作日志", "FrmClient()-准备CreateSubscriptionGroup", "", "");
OPCClient.CCommonOPCClient.CreateSubscriptionGroup();
CommonClassLib.CCarryConvert.WriteDarkCasket("Login", "操作日志", "FrmClient()-CreateSubscriptionGroup", "", "");
OPCClient.CCommonOPCClient.UpdateDB += new CUpdateDBEventHandler(CCommon_UpdateDB);
if (OPCClient.CCommonOPCClient.OpcError != null)
{
MessageBox.Show(OPCClient.CCommonOPCClient.OpcError);
}
}
catch (Exception ex)
{
CommonClassLib.CCarryConvert.WriteDarkCasket("Login", "操作日志", "FrmClient()-catch", ex.StackTrace, ex.Message);
throw ex;
}
#endregion
}
/// <summary>
/// 客户端事件响应20120428
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void CCommon_UpdateDB(object sender, CUpdateDBChangeEventArgs e)
{
if (CStaticClass.WCFOK == true && !CStaticClass.client.IsDisposed)
{
string errtext = string.Empty;
this.BeginInvoke(new MethodInvoker(delegate()
{ DealWithDeviceState(out errtext, e.Deviceindex, e.SplitbyteValue, e.Devicestates); }));
}
}
/// <summary>
/// 客户端事件响应处理函数20120428
/// </summary>
/// <param name="errtext"></param>
/// <param name="deviceindex"></param>
/// <param name="splitbyteValue"></param>
/// <param name="devicestates"></param>
/// <returns></returns>
bool DealWithDeviceState(out string errtext, int deviceindex, byte[] splitbyteValue, byte[] devicestates)
{//deviceindex设备组代表的订阅,首先把设备组按照F_DBW2Address由小到大排序,拆分到具体每个设备
if ((devicestates == null))//(splitbyteValue == null) &&
{//20120420
errtext = OPCClient.CCommonOPCClient.OpcError;
SendMessage(string.Format("tsStatus@FrmClient.DealWithDeviceState时,订阅组:{0}发生异常,{1}!", deviceindex, errtext));
return false;
}
errtext = string.Empty; DataView dv = new DataView(); DataView dvsp = new DataView(); DataView dvbc = new DataView();
int devicebegin = 0; int DBW2Addressbegin = 0; string S7Connection = string.Empty;
int SplitByteLength = 0;
try
{
//StringBuilder sql = new StringBuilder(string.Format("SELECT F_DeviceIndex, F_DBW2Address, F_DBWGetLength, F_SplitByte,F_S7Connection FROM T_Base_Device WHERE (F_DeviceKindIndex <>33) AND (F_ReadSubscription = '{0}') AND (F_DBW2Address IS NOT NULL) ORDER BY F_DBW2Address", deviceindex));
//dv = dbo1.ExceSQL(sql.ToString()).Tables[0].DefaultView;
//if (dv.Count > 0)
//{
// devicebegin = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
// DBW2Addressbegin = Convert.ToInt32(dv[0]["F_DBW2Address"]);
// //SplitBytebegin = Convert.ToInt32(dv[0]["F_SplitByte"]);
// S7Connection = dv[0]["F_S7Connection"].ToString();
// sql = new StringBuilder(string.Format("SELECT F_DeviceIndex, F_DBW2Address, F_DBWGetLength, F_SplitByte,F_S7Connection FROM T_Base_Device WHERE (F_DeviceKindIndex =33) AND (F_ReadSubscription = '{0}') ORDER BY F_DBW2Address", deviceindex));
// dvsp = dbo1.ExceSQL(sql.ToString()).Tables[0].DefaultView;
// if (dvsp.Count > 0)
// {
// SplitByteLength = Convert.ToInt32(dvsp[0]["F_DBWGetLength"]);
// }
//}
//else
//{
// sql = new StringBuilder(string.Format("SELECT F_DeviceIndex, F_DBW2Address, F_DBWGetLength, F_SplitByte,F_S7Connection FROM T_Base_Device WHERE (F_DeviceIndex = '{0}') AND (F_DBW2Address IS NOT NULL) ORDER BY F_DBW2Address", deviceindex));
// dv = dbo1.ExceSQL(sql.ToString()).Tables[0].DefaultView;
// if (dv.Count > 0)
// {
// devicebegin = Convert.ToInt32(dv[0]["F_DeviceIndex"]);
// DBW2Addressbegin = Convert.ToInt32(dv[0]["F_DBW2Address"]);
// //SplitBytebegin = Convert.ToInt32(dv[0]["F_SplitByte"]);
// S7Connection = dv[0]["F_S7Connection"].ToString();
// sql = new StringBuilder(string.Format("SELECT F_DeviceIndex, F_DBW2Address, F_DBWGetLength, F_SplitByte,F_S7Connection FROM T_Base_Device WHERE (F_DeviceKindIndex =33) AND (F_ReadSubscription = '{0}') ORDER BY F_DBW2Address", deviceindex));
// dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
// if (dv.Count > 0)
// {
// SplitByteLength = Convert.ToInt32(dv[0]["F_DBWGetLength"]);
// }
// }
// else
// {//20120420
// errtext = string.Format("FrmClient.DealWithDeviceState时,订阅组:{0}对应的设备索引不存在!", deviceindex);
// SendMessage(string.Format("tsStatus@FrmClient.DealWithDeviceState时,订阅组:{0}对应的设备索引不存在!", deviceindex));
// return false;
// }
//}
//int tempdb2addr = 0; StringBuilder sss = new StringBuilder(); StringBuilder barcode = new StringBuilder();
if (devicestates != null)
{
Array.Copy(devicestates, CStaticClass.MutiReadSubscriptionDeviceStateReturns[deviceindex.ToString()], devicestates.Length);
//for (int di = 0; di < dv.Count; di++)
//{
// int devidx = Convert.ToInt32(dv[di]["F_DeviceIndex"]);
// devinfo = Model.CGetInfo.GetDeviceInfo(devidx);
// int taskindex= 0;
// int state = 0;
// //以下代码重新开发CStaticClass.MutiS7ConnReturns改为按照F_ReadSubscription
// if (devinfo.Dbw2Getlength>3)
// {
// tempdb2addr = Convert.ToInt32(dv[di]["F_DBW2Address"]) - DBW2Addressbegin;
// taskindex = (devicestates[tempdb2addr + 2] << 8) + devicestates[tempdb2addr + 3];
// if (devinfo.Dbw2Getlength > 1)
// {
// state = devicestates[tempdb2addr + 1];
// }
// }
// int devkind = devinfo.DeviceKind;
// if (state >= 30)
// {
// devinfo.ErrorCode = state;
// devinfo.RunState = 2;
// }
// else
// {//0,1,2
// if (state == 2)
// {
// devinfo.RunState = 5;
// }
// else
// {
// devinfo.RunState = state;
// }
// devinfo.ErrorCode = state;
// }
// if (devkind == 13 && devinfo.UnControl != "1")
// {//richard.liu20230718鸿安环穿0-1是心跳单独订阅;2是可下任务状态0:不可下命令,1:可下命令
// state = devicestates[tempdb2addr + 1] == 0 ? 1 : 0;//可下任务状态
// taskindex = (devicestates[tempdb2addr + 2] << 8) + devicestates[tempdb2addr + 3];
// }
// devinfo.TaskNo = taskindex;
// int sn = 4;//输送机光电开关位移
// if ((devinfo.DeviceKind == 1) || (devinfo.DeviceKind == 4) || (devinfo.DeviceKind == 14))
// {
// devinfo.XCoor = devicestates[tempdb2addr + 7] + (devicestates[tempdb2addr + 6] << 8) + (devicestates[tempdb2addr + 5] << 16) + (devicestates[tempdb2addr + 4] << 32);//X坐标
// if (devinfo.DeviceKind == 1)
// {
// sn = 13;//堆垛机光电开关位移
// devinfo.YCoor = devicestates[tempdb2addr + 11] + (devicestates[tempdb2addr + 10] << 8) + (devicestates[tempdb2addr + 9] << 16) + (devicestates[tempdb2addr + 8] << 32);//Y坐标
// devinfo.ZCoor = devicestates[tempdb2addr + 12];//Z相对坐标(1或2\3)
// } else
// {
// sn = 8;//直穿和环穿光电开关位移
// }
// }
// //设备开关状态
// if (devinfo.Dbw2Getlength >= 3 && devinfo.DeviceKind!=5)
// {
// devinfo.SplitByte_0 = (devicestates[tempdb2addr + sn] & 1) == 1 ? 1 : 0;
// devinfo.SplitByte_1 = (devicestates[tempdb2addr + sn] & 2) == 2 ? 1 : 0;
// devinfo.SplitByte_2 = (devicestates[tempdb2addr + sn] & 4) == 4 ? 1 : 0;
// devinfo.SplitByte_3 = (devicestates[tempdb2addr + sn] & 8) == 8 ? 1 : 0;
// devinfo.SplitByte_4 = (devicestates[tempdb2addr + sn] & 16) == 16 ? 1 : 0;
// devinfo.SplitByte_5 = (devicestates[tempdb2addr + sn] & 32) == 32 ? 1 : 0;
// devinfo.SplitByte_6 = (devicestates[tempdb2addr + sn] & 64) == 64 ? 1 : 0;
// devinfo.SplitByte_7 = (devicestates[tempdb2addr + sn] & 128) == 128 ? 1 : 0;
// int a = "123".IndexOf("123");
// }
// Model.CGetInfo.SetDeviceInfo(devinfo);
//}
int devidx = deviceindex;
devinfo = Model.CGetInfo.GetDeviceInfo(devidx);
int taskindex = 0;
int state = 0;
//以下代码重新开发CStaticClass.MutiS7ConnReturns改为按照F_ReadSubscription
if (devinfo.Dbw2Getlength > 3)
{
taskindex = (devicestates[2] << 8) + devicestates[ 3];
if (devinfo.Dbw2Getlength > 1)
{
state = devicestates[ 1];
}
}
int devkind = devinfo.DeviceKind;
if (state >= 30)
{
devinfo.ErrorCode = state;
devinfo.RunState = 2;
}
else
{//0,1,2
if (state == 2)
{
devinfo.RunState = 5;
}
else
{
devinfo.RunState = state;
}
devinfo.ErrorCode = state;
}
if (devkind == 13 && devinfo.UnControl != "1")
{//richard.liu20230718鸿安环穿0-1是心跳单独订阅;2是可下任务状态0:不可下命令,1:可下命令
state = devicestates[ 1] == 0 ? 1 : 0;//可下任务状态
taskindex = (devicestates[ 2] << 8) + devicestates[ 3];
}
devinfo.TaskNo = taskindex;
int sn = 4;//输送机光电开关位移
if ((devinfo.DeviceKind == 1) || (devinfo.DeviceKind == 4) || (devinfo.DeviceKind == 14))
{
devinfo.XCoor = devicestates[ 7] + (devicestates[ 6] << 8) + (devicestates[ 5] << 16) + (devicestates[ 4] << 32);//X坐标
if (devinfo.DeviceKind == 1)
{
sn = 13;//堆垛机光电开关位移
devinfo.YCoor = devicestates[11] + (devicestates[10] << 8) + (devicestates[ 9] << 16) + (devicestates[ 8] << 32);//Y坐标
devinfo.ZCoor = devicestates[ 12];//Z相对坐标(1或2\3)
}
else
{
sn = 8;//直穿和环穿光电开关位移
}
}
//设备开关状态
if ((devinfo.Dbw2Getlength >= 5 && devinfo.DeviceKind != 5)||(devinfo.DeviceKind == 5 && devinfo.Dbw2Getlength >= 10))
{
devinfo.SplitByte_0 = (devicestates[ sn] & 1) == 1 ? 1 : 0;
devinfo.SplitByte_1 = (devicestates[ sn] & 2) == 2 ? 1 : 0;
devinfo.SplitByte_2 = (devicestates[ sn] & 4) == 4 ? 1 : 0;
devinfo.SplitByte_3 = (devicestates[ sn] & 8) == 8 ? 1 : 0;
devinfo.SplitByte_4 = (devicestates[sn] & 16) == 16 ? 1 : 0;
devinfo.SplitByte_5 = (devicestates[ sn] & 32) == 32 ? 1 : 0;
devinfo.SplitByte_6 = (devicestates[sn] & 64) == 64 ? 1 : 0;
devinfo.SplitByte_7 = (devicestates[sn] & 128) == 128 ? 1 : 0;
}
Model.CGetInfo.SetDeviceInfo(devinfo);
}
return true;
}
catch (Exception ex)
{
SendMessage(string.Format("tsStatus@FrmClient.DealWithDeviceState时{0}", ex.StackTrace+ex.Message));
errtext = string.Format("tsStatus@FrmClient.DealWithDeviceState时{0}", ex.StackTrace + ex.Message);
return false;
}
finally
{
dv.Dispose();
dvbc.Dispose();
dvsp.Dispose();
}
}
#region wcf回调
public void SendDeviceInfo(Model.MDevice devinfo)
{
try
{
if (CStaticClass.WCFOK == false) return;
if (this.IsDisposed) return;
Model.CGetInfo.SetDeviceInfo(devinfo);
}
catch (Exception ex)
{
throw ex;
}
}
public IAsyncResult BeginSendDeviceInfo(Model.MDevice devinfo, AsyncCallback acb, object state)
{
return state as IAsyncResult;
}
public void EndSendDeviceInfo(IAsyncResult ar)
{
}
public IAsyncResult BeginSendMessage(string message, AsyncCallback acb, object state)
{
return state as IAsyncResult;
}
public void EndSendMessage(IAsyncResult ar)
{
}
public void SendMessage(string message)
{
char[] cc = new char[1] { '@' };
string[] strsplit = message.Split(cc);
if (strsplit.GetLength(0) > 1)
{//更新指定控件
if (strsplit[0] == "tsStatus")
{
tsStatus.Text = strsplit[1];
}
else if (strsplit[0] == "notifyIcon1")
{
this.BeginInvoke(new MethodInvoker(delegate()
{
notifyIcon1.BalloonTipText = strsplit[1];
notifyIcon1.ShowBalloonTip(10000, "警告:", strsplit[1],ToolTipIcon.Warning);
}));
}
}
//else
//{//刷新数据显示
// this.dgvManager.BeginInvoke(new MethodInvoker(delegate()
// {
// sql.Remove(0, sql.Length);
// sql.Append("select * from V_Manage_Task where ").Append(CStaticClass.Manstatus);
// this.dgvManager.DataSource = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
// }));
// this.dgvMonitor.BeginInvoke(new MethodInvoker(delegate()
// {
// sql.Remove(0, sql.Length);
// sql.Append("select * from V_Monitor_Task where ").Append(CStaticClass.Monstatus).Append(" order by 设备指令索引 asc ");
// this.dgvMonitor.DataSource = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
// }));
//}
}
//20140824richard
public void SendOrderMessage(Model.MonitorInfo mi)
{
this.BeginInvoke(new MethodInvoker(delegate()
{
try
{
if (CStaticClass.UserID.ToUpper() == "SA")
{
CStaticClass.Order = mi.Orderturnon;
CStaticClass.ObtainManageTask = mi.Obtaintask;
if (CStaticClass.Order == true)
{
ClickOrderTurnOn();
}
else
{
ClickOrderTurnOff();
}
if (CStaticClass.ObtainManageTask == true)
{
ClickObtainTask();
}
else
{
ClickStopObtainTask();
}
}
}
catch (Exception ex)
{
if (tsStatus.Text.IndexOf("接收【获取任务和命令开关】广播时:" + ex.Message) < 0)
{
tsStatus.ForeColor = Color.Red;
this.tsStatus.Text += "接收【获取任务和命令开关】广播时:" + ex.Message;
}
}
}));
}
public IAsyncResult BeginSendOrderMessage(Model.MonitorInfo mi, AsyncCallback callBack, object state)
{
return state as IAsyncResult;
}
public void EndSendOrderMessage(IAsyncResult ar)
{
}
//20140824richard
#endregion
private void Client_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("您确认要关闭"+CStaticClass.SystemName+"吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
{
e.Cancel = true;
return;
}
ClientLogout();
CommonClassLib.AppSettings.dbo.Close();//richard20181022
CommonClassLib.AppSettings.dboM.Close();//richard20181022
OPCClient.CCommonOPCClient.DisConnectOPCServer();//20120428
FrmLogin.FormInstance.Close();
}
void LogCallBack(IAsyncResult ar)
{
try
{
string strErr = string.Empty;
if (CStaticClass.WcfControl.EndLogoutClient(out strErr, ar) == true)
{
//if (ar.AsyncState.ToString() == "RegisterClientCallBack")
//{
// CStaticClass.WcfControl.BeginRegisterClient(CStaticClass.UserID, "客户端:" + CStaticClass.ClientID + ",用户名:" + CStaticClass.UserID, new AsyncCallback(RegisterClientCallBack), null);
// return;
//}
}
CStaticClass.WCFOK = false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public void ClientLogout()
{
try
{
string errtext = string.Empty;
CStaticClass.WcfControl.BeginLogoutClient("客户端:" + CStaticClass.ClientID + ",用户名:" + CStaticClass.UserID,new AsyncCallback(LogCallBack),"" );
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void MIHandCommand_Click(object sender, EventArgs e)
{
FrmHandCommand.FormInstance.Show();
}
private void MIHandAssociateCommand_Click(object sender, EventArgs e)
{
FrmHandAssociateCommand.FormInstance.Show();
}
private void MIAutoCommand_Click(object sender, EventArgs e)
{
FrmAutoCommand.FormInstance.Show();
}
private void MIAltMonitor_Click(object sender, EventArgs e)
{
FrmModifyMonitor.FormInstance.Show();
}
private void MIAltManange_Click(object sender, EventArgs e)
{
FrmModifyManage.FormInstance.Show();
}
private void notifyIcon1_BalloonTipShown(object sender, EventArgs e)
{
try
{
//speak.Volume = 100;//设置音量
//speak.Rate = 0;//设置语速
//speak.SetOutputToDefaultAudioDevice();
//speak.SpeakAsync(notifyIcon1.BalloonTipText);//播放内容
speak.SpeakAsync(notifyIcon1.BalloonTipText);
}
catch
{
}
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (CStaticClass.WCFOK == true)
{
this.TopMost = true;
this.Visible = true;
this.TopMost = false;
this.WindowState = FormWindowState.Maximized;
}
}
private void tsStatus_TextChanged(object sender, EventArgs e)
{
}
private void TSMrefresh_Click(object sender, EventArgs e)
{
//sql.Remove(0, sql.Length);
//sql.Append("select * from V_Manage_Task where ").Append(CStaticClass.Manstatus);
//this.dgvManager.DataSource = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
}
private void TSMMonitorRefresh_Click(object sender, EventArgs e)
{
//sql.Remove(0, sql.Length);
//sql.Append("select * from V_Monitor_Task where ").Append(CStaticClass.Monstatus).Append(" order by 设备指令索引 asc ");
//this.dgvMonitor.DataSource = dbo.ExceSQL(sql.ToString()).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 comboBox1_SelectedIndexChanged(object sender, EventArgs e)
//{
// try
// {
// string df = "";
// switch (this.comboBox1.Text)
// {
// case "条码":
// df = "条码";
// break;
// case "调度任务索引":
// df = "调度任务索引";
// break;
// case "设备指令索引":
// df = "设备指令索引";
// break;
// default:
// return;
// }
// //20100208
// sql.Remove(0, sql.Length);
// sql.Append("select distinct " + df + " from V_Monitor_Task ");
// DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
// if (dv.Count > 0)
// {
// this.textBox1.DataSource = null;
// this.textBox1.DisplayMember = df;
// this.textBox1.ValueMember = df;
// this.textBox1.DataSource = dv;
// }
// }
// catch (Exception ex)
// {
// MessageBox.Show(ex.Message);
// }
//}
//private void button1_Click(object sender, EventArgs e)
//{
// try
// {
// if (this.textBox1.Text.Trim().Length == 0) return;
// if (this.comboBox1.Text == "条码")
// {
// CStaticClass.Monstatus = " 条码='" + this.textBox1.Text.Trim() + "' ";
// }
// if (this.comboBox1.Text == "调度任务索引")
// {
// CStaticClass.Monstatus = " 调度任务索引='" + this.textBox1.Text.Trim() + "' ";
// }
// if (this.comboBox1.Text == "设备指令索引")
// {
// CStaticClass.Monstatus = " 设备指令索引='" + this.textBox1.Text.Trim() + "' ";
// }
// TSMMonitorRefresh_Click(sender, e);
// }
// catch (Exception ex)
// {
// MessageBox.Show(ex.Message);
// }
//}
private void button2_Click(object sender, EventArgs e)
{
CStaticClass.Monstatus = " F_Status>=-1 ";
TSMMonitorRefresh_Click(sender, e);
}
public void MonitorRefresh()
{//20110222
//sql.Remove(0, sql.Length);
//sql.Append("select * from V_Monitor_Task where ").Append(CStaticClass.Monstatus).Append(" order by 设备指令索引 asc ");
//this.dgvMonitor.DataSource = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
}
public void ManagerRefresh()
{//20110222
//sql.Remove(0, sql.Length);
//sql.Append("select * from V_Manage_Task where ").Append(CStaticClass.Manstatus);
//this.dgvManager.DataSource = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
}
void BuildHandTaskCallBack(IAsyncResult ar)
{
string errtext = string.Empty;
if (CStaticClass.WcfControl.EndBuildHandTask(out errtext, ar) == false)
{
//MessageBox.Show(errtext, "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Client_Load(object sender, EventArgs e)
{
try
{
//for (int i = 0; i <= 1000; i++)
//{
// Model.HandTask ht = new Model.HandTask(11001, 1, 0, "0", "00-00-00", "-", 0, 0);
// CStaticClass.WcfControl.BeginBuildHandTask(ht, new AsyncCallback(BuildHandTaskCallBack), ht);
//}
#region 添加输送机、穿梭车和堆垛机的单击事件
foreach (Control ctrl in this.plHW.Controls)
{
if (ctrl.GetType().ToString() == "System.Windows.Forms.Button")
{
ctrl.Click += new EventHandler(ctrl_Click);
toolTip1.SetToolTip(ctrl, ctrl.Tag.ToString());
}
if ((ctrl.GetType().ToString() == "System.Windows.Forms.PictureBox") && (ctrl.Enabled == true))
{
if (ctrl.Name.ToString().Contains("stop"))
{
ctrl.Click += new EventHandler(ctrl_ClickPicStop);
ctrl.MouseEnter += new EventHandler(Btn_MouseEnter_Stop);
}
else
{
ctrl.Click += new EventHandler(ctrl_ClickPic);
}
toolTip1.SetToolTip(ctrl, ctrl.Tag.ToString());
}
}
foreach (Control ctrl in this.plCW.Controls)
{
if (ctrl.GetType().ToString() == "System.Windows.Forms.Button")
{
ctrl.Click += new EventHandler(ctrl_Click);
toolTip1.SetToolTip(ctrl, ctrl.Tag.ToString());
}
if ((ctrl.GetType().ToString() == "System.Windows.Forms.PictureBox") && (ctrl.Enabled == true))
{
if (ctrl.Name.ToString().Contains("stop"))
{
ctrl.Click += new EventHandler(ctrl_ClickPicStop);
ctrl.MouseEnter += new EventHandler(Btn_MouseEnter_Stop);
}
else
{
ctrl.Click += new EventHandler(ctrl_ClickPic);
}
toolTip1.SetToolTip(ctrl, ctrl.Tag.ToString());
}
}
foreach (Control ctrl in this.plZJLL.Controls)
{
if (ctrl.GetType().ToString() == "System.Windows.Forms.Button")
{
ctrl.Click += new EventHandler(ctrl_Click);
toolTip1.SetToolTip(ctrl, ctrl.Tag.ToString());
}
if ((ctrl.GetType().ToString() == "System.Windows.Forms.PictureBox") && (ctrl.Enabled == true))
{
if (ctrl.Name.ToString().Contains("stop"))
{
ctrl.Click += new EventHandler(ctrl_ClickPicStop);
ctrl.MouseEnter += new EventHandler(Btn_MouseEnter_Stop);
}
else
{
ctrl.Click += new EventHandler(ctrl_ClickPic);
}
toolTip1.SetToolTip(ctrl, ctrl.Tag.ToString());
}
}
foreach (Control ctrl in this.plZJCJ.Controls)
{
if (ctrl.GetType().ToString() == "System.Windows.Forms.Button")
{
ctrl.Click += new EventHandler(ctrl_Click);
toolTip1.SetToolTip(ctrl, ctrl.Tag.ToString());
}
if ((ctrl.GetType().ToString() == "System.Windows.Forms.PictureBox") && (ctrl.Enabled == true))
{
if (ctrl.Name.ToString().Contains("stop"))
{
ctrl.Click += new EventHandler(ctrl_ClickPicStop);
ctrl.MouseEnter += new EventHandler(Btn_MouseEnter_Stop);
}
else
{
ctrl.Click += new EventHandler(ctrl_ClickPic);
}
toolTip1.SetToolTip(ctrl, ctrl.Tag.ToString());
}
}
#endregion
TSMrefresh_Click(sender, e);
TSMMonitorRefresh_Click(sender, e);
if (CStaticClass.UserID.ToUpper() == "SA")
{
this.MMmasterAdmin.Visible = true;
}
else
{
this.MMmasterAdmin.Visible = false;
}
}
catch (Exception ex)
{
throw (ex);
}
}
private void MIDeviceState_Click(object sender, EventArgs e)
{
FrmDeviceInfoEdit.FormInstance.Show();
}
private void MIRouteInfo_Click(object sender, EventArgs e)
{
FrmRouteEdit.FormInstance.Show();
}
private void MIWaitTime_Click(object sender, EventArgs e)
{
FrmWaitTime.FormInstance.Show();
}
private void MIMonitorConnectInfo_Click(object sender, EventArgs e)
{
FrmConnectDB.FormInstance.ConnectType = "Monitor";
FrmConnectDB.FormInstance.Show();
}
private void MIIOStation_Click(object sender, EventArgs e)
{
FrmIOStation.FormInstance.Show();
}
private void timer1_Tick(object sender, EventArgs e)
{
try
{
if (CStaticClass.WcfControl != null)
{
if (CStaticClass.WcfControl.State == CommunicationState.Faulted)
{
CStaticClass.WCFOK = false;
ReConnectAndRegisterClient();//20160115添加断线重连功能
}
else
{
CStaticClass.WcfControl.BeginHeartbeat(new AsyncCallback(CallBackHeartbeat), null);
}
}
}
catch (Exception ex)
{
ReConnectAndRegisterClient();//20160115添加断线重连功能
}
if (CStaticClass.WCFOK == false) return;
try
{
CStaticClass.WcfControl.BeginHeartbeat(new AsyncCallback(CallBackHeartbeat), null);
}
catch (Exception ex)
{
if (tsStatus.Text.IndexOf("BeginHeartbeat时:" + ex.Message) < 0)
{
tsStatus.ForeColor = Color.Red;
this.tsStatus.Text += "BeginHeartbeat时:"+DateTime.Now.ToString("u") + ex.Message;
}
ReRegisterClient();
}
}
void ReConnectAndRegisterClient()
{
try
{
CStaticClass.ClientID = Dns.GetHostName();
var ctx = new InstanceContext(CStaticClass.client);
CStaticClass.WcfControl = new WcfControlMonitor.ControlMonitorClient(ctx);
string errtext = string.Empty;
CommonClassLib.CCarryConvert.WriteDarkCasket("Login", "UserID:" + CStaticClass.UserID + "的操作日志", "尝试重新连接", "", "");
CStaticClass.WcfControl.BeginRegisterClient(CStaticClass.UserID, "客户端:" + CStaticClass.ClientID + ",用户名:" + CStaticClass.UserID, new AsyncCallback(ReConnectAndRegisterClientCallBack), null);
}
catch (Exception ex)
{
throw ex;
}
}
void ReConnectAndRegisterClientCallBack(IAsyncResult ar)
{
try
{
string ErrText = string.Empty;
if (false == CStaticClass.WcfControl.EndRegisterClient(out ErrText, ar))
{
//MessageBox.Show(ErrText, "登陆错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
CStaticClass.WCFOK = false;
return;
}
//OPCClient.CCommonOPCClient.DisConnectOPCServer();
//OPCClient.CCommonOPCClient.UpdateDB += new CUpdateDBEventHandler(CCommon_UpdateDB);
//OPCClient.CCommonOPCClient.CreateSubscriptionGroup();
CommonClassLib.CCarryConvert.WriteDarkCasket("Login", "UserID:" + CStaticClass.UserID + "的操作日志", "重连**成功登录系统", "", "");
tsStatus.Text = "";
//CStaticClass.WcfControl.BeginSendAllDeviceStates(CStaticClass.client.devlist[0].DeviceIndex, new AsyncCallback(CStaticClass.client.SendAllDeviceStatesCallback), null);
CStaticClass.WCFOK = true;
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message, "登陆错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
CStaticClass.WCFOK = false;
return;
}
}
public void SendAllDeviceStatesCallback(IAsyncResult ar)
{
try
{
Model.MDevice dev;
dev = CStaticClass.WcfControl.EndSendAllDeviceStates(ar);
if (dev != null)
{
Model.CGetInfo.SetDeviceInfo(dev);
}
devsn++;
if (devsn < devlist.Count())
{
CStaticClass.WcfControl.BeginSendAllDeviceStates(devlist[devsn].DeviceIndex, new AsyncCallback(SendAllDeviceStatesCallback), null);
}
else
{
//devsn=0;
//CStaticClass.WcfControl.BeginSendAllDeviceStates(devlist[devsn].DeviceIndex, new AsyncCallback(SendAllDeviceStatesCallback), null);
}
}
catch (Exception ex)
{
this.BeginInvoke(new MethodInvoker(delegate()
{
if (tsStatus.Text.IndexOf("SendAllDeviceStatesCallback时:" + ex.Message) < 0)
{
tsStatus.ForeColor = Color.Red;
this.tsStatus.Text += "SendAllDeviceStatesCallback时:" + ex.Message;
}
}));
ReRegisterClient();
}
}
private void MITransportTimeout_Click(object sender, EventArgs e)
{
FrmTransportTimeout.FormInstance.Show();
}
private void MISeeDarket_Click(object sender, EventArgs e)
{
FrmBrowseDarkCasket.FormInstance.Show();
}
private void MIDarketFileSet_Click(object sender, EventArgs e)
{
FrmDarkCasket.FormInstance.Show();
}
private void MIAutoTaskHistory_Click(object sender, EventArgs e)
{
FrmBrowseAotoTaskLog.FormInstance.Show();
}
private void MIUserInfoManage_Click(object sender, EventArgs e)
{
FrmUsers.FormInstance.Show();
}
private void MIAltPassword_Click(object sender, EventArgs e)
{
FrmPassword.FormInstance.Show();
}
private void MMExitSystem_Click(object sender, EventArgs e)
{
this.Close();
}
private void MIUnVisible_Click(object sender, EventArgs e)
{
this.Visible = false;
}
private void MIMaxWindow_Click(object sender, EventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Maximized;
}
private void MICloseWindow_Click(object sender, EventArgs e)
{
this.Close();
}
private void tabPage1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.TranslateTransform(this.tabPage2.AutoScrollPosition.X, this.tabPage2.AutoScrollPosition.Y);
g.Dispose();
}
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_ClickPic(object sender, EventArgs e)
{
PictureBox btn = (PictureBox)sender;
_deviceStatus.DeviceIndex = Convert.ToInt32(btn.Tag);
_deviceStatus.ShowDialog();
}
private void ctrl_ClickPicStop(object sender, EventArgs e)
{
PictureBox btn = (PictureBox)sender;
int DeviceIndexForRunButton = Convert.ToInt32(btn.Tag);
Model.MDevice deviceRun = Model.CGetInfo.GetDeviceInfo(DeviceIndexForRunButton);
int iValue = 0;
iValue = (deviceRun.SplitByte_6 == 1) ? 0 : 1;
//if (iValue == 0)
//{
// if (MessageBox.Show("您确认要向设备:" + DeviceIndexForRunButton + "发送【设备急停】吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
// {
// return;
// }
//}
//else
//{
// if (MessageBox.Show("您确认要向设备:" + DeviceIndexForRunButton + "发送【急停复位】吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
// {
// return;
// }
//}
CStaticClass.WcfControl.BeginSendDeviceReset(DeviceIndexForRunButton, 10 + iValue, new AsyncCallback(SendDeviceResetCallBack), iValue);
// CStaticClass.WcfControl.BeginSendDeviceReset(DeviceIndexForRunButton, iValue, new AsyncCallback(SendDeviceResetCallBack), iValue);
}
/// <summary>
/// 急停显示 用于紧急急停按钮鼠标放上去显示设备信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Btn_MouseEnter_Stop(object sender, EventArgs e)
{
string deviceindex = (sender as Control).Tag.ToString();
devinfo = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(deviceindex));
if (devinfo != null)
{
if (devinfo.SplitByte_6 == 1)//未停车
{
deviceindex = string.Format("{0}-未联机停车", devinfo.DeviceIndex);
}
if (devinfo.SplitByte_6 == 0)//停车
{
deviceindex = string.Format("{0}-联机停车", devinfo.DeviceIndex);
}
}
toolTip1.SetToolTip(sender as Control, deviceindex);
}
void SendDeviceResetCallBack(IAsyncResult ar)
{
string errtext = string.Empty;
if (CStaticClass.WcfControl.EndSendDeviceReset(out errtext, ar) == false)
{
MessageBox.Show(errtext, "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void timerFlash_Tick(object sender, EventArgs e)
{
string[] DS;char[] dd=new char [1]{'.'};
Model.MDevice device;
TimeSpan ts = DateTime.Now.TimeOfDay;
DataView dv; DataView dvJY;
this.SuspendLayout(); //richard.liu20140806
try
{
if (CStaticClass.WCFOK == true)
{
//timersum++;//20150103增加断网恢复//20151120取消断网恢复
//if (timersum >= 120)//1分钟刷新订阅一次
//{//20150103增加断网恢复
// OPCClient.CCommonOPCClient.RefreshMonitoringMode();
// timersum = 0;
//}
sql.Remove(0, sql.Length);//richard.liu20140806
sql.Append("SELECT F_DeviceIndex FROM T_Base_Device WHERE F_LockedState = - 1 and F_DeviceIndex not in (12685,12686,12692,12693) ");
dvJY = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;//richard.liu20140806
dvJY.Sort = "F_DeviceIndex";
Button btdevice = bt11101;
PictureBox pbdevice = pbh15400;
TextBox tw0 = t11101;
TextBox tw1 = t11101;
Panel pp = plHW;
if (this.tabControl1.SelectedIndex == 0)
{
pp = plHW;
}
else if (this.tabControl1.SelectedIndex == 1)
{
pp = plCW;
}
else if (this.tabControl1.SelectedIndex == 2)
{
pp = plZJLL;
}
else if (this.tabControl1.SelectedIndex == 3)
{
pp = plZJCJ;
}
#region 每层楼监视画面
#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.DeviceIndex >= 15401 && device.DeviceIndex <= 15403)
{ 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;
}
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;
}
}
#endregion
#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>())
{
if(pp == plHW || pp == plCW)
{
if (ctrl.Tag!=null)
{
//如果是紧急停车按钮的时候
if (!ctrl.Tag.ToString().Contains("."))
{
if(ctrl.Name.Length>9)//gjn 界面联机急停长度超过9位 为10位
{
device = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32("3" + ctrl.Name.ToString().Substring(ctrl.Name.Length - 5, 4)));
}
else
{
device = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32("3" + ctrl.Name.ToString().Substring(ctrl.Name.Length - 4, 4)));
}
if (device.DeviceKind == 40)
{
//取堆垛机13.6状态来显示颜色
device = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(ctrl.Tag));
if (device == null)
{
if (tsStatus.Text.IndexOf(ctrl.Name + "控件对应的设备索引:" + ctrl.Name.ToString().Substring(ctrl.Name.Length - 5, 5) + "在数据库没有记录!") < 0)
{
tsStatus.ForeColor = Color.Red;
this.tsStatus.Text += ctrl.Name + "控件对应的设备索引:" + ctrl.Name.ToString().Substring(ctrl.Name.Length - 5, 5) + "在数据库没有记录!";
}
continue;
}
//DataView dwRunDevice = dbo.ExceSQL("SELECT F_DeviceIndex FROM T_Base_Device WHERE F_DeviceKindIndex = 1 or F_DeviceKindIndex = 4").Tables[0].DefaultView;
//for (int i = 0; i < dwRunDevice.Count; i++)
//{
// if (ctrl.Tag.ToString() == dwRunDevice[i]["F_Deviceindex"].ToString())
// {
//Model.MDevice deviceRun = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(ctrl.Tag.ToString()));
if (device.SplitByte_6 == 1)
{
//ctrl.Image = wcfControlMonitorClient.Properties.Resources.stop0;
ctrl.Image = wcfControlMonitorClient.Properties.Resources.stop0;
}
if (device.SplitByte_6 == 0)
{
//ctrl.Image = wcfControlMonitorClient.Properties.Resources.stop1;
ctrl.Image = wcfControlMonitorClient.Properties.Resources.stop1;
}
// }
//}
}
}
}
}
}
#endregion
#region Button
foreach (Button ctrl in pp.Controls.OfType<Button>())
{
device = Model.CGetInfo.GetDeviceInfo(Convert.ToInt32(ctrl.Tag));
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;
}
if (device.DeviceKind == 2)
{
#region 类输送机
#region 设置设备状态
switch (device.RunState)
{
//空闲
case 0:
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.Gray;
break;
}
#endregion
#endregion
}
else
{
#region 设置设备状态
switch (device.RunState)
{
//空闲
case 0:
ctrl.BackColor = Color.Orange;
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;
}
#endregion
#region 堆垛机、穿梭车模拟移动动画
if (device.DeviceKind == 1)
{
#region 堆垛机
if (pp == plHW)
{
// 常规堆垛机
if ((device.DeviceIndex >= 11209 && device.DeviceIndex <= 11214) || device.DeviceIndex == 11201 || device.DeviceIndex == 11202)
{
if (device.XCoor == 1)
{
ctrl.Location = new Point(ctrl.Location.X, button265.Location.Y + button265.Size.Height - bt11214.Size.Height);
}
//1列坐标+(货架长度/列数)*(X坐标-1)
// 堆垛机动画
//float newy1 = (this.Height) / y;
//ctrl.Location = new Point(ctrl.Location.X, newy1* + (int)((418 / 38) * (device.XCoor)));
// 堆垛机初始位置 = 输送线12509位置Y + 12509高度 - 堆垛机高度; 动画:头尾输送线之差 12372-12509 / 货列
//if (device.DeviceIndex == 11210)
//{
// ctrl.Location = new Point(ctrl.Location.X, (button265.Location.Y + button265.Size.Height - bt11214.Size.Height) + (int)(((pictureBox11.Size.Height + bt11214.Size.Height) / 38) * (device.XCoor - 1)));
//}
else
{
ctrl.Location = new Point(ctrl.Location.X, (button265.Location.Y + button265.Size.Height - bt11214.Size.Height) + (int)(((pictureBox11.Size.Height + bt11214.Size.Height) / 38) * device.XCoor));
}
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
// 大小货堆垛机
else if (device.DeviceIndex >= 11203 && device.DeviceIndex <= 11209)
{// 堆垛机动画
if (device.XCoor == 1)
{
ctrl.Location = new Point(ctrl.Location.X, button320.Location.Y + button320.Size.Height - bt11203.Size.Height);
}
else if (device.XCoor == 37)
{
ctrl.Location = new Point(ctrl.Location.X, pictureBox48.Location.Y + pictureBox48.Size.Height);
}
else
{
ctrl.Location = new Point(ctrl.Location.X, (button320.Location.Y + button320.Size.Height - bt11203.Size.Height) + (int)(((pictureBox48.Size.Height + bt11203.Size.Height) / 36) * device.XCoor));
}
// ctrl.Location = new Point(ctrl.Location.X, 234 + (int)((396 / 36) * (device.XCoor)));
// 堆垛机初始位置 = 12471 + 12471 - 堆垛机高度; 动画:头尾输送线之差 12334-12471 / 货列
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
/*
pbdevice = (PictureBox)pp.Controls[string.Format("pbh18{0}", ctrl.Tag.ToString().Substring(2))];
ctrl.Location = new Point((int)(pbdevice.Location.X + pbdevice.Size.Width), (int)(pbdevice.Location.Y - 25 + 0.006 * (device.XCoor)));
*/
}
else if (pp == plCW)//677+ 38 = 753 / 40 = 17.875 753/76 = 9.90789
{
if ((device.DeviceIndex >= 11101 && device.DeviceIndex <= 11102) || (device.DeviceIndex >= 11107 && device.DeviceIndex <= 11118))
{
if(device.XCoor > 1 && device.XCoor <= 40)
{
ctrl.Location = new Point((int)(ctrl.Location.X), (int)(button778.Location.Y - 25 + 17.875 * (device.XCoor)));//+ ctrl.Size.Width
}
else
{
ctrl.Location = new Point(ctrl.Location.X, button778.Location.Y + button778.Size.Height - bt11121.Size.Height);
}
}
else
{
if(device.XCoor > 1 && device.XCoor <= 76)
{
ctrl.Location = new Point((int)(ctrl.Location.X), (int)(button778.Location.Y - 25 + 9.4 * (device.XCoor)));//+ ctrl.Size.Width
}
else
{
ctrl.Location = new Point(ctrl.Location.X, button778.Location.Y + button778.Size.Height - bt11121.Size.Height);
}
}
//pbdevice = (PictureBox)pp.Controls[string.Format("pbc18{0}", ctrl.Tag.ToString().Substring(2))];
//ctrl.Location = new Point((int)(pbdevice.Location.X + pbdevice.Size.Width), (int)(pbdevice.Location.Y - 25 + 0.007 * (device.XCoor)));
//pbdevice = (PictureBox)pp.Controls[string.Format("bt{0}", ctrl.Tag.ToString())];
}
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
#endregion
}
else if (device.DeviceKind == 4)
{
#region 直穿
if (pp == plCW)
{//小于12459的条码,在plHW可见,大于则在plCW可见
//305-1844 68150-235689 = 1539/167539 = 0.00918592
if (device.XCoor >= 70258)
{
ctrl.Visible = true;
//ctrl.Location = new Point((int)(305 + 0.00918592 * (device.XCoor-68150)), ctrl.Location.Y);
if (device.XCoor > 70257 && device.XCoor <= 70286)
{
ctrl.Location = new Point(303, 2);//12458-12449
}
else if (device.XCoor > 70286 && device.XCoor <= 74725)
{
ctrl.Location = new Point(371 - 16, 2);//12458
}
else if (device.XCoor > 74725 && device.XCoor <= 78727)
{
ctrl.Location = new Point(412 - 16, 2);//12456
}
else if (device.XCoor > 78727 && device.XCoor <= 82733)
{
ctrl.Location = new Point(443 - 16, 2);//12454
}
else if (device.XCoor > 82733 && device.XCoor <= 86353)
{
ctrl.Location = new Point(483 - 16, 2);//12452
}
else if (device.XCoor > 86353 && device.XCoor <= 89319)
{
ctrl.Location = new Point(507 - 16, 2);//12450
}
else if (device.XCoor > 89319 && device.XCoor <= 92827)
{
ctrl.Location = new Point(533 - 16, 2);//12448
}
else if (device.XCoor > 92827 && device.XCoor <= 97005)
{
ctrl.Location = new Point(569 - 16, 2);//12446
}
else if (device.XCoor > 97005 && device.XCoor <= 100979)
{
ctrl.Location = new Point(617 - 16, 2);//12444
}
else if (device.XCoor > 100979 && device.XCoor <= 104946)
{
ctrl.Location = new Point(643 - 16, 2);//12442
}
else if (device.XCoor > 104946 && device.XCoor <= 108914)
{
ctrl.Location = new Point(683 - 16, 2);//12440
}
else if (device.XCoor > 108914 && device.XCoor <= 112881)
{
ctrl.Location = new Point(713 - 16, 2);//12438
}
else if (device.XCoor > 112881 && device.XCoor <= 117277)
{
ctrl.Location = new Point(757 - 16, 2);//12436
}
else if (device.XCoor > 117277 && device.XCoor <= 121684)
{
ctrl.Location = new Point(795 - 16, 2);//12434
}
else if (device.XCoor > 121684 && device.XCoor <= 125686)
{
ctrl.Location = new Point(837 - 16, 2);//12432
}
else if (device.XCoor > 125686 && device.XCoor <= 129662)
{
ctrl.Location = new Point(867 - 16, 2);//12430
}
else if (device.XCoor > 129662 && device.XCoor <= 137571)
{
ctrl.Location = new Point(925 - 20, 2);//12428 12427 12511
}
//else if (device.XCoor > 129662 && device.XCoor <= 132762)
//{
// ctrl.Location = new Point(901 - 16, 2);//12511
//}
//else if (device.XCoor > 132762 && device.XCoor <= 134358)
//{
// ctrl.Location = new Point(925 - 16, 2);//12428
//}
//else if (device.XCoor > 134358 && device.XCoor <= 137571)
//{
// ctrl.Location = new Point(949 - 16, 2);//12427
//}
else if (device.XCoor > 137571 && device.XCoor <= 142117)
{
ctrl.Location = new Point(985 - 16, 2);//12426
}
else if (device.XCoor > 142117 && device.XCoor <= 148332)
{
ctrl.Location = new Point(1020 - 16, 2);//12424
}
else if (device.XCoor > 148332 && device.XCoor <= 156309)
{
ctrl.Location = new Point(1093 - 16, 2);//12422
}
else if (device.XCoor > 156309 && device.XCoor <= 164800)
{
ctrl.Location = new Point(1165 - 16, 2);//12420
}
else if (device.XCoor > 164800 && device.XCoor <= 173413)
{
ctrl.Location = new Point(1251 - 16, 2);//12418
}
else if (device.XCoor > 173413 && device.XCoor <= 181383)
{
ctrl.Location = new Point(1321 - 16, 2);//12416
}
else if (device.XCoor > 181383 && device.XCoor <= 189752)
{
ctrl.Location = new Point(1392 - 16, 2);//12414
}
else if (device.XCoor > 189752 && device.XCoor <= 198260)
{
ctrl.Location = new Point(1475 - 16, 2);//12412
}
else if (device.XCoor > 198260 && device.XCoor <= 206253)
{
ctrl.Location = new Point(1547 - 16, 2);//12410
}
else if (device.XCoor > 206253 && device.XCoor <= 214945)
{
ctrl.Location = new Point(1621 - 16, 2);//12408
}
else if (device.XCoor > 214945 && device.XCoor <= 223673)
{
ctrl.Location = new Point(1703 - 16, 2);//12406
}
else if (device.XCoor > 223673 && device.XCoor <= 231699)
{
ctrl.Location = new Point(1779 - 16, 2);//12404
}
else if (device.XCoor > 231699)
{
ctrl.Location = new Point(1851 - 16, 2);//12402
}
tw0 = (TextBox)pp.Controls[string.Format("tc{0}", ctrl.Tag)];
//单工位
tw0.Location = new Point(ctrl.Location.X + 12, ctrl.Location.Y + 6);
tw0.Visible = device.SplitByte_0 == 1 ? true : false;
if (device.DeviceIndex >= 15401 && device.DeviceIndex <= 15402)
{//双工位
tw1 = (TextBox)pp.Controls[string.Format("tc{0}1", ctrl.Tag)];
tw1.Location = new Point(ctrl.Location.X + 28, ctrl.Location.Y + 6);
tw1.Visible = device.SplitByte_1 == 1 ? true : false;
}
}
else
{
ctrl.Visible = false;
tw0 = (TextBox)pp.Controls[string.Format("tc{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + 12, ctrl.Location.Y + 6);
tw0.Visible = false;
if (device.DeviceIndex >= 15401 && device.DeviceIndex <= 15402)
{//双工位
tw1 = (TextBox)pp.Controls[string.Format("tc{0}1", ctrl.Tag)];
tw1.Location = new Point(ctrl.Location.X + 28, ctrl.Location.Y + 6);
tw1.Visible = false;
}
}
}
else if (pp == plHW)
{
//930-1875 68149-4036 = 945 /64113 = 0.0147396
if (device.XCoor <= 70285)
{
ctrl.Visible = true;
//ctrl.Location = new Point((int)(930 + 0.0147396 * (device.XCoor - 4036)), ctrl.Location.Y);
if (device.XCoor <= 5942)
{
ctrl.Location = new Point(930, 2);//12720
}
else if (device.XCoor > 5942 && device.XCoor <= 10125)
{
ctrl.Location = new Point(996 - 16, 2);//12663
}
else if (device.XCoor > 10125 && device.XCoor <= 14295)
{
ctrl.Location = new Point(1075 - 16, 2);//12662
}
else if (device.XCoor > 14295 && device.XCoor <= 18488)
{
ctrl.Location = new Point(1125 - 16, 2);//12661
}
else if (device.XCoor > 18488 && device.XCoor <= 23106)
{
ctrl.Location = new Point(1192 - 16, 2);//12660
}
else if (device.XCoor > 23106 && device.XCoor <= 28940)
{
ctrl.Location = new Point(1267 - 16, 2);//12659
}
else if (device.XCoor > 28940 && device.XCoor <= 35421)
{
ctrl.Location = new Point(1355 - 16, 2);//12658
}
else if (device.XCoor > 35421 && device.XCoor <= 49769)
{
ctrl.Location = new Point(1443 - 16, 2);//12657
}
else if (device.XCoor > 49769 && device.XCoor <= 64648)
{
ctrl.Location = new Point(1780 - 16, 2);//12462 12461
}
//else if (device.XCoor > 49769 && device.XCoor <= 61952)
//{
// ctrl.Location = new Point(1780 - 16, 2);//12462
//}
//else if (device.XCoor > 61952 && device.XCoor <= 64648)
//{
// ctrl.Location = new Point(1805 - 16, 2);//12461
//}
else if (device.XCoor > 64648)
{
ctrl.Location = new Point(1853 - 16, 2);//12460 12459
}
//else if (device.XCoor > 64648 && device.XCoor <= 67348)
//{
// ctrl.Location = new Point(1853 - 16, 2);//12460
//}
//else if (device.XCoor > 67348)
//{
// ctrl.Location = new Point(1881 - 16, 2);//12459
//}
tw0 = (TextBox)pp.Controls[string.Format("th{0}", ctrl.Tag)];
//单工位
tw0.Location = new Point(ctrl.Location.X + 12, ctrl.Location.Y + 6);
tw0.Visible = device.SplitByte_0 == 1 ? true : false;
if (device.DeviceIndex >= 15401 && device.DeviceIndex <= 15402)
{//双工位
tw1 = (TextBox)pp.Controls[string.Format("th{0}1", ctrl.Tag)];
tw1.Location = new Point(ctrl.Location.X + 28, ctrl.Location.Y + 6);
tw1.Visible = device.SplitByte_1 == 1 ? true : false;
}
}
else
{
ctrl.Visible = false;
tw0 = (TextBox)pp.Controls[string.Format("th{0}", ctrl.Tag)];
//单工位
tw0.Location = new Point(ctrl.Location.X + 12, ctrl.Location.Y + 6);
tw0.Visible = false;
if (device.DeviceIndex >= 15401 && device.DeviceIndex <= 15402)
{//双工位
tw1 = (TextBox)pp.Controls[string.Format("th{0}1", ctrl.Tag)];
tw1.Location = new Point(ctrl.Location.X + 28, ctrl.Location.Y + 6);
tw1.Visible = false;
}
}
}
#endregion
}
else if (device.DeviceKind == 14)
{
#region 鸿安环穿
if (pp == plZJCJ)
{//一道内环sfZJH1_1,一道外环sfZJH1_2, 三道内环sfZJH2_1, 三道外环sfZJH2_2。
if (device.XCoor == 999999)
{
ctrl.Location = new Point(286, 440);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor >= 268050 && device.XCoor <= 456818)
{// 一道内环sfZJH1_1
int tempLength = pictureBox149.Location.X - sfZJH1_1.Location.X - button264.Size.Width;
ctrl.Location = new Point((int)(sfZJH1_1.Location.X + tempLength * (device.XCoor - 268050) / 188768), sfZJH1_1.Location.Y);
if (device.XCoor == 274108)
{
ctrl.Location = new Point(button100.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 278669)
{
ctrl.Location = new Point(button101.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 282480)
{
ctrl.Location = new Point(button103.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 287028)
{
ctrl.Location = new Point(button105.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 291622)
{
ctrl.Location = new Point(button107.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 298779)
{
ctrl.Location = new Point(button109.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 304503)
{
ctrl.Location = new Point(button111.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 326957)
{
ctrl.Location = new Point(button118.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 330422)
{
ctrl.Location = new Point(button122.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 334102)
{
ctrl.Location = new Point(button155.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 336718)
{
ctrl.Location = new Point(button159.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 359439)
{
ctrl.Location = new Point(button230.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 362931)
{
ctrl.Location = new Point(button232.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 367410)
{
ctrl.Location = new Point(button231.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 390064)
{
ctrl.Location = new Point(button173.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 392662)
{
ctrl.Location = new Point(button174.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 396330)
{
ctrl.Location = new Point(button176.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 399831)
{
ctrl.Location = new Point(button175.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 421940)
{
ctrl.Location = new Point(button219.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 424526)
{
ctrl.Location = new Point(button212.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 427159)
{
ctrl.Location = new Point(button211.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 446826)
{
ctrl.Location = new Point(button195.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 449489)
{
ctrl.Location = new Point(button196.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 453118)
{
ctrl.Location = new Point(button198.Location.X, sfZJH1_1.Location.Y);
}
else if (device.XCoor == 456617)
{
ctrl.Location = new Point(button197.Location.X, sfZJH1_1.Location.Y);
}
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor >= 456818 && device.XCoor <= 684475)
{// 一道外环sfZJH1_2
int tempLength = pictureBox149.Location.X - sfZJH1_2.Location.X - button264.Size.Width;
ctrl.Location = new Point((int)(pictureBox149.Location.X - button264.Size.Width - tempLength * (device.XCoor - 456818) / 227657), sfZJH1_2.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor >= 692695 && device.XCoor <= 940131)
{
// 三道外环sfZJH2_2
// 弯道12至弯道3外
if (device.XCoor >= 827106 && device.XCoor <= 940131)
{
int tempLength = button54.Location.Y - button136.Size.Height * 3 - sfZJH2_2.Location.Y;
//ctrl.Location = new Point(sfZJH2_1.Location.X, (int)(button54.Location.Y - button136.Size.Height * 2 - (tempLength * (device.XCoor - 827106) / 113025)));
ctrl.Location = new Point(sfZJH2_2.Location.X, (int)(button54.Location.Y - button136.Size.Height * 2 - (tempLength * (device.XCoor - 827106) / 113025)));
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
//弯道12
else if (device.XCoor >= 819388 && device.XCoor <= 827106)
{
ctrl.Location = new Point(sfZJH2_2.Location.X, button54.Location.Y - button136.Size.Height);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
//弯道11至弯道12
else if (device.XCoor >= 734180 && device.XCoor <= 819388)
{
int tempLength = sfZJH1_2.Location.Y - button136.Size.Height * 4 - button54.Location.Y;
//ctrl.Location = new Point(sfZJH2_1.Location.X, (int)(sfZJH1_2.Location.Y - button136.Size.Height * 3 - (tempLength * (device.XCoor - 734180) / 85208)));
ctrl.Location = new Point(sfZJH2_2.Location.X, (int)(sfZJH1_2.Location.Y - button136.Size.Height * 3 - (tempLength * (device.XCoor - 734180) / 85208)));
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
//弯道11
else if (device.XCoor >= 704288 && device.XCoor <= 734180)
{
ctrl.Location = new Point(sfZJH2_2.Location.X, sfZJH1_2.Location.Y - button136.Size.Height * 2);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
//直道
else if (device.XCoor >= 692695 && device.XCoor <= 704288)
{
ctrl.Location = new Point(sfZJH2_2.Location.X, sfZJH1_2.Location.Y - button136.Size.Height);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
/*
ctrl.Location = new Point(ctrl.Location.X, (int)(sfZJH2_2.Location.Y + 0.0038 * (device.XCoor)));
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0 .Location = new Point(ctrl.Location.X, tw0.Location.Y + 8);
*/
}
else if (device.XCoor >= 0 && device.XCoor <= 245800)
{ // 三道内环sfZJH2_1
int temp3startY = pictureBox150.Location.Y + pictureBox150.Size.Height;
// 零点 + 前两台落地机
if (device.XCoor >= 0 && device.XCoor <= 30342)
{
//每个站台
if (device.XCoor == 11121)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button145.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor == 15624)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button7.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor == 20932)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button9.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor == 25140)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button17.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor == 28032)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button26.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor == 30342)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button31.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else
{
ctrl.Location = new Point(sfZJH2_1.Location.X, sfZJH2_1.Location.Y + ((button31.Location.Y - sfZJH2_1.Location.Y - button264.Size.Height) * device.XCoor / 30342));
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
}
//第2.3台堆垛机直道
else if (device.XCoor >= 30342 && device.XCoor <= 52625)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button31.Location.Y + ((button54.Location.Y - button31.Location.Y - button31.Size.Height - button264.Size.Height) * (device.XCoor - 30342) / 22283));
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
//第3台落地机
else if (device.XCoor >= 52625 && device.XCoor <= 60457)
{
//每个站台
if (device.XCoor == 52625)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button54.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor == 55243)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button55.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor == 57854)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button73.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor == 60457)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button56.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else
{
int tempLength = button56.Location.Y - button54.Location.Y - button264.Size.Height;
ctrl.Location = new Point(sfZJH2_1.Location.X, (int)(button54.Location.Y + (tempLength * (device.XCoor - 52625) / 7832)));
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
}
//第3台落地机至弯道
else if (device.XCoor >= 60457 && device.XCoor <= 99595)
{
int tempLength = button91.Location.Y - button56.Location.Y - button56.Location.Y - button264.Size.Height;
ctrl.Location = new Point(sfZJH2_1.Location.X, (int)(button56.Location.Y + button56.Size.Height + tempLength / 3));
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
//弯道
else if ((device.XCoor >= 99595 && device.XCoor <= 130230) || (device.XCoor >= 1305195 && device.XCoor <= 1311727))
{
int tempLength = button91.Location.Y - button56.Location.Y - button56.Size.Height - button264.Size.Height;
ctrl.Location = new Point(sfZJH2_1.Location.X, (int)(button56.Location.Y + button56.Size.Height + tempLength / 3 * 2));
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
//第4台落地机
else if (device.XCoor >= 130230 && device.XCoor <= 146481)
{
//每个站台
if (device.XCoor == 133160)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button91.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor == 137588)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button87.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor == 141543)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button128.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor == 146481)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button90.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else
{
int tempLength = button90.Location.Y - button91.Size.Height - button264.Size.Height;
ctrl.Location = new Point(sfZJH2_1.Location.X, (int)(button91.Location.Y + (tempLength * (device.XCoor - 130230) / 16251)));
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
}
//第4台落地机至第五台落地机直道
else if (device.XCoor >= 146481 && device.XCoor <= 168560)
{
int tempLength = button133.Location.Y - button90.Location.Y - button90.Size.Height - button264.Size.Height;
ctrl.Location = new Point(sfZJH2_1.Location.X, (int)(button90.Location.Y + button90.Size.Height + (tempLength * (device.XCoor - 146481) / 22079)));
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
//第5台落地机
else if (device.XCoor >= 168560 && device.XCoor <= 177872)
{
//每个站台
if (device.XCoor == 168560)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button133.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor == 171162)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button134.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor == 173771)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button149.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor == 177872)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, button136.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else
{
int tempLength = button136.Location.Y - button133.Size.Height - button264.Size.Height;
ctrl.Location = new Point(sfZJH2_1.Location.X, (int)(button133.Location.Y + (tempLength * (device.XCoor - 168560) / 9312)));
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
}
//直道
else if (device.XCoor >= 177872 && device.XCoor <= 245800)
{
//ctrl.Location = new Point(ctrl.Location.X, (int)(sfZJH2_1.Location.Y + 0.0143 * (device.XCoor)));
//固定size值1076
ctrl.Location = new Point(sfZJH2_1.Location.X, (button136.Location.Y + button136.Size.Height));
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
}
else
{
// 弯道或者休息区
// 三内至一内
if (device.XCoor >= 245800 && device.XCoor <= 268050)
{
ctrl.Location = new Point(sfZJH2_1.Location.X, sfZJH1_1.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
// 一内至一外
else if (device.XCoor >= 456818 && device.XCoor <= 476594)
{
ctrl.Location = new Point(pictureBox149.Location.X, pictureBox149.Location.Y + pictureBox149.Size.Height / 2 - button264.Size.Height / 2);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
// 一外至三外
else if (device.XCoor >= 684475 && device.XCoor <= 692695)
{
ctrl.Location = new Point(sfZJH1_2.Location.X, sfZJH1_2.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
// 三外至三内
else if (device.XCoor >= 940131 && device.XCoor <= 957199)
{
ctrl.Location = new Point(pictureBox150.Location.X + pictureBox150.Size.Width / 2 - button264.Size.Width / 2, pictureBox150.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
}
}
else if (pp == plHW)
{
if (device.DeviceIndex >= 15201 && device.DeviceIndex <= 15219)
{
int temp2X = pictureBox152.Location.X - pictureBox151.Location.X - pictureBox151.Size.Width - button865.Size.Width;
// 环穿2区域
if (device.XCoor == 999999)
{
ctrl.Location = new Point(111, 654);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
if (device.XCoor >= 0 && device.XCoor <= 81206)
{ //下
//if (device.XCoor == 1079)
if (device.XCoor >= 1069 && device.XCoor <= 1089)
{
ctrl.Location = new Point(button439.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 3289)
{
ctrl.Location = new Point(button443.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 5742)
{
ctrl.Location = new Point(button452.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 11746)
{
ctrl.Location = new Point(button455.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 15008)
{
ctrl.Location = new Point(button466.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 18281)
{
ctrl.Location = new Point(button460.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 22548)
{
ctrl.Location = new Point(button480.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 25816)
{
ctrl.Location = new Point(button482.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 29074)
{
ctrl.Location = new Point(button481.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 33438)
{
ctrl.Location = new Point(button496.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 36696)
{
ctrl.Location = new Point(button498.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 39962)
{
ctrl.Location = new Point(button497.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 43537)
{
ctrl.Location = new Point(button512.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 46807)
{
ctrl.Location = new Point(button514.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 50067)
{
ctrl.Location = new Point(button513.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 54381)
{
ctrl.Location = new Point(button528.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 57648)
{
ctrl.Location = new Point(button530.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 60903)
{
ctrl.Location = new Point(button529.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 64701)
{
ctrl.Location = new Point(button534.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor == 68187)
{
ctrl.Location = new Point(button536.Location.X, sfHWH2_2.Location.Y);
}
else if (device.XCoor >= 78143 && device.XCoor <= 78163)
//else if (device.XCoor == 78153)
{
ctrl.Location = new Point(button538.Location.X, sfHWH2_2.Location.Y);
}
else
{
ctrl.Location = new Point((int)(pictureBox151.Location.X + pictureBox151.Size.Width + (temp2X * device.XCoor / 81206)), sfHWH2_2.Location.Y);
}
//ctrl.Location = new Point((int)(sfHWH2_1.Location.X + (945/ 81206) * (device.XCoor)), ctrl.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor >= 82106 && device.XCoor <= 96501)
{ // 右环弯
//ctrl.Location = new Point(1385, 587);
ctrl.Location = new Point(pictureBox152.Location.X, pictureBox152.Location.Y + pictureBox152.Size.Height / 2 - button865.Size.Height / 2);
// 右环弯落地机
if (device.XCoor == 81815)
{
ctrl.Location = new Point(button539.Location.X, sfHWH2_2.Location.Y);
}
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor >= 96501 && device.XCoor <= 178722)
{ // 上
//ctrl.Location = new Point((int)(sfHWH2_2.Location.X + (945 / 82221) * (device.XCoor)), ctrl.Location.Y);
ctrl.Location = new Point((int)(pictureBox152.Location.X - button865.Size.Width - Math.Round((float)temp2X / 82221, 4) * (device.XCoor - 96501)), sfHWH2_1.Location.Y);
if (device.XCoor == 96875)
{
ctrl.Location = new Point(button353.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 99413)
{
ctrl.Location = new Point(button355.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 104013)
{
ctrl.Location = new Point(button357.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 106536)
{
ctrl.Location = new Point(button359.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 109626)
{
ctrl.Location = new Point(button360.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 112435)
{
ctrl.Location = new Point(button363.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 115523)
{
ctrl.Location = new Point(button365.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 117253)
{
ctrl.Location = new Point(button367.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 120327)
{
ctrl.Location = new Point(button367.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 122069)
{
ctrl.Location = new Point(button370.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 125156)
{
ctrl.Location = new Point(button373.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 126895)
{
ctrl.Location = new Point(button374.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 129982)
{
ctrl.Location = new Point(button377.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 134806)
{
ctrl.Location = new Point(button379.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 142951)
{
ctrl.Location = new Point(button381.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 146230)
{
ctrl.Location = new Point(button382.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 150812)
{
ctrl.Location = new Point(button383.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 154107)
{
ctrl.Location = new Point(button387.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 158679)
{
ctrl.Location = new Point(button389.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 162962)
{
ctrl.Location = new Point(button391.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 167539)
{
ctrl.Location = new Point(button393.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 170817)
{
ctrl.Location = new Point(button395.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 175400)
{
ctrl.Location = new Point(button398.Location.X, sfHWH2_1.Location.Y);
}
else if (device.XCoor == 177963)
{
ctrl.Location = new Point(button397.Location.X, sfHWH2_1.Location.Y);
}
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor >= 178722 && device.XCoor <= 194213)
{ // 左环弯
//ctrl.Location = new Point(390, 587);
ctrl.Location = new Point(pictureBox151.Location.X, pictureBox151.Location.Y + pictureBox151.Size.Height / 2 - button865.Size.Height / 2);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
}
else if (device.DeviceIndex >= 15301 && device.DeviceIndex <= 15310)
{
if (device.XCoor == 999999)
{
ctrl.Location = new Point(111, 164);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
int temp3X = pictureBox148.Location.X - pictureBox147.Location.X - pictureBox147.Size.Width - button865.Size.Width;
if (device.XCoor >= 0 && device.XCoor <= 80325)
{// 通往102组件车间
//ctrl.Location = new Point((int)(sfHWH3_1.Location.X + (965/80325) * (device.XCoor)), ctrl.Location.Y);
ctrl.Location = new Point((int)(pictureBox148.Location.X - button865.Size.Width - Math.Round((float)temp3X / 80325, 4) * (device.XCoor)), sfHWH3_1.Location.Y);
if (device.XCoor == 23172)
{
ctrl.Location = new Point(button332.Location.X, sfHWH3_1.Location.Y);
}
else if (device.XCoor == 29073)
{
ctrl.Location = new Point(button340.Location.X, sfHWH3_1.Location.Y);
}
else if (device.XCoor == 36110)
{
ctrl.Location = new Point(button331.Location.X, sfHWH3_1.Location.Y);
}
else if (device.XCoor == 40733)
{
ctrl.Location = new Point(button329.Location.X, sfHWH3_1.Location.Y);
}
else if (device.XCoor == 45339)
{
ctrl.Location = new Point(button328.Location.X, sfHWH3_1.Location.Y);
}
else if (device.XCoor == 49038)
{
ctrl.Location = new Point(button281.Location.X, sfHWH3_1.Location.Y);
}
else if (device.XCoor == 53638)
{
ctrl.Location = new Point(button267.Location.X, sfHWH3_1.Location.Y);
}
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor >= 80325 && device.XCoor <= 94510)
{// 左环弯
//ctrl.Location = new Point(397, 126);
ctrl.Location = new Point(pictureBox147.Location.X, pictureBox147.Location.Y + pictureBox147.Size.Height / 2 - button865.Size.Height / 2);
if (device.XCoor == 94350)
{
ctrl.Location = new Point(button282.Location.X, sfHWH3_2.Location.Y);
}
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor >= 94510 && device.XCoor <= 176121)
{// 立库出库
//ctrl.Location = new Point((int)(sfHWH3_2.Location.X + (965/ 81611) * (device.XCoor)), ctrl.Location.Y);
ctrl.Location = new Point((int)(pictureBox147.Location.X + pictureBox147.Size.Width + Math.Round((float)temp3X / 81161, 4) * (device.XCoor - 94510)), sfHWH3_2.Location.Y);
if (device.XCoor == 96885)
{
ctrl.Location = new Point(button284.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 101492)
{
ctrl.Location = new Point(button288.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 104775)
{
ctrl.Location = new Point(button286.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 109361)
{
ctrl.Location = new Point(button289.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 113637)
{
ctrl.Location = new Point(button294.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 118236)
{
ctrl.Location = new Point(button292.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 121524)
{
ctrl.Location = new Point(button298.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 126125)
{
ctrl.Location = new Point(button296.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 129406)
{
ctrl.Location = new Point(button300.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 137547)
{
ctrl.Location = new Point(button301.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 142399)
{
ctrl.Location = new Point(button304.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 145478)
{
ctrl.Location = new Point(button305.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 147197)
{
ctrl.Location = new Point(button307.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 150332)
{
ctrl.Location = new Point(button309.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 152044)
{
ctrl.Location = new Point(button311.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 155172)
{
ctrl.Location = new Point(button313.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 156890)
{
ctrl.Location = new Point(button315.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 159990)
{
ctrl.Location = new Point(button317.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 162792)
{
ctrl.Location = new Point(button319.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 165891)
{
ctrl.Location = new Point(button321.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 168433)
{
ctrl.Location = new Point(button324.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 173025)
{
ctrl.Location = new Point(button326.Location.X, sfHWH3_2.Location.Y);
}
else if (device.XCoor == 175552)
{
ctrl.Location = new Point(button330.Location.X, sfHWH3_2.Location.Y);
}
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor >= 176121 && device.XCoor <= 191143)
{// 右环弯
//ctrl.Location = new Point(1410, 126);
ctrl.Location = new Point(pictureBox148.Location.X, pictureBox148.Location.Y + pictureBox148.Size.Height / 2 - button865.Size.Height / 2);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
/*
if (device.XCoor >= 0 && device.XCoor <= 3000)
{// 上环sfHWH3_1
ctrl.Location = new Point((int)(sfHWH3_1.Location.X + 0.015 * (device.XCoor)), ctrl.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
else if (device.XCoor >= 3001 && device.XCoor <= 6000)
{//下环sfHWH3_2
ctrl.Location = new Point((int)(sfHWH3_2.Location.X + 0.015 * (device.XCoor)), ctrl.Location.Y);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
*/
}
}
else if (pp == plCW)
{
if (device.DeviceIndex >= 15101 && device.DeviceIndex <= 15129)
{
int temp1X = pictureBox146.Location.X - pictureBox145.Location.X - pictureBox145.Size.Width - button865.Size.Width;
#region 常温环穿前输送机站台
if (device.XCoor == 999999)
{
ctrl.Location = new Point(1806, 1008);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
if (device.XCoor >= 0 && device.XCoor <= 191200)
{//常温入库区域
ctrl.Location = new Point((int)(pictureBox145.Location.X + pictureBox145.Size.Width + button865.Size.Width + Math.Round((float)temp1X / 191200, 4) * (device.XCoor)), sfCWH1_2.Location.Y);//pictureBox146.Size.Width +
if (device.XCoor == 2120)
{
ctrl.Location = new Point(button578.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 7076)
{
ctrl.Location = new Point(button586.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 10345)
{
ctrl.Location = new Point(button594.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 14275)
{
ctrl.Location = new Point(button588.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 21910)
{
ctrl.Location = new Point(button607.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 25195)
{
ctrl.Location = new Point(button612.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 28454)
{
ctrl.Location = new Point(button608.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 43832)
{
ctrl.Location = new Point(button624.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 47103)
{
ctrl.Location = new Point(button629.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 50390)
{
ctrl.Location = new Point(button625.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 65000)
{
ctrl.Location = new Point(button266.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 68238)
{
ctrl.Location = new Point(button645.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 71488)
{
ctrl.Location = new Point(button278.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 89925)
{
ctrl.Location = new Point(button651.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 93201)
{
ctrl.Location = new Point(button650.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 96441)
{
ctrl.Location = new Point(button652.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 114072)
{
ctrl.Location = new Point(button665.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 117326)
{
ctrl.Location = new Point(button664.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 120590)
{
ctrl.Location = new Point(button666.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 139834)
{
ctrl.Location = new Point(button679.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 143054)
{
ctrl.Location = new Point(button678.Location.X, sfCWH1_2.Location.Y);
}
if (device.XCoor == 146347)
{
ctrl.Location = new Point(button680.Location.X, sfCWH1_2.Location.Y);
}
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
#endregion
#region 常温环穿转弯区域 右半环
if (device.XCoor > 191200 && device.XCoor <= 211400)
{
ctrl.Location = new Point(pictureBox146.Location.X + pictureBox146.Size.Width - button865.Size.Width, pictureBox146.Location.Y + pictureBox146.Size.Height / 2 - button865.Size.Height / 2);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
#endregion
#region 常温环穿转弯区域 左半环
if (device.XCoor > 410800 && device.XCoor <= 424450)
{
ctrl.Location = new Point(pictureBox145.Location.X, pictureBox145.Location.Y + pictureBox145.Size.Height / 2 - button865.Size.Height / 2);
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
#endregion
#region 常温巷道前入库区域
if (device.XCoor > 211400 && device.XCoor <= 410800)
{
ctrl.Location = new Point((int)(pictureBox146.Location.X - button865.Size.Width - Math.Round((float)temp1X / 199400, 4) * (device.XCoor - 211400)), sfCWH1_1.Location.Y);//+ button865.Size.Width +
if (device.XCoor == 211701)
{
ctrl.Location = new Point(button776.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 214308)
{
ctrl.Location = new Point(button774.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 218958)
{
ctrl.Location = new Point(button772.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 222430)
{
ctrl.Location = new Point(button770.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 227098)
{
ctrl.Location = new Point(button768.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 231895)
{
ctrl.Location = new Point(button766.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 236488)
{
ctrl.Location = new Point(button764.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 239825)
{
ctrl.Location = new Point(button762.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 244460)
{
ctrl.Location = new Point(button760.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 247792)
{
ctrl.Location = new Point(button758.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 252442)
{
ctrl.Location = new Point(button756.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 256795)
{
ctrl.Location = new Point(button754.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 261442)
{
ctrl.Location = new Point(button752.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 264778)
{
ctrl.Location = new Point(button750.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 269447)
{
ctrl.Location = new Point(button748.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 272759)
{
ctrl.Location = new Point(button746.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 277418)
{
ctrl.Location = new Point(button744.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 281750)
{
ctrl.Location = new Point(button742.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 286396)
{
ctrl.Location = new Point(button740.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 289736)
{
ctrl.Location = new Point(button738.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 294398)
{
ctrl.Location = new Point(button736.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 297715)
{
ctrl.Location = new Point(button734.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 302361)
{
ctrl.Location = new Point(button732.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 306706)
{
ctrl.Location = new Point(button730.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 311362)
{
ctrl.Location = new Point(button728.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 314707)
{
ctrl.Location = new Point(button726.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 319361)
{
ctrl.Location = new Point(button724.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 322714)
{
ctrl.Location = new Point(button722.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 327353)
{
ctrl.Location = new Point(button720.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 331492)
{
ctrl.Location = new Point(button718.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 336144)
{
ctrl.Location = new Point(button716.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 339440)
{
ctrl.Location = new Point(button714.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 344094)
{
ctrl.Location = new Point(button712.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 347383)
{
ctrl.Location = new Point(button710.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 352021)
{
ctrl.Location = new Point(button708.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 355907)
{
ctrl.Location = new Point(button706.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 359013)
{
ctrl.Location = new Point(button704.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 361636)
{
ctrl.Location = new Point(button702.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 366233)
{
ctrl.Location = new Point(button700.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 369634)
{
ctrl.Location = new Point(button698.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 374224)
{
ctrl.Location = new Point(button639.Location.X, sfCWH1_1.Location.Y);
}
//if (device.XCoor == 378369)
//{
// ctrl.Location = new Point(button568.Location.X, sfCWH1_1.Location.Y);
//}
if (device.XCoor == 384354)
{
ctrl.Location = new Point(button639.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 391849)
{
ctrl.Location = new Point(button569.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 400398)
{
ctrl.Location = new Point(button571.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 407395)
{
ctrl.Location = new Point(button639.Location.X, sfCWH1_1.Location.Y);
}
if (device.XCoor == 410683)
{
ctrl.Location = new Point(button575.Location.X, sfCWH1_1.Location.Y);
}
tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
}
#endregion
}
//if (device.XCoor >= 0 && device.XCoor <= 3000)
//{// 上环sfCWH1_1
// ctrl.Location = new Point((int)(sfCWH1_1.Location.X + 0.015 * (device.XCoor)), ctrl.Location.Y);
// tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
// tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
//}
//else if (device.XCoor >= 3001 && device.XCoor <= 6000)
//{//下环sfCWH1_2
// ctrl.Location = new Point((int)(sfCWH1_2.Location.X + 0.015 * (device.XCoor)), ctrl.Location.Y);
// tw0 = (TextBox)pp.Controls[string.Format("t{0}", ctrl.Tag)];
// tw0.Location = new Point(ctrl.Location.X + ctrl.Size.Width / 2 - tw0.Size.Width / 2, ctrl.Location.Y + ctrl.Size.Height / 2 - tw0.Size.Height / 2);
//}
}
#endregion
}
#endregion
}
#region 设备被禁用
//richar.liu20140806
if (dvJY.Count > 0)
{
if (dvJY.Find(device.DeviceIndex) >= 0)
{
ctrl.BackColor = Color.Maroon;
}
}
#endregion
}
#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 dgvMonitor_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
//{
// int mfid = 0;
// Color BackColor = Color.YellowGreen;
// foreach (DataGridViewRow DGVRow in this.dgvMonitor.Rows)
// {
// if (DGVRow != null)
// {
// if (Convert.ToInt32(DGVRow.Cells["调度任务索引"].Value) != mfid)
// {
// mfid = Convert.ToInt32(DGVRow.Cells["调度任务索引"].Value);
// if (BackColor == Color.YellowGreen)
// {
// BackColor = Color.LightBlue;
// }
// else
// {
// BackColor = Color.YellowGreen;
// }
// DGVRow.DefaultCellStyle.BackColor = BackColor;
// }
// else
// {
// DGVRow.DefaultCellStyle.BackColor = BackColor;
// }
// if (Convert.ToInt32(DGVRow.Cells["f_status"].Value) >= 30)
// {
// DGVRow.DefaultCellStyle.BackColor = Color.Red;
// }
// if (Convert.ToInt32(DGVRow.Cells["f_status"].Value) == 2 || Convert.ToInt32(DGVRow.Cells["f_status"].Value) == 1)
// {
// DGVRow.DefaultCellStyle.BackColor = Color.Lime;
// }
// }
// }
//}
void ReRegisterClient()
{
//CStaticClass.ClientID = Dns.GetHostName();
//var ctx = new InstanceContext(CStaticClass.client);
//CStaticClass.WcfControl = new WcfControlMonitor.ControlMonitorClient(ctx);
//string errtext = string.Empty;
//CStaticClass.WcfControl.BeginRegisterClient(CStaticClass.UserID, "客户端:" + CStaticClass.ClientID + ",用户名:" + CStaticClass.UserID, new AsyncCallback(RegisterClientCallBack), null);
}
void RegisterClientCallBack(IAsyncResult ar)
{
try
{
string ErrText;
if (CStaticClass.WcfControl.EndRegisterClient(out ErrText, ar) == true)
{
CStaticClass.WCFOK = true;
devsn++;
if (devsn < devlist.Count())
{
CStaticClass.WcfControl.BeginSendAllDeviceStates(devlist[devsn].DeviceIndex, new AsyncCallback(SendAllDeviceStatesCallback), null);
}
else
{
devsn = 0;
CStaticClass.WcfControl.BeginSendAllDeviceStates(devlist[devsn].DeviceIndex, new AsyncCallback(SendAllDeviceStatesCallback), null);
}
}
else
{
CStaticClass.WcfControl.BeginLogoutClient("客户端:" + CStaticClass.ClientID + ",用户名:" + CStaticClass.UserID, new AsyncCallback(LogCallBack), "RegisterClientCallBack");
this.BeginInvoke(new MethodInvoker(delegate()
{
if (tsStatus.Text.IndexOf("EndRegisterClient时:" + ErrText) < 0)
{
tsStatus.ForeColor = Color.Red;
this.tsStatus.Text += "EndRegisterClient时:" + ErrText;
}
}));
}
}
catch (Exception ex)
{
this.BeginInvoke(new MethodInvoker(delegate()
{
if (tsStatus.Text.IndexOf("EndRegisterClient时:" + ex.Message) < 0)
{
tsStatus.ForeColor = Color.Red;
this.tsStatus.Text += "EndRegisterClient时:" + ex.Message;
}
}));
}
}
private void btClearStatus_Click(object sender, EventArgs e)
{
this.tsStatus.Text = "";
}
private void MIStartRetrieveTask_Click(object sender, EventArgs e)
{
ClickObtainTask();
CStaticClass.WcfControl.BeginObtainTask("", "UPDATE", new AsyncCallback(CallbackObtainTask), null);
}
private void MIStopRetrieveTask_Click(object sender, EventArgs e)
{
ClickStopObtainTask();
CStaticClass.WcfControl.BeginStopObtainTask(new AsyncCallback(CallbackStopObtainTask),null );
}
private void MITurnOn_Click(object sender, EventArgs e)
{
ClickOrderTurnOn();
CStaticClass.WcfControl.BeginOrderTurnOn(new AsyncCallback(CallbackTurnOn),null );
}
private void MITurnOff_Click(object sender, EventArgs e)
{
if (MessageBox.Show("您确认要“关闭命令开关”吗?如果“关闭命令开关”将导致调度计算机与所有设备通讯中断!", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
{
return;
}
ClickOrderTurnOff();
CStaticClass.WcfControl.BeginOrderTurnOff(new AsyncCallback(CallbackTurnOff),null );
}
private void MISystemInit_Click(object sender, EventArgs e)
{
FrmSystemInit.FormInstance.Show();
}
void CallbackObtainTask(IAsyncResult ar)
{
CStaticClass.WcfControl.EndObtainTask(ar);
}
void CallbackStopObtainTask(IAsyncResult ar)
{
CStaticClass.WcfControl.EndStopObtainTask(ar);
}
void CallbackTurnOn(IAsyncResult ar)
{
CStaticClass.WcfControl.EndOrderTurnOn(ar);
}
void CallbackTurnOff(IAsyncResult ar)
{
CStaticClass.WcfControl.EndOrderTurnOff(ar);
}
void CallBackHeartbeat(IAsyncResult ar)
{this.BeginInvoke(new MethodInvoker(delegate()
{
try
{
string errtext = string.Empty;
Model.MonitorInfo mi;
CStaticClass.WcfControl.EndHeartbeat(out mi, ar);
if (CStaticClass.UserID.ToUpper() == "SA")
{
CStaticClass.Order = mi.Orderturnon;
CStaticClass.ObtainManageTask = mi.Obtaintask;
if (mi.Orderturnon == true)
{
ClickOrderTurnOn();
}
else
{
ClickOrderTurnOff();
}
if (mi.Obtaintask == true)
{
ClickObtainTask();
}
else
{
ClickStopObtainTask();
}
}
if (mi.S7connectOnline.Count > 0)
{
foreach (PictureBox ctrl in pS7conn.Controls.OfType<PictureBox>())
{
if (mi.S7connectOnline.ContainsKey(ctrl.Name.Substring(2)) && (mi.S7connectOnline[ctrl.Name.Substring(2)] == 0))
{
ctrl.Image = wcfControlMonitorClient.Properties.Resources.ProgressSuccess;
}
else
{
ctrl.Image = wcfControlMonitorClient.Properties.Resources.ProgressError;
}
}
}
}
catch (Exception ex)
{
if (tsStatus.Text.IndexOf("CallBackHeartbeat时:" + ex.Message) < 0)
{
tsStatus.ForeColor = Color.Red;
this.tsStatus.Text += "CallBackHeartbeat时:" + ex.Message;
}
ReRegisterClient();
}
}));
}
void ClickObtainTask()
{
if (MITurnOn.Checked == true)
{
if (this.Text != CStaticClass.SystemName + "【开始获取任务!】" + "【正在执行自动命令!】")
{
this.Text = CStaticClass.SystemName + "【开始获取任务!】" + "【正在执行自动命令!】";
}
}
else
{
if (this.Text != CStaticClass.SystemName + "【开始获取任务!】")
{
this.Text = CStaticClass.SystemName + "【开始获取任务!】";
}
}
MIStartRetrieveTask.Checked = true;
MIStartRetrieveTask.Enabled = false;
MIStopRetrieveTask.Checked = false;
MIStopRetrieveTask.Enabled = true;
}
void ClickStopObtainTask()
{
if (MITurnOn.Checked == true)
{
if (this.Text != CStaticClass.SystemName + "【正在执行自动命令!】")
{
this.Text = CStaticClass.SystemName + "【正在执行自动命令!】";
}
}
else
{
if (this.Text != CStaticClass.SystemName)
{
this.Text = CStaticClass.SystemName;
}
}
MIStartRetrieveTask.Checked = false;
MIStartRetrieveTask.Enabled = true;
MIStopRetrieveTask.Enabled = false;
MIStopRetrieveTask.Checked = true;
}
void ClickOrderTurnOn()
{
if (MIStartRetrieveTask.Checked == true)
{
if (this.Text != CStaticClass.SystemName + "【开始获取任务!】" + "【正在执行自动命令!】")
{
this.Text = CStaticClass.SystemName + "【开始获取任务!】" + "【正在执行自动命令!】";
}
}
else
{
if (this.Text != CStaticClass.SystemName + "【正在执行自动命令!】")
{
this.Text = CStaticClass.SystemName + "【正在执行自动命令!】";
}
}
MITurnOff.Enabled = true;
MITurnOn.Enabled = false;
MITurnOff.Checked = false;
MITurnOn.Checked = true;
}
void ClickOrderTurnOff()
{
if (MIStartRetrieveTask.Checked == true)
{
if (this.Text != CStaticClass.SystemName + "【开始获取任务!】")
{
this.Text = CStaticClass.SystemName + "【开始获取任务!】";
}
}
else
{
if (this.Text != CStaticClass.SystemName)
{
this.Text = CStaticClass.SystemName;
}
}
MITurnOff.Enabled = false;
MITurnOn.Enabled = true;
MITurnOn.Checked = false;
MITurnOff.Checked = true;
}
private void MIManageConnectInfo_Click(object sender, EventArgs e)
{
FrmConnectDB.FormInstance.ConnectType = "Manage";
FrmConnectDB.FormInstance.Show();
}
public bool IsEquals(Array array1, Array array2, int arraylength)
{//20090902新增加arraylength
//比较类型是否一样
if ((array1 == null) || (array2 == null)) return false;
if (!Object.ReferenceEquals(array1.GetType(), array2.GetType()))
{
return false;
}
//比较长度是否一样
if (array1.GetLength(0) != array2.GetLength(0))
{
return false;
}
//比较成员是否对应相等
ValueType v1, v2;
for (int i = 0; i < arraylength; i++)
{
v1 = (ValueType)array1.GetValue(i);
v2 = (ValueType)array2.GetValue(i);
if (!v1.Equals(v2))
{
return false;
}
}
return true;
}
string GetBarcodeFromMonitorIndex(int taskindex)
{
DataView dvb = new DataView(); StringBuilder sss = new StringBuilder("");
try
{
sss.Append("SELECT F_TxtParam FROM T_Monitor_Task WHERE (F_MonitorIndex = ").Append(taskindex).Append(")");
dvb = dbo.ExceSQL(sss.ToString()).Tables[0].DefaultView;
if (dvb.Count > 0)
{
return dvb[0]["F_TxtParam"].ToString();
}
else
{
return "-";
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
dvb.Dispose();
}
}
int GetMonitorRunTaskIndexFromBarCode(StringBuilder BarCode)
{//20110216
DataView dv = new DataView();
try
{
string bc = BarCode.ToString();
dv = dbo1.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;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
dv.Dispose();
}
}
int GetMonitorAskTaskIndexFromBarCode(StringBuilder BarCode)
{//20110216
DataView dv = new DataView();
try
{
string bc = BarCode.ToString();
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) or (F_SendFlag=2 and F_Status=0)) and F_DeviceCommandIndex=6 order by F_MonitorIndex asc", bc)).Tables[0].DefaultView;
if (dv.Count > 0)
{
return Convert.ToInt32(dv[0]["F_MonitorIndex"]);
}
else
{
return -1;
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
dv.Dispose();
}
}
int GetMonitorTaskIndexFromBarCode(StringBuilder BarCode, Model.MDevice devinf)
{//20110216
DataView dv = new DataView();
try
{
string bc = BarCode.ToString();
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_NumParam4 = {1} or F_NumParam4 = {2}) and F_Status>0 order by F_MonitorIndex asc", bc, devinf.DeviceIndex, devinf.DeviceVisual)).Tables[0].DefaultView;
if (dv.Count > 0)
{
return Convert.ToInt32(dv[0]["F_MonitorIndex"]);
}
else
{
//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;
//}
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
dv.Dispose();
}
}
string GetMonitorTaskStartTime(int taskindex, out int order)
{//20110216
DataView dv = new DataView();
try
{
dv = dbo.ExceSQL(string.Format("SELECT F_StartTime,F_DeviceCommandIndex FROM T_Monitor_Task WHERE F_MonitorIndex={0}", taskindex)).Tables[0].DefaultView;
if (dv.Count > 0)
{
order = Convert.ToInt32(dv[0]["F_DeviceCommandIndex"]);
return dv[0]["F_StartTime"].ToString();
}
else
{
order = -1;
return "-";
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
dv.Dispose();
}
}
private void MIZCKSetIO_Click(object sender, EventArgs e)
{
FrmZCKSetIOStation.FormInstance.Show();
}
private void MIErrorSolutions_Click(object sender, EventArgs e)
{//20151120
FrmDeviceErrorSolutions.FormInstance.Show();
}
private void MITaskCount_Click(object sender, EventArgs e)
{//20151120
FrmTaskManage.FormInstance.Show();
}
private void MIStorageCheck_Click(object sender, EventArgs e)
{
FrmStorageCheck.FormInstance.Show();
}
private void MILanePile_Click(object sender, EventArgs e)
{
FrmLanePile.FormInstance.Show();
}
private void MIPalletCode_Click(object sender, EventArgs e)
{
FrmWMSOutTask.FormInstance.Show();
}
private void MIErrorLog_Click(object sender, EventArgs e)
{
FrmDeviceErrorLog.FormInstance.Show();
}
private void MIDeskStatus_Click(object sender, EventArgs e)
{
FrmDeskStatus.FormInstance.Show();
}
private void MIWmsRecall_Click(object sender, EventArgs e)
{
FrmWmsRecall.FormInstance.Show();
}
private void MIMutiOutTask_Click(object sender, EventArgs e)
{
FrmAutoOutTasks.FormInstance.Show();
}
private void MI14005OUT_Click(object sender, EventArgs e)
{
FrmOutCountandHave14005.FormInstance.Show();
}
private void MIRGVAreaSet_Click(object sender, EventArgs e)
{
FrmRGVAreaSet.FormInstance.Show();
}
private void MIAltManangel_Click(object sender, EventArgs e)
{
FrmModifyManagel.FormInstance.Show();
}
private void MIAltMonitorl_Click(object sender, EventArgs e)
{
FrmModifyMonitorl.FormInstance.Show();
}
private void MIsollow_Click(object sender, EventArgs e)
{
FrmOutCountandHave14005.FormInstance.Show();
}
private void textBox244_TextChanged(object sender, EventArgs e)
{
}
}
}