|
|
@@ -22,6 +22,7 @@ using VehicleControlSystem.ControlLayer.IO;
|
|
|
using VehicleControlSystem.ControlLayer.Serial.BatteryTabos;
|
|
|
using VehicleControlSystem.ControlLayer.Serial.DataModel;
|
|
|
using VehicleControlSystem.Managers;
|
|
|
+using static VehicleControlSystem.ControlLayer.Drive.GSIDrive;
|
|
|
|
|
|
namespace VehicleControlSystem.ControlLayer
|
|
|
{
|
|
|
@@ -328,6 +329,7 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
this.iO.OnChangedIO += IO_OnChangedIO;
|
|
|
this.sql = sqliteManager;
|
|
|
this.autoManager = auto;
|
|
|
+ this.autoManager.OnOperationModeChanged += AutoManager_OnOperationModeChanged;
|
|
|
|
|
|
this.obstacleBitList.AddRange( new string[]
|
|
|
{
|
|
|
@@ -348,6 +350,7 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
this.eventAggregator.GetEvent<ObstacleControlPubSubEvent>().Subscribe( ObstacleReceiveEvent );
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private void ObstacleReceiveEvent( ObstacleControlEventArgs obj )
|
|
|
{
|
|
|
if ( this.autoManager.OperationModeProperty != eOperatationMode.ManualMode )
|
|
|
@@ -599,12 +602,14 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
|
|
|
void ReqJog( DriveControlEventArgs _args )
|
|
|
{
|
|
|
- var drive = string.Empty;
|
|
|
-
|
|
|
if ( _args.JogDir == DriveControlEventArgs.eJogMoveDir.Positive )
|
|
|
- drive = "POSITIVE";
|
|
|
+ {
|
|
|
+ this.drive.JogForWard();
|
|
|
+ }
|
|
|
else
|
|
|
- drive = "NEGATIVE";
|
|
|
+ {
|
|
|
+ this.drive.JogBackward();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void ReqCurrentPos()
|
|
|
@@ -810,6 +815,8 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
|
|
|
this.taskMoveCancel.Add( CheckCrossPoint() );
|
|
|
|
|
|
+ PhysicalCheckupLogger.Instance.SetPLCStartDrive();
|
|
|
+ this.VehicleStateProperty = eVehicleState.Move;
|
|
|
//this.BuzzerOnOff(true, eBuzzerKind.Moving);
|
|
|
this.drive.MoveToPoint( pointID, 100 );
|
|
|
|
|
|
@@ -819,11 +826,13 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
this.taskMoveCancel.Cancel();
|
|
|
this.taskMoveCancel.WaitAll();
|
|
|
|
|
|
+ //Drive 에서 정지 확인 후 상태 변경
|
|
|
if ( drive.IsStop )
|
|
|
{
|
|
|
this.IsMoving = false;
|
|
|
this.OnMoveFinish?.Invoke();
|
|
|
|
|
|
+ PhysicalCheckupLogger.Instance.ResetPLCStartDrive();
|
|
|
this.VehicleStateProperty = eVehicleState.Idle;
|
|
|
}
|
|
|
|
|
|
@@ -919,12 +928,14 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
return false; //Alarm
|
|
|
}
|
|
|
|
|
|
- int result = this.clamp.Unlock_Sync();
|
|
|
- if ( result != 0 )
|
|
|
- {
|
|
|
- this.OccurVehicleAlarm( result );
|
|
|
- return false;
|
|
|
- }
|
|
|
+ //PIO 내부로 이동.
|
|
|
+ //int result = this.clamp.Unlock_Sync();
|
|
|
+ //if ( result != 0 )
|
|
|
+ //{
|
|
|
+ // this.OccurVehicleAlarm( result );
|
|
|
+ // return false;
|
|
|
+ //}
|
|
|
+ int result = 0;
|
|
|
|
|
|
this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
|
|
|
result = this.PIOAndLoad( sub.TargetID );
|
|
|
@@ -936,12 +947,13 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
}
|
|
|
this.iO.OutputOn( "OUT_PIO_SENSOR_ONOFF" );
|
|
|
|
|
|
- result = this.clamp.Lock_Sync();
|
|
|
- if ( result != 0 )
|
|
|
- {
|
|
|
- this.OccurVehicleAlarm( result );
|
|
|
- return false;
|
|
|
- }
|
|
|
+ //PIO 내부 이동.
|
|
|
+ //result = this.clamp.Lock_Sync();
|
|
|
+ //if ( result != 0 )
|
|
|
+ //{
|
|
|
+ // this.OccurVehicleAlarm( result );
|
|
|
+ // return false;
|
|
|
+ //}
|
|
|
|
|
|
//Load, Unload 가 끝나면 메인 Command 를 완료 했다고 판단.
|
|
|
sql.CommandDAL.UpdateState( sub.CmdID, eCommandState.Complete );
|
|
|
@@ -964,15 +976,17 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
return false; //Alarm
|
|
|
}
|
|
|
|
|
|
- int result = this.clamp.Unlock_Sync();
|
|
|
- if ( result != 0 )
|
|
|
- {
|
|
|
- this.OccurVehicleAlarm( result );
|
|
|
- return false;
|
|
|
- }
|
|
|
+ //PIO 내부로 이동.
|
|
|
+ //int result = this.clamp.Unlock_Sync();
|
|
|
+ //if ( result != 0 )
|
|
|
+ //{
|
|
|
+ // this.OccurVehicleAlarm( result );
|
|
|
+ // return false;
|
|
|
+ //}
|
|
|
|
|
|
this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
|
|
|
|
|
|
+ int result = 0;
|
|
|
result = this.PIOAndUnload( sub.TargetID );
|
|
|
if ( result != 0 )
|
|
|
{
|
|
|
@@ -1080,31 +1094,140 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+ public bool IsCharging { get; set; } = true;
|
|
|
+ public void ManualBatteryCharge()
|
|
|
+ {
|
|
|
+ this.VehicleStateProperty = eVehicleState.Charge;
|
|
|
+
|
|
|
+ var pioTimeout = sql.ConfigDal.GetValueToInt( ConstString.PIOTimeOut );
|
|
|
+
|
|
|
+ PIOClear();
|
|
|
+ if ( !this.iO.IsOn( "IN_PIO_READY" ) )
|
|
|
+ {
|
|
|
+ loggerPIO.E( "[Port] - 1 Ready not On" );
|
|
|
+ this.OccurVehicleAlarm( 25 );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.iO.WriteOutputIO( "OUT_PIO_READY", true );
|
|
|
+ loggerPIO.I( "[Vehicle] - 1 Ready On" );
|
|
|
+
|
|
|
+ if ( !this.iO.WaitChangeInputIO( true, pioTimeout, "IN_PIO_RECEIVE_RUN" ) )
|
|
|
+ {
|
|
|
+ PIOClear();
|
|
|
+ loggerPIO.E( "[Port] - 2 Receive CV Run Timeout" );
|
|
|
+ this.OccurVehicleAlarm( 26 );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.iO.WriteOutputIO( "OUT_PIO_SENDING_RUN", true );
|
|
|
+ loggerPIO.I( "[Vehicle] - 2 Send Run On" );
|
|
|
+
|
|
|
+ var sTime = SwUtils.CurrentTimeMillis;
|
|
|
+ while ( true )
|
|
|
+ {
|
|
|
+ LockUtils.Wait( 10 );
|
|
|
+
|
|
|
+ if ( !this.iO.IsOn( "IN_PIO_READY" ) || this.iO.IsOn( "IN_PIO_RECEIVE_RUN" ) )
|
|
|
+ break;
|
|
|
+
|
|
|
+ if ( !this.IsCharging )
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ this.IsCharging = true;
|
|
|
+
|
|
|
+ if ( !this.iO.WaitChangeInputIO( true, pioTimeout, "IN_PIO_RECEIVE_COMPLITE" ) )
|
|
|
+ {
|
|
|
+ PIOClear();
|
|
|
+ loggerPIO.E( "[Port] - 3 Receive Complete Timeout" );
|
|
|
+ this.OccurVehicleAlarm( 26 );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ PIOClear();
|
|
|
+
|
|
|
+ this.iO.WriteOutputIO( "OUT_PIO_SEND_COMPLITE", true );
|
|
|
+ Thread.Sleep( 1000 );
|
|
|
+ this.iO.WriteOutputIO( "OUT_PIO_SEND_COMPLITE", false );
|
|
|
+
|
|
|
+ this.VehicleStateProperty = eVehicleState.Idle;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void StartBatteryCharge()
|
|
|
+ {
|
|
|
+ var pioTimeout = sql.ConfigDal.GetValueToInt( ConstString.PIOTimeOut );
|
|
|
+
|
|
|
+ PIOClear();
|
|
|
+ loggerPIO.I( $"Start Battery Charge PIO" );
|
|
|
+
|
|
|
+ this.iO.WriteOutputIO( "OUT_PIO_RECEIVABLE", true );
|
|
|
+ loggerPIO.I( "[Vehicle] - 4 Receivable" );
|
|
|
+
|
|
|
+ if ( !this.iO.WaitChangeInputIO( true, pioTimeout, "IN_PIO_SENDABLE" ) )
|
|
|
+ {
|
|
|
+ PIOClear();
|
|
|
+ loggerPIO.E( "[Port] - 4 Ready Time Out" );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ loggerPIO.E( "[Port] - 4 Ready On" );
|
|
|
+
|
|
|
+ this.iO.WriteOutputIO( "OUT_PIO_RECEIVE_RUN", true, 1000 ); //1Sec 이후 On
|
|
|
+ loggerPIO.I( "[Vehicle] - Conveyor Run" );
|
|
|
+ this.OnConveyorStart?.Invoke( true );
|
|
|
+
|
|
|
+ if ( !this.iO.WaitChangeInputIO( true, pioTimeout, "IN_PIO_SEND_RUN" ) )
|
|
|
+ {
|
|
|
+ PIOClear();
|
|
|
+ loggerPIO.E( "[Port] - 5 Sending Run Time Out" );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ loggerPIO.I( "[Port] - 5 Sending Run On" );
|
|
|
+
|
|
|
+ this.VehicleStateProperty = eVehicleState.Charge;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void StopBatteryCharge()
|
|
|
+ {
|
|
|
+ loggerPIO.I( $"Stop Battery Charge PIO" );
|
|
|
+
|
|
|
+ var pioTimeout = sql.ConfigDal.GetValueToInt( ConstString.PIOTimeOut );
|
|
|
+
|
|
|
+ this.PIOClear();
|
|
|
+
|
|
|
+ this.iO.WriteOutputIO( "OUT_PIO_RECIVE_COMPLITE", true );
|
|
|
+ loggerPIO.I( "[Vehicle] Receive Complete On" );
|
|
|
+ if ( !this.iO.WaitChangeInputIO( true, pioTimeout, "IN_PIO_SEND_COMPLITE" ) )
|
|
|
+ {
|
|
|
+ this.iO.WriteOutputIO( "OUT_PIO_RECIVE_COMPLITE", false );
|
|
|
+ loggerPIO.E( "[Port] IN_PIO_SEND_COMPLITE On Time Out" );
|
|
|
+ }
|
|
|
+ loggerPIO.I( "[Port] Send Complete On" );
|
|
|
+
|
|
|
+ this.iO.WriteOutputIO( "OUT_PIO_RECIVE_COMPLITE", false, 1000 );
|
|
|
+
|
|
|
+ this.VehicleStateProperty = eVehicleState.Idle;
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region Check Method
|
|
|
bool CheckObstacle()
|
|
|
{
|
|
|
- //if ( this.iO.IsOn( "IN_OBSTRUCTION_DETECT_SAFETY" ) || this.iO.IsOn( "IN_OBSTRUCTION_DETECT_ERROR" ) )
|
|
|
- //{
|
|
|
- // this.ObstacleStateProperty = eObstacleState.Abnormal;
|
|
|
- // this.motion.SetObstacleState( this.ObstacleStateProperty );
|
|
|
- // return true;
|
|
|
- //}
|
|
|
+ if ( this.iO.IsOn( "IN_OBSTRUCTION_DETECT_SAFETY" ) || this.iO.IsOn( "IN_OBSTRUCTION_DETECT_ERROR" ) )
|
|
|
+ {
|
|
|
+ this.ObstacleStateProperty = eObstacleState.Abnormal;
|
|
|
+ this.OccurVehicleAlarm( 9999 );
|
|
|
+ }
|
|
|
|
|
|
- //if ( this.iO.IsOn( "IN_OBSTRUCTION_DETECT_STOP" ) )
|
|
|
- //{
|
|
|
- // this.ObstacleStateProperty = eObstacleState.Blocked;
|
|
|
- // this.motion.SetObstacleState( this.ObstacleStateProperty );
|
|
|
- // return true;
|
|
|
- //}
|
|
|
+ if ( this.iO.IsOn( "IN_OBSTRUCTION_DETECT_STOP" ) )
|
|
|
+ {
|
|
|
+ this.ObstacleStateProperty = eObstacleState.Blocked;
|
|
|
+ }
|
|
|
|
|
|
- //if ( this.iO.IsOn( "IN_OBSTRUCTION_DETECT_SLOW" ) )
|
|
|
- //{
|
|
|
- // this.ObstacleStateProperty = eObstacleState.Decelerate;
|
|
|
- // this.motion.SetObstacleState( this.ObstacleStateProperty );
|
|
|
- // return true;
|
|
|
- //}
|
|
|
+ if ( this.iO.IsOn( "IN_OBSTRUCTION_DETECT_SLOW" ) )
|
|
|
+ {
|
|
|
+ this.ObstacleStateProperty = eObstacleState.Decelerate;
|
|
|
+ }
|
|
|
|
|
|
this.ObstacleStateProperty = eObstacleState.Normal;
|
|
|
this.drive.SetObstacleState( this.ObstacleStateProperty );
|
|
|
@@ -1129,6 +1252,11 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
|
|
|
#region Mechanical Method
|
|
|
|
|
|
+ #region Drive
|
|
|
+ public void DriveServoOff() => this.drive.ServoOff();
|
|
|
+ public void DriveServoOn() => this.drive.ServoOn();
|
|
|
+ #endregion
|
|
|
+
|
|
|
#region Conveyor
|
|
|
|
|
|
public int ConveyorLoad() => this.conveyor.ConveyorLoad();
|
|
|
@@ -1162,6 +1290,14 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
Thread.Sleep( 1000 );
|
|
|
this.OnLoadComplete?.Invoke();
|
|
|
#else
|
|
|
+
|
|
|
+ int result = this.clamp.Unlock_Sync();
|
|
|
+ if ( result != 0 )
|
|
|
+ {
|
|
|
+ this.OccurVehicleAlarm( result );
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
var pioTimeout = sql.ConfigDal.GetValueToInt( ConstString.PIOTimeOut );
|
|
|
|
|
|
if ( this.conveyor.IsInverterError() )
|
|
|
@@ -1274,6 +1410,12 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
|
|
|
loggerPIO.I( $"End Load PIO - [{targetName}]" );
|
|
|
#endif
|
|
|
+ result = this.clamp.Lock_Sync();
|
|
|
+ if ( result != 0 )
|
|
|
+ {
|
|
|
+ this.OccurVehicleAlarm( result );
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -1294,13 +1436,21 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
this.OnConveyorStart?.Invoke( false );
|
|
|
|
|
|
Thread.Sleep( 10000 );
|
|
|
- this.OnOffConveyor( false ); //Stop
|
|
|
+ this.conveyor.OnOffConveyor( false ); //Stop
|
|
|
this.OnConveyorStop?.Invoke( false );
|
|
|
PIOClear();
|
|
|
|
|
|
Thread.Sleep( 1000 );
|
|
|
this.OnUnloadComplete?.Invoke();
|
|
|
#else
|
|
|
+
|
|
|
+ int result = this.clamp.Unlock_Sync();
|
|
|
+ if ( result != 0 )
|
|
|
+ {
|
|
|
+ this.OccurVehicleAlarm( result );
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
var pioTimeout = sql.ConfigDal.GetValueToInt( ConstString.PIOTimeOut );
|
|
|
|
|
|
if ( this.conveyor.IsInverterError() )
|
|
|
@@ -1595,51 +1745,71 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
#endregion
|
|
|
|
|
|
#region Event Subscribe
|
|
|
+ private void AutoManager_OnOperationModeChanged( eOperatationMode obj )
|
|
|
+ {
|
|
|
+ this.drive.SetDriveOperationMode( obj );
|
|
|
+ }
|
|
|
+
|
|
|
private void Motion_PropertyChanged( object sender, System.ComponentModel.PropertyChangedEventArgs e )
|
|
|
{
|
|
|
var property = sender.GetType().GetProperty( e.PropertyName );
|
|
|
var newValue = property.GetValue( sender, null );
|
|
|
|
|
|
- if ( e.PropertyName.Equals( "CurrentPos" ) )
|
|
|
+ switch ( e.PropertyName )
|
|
|
{
|
|
|
- var v = CastTo<double>.From<object>( newValue );
|
|
|
- this.CurrentPosition = v;
|
|
|
- }
|
|
|
-
|
|
|
- if ( e.PropertyName.Equals( "CurrentTag" ) )
|
|
|
- {
|
|
|
- var v = CastTo<string>.From<object>( newValue );
|
|
|
- this.CurrentTag = v;
|
|
|
- }
|
|
|
-
|
|
|
- if ( e.PropertyName.Equals( "CurrentSpeed" ) )
|
|
|
- {
|
|
|
- var v = CastTo<double>.From<object>( newValue );
|
|
|
- this.CurrentSpeed = v;
|
|
|
- }
|
|
|
-
|
|
|
- if ( e.PropertyName.Equals( "CurrentTorque" ) )
|
|
|
- {
|
|
|
- var v = CastTo<double>.From<object>( newValue );
|
|
|
- this.CurrentTorque = v;
|
|
|
- }
|
|
|
-
|
|
|
- if ( e.PropertyName.Equals( "ReqSteeringState" ) )
|
|
|
- {
|
|
|
- var v = CastTo<eSteeringState>.From<object>( newValue );
|
|
|
- switch ( v )
|
|
|
- {
|
|
|
- case eSteeringState.None:
|
|
|
- break;
|
|
|
- case eSteeringState.Left:
|
|
|
- this.steering.ControlSteering(true);
|
|
|
- break;
|
|
|
- case eSteeringState.Right:
|
|
|
- this.steering.ControlSteering();
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
+ case "CurrentPos":
|
|
|
+ {
|
|
|
+ var v = CastTo<double>.From<object>( newValue );
|
|
|
+ this.CurrentPosition = v;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "CurrentTag":
|
|
|
+ {
|
|
|
+ var v = CastTo<string>.From<object>( newValue );
|
|
|
+ this.CurrentTag = v;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "CurrentSpeed":
|
|
|
+ {
|
|
|
+ var v = CastTo<double>.From<object>( newValue );
|
|
|
+ this.CurrentSpeed = v;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "CurrentTorque":
|
|
|
+ {
|
|
|
+ var v = CastTo<double>.From<object>( newValue );
|
|
|
+ this.CurrentTorque = v;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "ReqSteeringState":
|
|
|
+ {
|
|
|
+ var v = CastTo<eSteeringState>.From<object>( newValue );
|
|
|
+ switch ( v )
|
|
|
+ {
|
|
|
+ case eSteeringState.None:
|
|
|
+ break;
|
|
|
+ case eSteeringState.Left:
|
|
|
+ this.steering.ControlSteering( true );
|
|
|
+ break;
|
|
|
+ case eSteeringState.Right:
|
|
|
+ this.steering.ControlSteering();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "DriveServoState":
|
|
|
+ {
|
|
|
+ var v = CastTo<eDriveServoState>.From<object>( newValue );
|
|
|
+ if ( v == eDriveServoState.ServoOn )
|
|
|
+ this.iO.OutputOn( "OUT_DRIVE_BRAKE_OFF" );
|
|
|
+ else
|
|
|
+ this.iO.OutputOff( "OUT_DRIVE_BRAKE_OFF" );
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1697,6 +1867,7 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
#endregion
|
|
|
}
|
|
|
}
|