StationUI.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using DbCommon.Enties.DbModels;
  10. using ProjectManagementSystem.Common.Core;
  11. using ProjectManagementSystem.Common.Logger;
  12. namespace ProjectManagementSystem.UI
  13. {
  14. public partial class StationUI : UserControl
  15. {
  16. private StationInfo m_info;
  17. public StationInfo StationInfo
  18. {
  19. get { return m_info; }
  20. }
  21. public StationUI()
  22. {
  23. InitializeComponent();
  24. }
  25. public void Init(StationInfo info)
  26. {
  27. m_info = info;
  28. }
  29. public void Display()
  30. {
  31. if (!Visible) return;
  32. this.labName.Text = $"{m_info.Name}{(m_info.Traffic ? "(管制)" : null)}{Environment.NewLine}地标{m_info.Mark}(指令{m_info.Command}){Environment.NewLine}{$"倒计时{m_info.CountSec}"}{Environment.NewLine}{m_info.AgvAlarmText}";
  33. this.labName.ForeColor = m_info.Online ? Color.Black : Color.DarkGray;
  34. this.labCar.ForeColor = m_info.Online ? Color.Black : Color.DarkGray;
  35. this.labCar.BackColor = m_info.HasCar ? Color.LightGreen : Color.LightGray;
  36. this.labCar.Text = $"AGV{m_info.AgvId},R{m_info.CurrentRoute},0x{m_info.AgvStausValue:X2}";
  37. switch (m_info.Status)
  38. {
  39. case LocationStatus.None:
  40. labName.BackColor = Color.LightGray;
  41. break;
  42. case LocationStatus.Filled:
  43. labName.BackColor = Color.Yellow;
  44. break;
  45. case LocationStatus.Empty:
  46. labName.BackColor = Color.Green;
  47. break;
  48. case LocationStatus.Locked:
  49. labName.BackColor = Color.Blue;
  50. break;
  51. case LocationStatus.Exception:
  52. labName.BackColor = Color.Red;
  53. break;
  54. default:
  55. labName.BackColor = Color.DarkGray;
  56. break;
  57. }
  58. }
  59. private void toolStripMenuItem1_Click(object sender, EventArgs e)
  60. {
  61. m_info.HasCar = !m_info.HasCar;
  62. }
  63. private void toolStripMenuItem2_Click(object sender, EventArgs e)
  64. {
  65. m_info.Status = LocationStatus.None;
  66. }
  67. private void toolStripMenuItem3_Click(object sender, EventArgs e)
  68. {
  69. if (m_info.Online
  70. && m_info.HasCar
  71. && m_info.ReleaseCold)
  72. {
  73. if (m_info.Traffic)
  74. {
  75. ShowErrMsg("管制中,不能放行!!!");
  76. return;
  77. }
  78. string text = $"确定要手动放行?";
  79. var dialogResult = MessageBox.Show(text, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
  80. if (dialogResult != DialogResult.OK)
  81. {
  82. return;
  83. }
  84. DeviceControl.Instance.ReleaseAgvOnStop(m_info.Mark, m_info.CurrentRoute, m_info.AgvId);
  85. m_info.LastReleaseTime = DateTime.Now.Ticks;
  86. CLog.Instance.TaskLog.WriteInfo($"手动放行,地标:{m_info.Mark},路线:{m_info.CurrentRoute},AGV:{m_info.AgvId},{m_info.Name},0x{m_info.AgvStausValue:X2}");
  87. }
  88. }
  89. private void ShowErrMsg(string text)
  90. {
  91. MessageBox.Show(text, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  92. }
  93. }
  94. }