|
|
@@ -1,11 +1,13 @@
|
|
|
using OHV.Common.Events;
|
|
|
using OHV.Common.Shareds;
|
|
|
+using OHV.SqliteDAL;
|
|
|
using Prism.Commands;
|
|
|
using Prism.Events;
|
|
|
using Prism.Mvvm;
|
|
|
using Prism.Services.Dialogs;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Drawing;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
@@ -17,7 +19,7 @@ namespace OHV.Module.Interactivity.PopUp
|
|
|
{
|
|
|
private DelegateCommand<string> _closeDialogCommand;
|
|
|
public DelegateCommand<string> CloseDialogCommand =>
|
|
|
- _closeDialogCommand ?? (_closeDialogCommand = new DelegateCommand<string>(CloseDialog));
|
|
|
+ _closeDialogCommand ?? ( _closeDialogCommand = new DelegateCommand<string>( CloseDialog ) );
|
|
|
|
|
|
private string _title = "LockServoView";
|
|
|
public string Title
|
|
|
@@ -25,7 +27,7 @@ namespace OHV.Module.Interactivity.PopUp
|
|
|
get { return this._title; }
|
|
|
set
|
|
|
{
|
|
|
- this.SetProperty(ref this._title, value);
|
|
|
+ this.SetProperty( ref this._title , value );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -33,7 +35,7 @@ namespace OHV.Module.Interactivity.PopUp
|
|
|
public string SelectAxis
|
|
|
{
|
|
|
get => this._selectAxis;
|
|
|
- set { this.SetProperty(ref this._selectAxis, value); }
|
|
|
+ set { this.SetProperty( ref this._selectAxis , value ); }
|
|
|
}
|
|
|
|
|
|
private string _selectedPosition = string.Empty;
|
|
|
@@ -42,7 +44,7 @@ namespace OHV.Module.Interactivity.PopUp
|
|
|
get => this._selectedPosition;
|
|
|
set
|
|
|
{
|
|
|
- this.SetProperty(ref this._selectedPosition, value);
|
|
|
+ this.SetProperty( ref this._selectedPosition , value );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -51,21 +53,21 @@ namespace OHV.Module.Interactivity.PopUp
|
|
|
public double TargetPosLockLeft
|
|
|
{
|
|
|
get { return this._targetPosLockLeft; }
|
|
|
- set { this.SetProperty(ref this._targetPosLockLeft, value); }
|
|
|
+ set { this.SetProperty( ref this._targetPosLockLeft , value ); }
|
|
|
}
|
|
|
|
|
|
private double _currentLockLeft;
|
|
|
public double CurrentLockLeft
|
|
|
{
|
|
|
get { return this._currentLockLeft; }
|
|
|
- set { this.SetProperty(ref this._currentLockLeft, value); }
|
|
|
+ set { this.SetProperty( ref this._currentLockLeft , value ); }
|
|
|
}
|
|
|
|
|
|
private double _differenceLockLeft;
|
|
|
public double DifferenceLockLeft
|
|
|
{
|
|
|
get { return this._differenceLockLeft; }
|
|
|
- set { this.SetProperty(ref this._differenceLockLeft, value); }
|
|
|
+ set { this.SetProperty( ref this._differenceLockLeft , value ); }
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
@@ -74,24 +76,30 @@ namespace OHV.Module.Interactivity.PopUp
|
|
|
public double TargetPosLockRight
|
|
|
{
|
|
|
get { return this._targetPosLockRight; }
|
|
|
- set { this.SetProperty(ref this._targetPosLockRight, value); }
|
|
|
+ set { this.SetProperty( ref this._targetPosLockRight , value ); }
|
|
|
}
|
|
|
|
|
|
private double _currentLockRight;
|
|
|
public double CurrentLockRight
|
|
|
{
|
|
|
get { return this._currentLockRight; }
|
|
|
- set { this.SetProperty(ref this._currentLockRight, value); }
|
|
|
+ set { this.SetProperty( ref this._currentLockRight , value ); }
|
|
|
}
|
|
|
|
|
|
private double _differenceLockRight;
|
|
|
public double DifferenceLockRight
|
|
|
{
|
|
|
get { return this._differenceLockRight; }
|
|
|
- set { this.SetProperty(ref this._differenceLockRight, value); }
|
|
|
+ set { this.SetProperty( ref this._differenceLockRight , value ); }
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
+ Brush _selectControl = Brushes.Gray;
|
|
|
+ public Brush SelectControl
|
|
|
+ {
|
|
|
+ get { return this._selectControl; }
|
|
|
+ set { SetProperty( ref this._selectControl , value ); }
|
|
|
+ }
|
|
|
|
|
|
public ICommand SelectAxisCommand { get; set; }
|
|
|
public ICommand KeyInTargetPosCommand { get; set; }
|
|
|
@@ -109,84 +117,105 @@ namespace OHV.Module.Interactivity.PopUp
|
|
|
|
|
|
IEventAggregator eventAggregator;
|
|
|
MessageController messageController;
|
|
|
+ SqliteManager sql;
|
|
|
|
|
|
- public LockServoViewModel(IEventAggregator ea, MessageController _messageController )
|
|
|
+ public LockServoViewModel( IEventAggregator ea , MessageController _messageController , SqliteManager _sql )
|
|
|
{
|
|
|
- this.SelectAxisCommand = new DelegateCommand<object>(ExecuteSelectAxisCommand);
|
|
|
- this.SelectPosCommand = new DelegateCommand<object>(ExecuteSelectPosCommand);
|
|
|
- this.MoveToCommand = new DelegateCommand(ExecuteMoveToCommand);
|
|
|
- this.CurrentToTargetCommand = new DelegateCommand(ExecuteCurrentToTargetCommand);
|
|
|
- this.KeyInTargetPosCommand = new DelegateCommand<object>(ExecuteKeyInCommand);
|
|
|
-
|
|
|
- this.ServoOnCommand = new DelegateCommand(ExecuteServoOnCommand);
|
|
|
- this.ServoOffCommand = new DelegateCommand(ExecuteServoOffCommand);
|
|
|
- this.FaultResetCommand = new DelegateCommand(ExecuteFaultResetCommand);
|
|
|
- this.OriginCommand = new DelegateCommand(ExecuteOriginCommand);
|
|
|
+ this.SelectAxisCommand = new DelegateCommand<object>( ExecuteSelectAxisCommand );
|
|
|
+ this.SelectPosCommand = new DelegateCommand<object>( ExecuteSelectPosCommand );
|
|
|
+ this.MoveToCommand = new DelegateCommand( ExecuteMoveToCommand );
|
|
|
+ this.CurrentToTargetCommand = new DelegateCommand( ExecuteCurrentToTargetCommand );
|
|
|
+ this.KeyInTargetPosCommand = new DelegateCommand<object>( ExecuteKeyInCommand );
|
|
|
+
|
|
|
+ this.ServoOnCommand = new DelegateCommand<object>( ExecuteServoOnCommand );
|
|
|
+ this.ServoOffCommand = new DelegateCommand<object>( ExecuteServoOffCommand );
|
|
|
+ this.FaultResetCommand = new DelegateCommand<object>( ExecuteFaultResetCommand );
|
|
|
+ this.OriginCommand = new DelegateCommand<object>( ExecuteOriginCommand );
|
|
|
this.SelectedPosDataSave = new DelegateCommand<object>( ExecuteSelectedPosDataSave );
|
|
|
|
|
|
- this.JogCommand = new DelegateCommand<object>(ExecuteJogCommand);
|
|
|
+ this.JogCommand = new DelegateCommand<object>( ExecuteJogCommand );
|
|
|
|
|
|
this.eventAggregator = ea;
|
|
|
- this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Unsubscribe(UICallbackCommunication);
|
|
|
- this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Subscribe(UICallbackCommunication, ThreadOption.UIThread);
|
|
|
+ this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Unsubscribe( UICallbackCommunication );
|
|
|
+ this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Subscribe( UICallbackCommunication , ThreadOption.UIThread );
|
|
|
|
|
|
this.messageController = _messageController;
|
|
|
+
|
|
|
+ this.sql = _sql;
|
|
|
}
|
|
|
|
|
|
private void ExecuteSelectedPosDataSave( object obj )
|
|
|
{
|
|
|
- // save data Send
|
|
|
- // currentPos, posName ,AxisName
|
|
|
- string axis = string.Empty;
|
|
|
- double currentPos;
|
|
|
+ List<Common.Model.AxisPositionData> dataList = null;
|
|
|
|
|
|
this.messageController.ShowConfirmationPopupView( "Position Data Save ?" , r =>
|
|
|
{
|
|
|
if ( r.Result == ButtonResult.OK )
|
|
|
{
|
|
|
- switch(this.SelectAxis )
|
|
|
+ if ( this.SelectAxis == ConstString.AXIS_CARRIER_LOCK_LEFT )
|
|
|
+ {
|
|
|
+ switch ( this.SelectedPosition )
|
|
|
+ {
|
|
|
+ case ConstString.TEACH_POSITION_LOCK:
|
|
|
+ dataList = sql.AxisPositionDataDAL.GetKFromPostion( ConstString.TEACH_POSITION_LOCK );
|
|
|
+ break;
|
|
|
+ case ConstString.TEACH_POSITION_UNLOCK:
|
|
|
+ dataList = sql.AxisPositionDataDAL.GetKFromPostion( ConstString.TEACH_POSITION_UNLOCK );
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ var sqlAxisLeft = dataList.Where( x => x.AxisName.Equals( ConstString.AXIS_CARRIER_LOCK_LEFT ) ).Single();
|
|
|
+ sqlAxisLeft.Value = this.CurrentLockLeft;
|
|
|
+ sql.AxisPositionDataDAL.Update( sqlAxisLeft );
|
|
|
+ }
|
|
|
+ else if ( this.SelectAxis == ConstString.AXIS_CARRIER_LOCK_RIGHT )
|
|
|
{
|
|
|
- case ConstString.AXIS_CARRIER_LOCK_LEFT:
|
|
|
- axis = ConstString.AXIS_CARRIER_LOCK_LEFT;
|
|
|
- currentPos = this.CurrentLockLeft;
|
|
|
- break;
|
|
|
- case ConstString.AXIS_CARRIER_LOCK_RIGHT:
|
|
|
- axis = ConstString.AXIS_CARRIER_LOCK_RIGHT;
|
|
|
- currentPos = this.CurrentLockRight;
|
|
|
- break;
|
|
|
+ switch ( this.SelectedPosition )
|
|
|
+ {
|
|
|
+ case ConstString.TEACH_POSITION_LOCK:
|
|
|
+ dataList = sql.AxisPositionDataDAL.GetKFromPostion( ConstString.TEACH_POSITION_LOCK );
|
|
|
+ break;
|
|
|
+ case ConstString.TEACH_POSITION_UNLOCK:
|
|
|
+ dataList = sql.AxisPositionDataDAL.GetKFromPostion( ConstString.TEACH_POSITION_UNLOCK );
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ var sqlAxisRight = dataList.Where( x => x.AxisName.Equals( ConstString.AXIS_CARRIER_LOCK_RIGHT ) ).Single();
|
|
|
+ sqlAxisRight.Value = this.CurrentLockLeft;
|
|
|
+ sql.AxisPositionDataDAL.Update( sqlAxisRight );
|
|
|
}
|
|
|
- //Publish( currentPos , this.SelectedPosition , axis );
|
|
|
+ else
|
|
|
+ { }
|
|
|
}
|
|
|
} );
|
|
|
}
|
|
|
|
|
|
- private void ExecuteJogCommand(object obj)
|
|
|
+ private void ExecuteJogCommand( object obj )
|
|
|
{
|
|
|
var msg = new AxisControlEventArgs
|
|
|
{
|
|
|
- Dir = AxisControlEventArgs.eEventDir.ToBack,
|
|
|
- Kind = AxisControlEventArgs.eAxisControlKind.Jog,
|
|
|
- AxisName = this.SelectAxis,
|
|
|
+ Dir = AxisControlEventArgs.eEventDir.ToBack ,
|
|
|
+ Kind = AxisControlEventArgs.eAxisControlKind.Jog ,
|
|
|
+ AxisName = this.SelectAxis ,
|
|
|
};
|
|
|
|
|
|
- if (obj.ToString().Equals("+"))
|
|
|
+ if ( obj.ToString().Equals( "+" ) )
|
|
|
msg.JogDir = AxisControlEventArgs.eJogMoveDir.Positive;
|
|
|
else
|
|
|
msg.JogDir = AxisControlEventArgs.eJogMoveDir.Negative;
|
|
|
|
|
|
- this.PublishEvent(msg);
|
|
|
+ this.PublishEvent( msg );
|
|
|
}
|
|
|
|
|
|
- void PublishEvent(AxisControlEventArgs args)
|
|
|
+ void PublishEvent( AxisControlEventArgs args )
|
|
|
{
|
|
|
- this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish(args);
|
|
|
+ this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish( args );
|
|
|
}
|
|
|
|
|
|
- void UICallbackCommunication(AxisControlEventArgs args)
|
|
|
+ void UICallbackCommunication( AxisControlEventArgs args )
|
|
|
{
|
|
|
- if (args.Dir == AxisControlEventArgs.eEventDir.ToFront)
|
|
|
+ if ( args.Dir == AxisControlEventArgs.eEventDir.ToFront )
|
|
|
{
|
|
|
- switch (args.Kind)
|
|
|
+ switch ( args.Kind )
|
|
|
{
|
|
|
case AxisControlEventArgs.eAxisControlKind.Stop:
|
|
|
break;
|
|
|
@@ -197,7 +226,7 @@ namespace OHV.Module.Interactivity.PopUp
|
|
|
case AxisControlEventArgs.eAxisControlKind.Jog:
|
|
|
break;
|
|
|
case AxisControlEventArgs.eAxisControlKind.CurrentPosition:
|
|
|
- if (args.AxisName.Equals(ConstString.AXIS_CARRIER_LOCK_LEFT))
|
|
|
+ if ( args.AxisName.Equals( ConstString.AXIS_CARRIER_LOCK_LEFT ) )
|
|
|
this.CurrentLockLeft = args.CurrentPosition;
|
|
|
else
|
|
|
this.CurrentLockRight = args.CurrentPosition;
|
|
|
@@ -212,57 +241,113 @@ namespace OHV.Module.Interactivity.PopUp
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void ExecuteOriginCommand()
|
|
|
+ private void ExecuteOriginCommand( object obj )
|
|
|
{
|
|
|
- }
|
|
|
+ var msg = new AxisControlEventArgs
|
|
|
+ {
|
|
|
+ Dir = AxisControlEventArgs.eEventDir.ToBack ,
|
|
|
+ Kind = AxisControlEventArgs.eAxisControlKind.OriginReturn ,
|
|
|
+ AxisName = this.SelectAxis ,
|
|
|
+ };
|
|
|
|
|
|
- private void ExecuteFaultResetCommand()
|
|
|
+ if ( obj.ToString().Equals( "Left" ) )
|
|
|
+ msg.Axis = AxisControlEventArgs.eAxises.LEFT;
|
|
|
+ else
|
|
|
+ msg.Axis = AxisControlEventArgs.eAxises.RIGHT;
|
|
|
+
|
|
|
+ this.PublishEvent( msg );
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ExecuteFaultResetCommand( object obj )
|
|
|
{
|
|
|
+ var msg = new AxisControlEventArgs
|
|
|
+ {
|
|
|
+ Dir = AxisControlEventArgs.eEventDir.ToBack ,
|
|
|
+ Kind = AxisControlEventArgs.eAxisControlKind.FaultReset ,
|
|
|
+ AxisName = this.SelectAxis ,
|
|
|
+ };
|
|
|
+
|
|
|
+ if ( obj.ToString().Equals( "Left" ) )
|
|
|
+ msg.Axis = AxisControlEventArgs.eAxises.LEFT;
|
|
|
+ else
|
|
|
+ msg.Axis = AxisControlEventArgs.eAxises.RIGHT;
|
|
|
+
|
|
|
+ this.PublishEvent( msg );
|
|
|
}
|
|
|
|
|
|
- private void ExecuteServoOffCommand()
|
|
|
+ private void ExecuteServoOffCommand( object obj )
|
|
|
{
|
|
|
+ //TODO: lib direct 사용할지 ?
|
|
|
+
|
|
|
+ var msg = new AxisControlEventArgs
|
|
|
+ {
|
|
|
+ Dir = AxisControlEventArgs.eEventDir.ToBack ,
|
|
|
+ Kind = AxisControlEventArgs.eAxisControlKind.ServoOff ,
|
|
|
+ AxisName = this.SelectAxis ,
|
|
|
+ };
|
|
|
+
|
|
|
+ if ( obj.ToString().Equals( "Left" ) )
|
|
|
+ msg.Axis = AxisControlEventArgs.eAxises.LEFT;
|
|
|
+ else
|
|
|
+ msg.Axis = AxisControlEventArgs.eAxises.RIGHT;
|
|
|
+
|
|
|
+ this.PublishEvent( msg );
|
|
|
}
|
|
|
|
|
|
- private void ExecuteServoOnCommand()
|
|
|
+ private void ExecuteServoOnCommand( object obj )
|
|
|
{
|
|
|
+ //TODO: lib direct 사용할지 ? Event 처리할지 ?
|
|
|
+
|
|
|
+ var msg = new AxisControlEventArgs
|
|
|
+ {
|
|
|
+ Dir = AxisControlEventArgs.eEventDir.ToBack ,
|
|
|
+ Kind = AxisControlEventArgs.eAxisControlKind.ServoOn ,
|
|
|
+ AxisName = this.SelectAxis ,
|
|
|
+ };
|
|
|
+
|
|
|
+ if ( obj.ToString().Equals( "Left" ) )
|
|
|
+ msg.Axis = AxisControlEventArgs.eAxises.LEFT;
|
|
|
+ else
|
|
|
+ msg.Axis = AxisControlEventArgs.eAxises.RIGHT;
|
|
|
+
|
|
|
+ this.PublishEvent( msg );
|
|
|
}
|
|
|
|
|
|
- private void ExecuteKeyInCommand( object obj)
|
|
|
+ private void ExecuteKeyInCommand( object obj )
|
|
|
{
|
|
|
- if (obj.ToString().Equals("Left"))
|
|
|
+ if ( obj.ToString().Equals( "Left" ) )
|
|
|
{
|
|
|
var numPad = new CalcuratorView();
|
|
|
- var result = numPad.ShowDialog(this.TargetPosLockLeft);
|
|
|
+ var result = numPad.ShowDialog( this.TargetPosLockLeft );
|
|
|
this.TargetPosLockLeft = result;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var numPad = new CalcuratorView();
|
|
|
- var result = numPad.ShowDialog(this.TargetPosLockRight);
|
|
|
+ var result = numPad.ShowDialog( this.TargetPosLockRight );
|
|
|
this.TargetPosLockRight = result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void ExecuteCurrentToTargetCommand()
|
|
|
+ private void ExecuteCurrentToTargetCommand( )
|
|
|
{
|
|
|
this.TargetPosLockLeft = this.CurrentLockLeft;
|
|
|
this.TargetPosLockRight = this.CurrentLockRight;
|
|
|
}
|
|
|
|
|
|
- private async void ExecuteMoveToCommand()
|
|
|
+ private async void ExecuteMoveToCommand( )
|
|
|
{
|
|
|
- await Task.Run(() =>
|
|
|
- {
|
|
|
- //Axis.Move(this.SelectPosition);
|
|
|
- });
|
|
|
+ await Task.Run( ( ) =>
|
|
|
+ {
|
|
|
+ //Axis.Move(this.SelectPosition);
|
|
|
+ } );
|
|
|
}
|
|
|
|
|
|
- private void ExecuteSelectPosCommand(object obj)
|
|
|
+ private void ExecuteSelectPosCommand( object obj )
|
|
|
{
|
|
|
this.SelectedPosition = obj.ToString();
|
|
|
|
|
|
- switch (this.SelectedPosition)
|
|
|
+ switch ( this.SelectedPosition )
|
|
|
{
|
|
|
case "Lock":
|
|
|
break;
|
|
|
@@ -273,44 +358,44 @@ namespace OHV.Module.Interactivity.PopUp
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void ExecuteSelectAxisCommand(object obj)
|
|
|
+ private void ExecuteSelectAxisCommand( object obj )
|
|
|
{
|
|
|
this.SelectAxis = obj.ToString();
|
|
|
}
|
|
|
|
|
|
#region Dialog
|
|
|
- public bool CanCloseDialog()
|
|
|
+ public bool CanCloseDialog( )
|
|
|
{
|
|
|
//throw new NotImplementedException();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public void OnDialogClosed()
|
|
|
+ public void OnDialogClosed( )
|
|
|
{
|
|
|
- this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish(new AxisControlEventArgs { Dir = AxisControlEventArgs.eEventDir.ToBack, Kind = AxisControlEventArgs.eAxisControlKind.ReqStopCurrentPosition});
|
|
|
- this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Unsubscribe(UICallbackCommunication);
|
|
|
+ this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish( new AxisControlEventArgs { Dir = AxisControlEventArgs.eEventDir.ToBack , Kind = AxisControlEventArgs.eAxisControlKind.ReqStopCurrentPosition } );
|
|
|
+ this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Unsubscribe( UICallbackCommunication );
|
|
|
}
|
|
|
|
|
|
- public void OnDialogOpened(IDialogParameters parameters)
|
|
|
+ public void OnDialogOpened( IDialogParameters parameters )
|
|
|
{
|
|
|
- this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish(new AxisControlEventArgs { Dir = AxisControlEventArgs.eEventDir.ToBack, Kind = AxisControlEventArgs.eAxisControlKind.ReqCurrentPosition });
|
|
|
+ this.eventAggregator.GetEvent<AxisControlPubSubEvent>().Publish( new AxisControlEventArgs { Dir = AxisControlEventArgs.eEventDir.ToBack , Kind = AxisControlEventArgs.eAxisControlKind.ReqCurrentPosition } );
|
|
|
}
|
|
|
|
|
|
- public virtual void RaiseRequestClose(IDialogResult dialogResult)
|
|
|
+ public virtual void RaiseRequestClose( IDialogResult dialogResult )
|
|
|
{
|
|
|
- RequestClose?.Invoke(dialogResult);
|
|
|
+ RequestClose?.Invoke( dialogResult );
|
|
|
}
|
|
|
|
|
|
- private void CloseDialog(string parameter)
|
|
|
+ private void CloseDialog( string parameter )
|
|
|
{
|
|
|
ButtonResult result = ButtonResult.None;
|
|
|
|
|
|
- if (parameter?.ToLower() == "true")
|
|
|
+ if ( parameter?.ToLower() == "true" )
|
|
|
result = ButtonResult.OK;
|
|
|
- else if (parameter?.ToLower() == "false")
|
|
|
+ else if ( parameter?.ToLower() == "false" )
|
|
|
result = ButtonResult.Cancel;
|
|
|
|
|
|
- RaiseRequestClose(new DialogResult(result));
|
|
|
+ RaiseRequestClose( new DialogResult( result ) );
|
|
|
}
|
|
|
#endregion
|
|
|
}
|