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

336 regels
14 KiB

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