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

298 строки
13 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.Net.Sockets;
  18. using System.Threading.Tasks;
  19. using System.Windows;
  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 async void OnStartup(StartupEventArgs e)
  29. {
  30. base.OnStartup(e);
  31. SystemHelper.GetInstance.CreateDesktopShortcut();
  32. MenuInite();
  33. LoginDataInite();
  34. MainView mv = new MainView();
  35. LoginView lv = new LoginView();
  36. var res = lv.ShowDialog();
  37. if (res != null && res == true)
  38. {
  39. mv.Show();
  40. MessageNotify.GetInstance.ShowUserLog("用户登录");
  41. try
  42. {
  43. await Task.Run(() => { DeviceOperate deviceOperate = DeviceOperate.GetInstance; });
  44. }
  45. catch (Exception)
  46. {
  47. MessageNotify.GetInstance.ShowRunLog("下位机PLC连接失败,请检查无误后重启上位机");
  48. }
  49. //开启实时PLC数据读取
  50. DosingLogicControl logigControl = DosingLogicControl.GetInstance;//开启逻辑控制任务程序
  51. AlarmHelper<AlarmInfo>.Init();//报警实时监控
  52. HubHelper.GetInstance.Connect("172.16.12.100", 8089);
  53. }
  54. else
  55. mv.Close();
  56. MainWindow = mv;
  57. //HubHelper.GetInstance.Report = new Action<object>((o) =>
  58. //{
  59. // var res = JsonConvert.DeserializeObject<AGVToUpSystem>(o.ToString());
  60. //});
  61. //HubHelper.GetInstance.Upstreamrequest = new Action<object>((o) =>
  62. //{
  63. // var res = JsonConvert.DeserializeObject<Upstreamrequest>(o.ToString());
  64. //});
  65. //本地服务连接
  66. }
  67. protected override void OnExit(ExitEventArgs e)
  68. {
  69. base.OnExit(e);
  70. Json<RecipeManage>.Save();
  71. MessageNotify.GetInstance.LogSave();
  72. }
  73. private void MenuInite()
  74. {
  75. // NfcServer.GetInstance.Init(); //NFC刷卡
  76. #region 配方管理菜单
  77. ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
  78. RecipeManage.Add(new SubMenumodel()
  79. {
  80. SubMenuName = "配方管理",
  81. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  82. AssemblyName = "FryPot_DosingSystem",
  83. ToggleWindowPath = "View.RecipeManageView"
  84. });
  85. RecipeManage.Add(new SubMenumodel()
  86. {
  87. SubMenuName = "配方下发",
  88. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  89. AssemblyName = "FryPot_DosingSystem",
  90. ToggleWindowPath = "View.RecipesSendDown"
  91. });
  92. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  93. {
  94. MainMenuIcon = "&#xe683;",
  95. MainMenuName = "配方管理",
  96. Alias = "Recipe Management",
  97. MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  98. subMenumodels = RecipeManage,
  99. });
  100. #endregion
  101. #region 消息日志
  102. ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>();
  103. InfoLog.Add(new SubMenumodel()
  104. {
  105. SubMenuName = "操作日志",
  106. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.观察员 },
  107. AssemblyName = "BPASmartClient.CustomResource",
  108. ToggleWindowPath = "Pages.View.UserLogView"
  109. });
  110. InfoLog.Add(new SubMenumodel()
  111. {
  112. SubMenuName = "运行日志",
  113. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.观察员 },
  114. AssemblyName = "BPASmartClient.CustomResource",
  115. ToggleWindowPath = "Pages.View.RunLogView"
  116. });
  117. InfoLog.Add(new SubMenumodel()
  118. {
  119. SubMenuName = "报警记录",
  120. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.观察员 },
  121. AssemblyName = "BPASmartClient.CustomResource",
  122. ToggleWindowPath = "Pages.View.AlarmView"
  123. });
  124. InfoLog.Add(new SubMenumodel()
  125. {
  126. SubMenuName = "炒锅历史状态",
  127. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.观察员 },
  128. AssemblyName = "FryPot_DosingSystem",
  129. ToggleWindowPath = "View.SqliteDataView"
  130. });
  131. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  132. {
  133. MainMenuIcon = "&#xe668;",
  134. MainMenuName = "消息日志",
  135. Alias = "Message Log",
  136. MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 },
  137. subMenumodels = InfoLog,
  138. });
  139. #endregion
  140. #region 参数设置
  141. ObservableCollection<SubMenumodel> ParamSet = new ObservableCollection<SubMenumodel>();
  142. ParamSet.Add(new SubMenumodel()
  143. {
  144. SubMenuName = "PLC通讯设置",
  145. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  146. AssemblyName = "FryPot_DosingSystem",
  147. ToggleWindowPath = "View.DeviceListVIew"
  148. });
  149. ParamSet.Add(new SubMenumodel()
  150. {
  151. SubMenuName = "PLC变量配置",
  152. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  153. AssemblyName = "BPASmartClient.CustomResource",
  154. ToggleWindowPath = "Pages.View.VariableConfigView"
  155. });
  156. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  157. {
  158. MainMenuIcon = "&#xe603;",
  159. MainMenuName = "参数设置",
  160. Alias = "Parameters Set",
  161. MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 },
  162. subMenumodels = ParamSet,
  163. });
  164. #endregion
  165. #region 硬件设备监控
  166. ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
  167. //DeviceMonitor.Add(new SubMenumodel()
  168. //{
  169. // SubMenuName = "PLC通讯设置",
  170. // SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  171. // AssemblyName = "FryPot_DosingSystem",
  172. // ToggleWindowPath = "View.DeviceListVIew"
  173. //});
  174. //DeviceMonitor.Add(new SubMenumodel()
  175. //{
  176. // SubMenuName = "PLC变量配置",
  177. // SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  178. // AssemblyName = "BPASmartClient.CustomResource",
  179. // ToggleWindowPath = "Pages.View.VariableConfigView"
  180. //});
  181. DeviceMonitor.Add(new SubMenumodel()
  182. {
  183. SubMenuName = "滚筒线运行状态",
  184. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 },
  185. AssemblyName = "FryPot_DosingSystem",
  186. ToggleWindowPath = "View.HardWareStatusView"
  187. });
  188. DeviceMonitor.Add(new SubMenumodel()
  189. {
  190. SubMenuName = "炒锅状态数据监控",
  191. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 },
  192. AssemblyName = "FryPot_DosingSystem",
  193. ToggleWindowPath = "View.FryPotMonitorView"
  194. });
  195. DeviceMonitor.Add(new SubMenumodel()
  196. {
  197. SubMenuName = "AGV视图",
  198. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 },
  199. AssemblyName = "FryPot_DosingSystem",
  200. ToggleWindowPath = "View.AgvView"
  201. });
  202. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  203. {
  204. MainMenuIcon = "&#xe603;",
  205. MainMenuName = "设备监控",
  206. Alias = "Device Monitor",
  207. MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员, Permission.观察员 },
  208. subMenumodels = DeviceMonitor,
  209. });
  210. #endregion
  211. #region 用户管理
  212. ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>();
  213. UserManager.Add(new SubMenumodel()
  214. {
  215. SubMenuName = "用户登录",
  216. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员, Permission.观察员, Permission.操作员 },
  217. AssemblyName = "BPASmartClient.CustomResource",
  218. ToggleWindowPath = "Pages.View.SubPagLoginView"
  219. });
  220. UserManager.Add(new SubMenumodel()
  221. {
  222. SubMenuName = "密码修改",
  223. SubMenuPermission = new Permission[] { Permission.管理员 },
  224. AssemblyName = "BPASmartClient.CustomResource",
  225. ToggleWindowPath = "Pages.View.PasswordChangeView"
  226. });
  227. UserManager.Add(new SubMenumodel()
  228. {
  229. SubMenuName = "用户管理",
  230. SubMenuPermission = new Permission[] { Permission.管理员 },
  231. AssemblyName = "BPASmartClient.CustomResource",
  232. ToggleWindowPath = "Pages.View.UserManageView"
  233. });
  234. UserManager.Add(new SubMenumodel()
  235. {
  236. SubMenuName = "NFC登录设置",
  237. SubMenuPermission = new Permission[] { Permission.管理员 },
  238. AssemblyName = "BPASmartClient.CustomResource",
  239. ToggleWindowPath = "Pages.View.NfcSetView"
  240. });
  241. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  242. {
  243. MainMenuIcon = "&#xe66d;",
  244. MainMenuName = "用户管理",
  245. Alias = "User Management",
  246. MainMenuPermission = new Permission[] { Permission.管理员, Permission.技术员, Permission.观察员, Permission.操作员 },
  247. subMenumodels = UserManager,
  248. });
  249. #endregion
  250. #region 调试界面
  251. ObservableCollection<SubMenumodel> DebugManage = new ObservableCollection<SubMenumodel>();
  252. DebugManage.Add(new SubMenumodel()
  253. {
  254. SubMenuName = "单一流程调试",
  255. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  256. AssemblyName = "FryPot_DosingSystem",
  257. ToggleWindowPath = "View.DebugView"
  258. });
  259. #endregion
  260. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  261. {
  262. MainMenuIcon = "&#xe683;",
  263. MainMenuName = "调试界面",
  264. Alias = "Debug Management",
  265. MainMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  266. subMenumodels = DebugManage,
  267. });
  268. }
  269. private void LoginDataInite()
  270. {
  271. //Config.GetInstance.Init();//用户数据初始化
  272. Json<RecipeManage>.Read();
  273. }
  274. }
  275. }