|
|
@@ -227,6 +227,7 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
|
|
|
ThreadCancel cancel = new ThreadCancel();
|
|
|
TaskCancel taskCancel = new TaskCancel();
|
|
|
+ TaskCancel taskMoveCancel = new TaskCancel();
|
|
|
|
|
|
IEventAggregator eventAggregator;
|
|
|
|
|
|
@@ -641,6 +642,7 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
}
|
|
|
logger.D( "Vehicle - _ThSubCmdWorker Dispose" );
|
|
|
}
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region Control Action Method
|
|
|
@@ -653,18 +655,14 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
this.OccurVehicleAlarm( 23 );
|
|
|
}
|
|
|
|
|
|
+ #region For Moving
|
|
|
void Move( SubCmd sub )
|
|
|
{
|
|
|
if ( this.MoveTo( sub.TargetID ) )
|
|
|
{
|
|
|
- sql.SubCmdDAL.Delete( sub );
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if ( this.ObstacleStateProperty == eObstacleState.Blocked )
|
|
|
- {
|
|
|
- }
|
|
|
}
|
|
|
+
|
|
|
+ sql.SubCmdDAL.Delete( sub );
|
|
|
}
|
|
|
|
|
|
bool MoveTo( string pointID )
|
|
|
@@ -687,11 +685,21 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
this.OnMoving?.Invoke();
|
|
|
this.IsMoving = true;
|
|
|
|
|
|
+ //이전에 있던 작업들 종료 및 삭제
|
|
|
+ this.taskMoveCancel.Cancel();
|
|
|
+ this.taskMoveCancel.WaitAll();
|
|
|
+
|
|
|
+ this.taskMoveCancel.Add( CheckCrossPoint() );
|
|
|
+
|
|
|
//this.BuzzerOnOff(true, eBuzzerKind.Moving);
|
|
|
this.motion.MoveToPoint( pointID, 100 );
|
|
|
|
|
|
bool result = Wait4MoveDone();
|
|
|
//this.BuzzerOnOff(false);
|
|
|
+
|
|
|
+ this.taskMoveCancel.Cancel();
|
|
|
+ this.taskMoveCancel.WaitAll();
|
|
|
+
|
|
|
if ( motion.IsStop )
|
|
|
{
|
|
|
this.IsMoving = false;
|
|
|
@@ -755,6 +763,24 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ Task CheckCrossPoint()
|
|
|
+ {
|
|
|
+ var task = Task.Run( () =>
|
|
|
+ {
|
|
|
+ long sTime = SwUtils.CurrentTimeMillis;
|
|
|
+
|
|
|
+ while ( !this.taskMoveCancel.Canceled )
|
|
|
+ {
|
|
|
+ Thread.Sleep( 10 );
|
|
|
+
|
|
|
+ //ToDo: approach Cross Point Check
|
|
|
+ }
|
|
|
+ } );
|
|
|
+
|
|
|
+ return task;
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
public bool LoadCarrier( SubCmd sub )
|
|
|
{
|
|
|
this.VehicleStateProperty = eVehicleState.Load;
|
|
|
@@ -774,12 +800,15 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ this.iO.OutputOn( "OUT_PIO_SENSOR_ONOFF" );
|
|
|
result = this.PIOAndLoad( sub.TargetID );
|
|
|
if ( result != 0 )
|
|
|
{
|
|
|
+ this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
|
|
|
this.OccurVehicleAlarm( result );
|
|
|
return false;
|
|
|
}
|
|
|
+ this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
|
|
|
|
|
|
result = this.clamp.Lock_Sync();
|
|
|
if ( result != 0 )
|
|
|
@@ -816,12 +845,16 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ this.iO.OutputOn( "OUT_PIO_SENSOR_ONOFF" );
|
|
|
+
|
|
|
result = this.PIOAndUnload( sub.TargetID );
|
|
|
if ( result != 0 )
|
|
|
{
|
|
|
+ this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
|
|
|
this.OccurVehicleAlarm( result );
|
|
|
return false;
|
|
|
}
|
|
|
+ this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
|
|
|
|
|
|
sql.CommandDAL.UpdateState( sub.CmdID, eCommandState.Complete );
|
|
|
sql.SubCmdDAL.Delete( sub );
|
|
|
@@ -831,33 +864,48 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ private void BatteryCharge( SubCmd subCmd )
|
|
|
+ {
|
|
|
+ this.VehicleStateProperty = eVehicleState.Charge;
|
|
|
+
|
|
|
+ this.iO.OutputOn( "OUT_PIO_SENSOR_ONOFF" );
|
|
|
+
|
|
|
+ this.PIOBatteryCharge( subCmd );
|
|
|
+
|
|
|
+ this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
|
|
|
+
|
|
|
+ sql.CommandDAL.UpdateState( subCmd.CmdID, eCommandState.Complete );
|
|
|
+ sql.SubCmdDAL.Delete( subCmd );
|
|
|
+
|
|
|
+ this.VehicleStateProperty = eVehicleState.Idle;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Battery Charge
|
|
|
/// 충전 시 PIO 를 해야 함.
|
|
|
/// </summary>
|
|
|
/// <param name="sub"></param>
|
|
|
/// <returns></returns>
|
|
|
- public bool BatteryCharge( SubCmd sub )
|
|
|
+ public int PIOBatteryCharge( SubCmd sub )
|
|
|
{
|
|
|
var route = sql.RouteDal.GetRoute( sub.TargetID );
|
|
|
|
|
|
if ( !CorrectPosition( route, this.CurrentPosition ) )
|
|
|
{
|
|
|
this.OccurVehicleAlarm( 21 );
|
|
|
- return false; //Alarm
|
|
|
+ return 0; //Alarm
|
|
|
}
|
|
|
|
|
|
var pioTimeout = sql.ConfigDal.GetValueToInt( ConstString.PIOTimeOut );
|
|
|
|
|
|
PIOClear();
|
|
|
- loggerPIO.I( $"Start Unload PIO - [{sub.TargetID}]" );
|
|
|
- this.OnPIOStart?.Invoke( false );
|
|
|
-
|
|
|
+ loggerPIO.I( $"Start Charge PIO - [{sub.TargetID}]" );
|
|
|
if ( !this.iO.IsOn( "IN_PIO_READY" ) )
|
|
|
{
|
|
|
loggerPIO.E( "[Port] - 1 Ready not On" );
|
|
|
- this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout );
|
|
|
- //return 0;
|
|
|
+ this.iO.OutputOff( "OUT_PIO_SENSOR_ONOFF" );
|
|
|
+ this.OccurVehicleAlarm( 25 );
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
this.iO.WriteOutputIO( "OUT_PIO_READY", true );
|
|
|
@@ -867,51 +915,44 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
{
|
|
|
PIOClear();
|
|
|
loggerPIO.E( "[Port] - 2 Receive CV Run Timeout" );
|
|
|
- this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout );
|
|
|
- //return 0;
|
|
|
+ this.OccurVehicleAlarm( 26 );
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
this.iO.WriteOutputIO( "OUT_PIO_SENDING_RUN", true );
|
|
|
loggerPIO.I( "[Vehicle] - 2 Send Run On" );
|
|
|
|
|
|
- this.SetConveyorSpeed( true );
|
|
|
- this.OnOffConveyor( true );
|
|
|
- this.OnConveyorStart?.Invoke( false );
|
|
|
-
|
|
|
var sTime = SwUtils.CurrentTimeMillis;
|
|
|
while ( true )
|
|
|
{
|
|
|
- if ( SwUtils.Gt( sTime, 20 * ConstUtils.ONE_SECOND ) )
|
|
|
- {
|
|
|
- PIOClear();
|
|
|
- this.OnOffConveyor( false, true );
|
|
|
- loggerPIO.E( "[Port] Conveyor Wait Time Out" );
|
|
|
- this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout );
|
|
|
+ Thread.Sleep( 5 );
|
|
|
|
|
|
- //if (IsDetectedLoadStart() || IsDetectedCenter()) //중간에 걸려 있다고 생각해서 알람 처리.
|
|
|
- // return 12; //Conveyor Moving Timeout
|
|
|
- //else
|
|
|
- // return 0;
|
|
|
- }
|
|
|
+ if ( !this.iO.IsOn( "IN_PIO_READY" ) || this.iO.IsOn( "IN_PIO_RECEIVE_RUN" ) )
|
|
|
+ break;
|
|
|
|
|
|
- if ( this.iO.IsOn( "IN_PIO_RECEIVE_COMPLITE" ) )
|
|
|
+ if ( !sql.CommandDAL.HasK( this.CurrentSubCommand.CmdID ) )
|
|
|
+ {
|
|
|
+ PIOClear();
|
|
|
+ logger.D( "[Wait Charging] - 메인 명령 사라짐" );
|
|
|
break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if ( !IsDetectedCenter() )
|
|
|
- this.OnCarrierDetected?.Invoke( false );
|
|
|
+ if ( !this.iO.WaitChangeInputIO( true, pioTimeout, "IN_PIO_RECEIVE_COMPLITE" ) )
|
|
|
+ {
|
|
|
+ PIOClear();
|
|
|
+ loggerPIO.E( "[Port] - 3 Receive Complete Timeout" );
|
|
|
+ this.OccurVehicleAlarm( 26 );
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
- this.OnOffConveyor( false ); //Stop
|
|
|
- this.OnConveyorStop?.Invoke( false );
|
|
|
PIOClear();
|
|
|
|
|
|
this.iO.WriteOutputIO( "OUT_PIO_SEND_COMPLITE", true );
|
|
|
- this.iO.WriteOutputIO( "OUT_PIO_SEND_COMPLITE", false, 1000 );
|
|
|
-
|
|
|
- this.OnUnloadComplete?.Invoke();
|
|
|
-
|
|
|
+ Thread.Sleep( 1000 );
|
|
|
+ this.iO.WriteOutputIO( "OUT_PIO_SEND_COMPLITE", false );
|
|
|
|
|
|
- return true;
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
@@ -1073,6 +1114,9 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
PIOClear();
|
|
|
Thread.Sleep( 1000 );
|
|
|
this.OnConveyorStop?.Invoke( true );
|
|
|
+
|
|
|
+ Thread.Sleep( 1000 );
|
|
|
+ this.OnLoadComplete?.Invoke();
|
|
|
#else
|
|
|
var pioTimeout = sql.ConfigDal.GetValueToInt( ConstString.PIOTimeOut );
|
|
|
|
|
|
@@ -1195,6 +1239,7 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
this.OnConveyorStop?.Invoke( false );
|
|
|
PIOClear();
|
|
|
|
|
|
+ Thread.Sleep( 1000 );
|
|
|
this.OnUnloadComplete?.Invoke();
|
|
|
#else
|
|
|
var pioTimeout = sql.ConfigDal.GetValueToInt( ConstString.PIOTimeOut );
|
|
|
@@ -1274,7 +1319,8 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
PIOClear();
|
|
|
|
|
|
this.iO.WriteOutputIO( "OUT_PIO_SEND_COMPLITE" , true );
|
|
|
- this.iO.WriteOutputIO( "OUT_PIO_SEND_COMPLITE" , false , 1000 );
|
|
|
+ Thread.Sleep( 1000 );
|
|
|
+ this.iO.WriteOutputIO( "OUT_PIO_SEND_COMPLITE" , false );
|
|
|
|
|
|
this.OnUnloadComplete?.Invoke();
|
|
|
#endif
|