namespace SHARP_CLAS_UI
|
{
|
public class Clamper
|
{
|
#region Enum
|
private enum ProcessSteps
|
{
|
Wait,
|
|
CalmpSolOn,
|
ClmapSolOnCheck,
|
ClampSensorCheck,
|
|
CalmpSolOff,
|
ClampSolOffCheck,
|
UnclampSensorCheck,
|
}
|
#endregion
|
|
#region Property
|
public bool ClampSol
|
{
|
get
|
{
|
return _equipment.Board_Control.IO_manager.Get_Output(_clampSol);
|
}
|
|
set
|
{
|
_equipment.Board_Control.IO_manager.Set_Output(_clampSol, value);
|
}
|
}
|
|
public bool IsClampSensor1
|
{
|
get
|
{
|
return _equipment.Board_Control.IO_manager.Get_Input(_isClampSensor1);
|
}
|
}
|
|
public bool IsClampSensor2
|
{
|
get
|
{
|
return _equipment.Board_Control.IO_manager.Get_Input(_isClampSensor2);
|
}
|
}
|
|
public bool IsUnclampSensor1
|
{
|
get
|
{
|
return _equipment.Board_Control.IO_manager.Get_Input(_isUnclampSensor1);
|
}
|
}
|
|
public bool IsUnclampSensor2
|
{
|
get
|
{
|
return _equipment.Board_Control.IO_manager.Get_Input(_isUnclampSensor2);
|
}
|
}
|
|
public bool IsClamp
|
{
|
get
|
{
|
if (ClampSol == true && IsClampSensor1 && IsClampSensor2)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
}
|
|
public bool IsUnclamp
|
{
|
get
|
{
|
if (ClampSol == false && IsUnclampSensor1 && IsUnclampSensor2)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
}
|
|
public bool IsWorkEnd
|
{
|
get
|
{
|
if (_step == ProcessSteps.Wait)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
}
|
#endregion
|
|
#region Field
|
Equipment _equipment;
|
|
private OutputData _clampSol;
|
|
private InputData _isClampSensor1;
|
private InputData _isClampSensor2;
|
|
private InputData _isUnclampSensor1;
|
private InputData _isUnclampSensor2;
|
|
private En_Alarm_List _clampSensor1Alarm;
|
private En_Alarm_List _clampSensor2Alarm;
|
private En_Alarm_List _unclampSensor1Alarm;
|
private En_Alarm_List _unclampSensor2Alarm;
|
private ProcessSteps _step;
|
|
private SequenceTimer _sequenceTimer;
|
|
private readonly int _retryLimitCount = 3;
|
private int _retryCount;
|
#endregion
|
|
#region Construct
|
public Clamper(Equipment equipment)
|
{
|
_equipment = equipment;
|
_sequenceTimer = new SequenceTimer();
|
_retryCount = 0;
|
_step = ProcessSteps.Wait;
|
}
|
#endregion
|
|
#region Function
|
public void Initialize(OutputData clampSol, InputData isClampSensor1, InputData isClampSensor2, InputData isUnclampSensor1, InputData isUnclampSensor2,
|
En_Alarm_List clampSensor1Alarm, En_Alarm_List clampSensor2Alarm, En_Alarm_List unclampSensor1Alarm, En_Alarm_List unclampSensor2Alarm)
|
{
|
_clampSol = clampSol;
|
|
_isClampSensor1 = isClampSensor1;
|
_isClampSensor2 = isClampSensor2;
|
_isUnclampSensor1 = isUnclampSensor1;
|
_isUnclampSensor2 = isUnclampSensor2;
|
|
_clampSensor1Alarm = clampSensor1Alarm;
|
_clampSensor2Alarm = clampSensor2Alarm;
|
_unclampSensor1Alarm = unclampSensor1Alarm;
|
_unclampSensor2Alarm = unclampSensor2Alarm;
|
}
|
|
public void ExecuteProcess()
|
{
|
switch (_step)
|
{
|
case ProcessSteps.Wait:
|
{
|
break;
|
}
|
case ProcessSteps.CalmpSolOn:
|
{
|
ClampSol = true;
|
_sequenceTimer.Restart();
|
_step = ProcessSteps.ClmapSolOnCheck;
|
break;
|
}
|
case ProcessSteps.ClmapSolOnCheck:
|
{
|
if (ClampSol == true)
|
{
|
_retryCount = 0;
|
_sequenceTimer.Restart();
|
_step = ProcessSteps.ClampSensorCheck;
|
}
|
else
|
{
|
if (_sequenceTimer.Seconds > 1)
|
{
|
if (_retryCount < _retryLimitCount)
|
{
|
_retryCount++;
|
_step = ProcessSteps.CalmpSolOn;
|
}
|
else
|
{
|
Interlock_Manager.Add_Interlock_Msg($"{_clampSol} on fail.", $"{_clampSol} on is fail (retry 3).");
|
_step = ProcessSteps.Wait;
|
}
|
}
|
}
|
break;
|
}
|
case ProcessSteps.ClampSensorCheck:
|
{
|
if (IsClampSensor1 && IsClampSensor2)
|
{
|
_sequenceTimer.Reset();
|
_step = ProcessSteps.Wait;
|
}
|
else
|
{
|
if (_sequenceTimer.Seconds > _equipment.Setting.Cylinder_Timeout)
|
{
|
if (IsClampSensor1 == false)
|
{
|
Alarm_Manager.Instance.Occurred(_clampSensor1Alarm);
|
}
|
|
if (IsClampSensor2 == false)
|
{
|
Alarm_Manager.Instance.Occurred(_clampSensor2Alarm);
|
}
|
|
_step = ProcessSteps.Wait;
|
}
|
}
|
break;
|
}
|
case ProcessSteps.CalmpSolOff:
|
{
|
ClampSol = false;
|
_sequenceTimer.Restart();
|
_step = ProcessSteps.ClampSolOffCheck;
|
break;
|
}
|
case ProcessSteps.ClampSolOffCheck:
|
{
|
if (ClampSol == false)
|
{
|
_retryCount = 0;
|
_sequenceTimer.Restart();
|
_step = ProcessSteps.UnclampSensorCheck;
|
}
|
else
|
{
|
if (_sequenceTimer.Seconds > 1)
|
{
|
if (_retryCount < _retryLimitCount)
|
{
|
_retryCount++;
|
_step = ProcessSteps.CalmpSolOn;
|
}
|
else
|
{
|
Interlock_Manager.Add_Interlock_Msg($"{_clampSol} off fail.", $"{_clampSol} off is fail (retry 3).");
|
_step = ProcessSteps.Wait;
|
}
|
}
|
}
|
break;
|
}
|
case ProcessSteps.UnclampSensorCheck:
|
{
|
if (IsUnclampSensor1 && IsUnclampSensor2)
|
{
|
_sequenceTimer.Reset();
|
_step = ProcessSteps.Wait;
|
}
|
else
|
{
|
if (_sequenceTimer.Seconds > _equipment.Setting.Cylinder_Timeout)
|
{
|
if (IsUnclampSensor1 == false)
|
{
|
Alarm_Manager.Instance.Occurred(_unclampSensor1Alarm);
|
}
|
|
if (IsUnclampSensor2 == false)
|
{
|
Alarm_Manager.Instance.Occurred(_unclampSensor2Alarm);
|
}
|
|
_step = ProcessSteps.Wait;
|
}
|
}
|
break;
|
}
|
}
|
}
|
|
public bool Clamp()
|
{
|
if (IsWorkEnd)
|
{
|
if (ClampSol && IsClampSensor1 && IsClampSensor2)
|
{
|
return true;
|
}
|
else
|
{
|
_step = ProcessSteps.CalmpSolOn;
|
return true;
|
}
|
}
|
else
|
{
|
return false;
|
}
|
}
|
|
public bool Unclamp()
|
{
|
if (IsWorkEnd)
|
{
|
if (ClampSol == false && IsUnclampSensor1 && IsUnclampSensor2)
|
{
|
return true;
|
}
|
else
|
{
|
_step = ProcessSteps.CalmpSolOff;
|
return true;
|
}
|
}
|
else
|
{
|
return false;
|
}
|
}
|
#endregion
|
}
|
}
|