[근무 일지] SNET Test Program Refactoring

타키탸키·2022년 4월 5일
0

근무 일지

목록 보기
7/16

SNET Test Program Refactoring

  • 기존 프로그램 구조를 효율적으로 바꾸고자 refactoring 진행

세부 일정

04.05

[RENAME] Waiting class

  • 불필요하게 긴 변수명
    • IControllerWait >> IWait
  • 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;
}
  • 불필요한 인스턴스 객체 생성X
private SnetDevice _snetDevice = new SnetDevice();
private Job _job = null;
private IWait _iWait = null;

public FormMainMenu()
{
    InitializeComponent();
    
    _iWait = new PollingWait(_snetDevcie);
    _job = new Job(_iWait);
}
profile
There's Only One Thing To Do: Learn All We Can

0개의 댓글