> For the complete documentation index, see [llms.txt](https://nviasoft.gitbook.io/nviasoft-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nviasoft.gitbook.io/nviasoft-docs/documentation/c/8.-host-command-send-s2f41.md).

# 8. Host Command Send(S2F41)

### AddRemoteCommand() / OnRemoteCommand()

<figure><img src="/files/F4lTSYvc2lPi7j0FbBPx" alt=""><figcaption></figcaption></figure>

```csharp
// 시작전AddRemoteCommand()로 RCMD 등록
//===================================================================================
m_gem.AddRemoteCommand(RCMD.START);  //Start 명령과 PP-Select 명령을 사용한다고 가정
m_gem.AddRemoteCommand(RCMD.PPSELECT);      
//===================================================================================
```

```csharp
// OnEventReceived()에서
// OnRemoteCommand() 로 사용자에게 전달
 //=================================================================
 case EZGEM_EVENT.HOST_COMMAND:       //1030
     OnRemoteCommand(lParam);
     break;
 //=================================================================
```

```csharp
//OnRemoteCommand에서 사용자가 처리
public void OnRemoteCommand(int lMsgId)
{
    string strCommand = string.Empty;
    string strCPName = string.Empty, strCPValue = string.Empty;
    int nParamCount = 0, nFormat =0;
    short nHCACK = 0;
    //==============받아서 처리하는 변수를 선언합니다.=================
    string strLOTID = string.Empty, strPPID = string.Empty;
   //===============================================================
    nParamCount = m_gem.GetRemoteCommand(lMsgId, ref strCommand);

    for (short i = 0; i < (short)nParamCount; i++)
    {
        int nCntOFParam = m_gem.GetRemoteCommandParam(lMsgId, i, ref strCPName, ref strCPValue, ref nFormat);

        strCPName.ToUpper();
        if (strCPName == CPNAME.LOTID)
        {
            strLOTID = strCPValue;
        }
        else if (strCPName == CPNAME.PPID)
        {
            strPPID = strCPValue;
        }
        else //해당되는 CPNAME이 존재하지 않는 경우. NACK
        {
            nHCACK = 3;
            m_gem.SetRemoteCommandErrorCode(lMsgId, strCommand, i, 3);
        }
    }
    if (nHCACK != 0)
    { 
        m_gem.ReplyRemoteCommand(lMsgId, nHCACK);// 허용되지 않는 CPNAME이 존재함.
        return;
    }
    else
    {
        if (strCommand == RCMD.START)    //Start명령일경우
        {
            m_gem.ReplyRemoteCommand(lMsgId, nHCACK);//응답전송
            m_gem.SetVIDValue(SVID.LOT_ID, strLOTID);//LOTID 새로운 값으로 세팅
            m_gem.SendEventReport(CEID.LOT_START);    //S6F11 이벤트 전송
        }
        else if (strCommand == RCMD.PPSELECT)  //PP-Select명령일경우
        {
            if (strPPID != "")
            {
                m_gem.ReplyRemoteCommand(lMsgId, nHCACK);     //응답 전송
                m_gem.SetVIDValue(SVID.PPID, strPPID);        //PPID 새로운 값 세팅
                m_gem.SendEventReport(CEID.PP_SELECTED_LOADED);//S6F11 이벤트 전송
            }
            else
            {
                nHCACK = 3;//해당되는 레시피 이름이 없는 경우 작업진행 불가.
                m_gem.ReplyRemoteCommand(lMsgId, nHCACK); //HOST로 에러코드 전송
            }
        }
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://nviasoft.gitbook.io/nviasoft-docs/documentation/c/8.-host-command-send-s2f41.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
