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

356 строки
15 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. mv.TitleName = "自动化产线-小料站上位机控制系统";
  44. LoginView lv = new LoginView();
  45. var res = lv.ShowDialog();
  46. if (res != null && res == true)
  47. {
  48. MessageNotify.GetInstance.ShowUserLog("用户登录");
  49. mv.Show();
  50. }
  51. else
  52. mv.Close();
  53. MainWindow = mv;
  54. }
  55. private async void Init()
  56. {
  57. await Task.Run(new Action(() =>
  58. {
  59. DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化
  60. ProcessControl.GetInstance.Init();
  61. }));
  62. }
  63. protected override void OnExit(ExitEventArgs e)
  64. {
  65. base.OnExit(e);
  66. Json<LocaPar>.Save();
  67. Json<LocalRecipeDataColl>.Save();
  68. Json<RemoteRecipeDataColl>.Save();
  69. MessageNotify.GetInstance.LogSave();
  70. ThreadManage.GetInstance().Dispose();
  71. }
  72. private void MenuInit()
  73. {
  74. //NfcServer.GetInstance.Init();
  75. #region 配方管理菜单
  76. ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
  77. //RecipeManage.Add(new SubMenumodel()
  78. //{
  79. // SubMenuName = "味魔方配方管理",
  80. // SubMenuPermission = new Permission[] { Permission.管理员 },
  81. // AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  82. // ToggleWindowPath = "View.RecipeSettingsView"
  83. //});
  84. //RecipeManage.Add(new SubMenumodel()
  85. //{
  86. // SubMenuName = "味魔方配方下发",
  87. // SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员 },
  88. // AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  89. // ToggleWindowPath = "View.RecipeControlView"
  90. //});
  91. RecipeManage.Add(new SubMenumodel()
  92. {
  93. SubMenuName = "本地配方管理",
  94. SubMenuPermission = new Permission[] { Permission.管理员 },
  95. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  96. ToggleWindowPath = "View.RecipeReceiveView"
  97. });
  98. RecipeManage.Add(new SubMenumodel()
  99. {
  100. SubMenuName = "西门子配方管理",
  101. SubMenuPermission = new Permission[] { Permission.管理员 },
  102. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  103. ToggleWindowPath = "View.SiemensRecipeReceiveView"
  104. });
  105. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  106. {
  107. MainMenuIcon = "&#xe683;",
  108. MainMenuName = "配方管理",
  109. Alias = "Recipe Management",
  110. subMenumodels = RecipeManage,
  111. });
  112. #endregion
  113. #region 参数设置
  114. ObservableCollection<SubMenumodel> ParSet = new ObservableCollection<SubMenumodel>();
  115. ParSet.Add(new SubMenumodel()
  116. {
  117. SubMenuName = "味魔方参数设置",
  118. SubMenuPermission = new Permission[] { Permission.管理员 },
  119. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  120. ToggleWindowPath = "View.DeviceMaterialParView"
  121. });
  122. ParSet.Add(new SubMenumodel()
  123. {
  124. SubMenuName = "粉仓参数设置",
  125. SubMenuPermission = new Permission[] { Permission.管理员 },
  126. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  127. ToggleWindowPath = "View.WindSendParView"
  128. });
  129. ParSet.Add(new SubMenumodel()
  130. {
  131. SubMenuName = "系统参数设置",
  132. SubMenuPermission = new Permission[] { Permission.管理员 },
  133. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  134. ToggleWindowPath = "View.SystemParView"
  135. });
  136. ParSet.Add(new SubMenumodel()
  137. {
  138. SubMenuName = "原料与料仓管理",
  139. SubMenuPermission = new Permission[] { Permission.管理员 },
  140. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  141. ToggleWindowPath = "View.StockBinRawMaterialView"
  142. });
  143. ParSet.Add(new SubMenumodel()
  144. {
  145. SubMenuName = "西门子物料管理",
  146. SubMenuPermission = new Permission[] { Permission.管理员 },
  147. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  148. ToggleWindowPath = "View.BomOfMaterialView"
  149. });
  150. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  151. {
  152. MainMenuIcon = "&#xe62d;",
  153. MainMenuName = "参数设置",
  154. Alias = "Parameter Set",
  155. subMenumodels = ParSet,
  156. });
  157. #endregion
  158. #region 手动控制
  159. ObservableCollection<SubMenumodel> ManualControl = new ObservableCollection<SubMenumodel>();
  160. ManualControl.Add(new SubMenumodel()
  161. {
  162. SubMenuName = "手动控制硬件",
  163. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  164. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  165. ToggleWindowPath = "View.ManualControlView"
  166. });
  167. /*ManualControl.Add(new SubMenumodel()
  168. {
  169. SubMenuName = "手动控制信号",
  170. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  171. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  172. ToggleWindowPath = "View.ManualCommView"
  173. });*/
  174. ManualControl.Add(new SubMenumodel()
  175. {
  176. SubMenuName = "手动控制流程",
  177. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  178. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  179. ToggleWindowPath = "View.ManualFlowView"
  180. });
  181. ManualControl.Add(new SubMenumodel()
  182. {
  183. SubMenuName = "机器人设备控制",
  184. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  185. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  186. ToggleWindowPath = "View.RobotView"
  187. });
  188. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  189. {
  190. MainMenuIcon = "&#xe622;",
  191. MainMenuName = "手动控制",
  192. Alias = "Parameter Set",
  193. subMenumodels = ManualControl,
  194. });
  195. #endregion
  196. #region 消息日志
  197. ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>();
  198. InfoLog.Add(new SubMenumodel()
  199. {
  200. SubMenuName = "操作日志",
  201. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  202. AssemblyName = "BPASmartClient.CustomResource",
  203. ToggleWindowPath = "Pages.View.UserLogView"
  204. });
  205. InfoLog.Add(new SubMenumodel()
  206. {
  207. SubMenuName = "运行日志",
  208. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  209. AssemblyName = "BPASmartClient.CustomResource",
  210. ToggleWindowPath = "Pages.View.RunLogView"
  211. });
  212. InfoLog.Add(new SubMenumodel()
  213. {
  214. SubMenuName = "配方日志",
  215. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  216. AssemblyName = "BPASmartClient.CustomResource",
  217. ToggleWindowPath = "Pages.View.RecipeCompleteView"
  218. });
  219. InfoLog.Add(new SubMenumodel()
  220. {
  221. SubMenuName = "报警记录",
  222. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
  223. AssemblyName = "BPASmartClient.CustomResource",
  224. ToggleWindowPath = "Pages.View.AlarmView"
  225. });
  226. InfoLog.Add(new SubMenumodel()
  227. {
  228. SubMenuName = "调试日志",
  229. SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.技术员 },
  230. AssemblyName = "BPASmartClient.CustomResource",
  231. ToggleWindowPath = "Pages.View.DebugLogView"
  232. });
  233. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  234. {
  235. MainMenuIcon = "&#xe668;",
  236. MainMenuName = "消息日志",
  237. Alias = "Message Log",
  238. subMenumodels = InfoLog,
  239. });
  240. #endregion
  241. #region 硬件设备监控
  242. ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
  243. DeviceMonitor.Add(new SubMenumodel()
  244. {
  245. SubMenuName = "原料设备列表",
  246. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  247. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  248. ToggleWindowPath = "View.DeviceListView"
  249. });
  250. DeviceMonitor.Add(new SubMenumodel()
  251. {
  252. SubMenuName = "Plc变量监控",
  253. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  254. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  255. ToggleWindowPath = "View.PlcVarMonitorView"
  256. });
  257. DeviceMonitor.Add(new SubMenumodel()
  258. {
  259. SubMenuName = "流程变量监控",
  260. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  261. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  262. ToggleWindowPath = "View.ProcessMonitorView"
  263. });
  264. DeviceMonitor.Add(new SubMenumodel()
  265. {
  266. SubMenuName = "设备状态",
  267. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  268. AssemblyName = "BPASmartClient.JXJFoodSmallStation",
  269. ToggleWindowPath = "View.HardwareStatusView"
  270. });
  271. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  272. {
  273. MainMenuIcon = "&#xe603;",
  274. MainMenuName = "设备监控",
  275. Alias = "Device Monitor",
  276. subMenumodels = DeviceMonitor,
  277. });
  278. #endregion
  279. #region 用户管理
  280. ObservableCollection<SubMenumodel> UserManager = new ObservableCollection<SubMenumodel>();
  281. UserManager.Add(new SubMenumodel()
  282. {
  283. SubMenuName = "用户登录",
  284. SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
  285. AssemblyName = "BPASmartClient.CustomResource",
  286. ToggleWindowPath = "Pages.View.SubPagLoginView"
  287. });
  288. UserManager.Add(new SubMenumodel()
  289. {
  290. SubMenuName = "密码修改",
  291. SubMenuPermission = new Permission[] { Permission.管理员, Permission.技术员 },
  292. AssemblyName = "BPASmartClient.CustomResource",
  293. ToggleWindowPath = "Pages.View.PasswordChangeView"
  294. });
  295. UserManager.Add(new SubMenumodel()
  296. {
  297. SubMenuName = "用户管理",
  298. SubMenuPermission = new Permission[] { Permission.管理员 },
  299. AssemblyName = "BPASmartClient.CustomResource",
  300. ToggleWindowPath = "Pages.View.UserManagerView"
  301. });
  302. /* UserManager.Add(new SubMenumodel()
  303. {
  304. SubMenuName = "NFC登录设置",
  305. SubMenuPermission = new Permission[] { Permission.管理员 },
  306. AssemblyName = "BPASmartClient.CustomResource",
  307. ToggleWindowPath = "Pages.View.NfcSetView"
  308. });*/
  309. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  310. {
  311. MainMenuIcon = "&#xe66d;",
  312. MainMenuName = "用户管理",
  313. Alias = "User Management",
  314. subMenumodels = UserManager,
  315. });
  316. #endregion
  317. }
  318. private void DataInit()
  319. {
  320. //Config.GetInstance.Init();
  321. Json<LocaPar>.Read();
  322. Json<DevicePar>.Read();
  323. Json<WindSendDevicePar>.Read();
  324. Json<LocalRecipeDataColl>.Read();
  325. Json<RemoteRecipeDataColl>.Read();
  326. }
  327. }
  328. }