终端一体化运控平台
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

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