|
|
@@ -9,6 +9,7 @@ using GSG.NET.Concurrent;
|
|
|
using GSG.NET.Extensions;
|
|
|
using GSG.NET.LINQ;
|
|
|
using GSG.NET.Logging;
|
|
|
+using GSG.NET.Quartz;
|
|
|
using GSG.NET.Utils;
|
|
|
using OHV.Common.Events;
|
|
|
using OHV.Common.Model;
|
|
|
@@ -165,11 +166,6 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
{
|
|
|
if ( SetField( ref this.vehicleState, value ) )
|
|
|
{
|
|
|
- if ( value == eVehicleState.Charge )
|
|
|
- this.OnCharging?.Invoke();
|
|
|
- else
|
|
|
- this.OnChargingFull?.Invoke();
|
|
|
-
|
|
|
var info = sql.VehicleInfoDAL.GetAll().FirstOrDefault();
|
|
|
info.VehicleState = value;
|
|
|
sql.VehicleInfoDAL.Update( info );
|
|
|
@@ -225,6 +221,27 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
|
|
|
public bool IsMoving { get => this.refObjects.Drive.IsDriveMoving(); }
|
|
|
|
|
|
+ private bool batteryChargeState;
|
|
|
+
|
|
|
+ public bool BatteryChargeState
|
|
|
+ {
|
|
|
+ get { return batteryChargeState; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ if ( SetField( ref batteryChargeState, value ) )
|
|
|
+ {
|
|
|
+ if ( value )
|
|
|
+ {
|
|
|
+ this.OnChargingStart?.Invoke();
|
|
|
+ LockUtils.Wait( 200 );
|
|
|
+ this.OnCharging?.Invoke();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ this.OnChargingFull?.Invoke();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
#region Battery Property
|
|
|
|
|
|
double batteryVoltage;
|
|
|
@@ -376,6 +393,7 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
get { return this.rearTorque; }
|
|
|
set { SetField( ref this.rearTorque, value ); }
|
|
|
}
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region Event
|
|
|
@@ -922,7 +940,7 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
{
|
|
|
//Move 시작 시 충전 중이면 충전 중지 실행.
|
|
|
int result = 0;
|
|
|
- if ( this.IsCharging() || this.VehicleStateProperty == eVehicleState.Charge )
|
|
|
+ if ( this.IsCharging() || this.VehicleStateProperty == eVehicleState.Charge || this.BatteryChargeState)
|
|
|
{
|
|
|
result = this.StopBatteryCharge();
|
|
|
if ( result != 0 )
|
|
|
@@ -1085,8 +1103,10 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
sql.CommandDAL.Update( cmd );
|
|
|
}
|
|
|
|
|
|
- LockUtils.Wait( 1000 );
|
|
|
- this.OnLoadComplete?.Invoke(); //일찍 주면 다음 명령을 500ms 안에 주는 현상 있음. 그러니까 천천히 주자
|
|
|
+ TimerUtils.Once( 1000, this.OnLoadComplete );
|
|
|
+
|
|
|
+ //LockUtils.Wait( 1000 );
|
|
|
+ //this.OnLoadComplete?.Invoke(); //일찍 주면 다음 명령을 500ms 안에 주는 현상 있음. 그러니까 천천히 주자
|
|
|
this.VehicleStateProperty = eVehicleState.Idle;
|
|
|
|
|
|
return true;
|
|
|
@@ -1138,8 +1158,10 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
sql.CommandDAL.Update( cmd );
|
|
|
}
|
|
|
|
|
|
- LockUtils.Wait( 1000 );
|
|
|
- this.OnUnloadComplete?.Invoke(); //일찍 주면 다음 명령을 500ms 안에 주는 현상 있음. 그러니까 천천히 주자
|
|
|
+ TimerUtils.Once( 1000, this.OnUnloadComplete );
|
|
|
+
|
|
|
+ //LockUtils.Wait( 1000 );
|
|
|
+ //this.OnUnloadComplete?.Invoke(); //일찍 주면 다음 명령을 500ms 안에 주는 현상 있음. 그러니까 천천히 주자
|
|
|
this.VehicleStateProperty = eVehicleState.Idle;
|
|
|
|
|
|
logger.D( $"[Unloading End]--------------------------------------" );
|
|
|
@@ -1436,7 +1458,16 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
/// 이걸 보고 판단 하자. 충전 단자 전진 상태임.
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
- public bool IsCharging() => this.refObjects.IO.IsOn( "IN_PIO_SEND_RUN" ) && this.refObjects.IO.IsOn( "IN_PIO_SENDABLE" );
|
|
|
+ public bool IsCharging()
|
|
|
+ {
|
|
|
+ this.PIOSensorOn();
|
|
|
+ LockUtils.Wait( 500 );
|
|
|
+
|
|
|
+ var ret = this.refObjects.IO.IsOn( "OUT_PIO_RECEIVABLE", false ) && this.refObjects.IO.IsOn( "OUT_PIO_RECEIVE_RUN", false );
|
|
|
+ //this.PIOSensorOff();
|
|
|
+
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
#region Drive
|
|
|
@@ -1494,32 +1525,33 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
if ( this.refObjects.Conveyor.IsInverterError() )
|
|
|
return 16;
|
|
|
|
|
|
+ if ( this.refObjects.Conveyor.IsDetectedCenter() )
|
|
|
+ {
|
|
|
+ this.OnFailReport?.Invoke( eFailCode.Load_VehicleHasCarrier );
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
if ( !this.refObjects.IO.WaitChangeInputIO( true, 20 * ConstUtils.ONE_SECOND, "IN_LIFTER_POSITION_DETECT" ) )
|
|
|
{
|
|
|
loggerPIO.E( "[Port] - Lift Position Check Error" );
|
|
|
- this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
|
|
|
+ TimerUtils.Once( 1000, this.OnFailReport, eFailCode.LoadPIOInterlockTimeout );
|
|
|
+ //this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
|
|
|
return 0; //14
|
|
|
}
|
|
|
|
|
|
//if ( !this.refObjects.Conveyor.IsLifterPositinCheck() )
|
|
|
- //{
|
|
|
- // loggerPIO.E( "[Port] - Lift Position Check Error" );
|
|
|
- // this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
|
|
|
- // return 0; //14
|
|
|
- //}
|
|
|
-
|
|
|
- //Todo: Sensor Setting 이 후 주석 풀기.
|
|
|
- //if ( !this.IsLifterDuplication() )
|
|
|
- //{
|
|
|
- // this.OnFailReport?.Invoke( eFailCode.Load_PortHasNotCarrier );
|
|
|
- // return 0;
|
|
|
- //}
|
|
|
+ //{
|
|
|
+ // loggerPIO.E( "[Port] - Lift Position Check Error" );
|
|
|
+ // this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
|
|
|
+ // return 0; //14
|
|
|
+ //}
|
|
|
|
|
|
- if ( this.refObjects.Conveyor.IsDetectedCenter() )
|
|
|
- {
|
|
|
- this.OnFailReport?.Invoke( eFailCode.Load_VehicleHasCarrier );
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ //Todo: Sensor Setting 이 후 주석 풀기.
|
|
|
+ //if ( !this.IsLifterDuplication() )
|
|
|
+ //{
|
|
|
+ // this.OnFailReport?.Invoke( eFailCode.Load_PortHasNotCarrier );
|
|
|
+ // return 0;
|
|
|
+ //}
|
|
|
|
|
|
PIOClear();
|
|
|
this.OnPIOStart?.Invoke( true );
|
|
|
@@ -1527,11 +1559,12 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
this.refObjects.IO.WriteOutputIO( "OUT_PIO_RECEIVABLE", true );
|
|
|
loggerPIO.I( "[Vehicle] - 4 Receivable" );
|
|
|
|
|
|
- if ( !this.refObjects.IO.WaitChangeInputIO( true, pioTimeout, "IN_PIO_SENDABLE" ) )
|
|
|
+ if ( !this.refObjects.IO.WaitChangeInputIO( true, 10 * ConstUtils.ONE_SECOND, "IN_PIO_SENDABLE" ) )
|
|
|
{
|
|
|
PIOClear();
|
|
|
loggerPIO.E( "[Port] - 4 Ready Time Out" );
|
|
|
- this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
|
|
|
+ TimerUtils.Once( 1000, this.OnFailReport, eFailCode.LoadPIOInterlockTimeout );
|
|
|
+ //this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
|
|
|
return 0;
|
|
|
}
|
|
|
loggerPIO.E( "[Port] - 4 Ready On" );
|
|
|
@@ -1548,7 +1581,8 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
this.refObjects.Conveyor.OnOffConveyor( false, true );
|
|
|
PIOClear();
|
|
|
loggerPIO.E( "[Port] - 5 Sending Run Time Out" );
|
|
|
- this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
|
|
|
+ TimerUtils.Once( 1000, this.OnFailReport, eFailCode.LoadPIOInterlockTimeout );
|
|
|
+ //this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
|
|
|
return 0;
|
|
|
}
|
|
|
loggerPIO.I( "[Port] - 5 Sending Run On" );
|
|
|
@@ -1564,7 +1598,8 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
PIOClear();
|
|
|
this.refObjects.Conveyor.OnOffConveyor( false, true );
|
|
|
loggerPIO.E( "[Vehicle] Conveyor Wait Time Out" );
|
|
|
- this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
|
|
|
+ TimerUtils.Once( 1000, this.OnFailReport, eFailCode.LoadPIOInterlockTimeout );
|
|
|
+ //this.OnFailReport?.Invoke( eFailCode.LoadPIOInterlockTimeout );
|
|
|
|
|
|
if ( this.refObjects.Conveyor.IsDetectedLoadStart() ) // 감지가 시작 되었으면 이동중 Error 로 판단 설비를 정지 상태로
|
|
|
return 10; //Conveyor Moving Timeout
|
|
|
@@ -1663,14 +1698,16 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
|
|
|
if ( !this.refObjects.Conveyor.IsDetectedCenter() )
|
|
|
{
|
|
|
- this.OnFailReport?.Invoke( eFailCode.Unload_VehicleHasNotCarrier );
|
|
|
+ TimerUtils.Once( 1000, this.OnFailReport, eFailCode.Unload_VehicleHasNotCarrier );
|
|
|
+ //this.OnFailReport?.Invoke( eFailCode.Unload_VehicleHasNotCarrier );
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
if ( !this.refObjects.IO.WaitChangeInputIO( true, 20 * ConstUtils.ONE_SECOND, "IN_LIFTER_POSITION_DETECT" ) )
|
|
|
{
|
|
|
loggerPIO.E( "[Port] - Lift Position Check Error" );
|
|
|
- this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout );
|
|
|
+ TimerUtils.Once( 1000, this.OnFailReport, eFailCode.UnlaodPIOInterlockTimeout );
|
|
|
+ //this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout );
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
@@ -1684,21 +1721,23 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
PIOClear();
|
|
|
this.OnPIOStart?.Invoke( false );
|
|
|
|
|
|
- if ( !this.refObjects.IO.IsOn( "IN_PIO_READY" ) )
|
|
|
+ if ( !this.refObjects.IO.WaitChangeInputIO( true, 5 * ConstUtils.ONE_SECOND, "IN_PIO_READY" ) )
|
|
|
{
|
|
|
loggerPIO.E( "[Port] - 1 Ready not On" );
|
|
|
- this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout );
|
|
|
+ TimerUtils.Once( 1000, this.OnFailReport, eFailCode.UnlaodPIOInterlockTimeout );
|
|
|
+ //this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout );
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
this.refObjects.IO.WriteOutputIO( "OUT_PIO_READY", true );
|
|
|
loggerPIO.I( "[Vehicle] - 1 Ready On" );
|
|
|
|
|
|
- if ( !this.refObjects.IO.WaitChangeInputIO( true, pioTimeout, "IN_PIO_RECEIVE_RUN" ) )
|
|
|
+ if ( !this.refObjects.IO.WaitChangeInputIO( true, 10 * ConstUtils.ONE_SECOND, "IN_PIO_RECEIVE_RUN" ) )
|
|
|
{
|
|
|
PIOClear();
|
|
|
loggerPIO.E( "[Port] - 2 Receive CV Run Timeout" );
|
|
|
- this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout );
|
|
|
+ TimerUtils.Once( 1000, this.OnFailReport, eFailCode.UnlaodPIOInterlockTimeout );
|
|
|
+ //this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout );
|
|
|
return 0;
|
|
|
}
|
|
|
loggerPIO.E( "[Port] - 2 Receive CV Run On" );
|
|
|
@@ -1725,7 +1764,8 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
PIOClear();
|
|
|
this.refObjects.Conveyor.OnOffConveyor( false, true );
|
|
|
loggerPIO.E( "[Port] Conveyor Wait Time Out" );
|
|
|
- this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout );
|
|
|
+ TimerUtils.Once( 1000, this.OnFailReport, eFailCode.UnlaodPIOInterlockTimeout );
|
|
|
+ //this.OnFailReport?.Invoke( eFailCode.UnlaodPIOInterlockTimeout );
|
|
|
|
|
|
if ( this.refObjects.Conveyor.IsDetectedLoadStart() || this.refObjects.Conveyor.IsDetectedCenter() ) //중간에 걸려 있다고 생각해서 알람 처리.
|
|
|
return 12; //Conveyor Moving Timeout
|
|
|
@@ -1911,6 +1951,11 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
break;
|
|
|
case eDataKind.Current:
|
|
|
this.BatteryCurrent = (double)obj.Value;
|
|
|
+ if ( BatteryCurrent > 0 )
|
|
|
+ this.BatteryChargeState = true;
|
|
|
+ else
|
|
|
+ this.BatteryChargeState = false;
|
|
|
+
|
|
|
break;
|
|
|
case eDataKind.BatteryState:
|
|
|
if ( obj.Value == null )
|
|
|
@@ -1920,12 +1965,13 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
case eDataKind.ChargeCompleteTime:
|
|
|
if ( obj.Value == null /*|| obj.Value <= 0 */)
|
|
|
return;
|
|
|
+
|
|
|
this.BatteryChargeTime = (double)obj.Value;
|
|
|
|
|
|
//if ( this.BatteryChargeTime > 0 )
|
|
|
//{
|
|
|
// //this.OnCharging?.Invoke();
|
|
|
- // //this.VehicleStateProperty = eVehicleState.Charge;
|
|
|
+ // this.VehicleStateProperty = eVehicleState.Charge;
|
|
|
//}
|
|
|
//else
|
|
|
// //this.OnChargingFull?.Invoke();
|
|
|
@@ -1943,7 +1989,7 @@ namespace VehicleControlSystem.ControlLayer
|
|
|
if ( this.autoManager.AutoModeStateProperty != eAutoModeState.Run )
|
|
|
return;
|
|
|
|
|
|
- if ( this.VehicleStateProperty == eVehicleState.Charge || this.IsCharging() )
|
|
|
+ if ( this.VehicleStateProperty == eVehicleState.Charge || this.IsCharging() || this.BatteryChargeState )
|
|
|
{
|
|
|
int result = ConstInt.EXECUTE_SUCCESS;
|
|
|
result = this.StopBatteryCharge();
|