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

355 rivejä
14 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. ParSet.Add(new SubMenumodel()
  143. {
  144. SubMenuName = "西门子物料管理",
  145. SubMenuPermission = new Permission[] { Permission.管理员 },
  146. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  147. ToggleWindowPath = "View.BomOfMaterialView"
  148. });
  149. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  150. {
  151. MainMenuIcon = "&#xe62d;",
  152. MainMenuName = "参数设置",
  153. Alias = "Parameter Set",
  154. subMenumodels = ParSet,
  155. });
  156. #endregion
  157. #region 手动控制
  158. ObservableCollection<SubMenumodel> ManualControl = new ObservableCollection<SubMenumodel>();
  159. ManualControl.Add(new SubMenumodel()
  160. {
  161. SubMenuName = "手动控制硬件",
  162. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  163. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  164. ToggleWindowPath = "View.ManualControlView"
  165. });
  166. /*ManualControl.Add(new SubMenumodel()
  167. {
  168. SubMenuName = "手动控制信号",
  169. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  170. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  171. ToggleWindowPath = "View.ManualCommView"
  172. });*/
  173. ManualControl.Add(new SubMenumodel()
  174. {
  175. SubMenuName = "手动控制流程",
  176. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  177. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  178. ToggleWindowPath = "View.ManualFlowView"
  179. });
  180. ManualControl.Add(new SubMenumodel()
  181. {
  182. SubMenuName = "机器人设备控制",
  183. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  184. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  185. ToggleWindowPath = "View.RobotView"
  186. });
  187. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  188. {
  189. MainMenuIcon = "&#xe622;",
  190. MainMenuName = "手动控制",
  191. Alias = "Parameter Set",
  192. subMenumodels = ManualControl,
  193. });
  194. #endregion
  195. #region 消息日志
  196. ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>();
  197. InfoLog.Add(new SubMenumodel()
  198. {
  199. SubMenuName = "操作日志",
  200. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  201. AssemblyName = "BPASmartClient.CustomResource",
  202. ToggleWindowPath = "Pages.View.UserLogView"
  203. });
  204. InfoLog.Add(new SubMenumodel()
  205. {
  206. SubMenuName = "运行日志",
  207. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  208. AssemblyName = "BPASmartClient.CustomResource",
  209. ToggleWindowPath = "Pages.View.RunLogView"
  210. });
  211. InfoLog.Add(new SubMenumodel()
  212. {
  213. SubMenuName = "配方日志",
  214. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  215. AssemblyName = "BPASmartClient.CustomResource",
  216. ToggleWindowPath = "Pages.View.RecipeCompleteView"
  217. });
  218. InfoLog.Add(new SubMenumodel()
  219. {
  220. SubMenuName = "报警记录",
  221. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  222. AssemblyName = "BPASmartClient.CustomResource",
  223. ToggleWindowPath = "Pages.View.AlarmView"
  224. });
  225. InfoLog.Add(new SubMenumodel()
  226. {
  227. SubMenuName = "调试日志",
  228. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.技术员 },
  229. AssemblyName = "BPASmartClient.CustomResource",
  230. ToggleWindowPath = "Pages.View.DebugLogView"
  231. });
  232. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  233. {
  234. MainMenuIcon = "&#xe668;",
  235. MainMenuName = "消息日志",
  236. Alias = "Message Log",
  237. subMenumodels = InfoLog,
  238. });
  239. #endregion
  240. #region 硬件设备监控
  241. ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
  242. DeviceMonitor.Add(new SubMenumodel()
  243. {
  244. SubMenuName = "原料设备列表",
  245. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  246. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  247. ToggleWindowPath = "View.DeviceListView"
  248. });
  249. DeviceMonitor.Add(new SubMenumodel()
  250. {
  251. SubMenuName = "Plc变量监控",
  252. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  253. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  254. ToggleWindowPath = "View.PlcVarMonitorView"
  255. });
  256. DeviceMonitor.Add(new SubMenumodel()
  257. {
  258. SubMenuName = "流程变量监控",
  259. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  260. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  261. ToggleWindowPath = "View.ProcessMonitorView"
  262. });
  263. DeviceMonitor.Add(new SubMenumodel()
  264. {
  265. SubMenuName = "设备状态",
  266. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  267. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  268. ToggleWindowPath = "View.HardwareStatusView"
  269. });
  270. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  271. {
  272. MainMenuIcon = "&#xe603;",
  273. MainMenuName = "设备监控",
  274. Alias = "Device Monitor",
  275. subMenumodels = DeviceMonitor,
  276. });
  277. #endregion
  278. #region 用户管理
  279. ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>();
  280. UserManager.Add(new SubMenumodel()
  281. {
  282. SubMenuName = "用户登录",
  283. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  284. AssemblyName = "BPASmartClient.CustomResource",
  285. ToggleWindowPath = "Pages.View.SubPagLoginView"
  286. });
  287. UserManager.Add(new SubMenumodel()
  288. {
  289. SubMenuName = "密码修改",
  290. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  291. AssemblyName = "BPASmartClient.CustomResource",
  292. ToggleWindowPath = "Pages.View.PasswordChangeView"
  293. });
  294. UserManager.Add(new SubMenumodel()
  295. {
  296. SubMenuName = "用户管理",
  297. SubMenuPermission = new Permission[] { Permission.管理员 },
  298. AssemblyName = "BPASmartClient.CustomResource",
  299. ToggleWindowPath = "Pages.View.UserManagerView"
  300. });
  301. /* UserManager.Add(new SubMenumodel()
  302. {
  303. SubMenuName = "NFC登录设置",
  304. SubMenuPermission = new Permission[] { Permission.管理员 },
  305. AssemblyName = "BPASmartClient.CustomResource",
  306. ToggleWindowPath = "Pages.View.NfcSetView"
  307. });*/
  308. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  309. {
  310. MainMenuIcon = "&#xe66d;",
  311. MainMenuName = "用户管理",
  312. Alias = "User Management",
  313. subMenumodels = UserManager,
  314. });
  315. #endregion
  316. }
  317. private void DataInit()
  318. {
  319. //Config.GetInstance.Init();
  320. Json<LocaPar>.Read();
  321. Json<DevicePar>.Read();
  322. Json<WindSendDevicePar>.Read();
  323. Json<LocalRecipeDataColl>.Read();
  324. Json<RemoteRecipeDataColl>.Read();
  325. }
  326. }
  327. }