Frm_YongGuanMontior.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913
  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
  302. {
  303. ddjstatus.LblInStatus.BackColor = Color.DarkGray;
  304. ddjstatus.LblOutStatus.BackColor = Color.DarkGray;
  305. }
  306. }
  307. });
  308. ////运行时长
  309. ddjstatus.DdjWorkTime.Text = item.D521.Runtime.ToString() + "h";
  310. ////里程数
  311. ddjstatus.DdjTotal_KM.Text = item.D521.TotalKM.ToString() + "KM";
  312. }
  313. }
  314. //RGV
  315. foreach (var item in rgvdata.Datas)
  316. {
  317. //只更新有变更的数据
  318. //var oldItem = eqpData.oldDeviceDataPack.RGVDatas.Datas.FirstOrDefault(p => p.Code == item.Code);
  319. //if (oldItem.ToString() == item.ToString()) return;
  320. var rgvstatus = RGVSatatusSet.FirstOrDefault(v => v.RGVName == item.Code);
  321. if (rgvstatus != null)
  322. {
  323. string workmode = item.D521.WorkMode.ToString();
  324. //模式
  325. rgvstatus.RGVMode.Text = item.D521.WorkMode.ToString();
  326. if (item.D521.WorkMode.ToString() == "自动")
  327. {
  328. rgvstatus.G.Image = Properties.Resources.绿;
  329. }
  330. else if (item.D521.WorkMode.ToString() == "半自动")
  331. {
  332. rgvstatus.G.Image = Properties.Resources.黄;
  333. }
  334. else if (item.D521.WorkMode.ToString() == "手动")
  335. {
  336. rgvstatus.G.Image = Properties.Resources.黄;
  337. }
  338. else if (item.D521.WorkMode.ToString() == "维护")
  339. {
  340. rgvstatus.G.Image = Properties.Resources.红;
  341. }
  342. else if(item.D521.WorkMode.ToString() == "99")
  343. {
  344. rgvstatus.RGVMode.Text = "手动";
  345. rgvstatus.G.Image = Properties.Resources.黄;
  346. }
  347. ////状态
  348. rgvstatus.RGVStatus.Text = item.D521.SystemStatus.ToString();
  349. //rgvstatus.RGVOrdId.Text = item.D521.TaskID_1.ToString();
  350. //任务Id
  351. if (item.D521.TaskID_1.ToString().Length > 3)
  352. {
  353. rgvstatus.RGVOrdId.Text = item.D521.TaskID_1.ToString();
  354. }
  355. else if (item.D521.TaskID_2.ToString().Length > 3)
  356. {
  357. rgvstatus.RGVOrdId.Text = item.D521.TaskID_2.ToString();
  358. }
  359. else
  360. {
  361. rgvstatus.RGVOrdId.Text = item.D521.TaskID_1.ToString();
  362. }
  363. if (item.D521.Status_1.HasFlag(WCS.Entity.Protocol.RGVStatus.光电) || item.D521.Status_2.HasFlag(WCS.Entity.Protocol.RGVStatus.光电))
  364. {
  365. rgvstatus.RGVPosCurr.Text = "true";
  366. }
  367. else
  368. {
  369. rgvstatus.RGVPosCurr.Text = "false";
  370. }
  371. //作业类型
  372. rgvstatus.RGVOptType.Text = item.D521.TaskType_1.ToString();
  373. //当前位置
  374. //rgvstatus.RGVPosCurr.Text = item.D521.Position.ToString();
  375. //起始位置
  376. rgvstatus.RGVPosFrom.Text = item.D521.Position.ToString(); //item.D521.StartPosition_1.ToString();
  377. //目标位置
  378. rgvstatus.RGVPosTo.Text = item.D521.DestPosition_1.ToString();
  379. var control = FindControl(item.Code);
  380. if (control != null)
  381. {
  382. if (control is Conveyor_R)
  383. {
  384. var con = (Conveyor_R)control;
  385. con.button1.Text = item.Code.ToString();
  386. if (item.D523.Fault != 0) con.BackColor = Color.Red;
  387. else if (item.D523.Status == 0 && item.Code.ToString()!="RGV8") con.BackColor = Color.Yellow;
  388. else con.BackColor = Color.FromArgb(0, 144, 154);
  389. if (item.D521.Status_1.HasFlag(WCS.Entity.Protocol.RGVStatus.光电))
  390. {
  391. if (con.button1.Tag.ToString() != "pall")
  392. {
  393. con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor_R.png");//1009L1.png
  394. con.button1.Tag = "pall";
  395. }
  396. }
  397. else
  398. {
  399. if (con.button1.Tag.ToString() != "empty")
  400. {
  401. con.button1.BackgroundImage = Image.FromFile("Resources/1009L1.png");//1009L1.png
  402. con.button1.Tag = "empty";
  403. }
  404. }
  405. }
  406. }
  407. }
  408. }
  409. //输送线
  410. foreach (var item in convdata.Datas)
  411. {
  412. //只更新有变更的数据
  413. var control = FindControl("con" + item.Code);
  414. if (control != null)
  415. {
  416. if (control is Conveyor)
  417. {
  418. var con = (Conveyor)control;
  419. if (item.D523.Alarm != 0) con.BackColor = Color.Red;
  420. else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  421. else con.BackColor = Color.FromArgb(0, 144, 154);
  422. con.button1.Text = item.Code.ToString();
  423. if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.光电状态))
  424. {
  425. if (con.button1.Tag.ToString() != "pall")
  426. {
  427. con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor.png");
  428. con.button1.Tag = "pall";
  429. }
  430. }
  431. else if (item.D521.Tasknum.ToString().Length > 10000)
  432. {
  433. if (con.button1.Tag.ToString() != "pall")
  434. {
  435. con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor.png");
  436. con.button1.Tag = "pall";
  437. }
  438. }
  439. else
  440. {
  441. if (con.button1.Tag.ToString() != "empty")
  442. {
  443. con.button1.BackgroundImage = Image.FromFile("Resources/shelf16UD.png");
  444. con.button1.Tag = "empty";
  445. }
  446. }
  447. }
  448. #region condition
  449. else if (control is Conveyor_L)
  450. {
  451. var con = (Conveyor_L)control;
  452. con.button1.Text = item.Code.ToString();
  453. if (item.D523.Alarm != 0) con.BackColor = Color.Red;
  454. else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  455. else con.BackColor = Color.FromArgb(0, 144, 154);
  456. if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.光电状态))
  457. {
  458. if (con.button1.Tag.ToString() != "pall")
  459. {
  460. con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor_L.png");//1009L11.png
  461. con.button1.Tag = "pall";
  462. }
  463. }
  464. else
  465. {
  466. if (con.button1.Tag.ToString() != "empty")
  467. {
  468. con.button1.BackgroundImage = Image.FromFile("Resources/1009L11.png");//1009L11.png
  469. con.button1.Tag = "empty";
  470. }
  471. }
  472. }
  473. else if (control is Conveyor_R)
  474. {
  475. var con = (Conveyor_R)control;
  476. con.button1.Text = item.Code.ToString();
  477. if (item.D523.Alarm != 0) con.BackColor = Color.Red;
  478. else if(item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.条码未读出)) con.BackColor = Color.Red;
  479. else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  480. else con.BackColor = Color.FromArgb(0, 144, 154);
  481. if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.光电状态))
  482. {
  483. if (con.button1.Tag.ToString() != "pall")
  484. {
  485. con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor_R.png");//1009L1.png
  486. con.button1.Tag = "pall";
  487. }
  488. }
  489. else
  490. {
  491. if (con.button1.Tag.ToString() != "empty")
  492. {
  493. con.button1.BackgroundImage = Image.FromFile("Resources/1009L1.png");//1009L1.png
  494. con.button1.Tag = "empty";
  495. }
  496. }
  497. }
  498. else if (control is Conveyor3_A)
  499. {
  500. var con = (Conveyor3_A)control;
  501. con.button1.Text = item.Code.ToString();
  502. if (item.D523.Alarm != 0) con.BackColor = Color.Red;
  503. else if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.条码未读出)) con.BackColor = Color.Red;
  504. else if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.外检扫码故障)) con.BackColor = Color.Red;
  505. else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  506. else con.BackColor = Color.FromArgb(0, 144, 154);
  507. if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.光电状态))
  508. {
  509. if (con.button1.Tag.ToString() != "pall")
  510. {
  511. con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor3_A_Box.png");//Conveyor3_A_Box.png
  512. con.button1.Tag = "pall";
  513. }
  514. }
  515. else
  516. {
  517. if (con.button1.Tag.ToString() != "empty")
  518. {
  519. con.button1.BackgroundImage = Image.FromFile("Resources/1009_A.png");//1009_A.png
  520. con.button1.Tag = "empty";
  521. }
  522. }
  523. }
  524. else if (control is Conveyor3_B)
  525. {
  526. var con = (Conveyor3_B)control;
  527. con.button1.Text = item.Code.ToString();
  528. if (item.D523.Alarm != 0) con.BackColor = Color.Red;
  529. else if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.条码未读出)) con.BackColor = Color.Red;
  530. else if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.外检扫码故障)) con.BackColor = Color.Red;
  531. else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  532. else con.BackColor = Color.FromArgb(0, 144, 154);
  533. if (item.D521.Status.HasFlag(WCS.Entity.Protocol.IstationStatus.光电状态))
  534. {
  535. if (con.button1.Tag.ToString() != "pall")
  536. {
  537. con.button1.BackgroundImage = Image.FromFile("Resources/1009R1_B.png");//1009R1_A.png
  538. con.button1.Tag = "pall";
  539. }
  540. }
  541. else
  542. {
  543. if (con.button1.Tag.ToString() != "empty")
  544. {
  545. con.button1.BackgroundImage = Image.FromFile("Resources/1009R1.png");//1009R1.png
  546. con.button1.Tag = "empty";
  547. }
  548. }
  549. }
  550. #region ---
  551. //else if (control is Conveyor4_L_R)
  552. //{
  553. // var con = (Conveyor4_L_R)control;
  554. // con.button1.Text = item.Code.ToString();
  555. // if (item.D523.Fault != 0) con.BackColor = Color.Red;
  556. // else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  557. // else con.BackColor = Color.FromArgb(0, 144, 154);
  558. // if (item.D521.PH_STATUS == true)
  559. // {
  560. // if (con.button1.Tag.ToString() != "pall")
  561. // {
  562. // con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor4_L_R.png");
  563. // con.button1.Tag = "pall";
  564. // }
  565. // }
  566. // else
  567. // {
  568. // if (con.button1.Tag.ToString() != "empty")
  569. // {
  570. // con.button1.BackgroundImage = Image.FromFile("Resources/1001LR.gif");
  571. // con.button1.Tag = "empty";
  572. // }
  573. // }
  574. //}
  575. //else if (control is Conveyor3)
  576. //{
  577. // var con = (Conveyor3)control;
  578. // con.button1.Text = item.Code.ToString();
  579. // if (item.D523.Fault != 0) con.BackColor = Color.Red;
  580. // else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  581. // else con.BackColor = Color.FromArgb(0, 144, 154);
  582. // if (item.D521.PH_STATUS == true)
  583. // {
  584. // if (con.button1.Tag.ToString() != "pall")
  585. // {
  586. // con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor3.png");//1009R1_A.png
  587. // con.button1.Tag = "pall";
  588. // }
  589. // }
  590. // else
  591. // {
  592. // if (con.button1.Tag.ToString() != "empty")
  593. // {
  594. // con.button1.BackgroundImage = Image.FromFile("Resources/1004LR.png");//1009R1.png
  595. // con.button1.Tag = "empty";
  596. // }
  597. // }
  598. //}
  599. //else if (control is Conveyor4_left)
  600. //{
  601. // var con = (Conveyor4_left)control;
  602. // con.button1.Text = item.Code.ToString();
  603. // if (item.D523.Fault != 0) con.BackColor = Color.Red;
  604. // else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  605. // else con.BackColor = Color.FromArgb(0, 144, 154);
  606. // if (item.D521.PH_STATUS == true)
  607. // {
  608. // if (con.button1.Tag.ToString() != "pall")
  609. // {
  610. // con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor4_left.png");
  611. // con.button1.Tag = "pall";
  612. // }
  613. // }
  614. // else
  615. // {
  616. // if (con.button1.Tag.ToString() != "empty")
  617. // {
  618. // con.button1.BackgroundImage = Image.FromFile("Resources/1001L.gif");
  619. // con.button1.Tag = "empty";
  620. // }
  621. // }
  622. //}
  623. //else if (control is Conveyor4_right)
  624. //{
  625. // var con = (Conveyor4_right)control;
  626. // con.button1.Text = item.Code.ToString();
  627. // if (item.D523.Fault != 0) con.BackColor = Color.Red;
  628. // else if (item.D523.Status == 0) con.BackColor = Color.Yellow;
  629. // else con.BackColor = Color.FromArgb(0, 144, 154);
  630. // if (item.D521.PH_STATUS == true)
  631. // {
  632. // if (con.button1.Tag.ToString() != "pall")
  633. // {
  634. // con.button1.BackgroundImage = Image.FromFile("Resources/Conveyor4_right.png");
  635. // con.button1.Tag = "pall";
  636. // }
  637. // }
  638. // else
  639. // {
  640. // if (con.button1.Tag.ToString() != "empty")
  641. // {
  642. // con.button1.BackgroundImage = Image.FromFile("Resources/1001LR.gif");
  643. // con.button1.Tag = "empty";
  644. // }
  645. // }
  646. //}
  647. #endregion
  648. #endregion
  649. }
  650. }
  651. //string endtTime = DateTime.Now.ToString();
  652. //MessageBox.Show("开始时间--" + startTime + ",结束时间--" + endtTime);
  653. //eqpData.deviceDataPack = pack;
  654. }
  655. catch (Exception ex)
  656. {
  657. }
  658. finally
  659. {
  660. isinitfrm = true;
  661. }
  662. }
  663. private void lblsrm01_Click(object sender, EventArgs e)
  664. {
  665. Label srm = (Label)sender;
  666. string equName = srm.Name.Substring(3);
  667. FrmEquMsg_dtl Frm = new FrmEquMsg_dtl(equName);
  668. Frm.Show();
  669. }
  670. private void Frm_YongGuanMontior_FormClosing(object sender, FormClosingEventArgs e)
  671. {
  672. _timer.Stop();
  673. _timer.Elapsed -= new System.Timers.ElapsedEventHandler(theout);//到达时间的时候执行事件;
  674. }
  675. #region load
  676. private void con2114_Load(object sender, EventArgs e)
  677. {
  678. }
  679. private void tableCellLabel23_Load(object sender, EventArgs e)
  680. {
  681. }
  682. private void con2035_Load(object sender, EventArgs e)
  683. {
  684. }
  685. #endregion
  686. private void srm1_Load_1(object sender, EventArgs e)
  687. {
  688. srm srm = (srm)sender;
  689. string equName = "srm";
  690. if (srm.Name.ToString().Length > 4)
  691. {
  692. equName = srm.Name.Substring(4);
  693. }
  694. else
  695. {
  696. equName = srm.Name.Substring(3);
  697. }
  698. FrmEquMsg_dtl Frm = new FrmEquMsg_dtl(equName);
  699. Frm.Show();
  700. }
  701. }
  702. public class DDJSatatus
  703. {
  704. /// <summary>
  705. /// 状态图标
  706. /// </summary>
  707. public PictureBox G { get; set; }
  708. /// <summary>
  709. /// 堆垛机名称
  710. /// </summary>
  711. public string SrmName { get; set; }
  712. /// <summary>
  713. /// 入库状态
  714. /// </summary>
  715. public Label LblInStatus { get; set; }
  716. /// <summary>
  717. /// 出库状态
  718. /// </summary>
  719. public Label LblOutStatus { get; set; }
  720. /// <summary>
  721. /// 堆垛机模式
  722. /// </summary>
  723. public Label DdjMode { get; set; }
  724. public Label DdjWarning { get; set; }
  725. /// <summary>
  726. /// 堆垛机工作状态
  727. /// </summary>
  728. public Label DdjStatus { get; set; }
  729. /// <summary>
  730. /// 堆垛机工作任务
  731. /// </summary>
  732. public Label DdjOrdId { get; set; }
  733. /// <summary>
  734. /// 堆垛机作业类型
  735. /// </summary>
  736. public Label DdjOptType { get; set; }
  737. /// <summary>
  738. /// 堆垛机当前位置
  739. /// </summary>
  740. public Label DdjPosCurr { get; set; }
  741. /// <summary>
  742. /// 运行时间
  743. /// </summary>
  744. public Label DdjWorkTime { get; set; }
  745. /// <summary>
  746. /// 里程数
  747. /// </summary>
  748. public Label DdjTotal_KM { get; set; }
  749. /// <summary>
  750. /// 源仓位
  751. /// </summary>
  752. public Label DdjPosFrom { get; set; }
  753. /// <summary>
  754. /// 目标仓位
  755. /// </summary>
  756. public Label DdjPosTo { get; set; }
  757. }
  758. public class RGVSatatus
  759. {
  760. /// <summary>
  761. /// 状态图标
  762. /// </summary>
  763. public PictureBox G { get; set; }
  764. /// <summary>
  765. /// RGV名称
  766. /// </summary>
  767. public string RGVName { get; set; }
  768. /// <summary>
  769. /// RGV模式
  770. /// </summary>
  771. public Label RGVMode { get; set; }
  772. /// <summary>
  773. /// RGV工作状态
  774. /// </summary>
  775. public Label RGVStatus { get; set; }
  776. /// <summary>
  777. /// RGV工作任务
  778. /// </summary>
  779. public Label RGVOrdId { get; set; }
  780. /// <summary>
  781. /// RGV作业类型
  782. /// </summary>
  783. public Label RGVOptType { get; set; }
  784. /// <summary>
  785. /// RGV当前位置
  786. /// </summary>
  787. public Label RGVPosCurr { get; set; }
  788. /// <summary>
  789. /// 起始站台
  790. /// </summary>
  791. public Label RGVPosFrom { get; set; }
  792. /// <summary>
  793. /// 目标站台
  794. /// </summary>
  795. public Label RGVPosTo { get; set; }
  796. }
  797. public class WCS_STATION5201 : WCS_Station520
  798. {
  799. public new DateTime UPDATETIME { get; set; }
  800. }
  801. /// <summary>
  802. /// 提示 ToolTip
  803. /// </summary>
  804. public class MoveOverInfoTip
  805. {
  806. #region 基础参数
  807. //信息提示组件
  808. private static ToolTip _toolTip = new ToolTip();
  809. #endregion
  810. #region 公有方法
  811. /// <summary>
  812. /// 设置单个控件提示信息
  813. /// </summary>
  814. /// <typeparam name="T">组件类型</typeparam>
  815. /// <param name="t">组件</param>
  816. /// <param name="tipInfo">需要显示的提示信息</param>
  817. public static void SettingSingleTipInfo<T>(T t, string tipInfo) where T : Control
  818. {
  819. _toolTip.SetToolTip(t, tipInfo);
  820. }
  821. /// <summary>
  822. /// 设置多个同种类型的提示信息
  823. /// </summary>
  824. /// <typeparam name="T">组件类型</typeparam>
  825. /// <param name="dic">组件和提示信息字典</param>
  826. public static void SettingMutiTipInfo<T>(Dictionary<T, string> dic) where T : Control
  827. {
  828. if (dic == null || dic.Count <= 0) return;
  829. foreach (var item in dic)
  830. {
  831. _toolTip.SetToolTip(item.Key, item.Value);
  832. }
  833. }
  834. #endregion
  835. }
  836. }