终端一体化运控平台
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.
 
 
 

265 lines
11 KiB

  1. using BPASmartClient.AGV.Feedback;
  2. using BPASmartClient.CustomResource.Pages.Enums;
  3. using BPASmartClient.CustomResource.Pages.Model;
  4. using BPASmartClient.CustomResource.Pages.View;
  5. using BPASmartClient.Helper;
  6. using BPASmartClient.HubHelper;
  7. using FryPot_DosingSystem.Control;
  8. using FryPot_DosingSystem.Model;
  9. using Newtonsoft.Json;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Collections.ObjectModel;
  13. using System.Configuration;
  14. using System.Data;
  15. using System.IO;
  16. using System.Linq;
  17. using System.Threading.Tasks;
  18. using System.Windows;
  19. using AlarmInfo = BPASmartClient.CustomResource.Pages.Model.AlarmInfo;
  20. namespace FryPot_DosingSystem
  21. {
  22. /// <summary>
  23. /// Interaction logic for App.xaml
  24. /// </summary>
  25. public partial class App : Application
  26. {
  27. public static Window MainWindow;
  28. protected override void OnStartup(StartupEventArgs e)
  29. {
  30. base.OnStartup(e);
  31. MenuInite();
  32. LoginDataInite();
  33. MainView mv = new MainView();
  34. LoginView lv = new LoginView();
  35. var res = lv.ShowDialog();
  36. if (res != null && res == true)
  37. {
  38. mv.Show();
  39. DeviceOperate deviceOperate = DeviceOperate.GetInstance;//开启实时PLC数据读取
  40. DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序
  41. HubHelper.GetInstance.Connect("192.168.1.40", 8089);
  42. AlarmHelper<AlarmInfo>.Init();
  43. }
  44. else
  45. mv.Close();
  46. MainWindow = mv;
  47. //HubHelper.GetInstance.Report = new Action<object>((o) =>
  48. //{
  49. // var res = JsonConvert.DeserializeObject<AGVToUpSystem>(o.ToString());
  50. //});
  51. //HubHelper.GetInstance.Upstreamrequest = new Action<object>((o) =>
  52. //{
  53. // var res = JsonConvert.DeserializeObject<Upstreamrequest>(o.ToString());
  54. //});
  55. //本地服务连接
  56. }
  57. protected override void OnExit(ExitEventArgs e)
  58. {
  59. base.OnExit(e);
  60. Json<RecipeManage>.Save();
  61. MessageLog.GetInstance.LogSave();
  62. }
  63. private void MenuInite()
  64. {
  65. NfcServer.GetInstance.Init();
  66. #region 配方管理菜单
  67. ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
  68. RecipeManage.Add(new SubMenumodel()
  69. {
  70. SubMenuName = "配方管理",
  71. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  72. AssemblyName = "FryPot_DosingSystem",
  73. ToggleWindowPath = "View.RecipeManageView"
  74. });
  75. RecipeManage.Add(new SubMenumodel()
  76. {
  77. SubMenuName = "配方下发",
  78. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  79. AssemblyName = "FryPot_DosingSystem",
  80. ToggleWindowPath = "View.RecipesSendDown"
  81. });
  82. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  83. {
  84. MainMenuIcon = "&#xe683;",
  85. MainMenuName = "配方管理",
  86. Alias = "Recipe Management",
  87. MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  88. subMenumodels = RecipeManage,
  89. });
  90. #endregion
  91. #region 消息日志
  92. ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>();
  93. InfoLog.Add(new SubMenumodel()
  94. {
  95. SubMenuName = "操作日志",
  96. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  97. AssemblyName = "BPASmartClient.CustomResource",
  98. ToggleWindowPath = "Pages.View.UserLogView"
  99. });
  100. InfoLog.Add(new SubMenumodel()
  101. {
  102. SubMenuName = "运行日志",
  103. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  104. AssemblyName = "BPASmartClient.CustomResource",
  105. ToggleWindowPath = "Pages.View.RunLogView"
  106. });
  107. InfoLog.Add(new SubMenumodel()
  108. {
  109. SubMenuName = "报警记录",
  110. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  111. AssemblyName = "BPASmartClient.CustomResource",
  112. ToggleWindowPath = "Pages.View.AlarmView"
  113. });
  114. InfoLog.Add(new SubMenumodel()
  115. {
  116. SubMenuName = "炒锅状态记录",
  117. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  118. AssemblyName = "FryPot_DosingSystem",
  119. ToggleWindowPath = "View.SqliteDataView"
  120. });
  121. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  122. {
  123. MainMenuIcon = "&#xe668;",
  124. MainMenuName = "消息日志",
  125. Alias = "Message Log",
  126. MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  127. subMenumodels = InfoLog,
  128. });
  129. #endregion
  130. #region 硬件设备监控
  131. ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
  132. DeviceMonitor.Add(new SubMenumodel()
  133. {
  134. SubMenuName = "PLC通讯设置",
  135. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  136. AssemblyName = "FryPot_DosingSystem",
  137. ToggleWindowPath = "View.DeviceListVIew"
  138. });
  139. DeviceMonitor.Add(new SubMenumodel()
  140. {
  141. SubMenuName = "PLC变量配置",
  142. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  143. AssemblyName = "BPASmartClient.CustomResource",
  144. ToggleWindowPath = "Pages.View.VariableConfigView"
  145. });
  146. DeviceMonitor.Add(new SubMenumodel()
  147. {
  148. SubMenuName = "滚筒线运行状态",
  149. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 },
  150. AssemblyName = "FryPot_DosingSystem",
  151. ToggleWindowPath = "View.HardWareStatusView"
  152. });
  153. DeviceMonitor.Add(new SubMenumodel()
  154. {
  155. SubMenuName = "炒锅状态监控",
  156. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 },
  157. AssemblyName = "FryPot_DosingSystem",
  158. ToggleWindowPath = "View.FryPotMonitorView"
  159. });
  160. DeviceMonitor.Add(new SubMenumodel()
  161. {
  162. SubMenuName = "AGV视图",
  163. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  164. AssemblyName = "FryPot_DosingSystem",
  165. ToggleWindowPath = "View.AgvView"
  166. });
  167. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  168. {
  169. MainMenuIcon = "&#xe603;",
  170. MainMenuName = "设备监控",
  171. Alias = "Device Monitor",
  172. MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 },
  173. subMenumodels = DeviceMonitor,
  174. });
  175. #endregion
  176. #region 用户管理
  177. ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>();
  178. UserManager.Add(new SubMenumodel()
  179. {
  180. SubMenuName = "用户登录",
  181. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  182. AssemblyName = "BPASmartClient.CustomResource",
  183. ToggleWindowPath = "Pages.View.SubPagLoginView"
  184. });
  185. UserManager.Add(new SubMenumodel()
  186. {
  187. SubMenuName = "密码修改",
  188. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  189. AssemblyName = "BPASmartClient.CustomResource",
  190. ToggleWindowPath = "Pages.View.PasswordChangeView"
  191. });
  192. UserManager.Add(new SubMenumodel()
  193. {
  194. SubMenuName = "账号管理",
  195. SubMenuPermission = new Permission[] { Permission.管理员 },
  196. AssemblyName = "BPASmartClient.CustomResource",
  197. ToggleWindowPath = "Pages.View.UserManageView"
  198. });
  199. UserManager.Add(new SubMenumodel()
  200. {
  201. SubMenuName = "NFC登录设置",
  202. SubMenuPermission = new Permission[] { Permission.管理员 },
  203. AssemblyName = "BPASmartClient.CustomResource",
  204. ToggleWindowPath = "Pages.View.NfcSetView"
  205. });
  206. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  207. {
  208. MainMenuIcon = "&#xe66d;",
  209. MainMenuName = "用户管理",
  210. Alias = "User Management",
  211. MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  212. subMenumodels = UserManager,
  213. });
  214. #endregion
  215. #region 调试界面
  216. ObservableCollection<SubMenumodel> DebugManage = new ObservableCollection<SubMenumodel>();
  217. DebugManage.Add(new SubMenumodel()
  218. {
  219. SubMenuName = "单一流程调试",
  220. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  221. AssemblyName = "FryPot_DosingSystem",
  222. ToggleWindowPath = "View.DebugView"
  223. });
  224. #endregion
  225. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  226. {
  227. MainMenuIcon = "&#xe683;",
  228. MainMenuName = "调试界面",
  229. Alias = "Debug Management",
  230. MainMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  231. subMenumodels = DebugManage,
  232. });
  233. }
  234. private void LoginDataInite()
  235. {
  236. Config.GetInstance.Init();//用户数据初始化
  237. Json<RecipeManage>.Read();
  238. }
  239. }
  240. }