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

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