终端一体化运控平台
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

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