LockServoViewModel.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. using OHV.Common.Events;
  2. using OHV.Common.Model;
  3. using OHV.Common.Shareds;
  4. using OHV.SqliteDAL;
  5. using Prism.Commands;
  6. using Prism.Events;
  7. using Prism.Mvvm;
  8. using Prism.Services.Dialogs;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Threading.Tasks;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using static OHV.Common.Events.AxisControlEventArgs;
  16. namespace OHV.Module.Interactivity.PopUp
  17. {
  18. public class LockServoViewModel : BindableBase, IDialogAware
  19. {
  20. private DelegateCommand<string> _closeDialogCommand;
  21. public DelegateCommand<string> CloseDialogCommand =>
  22. _closeDialogCommand ?? ( _closeDialogCommand = new DelegateCommand<string>( CloseDialog ) );
  23. private string _title = "LockServoView";
  24. public string Title
  25. {
  26. get { return this._title; }
  27. set
  28. {
  29. this.SetProperty( ref this._title , value );
  30. }
  31. }
  32. private string _selectAxis = string.Empty;
  33. public string SelectAxis
  34. {
  35. get => this._selectAxis;
  36. set { this.SetProperty( ref this._selectAxis , value ); }
  37. }
  38. private string _selectedPosition = string.Empty;
  39. public string SelectedPosition
  40. {
  41. get => this._selectedPosition;
  42. set
  43. {
  44. this.SetProperty( ref this._selectedPosition , value );
  45. }
  46. }
  47. double _jogVelocity = 5;
  48. public double JogVelocity
  49. {
  50. get { return this._jogVelocity; }
  51. set { this.SetProperty( ref this._jogVelocity , value ); }
  52. }
  53. #region Binding Lock Left
  54. private double _targetPosLockLeft;
  55. public double TargetPosLockLeft
  56. {
  57. get { return this._targetPosLockLeft; }
  58. set { this.SetProperty( ref this._targetPosLockLeft , value ); }
  59. }
  60. private double _currentLockLeft;
  61. public double CurrentLockLeft
  62. {
  63. get { return this._currentLockLeft; }
  64. set { this.SetProperty( ref this._currentLockLeft , value ); }
  65. }
  66. private double _differenceLockLeft;
  67. public double DifferenceLockLeft
  68. {
  69. get { return this._differenceLockLeft; }
  70. set { this.SetProperty( ref this._differenceLockLeft , value ); }
  71. }
  72. Brush _leftAxisBrush = Brushes.Gray;
  73. public Brush LeftAxisBrush
  74. {
  75. get { return this._leftAxisBrush; }
  76. set { SetProperty( ref this._leftAxisBrush , value ); }
  77. }
  78. private Brush posLockBrush = Brushes.Gray;
  79. public Brush PosLockBrush
  80. {
  81. get { return posLockBrush; }
  82. set { SetProperty( ref this.posLockBrush , value ); }
  83. }
  84. private bool isLeftServoOn;
  85. public bool IsLeftServoOn
  86. {
  87. get { return isLeftServoOn; }
  88. set { SetProperty( ref isLeftServoOn , value ); }
  89. }
  90. private bool isLeftServoOriginReturn;
  91. public bool IsLeftServoOriginReturn
  92. {
  93. get { return isLeftServoOriginReturn; }
  94. set { SetProperty( ref isLeftServoOriginReturn , value ); }
  95. }
  96. private bool isLeftServoFalut;
  97. public bool IsLeftServoFault
  98. {
  99. get { return isLeftServoFalut; }
  100. set { SetProperty( ref isLeftServoFalut , value ); }
  101. }
  102. #endregion
  103. #region Binding Lock Right
  104. private double _targetPosLockRight;
  105. public double TargetPosLockRight
  106. {
  107. get { return this._targetPosLockRight; }
  108. set { this.SetProperty( ref this._targetPosLockRight , value ); }
  109. }
  110. private double _currentLockRight;
  111. public double CurrentLockRight
  112. {
  113. get { return this._currentLockRight; }
  114. set { this.SetProperty( ref this._currentLockRight , value ); }
  115. }
  116. private double _differenceLockRight;
  117. public double DifferenceLockRight
  118. {
  119. get { return this._differenceLockRight; }
  120. set { this.SetProperty( ref this._differenceLockRight , value ); }
  121. }
  122. Brush _rightAxisBrush = Brushes.Gray;
  123. public Brush RightAxisBrush
  124. {
  125. get { return this._rightAxisBrush; }
  126. set { SetProperty( ref this._rightAxisBrush , value ); }
  127. }
  128. private Brush posUnlockBursh = Brushes.Gray;
  129. public Brush PosUnlockBrush
  130. {
  131. get { return posUnlockBursh; }
  132. set { SetProperty( ref this.posUnlockBursh , value ); }
  133. }
  134. private bool isRightServoOn;
  135. public bool IsRightServoOn
  136. {
  137. get { return isRightServoOn; }
  138. set { SetProperty( ref isRightServoOn , value ); }
  139. }
  140. private bool isRightServoOriginReturn;
  141. public bool IsRightServoOriginReturn
  142. {
  143. get { return isRightServoOriginReturn; }
  144. set { SetProperty( ref isRightServoOriginReturn , value ); }
  145. }
  146. private bool isRightServoFalut;
  147. public bool IsRightServoFault
  148. {
  149. get { return isRightServoFalut; }
  150. set { SetProperty( ref isRightServoFalut , value ); }
  151. }
  152. #endregion
  153. #region ICommand
  154. public ICommand SelectAxisCommand { get; set; }
  155. public ICommand KeyInTargetPosCommand { get; set; }
  156. public ICommand SelectPosCommand { get; set; }
  157. public ICommand MoveToCommand { get; set; }
  158. public ICommand CurrentToTargetCommand { get; set; }
  159. public ICommand ServoOnCommand { get; set; }
  160. public ICommand ServoOffCommand { get; set; }
  161. public ICommand FaultResetCommand { get; set; }
  162. public ICommand OriginCommand { get; set; }
  163. public ICommand JogCommand { get; set; }
  164. public ICommand SelectedPosDataSave { get; set; }
  165. public ICommand JogVelPopupCommand { get; set; }
  166. public ICommand JogStopCommand { get; set; }
  167. public ICommand AllOriginCommand { get; set; }
  168. #endregion
  169. public event Action<IDialogResult> RequestClose;
  170. IEventAggregator eventAggregator;
  171. MessageController messageController;
  172. SqliteManager sql;
  173. public LockServoViewModel( IEventAggregator ea , MessageController _messageController , SqliteManager _sql )
  174. {
  175. this.SelectAxisCommand = new DelegateCommand<object>( ExecuteSelectAxisCommand );
  176. this.SelectPosCommand = new DelegateCommand<object>( ExecuteSelectPosCommand );
  177. this.MoveToCommand = new DelegateCommand( ExecuteMoveToCommand );
  178. this.CurrentToTargetCommand = new DelegateCommand( ExecuteCurrentToTargetCommand );
  179. this.KeyInTargetPosCommand = new DelegateCommand<object>( ExecuteKeyInCommand );
  180. this.ServoOnCommand = new DelegateCommand<object>( ExecuteServoOnCommand );
  181. this.ServoOffCommand = new DelegateCommand<object>( ExecuteServoOffCommand );
  182. this.FaultResetCommand = new DelegateCommand<object>( ExecuteFaultResetCommand );
  183. this.OriginCommand = new DelegateCommand<object>( ExecuteOriginCommand );
  184. this.AllOriginCommand = new DelegateCommand( ExecuteAllOriginCommand );
  185. this.SelectedPosDataSave = new DelegateCommand<object>( ExecuteSelectedPosDataSave );
  186. this.JogCommand = new DelegateCommand<object>( ExecuteJogCommand );
  187. this.JogVelPopupCommand = new DelegateCommand( ExecuteJogVelPopup );
  188. this.JogStopCommand = new DelegateCommand( ExecuteJogStop );
  189. this.eventAggregator = ea;
  190. this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Unsubscribe( AxisUICallbackCommunication );
  191. this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Subscribe( AxisUICallbackCommunication , ThreadOption.UIThread );
  192. this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Unsubscribe( UICallbackCommunication );
  193. this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Subscribe( UICallbackCommunication , ThreadOption.UIThread );
  194. this.messageController = _messageController;
  195. this.sql = _sql;
  196. //초기 선택 축
  197. }
  198. private void ExecuteAllOriginCommand( )
  199. {
  200. var msg = new AxisControlEventArgs
  201. {
  202. Dir = eEventDir.ToBack ,
  203. Kind = eAxisControlKind.AllOriginReturn ,
  204. };
  205. this.PublishEvent( msg );
  206. }
  207. public void Init()
  208. {
  209. this.SelectAxis = ConstString.AXIS_CARRIER_LOCK_LEFT;
  210. this.LeftAxisBrush = Brushes.Orange;
  211. List<AxisPositionData> positionList = null;
  212. positionList = sql.AxisPositionDataDAL.Get( x => x.Name.Equals( ConstString.TEACH_POSITION_LOCK ) ).ToList();
  213. this.TargetPosLockLeft = positionList.Where( x => x.AxisName.Equals( ConstString.AXIS_CARRIER_LOCK_LEFT ) ).Single().Value;
  214. //초기 Pos 선택
  215. positionList = sql.AxisPositionDataDAL.Get( x => x.Name.Equals( ConstString.TEACH_POSITION_LOCK ) ).ToList();
  216. this.TargetPosLockRight = positionList.Where( x => x.AxisName.Equals( ConstString.AXIS_CARRIER_LOCK_RIGHT ) ).Single().Value;
  217. this.SelectedPosition = ConstString.TEACH_POSITION_LOCK;
  218. this.PosLockBrush = Brushes.Orange;
  219. }
  220. public void ExecuteJogStop( )
  221. {
  222. var msg = new AxisControlEventArgs
  223. {
  224. Dir = eEventDir.ToBack ,
  225. Kind = eAxisControlKind.Stop,
  226. AxisName = this.SelectAxis ,
  227. };
  228. this.PublishEvent( msg );
  229. }
  230. private void ExecuteJogVelPopup( )
  231. {
  232. var numPad = new CalcuratorView();
  233. var result = numPad.ShowDialog( this.JogVelocity );
  234. this.JogVelocity = result;
  235. }
  236. private void UICallbackCommunication( GUIMessageEventArgs obj )
  237. {
  238. if ( obj.Kind == GUIMessageEventArgs.eGUIMessageKind.ModelPropertyChange )
  239. {
  240. if ( obj.MessageKey.Equals( MessageKey.Vehicle ) )
  241. {
  242. }
  243. }
  244. }
  245. private void ExecuteSelectedPosDataSave( object obj )
  246. {
  247. List<AxisPositionData> dataList = null;
  248. this.messageController.ShowConfirmationPopupView( "Position Data Save ?" , r =>
  249. {
  250. if ( r.Result == ButtonResult.OK )
  251. {
  252. switch ( this.SelectedPosition )
  253. {
  254. case ConstString.TEACH_POSITION_LOCK:
  255. dataList = sql.AxisPositionDataDAL.Get( x => x.Name.Equals( ConstString.TEACH_POSITION_LOCK ) ).ToList();
  256. break;
  257. case ConstString.TEACH_POSITION_UNLOCK:
  258. dataList = sql.AxisPositionDataDAL.Get( x => x.Name.Equals( ConstString.TEACH_POSITION_UNLOCK ) ).ToList();
  259. break;
  260. }
  261. var sqlAxisLeft = dataList.Where( x => x.AxisName.Equals( ConstString.AXIS_CARRIER_LOCK_LEFT ) ).Single();
  262. sqlAxisLeft.Value = this.TargetPosLockLeft;
  263. sql.AxisPositionDataDAL.Update( sqlAxisLeft );
  264. var sqlAxisRight = dataList.Where( x => x.AxisName.Equals( ConstString.AXIS_CARRIER_LOCK_RIGHT ) ).Single();
  265. sqlAxisRight.Value = this.TargetPosLockRight;
  266. sql.AxisPositionDataDAL.Update( sqlAxisRight );
  267. }
  268. } );
  269. }
  270. public void ExecuteJogCommand( object obj )
  271. {
  272. if ( this.JogVelocity <= 0 )
  273. {
  274. this.messageController.ShowNotificationView( "Check Jog Velocity" );
  275. return;
  276. }
  277. var msg = new AxisControlEventArgs
  278. {
  279. Dir = eEventDir.ToBack,
  280. Kind = eAxisControlKind.Jog,
  281. AxisName = this.SelectAxis,
  282. JogVelocity = Convert.ToInt32( this.JogVelocity ),
  283. };
  284. if ( obj.ToString().Equals( "+" ) )
  285. msg.JogDir = eJogMoveDir.Positive;
  286. else
  287. msg.JogDir = eJogMoveDir.Negative;
  288. this.PublishEvent( msg );
  289. }
  290. void PublishEvent( AxisControlEventArgs args )
  291. {
  292. args.Dir = eEventDir.ToBack;
  293. this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish( args );
  294. }
  295. void AxisUICallbackCommunication( AxisControlEventArgs args )
  296. {
  297. if ( args.Dir == eEventDir.ToFront )
  298. {
  299. switch ( args.Kind )
  300. {
  301. case eAxisControlKind.Stop:
  302. break;
  303. case eAxisControlKind.EStop:
  304. break;
  305. case eAxisControlKind.Move:
  306. RspMove( args );
  307. break;
  308. case eAxisControlKind.Jog:
  309. break;
  310. case eAxisControlKind.ServoOn:
  311. break;
  312. case eAxisControlKind.ServoOff:
  313. break;
  314. case eAxisControlKind.NONE:
  315. break;
  316. case eAxisControlKind.OriginReturn:
  317. break;
  318. case eAxisControlKind.ReqCurrentPosition:
  319. break;
  320. case eAxisControlKind.ReqStopCurrentPosition:
  321. break;
  322. case eAxisControlKind.FaultReset:
  323. {
  324. var msg = string.Empty;
  325. if ( args.Result.IsSuccess )
  326. msg = $" {this.SelectAxis} Reset Success ";
  327. else
  328. msg = $" {this.SelectAxis} Reset Failed ";
  329. this.messageController.ShowNotificationView( msg );
  330. }
  331. break;
  332. case eAxisControlKind.AxisState:
  333. AxisState( args );
  334. break;
  335. case eAxisControlKind.AllOriginReturn:
  336. {
  337. this.RspOriginState( args );
  338. }
  339. break;
  340. case eAxisControlKind.SyncMove:
  341. break;
  342. case eAxisControlKind.SyncState:
  343. break;
  344. default:
  345. break;
  346. }
  347. }
  348. }
  349. void RspOriginState( AxisControlEventArgs args )
  350. {
  351. var msg = string.Empty;
  352. if ( args.Result.IsSuccess )
  353. msg = "All Origin Success";
  354. else
  355. msg = "Origin Fail";
  356. //if ( IsLeftServoOriginReturn && IsRightServoOriginReturn )
  357. // msg = "All Origin Success";
  358. //else
  359. // msg = "Origin Fail";
  360. this.messageController.ShowNotificationView( msg );
  361. }
  362. private void AxisState( AxisControlEventArgs args )
  363. {
  364. var left = args.Args[ "Left" ] as AxisState;
  365. var right = args.Args[ "Right" ] as AxisState;
  366. this.IsLeftServoOn = left.IsServoOn;
  367. this.IsLeftServoOriginReturn = left.IsOriginReturn;
  368. this.IsLeftServoFault = left.IsAmpFault;
  369. this.CurrentLockLeft = left.CurrentPosition;
  370. this.IsRightServoOn = right.IsServoOn;
  371. this.IsRightServoOriginReturn = right.IsOriginReturn;
  372. this.IsRightServoFault = right.IsAmpFault;
  373. this.CurrentLockRight = right.CurrentPosition;
  374. }
  375. private void RspMove( AxisControlEventArgs args )
  376. {
  377. string msg = string.Empty;
  378. if ( args.Result.IsSuccess )
  379. {
  380. if ( args.PosDir == ePosDir.Lock )
  381. msg = "Clamp Lock Success";
  382. else
  383. msg = "Clamp Unlock Success";
  384. }
  385. else
  386. {
  387. var error = args.Result.Errors.FirstOrDefault();
  388. var alarm = error.Metadata[ "Alarm" ] as Alarm;
  389. msg = alarm.Name + " " + alarm.Text;
  390. }
  391. this.messageController.ShowNotificationView( msg );
  392. }
  393. private void ExecuteOriginCommand( object obj )
  394. {
  395. var msg = new AxisControlEventArgs
  396. {
  397. Dir = eEventDir.ToBack ,
  398. Kind = eAxisControlKind.OriginReturn ,
  399. AxisName = this.SelectAxis ,
  400. };
  401. this.PublishEvent( msg );
  402. }
  403. private void ExecuteFaultResetCommand( object obj )
  404. {
  405. var msg = new AxisControlEventArgs
  406. {
  407. Dir = eEventDir.ToBack ,
  408. Kind = eAxisControlKind.FaultReset ,
  409. AxisName = this.SelectAxis ,
  410. };
  411. this.PublishEvent( msg );
  412. }
  413. private void ExecuteServoOffCommand( object obj )
  414. {
  415. var msg = new AxisControlEventArgs
  416. {
  417. Dir = eEventDir.ToBack ,
  418. Kind = eAxisControlKind.ServoOff ,
  419. AxisName = this.SelectAxis ,
  420. };
  421. this.PublishEvent( msg );
  422. }
  423. private void ExecuteServoOnCommand( object obj )
  424. {
  425. var msg = new AxisControlEventArgs
  426. {
  427. Dir = eEventDir.ToBack ,
  428. Kind = eAxisControlKind.ServoOn ,
  429. AxisName = this.SelectAxis ,
  430. };
  431. this.PublishEvent( msg );
  432. }
  433. private void ExecuteKeyInCommand( object obj )
  434. {
  435. var numPad = new CalcuratorView();
  436. if ( obj.ToString().Equals( "Left" ) )
  437. {
  438. var result = numPad.ShowDialog( this.TargetPosLockLeft );
  439. this.TargetPosLockLeft = result;
  440. }
  441. else
  442. {
  443. var result = numPad.ShowDialog( this.TargetPosLockRight );
  444. this.TargetPosLockRight = result;
  445. }
  446. }
  447. private void ExecuteCurrentToTargetCommand( )
  448. {
  449. this.messageController.ShowConfirmationPopupView( "Current Position To Target Position ?" , r =>
  450. {
  451. if ( r.Result == ButtonResult.OK )
  452. {
  453. switch ( this.SelectAxis )
  454. {
  455. case ConstString.AXIS_CARRIER_LOCK_LEFT:
  456. this.TargetPosLockLeft = this.CurrentLockLeft;
  457. break;
  458. case ConstString.AXIS_CARRIER_LOCK_RIGHT:
  459. this.TargetPosLockRight = this.CurrentLockRight;
  460. break;
  461. }
  462. }
  463. } );
  464. }
  465. private void ExecuteMoveToCommand( )
  466. {
  467. var error = string.Empty;
  468. if ( this.IsLeftServoFault || this.IsRightServoFault )
  469. error = "Is Servo Fault";
  470. else if ( !this.IsLeftServoOn || !this.IsRightServoOn )
  471. error = "Is Servo OFF";
  472. if ( error != string.Empty )
  473. this.messageController.ShowNotificationView( error );
  474. else
  475. {
  476. this.messageController.ShowConfirmationPopupView( $"Clamp Move To {this.SelectedPosition}" , r =>
  477. {
  478. if ( r.Result == ButtonResult.OK )
  479. {
  480. var msg = new AxisControlEventArgs();
  481. msg.Kind = eAxisControlKind.Move;
  482. msg.AxisName = this.SelectAxis;
  483. if ( SelectedPosition.Equals( ConstString.TEACH_POSITION_LOCK ) )
  484. msg.PosDir = ePosDir.Lock;
  485. else
  486. msg.PosDir = ePosDir.UnLock;
  487. this.PublishEvent( msg );
  488. }
  489. } );
  490. }
  491. }
  492. private void ExecuteSelectPosCommand( object obj )
  493. {
  494. List<AxisPositionData> positionList = null;
  495. this.SelectedPosition = obj.ToString();
  496. if ( obj.Equals( ConstString.TEACH_POSITION_LOCK ) )
  497. {
  498. this.PosLockBrush = Brushes.Orange;
  499. this.PosUnlockBrush = Brushes.Gray;
  500. }
  501. else
  502. {
  503. this.PosLockBrush = Brushes.Gray;
  504. this.PosUnlockBrush = Brushes.Orange;
  505. }
  506. switch ( this.SelectedPosition )
  507. {
  508. case ConstString.TEACH_POSITION_LOCK:
  509. positionList = sql.AxisPositionDataDAL.Get( x => x.Name.Equals( ConstString.TEACH_POSITION_LOCK ) ).ToList();
  510. break;
  511. case ConstString.TEACH_POSITION_UNLOCK:
  512. positionList = sql.AxisPositionDataDAL.Get( x => x.Name.Equals( ConstString.TEACH_POSITION_UNLOCK ) ).ToList();
  513. break;
  514. }
  515. var sqlAxisLeft = positionList.Where( x => x.AxisName.Equals( ConstString.AXIS_CARRIER_LOCK_LEFT ) ).Single();
  516. this.TargetPosLockLeft = sqlAxisLeft.Value;
  517. var sqlAxisRight = positionList.Where( x => x.AxisName.Equals( ConstString.AXIS_CARRIER_LOCK_RIGHT ) ).Single();
  518. this.TargetPosLockRight = sqlAxisRight.Value;
  519. }
  520. private void ExecuteSelectAxisCommand( object obj )
  521. {
  522. if ( obj.ToString().Equals( ConstString.AXIS_CARRIER_LOCK_LEFT ) )
  523. {
  524. this.LeftAxisBrush = Brushes.Orange;
  525. this.RightAxisBrush = Brushes.Gray;
  526. this.SelectAxis = ConstString.AXIS_CARRIER_LOCK_LEFT;
  527. }
  528. else
  529. {
  530. this.RightAxisBrush = Brushes.Orange;
  531. this.LeftAxisBrush = Brushes.Gray;
  532. this.SelectAxis = ConstString.AXIS_CARRIER_LOCK_RIGHT;
  533. }
  534. }
  535. #region Dialog
  536. public bool CanCloseDialog( )
  537. {
  538. //throw new NotImplementedException();
  539. return true;
  540. }
  541. public void OnDialogClosed( )
  542. {
  543. this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish( new AxisControlEventArgs { Dir = AxisControlEventArgs.eEventDir.ToBack , Kind = AxisControlEventArgs.eAxisControlKind.ReqStopCurrentPosition } );
  544. this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Unsubscribe( AxisUICallbackCommunication );
  545. this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Unsubscribe( UICallbackCommunication );
  546. }
  547. public async void OnDialogOpened( IDialogParameters parameters )
  548. {
  549. Action action = new Action(() => this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish( new AxisControlEventArgs { Dir = AxisControlEventArgs.eEventDir.ToBack, Kind = AxisControlEventArgs.eAxisControlKind.ReqCurrentPosition } ) );
  550. await Task.Run( action );
  551. }
  552. public virtual void RaiseRequestClose( IDialogResult dialogResult )
  553. {
  554. RequestClose?.Invoke( dialogResult );
  555. }
  556. private void CloseDialog( string parameter )
  557. {
  558. ButtonResult result = ButtonResult.None;
  559. if ( parameter?.ToLower() == "true" )
  560. result = ButtonResult.OK;
  561. else if ( parameter?.ToLower() == "false" )
  562. result = ButtonResult.Cancel;
  563. RaiseRequestClose( new DialogResult( result ) );
  564. }
  565. #endregion
  566. }
  567. }