DriveServoViewModel.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. using GSG.NET.Extensions;
  2. using GSG.NET.Utils;
  3. using OHV.Common.Events;
  4. using OHV.Common.Model;
  5. using OHV.Common.Shareds;
  6. using OHV.SqliteDAL;
  7. using Prism.Commands;
  8. using Prism.Events;
  9. using Prism.Mvvm;
  10. using Prism.Services.Dialogs;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Collections.ObjectModel;
  14. using System.Linq;
  15. using System.Threading.Tasks;
  16. using System.Windows.Controls;
  17. using System.Windows.Input;
  18. using System.Windows.Media;
  19. using VehicleControlSystem;
  20. using VehicleControlSystem.ControlLayer.MQ;
  21. namespace OHV.Module.Interactivity.PopUp
  22. {
  23. public class DriveServoViewModel : BindableBase, IDialogAware
  24. {
  25. private DelegateCommand<string> _closeDialogCommand;
  26. public DelegateCommand<string> CloseDialogCommand =>
  27. _closeDialogCommand ?? ( _closeDialogCommand = new DelegateCommand<string>( CloseDialog ) );
  28. private string _title = "DriveServoView";
  29. public string Title
  30. {
  31. get { return this._title; }
  32. set
  33. {
  34. this.SetProperty( ref this._title, value );
  35. }
  36. }
  37. private string _selectedPosition = string.Empty;
  38. public string SelectedPosition
  39. {
  40. get => this._selectedPosition;
  41. set
  42. {
  43. this.SetProperty( ref this._selectedPosition, value );
  44. }
  45. }
  46. private string _selectDirection = string.Empty;
  47. public string SelectDirection
  48. {
  49. get => this._selectDirection;
  50. set { this.SetProperty( ref this._selectDirection, value ); }
  51. }
  52. #region Motor Left Binding Value
  53. private double _driveTargetPos;
  54. public double DriveTargetPos
  55. {
  56. get { return this._driveTargetPos; }
  57. set { this.SetProperty( ref this._driveTargetPos, value ); }
  58. }
  59. private double _currentPosition;
  60. /// <summary>
  61. /// * Drive Current Position
  62. /// </summary>
  63. public double CurrentPosition
  64. {
  65. get { return this._currentPosition; }
  66. set { this.SetProperty( ref this._currentPosition, value ); }
  67. }
  68. private double _differenceDrive;
  69. public double DifferenceDrive
  70. {
  71. get { return this._differenceDrive; }
  72. set { this.SetProperty( ref this._differenceDrive, value ); }
  73. }
  74. private double _jogVelocity = 3.0;
  75. public double JogVelocity
  76. {
  77. get { return this._jogVelocity; }
  78. set { this.SetProperty( ref this._jogVelocity, value ); }
  79. }
  80. #endregion
  81. public event Action<IDialogResult> RequestClose;
  82. #region Commands
  83. public ICommand SelectAxisCommand { get; set; }
  84. public ICommand KeyInTargetPosCommand { get; set; }
  85. public ICommand SelectPosCommand { get; set; }
  86. public ICommand MoveToCommand { get; set; }
  87. public ICommand CurrentToTargetCommand { get; set; }
  88. public ICommand ServoOnCommand { get; set; }
  89. public ICommand ServoOffCommand { get; set; }
  90. public ICommand FaultResetCommand { get; set; }
  91. public ICommand OriginCommand { get; set; }
  92. public IEventAggregator eventAggregator;
  93. public ICommand PositionAddCommand { get; set; }
  94. public ICommand PositionDeleteCommand { get; set; }
  95. public ICommand PositionSaveCommand { get; set; }
  96. public ICommand SteeringMoveCommand { get; set; }
  97. public ICommand SelectedDirection { get; set; }
  98. public ICommand JogVelPopupCommand { get; set; }
  99. public ICommand JogCommand { get; set; }
  100. #endregion
  101. #region Brushes
  102. private Brush steeringLeftBrush = Brushes.Gray;
  103. public Brush SteeringLeftBrushProperty
  104. {
  105. get { return steeringLeftBrush; }
  106. set { SetProperty( ref this.steeringLeftBrush, value ); }
  107. }
  108. private Brush steeringRightBrush = Brushes.Gray;
  109. public Brush SteeringRightBrushProperty
  110. {
  111. get { return steeringRightBrush; }
  112. set { SetProperty( ref this.steeringRightBrush, value ); }
  113. }
  114. Brush driveOnStateBrush = Brushes.DodgerBlue;
  115. public Brush DriveOnStateBrush
  116. {
  117. get { return this.driveOnStateBrush; }
  118. set { SetProperty(ref this.driveOnStateBrush, value); }
  119. }
  120. Brush driveOffStateBrush = Brushes.DodgerBlue;
  121. public Brush DriveOffStateBrush
  122. {
  123. get { return this.driveOffStateBrush; }
  124. set { SetProperty(ref this.driveOffStateBrush, value); }
  125. }
  126. #endregion
  127. private ObservableCollection<Route> _routeList;
  128. public ObservableCollection<Route> RouteList
  129. {
  130. get { return this._routeList; }
  131. set { SetProperty( ref this._routeList, value ); }
  132. }
  133. public SqliteDAL.DAL.AxisPositionDataDAL axisPositionDataDal;
  134. SqliteManager sql;
  135. MessageController messageController;
  136. private string autoReadyFlag = "NG";
  137. public string AutoReadyFlag
  138. {
  139. get { return autoReadyFlag; }
  140. set { this.SetProperty(ref this.autoReadyFlag, value); }
  141. }
  142. Brush autoReadyFlagColor = Brushes.Gray;
  143. public Brush AutoReadyFlagColor
  144. {
  145. get { return this.autoReadyFlagColor; }
  146. set { this.SetProperty(ref this.autoReadyFlagColor, value); }
  147. }
  148. private string currentMCR = "None";
  149. public string CurrentMCR
  150. {
  151. get { return currentMCR; }
  152. set { this.SetProperty(ref this.currentMCR, value); }
  153. }
  154. private string currentTag = "None";
  155. public string CurrentTag
  156. {
  157. get { return currentTag; }
  158. set { SetProperty(ref this.currentTag, value); }
  159. }
  160. ZmqManager zmqManager;
  161. public DriveServoViewModel( IEventAggregator _ea, SqliteManager _sql, MessageController _messageController, VCSystem system )
  162. {
  163. this.eventAggregator = _ea;
  164. this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Unsubscribe( DriveControlCallBack );
  165. this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Subscribe( DriveControlCallBack, ThreadOption.UIThread );
  166. this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Unsubscribe( UICallBackCommunication );
  167. this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Subscribe( UICallBackCommunication, ThreadOption.UIThread );
  168. this.sql = _sql;
  169. this.messageController = _messageController;
  170. this.zmqManager = system.ZmqManager;
  171. system.ZmqManager.PropertyChanged += ZmqManager_PropertyChanged;
  172. this.SelectPosCommand = new DelegateCommand<object>( ExecuteSelectPosCommand );
  173. this.MoveToCommand = new DelegateCommand( ExecuteMoveToCommand );
  174. this.CurrentToTargetCommand = new DelegateCommand( ExecuteCurrentToTargetCommand );
  175. this.KeyInTargetPosCommand = new DelegateCommand<object>( ExecuteKeyInCommadn );
  176. this.ServoOnCommand = new DelegateCommand( ExecuteServoOnCommand );
  177. this.ServoOffCommand = new DelegateCommand( ExecuteServoOffCommand );
  178. this.FaultResetCommand = new DelegateCommand( ExecuteFaultResetCommand );
  179. this.OriginCommand = new DelegateCommand( ExecuteOriginCommand );
  180. this.PositionAddCommand = new DelegateCommand( ExecutePositionAddCommand );
  181. this.PositionDeleteCommand = new DelegateCommand( ExecutePositionDeleteCommand );
  182. this.PositionSaveCommand = new DelegateCommand( ExecutePositionSaveCommand );
  183. this.SelectedDirection = new DelegateCommand<object>( ExecuteSelectedDirection );
  184. this.SteeringMoveCommand = new DelegateCommand<object>( ExecuteSteeringMove );
  185. this.JogVelPopupCommand = new DelegateCommand( ExecuteJogVelPopupCommand );
  186. this.JogCommand = new DelegateCommand<object>( ExecuteJogCommand );
  187. this.InitializeData();
  188. }
  189. private void InitializeData()
  190. {
  191. this.CurrentMCR = this.zmqManager.CurrentMCR;
  192. this.CurrentTag = this.zmqManager.GetCurrentPointNo().ToString();
  193. //TODO: Drive 상태 Update (On/Off, Fault)
  194. //if (zmqManager.IsDriveOn)
  195. // this.DriveOnStateBrush = Brushes.LimeGreen;
  196. //else
  197. // this.DriveOnStateBrush = Brushes.DodgerBlue;
  198. DriveAutoReadyState(this.zmqManager.IsCanStanbyLocation);
  199. }
  200. private void ZmqManager_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  201. {
  202. var property = sender.GetType().GetProperty(e.PropertyName);
  203. var newValue = property.GetValue(sender, null);
  204. switch(e.PropertyName)
  205. {
  206. case "CurrentTag":
  207. this.CurrentTag = CastTo<int>.From<object>(newValue).ToString();
  208. break;
  209. case "CurrentMCR":
  210. this.CurrentMCR = CastTo<string>.From<object>(newValue);
  211. break;
  212. case "IsCanStanbyLocation":
  213. {
  214. var ll = CastTo<bool>.From<object>(newValue);
  215. DriveAutoReadyState(ll);
  216. }
  217. break;
  218. case "IsDriveOn":
  219. {
  220. var result = CastTo<bool>.From<object>(newValue);
  221. if (result)
  222. this.DriveOnStateBrush = Brushes.LimeGreen;
  223. else
  224. this.DriveOnStateBrush = Brushes.DodgerBlue;
  225. }
  226. break;
  227. }
  228. }
  229. private void ExecuteSteeringMove( object obj )
  230. {
  231. var msg = new DriveControlEventArgs
  232. {
  233. EventDir = DriveControlEventArgs.eEventDir.ToBack ,
  234. ControlKind = DriveControlEventArgs.eControlKind.Steering ,
  235. };
  236. if ( obj.ToString().Equals( "CW" ) )
  237. msg.MoveDir = DriveControlEventArgs.eMoveDir.LEFT;
  238. else
  239. msg.MoveDir = DriveControlEventArgs.eMoveDir.RIGHT;
  240. this.PublishEvent( msg );
  241. }
  242. private void UICallBackCommunication( GUIMessageEventArgs obj )
  243. {
  244. if ( obj.Kind == GUIMessageEventArgs.eGUIMessageKind.ModelPropertyChange )
  245. {
  246. if ( obj.MessageKey.Equals( MessageKey.Vehicle ) )
  247. {
  248. switch ( obj.ModelPropertyName )
  249. {
  250. case "SteeringState":
  251. {
  252. var dir = CastTo<eSteeringState>.From<object>( obj.Args );
  253. this.ChangeSteeringDirection( dir );
  254. }
  255. break;
  256. case "VehicleStateProperty":
  257. {
  258. var v = CastTo<eVehicleState>.From<object>( obj.Args );
  259. this.ChagneVehicleState( v );
  260. }
  261. break;
  262. case "CurrentPosition":
  263. {
  264. var v = CastTo<double>.From<object>( obj.Args );
  265. this.CurrentPosition = v;
  266. }
  267. break;
  268. case "CurrentSpeed":
  269. break;
  270. case "CurrentTorque":
  271. break;
  272. default:
  273. break;
  274. }
  275. }
  276. }
  277. if ( obj.Kind == GUIMessageEventArgs.eGUIMessageKind.RspRouteManager )
  278. {
  279. }
  280. }
  281. void DriveAutoReadyState(bool state)
  282. {
  283. if(state)
  284. {
  285. this.AutoReadyFlag = "OK";
  286. this.AutoReadyFlagColor = Brushes.LimeGreen;
  287. }
  288. else
  289. {
  290. this.AutoReadyFlag = "NG";
  291. this.AutoReadyFlagColor = Brushes.Gray;
  292. }
  293. }
  294. private void ChagneVehicleState( eVehicleState v )
  295. {
  296. switch ( v )
  297. {
  298. case eVehicleState.None:
  299. break;
  300. case eVehicleState.Idle:
  301. break;
  302. case eVehicleState.Move:
  303. break;
  304. case eVehicleState.Load:
  305. break;
  306. case eVehicleState.Unload:
  307. break;
  308. case eVehicleState.Charge:
  309. break;
  310. case eVehicleState.Abnormal:
  311. break;
  312. case eVehicleState.Blocked:
  313. break;
  314. case eVehicleState.Decelerate:
  315. break;
  316. }
  317. }
  318. private void DriveControlCallBack( DriveControlEventArgs args )
  319. {
  320. if ( args.EventDir == DriveControlEventArgs.eEventDir.ToFront )
  321. {
  322. switch ( args.ControlKind )
  323. {
  324. case DriveControlEventArgs.eControlKind.MOVE:
  325. ResponseMove( args );
  326. break;
  327. case DriveControlEventArgs.eControlKind.STOP:
  328. break;
  329. case DriveControlEventArgs.eControlKind.Steering:
  330. //if ( args.Result.IsSuccess )
  331. //{
  332. // var dir = args.Result.ToResult<eSteeringState>().Value;
  333. // this.ChangeSteeringDirection( dir );
  334. //}
  335. break;
  336. case DriveControlEventArgs.eControlKind.SteeringState:
  337. if ( args.Result.IsSuccess )
  338. {
  339. var dir = CastTo<eSteeringState>.From<object>( args.Args );
  340. this.ChangeSteeringDirection( dir );
  341. }
  342. else
  343. {
  344. this.ChangeSteeringDirection( eSteeringState.None );
  345. }
  346. break;
  347. case DriveControlEventArgs.eControlKind.ReqCurrentPos:
  348. this.CurrentPosition = args.CurrentPosition;
  349. break;
  350. case DriveControlEventArgs.eControlKind.ReqStopCurrentPos:
  351. break;
  352. case DriveControlEventArgs.eControlKind.FaultReset:
  353. break;
  354. case DriveControlEventArgs.eControlKind.DriveON:
  355. break;
  356. case DriveControlEventArgs.eControlKind.DriveOFF:
  357. break;
  358. case DriveControlEventArgs.eControlKind.JOG:
  359. break;
  360. case DriveControlEventArgs.eControlKind.VehicleState:
  361. ResponseVehicleState( args );
  362. break;
  363. default:
  364. break;
  365. }
  366. }
  367. }
  368. private void ResponseVehicleState( DriveControlEventArgs args )
  369. {
  370. var state = CastTo<VehicleInfo>.From<object>( args.Args );
  371. this.CurrentPosition = state.CurrentPosition;
  372. }
  373. private void ResponseMove( DriveControlEventArgs args )
  374. {
  375. var msg = string.Empty;
  376. if ( args.Result.IsSuccess )
  377. {
  378. msg = "Move Success";
  379. }
  380. else
  381. {
  382. var error = args.Result.Errors.FirstOrDefault();
  383. var alarm = error.Metadata["Alarm"] as Alarm;
  384. msg = alarm.Name + " " + alarm.Text;
  385. }
  386. this.messageController.ShowNotificationView( msg );
  387. }
  388. void PublishEvent( DriveControlEventArgs args )
  389. {
  390. args.EventDir = DriveControlEventArgs.eEventDir.ToBack;
  391. this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Publish( args );
  392. }
  393. void ChangeSteeringDirection( eSteeringState state )
  394. {
  395. if ( state == eSteeringState.Left )
  396. {
  397. this.SteeringLeftBrushProperty = (Brush)new BrushConverter().ConvertFromString( "#FF00FFD3" );
  398. this.SteeringRightBrushProperty = Brushes.Gray;
  399. }
  400. else if ( state == eSteeringState.Right )
  401. {
  402. this.SteeringLeftBrushProperty = Brushes.Gray;
  403. this.SteeringRightBrushProperty = (Brush)new BrushConverter().ConvertFromString( "#FF00FFD3" );
  404. }
  405. else
  406. {
  407. this.SteeringLeftBrushProperty = Brushes.Gray;
  408. this.SteeringRightBrushProperty = Brushes.Gray;
  409. }
  410. }
  411. #region Execute Method
  412. private void ExecuteJogCommand( object obj )
  413. {
  414. if ( this.JogVelocity <= 0 )
  415. {
  416. this.messageController.ShowNotificationView( "Check Jog Velocity" );
  417. return;
  418. }
  419. var msg = new DriveControlEventArgs
  420. {
  421. EventDir = DriveControlEventArgs.eEventDir.ToBack,
  422. ControlKind = DriveControlEventArgs.eControlKind.JOG,
  423. };
  424. if ( obj.ToString().Equals( "+" ) )
  425. msg.JogDir = DriveControlEventArgs.eJogMoveDir.Positive;
  426. else
  427. msg.JogDir = DriveControlEventArgs.eJogMoveDir.Negative;
  428. this.PublishEvent( msg );
  429. }
  430. private void ExecuteJogVelPopupCommand()
  431. {
  432. var numPad = new CalcuratorView();
  433. var result = numPad.ShowDialog( this.JogVelocity );
  434. this.JogVelocity = result;
  435. }
  436. private void ExecuteSelectedDirection( object obj )
  437. {
  438. this.SelectDirection = obj.ToString();
  439. }
  440. private void ExecutePositionSaveCommand()
  441. {
  442. this.messageController.ShowConfirmationPopupView( "Save To Data ?", r =>
  443. {
  444. if ( r.Result == ButtonResult.OK )
  445. {
  446. var result = this.RouteList.Any( x => x.IsSelected != false );
  447. if ( !result )
  448. {
  449. this.messageController.ShowNotificationView( "Pos Not Selected" );
  450. return;
  451. }
  452. var ll = this.RouteList.Where( x => x.IsSelected ).FirstOrDefault();
  453. }
  454. } );
  455. }
  456. private void ExecutePositionDeleteCommand()
  457. {
  458. this.messageController.ShowConfirmationPopupView( "Select To Delete ?", r =>
  459. {
  460. if ( r.Result == ButtonResult.OK )
  461. {
  462. var deleteList = new List<Route>();
  463. foreach ( var item in this.RouteList )
  464. {
  465. if ( item.IsSelected )
  466. deleteList.Add( item );
  467. }
  468. deleteList.ForEach( x => { this.RouteList.Remove( x ); } );
  469. }
  470. } );
  471. }
  472. private void ExecutePositionAddCommand()
  473. {
  474. this.messageController.ShowConfirmationPopupView( "Position Add ?", r =>
  475. {
  476. if ( r.Result == ButtonResult.OK )
  477. {
  478. this.RouteList.Add( new Route() );
  479. this.messageController.ShowNotificationView( "Create Success" );
  480. }
  481. } );
  482. }
  483. private void ExecuteKeyInCommadn( object obj )
  484. {
  485. var numPad = new CalcuratorView();
  486. var result = numPad.ShowDialog( this.DriveTargetPos );
  487. this.DriveTargetPos = result;
  488. }
  489. private void ExecuteOriginCommand()
  490. {
  491. this.messageController.ShowConfirmationPopupView( "Origin ?", r =>
  492. {
  493. if ( r.Result == ButtonResult.OK )
  494. {
  495. }
  496. } );
  497. }
  498. private void ExecuteFaultResetCommand()
  499. {
  500. var msg = new DriveControlEventArgs
  501. {
  502. EventDir = DriveControlEventArgs.eEventDir.ToBack,
  503. ControlKind = DriveControlEventArgs.eControlKind.FaultReset,
  504. };
  505. this.PublishEvent( msg );
  506. }
  507. private void ExecuteServoOffCommand()
  508. {
  509. var msg = new DriveControlEventArgs
  510. {
  511. EventDir = DriveControlEventArgs.eEventDir.ToBack,
  512. ControlKind = DriveControlEventArgs.eControlKind.DriveOFF,
  513. };
  514. this.PublishEvent( msg );
  515. }
  516. private void ExecuteServoOnCommand()
  517. {
  518. var msg = new DriveControlEventArgs
  519. {
  520. EventDir = DriveControlEventArgs.eEventDir.ToBack,
  521. ControlKind = DriveControlEventArgs.eControlKind.DriveON,
  522. };
  523. this.PublishEvent( msg );
  524. }
  525. private void ExecuteCurrentToTargetCommand()
  526. {
  527. this.messageController.ShowConfirmationPopupView( "Current To Target ?", r =>
  528. {
  529. if ( r.Result == ButtonResult.OK )
  530. {
  531. this.DriveTargetPos = this.CurrentPosition;
  532. }
  533. } );
  534. }
  535. private void ExecuteMoveToCommand()
  536. {
  537. this.messageController.ShowConfirmationPopupView( "Move To Selected Position ?", r =>
  538. {
  539. if ( r.Result == ButtonResult.OK )
  540. {
  541. var result = this.RouteList.Any( x => x.IsSelected != false );
  542. if ( !result )
  543. {
  544. this.messageController.ShowNotificationView( "Pos Not Selected" );
  545. return;
  546. }
  547. var ll = this.RouteList.Where( x => x.IsSelected ).FirstOrDefault();
  548. var msg = new DriveControlEventArgs
  549. {
  550. EventDir = DriveControlEventArgs.eEventDir.ToBack,
  551. ControlKind = DriveControlEventArgs.eControlKind.MOVE,
  552. TargetRouteID = ll.Id,
  553. };
  554. this.PublishEvent( msg );
  555. }
  556. } );
  557. }
  558. private void ExecuteSelectPosCommand( object obj )
  559. {
  560. this.SelectedPosition = obj.ToString();
  561. }
  562. #endregion
  563. #region Dialog Function
  564. public bool CanCloseDialog()
  565. {
  566. return true;
  567. }
  568. public void OnDialogClosed()
  569. {
  570. this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Publish( new DriveControlEventArgs { EventDir = DriveControlEventArgs.eEventDir.ToBack, ControlKind = DriveControlEventArgs.eControlKind.ReqStopCurrentPos } );
  571. this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Unsubscribe( DriveControlCallBack );
  572. this.eventAggregator.GetEvent<GUIMessagePubSubEvent>().Unsubscribe( UICallBackCommunication );
  573. }
  574. public async void OnDialogOpened( IDialogParameters parameters )
  575. {
  576. Task task = Task.Run( () =>
  577. {
  578. var msg = new DriveControlEventArgs
  579. {
  580. EventDir = DriveControlEventArgs.eEventDir.ToBack,
  581. ControlKind = DriveControlEventArgs.eControlKind.SteeringState,
  582. };
  583. this.PublishEvent( msg );
  584. this.eventAggregator.GetEvent<DriveControlPubSubEvent>().Publish( new DriveControlEventArgs { EventDir = DriveControlEventArgs.eEventDir.ToBack, ControlKind = DriveControlEventArgs.eControlKind.VehicleState } );
  585. var vcsMsg = new VCSMessageEventArgs() { Kind = VCSMessageEventArgs.eVCSMessageKind.ReqRouteManager };
  586. this.eventAggregator.GetEvent<VCSMessagePubSubEvent>().Publish( vcsMsg );
  587. var sT = SwUtils.CurrentTimeMillis;
  588. this.RouteList = new ObservableCollection<Route>( sql.RouteDal.GetAll() );
  589. Console.WriteLine( SwUtils.Elapsed( sT ) );
  590. } );
  591. await task;
  592. }
  593. private void CloseDialog( string parameter )
  594. {
  595. ButtonResult result = ButtonResult.None;
  596. if ( parameter?.ToLower() == "true" )
  597. result = ButtonResult.OK;
  598. else if ( parameter?.ToLower() == "false" )
  599. result = ButtonResult.Cancel;
  600. RaiseRequestClose( new DialogResult( result ) );
  601. }
  602. public virtual void RaiseRequestClose( IDialogResult dialogResult )
  603. {
  604. RequestClose?.Invoke( dialogResult );
  605. }
  606. #endregion
  607. }
  608. }