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

325 рядки
13 KiB

  1. using BPASmartClient.JXJFoodSmallStation.Model;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Collections.ObjectModel;
  5. using System.Configuration;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using BPASmartClient.CustomResource.Pages.Enums;
  11. using BPASmartClient.CustomResource.Pages.Model;
  12. using BPASmartClient.CustomResource.Pages.View;
  13. using BPASmartClient.CustomResource.Pages.ViewModel;
  14. using BPASmartClient.Helper;
  15. using BPASmartClient.JXJFoodSmallStation.Model.Siemens;
  16. using BPASmartClient.JXJFoodSmallStation.Model.WindSend;
  17. using System.Threading;
  18. namespace BPASmartClient.JXJFoodSmallStation
  19. {
  20. /// <summary>
  21. /// Interaction logic for App.xaml
  22. /// </summary>
  23. public partial class App : Application
  24. {
  25. public static Window MainWindow;
  26. public EventWaitHandle ProgramStarted { get; set; }
  27. protected override void OnStartup(StartupEventArgs e)
  28. {
  29. bool createNew;
  30. ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "SmallStationApp", out createNew);
  31. if (!createNew)
  32. {
  33. MessageBox.Show("程序已启动");
  34. App.Current.Shutdown();
  35. Environment.Exit(0);
  36. }
  37. BPASmartClient.Helper.SystemHelper.GetInstance.CreateDesktopShortcut();
  38. base.OnStartup(e);
  39. MenuInit();
  40. DataInit();
  41. Init();
  42. MainView mv = new MainView();
  43. LoginView lv = new LoginView();
  44. var res = lv.ShowDialog();
  45. if (res != null && res == true)
  46. {
  47. MessageNotify.GetInstance.ShowUserLog("用户登录");
  48. mv.Show();
  49. }
  50. else
  51. mv.Close();
  52. MainWindow = mv;
  53. }
  54. private async void Init()
  55. {
  56. await Task.Run(new Action(() =>
  57. {
  58. DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化
  59. ProcessControl.GetInstance.Init();
  60. }));
  61. }
  62. protected override void OnExit(ExitEventArgs e)
  63. {
  64. base.OnExit(e);
  65. Json<LocaPar>.Save();
  66. Json<LocalRecipeDataColl>.Save();
  67. Json<RemoteRecipeDataColl>.Save();
  68. MessageNotify.GetInstance.LogSave();
  69. ThreadManage.GetInstance().Dispose();
  70. }
  71. private void MenuInit()
  72. {
  73. //NfcServer.GetInstance.Init();
  74. #region 配方管理菜单
  75. ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
  76. RecipeManage.Add(new SubMenumodel()
  77. {
  78. SubMenuName = "味魔方配方管理",
  79. SubMenuPermission = new Permission[] { Permission.管理员 },
  80. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  81. ToggleWindowPath = "View.RecipeSettingsView"
  82. });
  83. RecipeManage.Add(new SubMenumodel()
  84. {
  85. SubMenuName = "味魔方配方下发",
  86. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员 },
  87. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  88. ToggleWindowPath = "View.RecipeControlView"
  89. });
  90. RecipeManage.Add(new SubMenumodel()
  91. {
  92. SubMenuName = "本地配方管理",
  93. SubMenuPermission = new Permission[] { Permission.管理员 },
  94. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  95. ToggleWindowPath = "View.RecipeReceiveView"
  96. });
  97. RecipeManage.Add(new SubMenumodel()
  98. {
  99. SubMenuName = "西门子配方管理",
  100. SubMenuPermission = new Permission[] { Permission.管理员 },
  101. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  102. ToggleWindowPath = "View.SiemensRecipeReceiveView"
  103. });
  104. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  105. {
  106. MainMenuIcon = "&#xe683;",
  107. MainMenuName = "配方管理",
  108. Alias = "Recipe Management",
  109. subMenumodels = RecipeManage,
  110. });
  111. #endregion
  112. #region 参数设置
  113. ObservableCollection<SubMenumodel> ParSet = new ObservableCollection<SubMenumodel>();
  114. ParSet.Add(new SubMenumodel()
  115. {
  116. SubMenuName = "柔性味魔方参数设置",
  117. SubMenuPermission = new Permission[] { Permission.管理员 },
  118. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  119. ToggleWindowPath = "View.DeviceMaterialParView"
  120. });
  121. ParSet.Add(new SubMenumodel()
  122. {
  123. SubMenuName = "粉仓参数设置",
  124. SubMenuPermission = new Permission[] { Permission.管理员 },
  125. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  126. ToggleWindowPath = "View.WindSendParView"
  127. });
  128. ParSet.Add(new SubMenumodel()
  129. {
  130. SubMenuName = "系统参数设置",
  131. SubMenuPermission = new Permission[] { Permission.管理员 },
  132. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  133. ToggleWindowPath = "View.SystemParView"
  134. });
  135. ParSet.Add(new SubMenumodel()
  136. {
  137. SubMenuName = "原料与料仓对应设置",
  138. SubMenuPermission = new Permission[] { Permission.管理员 },
  139. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  140. ToggleWindowPath = "View.StockBinRawMaterialView"
  141. });
  142. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  143. {
  144. MainMenuIcon = "&#xe62d;",
  145. MainMenuName = "参数设置",
  146. Alias = "Parameter Set",
  147. subMenumodels = ParSet,
  148. });
  149. #endregion
  150. #region 手动控制
  151. ObservableCollection<SubMenumodel> ManualControl = new ObservableCollection<SubMenumodel>();
  152. ManualControl.Add(new SubMenumodel()
  153. {
  154. SubMenuName = "手动控制硬件",
  155. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  156. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  157. ToggleWindowPath = "View.ManualControlView"
  158. });
  159. /*ManualControl.Add(new SubMenumodel()
  160. {
  161. SubMenuName = "手动控制信号",
  162. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  163. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  164. ToggleWindowPath = "View.ManualCommView"
  165. });*/
  166. ManualControl.Add(new SubMenumodel()
  167. {
  168. SubMenuName = "手动控制流程",
  169. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  170. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  171. ToggleWindowPath = "View.ManualFlowView"
  172. });
  173. ManualControl.Add(new SubMenumodel()
  174. {
  175. SubMenuName = "机器人设备控制",
  176. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  177. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  178. ToggleWindowPath = "View.RobotView"
  179. });
  180. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  181. {
  182. MainMenuIcon = "&#xe622;",
  183. MainMenuName = "手动控制",
  184. Alias = "Parameter Set",
  185. subMenumodels = ManualControl,
  186. });
  187. #endregion
  188. #region 消息日志
  189. ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>();
  190. InfoLog.Add(new SubMenumodel()
  191. {
  192. SubMenuName = "操作日志",
  193. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  194. AssemblyName = "BPASmartClient.CustomResource",
  195. ToggleWindowPath = "Pages.View.UserLogView"
  196. });
  197. InfoLog.Add(new SubMenumodel()
  198. {
  199. SubMenuName = "运行日志",
  200. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  201. AssemblyName = "BPASmartClient.CustomResource",
  202. ToggleWindowPath = "Pages.View.RunLogView"
  203. });
  204. InfoLog.Add(new SubMenumodel()
  205. {
  206. SubMenuName = "报警记录",
  207. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  208. AssemblyName = "BPASmartClient.CustomResource",
  209. ToggleWindowPath = "Pages.View.AlarmView"
  210. });
  211. InfoLog.Add(new SubMenumodel()
  212. {
  213. SubMenuName = "调试日志",
  214. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.技术员 },
  215. AssemblyName = "BPASmartClient.CustomResource",
  216. ToggleWindowPath = "Pages.View.DebugLogView"
  217. });
  218. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  219. {
  220. MainMenuIcon = "&#xe668;",
  221. MainMenuName = "消息日志",
  222. Alias = "Message Log",
  223. subMenumodels = InfoLog,
  224. });
  225. #endregion
  226. #region 硬件设备监控
  227. ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
  228. DeviceMonitor.Add(new SubMenumodel()
  229. {
  230. SubMenuName = "原料设备列表",
  231. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  232. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  233. ToggleWindowPath = "View.DeviceListView"
  234. });
  235. DeviceMonitor.Add(new SubMenumodel()
  236. {
  237. SubMenuName = "设备状态",
  238. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  239. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  240. ToggleWindowPath = "View.HardwareStatusView"
  241. });
  242. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  243. {
  244. MainMenuIcon = "&#xe603;",
  245. MainMenuName = "设备监控",
  246. Alias = "Device Monitor",
  247. subMenumodels = DeviceMonitor,
  248. });
  249. #endregion
  250. #region 用户管理
  251. ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>();
  252. UserManager.Add(new SubMenumodel()
  253. {
  254. SubMenuName = "用户登录",
  255. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  256. AssemblyName = "BPASmartClient.CustomResource",
  257. ToggleWindowPath = "Pages.View.SubPagLoginView"
  258. });
  259. UserManager.Add(new SubMenumodel()
  260. {
  261. SubMenuName = "密码修改",
  262. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  263. AssemblyName = "BPASmartClient.CustomResource",
  264. ToggleWindowPath = "Pages.View.PasswordChangeView"
  265. });
  266. UserManager.Add(new SubMenumodel()
  267. {
  268. SubMenuName = "用户管理",
  269. SubMenuPermission = new Permission[] { Permission.管理员 },
  270. AssemblyName = "BPASmartClient.CustomResource",
  271. ToggleWindowPath = "Pages.View.UserManagerView"
  272. });
  273. /* UserManager.Add(new SubMenumodel()
  274. {
  275. SubMenuName = "NFC登录设置",
  276. SubMenuPermission = new Permission[] { Permission.管理员 },
  277. AssemblyName = "BPASmartClient.CustomResource",
  278. ToggleWindowPath = "Pages.View.NfcSetView"
  279. });*/
  280. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  281. {
  282. MainMenuIcon = "&#xe66d;",
  283. MainMenuName = "用户管理",
  284. Alias = "User Management",
  285. subMenumodels = UserManager,
  286. });
  287. #endregion
  288. }
  289. private void DataInit()
  290. {
  291. //Config.GetInstance.Init();
  292. Json<LocaPar>.Read();
  293. Json<DevicePar>.Read();
  294. Json<WindSendDevicePar>.Read();
  295. Json<LocalRecipeDataColl>.Read();
  296. Json<RemoteRecipeDataColl>.Read();
  297. }
  298. }
  299. }