Frm_YongGuanMontior.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Threading;
  7. using System.Windows.Forms;
  8. using WCS.Data;
  9. using WCS.Entity.Protocol.Station;
  10. using WCS_Client.From.From_Montior;
  11. namespace WCS_Client.Frm
  12. {
  13. public partial class Frm_YongGuanMontior : Form
  14. {
  15. private System.Timers.Timer _timer;
  16. private delegate void ShowTextDelegate();// 创建委托和委托对象
  17. private List<string> _plcnameSet = new List<string>();
  18. private List<DDJSatatus> DDJSatatusSet = new List<DDJSatatus>();
  19. private List<RGVSatatus> RGVSatatusSet = new List<RGVSatatus>();
  20. public bool isinitfrm = false;
  21. // 防止闪屏
  22. protected override CreateParams CreateParams
  23. {
  24. get
  25. {
  26. CreateParams cp = base.CreateParams;
  27. cp.ExStyle |= 0x02000000;
  28. return cp;
  29. }
  30. }
  31. public Frm_YongGuanMontior()
  32. {
  33. isinitfrm = false;
  34. InitializeComponent();
  35. Init();
  36. }
  37. private void Init()
  38. {
  39. _plcnameSet.Add("SRM1");
  40. _plcnameSet.Add("SRM2");
  41. _plcnameSet.Add("SRM3");
  42. _plcnameSet.Add("SRM4");
  43. _plcnameSet.Add("SRM5");
  44. _plcnameSet.Add("SRM6");
  45. _plcnameSet.Add("SRM7");
  46. _plcnameSet.Add("SRM8");
  47. _plcnameSet.Add("RGV1");
  48. _plcnameSet.Add("RGV2");
  49. _plcnameSet.Add("RGV3");
  50. _plcnameSet.Add("RGV4");
  51. _plcnameSet.Add("RGV5");
  52. _plcnameSet.Add("RGV6");
  53. _plcnameSet.Add("RGV7");
  54. _plcnameSet.Add("RGV8");
  55. _plcnameSet.Add("RGV9");
  56. _plcnameSet.Add("RGV10");
  57. _plcnameSet.Add("RGV11");
  58. _plcnameSet.Add("RGV12");
  59. _plcnameSet.Add("RGV13");
  60. _plcnameSet.Add("RGV14");
  61. _plcnameSet.Add("Conv");
  62. var plcnameSetsrm = _plcnameSet.Where(value => value.Contains("SRM")).ToList();
  63. for (int i = 0; i < plcnameSetsrm.Count; i++)
  64. {
  65. var item = plcnameSetsrm[i];
  66. if (!DDJSatatusSet.Any(v => v.SrmName == item))
  67. {
  68. var ddjsatatus = new DDJSatatus();
  69. ddjsatatus.SrmName = item;
  70. int index = i + 1;
  71. ddjsatatus.G = (PictureBox)FindControl("G" + index);
  72. ddjsatatus.LblInStatus = (Label)FindControl("lblInStatus" + index);
  73. ddjsatatus.LblOutStatus = (Label)FindControl("lblOutStatus" + index);
  74. ddjsatatus.DdjMode = (Label)FindControl("ddjMode" + index);
  75. ddjsatatus.DdjStatus = (Label)FindControl("ddjStatus" + index);
  76. ddjsatatus.DdjOrdId = (Label)FindControl("ddjOrdId" + index);
  77. ddjsatatus.DdjOptType = (Label)FindControl("ddjOptType" + index);
  78. ddjsatatus.DdjPosCurr = (Label)FindControl("ddjPosCurr" + index);
  79. ddjsatatus.DdjWorkTime = (Label)FindControl("ddjWorkTime" + index);
  80. ddjsatatus.DdjTotal_KM = (Label)FindControl("ddjTotal_KM" + index);
  81. ddjsatatus.DdjPosFrom = (Label)FindControl("ddjPosFrom" + index);
  82. ddjsatatus.DdjPosTo = (Label)FindControl("ddjPosTo" + index);
  83. ddjsatatus.DdjWarning = (Label)FindControl("lblDDJWarning" + index);
  84. DDJSatatusSet.Add(ddjsatatus);
  85. }
  86. }
  87. var plcnameSetrgv = _plcnameSet.Where(value => value.Contains("RGV")).ToList();
  88. for (int i = 0; i < plcnameSetrgv.Count; i++)
  89. {
  90. var item = plcnameSetrgv[i];
  91. if (!RGVSatatusSet.Any(v => v.RGVName == item))
  92. {
  93. var rgvsatatus = new RGVSatatus();
  94. rgvsatatus.RGVName = item;
  95. int index;
  96. if (item.Length > 4)
  97. {
  98. index = Convert.ToInt32(item.Substring(3, 2).ToString());
  99. }
  100. else
  101. {
  102. index = Convert.ToInt32(item.Substring(3, 1).ToString());
  103. }
  104. rgvsatatus.G = (PictureBox)FindControl("GV" + index);
  105. rgvsatatus.RGVMode = (Label)FindControl("rgvMode" + index);
  106. rgvsatatus.RGVStatus = (Label)FindControl("rgvStatus" + index);
  107. rgvsatatus.RGVOrdId = (Label)FindControl("rgvOrdId" + index);
  108. rgvsatatus.RGVPosCurr = (Label)FindControl("rgvPosCurr" + index);
  109. rgvsatatus.RGVPosFrom = (Label)FindControl("rgvPosFrom" + index);
  110. rgvsatatus.RGVPosTo = (Label)FindControl("rgvPosTo" + index);
  111. rgvsatatus.RGVOptType = (Label)FindControl("rgvOptType" + index);
  112. RGVSatatusSet.Add(rgvsatatus);
  113. }
  114. }
  115. }
  116. private Control FindControl(string controlName)
  117. {
  118. var control = Controls.Find(controlName, true);
  119. if (control.Count() > 0)
  120. return control[0];
  121. else
  122. return null;
  123. }
  124. private void Frm_YongGuanMontior_Load(object sender, EventArgs e)
  125. {
  126. _timer = new System.Timers.Timer(4000);
  127. _timer.Elapsed += new System.Timers.ElapsedEventHandler(theout);//到达时间的时候执行事件;
  128. _timer.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
  129. _timer.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件;
  130. //this.BeginInvoke(new ShowTextDelegate(InItpan11));
  131. }
  132. private static int _theout = 0;
  133. private void theout(object sender, EventArgs e)
  134. {
  135. if (Interlocked.Exchange(ref _theout, 1) == 0)
  136. {
  137. try
  138. {
  139. //Current.RefreshData(true);
  140. //var listDDJ = BaseWorkflow.QueryStackerdDataDDJ(_plcnameSet);
  141. ShowData();
  142. }
  143. catch (Exception ex)
  144. {
  145. }
  146. finally
  147. {
  148. Interlocked.Exchange(ref _theout, 0);
  149. }
  150. }
  151. }
  152. private void ShowData()
  153. {
  154. try
  155. {
  156. if (InvokeRequired)
  157. {
  158. //异步调用委托(后面添加方法需要将方法委托其中)
  159. this.BeginInvoke(new ShowTextDelegate(pan11));
  160. }
  161. else
  162. {
  163. }
  164. }
  165. catch (Exception ex)
  166. {
  167. LogHelper.Sys_Log.WriteLog(ex.ToString());
  168. }
  169. }
  170. readonly string[] srmArray = new string[] { "srm" , "srm0"};
  171. public void pan11()
  172. {
  173. try
  174. {
  175. var pack = eqpData.deviceDataPack;
  176. // var frame = pack.Frame;//数据帧(数据产生的时间)
  177. var convdata = pack.StationDatas;//输送线数据
  178. var rgvdata = pack.RGVDatas;//穿梭车数据
  179. var scdata = pack.SCDatas;//堆垛机数据
  180. //SRM
  181. foreach (var item in scdata.Datas)
  182. {
  183. var ddjstatus = DDJSatatusSet.FirstOrDefault(v => v.SrmName == item.Code);
  184. if (ddjstatus != null)
  185. {
  186. //报警信息
  187. if (item.D537.SCAlarm.ToString() == "无")
  188. {
  189. ddjstatus.DdjWarning.Text = "";
  190. }
  191. else
  192. {
  193. ddjstatus.DdjWarning.Text += item.D537.SCAlarm.ToString();//item.Info.Contains("接口调用") ? "" : item.Info;
  194. }
  195. //当前巷道
  196. if (item.Code != null)
  197. {
  198. //ddjstatus.DdjPosCurr.Text = item.Code.ToString().Substring(3);
  199. }
  200. //模式
  201. ddjstatus.DdjMode.Text = item.D521.SRMMode.ToString();
  202. int srmColor = 0; //1 red 2 Yellow 3 green
  203. if (ddjstatus.DdjWarning.Text != "")
  204. {
  205. ddjstatus.G.Image = Properties.Resources.红;
  206. srmColor = 1;
  207. }
  208. else
  209. {
  210. if (!string.IsNullOrEmpty(ddjstatus.DdjMode.Text))
  211. {
  212. if (item.D521.SRMMode.ToString() == "远程")
  213. {
  214. ddjstatus.G.Image = Properties.Resources.绿;
  215. srmColor = 3;
  216. }
  217. else if (item.D521.SRMMode.ToString() == "半自动" || item.D521.SRMMode.ToString() == "手动")
  218. {
  219. ddjstatus.G.Image = Properties.Resources.黄;
  220. srmColor = 2;
  221. }
  222. else if (item.D521.SRMMode.ToString() == "维修")
  223. {
  224. ddjstatus.G.Image = Properties.Resources.红;
  225. srmColor = 1;
  226. }
  227. }
  228. else
  229. {
  230. ddjstatus.DdjMode.Text = "无";
  231. ddjstatus.G.Image = Properties.Resources.黄;
  232. srmColor = 2;
  233. }
  234. }
  235. try
  236. {
  237. var srmIndex = ddjstatus.SrmName.Substring(3);
  238. for (int i = 0; i < srmArray.Length; i++)
  239. {
  240. var control = FindControl(srmArray[i] + srmIndex);
  241. if (control != null)
  242. {
  243. Thread.Sleep(10);
  244. ((srm)control).SetColor(srmColor);
  245. }
  246. }
  247. }
  248. catch (Exception ex)
  249. {
  250. }
  251. ////状态
  252. ddjstatus.DdjStatus.Text = item.D521.SRMStatus.ToString();
  253. int taskid = 100;
  254. if (item.D521.TaskID_1 > 10000 && item.D521.TaskID_2 > 10000)
  255. {
  256. taskid = item.D521.TaskID_1;
  257. }
  258. else if (item.D521.TaskID_1 > 10000)
  259. {
  260. taskid = item.D521.TaskID_1;
  261. }
  262. else if (item.D521.TaskID_2 > 10000)
  263. {
  264. taskid = item.D521.TaskID_2;
  265. }
  266. else
  267. {
  268. taskid = item.D521.TaskID_1;
  269. }
  270. //任务号
  271. ddjstatus.DdjOrdId.Text = taskid.ToString();
  272. TryCachHelper.TryExecute((db) =>
  273. {
  274. var task_Temp = db.Queryable<WCS_TASK>().First(v => v.ID == taskid);
  275. if (task_Temp == null)
  276. {
  277. ddjstatus.LblInStatus.BackColor = Color.DarkGray;
  278. ddjstatus.LblOutStatus.BackColor = Color.DarkGray;
  279. }
  280. else
  281. {
  282. //任务类型
  283. ddjstatus.DdjOptType.Text = task_Temp.TYPE.ToString();
  284. if (task_Temp.TYPE == TaskType.入库)
  285. {
  286. ddjstatus.LblInStatus.BackColor = Color.Lime;
  287. ddjstatus.LblOutStatus.BackColor = Color.DarkGray;
  288. //起始位置
  289. ddjstatus.DdjPosFrom.Text = item.D521.SLine_1.ToString();
  290. //目标位置
  291. ddjstatus.DdjPosTo.Text = item.D521.ELine_1.ToString() + "-" + item.D521.ECol_1.ToString() + "-" + item.D521.ELayer_1.ToString();
  292. }
  293. else if (task_Temp.TYPE == TaskType.出库)
  294. {
  295. ddjstatus.LblInStatus.BackColor = Color.DarkGray;
  296. ddjstatus.LblOutStatus.BackColor = Color.Lime;
  297. ddjstatus.DdjPosFrom.Text = item.D521.SLine_1.ToString() + "-" + item.D521.SCol_1.ToString() + "-" + item.D521.SLayer_1.ToString();
  298. //目标位置
  299. ddjstatus.DdjPosTo.Text = item.D521.ELine_1.ToString();
  300. }
  301. else if (task_Temp.TYPE == TaskType.移库 || task_Temp.TYPE == TaskType.倒库)
  302. {
  303. ddjstatus.DdjPosFrom.Text = item.D521.SLine_1.ToString() + "-" + item.D521.SCol_1.ToString() + "-" + item.D521.SLayer_1.ToString();
  304. ddjstatus.DdjPosTo.Text = item.D521.ELine_1.ToString() + "-" + item.D521.ECol_1.ToString() + "-" + item.D521.ELayer_1.ToString();
  305. }
  306. else
  307. {
  308. ddjstatus.LblInStatus.BackColor = Color.DarkGray;
  309. ddjstatus.LblOutStatus.BackColor = Color.DarkGray;
  310. }
  311. }
  312. });
  313. ////运行时长
  314. ddjstatus.DdjWorkTime.Text = item.D521.Runtime.ToString() + "h";
  315. ////里程数
  316. ddjstatus.DdjTotal_KM.Text = item.D521.TotalKM.ToString() + "KM";
  317. }
  318. }
  319. //RGV
  320. foreach (var item in rgvdata.Datas)
  321. {
  322. //只更新有变更的数据
  323. //var oldItem = eqpData.oldDeviceDataPack.RGVDatas.Datas.FirstOrDefault(p => p.Code == item.Code);
  324. //if (oldItem.ToString() == item.ToString()) return;
  325. var rgvstatus = RGVSatatusSet.FirstOrDefault(v => v.RGVName == item.Code);
  326. if (rgvstatus != null)
  327. {
  328. string workmode = item.D521.WorkMode.ToString();
  329. //模式
  330. rgvstatus.RGVMode.Text = item.D521.WorkMode.ToString();
  331. if (item.D521.WorkMode.ToString() == "自动")
  332. {
  333. rgvstatus.G.Image = Properties.Resources.绿;
  334. }
  335. else if (item.D521.WorkMode.ToString() == "半自动")
  336. {
  337. rgvstatus.G.Image = Properties.Resources.黄;
  338. }
  339. else if (item.D521.WorkMode.ToString() == "手动")
  340. {
  341. rgvstatus.G.Image = Properties.Resources.黄;
  342. }
  343. else if (item.D521.WorkMode.ToString() == "维护")
  344. {
  345. rgvstatus.G.Image = Properties.Resources.红;
  346. }
  347. else if(item.D521.WorkMode.ToString() == "99")
  348. {
  349. rgvstatus.RGVMode.Text = "手动";
  350. rgvstatus.G.Image = Properties.Resources.黄;
  351. }
  352. ////状态
  353. rgvstatus.RGVStatus.Text = item.D521.SystemStatus.ToString();
  354. //rgvstatus.RGVOrdId.Text = item.D521.TaskID_1.ToString();
  355. //任务Id
  356. if (item.D521.TaskID_1.ToString().Length > 3)
  357. {
  358. rgvstatus.RGVOrdId.Text = item.D521.TaskID_1.ToString();
  359. }
  360. else if (item.D521.TaskID_2.ToString().Length > 3)
  361. {
  362. rgvstatus.RGVOrdId.Text = item.D521.TaskID_2.ToString();
  363. }
  364. else
  365. {
  366. rgvstatus.RGVOrdId.Text = item.D521.TaskID_1.ToString();
  367. }
  368. if (item.D521.Status_1.HasFlag(WCS.Entity.Protocol.RGVStatus.光电) || item.D521.Status_2.HasFlag(WCS.Entity.Protocol.RGVStatus.光电))
  369. {
  370. rgvstatus.RGVPosCurr.Text = "true";
  371. }
  372. else
  373. {
  374. rgvstatus.RGVPosCurr.Text = "false";
  375. }
  376. //作业类型
  377. rgvstatus.RGVOptType.Text = item.D521.TaskType_1.ToString();
  378. //当前位置
  379. //rgvstatus.RGVPosCurr.Text = item.D521.Position.ToString();
  380. //起始位置
  381. rgvstatus.RGVPosFrom.Text = item.D521.Position.ToString(); //item.D521.StartPosition_1.ToString();
  382. //目标位置
  383. rgvstatus.RGVPosTo.Text = item.D521.DestPosition_1.ToString();
  384. var control = FindControl(item.Code);
  385. if (control != null)
  386. {
  387. if (control is Conveyor_R)
  388. {
  389. var con = (Conveyor_R)control;
  390. con.button1.Text = item.Code.ToString();
  391. if (item.D523.Fault != 0) con.BackColor = Color.Red;
  392. else if (item.D523.Status == 0 && item.Code.ToString()!="RGV8") con.BackColor = Color.Yellow;
  393. else con.BackColor = Color.FromArgb(0, 144, 154);
  394. if (item.D521.Status_1.HasFlag(WCS.Entity.Protocol.RGVStatus.光电))
  395. {
  396. if (con.button1.Tag.ToString() != "pall")
  397. {
  398. con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor_R.png");//1009L1.png
  399. con.button1.Tag = "pall";
  400. }
  401. }
  402. else
  403. {
  404. if (con.button1.Tag.ToString() != "empty")
  405. {
  406. con.button1.BackgroundImage = Image.FromFile("Resources/1009L1.png");//1009L1.png
  407. con.button1.Tag = "empty";
  408. }
  409. }
  410. }
  411. }
  412. }
  413. }
  414. //输送线
  415. foreach (var item in convdata.Datas)
  416. {
  417. //只更新有变更的数据
  418. var control = FindControl("con" + item.Code);
  419. if (control != null)
  420. {
  421. if (control is Conveyor)
  422. {
  423. var con = (Conveyor)control;
  424. if (item.D523.Alarm != 0) con.BackColor = Color.Red;
  425. else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  426. else con.BackColor = Color.FromArgb(0, 144, 154);
  427. con.button1.Text = item.Code.ToString();
  428. if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.光电状态))
  429. {
  430. if (con.button1.Tag.ToString() != "pall")
  431. {
  432. con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor.png");
  433. con.button1.Tag = "pall";
  434. }
  435. }
  436. else if (item.D521.Tasknum.ToString().Length > 10000)
  437. {
  438. if (con.button1.Tag.ToString() != "pall")
  439. {
  440. con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor.png");
  441. con.button1.Tag = "pall";
  442. }
  443. }
  444. else
  445. {
  446. if (con.button1.Tag.ToString() != "empty")
  447. {
  448. con.button1.BackgroundImage = Image.FromFile("Resources/shelf16UD.png");
  449. con.button1.Tag = "empty";
  450. }
  451. }
  452. }
  453. #region condition
  454. else if (control is Conveyor_L)
  455. {
  456. var con = (Conveyor_L)control;
  457. con.button1.Text = item.Code.ToString();
  458. if (item.D523.Alarm != 0) con.BackColor = Color.Red;
  459. else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  460. else con.BackColor = Color.FromArgb(0, 144, 154);
  461. if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.光电状态))
  462. {
  463. if (con.button1.Tag.ToString() != "pall")
  464. {
  465. con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor_L.png");//1009L11.png
  466. con.button1.Tag = "pall";
  467. }
  468. }
  469. else
  470. {
  471. if (con.button1.Tag.ToString() != "empty")
  472. {
  473. con.button1.BackgroundImage = Image.FromFile("Resources/1009L11.png");//1009L11.png
  474. con.button1.Tag = "empty";
  475. }
  476. }
  477. }
  478. else if (control is Conveyor_R)
  479. {
  480. var con = (Conveyor_R)control;
  481. con.button1.Text = item.Code.ToString();
  482. if (item.D523.Alarm != 0) con.BackColor = Color.Red;
  483. else if(item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.条码未读出)) con.BackColor = Color.Red;
  484. else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  485. else con.BackColor = Color.FromArgb(0, 144, 154);
  486. if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.光电状态))
  487. {
  488. if (con.button1.Tag.ToString() != "pall")
  489. {
  490. con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor_R.png");//1009L1.png
  491. con.button1.Tag = "pall";
  492. }
  493. }
  494. else
  495. {
  496. if (con.button1.Tag.ToString() != "empty")
  497. {
  498. con.button1.BackgroundImage = Image.FromFile("Resources/1009L1.png");//1009L1.png
  499. con.button1.Tag = "empty";
  500. }
  501. }
  502. }
  503. else if (control is Conveyor3_A)
  504. {
  505. var con = (Conveyor3_A)control;
  506. con.button1.Text = item.Code.ToString();
  507. if (item.D523.Alarm != 0) con.BackColor = Color.Red;
  508. else if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.条码未读出)) con.BackColor = Color.Red;
  509. else if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.外检扫码故障)) con.BackColor = Color.Red;
  510. else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  511. else con.BackColor = Color.FromArgb(0, 144, 154);
  512. if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.光电状态))
  513. {
  514. if (con.button1.Tag.ToString() != "pall")
  515. {
  516. con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor3_A_Box.png");//Conveyor3_A_Box.png
  517. con.button1.Tag = "pall";
  518. }
  519. }
  520. else
  521. {
  522. if (con.button1.Tag.ToString() != "empty")
  523. {
  524. con.button1.BackgroundImage = Image.FromFile("Resources/1009_A.png");//1009_A.png
  525. con.button1.Tag = "empty";
  526. }
  527. }
  528. }
  529. else if (control is Conveyor3_B)
  530. {
  531. var con = (Conveyor3_B)control;
  532. con.button1.Text = item.Code.ToString();
  533. if (item.D523.Alarm != 0) con.BackColor = Color.Red;
  534. else if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.条码未读出)) con.BackColor = Color.Red;
  535. else if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.外检扫码故障)) con.BackColor = Color.Red;
  536. else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  537. else con.BackColor = Color.FromArgb(0, 144, 154);
  538. if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.光电状态))
  539. {
  540. if (con.button1.Tag.ToString() != "pall")
  541. {
  542. con.button1.BackgroundImage = Image.FromFile("Resources/1009R1_B.png");//1009R1_A.png
  543. con.button1.Tag = "pall";
  544. }
  545. }
  546. else
  547. {
  548. if (con.button1.Tag.ToString() != "empty")
  549. {
  550. con.button1.BackgroundImage = Image.FromFile("Resources/1009R1.png");//1009R1.png
  551. con.button1.Tag = "empty";
  552. }
  553. }
  554. }
  555. #region ---
  556. //else if (control is Conveyor4_L_R)
  557. //{
  558. // var con = (Conveyor4_L_R)control;
  559. // con.button1.Text = item.Code.ToString();
  560. // if (item.D523.Fault != 0) con.BackColor = Color.Red;
  561. // else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  562. // else con.BackColor = Color.FromArgb(0, 144, 154);
  563. // if (item.D521.PH_STATUS == true)
  564. // {
  565. // if (con.button1.Tag.ToString() != "pall")
  566. // {
  567. // con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor4_L_R.png");
  568. // con.button1.Tag = "pall";
  569. // }
  570. // }
  571. // else
  572. // {
  573. // if (con.button1.Tag.ToString() != "empty")
  574. // {
  575. // con.button1.BackgroundImage = Image.FromFile("Resources/1001LR.gif");
  576. // con.button1.Tag = "empty";
  577. // }
  578. // }
  579. //}
  580. //else if (control is Conveyor3)
  581. //{
  582. // var con = (Conveyor3)control;
  583. // con.button1.Text = item.Code.ToString();
  584. // if (item.D523.Fault != 0) con.BackColor = Color.Red;
  585. // else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  586. // else con.BackColor = Color.FromArgb(0, 144, 154);
  587. // if (item.D521.PH_STATUS == true)
  588. // {
  589. // if (con.button1.Tag.ToString() != "pall")
  590. // {
  591. // con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor3.png");//1009R1_A.png
  592. // con.button1.Tag = "pall";
  593. // }
  594. // }
  595. // else
  596. // {
  597. // if (con.button1.Tag.ToString() != "empty")
  598. // {
  599. // con.button1.BackgroundImage = Image.FromFile("Resources/1004LR.png");//1009R1.png
  600. // con.button1.Tag = "empty";
  601. // }
  602. // }
  603. //}
  604. //else if (control is Conveyor4_left)
  605. //{
  606. // var con = (Conveyor4_left)control;
  607. // con.button1.Text = item.Code.ToString();
  608. // if (item.D523.Fault != 0) con.BackColor = Color.Red;
  609. // else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  610. // else con.BackColor = Color.FromArgb(0, 144, 154);
  611. // if (item.D521.PH_STATUS == true)
  612. // {
  613. // if (con.button1.Tag.ToString() != "pall")
  614. // {
  615. // con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor4_left.png");
  616. // con.button1.Tag = "pall";
  617. // }
  618. // }
  619. // else
  620. // {
  621. // if (con.button1.Tag.ToString() != "empty")
  622. // {
  623. // con.button1.BackgroundImage = Image.FromFile("Resources/1001L.gif");
  624. // con.button1.Tag = "empty";
  625. // }
  626. // }
  627. //}
  628. //else if (control is Conveyor4_right)
  629. //{
  630. // var con = (Conveyor4_right)control;
  631. // con.button1.Text = item.Code.ToString();
  632. // if (item.D523.Fault != 0) con.BackColor = Color.Red;
  633. // else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  634. // else con.BackColor = Color.FromArgb(0, 144, 154);
  635. // if (item.D521.PH_STATUS == true)
  636. // {
  637. // if (con.button1.Tag.ToString() != "pall")
  638. // {
  639. // con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor4_right.png");
  640. // con.button1.Tag = "pall";
  641. // }
  642. // }
  643. // else
  644. // {
  645. // if (con.button1.Tag.ToString() != "empty")
  646. // {
  647. // con.button1.BackgroundImage = Image.FromFile("Resources/1001LR.gif");
  648. // con.button1.Tag = "empty";
  649. // }
  650. // }
  651. //}
  652. #endregion
  653. #endregion
  654. }
  655. }
  656. //string endtTime = DateTime.Now.ToString();
  657. //MessageBox.Show("开始时间--" + startTime + ",结束时间--" + endtTime);
  658. //eqpData.deviceDataPack = pack;
  659. }
  660. catch (Exception ex)
  661. {
  662. }
  663. finally
  664. {
  665. isinitfrm = true;
  666. }
  667. }
  668. private void lblsrm01_Click(object sender, EventArgs e)
  669. {
  670. Label srm = (Label)sender;
  671. string equName = srm.Name.Substring(3);
  672. FrmEquMsg_dtl Frm = new FrmEquMsg_dtl(equName);
  673. Frm.Show();
  674. }
  675. private void Frm_YongGuanMontior_FormClosing(object sender, FormClosingEventArgs e)
  676. {
  677. _timer.Stop();
  678. _timer.Elapsed -= new System.Timers.ElapsedEventHandler(theout);//到达时间的时候执行事件;
  679. }
  680. #region load
  681. private void con2114_Load(object sender, EventArgs e)
  682. {
  683. }
  684. private void tableCellLabel23_Load(object sender, EventArgs e)
  685. {
  686. }
  687. private void con2035_Load(object sender, EventArgs e)
  688. {
  689. }
  690. #endregion
  691. private void srm1_Load_1(object sender, EventArgs e)
  692. {
  693. srm srm = (srm)sender;
  694. string equName = "srm";
  695. if (srm.Name.ToString().Length > 4)
  696. {
  697. equName = srm.Name.Substring(4);
  698. }
  699. else
  700. {
  701. equName = srm.Name.Substring(3);
  702. }
  703. FrmEquMsg_dtl Frm = new FrmEquMsg_dtl(equName);
  704. Frm.Show();
  705. }
  706. }
  707. public class DDJSatatus
  708. {
  709. /// <summary>
  710. /// 状态图标
  711. /// </summary>
  712. public PictureBox G { get; set; }
  713. /// <summary>
  714. /// 堆垛机名称
  715. /// </summary>
  716. public string SrmName { get; set; }
  717. /// <summary>
  718. /// 入库状态
  719. /// </summary>
  720. public Label LblInStatus { get; set; }
  721. /// <summary>
  722. /// 出库状态
  723. /// </summary>
  724. public Label LblOutStatus { get; set; }
  725. /// <summary>
  726. /// 堆垛机模式
  727. /// </summary>
  728. public Label DdjMode { get; set; }
  729. public Label DdjWarning { get; set; }
  730. /// <summary>
  731. /// 堆垛机工作状态
  732. /// </summary>
  733. public Label DdjStatus { get; set; }
  734. /// <summary>
  735. /// 堆垛机工作任务
  736. /// </summary>
  737. public Label DdjOrdId { get; set; }
  738. /// <summary>
  739. /// 堆垛机作业类型
  740. /// </summary>
  741. public Label DdjOptType { get; set; }
  742. /// <summary>
  743. /// 堆垛机当前位置
  744. /// </summary>
  745. public Label DdjPosCurr { get; set; }
  746. /// <summary>
  747. /// 运行时间
  748. /// </summary>
  749. public Label DdjWorkTime { get; set; }
  750. /// <summary>
  751. /// 里程数
  752. /// </summary>
  753. public Label DdjTotal_KM { get; set; }
  754. /// <summary>
  755. /// 源仓位
  756. /// </summary>
  757. public Label DdjPosFrom { get; set; }
  758. /// <summary>
  759. /// 目标仓位
  760. /// </summary>
  761. public Label DdjPosTo { get; set; }
  762. }
  763. public class RGVSatatus
  764. {
  765. /// <summary>
  766. /// 状态图标
  767. /// </summary>
  768. public PictureBox G { get; set; }
  769. /// <summary>
  770. /// RGV名称
  771. /// </summary>
  772. public string RGVName { get; set; }
  773. /// <summary>
  774. /// RGV模式
  775. /// </summary>
  776. public Label RGVMode { get; set; }
  777. /// <summary>
  778. /// RGV工作状态
  779. /// </summary>
  780. public Label RGVStatus { get; set; }
  781. /// <summary>
  782. /// RGV工作任务
  783. /// </summary>
  784. public Label RGVOrdId { get; set; }
  785. /// <summary>
  786. /// RGV作业类型
  787. /// </summary>
  788. public Label RGVOptType { get; set; }
  789. /// <summary>
  790. /// RGV当前位置
  791. /// </summary>
  792. public Label RGVPosCurr { get; set; }
  793. /// <summary>
  794. /// 起始站台
  795. /// </summary>
  796. public Label RGVPosFrom { get; set; }
  797. /// <summary>
  798. /// 目标站台
  799. /// </summary>
  800. public Label RGVPosTo { get; set; }
  801. }
  802. public class WCS_STATION5201 : WCS_Station520
  803. {
  804. public new DateTime UPDATETIME { get; set; }
  805. }
  806. /// <summary>
  807. /// 提示 ToolTip
  808. /// </summary>
  809. public class MoveOverInfoTip
  810. {
  811. #region 基础参数
  812. //信息提示组件
  813. private static ToolTip _toolTip = new ToolTip();
  814. #endregion
  815. #region 公有方法
  816. /// <summary>
  817. /// 设置单个控件提示信息
  818. /// </summary>
  819. /// <typeparam name="T">组件类型</typeparam>
  820. /// <param name="t">组件</param>
  821. /// <param name="tipInfo">需要显示的提示信息</param>
  822. public static void SettingSingleTipInfo<T>(T t, string tipInfo) where T : Control
  823. {
  824. _toolTip.SetToolTip(t, tipInfo);
  825. }
  826. /// <summary>
  827. /// 设置多个同种类型的提示信息
  828. /// </summary>
  829. /// <typeparam name="T">组件类型</typeparam>
  830. /// <param name="dic">组件和提示信息字典</param>
  831. public static void SettingMutiTipInfo<T>(Dictionary<T, string> dic) where T : Control
  832. {
  833. if (dic == null || dic.Count <= 0) return;
  834. foreach (var item in dic)
  835. {
  836. _toolTip.SetToolTip(item.Key, item.Value);
  837. }
  838. }
  839. #endregion
  840. }
  841. }