namespace SHARP_CLAS_UI
|
{
|
public class Stacker
|
{
|
#region Enum
|
private enum ProcessSteps
|
{
|
Wait,
|
|
StackerForwardSolOn,
|
StackerForwardSolOnCheck,
|
StackerForwardSensorCheck,
|
|
StackerForwardSolOff,
|
StackerForwardSolOffCheck,
|
StackerBackwardSensorCheck,
|
}
|
#endregion
|
|
#region Property
|
public bool ForwardSol
|
{
|
get
|
{
|
return _equipment.Board_Control.IO_manager.Get_Output(_forwardSol);
|
}
|
|
set
|
{
|
_equipment.Board_Control.IO_manager.Set_Output(_forwardSol, value);
|
}
|
}
|
|
public bool IsForwardSensor1
|
{
|
get
|
{
|
return _equipment.Board_Control.IO_manager.Get_Input(_isForwardSensor1);
|
}
|
}
|
|
public bool IsForwardSensor2
|
{
|
get
|
{
|
return _equipment.Board_Control.IO_manager.Get_Input(_isForwardSensor2);
|
}
|
}
|
|
public bool IsForwardSensor3
|
{
|
get
|
{
|
return _equipment.Board_Control.IO_manager.Get_Input(_isForwardSensor3);
|
}
|
}
|
|
public bool IsForwardSensor4
|
{
|
get
|
{
|
return _equipment.Board_Control.IO_manager.Get_Input(_isForwardSensor4);
|
}
|
}
|
|
public bool IsBackwardSensor1
|
{
|
get
|
{
|
return _equipment.Board_Control.IO_manager.Get_Input(_isBackwardSensor1);
|
}
|
}
|
|
public bool IsBackwardSensor2
|
{
|
get
|
{
|
return _equipment.Board_Control.IO_manager.Get_Input(_isBackwardSensor2);
|
}
|
}
|
|
public bool IsBackwardSensor3
|
{
|
get
|
{
|
return _equipment.Board_Control.IO_manager.Get_Input(_isBackwardSensor3);
|
}
|
}
|
|
public bool IsBackwardSensor4
|
{
|
get
|
{
|
return _equipment.Board_Control.IO_manager.Get_Input(_isBackwardSensor4);
|
}
|
}
|
|
public bool IsForward
|
{
|
get
|
{
|
return ForwardSol && IsForwardSensor1 && IsForwardSensor2 && IsForwardSensor3 && IsForwardSensor4;
|
}
|
}
|
|
public bool IsBackward
|
{
|
get
|
{
|
return ForwardSol == false && IsBackwardSensor1 && IsBackwardSensor2 && IsBackwardSensor3 && IsBackwardSensor4;
|
}
|
}
|
|
public bool IsWorkEnd
|
{
|
get
|
{
|
if(_step == ProcessSteps.Wait)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
}
|
#endregion
|
|
#region Field
|
Equipment _equipment;
|
|
private OutputData _forwardSol;
|
|
private InputData _isForwardSensor1;
|
private InputData _isForwardSensor2;
|
private InputData _isForwardSensor3;
|
private InputData _isForwardSensor4;
|
|
private InputData _isBackwardSensor1;
|
private InputData _isBackwardSensor2;
|
private InputData _isBackwardSensor3;
|
private InputData _isBackwardSensor4;
|
|
private En_Alarm_List _forwardSensor1Alarm;
|
private En_Alarm_List _forwardSensor2Alarm;
|
private En_Alarm_List _forwardSensor3Alarm;
|
private En_Alarm_List _forwardSensor4Alarm;
|
private En_Alarm_List _backwardSensor1Alarm;
|
private En_Alarm_List _backwardSensor2Alarm;
|
private En_Alarm_List _backwardSensor3Alarm;
|
private En_Alarm_List _backwardSensor4Alarm;
|
|
private ProcessSteps _step;
|
|
private SequenceTimer _sequenceTimer;
|
|
private readonly int _retryLimitCount = 3;
|
private int _retryCount;
|
|
#endregion
|
|
#region Construct
|
public Stacker(Equipment equipment)
|
{
|
_equipment = equipment;
|
_sequenceTimer = new SequenceTimer();
|
_retryCount = 0;
|
_step = ProcessSteps.Wait;
|
}
|
#endregion
|
|
#region Function
|
public void Initialize(OutputData forwardSol, InputData isForwardSensor1, InputData isForwardSensor2, InputData isForwardSensor3, InputData isForwardSensor4, InputData isBackwardSensor1, InputData isBackwardSensor2, InputData isBackwardSensor3, InputData isBackwardSensor4,
|
En_Alarm_List forwardSensor1Alarm, En_Alarm_List forwardSensor2Alarm, En_Alarm_List forwardSensor3Alarm, En_Alarm_List forwardSensor4Alarm, En_Alarm_List backwardSensor1Alarm, En_Alarm_List backwardSensor2Alarm, En_Alarm_List backwardSensor3Alarm, En_Alarm_List backwardSensor4Alarm)
|
{
|
_forwardSol = forwardSol;
|
_isForwardSensor1 = isForwardSensor1;
|
_isForwardSensor2 = isForwardSensor2;
|
_isForwardSensor3 = isForwardSensor3;
|
_isForwardSensor4 = isForwardSensor4;
|
_isBackwardSensor1 = isBackwardSensor1;
|
_isBackwardSensor2 = isBackwardSensor2;
|
_isBackwardSensor3 = isBackwardSensor3;
|
_isBackwardSensor4 = isBackwardSensor4;
|
|
_forwardSensor1Alarm = forwardSensor1Alarm;
|
_forwardSensor2Alarm = forwardSensor2Alarm;
|
_forwardSensor3Alarm = forwardSensor3Alarm;
|
_forwardSensor4Alarm = forwardSensor4Alarm;
|
_backwardSensor1Alarm = backwardSensor1Alarm;
|
_backwardSensor2Alarm = backwardSensor2Alarm;
|
_backwardSensor3Alarm = backwardSensor3Alarm;
|
_backwardSensor4Alarm = backwardSensor4Alarm;
|
}
|
|
public void ExecuteProcess()
|
{
|
switch (_step)
|
{
|
case ProcessSteps.Wait:
|
{
|
break;
|
}
|
case ProcessSteps.StackerForwardSolOn:
|
{
|
ForwardSol = true;
|
_sequenceTimer.Restart();
|
_step = ProcessSteps.StackerForwardSolOnCheck;
|
break;
|
}
|
case ProcessSteps.StackerForwardSolOnCheck:
|
{
|
if (ForwardSol == true)
|
{
|
_retryCount = 0;
|
_sequenceTimer.Restart();
|
_step = ProcessSteps.StackerForwardSensorCheck;
|
}
|
else
|
{
|
if (_sequenceTimer.Seconds > 1)
|
{
|
if (_retryCount < _retryLimitCount)
|
{
|
_retryCount++;
|
_step = ProcessSteps.StackerForwardSolOn;
|
}
|
else
|
{
|
_retryCount = 0;
|
Interlock_Manager.Add_Interlock_Msg($"{_forwardSol} on fail.", $"{_forwardSol} on is fail (retry 3).");
|
_step = ProcessSteps.Wait;
|
}
|
}
|
}
|
break;
|
}
|
case ProcessSteps.StackerForwardSensorCheck:
|
{
|
if (IsForwardSensor1 && IsForwardSensor2 && IsForwardSensor3 && IsForwardSensor4)
|
{
|
_sequenceTimer.Reset();
|
_step = ProcessSteps.Wait;
|
}
|
else
|
{
|
if (_sequenceTimer.Seconds > _equipment.Setting.Cylinder_Timeout)
|
{
|
if (IsForwardSensor1 == false)
|
{
|
Alarm_Manager.Instance.Occurred(_forwardSensor1Alarm);
|
}
|
|
if (IsForwardSensor2 == false)
|
{
|
Alarm_Manager.Instance.Occurred(_forwardSensor2Alarm);
|
}
|
|
if (IsForwardSensor3 == false)
|
{
|
Alarm_Manager.Instance.Occurred(_forwardSensor3Alarm);
|
}
|
|
if (IsForwardSensor4 == false)
|
{
|
Alarm_Manager.Instance.Occurred(_forwardSensor4Alarm);
|
}
|
_step = ProcessSteps.Wait;
|
}
|
}
|
break;
|
}
|
case ProcessSteps.StackerForwardSolOff:
|
{
|
ForwardSol = false;
|
_sequenceTimer.Restart();
|
_step = ProcessSteps.StackerForwardSolOffCheck;
|
break;
|
}
|
case ProcessSteps.StackerForwardSolOffCheck:
|
{
|
if (ForwardSol == false)
|
{
|
_retryCount = 0;
|
_sequenceTimer.Restart();
|
_step = ProcessSteps.StackerBackwardSensorCheck;
|
}
|
else
|
{
|
if (_sequenceTimer.Seconds > 1)
|
{
|
if (_retryCount < _retryLimitCount)
|
{
|
_retryCount++;
|
_step = ProcessSteps.StackerForwardSolOff;
|
}
|
else
|
{
|
_retryCount = 0;
|
Interlock_Manager.Add_Interlock_Msg($"{_forwardSol} off fail.", $"{_forwardSol} off is fail (retry 3).");
|
_step = ProcessSteps.Wait;
|
}
|
}
|
}
|
break;
|
}
|
case ProcessSteps.StackerBackwardSensorCheck:
|
{
|
if (IsBackwardSensor1 && IsBackwardSensor2 && IsBackwardSensor3 && IsBackwardSensor4)
|
{
|
_sequenceTimer.Reset();
|
_step = ProcessSteps.Wait;
|
}
|
else
|
{
|
if (_sequenceTimer.Seconds > _equipment.Setting.Cylinder_Timeout)
|
{
|
if (IsBackwardSensor1 == false)
|
{
|
Alarm_Manager.Instance.Occurred(_backwardSensor1Alarm);
|
}
|
|
if (IsBackwardSensor2 == false)
|
{
|
Alarm_Manager.Instance.Occurred(_backwardSensor2Alarm);
|
}
|
|
if (IsBackwardSensor3 == false)
|
{
|
Alarm_Manager.Instance.Occurred(_backwardSensor3Alarm);
|
}
|
|
if (IsBackwardSensor4 == false)
|
{
|
Alarm_Manager.Instance.Occurred(_backwardSensor4Alarm);
|
}
|
_step = ProcessSteps.Wait;
|
}
|
}
|
break;
|
}
|
}
|
}
|
|
public bool Forward()
|
{
|
if (IsWorkEnd)
|
{
|
if (ForwardSol && IsForwardSensor1 && IsForwardSensor2 && IsForwardSensor3 && IsForwardSensor4)
|
{
|
return true;
|
}
|
else
|
{
|
_step = ProcessSteps.StackerForwardSolOn;
|
return true;
|
}
|
}
|
else
|
{
|
return false;
|
}
|
}
|
|
public bool Backward()
|
{
|
if (IsWorkEnd)
|
{
|
if (ForwardSol == false && IsBackwardSensor1 && IsBackwardSensor2 && IsBackwardSensor3 && IsBackwardSensor4)
|
{
|
return true;
|
}
|
else
|
{
|
_step = ProcessSteps.StackerForwardSolOff;
|
return true;
|
}
|
}
|
else
|
{
|
return false;
|
}
|
}
|
#endregion
|
}
|
}
|