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.
1280 lines
49 KiB
1280 lines
49 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.ServiceModel;
|
|
using WcfControlMonitorLib;
|
|
using CommonLib;
|
|
using System.Globalization;
|
|
using System.Security.Cryptography;//20151019richard
|
|
namespace wcfControlMonitorClient
|
|
{
|
|
public partial class FrmHost : Form
|
|
{
|
|
Model.MonitorInfo mi;//20140824richard
|
|
//20130122
|
|
private static FrmHost _formInstance;
|
|
//20130122
|
|
public static FrmHost FormInstance
|
|
{
|
|
get
|
|
{
|
|
if (_formInstance == null)
|
|
{
|
|
_formInstance = new FrmHost();
|
|
}
|
|
return _formInstance;
|
|
}
|
|
set { _formInstance = value; }
|
|
}
|
|
int timersum = 0;//20120513
|
|
int timerefesh = 0;//20150103增加断网恢复
|
|
DBFactory.DBOperator dbo ;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public FrmHost()
|
|
{
|
|
try
|
|
{
|
|
dbo = CStaticClass.dbo;
|
|
InitializeComponent();
|
|
CStaticClass.SystemName = CommonClassLib.AppSettings.GetValue("SystemName");
|
|
this.notifyIcon1.Text = CStaticClass.SystemName;
|
|
this.Text = CStaticClass.SystemName;
|
|
//WCSServer.ControlMonitorClient aa = new WCSServer.ControlMonitorClient(new InstanceContext(new FrmSystemInit()));
|
|
//Model.MonitorInfo mi=new Model.MonitorInfo();
|
|
//if (aa.Heartbeat(out mi) == true)
|
|
//{
|
|
// MessageBox.Show("网络中已经有WCS服务端工作,不要重复启动WCS服务!");
|
|
// this.Close();
|
|
// return;
|
|
//}
|
|
_host = new ServiceHost(typeof(WcfControlMonitorLib.SControlMonitor));
|
|
_host.Open();
|
|
//Silverlight跨域访问服务
|
|
//policyHost = ClientCrossDomainAccessPolicy.GetHost(_host.BaseAddresses[0].Host);
|
|
//policyHost.Open();
|
|
SControlMonitor.ChannelOpen += new ClientLogEventHandler(SControlMonitor_ChannelOpen);
|
|
SControlMonitor.ClientLogout += new ClientLogEventHandler(SControlMonitor_ClientLogout);
|
|
SControlMonitor.RefreshMonitor += new RefreshMonitorEventHandler(SControlMonitor_RefreshMonitor);
|
|
SControlMonitor.PLCCommonUpdateDB += new CUpdateDBEventHandler(SControlMonitor_PLCCommonUpdateDB);//PLC//20121108
|
|
SControlMonitor.AGVUpdateDB += new CUpdateDBEventHandler(SControlMonitor_AGVUpdateDB);//AGV//20121108
|
|
SControlMonitor.SendBarcode += new CStringInfoEventHandler(SControlMonitor_SendBarcode);
|
|
SControlMonitor.WriteDarkCasket += new CWriteDarkCasketEventHandler(SControlMonitor_WriteDarkCasket);//20121108
|
|
SControlMonitor.SendDeviceOrder += new CSendDeviceOrderEventHandler(SControlMonitor_SendDeviceOrder); ;//20121108
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message + ex.InnerException, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
this.Close();
|
|
}
|
|
}
|
|
|
|
void SControlMonitor_AGVUpdateDB(object sender, CUpdateDBChangeEventArgs e)
|
|
{//20120616
|
|
this.BeginInvoke(new MethodInvoker(delegate()
|
|
{ CStaticClass.WcfControl.DealWithListenAGVState_UpdateDB(sender,e); }));
|
|
|
|
}
|
|
|
|
void SControlMonitor_PLCCommonUpdateDB(object sender, CUpdateDBChangeEventArgs e)
|
|
{
|
|
|
|
string errtext=string.Empty;
|
|
this.BeginInvoke(new MethodInvoker(delegate()
|
|
{CStaticClass.WcfControl.DealWithDeviceState(out errtext, e.Deviceindex, e.SplitbyteValue, e.Devicestates);}));
|
|
|
|
}
|
|
void SControlMonitor_SendBarcode(object sender, CStringInfoEventArgs e)
|
|
{
|
|
string errtext = string.Empty;
|
|
this.BeginInvoke(new MethodInvoker(delegate()
|
|
{
|
|
CStaticClass.WcfControl.WriteDBData(e.Deviceindex,"DB1",e.Barcode+","+e.Confirm.ToString(),out errtext);
|
|
dbo.ExceSQL(string.Format(" update T_Base_PLC_Ask set F_TaskIndex={0} WHERE (F_DeviceIndex = {1})", e.Deviceindex,Convert.ToInt32(sender)));
|
|
}));
|
|
|
|
}
|
|
void SControlMonitor_SendDeviceOrder(object sender, CSendDeviceOrderEventArgs e)
|
|
{//20121108
|
|
this.BeginInvoke(new MethodInvoker(delegate()
|
|
{ CStaticClass.WcfControl.DealWithSendDeviceOrder(sender, e); }));
|
|
}
|
|
void SControlMonitor_WriteDarkCasket(object sender, CWriteDarkCasketEventArgs e)
|
|
{//20121108
|
|
this.BeginInvoke(new MethodInvoker(delegate()
|
|
{ CStaticClass.WcfControl.DealWithWriteDarkCasket(sender, e); }));
|
|
}
|
|
|
|
void SControlMonitor_CDeviceState(object sender, CDeviceStateChangeEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
SendDeviceInfosToClient(e.Devinfo);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf("SControlMonitor_CDeviceState:" + ex.StackTrace + ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += "SControlMonitor_CDeviceState:" + ex.StackTrace + ex.Message;
|
|
}
|
|
}
|
|
}
|
|
|
|
void SControlMonitor_RefreshMonitor(RefreshMonitorEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.BeginInvoke(new MethodInvoker(delegate()
|
|
{
|
|
SendMessageToClient(e.RefreshObjectName + "@" + e.RefreshObjectInfo);
|
|
}));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf("SControlMonitor_RefreshMonitor:" + ex.StackTrace + ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += "SControlMonitor_RefreshMonitor:" + ex.StackTrace + ex.Message;
|
|
}
|
|
}
|
|
}
|
|
|
|
void SControlMonitor_DataChange(object sender, CDataChangeEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
SendMessageToClient(sender.ToString());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf("SControlMonitor_DataChange:" + ex.StackTrace + ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += "SControlMonitor_DataChange:" + ex.StackTrace + ex.Message;
|
|
}
|
|
}
|
|
}
|
|
|
|
void SControlMonitor_ClientLogout(ClientLogEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
AddList1Info(e.clientInfo);//20120503
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf("SControlMonitor_ClientLogout:" + ex.StackTrace + ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += "SControlMonitor_ClientLogout:" + ex.StackTrace + ex.Message;
|
|
}
|
|
}
|
|
}
|
|
|
|
void SControlMonitor_ChannelOpen(ClientLogEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
AddList1Info(e.clientInfo);//20120503
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf("SControlMonitor_ChannelOpen:" + ex.StackTrace + ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += "SControlMonitor_ChannelOpen:" + ex.StackTrace + ex.Message;
|
|
}
|
|
}
|
|
}
|
|
private ServiceHost _host = null;
|
|
private ServiceHost policyHost = null;
|
|
private void FrmHost_Load(object sender, EventArgs e)
|
|
{
|
|
if (WcfControlMonitorLib.CStaticClass.Automatic == "1")
|
|
{
|
|
MIStartRetrieveTask_Click(sender, e);
|
|
MITurnOn_Click(sender, e);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void MIDataClear_Click(object sender, EventArgs e)
|
|
{
|
|
if (MessageBox.Show("您确认清空调度系统的调度队列和设备指令队列数据吗?这个操作将导致调度系统丢失当前记录的所有数据,并且使系统恢复到初始状态!", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
string errtext=string.Empty;
|
|
if (CStaticClass.WcfControl.DataClear(out errtext) == false)
|
|
{
|
|
MessageBox.Show(errtext, "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
void SendMessageToClient(string strmessage)
|
|
{
|
|
IClient cl=null;
|
|
try
|
|
{
|
|
if(AddList1Info(strmessage)==false)return ;//20130510
|
|
var list = WcfControlMonitorLib.SControlMonitor.ClientCallbackLists;
|
|
if (list == null || list.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
lock (list)
|
|
{
|
|
foreach (System.Collections.DictionaryEntry client in list)
|
|
{
|
|
// Broadcast
|
|
cl = (IClient)client.Key;
|
|
//string aa = client.Value.ToString();
|
|
//this.BeginInvoke(new MethodInvoker(delegate()
|
|
//{
|
|
//20140824richard
|
|
if (strmessage == "巡检客户端")
|
|
{
|
|
cl.BeginSendOrderMessage(mi, new AsyncCallback(SendOrderMessageCallback), mi);
|
|
}
|
|
else
|
|
{
|
|
cl.BeginSendMessage(strmessage, new AsyncCallback(sendMessageCallback), strmessage);
|
|
|
|
}
|
|
//20140824richard
|
|
//}));
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (cl != null)
|
|
{
|
|
WcfControlMonitorLib.SControlMonitor.ClientCallbackLists.Remove(cl);
|
|
WcfControlMonitorLib.SControlMonitor.ClientShowLists.Remove(cl);
|
|
}
|
|
AddList1Info(string.Format("SendMessageToClient时异常:{0}", ex.Message));//20120503
|
|
//if (listBox1.Items.Count >= 100) listBox1.Items.Clear();
|
|
//this.listBox1.Items.Add(string.Format("SendMessageToClient时异常:{0},{1}" , ex.Message,DateTime.Now.ToString("u")));
|
|
}
|
|
}
|
|
void SendOrderMessageCallback(IAsyncResult ar)
|
|
{
|
|
|
|
}
|
|
void sendMessageCallback(IAsyncResult ar)
|
|
{
|
|
try
|
|
{
|
|
this.BeginInvoke(new MethodInvoker(delegate()
|
|
{
|
|
|
|
string sem = (string)ar.AsyncState;
|
|
AddList1Info(sem);//20120503
|
|
//if (listBox1.Items.Count >= 100) listBox1.Items.Clear();
|
|
//if (listBox1.Items.Count >= 1)
|
|
//{
|
|
// if (this.listBox1.Items[listBox1.Items.Count - 1].ToString().IndexOf(sem) >= 0) return;
|
|
//}
|
|
//if (sem == "巡检客户端") return;
|
|
//listBox1.Items.Add(DateTime.Now.ToLongTimeString()+sem);
|
|
|
|
}));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this.BeginInvoke(new MethodInvoker(delegate()
|
|
{
|
|
if (tsStatus.Text.IndexOf("巡检客户端sendMessageCallback:" + ex.StackTrace + ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += "巡检客户端sendMessageCallback:" + ex.StackTrace + ex.Message;
|
|
}
|
|
}));
|
|
}
|
|
}
|
|
void SendDeviceInfosToClient(Model.MDevice devinfo)
|
|
{
|
|
IClient cl = null;
|
|
try
|
|
{
|
|
var list = WcfControlMonitorLib.SControlMonitor.ClientCallbackLists;
|
|
if (list == null || list.Count == 0)
|
|
return;
|
|
lock (list)
|
|
{
|
|
foreach (System.Collections.DictionaryEntry client in list)
|
|
{
|
|
// Broadcast
|
|
cl = (IClient)client.Key;
|
|
cl.BeginSendDeviceInfo(devinfo, new AsyncCallback(sendDeviceInfosCallback), null);
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (cl != null)
|
|
{
|
|
WcfControlMonitorLib.SControlMonitor.ClientCallbackLists.Remove(cl);
|
|
WcfControlMonitorLib.SControlMonitor.ClientShowLists.Remove(cl);
|
|
}
|
|
AddList1Info(string.Format("SendDeviceInfosToClient时异常:{0}", ex.Message));//20120503
|
|
//if (listBox1.Items.Count >= 100) listBox1.Items.Clear();
|
|
//this.listBox1.Items.Add(string.Format("SendDeviceInfosToClient时异常:{0},{1}" , ex.Message , DateTime.Now.ToString("u")));
|
|
}
|
|
}
|
|
|
|
void sendDeviceInfosCallback(IAsyncResult ar)
|
|
{
|
|
|
|
}
|
|
private void FrmHost_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
if (MessageBox.Show("您确认要关闭"+CStaticClass.SystemName+"吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
|
|
{
|
|
e.Cancel = true;
|
|
return;
|
|
}
|
|
if (_host != null)
|
|
{
|
|
SControlMonitor.ChannelOpen -= new ClientLogEventHandler(SControlMonitor_ChannelOpen);
|
|
SControlMonitor.ClientLogout -= new ClientLogEventHandler(SControlMonitor_ClientLogout);
|
|
SControlMonitor.DataChange -= new CDataSourceChangeEventHandler(SControlMonitor_DataChange);
|
|
SControlMonitor.RefreshMonitor -= new RefreshMonitorEventHandler(SControlMonitor_RefreshMonitor);
|
|
SControlMonitor.CDeviceState -= new CDeviceStateChangeEventHandler(SControlMonitor_CDeviceState);
|
|
SControlMonitor.PLCCommonUpdateDB -= new CUpdateDBEventHandler(SControlMonitor_PLCCommonUpdateDB);
|
|
SControlMonitor.SendBarcode -= new CStringInfoEventHandler(SControlMonitor_SendBarcode);
|
|
_host.Close();
|
|
IDisposable host = _host as IDisposable;
|
|
host.Dispose();
|
|
}
|
|
CommonClassLib.AppSettings.dbo.Close();
|
|
CommonClassLib.AppSettings.dboM.Close();
|
|
}
|
|
|
|
private void MIStartRetrieveTask_Click(object sender, EventArgs e)
|
|
{
|
|
if (MITurnOn.Checked == true)
|
|
{
|
|
this.Text = CStaticClass.SystemName + "【开始获取任务!】" + "【正在执行自动命令!】";//20120510
|
|
}
|
|
else
|
|
{
|
|
this.Text = CStaticClass.SystemName + "【开始获取任务!】";//20120510
|
|
}
|
|
CStaticClass.WcfControl.ObtainTask("", "UPDATE");
|
|
MIStopRetrieveTask.Enabled = true;
|
|
//CStaticClass.ObtainManageTask = true;
|
|
MIStartRetrieveTask.Checked = true;
|
|
MIStopRetrieveTask.Checked = false;
|
|
}
|
|
|
|
private void MIStopRetrieveTask_Click(object sender, EventArgs e)
|
|
{
|
|
if (MITurnOn.Checked == true)
|
|
{
|
|
this.Text = CStaticClass.SystemName + "【正在执行自动命令!】";//20120510
|
|
}
|
|
else
|
|
{
|
|
this.Text = CStaticClass.SystemName;//20120510
|
|
}
|
|
CStaticClass.WcfControl.StopObtainTask();
|
|
//CStaticClass.ObtainManageTask = false;
|
|
//20120510CStaticClass.WcfControl.StopObtainTask();
|
|
ToolStripMenuItem tsm;
|
|
for (int i = 0; i < MIStartRetrieveTask.DropDown.Items.Count; i++)
|
|
{
|
|
tsm = (ToolStripMenuItem)MIStartRetrieveTask.DropDown.Items[i];
|
|
tsm.Checked = false;
|
|
}
|
|
MIStartRetrieveTask.Checked = false;
|
|
MIStartRetrieveTask.Enabled = true;
|
|
|
|
MIStopRetrieveTask.Enabled = false;
|
|
MIStopRetrieveTask.Checked = true;
|
|
}
|
|
void ToolStripMenu_Click(object sender, EventArgs e)
|
|
{
|
|
ToolStripMenuItem tsm; bool ifget = false;
|
|
|
|
DataView dv;
|
|
char[] cc = new char[1] { ':' };
|
|
int laneway = 0; StringBuilder minz = new StringBuilder(); StringBuilder maxz = new StringBuilder();
|
|
StringBuilder wherez = new StringBuilder();
|
|
ToolStripMenuItem aa = (ToolStripMenuItem)sender;
|
|
|
|
if (aa.Name == "MCAll")
|
|
{
|
|
if (aa.Checked == true)
|
|
{
|
|
aa.Checked = false;
|
|
CStaticClass.WcfControl.ObtainTask("", "UPDATE");
|
|
|
|
}
|
|
else
|
|
{
|
|
aa.Checked = true;
|
|
CStaticClass.WcfControl.ObtainTask(" or (1=1) ", "UPDATE");
|
|
|
|
}
|
|
//20100625修正不能获取站台到站台的任务
|
|
|
|
for (int i = 0; i < MIStartRetrieveTask.DropDown.Items.Count; i++)
|
|
{
|
|
|
|
tsm = (ToolStripMenuItem)MIStartRetrieveTask.DropDown.Items[i];
|
|
if (tsm.Name != "MCAll")
|
|
{
|
|
|
|
tsm.Checked = aa.Checked;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//20100625修正不能获取站台到站台的任务
|
|
|
|
}
|
|
else
|
|
{
|
|
laneway = Convert.ToInt32(aa.Text.Split(cc)[1]);
|
|
dv = dbo.ExceSQL("select min(f_z) as minZ from st_cell where flaneway=" + laneway + "").Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if (dv[0]["minZ"].ToString().Length == 1)
|
|
{
|
|
minz = minz.Append("'0").Append(dv[0]["minZ"].ToString()).Append("-00-00'");
|
|
}
|
|
else
|
|
{
|
|
minz = minz.Append("'" + dv[0]["minZ"].ToString()).Append("-00-00'");
|
|
}
|
|
|
|
}
|
|
dv = dbo.ExceSQL("select max(f_z) as maxZ from st_cell where flaneway=" + laneway + "").Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if (dv[0]["maxZ"].ToString().Length == 1)
|
|
{
|
|
maxz = maxz.Append("'0").Append(dv[0]["maxZ"].ToString()).Append("-99-99'");
|
|
}
|
|
else
|
|
{
|
|
maxz = maxz.Append("'" + dv[0]["maxZ"].ToString()).Append("-99-99'");
|
|
}
|
|
}
|
|
wherez.Append(" or ((START_DEVICE_CODE between ").Append(minz).Append(" and ").Append(maxz).Append(" ) or (END_DEVICE_CODE between ").Append(minz).Append(" and ").Append(maxz).Append("))");
|
|
if (aa.Checked == true)
|
|
{
|
|
aa.Checked = false;
|
|
//20100625修正不能获取站台到站台的任务
|
|
CStaticClass.WcfControl.ObtainTask(wherez.ToString(), "REPLACE");
|
|
|
|
|
|
ToolStripMenuItem cm = new ToolStripMenuItem();
|
|
ToolStripMenuItem all = (ToolStripMenuItem)MIStartRetrieveTask.DropDown.Items["MCAll"];
|
|
CStaticClass.WcfControl.ObtainTask(" or (1=1) ", "REPLACE");
|
|
all.Checked = false;
|
|
StringBuilder wherez1 = new StringBuilder();
|
|
|
|
for (int ii = 0; ii < MIStartRetrieveTask.DropDown.Items.Count; ii++)
|
|
{
|
|
//20101208
|
|
minz.Remove(0, minz.Length);
|
|
maxz.Remove(0, maxz.Length);
|
|
|
|
cm = (ToolStripMenuItem)MIStartRetrieveTask.DropDown.Items[ii];
|
|
if ((cm.Checked == true) && (cm.Name != aa.Name) && (cm.Name != "MCAll"))
|
|
{
|
|
laneway = Convert.ToInt32(cm.Text.Split(cc)[1]);
|
|
dv = dbo.ExceSQL("select min(f_z) as minZ from st_cell where flaneway=" + laneway + "").Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if (dv[0]["minZ"].ToString().Length == 1)
|
|
{
|
|
minz = minz.Append("'0").Append(dv[0]["minZ"].ToString()).Append("-00-00'");
|
|
}
|
|
else
|
|
{
|
|
minz = minz.Append("'" + dv[0]["minZ"].ToString()).Append("-00-00'");
|
|
}
|
|
|
|
}
|
|
dv = dbo.ExceSQL("select max(f_z) as maxZ from st_cell where flaneway=" + laneway + "").Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if (dv[0]["maxZ"].ToString().Length == 1)
|
|
{
|
|
maxz = maxz.Append("'0").Append(dv[0]["maxZ"].ToString()).Append("-99-99'");
|
|
}
|
|
else
|
|
{
|
|
maxz = maxz.Append("'" + dv[0]["maxZ"].ToString()).Append("-99-99'");
|
|
}
|
|
}
|
|
wherez1.Append(" or ((START_DEVICE_CODE between ").Append(minz).Append(" and ").Append(maxz).Append(" ) or (END_DEVICE_CODE between ").Append(minz).Append(" and ").Append(maxz).Append("))");
|
|
|
|
}
|
|
|
|
}
|
|
CStaticClass.WcfControl.ObtainTask(wherez1.ToString(), "APPEND");
|
|
|
|
//20100625修正不能获取站台到站台的任务
|
|
}
|
|
else
|
|
{
|
|
aa.Checked = true;
|
|
|
|
CStaticClass.WcfControl.ObtainTask(wherez.ToString(), "APPEND");
|
|
}
|
|
}
|
|
|
|
MIStartRetrieveTask_Click(sender, e);
|
|
|
|
for (int i = 0; i < MIStartRetrieveTask.DropDown.Items.Count; i++)
|
|
{
|
|
tsm = (ToolStripMenuItem)MIStartRetrieveTask.DropDown.Items[i];
|
|
if (tsm.Checked == true)
|
|
{
|
|
ifget = true;
|
|
}
|
|
}
|
|
if (ifget == false)
|
|
{
|
|
MIStopRetrieveTask_Click(sender, e);
|
|
|
|
}
|
|
}
|
|
|
|
private void MITurnOn_Click(object sender, EventArgs e)
|
|
{
|
|
MITurnOff.Enabled = true;
|
|
MITurnOn.Enabled = false;
|
|
tsmTurnOff.Enabled = true;
|
|
tsmTurnOn.Enabled = false;
|
|
|
|
tsmTurnOff.Checked = false;
|
|
tsmTurnOn.Checked = true;
|
|
MITurnOff.Checked = false;
|
|
MITurnOn.Checked = true;
|
|
//CStaticClass.Order = true;
|
|
CStaticClass.WcfControl.OrderTurnOn();
|
|
if (MIStartRetrieveTask.Checked == true)
|
|
{
|
|
this.Text = CStaticClass.SystemName + "【开始获取任务!】" + "【正在执行自动命令!】";
|
|
}
|
|
else
|
|
{
|
|
this.Text = CStaticClass.SystemName + "【正在执行自动命令!】";
|
|
}
|
|
//20120510CStaticClass.WcfControl.OrderTurnOn();
|
|
}
|
|
|
|
private void MITurnOff_Click(object sender, EventArgs e)
|
|
{
|
|
if (MessageBox.Show("您确认要“关闭命令开关”吗?如果“关闭命令开关”将导致调度计算机与所有设备通讯中断!", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK)
|
|
{
|
|
return;
|
|
}
|
|
CStaticClass.WcfControl.OrderTurnOff();
|
|
//CStaticClass.Order = false;
|
|
MITurnOff.Enabled = false;
|
|
MITurnOn.Enabled = true;
|
|
tsmTurnOff.Enabled = false;
|
|
tsmTurnOn.Enabled = true;
|
|
|
|
tsmTurnOn.Checked = false;
|
|
tsmTurnOff.Checked = true;
|
|
MITurnOn.Checked = false;
|
|
MITurnOff.Checked = true;
|
|
|
|
if (MIStartRetrieveTask.Checked == true)
|
|
{
|
|
this.Text = CStaticClass.SystemName + "【开始获取任务!】";
|
|
}
|
|
else
|
|
{
|
|
this.Text = CStaticClass.SystemName;
|
|
}
|
|
//20120510CStaticClass.WcfControl.OrderTurnOff();
|
|
}
|
|
|
|
private void timerObtainTask_Tick(object sender, EventArgs e)
|
|
{
|
|
timerObtainTask.Enabled = false;
|
|
try
|
|
//if (CStaticClass.ObtainManageTask == true)
|
|
{
|
|
string errtext = string.Empty;
|
|
|
|
if (CStaticClass.WcfControl.GetAllManageTask(out errtext) == false)
|
|
{
|
|
if (tsStatus.Text.IndexOf(errtext) < 0)
|
|
{
|
|
tsStatus.Text += errtext;
|
|
}
|
|
}
|
|
#region AGV任务没响应,任务重发
|
|
|
|
//int DeviceIdx;
|
|
//int TaskIdx = 0;
|
|
//StringBuilder sql = new StringBuilder();
|
|
//DataView dvmo =new DataView();
|
|
//sql.Remove(0, sql.Length);
|
|
//sql.Append("SELECT F_DeviceIndex,F_DeviceKindIndex,F_MaxSendCount,F_SendInterval FROM T_Base_Device WHERE F_DeviceKindIndex = 6");
|
|
//DataView dd = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
//for (int j = 0; j < dd.Count; j++)
|
|
//{
|
|
// DeviceIdx = Convert.ToInt32(dd[j]["F_DeviceIndex"]);
|
|
// #region 发送后规定时间内没报开始或者读取数据成功需要进行超时重发,重发超限时报错
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append("select F_MonitorIndex,F_DeviceIndex,F_SendCount,F_StartTime,F_Status,F_AgvNo from T_Monitor_Task where F_DeviceIndex=").Append(DeviceIdx).Append(" and f_status=1 and F_SendFlag='1'");
|
|
// dvmo= dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;//20100905只重发主任务
|
|
// if (dvmo.Count > 0)
|
|
// {//20110510
|
|
// TaskIdx = Convert.ToInt32(dvmo[0]["F_MonitorIndex"]);
|
|
// int scount = Convert.ToInt32(dvmo[0]["F_SendCount"]);
|
|
// scount++;
|
|
// if (scount > Convert.ToInt32(dd[j]["F_MaxSendCount"]))
|
|
// {
|
|
// //发送次数超限报警
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append("update T_Monitor_Task set F_Status=999 where F_Status<>999 and F_MonitorIndex=").Append(TaskIdx);//20110505
|
|
// dbo.ExceSQL(sql.ToString());
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// //DateTime.Now.AddMilliseconds
|
|
// if (dvmo[0]["F_StartTime"].ToString() != "-")
|
|
// {
|
|
// if (Convert.ToDateTime(dvmo[0]["F_StartTime"].ToString().Substring(0, 19), CultureInfo.CurrentCulture).AddMilliseconds(Convert.ToDouble(dd[j]["F_SendInterval"])) <= DateTime.Now)
|
|
// {
|
|
|
|
// if (dvmo[0]["F_AgvNo"] == DBNull.Value)
|
|
// {
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append("update T_Base_Device set F_LockedState=0 where F_DeviceIndex=").Append(DeviceIdx);
|
|
// dbo.ExceSQL(sql.ToString());
|
|
// sql.Remove(0, sql.Length);
|
|
// sql.Append("update T_Monitor_Task set F_SendCount=").Append(scount).Append(",F_Status=0 where F_MonitorIndex=").Append(TaskIdx);
|
|
// dbo.ExceSQL(sql.ToString());
|
|
// }
|
|
// CommonClassLib.CCarryConvert.WriteDarkCasket("GetDeviceState", "超时重发", DeviceIdx.ToString(), "设备指令索引:" + TaskIdx.ToString() + "发送后,一直没有报告执行或者完成,重新发送命令!");
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// #endregion
|
|
//}
|
|
#endregion
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf(ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += ex.Message;
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
timerObtainTask.Enabled = true;
|
|
}
|
|
}
|
|
|
|
private void timerDisassembleTask_Tick(object sender, EventArgs e)
|
|
{
|
|
timerDisassembleTask.Enabled = false;
|
|
try
|
|
//if (CStaticClass.Order == true)
|
|
{
|
|
string errtext = string.Empty;
|
|
if (CStaticClass.WcfControl.DisassembleTask(out errtext) == false)
|
|
{
|
|
if (tsStatus.Text.IndexOf(errtext) < 0)
|
|
{
|
|
tsStatus.Text += errtext;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf(ex.Message ) < 0)
|
|
{
|
|
tsStatus.Text += ex.Message;
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
timerDisassembleTask.Enabled = true;
|
|
}
|
|
}
|
|
|
|
private void timerSendOrder_Tick(object sender, EventArgs e)
|
|
{
|
|
timerSendOrder.Enabled = false;
|
|
try
|
|
//if (CStaticClass.Order == true)
|
|
{
|
|
string errtext = string.Empty;
|
|
if (CStaticClass.WcfControl.StartSendDeviceOrder(out errtext) == false)
|
|
{
|
|
if (tsStatus.Text.IndexOf(errtext) < 0)
|
|
{
|
|
tsStatus.Text += errtext;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf(ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += ex.Message;
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
timerSendOrder.Enabled = true;
|
|
}
|
|
}
|
|
|
|
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 MMExitSystem_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void MISystemInit_Click(object sender, EventArgs e)
|
|
{
|
|
FrmSystemInit.FormInstance.Show();
|
|
}
|
|
|
|
private void toolStripMenuItem13_Click(object sender, EventArgs e)
|
|
{
|
|
MITurnOn_Click(sender, e);
|
|
}
|
|
|
|
private void toolStripMenuItem14_Click(object sender, EventArgs e)
|
|
{
|
|
MITurnOff_Click(sender, e);
|
|
}
|
|
|
|
private void toolStripMenuItem9_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void toolStripMenuItem8_Click(object sender, EventArgs e)
|
|
{
|
|
this.Visible = true;
|
|
this.WindowState = FormWindowState.Maximized;
|
|
}
|
|
|
|
private void toolStripMenuItem10_Click(object sender, EventArgs e)
|
|
{
|
|
this.Visible = false;
|
|
}
|
|
|
|
|
|
|
|
private void notifyIcon1_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
|
|
this.TopMost = true;
|
|
this.Visible = true;
|
|
this.TopMost = false;
|
|
this.WindowState = FormWindowState.Maximized;
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
listBox1.Items.Clear();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 20120503向列表框增加显示内容
|
|
/// </summary>
|
|
/// <param name="txtinfo"></param>
|
|
/// <returns></returns>
|
|
bool AddList1Info(string txtinfo)
|
|
{
|
|
try
|
|
{
|
|
if (txtinfo.IndexOf("巡检客户端") >= 0) return true;
|
|
if (listBox1.Items.Count >= 70) listBox1.Items.Clear();
|
|
foreach (object li in listBox1.Items)
|
|
{
|
|
if (li.ToString().IndexOf(txtinfo) >= 0)
|
|
{
|
|
//listBox1.Items.Remove(li);
|
|
//listBox1.Items.Add(DateTime.Now.ToLongTimeString() + txtinfo);
|
|
return false;
|
|
}
|
|
}
|
|
listBox1.Items.Add(DateTime.Now.ToLongTimeString() + txtinfo);
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf("巡检客户端AddList1Info:" + ex.StackTrace + ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += "巡检客户端AddList1Info:" + ex.StackTrace + ex.Message;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void button4_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.listBox2.Items.Clear();
|
|
var list = WcfControlMonitorLib.SControlMonitor.ClientCallbackLists;
|
|
if (list == null || list.Count == 0)
|
|
return;
|
|
lock (list)
|
|
{
|
|
foreach (System.Collections.DictionaryEntry client in list)
|
|
{
|
|
listBox2.Items.Add(client.Value.ToString());
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf("刷新客户端时:" + ex.StackTrace + ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += "刷新客户端时:" + ex.StackTrace + ex.Message;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void button3_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (listBox2.SelectedItem == null) return;
|
|
var list = WcfControlMonitorLib.SControlMonitor.ClientCallbackLists;
|
|
foreach (System.Collections.DictionaryEntry client in list)
|
|
{
|
|
if (client.Value.ToString() == listBox2.SelectedItem.ToString())
|
|
{
|
|
WcfControlMonitorLib.SControlMonitor.ClientShowLists.Remove(client.Key);
|
|
WcfControlMonitorLib.SControlMonitor.ClientCallbackLists.Remove(client.Key);
|
|
button4_Click(sender, e);
|
|
return;
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf("注销客户端时:" + ex.StackTrace + ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += "注销客户端时:" + ex.StackTrace + ex.Message;
|
|
}
|
|
}
|
|
}
|
|
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;
|
|
}
|
|
|
|
int UserTimeOut = 0;//用于过期时间判断
|
|
private void timer1_Tick(object sender, EventArgs e)
|
|
{
|
|
DataView dv = new DataView();
|
|
try
|
|
{//20121203
|
|
#region 测试黑匣子记录
|
|
//for (int i = 0; i < 5000; i++)
|
|
//{
|
|
// CommonClassLib.CCarryConvert.WriteDarkCasket("测试记录", i.ToString(), "", "");
|
|
|
|
//}
|
|
#endregion
|
|
|
|
CStaticClass.WcfControl.Heartbeat(out mi);
|
|
if (mi.S7connectOnline.Count > 0)
|
|
{
|
|
if (mi.S7connectOnline["S7 connection_2"] == 0)
|
|
{
|
|
pbF1S7.Image = wcfControlMonitorClient.Properties.Resources.ProgressSuccess;
|
|
}
|
|
else
|
|
{
|
|
pbF1S7.Image = wcfControlMonitorClient.Properties.Resources.ProgressError;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
pbF1S7.Image = wcfControlMonitorClient.Properties.Resources.ProgressError;
|
|
}
|
|
if (mi.Orderturnon == true)
|
|
{
|
|
ClickOrderTurnOn();
|
|
}
|
|
else
|
|
{
|
|
ClickOrderTurnOff();
|
|
}
|
|
if (mi.Obtaintask == true)
|
|
{
|
|
ClickObtainTask();
|
|
}
|
|
else
|
|
{
|
|
ClickStopObtainTask();
|
|
}
|
|
timersum++;//20120513
|
|
|
|
if (timersum > 60)//20120513
|
|
{
|
|
listBox1.Items.Clear();
|
|
timersum = 0;
|
|
dv = dbo.ExceSQL("SELECT T_Monitor_Task.F_MonitorIndex,T_Base_Device.F_DeviceIndex FROM T_Base_Device,T_Monitor_Task where T_Base_Device.F_DeviceIndex = T_Monitor_Task.F_DeviceIndex and (T_Base_Device.F_DeviceKindIndex = 1 OR T_Base_Device.F_DeviceKindIndex = 4) and F_Status>0 and F_StartTime<>'-' and (datediff(MINUTE,CONVERT(datetime,SUBSTRING( F_StartTime,1,19),120),GETDATE()) >5)").Tables[0].DefaultView;
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
CStaticClass.WcfControl.ActionError(Convert.ToInt32(dv[i][1]), Convert.ToInt32(dv[i][0]), 999);
|
|
CStaticClass.dbo.ExecuteSql(string.Format("update T_Base_Device set F_ErrorTaskNo=0 where F_ErrorTaskNo={0}", Convert.ToInt32(dv[i][0])));
|
|
}
|
|
}
|
|
//timerefesh++;//20150103增加断网恢复//20151120取消断网恢复
|
|
//if (timerefesh > 1)
|
|
//{//20150103增加断网恢复
|
|
// CStaticClass.WcfControl.RefreshMonitoringMode();
|
|
// timerefesh = 0;
|
|
//}
|
|
|
|
|
|
SendMessageToClient("巡检客户端");
|
|
|
|
UserTimeOut++;
|
|
if (UserTimeOut >= 360)
|
|
{
|
|
UserTimeOut = 0;
|
|
string DES = CommonClassLib.AppSettings.GetValue("siasunTaskNum");
|
|
string des = CStaticClass.WcfControl.Md5Decrypt(DES);
|
|
string[] date = des.Split('|');
|
|
if (date[1].ToString() == "over")
|
|
{
|
|
try
|
|
{
|
|
var list = WcfControlMonitorLib.SControlMonitor.ClientCallbackLists;
|
|
foreach (System.Collections.DictionaryEntry client in list)
|
|
{
|
|
WcfControlMonitorLib.SControlMonitor.ClientShowLists.Remove(client.Key); WcfControlMonitorLib.SControlMonitor.ClientCallbackLists.Remove(client.Key);
|
|
button4_Click(sender, e);
|
|
return;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf("注销客户端时:" + ex.StackTrace + ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += "注销客户端时:" + ex.StackTrace + ex.Message;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
DateTime limittime = Convert.ToDateTime(date[1].ToString());
|
|
if (limittime < DateTime.Now)
|
|
{
|
|
try
|
|
{
|
|
var list = WcfControlMonitorLib.SControlMonitor.ClientCallbackLists;
|
|
foreach (System.Collections.DictionaryEntry client in list)
|
|
{
|
|
WcfControlMonitorLib.SControlMonitor.ClientShowLists.Remove(client.Key);
|
|
WcfControlMonitorLib.SControlMonitor.ClientCallbackLists.Remove(client.Key);
|
|
button4_Click(sender, e);
|
|
return;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf("注销客户端时:" + ex.StackTrace + ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += "注销客户端时:" + ex.StackTrace + ex.Message;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf("巡检客户端时:"+ex.StackTrace+ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += "巡检客户端时:" + ex.StackTrace + ex.Message;
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
|
|
}
|
|
|
|
private void timerTCPReConnect_Tick(object sender, EventArgs e)
|
|
{
|
|
timerTCPReConnect.Enabled = false;
|
|
try
|
|
{
|
|
string errtext = string.Empty;
|
|
if (CStaticClass.WcfControl.ReConnectAGVPC(out errtext) == false)
|
|
{
|
|
if (tsStatus.Text.IndexOf(errtext) < 0)
|
|
{
|
|
tsStatus.Text += errtext;
|
|
}
|
|
}
|
|
#region 20200519 增加AGV任务没有应答的重发
|
|
DealWithAGVNoHandCommand();
|
|
#endregion
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf(ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += ex.Message;
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
timerTCPReConnect.Enabled = true;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 处理发送成功但是AGV控制台没有应答的任务(已发送状态 1)
|
|
/// </summary>
|
|
private void DealWithAGVNoHandCommand()
|
|
{
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
dv = dbo.ExceSQL("SELECT T_Monitor_Task.F_MonitorIndex,T_Monitor_Task.F_StartTime,T_Base_Device.F_DeviceIndex FROM T_Base_Device,T_Monitor_Task where T_Base_Device.F_DeviceIndex = T_Monitor_Task.F_DeviceIndex and (T_Base_Device.F_DeviceKindIndex = 6 ) and F_Status = 1 and F_StartTime<>'-' ").Tables[0].DefaultView;
|
|
for (int i = 0; i < dv.Count; i++)
|
|
{
|
|
DateTime appdt = new DateTime();
|
|
DateTime.TryParse(dv[i]["F_StartTime"].ToString().Substring(0, 19), out appdt);
|
|
if (appdt.AddSeconds(5) < DateTime.Now)
|
|
{
|
|
dbo.ExceSQL("update T_Monitor_Task set F_status = 0 where F_MonitorIndex = " + dv[i]["F_MonitorIndex"]);
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("timerTCPReConnect", "重发无应答AGV任务", dv[i]["F_DeviceIndex"].ToString(), "指令号:" + dv[i]["F_MonitorIndex"].ToString());
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
if (tsStatus.Text.IndexOf("重发AGV任务时:" + ex.StackTrace + ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += "重发AGV任务时:" + ex.StackTrace + ex.Message;
|
|
}
|
|
|
|
}
|
|
finally
|
|
{
|
|
dv.Dispose();
|
|
}
|
|
return;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 环形穿梭车、AGV数据库任务接口,获得任务状态定时器
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void timerGetARgvState_Tick(object sender, EventArgs e)
|
|
{
|
|
timerGetARgvState.Enabled = false;
|
|
try
|
|
//if (CStaticClass.ObtainManageTask == true)
|
|
{
|
|
string errtext = string.Empty;
|
|
|
|
if (CStaticClass.WcfControl.GetARGVState(out errtext) == false)
|
|
{
|
|
if (tsStatus.Text.IndexOf(errtext) < 0)
|
|
{
|
|
tsStatus.Text += errtext;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf(ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += ex.Message;
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
timerGetARgvState.Enabled = true;
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 20200927 双鹿电池控制点灯定时器,从管理软件表读数据,写给PLC DB2 600-900 300byte 控制300个灯;1亮,0灭
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void timerLighting_Tick(object sender, EventArgs e)
|
|
{
|
|
timerLighting.Enabled = false;
|
|
try
|
|
//if (CStaticClass.Order == true)
|
|
{
|
|
string errtext = string.Empty;
|
|
|
|
if (CStaticClass.WcfControl.DealwithLight(out errtext) == false)
|
|
{
|
|
if (tsStatus.Text.IndexOf(errtext) < 0)
|
|
{
|
|
tsStatus.Text += errtext;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (tsStatus.Text.IndexOf(ex.Message) < 0)
|
|
{
|
|
tsStatus.Text += ex.Message;
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
timerLighting.Enabled = true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|