终端一体化运控平台
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 

289 рядки
12 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. namespace FryPot_DosingSystem
  20. {
  21. /// <summary>
  22. /// Interaction logic for App.xaml
  23. /// </summary>
  24. public partial class App : Application
  25. {
  26. public static Window MainWindow;
  27. protected override async void OnStartup(StartupEventArgs e)
  28. {
  29. base.OnStartup(e);
  30. SystemHelper.GetInstance.CreateDesktopShortcut();
  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. await Task.Run(()=> { DeviceOperate deviceOperate = DeviceOperate.GetInstance; });//开启实时PLC数据读取
  41. DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序
  42. HubHelper.GetInstance.Connect("192.168.1.20", 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> ParamSet = new ObservableCollection<SubMenumodel>();
  133. ParamSet.Add(new SubMenumodel()
  134. {
  135. SubMenuName = "PLC通讯设置",
  136. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  137. AssemblyName = "FryPot_DosingSystem",
  138. ToggleWindowPath = "View.DeviceListVIew"
  139. });
  140. ParamSet.Add(new SubMenumodel()
  141. {
  142. SubMenuName = "PLC变量配置",
  143. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  144. AssemblyName = "BPASmartClient.CustomResource",
  145. ToggleWindowPath = "Pages.View.VariableConfigView"
  146. });
  147. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  148. {
  149. MainMenuIcon = "&#xe603;",
  150. MainMenuName = "参数设置",
  151. Alias = "Parameters Set",
  152. MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 },
  153. subMenumodels = ParamSet,
  154. });
  155. #endregion
  156. #region 硬件设备监控
  157. ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
  158. //DeviceMonitor.Add(new SubMenumodel()
  159. //{
  160. // SubMenuName = "PLC通讯设置",
  161. // SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  162. // AssemblyName = "FryPot_DosingSystem",
  163. // ToggleWindowPath = "View.DeviceListVIew"
  164. //});
  165. //DeviceMonitor.Add(new SubMenumodel()
  166. //{
  167. // SubMenuName = "PLC变量配置",
  168. // SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  169. // AssemblyName = "BPASmartClient.CustomResource",
  170. // ToggleWindowPath = "Pages.View.VariableConfigView"
  171. //});
  172. DeviceMonitor.Add(new SubMenumodel()
  173. {
  174. SubMenuName = "滚筒线运行状态",
  175. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 },
  176. AssemblyName = "FryPot_DosingSystem",
  177. ToggleWindowPath = "View.HardWareStatusView"
  178. });
  179. DeviceMonitor.Add(new SubMenumodel()
  180. {
  181. SubMenuName = "炒锅状态数据监控",
  182. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 },
  183. AssemblyName = "FryPot_DosingSystem",
  184. ToggleWindowPath = "View.FryPotMonitorView"
  185. });
  186. DeviceMonitor.Add(new SubMenumodel()
  187. {
  188. SubMenuName = "AGV视图",
  189. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 },
  190. AssemblyName = "FryPot_DosingSystem",
  191. ToggleWindowPath = "View.AgvView"
  192. });
  193. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  194. {
  195. MainMenuIcon = "&#xe603;",
  196. MainMenuName = "设备监控",
  197. Alias = "Device Monitor",
  198. MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 },
  199. subMenumodels = DeviceMonitor,
  200. });
  201. #endregion
  202. #region 用户管理
  203. ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>();
  204. UserManager.Add(new SubMenumodel()
  205. {
  206. SubMenuName = "用户登录",
  207. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员, Permission.观察员, Permission.操作员 },
  208. AssemblyName = "BPASmartClient.CustomResource",
  209. ToggleWindowPath = "Pages.View.SubPagLoginView"
  210. });
  211. UserManager.Add(new SubMenumodel()
  212. {
  213. SubMenuName = "密码修改",
  214. SubMenuPermission = new Permission[] { Permission.管理员 },
  215. AssemblyName = "BPASmartClient.CustomResource",
  216. ToggleWindowPath = "Pages.View.PasswordChangeView"
  217. });
  218. UserManager.Add(new SubMenumodel()
  219. {
  220. SubMenuName = "用户管理",
  221. SubMenuPermission = new Permission[] { Permission.管理员 },
  222. AssemblyName = "BPASmartClient.CustomResource",
  223. ToggleWindowPath = "Pages.View.UserManageView"
  224. });
  225. UserManager.Add(new SubMenumodel()
  226. {
  227. SubMenuName = "NFC登录设置",
  228. SubMenuPermission = new Permission[] { Permission.管理员 },
  229. AssemblyName = "BPASmartClient.CustomResource",
  230. ToggleWindowPath = "Pages.View.NfcSetView"
  231. });
  232. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  233. {
  234. MainMenuIcon = "&#xe66d;",
  235. MainMenuName = "用户管理",
  236. Alias = "User Management",
  237. MainMenuPermission = new Permission[] { Permission.管理员, Permission.技术员, Permission.观察员, Permission.操作员 },
  238. subMenumodels = UserManager,
  239. });
  240. #endregion
  241. #region 调试界面
  242. ObservableCollection<SubMenumodel> DebugManage = new ObservableCollection<SubMenumodel>();
  243. DebugManage.Add(new SubMenumodel()
  244. {
  245. SubMenuName = "单一流程调试",
  246. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  247. AssemblyName = "FryPot_DosingSystem",
  248. ToggleWindowPath = "View.DebugView"
  249. });
  250. #endregion
  251. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  252. {
  253. MainMenuIcon = "&#xe683;",
  254. MainMenuName = "调试界面",
  255. Alias = "Debug Management",
  256. MainMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  257. subMenumodels = DebugManage,
  258. });
  259. }
  260. private void LoginDataInite()
  261. {
  262. //Config.GetInstance.Init();//用户数据初始化
  263. Json<RecipeManage>.Read();
  264. }
  265. }
  266. }