终端一体化运控平台
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

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