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

App.xaml.cs 13 KiB

2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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 BPA.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. Task.Run(()=> { 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.技术员 },
  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. }