SettingViewModel.cs 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217
  1. using ICSharpCode.AvalonEdit.Search;
  2. using MaterialDesignThemes.Wpf;
  3. using NPOI.SS.Formula.Functions;
  4. using Opc.Ua;
  5. using Prism.Commands;
  6. using Prism.Events;
  7. using Prism.Ioc;
  8. using Prism.Mvvm;
  9. using Prism.Regions;
  10. using Prism.Services.Dialogs;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Collections.ObjectModel;
  14. using System.ComponentModel;
  15. using System.Globalization;
  16. using System.Linq;
  17. using System.Text;
  18. using System.Windows;
  19. using Team.FFFeederService.Interfaces;
  20. using TeamAAS_VP.Controls;
  21. using TeamAAS_VP.Core;
  22. using TeamAAS_VP.Core.Cameras;
  23. using TeamAAS_VP.Core.Lights;
  24. using TeamAAS_VP.Enums;
  25. using TeamAAS_VP.Events;
  26. using TeamAAS_VP.Interfaces;
  27. using TeamAAS_VP.Models;
  28. using TeamAAS_VP.Models.Lights;
  29. using TeamAAS_VP.Resources.Languages;
  30. using TeamAAS_VP.Services;
  31. using TeamAAS_VP.ViewModels.User;
  32. using TouchSocket.Core;
  33. using WPFLocalizeExtension.Engine;
  34. namespace TeamAAS_VP.ViewModels
  35. {
  36. public class SettingViewModel : BindableBase, IConfirmNavigationRequest
  37. {
  38. IRegionManager _regionManager;
  39. IEventAggregator _eventAggregator;
  40. IContainerProvider _container;
  41. IDialogService _dialogService;
  42. IConfigService _configService;
  43. IRobotService _robotService;
  44. ICameraService _cameraService;
  45. IFeederService _feeder_service;
  46. IFeederService _feederService;
  47. IPlcService _plcService;
  48. IProductService _productService;
  49. ISystemDatabaseService _systemDatabaseService;
  50. bool isFirstLoad = true;
  51. #region 属性
  52. private Management _management;
  53. public Management management
  54. {
  55. get { return _management; }
  56. set { SetProperty(ref _management, value); }
  57. }
  58. private ObservableCollection<RobotInfo> _RobotList;
  59. public ObservableCollection<RobotInfo> RobotList
  60. {
  61. get { return _RobotList; }
  62. set { SetProperty(ref _RobotList, value); }
  63. }
  64. private ObservableCollection<CameraInfo> _CameraList;
  65. public ObservableCollection<CameraInfo> CameraList
  66. {
  67. get { return _CameraList; }
  68. set { SetProperty(ref _CameraList, value); }
  69. }
  70. private ObservableCollection<FeederInfo> _FeederList;
  71. public ObservableCollection<FeederInfo> FeederList
  72. {
  73. get { return _FeederList; }
  74. set { SetProperty(ref _FeederList, value); }
  75. }
  76. private ObservableCollection<PlcInfo> _PlcList;
  77. public ObservableCollection<PlcInfo> PlcList
  78. {
  79. get { return _PlcList; }
  80. set { SetProperty(ref _PlcList, value); }
  81. }
  82. private Language _CurrentLanguage;
  83. public Language CurrentLanguage
  84. {
  85. get { return _CurrentLanguage; }
  86. set { SetProperty(ref _CurrentLanguage, value); }
  87. }
  88. private RobotInfo _SelectRobot;
  89. /// <summary>
  90. /// 选中的机器人
  91. /// </summary>
  92. public RobotInfo SelectRobot
  93. {
  94. get { return _SelectRobot; }
  95. set
  96. {
  97. SetProperty(ref _SelectRobot, value);
  98. if (value != null && (value.RobotBrand == RobotBrand.XYZ_Platform || value.RobotBrand == RobotBrand.XYZU_Platform))
  99. {
  100. RobotSelectedPlc = PlcList.FirstOrDefault(p => p.Id == value.PLC);
  101. var root = _robotService.GetRobot(SelectRobot.Id);
  102. if (root != null)
  103. {
  104. //ResultsValues.Clear();
  105. //var res = root.GetNodesValue();
  106. //for (int i = 0; i < res.Count; i++)
  107. //{
  108. // if (res[i].StatusCode.Code != 2150891520)
  109. // {
  110. // ResultsValues.Add(res[i].Value.ToString());
  111. // }
  112. // else
  113. // {
  114. // break;
  115. // }
  116. //}
  117. }
  118. }
  119. }
  120. }
  121. private FeederInfo _SelectFeeder;
  122. /// <summary>
  123. /// 选中的Feeder
  124. /// </summary>
  125. public FeederInfo SelectFeeder
  126. {
  127. get { return _SelectFeeder; }
  128. set { SetProperty(ref _SelectFeeder, value); }
  129. }
  130. private PlcInfo _SelectPlc;
  131. public PlcInfo SelectPlc
  132. {
  133. get { return _SelectPlc; }
  134. set { SetProperty(ref _SelectPlc, value); }
  135. }
  136. private ObservableCollection<string> _ResultsValues = new ObservableCollection<string>();
  137. public ObservableCollection<string> ResultsValues { get => _ResultsValues; set => _ResultsValues = value; }
  138. private CameraInfo _SelectCamera;
  139. /// <summary>
  140. /// 选中的Camera
  141. /// </summary>
  142. public CameraInfo SelectCamera
  143. {
  144. get { return _SelectCamera; }
  145. set { SetProperty(ref _SelectCamera, value); }
  146. }
  147. private double _Title1;
  148. public double Title1
  149. {
  150. get { return _Title1; }
  151. set { SetProperty(ref _Title1, value); }
  152. }
  153. private double _Title2;
  154. public double Title2
  155. {
  156. get { return _Title2; }
  157. set { SetProperty(ref _Title2, value); }
  158. }
  159. private double _Title3;
  160. public double Title3
  161. {
  162. get { return _Title3; }
  163. set { SetProperty(ref _Title3, value); }
  164. }
  165. private double _Title4;
  166. public double Title4
  167. {
  168. get { return _Title4; }
  169. set { SetProperty(ref _Title4, value); }
  170. }
  171. private double _Body1;
  172. public double Body1
  173. {
  174. get { return _Body1; }
  175. set { SetProperty(ref _Body1, value); }
  176. }
  177. private double _Body2;
  178. public double Body2
  179. {
  180. get { return _Body2; }
  181. set { SetProperty(ref _Body2, value); }
  182. }
  183. private double _Body3;
  184. public double Body3
  185. {
  186. get { return _Body3; }
  187. set { SetProperty(ref _Body3, value); }
  188. }
  189. private double _Body4;
  190. public double Body4
  191. {
  192. get { return _Body4; }
  193. set { SetProperty(ref _Body4, value); }
  194. }
  195. private double _Captions1;
  196. public double Captions1
  197. {
  198. get { return _Captions1; }
  199. set { SetProperty(ref _Captions1, value); }
  200. }
  201. private double _Captions2;
  202. public double Captions2
  203. {
  204. get { return _Captions2; }
  205. set { SetProperty(ref _Captions2, value); }
  206. }
  207. private double _Captions3;
  208. public double Captions3
  209. {
  210. get { return _Captions3; }
  211. set { SetProperty(ref _Captions3, value); }
  212. }
  213. private double _Captions4;
  214. public double Captions4
  215. {
  216. get { return _Captions4; }
  217. set { SetProperty(ref _Captions4, value); }
  218. }
  219. private PlcInfo _RobotSelectedPlc;
  220. public PlcInfo RobotSelectedPlc
  221. {
  222. get { return _RobotSelectedPlc; }
  223. set
  224. {
  225. SetProperty(ref _RobotSelectedPlc, value);
  226. if (SelectRobot != null)
  227. {
  228. if (value != null)
  229. {
  230. SelectRobot.PLC = value.Id;
  231. }
  232. else
  233. {
  234. SelectRobot.PLC = Guid.Empty;
  235. }
  236. }
  237. }
  238. }
  239. private BgModbusTcp _BgModbus;
  240. public BgModbusTcp BgModbus
  241. {
  242. get { return _BgModbus; }
  243. set { SetProperty(ref _BgModbus, value); }
  244. }
  245. private BgTcpIP _BgTcp;
  246. public BgTcpIP BgTcp
  247. {
  248. get { return _BgTcp; }
  249. set { SetProperty(ref _BgTcp, value); }
  250. }
  251. private ObservableCollection<LightControllerConfig> _LightControllerList;
  252. public ObservableCollection<LightControllerConfig> LightControllerList
  253. {
  254. get { return _LightControllerList; }
  255. set { SetProperty(ref _LightControllerList, value); }
  256. }
  257. private LightControllerConfig _SelectLightController;
  258. public LightControllerConfig SelectLightController
  259. {
  260. get { return _SelectLightController; }
  261. set { SetProperty(ref _SelectLightController, value); }
  262. }
  263. #endregion
  264. #region 命令
  265. public DelegateCommand LoadedCommand { get; set; }
  266. private DelegateCommand _AddRobotCommand;
  267. public DelegateCommand AddRobotCommand =>
  268. _AddRobotCommand ?? (_AddRobotCommand = new DelegateCommand(ExecuteAddRobotCommand));
  269. private DelegateCommand _RemoveCommand;
  270. public DelegateCommand RemoveCommand =>
  271. _RemoveCommand ?? (_RemoveCommand = new DelegateCommand(ExecuteRemoveCommand));
  272. private DelegateCommand _AddFeederCommand;
  273. public DelegateCommand AddFeederCommand =>
  274. _AddFeederCommand ?? (_AddFeederCommand = new DelegateCommand(ExecuteAddFeederCommand));
  275. private DelegateCommand _RemoveFeederCommand;
  276. public DelegateCommand RemoveFeederCommand =>
  277. _RemoveFeederCommand ?? (_RemoveFeederCommand = new DelegateCommand(ExecuteRemoveFeederCommand));
  278. private DelegateCommand<string> _SelectLanguageCommand;
  279. public DelegateCommand<string> SelectLanguageCommand =>
  280. _SelectLanguageCommand ?? (_SelectLanguageCommand = new DelegateCommand<string>(ExecuteSelectLanguageCommand));
  281. private DelegateCommand _SaveRobotsCommand;
  282. public DelegateCommand SaveRobotsCommand =>
  283. _SaveRobotsCommand ?? (_SaveRobotsCommand = new DelegateCommand(ExecuteSaveRobotsCommand));
  284. private DelegateCommand _SaveFeedersCommand;
  285. public DelegateCommand SaveFeedersCommand =>
  286. _SaveFeedersCommand ?? (_SaveFeedersCommand = new DelegateCommand(ExecuteSaveFeedersCommand));
  287. private DelegateCommand<string> _SaveCommunicateCommand;
  288. public DelegateCommand<string> SaveCommunicateCommand =>
  289. _SaveCommunicateCommand ?? (_SaveCommunicateCommand = new DelegateCommand<string>(ExecuteSaveCommunicateCommand));
  290. private DelegateCommand _AddCameraCommand;
  291. public DelegateCommand AddCameraCommand =>
  292. _AddCameraCommand ?? (_AddCameraCommand = new DelegateCommand(ExecuteAddCameraCommand));
  293. private DelegateCommand _EditCameraCommand;
  294. public DelegateCommand EditCameraCommand =>
  295. _EditCameraCommand ?? (_EditCameraCommand = new DelegateCommand(ExecuteEditCameraCommand));
  296. private DelegateCommand _RemoveCameraCommand;
  297. public DelegateCommand RemoveCameraCommand =>
  298. _RemoveCameraCommand ?? (_RemoveCameraCommand = new DelegateCommand(ExecuteRemoveCameraCommand));
  299. private DelegateCommand _SaveCamerasCommand;
  300. public DelegateCommand SaveCamerasCommand =>
  301. _SaveCamerasCommand ?? (_SaveCamerasCommand = new DelegateCommand(ExecuteSaveCamerasCommand));
  302. private DelegateCommand _AddPlcCommand;
  303. public DelegateCommand AddPlcCommand =>
  304. _AddPlcCommand ?? (_AddPlcCommand = new DelegateCommand(ExecuteAddPlcCommand));
  305. private DelegateCommand _RemovePlcCommand;
  306. public DelegateCommand RemovePlcCommand =>
  307. _RemovePlcCommand ?? (_RemovePlcCommand = new DelegateCommand(ExecuteRemovePlcCommand));
  308. private DelegateCommand _SavePlcsCommand;
  309. public DelegateCommand SavePlcsCommand =>
  310. _SavePlcsCommand ?? (_SavePlcsCommand = new DelegateCommand(ExecuteSavePlcsCommand));
  311. private DelegateCommand _AddLightControllerCommand;
  312. public DelegateCommand AddLightControllerCommand => _AddLightControllerCommand ?? (_AddLightControllerCommand = new DelegateCommand(ExecuteAddLightControllerCommand));
  313. private DelegateCommand _RemoveLightControllerCommand;
  314. public DelegateCommand RemoveLightControllerCommand => _RemoveLightControllerCommand ?? (_RemoveLightControllerCommand = new DelegateCommand(ExecuteRemoveLightControllerCommand));
  315. private DelegateCommand _SaveLightControllersCommand;
  316. public DelegateCommand SaveLightControllersCommand => _SaveLightControllersCommand ?? (_SaveLightControllersCommand = new DelegateCommand(ExecuteSaveLightControllersCommand));
  317. #endregion
  318. #region 事件
  319. #endregion
  320. public SettingViewModel(IRegionManager regionManager, IEventAggregator ea, IContainerProvider container, IDialogService dialogService,
  321. IConfigService configService, IRobotService robotService, ICameraService cameraService, IFeederService feederService, IPlcService plcService,
  322. IProductService productService, ISystemDatabaseService systemDatabaseService)
  323. {
  324. _regionManager = regionManager;
  325. _eventAggregator = ea;
  326. _container = container;
  327. _dialogService = dialogService;
  328. _configService = configService;
  329. _robotService = robotService;
  330. _cameraService = cameraService;
  331. _feederService = feederService;
  332. _plcService = plcService;
  333. _productService = productService;
  334. _systemDatabaseService = systemDatabaseService;
  335. management = _container.Resolve<Management>();
  336. LoadedCommand = new DelegateCommand(OnLoad);
  337. //订阅权限登录事件
  338. _eventAggregator.GetEvent<UserLoginNotification>().Subscribe(LoginChange);
  339. }
  340. #region 方法
  341. #region 机器人
  342. private void ExecuteAddRobotCommand()
  343. {
  344. _dialogService.ShowDialog("AddRobot", rst =>
  345. {
  346. //对话框关闭之后的回调函数,可以在这解析结果。
  347. ButtonResult result1 = rst.Result;
  348. if (result1 == ButtonResult.OK)
  349. {
  350. var param = rst.Parameters.GetValue<RobotInfo>("Robot");
  351. var robot = new RobotInfo()
  352. {
  353. Id = param.Id,
  354. RobotName = param.RobotName,
  355. ConnectType = param.ConnectType,
  356. RobotBrand = param.RobotBrand,
  357. IP = param.IP,
  358. Port = param.Port,
  359. Terminator = param.Terminator,
  360. };
  361. RobotList.Add(robot);
  362. _configService.AddOrUpdateRobot(robot);
  363. _robotService.CreateRobot(robot.Id, robot);
  364. //对所有产品也进行添加
  365. _productService.AddRobotPointToProduct(robot.Id, robot.RobotName);
  366. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = $"{Lang.添加完成}", Duration = 1 });
  367. }
  368. });
  369. }
  370. void ExecuteRemoveCommand()
  371. {
  372. if (MessageBox.Show(Lang.是否移除机器人, $"AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  373. {
  374. // 找到要删除的机器人
  375. var robotToRemove = RobotList.FirstOrDefault(r => r.Id == SelectRobot.Id);
  376. if (robotToRemove != null)
  377. {
  378. RobotList.Remove(robotToRemove);
  379. _configService.RemoveRobot(robotToRemove.Id);
  380. _robotService.RemoveRobot(robotToRemove.Id);
  381. //对所有产品也进行移除
  382. _productService.RemoveRobotPointFromProduct(robotToRemove.Id);
  383. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.移除完成, Duration = 1 });
  384. }
  385. }
  386. }
  387. async void ExecuteSaveRobotsCommand()
  388. {
  389. var view = new ShowMessage($"AAS", Lang.是否保存机器人);
  390. //show the dialog
  391. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  392. if (result != null && result is bool)
  393. {
  394. if (((bool)result))
  395. {
  396. foreach (var item in RobotList)
  397. {
  398. _configService.AddOrUpdateRobot(item);
  399. }
  400. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  401. }
  402. }
  403. }
  404. #endregion
  405. #region 相机
  406. /// <summary>
  407. /// 保存所有相机
  408. /// </summary>
  409. async void ExecuteSaveCamerasCommand()
  410. {
  411. var view = new ShowMessage($"AAS", Lang.是否保存相机配置);
  412. //show the dialog
  413. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  414. if (result != null && result is bool)
  415. {
  416. if (((bool)result))
  417. {
  418. //management.DeviceConfig.Cameras = DeviceConfig.Cameras;
  419. //management.SaveCamerasDeviceConfig();
  420. //management.DeviceConfig.Cameras = DeviceConfig.Cameras;
  421. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  422. }
  423. }
  424. }
  425. /// <summary>
  426. /// 移除相机
  427. /// </summary>
  428. void ExecuteRemoveCameraCommand()
  429. {
  430. if (MessageBox.Show(Lang.是否移除相机, $"AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  431. {
  432. // 找到要删除的相机
  433. var cameraToRemove = CameraList.FirstOrDefault(r => r.Id == SelectCamera.Id);
  434. if (cameraToRemove != null)
  435. {
  436. _configService.RemoveCamera(cameraToRemove.Id);
  437. _cameraService.RemoveCamera(cameraToRemove.Id);
  438. var root = _configService.GetAllCameras();
  439. CameraList = new ObservableCollection<CameraInfo>(root);
  440. foreach (var item in CameraList)
  441. {
  442. _cameraService.UpdateCameraNumber(item.Id, item.CameraNo);
  443. }
  444. //对所有产品也进行移除
  445. _productService.RemoveCameraFromProduct(cameraToRemove.Id);
  446. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  447. }
  448. }
  449. }
  450. /// <summary>
  451. /// 编辑相机
  452. /// </summary>
  453. void ExecuteEditCameraCommand()
  454. {
  455. if (SelectCamera == null) return;
  456. bool isSelectedCameraBrandSucced = false;
  457. CameraBrand cameraBrand = CameraBrand.HikRobot_MVS;
  458. IDialogParameters parameters1 = new DialogParameters();
  459. parameters1.Add("CameraBrand", SelectCamera.CameraBrand);
  460. _dialogService.ShowDialog("SelectCameraBrand", parameters1, rst =>
  461. {
  462. if (rst.Result == ButtonResult.OK)
  463. {
  464. isSelectedCameraBrandSucced = true;
  465. cameraBrand = rst.Parameters.GetValue<CameraBrand>("CameraBrand");
  466. }
  467. else
  468. {
  469. return;
  470. }
  471. });
  472. if (!isSelectedCameraBrandSucced) { return; }
  473. (bool isInstalled, string version) result = (false, "");
  474. string softwarename = "";
  475. switch (cameraBrand)
  476. {
  477. case CameraBrand.HikRobot_MVS:
  478. softwarename = "MVS";
  479. result = MvCamera.CheckSoftwareInstalled();
  480. break;
  481. case CameraBrand.Basler_Pylon:
  482. softwarename = "Pylon 7";
  483. result = BaslerCamera.CheckSoftwareInstalled();
  484. break;
  485. case CameraBrand.IRayple:
  486. softwarename = "MV Viewer";
  487. result = AHuaCamera.CheckSoftwareInstalled();
  488. break;
  489. case CameraBrand.Cognex:
  490. softwarename = "Cognex VisionPro";
  491. result = CognexCamera.CheckSoftwareInstalled();
  492. break;
  493. case CameraBrand.Galaxy:
  494. softwarename = "Galaxy Viewer";
  495. result = GalaxyCamera.CheckSoftwareInstalled();
  496. break;
  497. default:
  498. break;
  499. }
  500. if (!result.isInstalled)
  501. {
  502. if (string.IsNullOrEmpty(result.version))
  503. {
  504. //未安装
  505. MessageBox.Show(Lang.CameraSDKCheck_Message1.Replace("{name}", softwarename), "AAS", MessageBoxButton.OK, MessageBoxImage.Asterisk);
  506. }
  507. else
  508. {
  509. //版本较低
  510. MessageBox.Show(Lang.CameraSDKCheck_Message2.Replace("{name}", softwarename).Replace("{version}", result.version).Replace("\\n", Environment.NewLine), "AAS", MessageBoxButton.OK, MessageBoxImage.Asterisk);
  511. }
  512. return;
  513. }
  514. //编辑前的相机名称
  515. string oldCameraName = SelectCamera.CameraName;
  516. IDialogParameters parameters = new DialogParameters();
  517. parameters.Add("CameraBrand", cameraBrand);
  518. parameters.Add("Camera", SelectCamera.Copy());
  519. _dialogService.ShowDialog("EditCamera", parameters, rst =>
  520. {
  521. //对话框关闭之后的回调函数,可以在这解析结果。
  522. ButtonResult result1 = rst.Result;
  523. if (result1 == ButtonResult.OK)
  524. {
  525. var param = rst.Parameters.GetValue<CameraInfo>("Camera");
  526. SelectCamera.CameraName = param.CameraName;
  527. SelectCamera.SerialNumber = param.SerialNumber;
  528. SelectCamera.Model = param.Model;
  529. SelectCamera.ManufacturerName = param.ManufacturerName;
  530. SelectCamera.CameraType = param.CameraType;
  531. SelectCamera.CameraBrand = param.CameraBrand;
  532. SelectCamera.CameraIp = param.CameraIp;
  533. _configService.AddOrUpdateCamera(SelectCamera);
  534. if (oldCameraName != param.CameraName)
  535. {
  536. //对所有产品也进行修改
  537. _productService.UpdateCameraNameInProduct(SelectCamera.Id, SelectCamera.CameraName);
  538. }
  539. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  540. }
  541. });
  542. }
  543. /// <summary>
  544. /// 增加相机
  545. /// </summary>
  546. void ExecuteAddCameraCommand()
  547. {
  548. bool isSelectedCameraBrandSucced = false;
  549. CameraBrand cameraBrand = CameraBrand.HikRobot_MVS;
  550. _dialogService.ShowDialog("SelectCameraBrand", rst =>
  551. {
  552. if (rst.Result == ButtonResult.OK)
  553. {
  554. isSelectedCameraBrandSucced = true;
  555. cameraBrand = rst.Parameters.GetValue<CameraBrand>("CameraBrand");
  556. }
  557. else
  558. {
  559. return;
  560. }
  561. });
  562. if (!isSelectedCameraBrandSucced) { return; }
  563. ;
  564. (bool isInstalled, string version) result = (false, "");
  565. string softwarename = "";
  566. switch (cameraBrand)
  567. {
  568. case CameraBrand.HikRobot_MVS:
  569. softwarename = "MVS";
  570. result = MvCamera.CheckSoftwareInstalled();
  571. break;
  572. case CameraBrand.Basler_Pylon:
  573. softwarename = "Pylon 7";
  574. result = BaslerCamera.CheckSoftwareInstalled();
  575. break;
  576. case CameraBrand.IRayple:
  577. softwarename = "MV Viewer";
  578. result = AHuaCamera.CheckSoftwareInstalled();
  579. break;
  580. case CameraBrand.Cognex:
  581. softwarename = "Cognex VisionPro";
  582. result = CognexCamera.CheckSoftwareInstalled();
  583. break;
  584. case CameraBrand.Galaxy:
  585. softwarename = "Galaxy Viewer";
  586. result = GalaxyCamera.CheckSoftwareInstalled();
  587. break;
  588. default:
  589. break;
  590. }
  591. if (!result.isInstalled)
  592. {
  593. if (string.IsNullOrEmpty(result.version))
  594. {
  595. //未安装
  596. MessageBox.Show(Lang.CameraSDKCheck_Message1.Replace("{name}", softwarename), "AAS", MessageBoxButton.OK, MessageBoxImage.Asterisk);
  597. }
  598. else
  599. {
  600. //版本较低
  601. MessageBox.Show(Lang.CameraSDKCheck_Message2.Replace("{name}", softwarename).Replace("{version}", result.version).Replace("\\n", Environment.NewLine), "AAS", MessageBoxButton.OK, MessageBoxImage.Asterisk);
  602. }
  603. return;
  604. }
  605. IDialogParameters parameters = new DialogParameters();
  606. parameters.Add("CameraBrand", cameraBrand);
  607. _dialogService.ShowDialog("AddCamera", parameters, rst =>
  608. {
  609. //对话框关闭之后的回调函数,可以在这解析结果。
  610. ButtonResult result1 = rst.Result;
  611. if (result1 == ButtonResult.OK)
  612. {
  613. var param = rst.Parameters.GetValue<CameraInfo>("Camera");
  614. var camera = new CameraInfo()
  615. {
  616. Id = param.Id,
  617. CameraName = param.CameraName,
  618. SerialNumber = param.SerialNumber,
  619. Model = param.Model,
  620. ManufacturerName = param.ManufacturerName,
  621. CameraType = param.CameraType,
  622. CameraBrand = param.CameraBrand,
  623. CameraIp = param.CameraIp
  624. };
  625. CameraList.Add(camera);
  626. _configService.AddOrUpdateCamera(camera);
  627. _cameraService.CreateCamera(camera.Id, camera);
  628. //对所有产品也进行添加
  629. _productService.AddCameraToProduct(camera.Id, camera.CameraName);
  630. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  631. }
  632. });
  633. }
  634. #endregion
  635. #region Feeder
  636. void ExecuteAddFeederCommand()
  637. {
  638. _dialogService.ShowDialog("AddFeeder", rst =>
  639. {
  640. //对话框关闭之后的回调函数,可以在这解析结果。
  641. ButtonResult result1 = rst.Result;
  642. if (result1 == ButtonResult.OK)
  643. {
  644. var param = rst.Parameters.GetValue<FeederInfo>("Feeder");
  645. var feeder = new FeederInfo()
  646. {
  647. Id = param.Id,
  648. FeederName = param.FeederName,
  649. ConnectType = param.ConnectType,
  650. FeederBrand = param.FeederBrand,
  651. IP = param.IP,
  652. Port = param.Port
  653. };
  654. FeederList.Add(feeder);
  655. _configService.AddOrUpdateFeeder(feeder);
  656. _feederService.CreateFeeder(feeder.Id, feeder.FeederNo, feeder.FeederName, feeder.IP, feeder.Port, feeder.FeederBrand);
  657. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.添加完成, Duration = 1 });
  658. }
  659. });
  660. }
  661. void ExecuteRemoveFeederCommand()
  662. {
  663. if (MessageBox.Show(Lang.是否移除Feeder, " AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  664. {
  665. // 找到要删除的机器人
  666. var feederToRemove = FeederList.FirstOrDefault(r => r.Id == SelectFeeder.Id);
  667. if (feederToRemove != null)
  668. {
  669. _configService.RemoveFeeder(feederToRemove.Id);
  670. _feederService.RemoveFeeder(feederToRemove.Id);
  671. var root = _configService.GetAllFeeders();
  672. FeederList = new ObservableCollection<FeederInfo>(root);
  673. foreach (var item in FeederList)
  674. {
  675. _feederService.UpdateFeederNo(item.Id, item.FeederNo);
  676. }
  677. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.移除完成, Duration = 1 });
  678. }
  679. }
  680. }
  681. async void ExecuteSaveFeedersCommand()
  682. {
  683. var view = new ShowMessage($"AAS", Lang.是否保存Feeder);
  684. //show the dialog
  685. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  686. if (result != null && result is bool)
  687. {
  688. if (((bool)result))
  689. {
  690. foreach (var item in FeederList)
  691. {
  692. _configService.AddOrUpdateFeeder(item);
  693. }
  694. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  695. }
  696. }
  697. }
  698. #endregion
  699. #region PLC
  700. /// <summary>
  701. /// 保存PLC
  702. /// </summary>
  703. async void ExecuteSavePlcsCommand()
  704. {
  705. var view = new ShowMessage($"AAS", Lang.是否保存PLC);
  706. //show the dialog
  707. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  708. if (result != null && result is bool)
  709. {
  710. if (((bool)result))
  711. {
  712. foreach (var item in PlcList)
  713. {
  714. _configService.AddOrUpdatePlc(item);
  715. }
  716. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  717. }
  718. }
  719. }
  720. /// <summary>
  721. /// 移除PLC
  722. /// </summary>
  723. void ExecuteRemovePlcCommand()
  724. {
  725. if (MessageBox.Show(Lang.是否移除PLC, $"AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  726. {
  727. // 找到要删除的plc
  728. var plcToRemove = PlcList.FirstOrDefault(r => r.Id == SelectPlc.Id);
  729. if (plcToRemove != null)
  730. {
  731. _configService.RemovePlc(plcToRemove.Id);
  732. _plcService.RemovePlc(plcToRemove.Id);
  733. var root = _configService.GetAllPlcs();
  734. PlcList = new ObservableCollection<PlcInfo>(root);
  735. foreach (var item in PlcList)
  736. {
  737. _plcService.UpdatePlcNumber(item.Id, item.Index);
  738. }
  739. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.移除完成, Duration = 1 });
  740. }
  741. }
  742. }
  743. /// <summary>
  744. /// 增加PLC
  745. /// </summary>
  746. void ExecuteAddPlcCommand()
  747. {
  748. _dialogService.ShowDialog("AddPlc", rst =>
  749. {
  750. //对话框关闭之后的回调函数,可以在这解析结果。
  751. ButtonResult result1 = rst.Result;
  752. if (result1 == ButtonResult.OK)
  753. {
  754. var param = rst.Parameters.GetValue<PlcInfo>("PLC");
  755. var plc = new PlcInfo()
  756. {
  757. Id = param.Id,
  758. Name = param.Name,
  759. CommunicationType = param.CommunicationType,
  760. EndpointUrl = param.EndpointUrl,
  761. };
  762. PlcList.Add(plc);
  763. _configService.AddOrUpdatePlc(plc);
  764. _plcService.CreatePlc(plc.Id, plc);
  765. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.添加完成, Duration = 1 });
  766. }
  767. });
  768. }
  769. #endregion
  770. #region Light handlers
  771. void ExecuteAddLightControllerCommand()
  772. {
  773. // create default controller
  774. var ctrl = new LightControllerConfig()
  775. {
  776. Name = $"Controller {(LightControllerList?.Count ?? 0) + 1}",
  777. LightModel = LightModel.KCS_KDC_12V60W_4T
  778. };
  779. LightControllerList.Add(ctrl);
  780. _configService.AddOrUpdateLightController(ctrl);
  781. SelectLightController = ctrl;
  782. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "添加完成", Duration = 1 });
  783. }
  784. void ExecuteRemoveLightControllerCommand()
  785. {
  786. if (SelectLightController == null) return;
  787. if (MessageBox.Show("是否移除光源控制器?", "AAS", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
  788. {
  789. _configService.RemoveLightController(SelectLightController.Id);
  790. LightControllerList.Remove(SelectLightController);
  791. SelectLightController = null;
  792. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "移除完成", Duration = 1 });
  793. }
  794. }
  795. async void ExecuteSaveLightControllersCommand()
  796. {
  797. var view = new ShowMessage($"AAS", "是否保存光源控制器配置?");
  798. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  799. if (result != null && result is bool && (bool)result)
  800. {
  801. foreach (var item in LightControllerList)
  802. {
  803. _configService.AddOrUpdateLightController(item);
  804. }
  805. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = "完成", Duration = 1 });
  806. }
  807. }
  808. #endregion
  809. #region 通讯
  810. async void ExecuteSaveCommunicateCommand(string parm)
  811. {
  812. if (parm == "TCPIP")
  813. {
  814. var view = new ShowMessage($"AAS", Lang.是否保存后台TCP通讯配置);
  815. //show the dialog
  816. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  817. if (result != null && result is bool)
  818. {
  819. if (((bool)result))
  820. {
  821. _configService.SetBgTcp(BgTcp);
  822. _configService.SaveBgTcp();
  823. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  824. }
  825. }
  826. }
  827. else if (parm == "ModbusTCP")
  828. {
  829. var view = new ShowMessage($"AAS", Lang.是否保存后台ModbusTCP通讯配置);
  830. //show the dialog
  831. var result = await DialogHost.Show(view, "RootDialog", null, null, null);
  832. if (result != null && result is bool)
  833. {
  834. if (((bool)result))
  835. {
  836. _configService.SetBgModbusTcp(BgModbus);
  837. _configService.SaveBgModbusTcp();
  838. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 1 });
  839. }
  840. }
  841. }
  842. else
  843. {
  844. return;
  845. }
  846. }
  847. #endregion
  848. #region 语言
  849. void ExecuteSelectLanguageCommand(string language)
  850. {
  851. if (string.Equals(language, "ChineseSimplified"))
  852. {
  853. CurrentLanguage = Enums.Language.ChineseSimplified;
  854. var sysConfig = _configService.GetSystemConfiguration();
  855. sysConfig.CurrentLanguage = CurrentLanguage;
  856. _configService.SaveSystemConfiguration(sysConfig);
  857. var culture = new CultureInfo("zh-CN");
  858. App.Current.Dispatcher.Thread.CurrentCulture = culture;
  859. App.Current.Dispatcher.Thread.CurrentUICulture = culture;
  860. LocalizeDictionary.Instance.Culture = culture;
  861. Lang.Culture = culture;
  862. Application.Current.Resources["DefaultFont"] = new System.Windows.Media.FontFamily("Microsoft YaHei");
  863. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
  864. }
  865. else if (string.Equals(language, "ChineseTraditional"))
  866. {
  867. CurrentLanguage = Enums.Language.ChineseTraditional;
  868. var sysConfig = _configService.GetSystemConfiguration();
  869. sysConfig.CurrentLanguage = CurrentLanguage;
  870. _configService.SaveSystemConfiguration(sysConfig);
  871. var culture = new CultureInfo("zh-TW");
  872. App.Current.Dispatcher.Thread.CurrentCulture = culture;
  873. App.Current.Dispatcher.Thread.CurrentUICulture = culture;
  874. LocalizeDictionary.Instance.Culture = culture;
  875. Lang.Culture = culture;
  876. Application.Current.Resources["DefaultFont"] = new System.Windows.Media.FontFamily("Microsoft YaHei");
  877. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
  878. }
  879. else if (string.Equals(language, "English"))
  880. {
  881. CurrentLanguage = Enums.Language.English;
  882. var sysConfig = _configService.GetSystemConfiguration();
  883. sysConfig.CurrentLanguage = CurrentLanguage;
  884. _configService.SaveSystemConfiguration(sysConfig);
  885. var culture = new CultureInfo("en");
  886. App.Current.Dispatcher.Thread.CurrentCulture = culture;
  887. App.Current.Dispatcher.Thread.CurrentUICulture = culture;
  888. LocalizeDictionary.Instance.Culture = culture;
  889. Lang.Culture = culture;
  890. Application.Current.Resources["DefaultFont"] = new System.Windows.Media.FontFamily("Segoe UI");
  891. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
  892. }
  893. else if (string.Equals(language, "Japanese"))
  894. {
  895. CurrentLanguage = Enums.Language.Japanese;
  896. var sysConfig = _configService.GetSystemConfiguration();
  897. sysConfig.CurrentLanguage = CurrentLanguage;
  898. _configService.SaveSystemConfiguration(sysConfig);
  899. var culture = new CultureInfo("ja-JP");
  900. App.Current.Dispatcher.Thread.CurrentCulture = culture;
  901. App.Current.Dispatcher.Thread.CurrentUICulture = culture;
  902. LocalizeDictionary.Instance.Culture = culture;
  903. Lang.Culture = culture;
  904. Application.Current.Resources["DefaultFont"] = new System.Windows.Media.FontFamily("Segoe UI");
  905. _eventAggregator.GetEvent<SnackbarMessageNotification>().Publish(new MessageParameter() { Msg = Lang.完成, Duration = 0.5 });
  906. }
  907. }
  908. #endregion
  909. private void OnLoad()
  910. {
  911. }
  912. private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
  913. {
  914. switch (e.PropertyName)
  915. {
  916. case "Title1":
  917. Application.Current.Resources["Font.Size.Title1"] = Title1;
  918. break;
  919. case "Title2":
  920. Application.Current.Resources["Font.Size.Title2"] = Title2;
  921. break;
  922. case "Title3":
  923. Application.Current.Resources["Font.Size.Title3"] = Title3;
  924. break;
  925. case "Title4":
  926. Application.Current.Resources["Font.Size.Title4"] = Title4;
  927. break;
  928. case "Body1":
  929. Application.Current.Resources["Font.Size.Body1"] = Body1;
  930. break;
  931. case "Body2":
  932. Application.Current.Resources["Font.Size.Body2"] = Body2;
  933. break;
  934. case "Body3":
  935. Application.Current.Resources["Font.Size.Body3"] = Body3;
  936. break;
  937. case "Body4":
  938. Application.Current.Resources["Font.Size.Body4"] = Body4;
  939. break;
  940. case "Captions1":
  941. Application.Current.Resources["Font.Size.Captions1"] = Captions1;
  942. break;
  943. case "Captions2":
  944. Application.Current.Resources["Font.Size.Captions2"] = Captions2;
  945. break;
  946. case "Captions3":
  947. Application.Current.Resources["Font.Size.Captions3"] = Captions3;
  948. break;
  949. case "Captions4":
  950. Application.Current.Resources["Font.Size.Captions4"] = Captions4;
  951. break;
  952. default:
  953. break;
  954. }
  955. }
  956. #endregion
  957. #region 继承
  958. /// <summary>
  959. /// 确认导航请求时调用。此方法允许您在导航之前执行一些操作。
  960. /// </summary>
  961. /// <param name="navigationContext"></param>
  962. /// <param name="continuationCallback"></param>
  963. public void ConfirmNavigationRequest(NavigationContext navigationContext, Action<bool> continuationCallback)
  964. {
  965. continuationCallback(true);
  966. }
  967. /// <summary>
  968. /// 接收导航请求时调用。传入导航参数,包含有关导航目标的信息。
  969. /// </summary>
  970. /// <param name="navigationContext"></param>
  971. /// <exception cref="NotImplementedException"></exception>
  972. public async void OnNavigatedTo(NavigationContext navigationContext)
  973. {
  974. if (_systemDatabaseService.GetCurrentUser().userPart == Enums.UserPart.Operator)
  975. {
  976. IsAllowEdit = false;
  977. }
  978. else
  979. {
  980. IsAllowEdit = true;
  981. }
  982. if (RobotList == null)
  983. {
  984. RobotList = new ObservableCollection<RobotInfo>();
  985. var robots = _configService.GetAllRobots();
  986. foreach (var robot in robots)
  987. {
  988. RobotList.Add(robot);
  989. }
  990. }
  991. if (CameraList == null)
  992. {
  993. CameraList = new ObservableCollection<CameraInfo>();
  994. var cameras = _configService.GetAllCameras();
  995. foreach (var camera in cameras)
  996. {
  997. CameraList.Add(camera);
  998. }
  999. }
  1000. if (FeederList == null)
  1001. {
  1002. FeederList = new ObservableCollection<FeederInfo>();
  1003. var feeders = _configService.GetAllFeeders();
  1004. foreach (var feeder in feeders)
  1005. {
  1006. FeederList.Add(feeder);
  1007. }
  1008. }
  1009. if (PlcList == null)
  1010. {
  1011. PlcList = new ObservableCollection<PlcInfo>();
  1012. var plcs = _configService.GetAllPlcs();
  1013. foreach (var plc in plcs)
  1014. {
  1015. PlcList.Add(plc);
  1016. }
  1017. }
  1018. // load light controllers
  1019. if (LightControllerList == null)
  1020. {
  1021. LightControllerList = new ObservableCollection<LightControllerConfig>();
  1022. var controllers = _configService.GetAllLightControllers();
  1023. foreach (var ctrl in controllers)
  1024. {
  1025. LightControllerList.Add(ctrl);
  1026. }
  1027. }
  1028. if (BgTcp == null)
  1029. {
  1030. BgTcp = _configService.GetBgTcp();
  1031. }
  1032. if (BgModbus == null)
  1033. {
  1034. BgModbus = _configService.GetBgModbusTcp();
  1035. }
  1036. CurrentLanguage = _configService.GetSystemConfiguration().CurrentLanguage;
  1037. if (isFirstLoad)
  1038. {
  1039. Title1 = (double)Application.Current.Resources["Font.Size.Title1"];
  1040. Title2 = (double)Application.Current.Resources["Font.Size.Title2"];
  1041. Title3 = (double)Application.Current.Resources["Font.Size.Title3"];
  1042. Title4 = (double)Application.Current.Resources["Font.Size.Title4"];
  1043. Body1 = (double)Application.Current.Resources["Font.Size.Body1"];
  1044. Body2 = (double)Application.Current.Resources["Font.Size.Body2"];
  1045. Body3 = (double)Application.Current.Resources["Font.Size.Body3"];
  1046. Body4 = (double)Application.Current.Resources["Font.Size.Body4"];
  1047. Captions1 = (double)Application.Current.Resources["Font.Size.Captions1"];
  1048. Captions2 = (double)Application.Current.Resources["Font.Size.Captions2"];
  1049. Captions3 = (double)Application.Current.Resources["Font.Size.Captions3"];
  1050. Captions4 = (double)Application.Current.Resources["Font.Size.Captions4"];
  1051. this.PropertyChanged += OnPropertyChanged;
  1052. isFirstLoad = false;
  1053. }
  1054. }
  1055. /// <summary>
  1056. /// 是否允许导航到此视图模型。
  1057. /// </summary>
  1058. /// <param name="navigationContext"></param>
  1059. /// <returns></returns>
  1060. public bool IsNavigationTarget(NavigationContext navigationContext)
  1061. {
  1062. return true;
  1063. }
  1064. /// <summary>
  1065. /// 导航离开此视图模型时调用。您可以在此处执行清理操作或保存状态。
  1066. /// </summary>
  1067. /// <param name="navigationContext"></param>
  1068. public void OnNavigatedFrom(NavigationContext navigationContext)
  1069. {
  1070. }
  1071. #endregion
  1072. private bool _IsAllowEdit = false;
  1073. public bool IsAllowEdit
  1074. {
  1075. get { return _IsAllowEdit; }
  1076. set { SetProperty(ref _IsAllowEdit, value); }
  1077. }
  1078. private void LoginChange(Models.User user)
  1079. {
  1080. if (user.userPart == Enums.UserPart.Operator)
  1081. {
  1082. IsAllowEdit = false;
  1083. }
  1084. else
  1085. {
  1086. IsAllowEdit = true;
  1087. }
  1088. }
  1089. }
  1090. }