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.
364 lines
12 KiB
364 lines
12 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Data;
|
|
using DBFactory;
|
|
using System.ServiceModel;
|
|
using System.Text.RegularExpressions;
|
|
namespace wcfControlMonitorClient
|
|
{
|
|
/// <summary>
|
|
/// Creator:Richard.liu
|
|
///
|
|
/// 命令开关等全局变量的定义
|
|
/// </summary>
|
|
public static class CStaticClass
|
|
{
|
|
#region 客户端订阅需要的函数20120428
|
|
|
|
/// <summary>
|
|
/// 使用正则表达式验证字符串
|
|
/// </summary>
|
|
/// <param name="strCode">待验证字符串</param>
|
|
/// <returns>合法返回true,否则返回false</returns>
|
|
public static bool GetCodeCheck(string strCode)
|
|
{
|
|
Match mCode = Regex.Match(strCode, CStaticClass.StockCodeCheck);
|
|
if (mCode.Success)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
static string _stockCodeCheck = "^[B|D|G|P][A-Z][0-9]{4}$";
|
|
/// <summary>
|
|
/// 条码格式检查
|
|
/// </summary>
|
|
public static string StockCodeCheck
|
|
{
|
|
|
|
get { return CStaticClass._stockCodeCheck; }
|
|
set
|
|
{
|
|
int aa;
|
|
if (int.TryParse(_stockCodeCheck, out aa) == true)
|
|
{
|
|
|
|
CStaticClass._stockCodeCheck = value;
|
|
}
|
|
else
|
|
{
|
|
CStaticClass._stockCodeCheck = "^[B|D|G|P][A-Z][0-9]{4}$";
|
|
}
|
|
}
|
|
}
|
|
public static Dictionary<string, int[]> MutiReadSubscriptionDeviceStateReturns = new Dictionary<string, int[]>();
|
|
public static Dictionary<string, int[]> MutiReadSubscriptionDeviceSplitReturns = new Dictionary<string, int[]>();
|
|
|
|
#endregion
|
|
/// <summary>
|
|
/// 命令开关是否打开
|
|
/// </summary>
|
|
public static bool Order { get; set; }
|
|
|
|
/// <summary>
|
|
/// 是否获取调度任务
|
|
/// </summary>
|
|
public static bool ObtainManageTask { get; set; }
|
|
public static FrmClient client;
|
|
public static Model.MDevice devinfo28;
|
|
public static int[] AllReturns;
|
|
static string GetDeviceS7Connection(int deviceindex)
|
|
{//20110216
|
|
DataView dv = dbo.ExceSQL("SELECT F_S7Connection FROM T_Base_Device WHERE (F_DeviceIndex = " + deviceindex + ")").Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return dv[0]["F_S7Connection"].ToString();
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 20110216支持多个S7Connnection组态OPC
|
|
/// </summary>
|
|
public static Dictionary<string, int[]> MutiS7ConnReturns = new Dictionary<string, int[]>();
|
|
public static bool WCFOK = false;
|
|
static string _userID;
|
|
/// <summary>
|
|
/// 用户编号
|
|
/// </summary>
|
|
public static string UserID
|
|
{
|
|
get { return CStaticClass._userID; }
|
|
set { CStaticClass._userID = value; }
|
|
}
|
|
public static string ClientID { get; set; }
|
|
public static bool IfRemind { get; set; }
|
|
public static DBOperator dbo = CommonClassLib.AppSettings.dbo;//richard20181022
|
|
public static DBOperator dboM = CommonClassLib.AppSettings.dboM;//richard20181022
|
|
public static WcfControlMonitor.ControlMonitorClient WcfControl;
|
|
|
|
static string _manstatus = " F_Status>=-1 ";//默认,显示调度任务全部队列
|
|
static string _monstatus = " F_Status>=-1 ";//默认,显示设备指令全部队列
|
|
/// <summary>
|
|
/// 显示调度任务全部队列" F_Status>=-1 ";等待队列" F_Status=0 ";运行队列" F_Status=1 ";
|
|
/// </summary>
|
|
public static string Manstatus
|
|
{
|
|
get { return CStaticClass._manstatus; }
|
|
set { CStaticClass._manstatus = value; }
|
|
}
|
|
static StringBuilder sql = new StringBuilder();//20140218
|
|
/// <summary>
|
|
/// 显示设备指令全部队列" F_Status>=-1 ";等待队列" F_Status=0 ";运行队列" F_Status=1 ";
|
|
/// </summary>
|
|
public static string Monstatus
|
|
{
|
|
get { return CStaticClass._monstatus; }
|
|
set { CStaticClass._monstatus = value; }
|
|
}
|
|
|
|
static string _movedDeviceAheadTrigger = "1";
|
|
/// <summary>
|
|
/// 移动设备是否被提前触发将取
|
|
/// </summary>
|
|
public static string MovedDeviceAheadTrigger
|
|
{
|
|
get { return CStaticClass._movedDeviceAheadTrigger; }
|
|
set
|
|
{
|
|
if ((value == "0") || (value == "1"))
|
|
{
|
|
CStaticClass._movedDeviceAheadTrigger = value;
|
|
}
|
|
else
|
|
{
|
|
CStaticClass._movedDeviceAheadTrigger = "1";
|
|
}
|
|
}
|
|
}
|
|
|
|
static string _outDetectArrowIdleGoods = "1";
|
|
/// <summary>
|
|
/// 堆垛机出库是否检测目标输送机空闲和有物
|
|
/// </summary>
|
|
public static string OutDetectArrowIdleGoods
|
|
{
|
|
get { return CStaticClass._outDetectArrowIdleGoods; }
|
|
set
|
|
{
|
|
if ((value == "0") || (value == "1"))
|
|
{
|
|
CStaticClass._outDetectArrowIdleGoods = value;
|
|
}
|
|
else
|
|
{
|
|
CStaticClass._outDetectArrowIdleGoods = "1";
|
|
}
|
|
}
|
|
}
|
|
|
|
static string _deviceErrorAutoModifyRoutePath = "0";
|
|
/// <summary>
|
|
/// 设备发生故障自动变更路径
|
|
/// </summary>
|
|
public static string DeviceErrorAutoModifyRoutePath
|
|
{
|
|
get { return CStaticClass._deviceErrorAutoModifyRoutePath; }
|
|
set
|
|
{
|
|
if ((value == "0") || (value == "1"))
|
|
{
|
|
CStaticClass._deviceErrorAutoModifyRoutePath = value;
|
|
}
|
|
else
|
|
{
|
|
CStaticClass._deviceErrorAutoModifyRoutePath = "0";
|
|
}
|
|
}
|
|
}
|
|
|
|
static string _doubleForkWaitTime = "120";
|
|
/// <summary>
|
|
/// 双叉关联入库任务允许等待的时间单位(秒):默认120秒
|
|
/// </summary>
|
|
public static string DoubleForkWaitTime
|
|
{
|
|
|
|
get { return CStaticClass._doubleForkWaitTime; }
|
|
set
|
|
{
|
|
int aa;
|
|
if (int.TryParse(_doubleForkWaitTime, out aa) == true)
|
|
{
|
|
|
|
CStaticClass._doubleForkWaitTime = value;
|
|
}
|
|
else
|
|
{
|
|
CStaticClass._doubleForkWaitTime = "120";
|
|
}
|
|
}
|
|
}
|
|
static string _transportTimeout = "5";
|
|
/// <summary>
|
|
/// 输送超时最大允许时间单位(分):默认5分钟//20110608
|
|
/// </summary>
|
|
public static string TransportTimeout
|
|
{
|
|
get { return CStaticClass._transportTimeout; }
|
|
set
|
|
{
|
|
int aa;
|
|
if (int.TryParse(_transportTimeout, out aa) == true)
|
|
{
|
|
|
|
CStaticClass._transportTimeout = value;
|
|
}
|
|
else
|
|
{
|
|
CStaticClass._transportTimeout = "5";
|
|
}
|
|
}
|
|
}
|
|
static string _SystemName = "【沈阳新松自动化立体仓库监控系统【客户端】";
|
|
|
|
public static string SystemName
|
|
{
|
|
get { return CStaticClass._SystemName; }
|
|
set { CStaticClass._SystemName = value; }
|
|
}
|
|
public static int GetDeviceKindIdx(int devIdx)
|
|
{
|
|
try
|
|
{
|
|
|
|
string strSql = "SELECT F_DeviceIndex, F_DeviceKindIndex FROM T_Base_Device WHERE F_DeviceIndex=" + devIdx;
|
|
DataSet ds = dbo.ExceSQL(strSql);
|
|
DataView dv = ds.Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dv[0]["F_DeviceKindIndex"]);
|
|
}
|
|
else
|
|
return -1;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
|
|
public static int GetLaneWay(int StackDeviceIndex)
|
|
{
|
|
//20101124
|
|
StringBuilder sql = new StringBuilder();
|
|
sql.Append("SELECT F_LaneDeviceIndex FROM T_Base_LaneInfo WHERE (F_StackIndex = ").Append(StackDeviceIndex).Append(")");
|
|
DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dv[0][0]);
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
public static int GetManageTaskIndexfromMonitor(int monitorIdx)
|
|
{
|
|
//20140218
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
//20100108
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_ManageTaskIndex FROM T_Monitor_Task WHERE (F_MonitorIndex = ").Append(monitorIdx).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dv[0]["F_ManageTaskIndex"]);
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{//20100108
|
|
throw ex;
|
|
}
|
|
finally
|
|
{//20100108
|
|
dv.Dispose();
|
|
}
|
|
}
|
|
public static int GetManageTaskKindIndexFromMonitor(int monitorIdx)
|
|
{//20140218
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT F_ManageTaskKindIndex FROM T_Monitor_Task WHERE (F_MonitorIndex = ").Append(monitorIdx).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
return Convert.ToInt32(dv[0]["F_ManageTaskKindIndex"]);
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{//20100108
|
|
throw ex;
|
|
}
|
|
finally
|
|
{//20100108
|
|
dv.Dispose();
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public static int GetFCONTROLTASKTYPEFromManageTask(int taskKindIndex, int Managefid)
|
|
{
|
|
//20100108
|
|
DataView dv = new DataView();
|
|
try
|
|
{
|
|
//20101124
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("SELECT FCONTROLTASKTYPE FROM T_Manage_Task WHERE (FID = ").Append(Managefid).Append(") AND (F_ManageTaskKindIndex = ").Append(taskKindIndex).Append(")");
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if (dv[0]["FCONTROLTASKTYPE"] == DBNull.Value) return -1;
|
|
return Convert.ToInt32(dv[0]["FCONTROLTASKTYPE"]);
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{//20100108
|
|
throw ex;
|
|
}
|
|
finally
|
|
{//20100108
|
|
dv.Dispose();
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|