using System; using System.Threading; namespace RGD.WCS { /// /// 新增公共配置20220310 /// public class CConfig { #region 仓储管理系统对接 /// /// 管理系统类型 1安徽mds 2rgd 后续开发 /// public static int WMSType = 1; /// /// 管理系统服务地址 /// public static string WMSServiceUrl = "http://10.138.18.151:17004/client/wms/services/WMSWebService?wsdl"; #endregion 仓储管理系统对接 #region 默认配置站台 /// /// 射频站台 /// public static int Device_Rfid; /// /// 叠盘站台 /// public static int Device_Stacker; /// /// 拆盘站台 /// public static int Device_DStacker; /// /// 视觉站台 /// public static int Device_Vision; /// /// 贴标站台 /// public static int Device_Labeling; /// /// 贴标机 /// public static int Device_LableM; /// /// 拣选站台 /// public static int Device_Pick; /// /// 拣选站台 /// public static int Device_PickM; /// /// 扫码头设备 /// public static int Device_ScanCode; /// /// 出库站台 /// public static int Device_Out; #endregion 默认配置站台 /// /// 加载配置文件 20220310 暂时写死 /// public static void LoadConfig() { //DataTable dt = DBUtility.DbHelperSQL.Query("select * from T_Base_PLC_Ask").Tables[0]; //foreach (DataRow row in dt.Rows) //{ // switch (row["F_Askkind"].ToString()) // { // case "1": // Device_Rfid = int.Parse(row["F_BindingDevice"].ToString()); // break; // case "2": // Device_Rfid = int.Parse(row["F_BindingDevice"].ToString()); // break; // case "3": // Device_Rfid = int.Parse(row["F_BindingDevice"].ToString()); // break; // } //} Device_Rfid = 12002; Device_Stacker = 9999; Device_DStacker = 12030; Device_Vision = 0; Device_LableM = 0; Device_PickM = 0; Device_Out = 12001; } public CConfig() { } #region 运行时 private static Object thisLock = new Object(); //锁定timer的一次执行 private static System.Timers.Timer getAllReturnTimer = new System.Timers.Timer(); private static System.Timers.Timer getStateTimer = new System.Timers.Timer(); private static System.Timers.Timer controlTimer = new System.Timers.Timer(); private static System.Timers.Timer disTaskTimer = new System.Timers.Timer(); private static bool isGetStateRun = false; public static void StartAll() { getAllReturnTimer.Interval = 300; getAllReturnTimer.Elapsed += AllReturnsOnTimedEvent; getAllReturnTimer.Enabled = true; getAllReturnTimer.Start(); ///////////////////////////////////////////////// getStateTimer.Interval = 300; getStateTimer.Elapsed += GetStateOnTimedEvent; getStateTimer.Enabled = true; getStateTimer.Start(); /////////////////////////////////////////////// controlTimer.Interval = 300; controlTimer.Elapsed += controlTimedEvent; controlTimer.Enabled = true; controlTimer.Start(); ////////////////////////////////////////////// disTaskTimer.Interval = 500; disTaskTimer.Elapsed += disTaskTimedEvent; disTaskTimer.Enabled = true; disTaskTimer.Start(); } public static void StopAll() { getAllReturnTimer.Stop(); ///////////////////////////////////////////////// getStateTimer.Stop(); /////////////////////////////////////////////// controlTimer.Stop(); ////////////////////////////////////////////// disTaskTimer.Stop(); } private static void AllReturnsOnTimedEvent(Object source, System.Timers.ElapsedEventArgs e) { DateTime dt = DateTime.Now; if (!CStaticClass.GetAllReturnFlag) { CStaticClass.GetAllReturns(); } FrmControlMonitor.FormInstance.label12.Text = "GetAllReturn300:" + (DateTime.Now - dt).TotalMilliseconds + "|" + Thread.CurrentThread.ManagedThreadId.ToString(); } private static void GetStateOnTimedEvent(Object source, System.Timers.ElapsedEventArgs e) { DateTime dt = DateTime.Now; if (CStaticClass.Order == true) { //DateTime dt = DateTime.Now; if (!isGetStateRun) { isGetStateRun = true; new CGetState().GetDeviceState(); isGetStateRun = false; } //label82.Text = "nGetState300:" + (DateTime.Now - dt).TotalMilliseconds + "|" + Thread.CurrentThread.ManagedThreadId.ToString(); } try { FrmControlMonitor.FormInstance.label82.Text = "nGetState300:" + (DateTime.Now - dt).TotalMilliseconds + "|" + Thread.CurrentThread.ManagedThreadId.ToString(); } catch (Exception ex) { } } private static void controlTimedEvent(Object source, System.Timers.ElapsedEventArgs e) { DateTime dt = DateTime.Now; if (CStaticClass.Order == true) // 自动监听plc { string ss1 = DateTime.Now.Second.ToString() + "-" + DateTime.Now.Millisecond.ToString(); lock (thisLock) { new CControl().StartOrder(); //发送命令 } lock (thisLock) { new CListenPLCAsk().DealwithPLCAsk();//处理主动上报状态的设备 叠盘/扫码/贴标等 } } try { FrmControlMonitor.FormInstance.label63.Text = "Control300:" + (DateTime.Now - dt).TotalMilliseconds + "|" + Thread.CurrentThread.ManagedThreadId.ToString(); } catch (Exception ex) { } } private static void disTaskTimedEvent(Object source, System.Timers.ElapsedEventArgs e) { DateTime dt = DateTime.Now; if ((CStaticClass.Order == true)) { //启动拆分进程MyTaskIntoSteps(); int nSubCount = 0; lock (thisLock) { nSubCount = CDisassembleTask.MyTaskIntoSteps(); } } FrmControlMonitor.FormInstance.label79.Text = "Disassemble900:" + (DateTime.Now - dt).TotalMilliseconds + "|" + Thread.CurrentThread.ManagedThreadId.ToString(); } #endregion 运行时 } }