SNET Test Program Refactoring
- 기존 프로그램 구조를 효율적으로 바꾸고자 refactoring 진행
세부 일정
04.05
[RENAME] Waiting class
Wait
이라는 속성에 맞게 변경
InterruptFunction
>> InterruptFunctionWait
- API 이름과 통일하기 위해 변경
InterruptWait
>> InterruptEventWait
InitInterruptTable
>> InitInterruptEventTable
- 직관적인 이해를 위해 약어 사용X
ieti
>> InterruptEventTableInfo
ieh
>> InterruptEventHandler
[REFACTOR] Waiting class
- 함수의 인자에 값을 바로 넣지 않고 변수를 선언하여 변수명을 전달
bool enable = true;
_snetDevice.EnableInterruptEvent(enable)
// InterruptEventWait
public int WaitMotionDone(int axis)
{
bool motionDone = false;
int returnCode = _snetDevice.GetMotionDone(axis, ref motionDone);
if(returnCode == (int)SnetDevice.eSnetApiReturnCode.Success)
{
if(!motionDone) returnCode = _snetDevice.WaitInterruptEvent(0, 0);
}
else if(returnCode == (int)SnetDevice.eSnetApiReturnCode.InterruptEventFailedWaiting)
{
Debug.WriteLine("TimeOut!!!");
}
return returnCode;
}
// InterruptFunctionWait
public int WaitMotionDone(int axis)
{
bool motionDone = false;
int returnCode = _snetDevice.GetMotionDone(axis, ref motionDone);
if(returnCode == (int)SnetDevice.eSnetApiReturnCode.Success)
{
if(!motionDone)
{
eventWaitHandle.WaitOne();
eventWaitHandle.Reset();
}
}
return returnCode;
}
private SnetDevice _snetDevice = new SnetDevice();
private Job _job = null;
private IWait _iWait = null;
public FormMainMenu()
{
InitializeComponent();
_iWait = new PollingWait(_snetDevcie);
_job = new Job(_iWait);
}