> 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/api-reference/undefined-5/replyremotecommand.md).

# ReplyRemoteCommand

### short ReplyRemoteCommand(int lMsgId, short HCACK)

호스트로부터 수신된 S2F41 (Host Command Send) 메시지에 대한 응답(`S2F42`)을 전송합니다. 이벤트 핸들러를 통해 수신된 명령(RCMD)과 파라미터(CPNAME/CPVAL)를 확인한 후, 수락 여부를 HCACK 값에 담아 이 함수를 호출합니다.

{% hint style="info" %}
GetRemoteCommand()함수와 함께 사용합니다.
{% endhint %}

Parameters

<table data-header-hidden><thead><tr><th width="203" valign="top"></th><th width="78" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Name</td><td valign="top">Type</td><td valign="top">Description</td></tr><tr><td valign="top">lMsgId</td><td valign="top">long</td><td valign="top">수신한 S2F41W의 Message의 ID</td></tr><tr><td valign="top">HCACK</td><td valign="top">short</td><td valign="top">S2F42에 설정할 응답코드</td></tr></tbody></table>

```csharp
public void OnRemoteCommand(int lMsgId)
{
    string strCommand = "", strCPName = "", strCPValue = "";
    int nParamCount = 0;
    int 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);

        }

        AddLog(string.Format("CPNAME = {0}", strCPName));
        AddLog(string.Format("CPVALUE[{0},{1}] = {2}", nCntOFParam, nFormat, strCPValue));
    }

    



    if (nHCACK != 0)
    {
        // 허용되지 않는 CPNAME이 존재함.
        m_gem.ReplyRemoteCommand(lMsgId, nHCACK);
        return;
    }
    else
    {
        // 
        if (strCommand == RCMD.START)
        {
            //들어온 LOTID나 CSTID,.. 등등을 비교하여 문제가 없으면 해당해서 보냄.
            m_gem.ReplyRemoteCommand(lMsgId, nHCACK); //응답후 해당작업 진행 가능하면 작업진행.
            m_gem.SetVIDValue(SVID.LOT_ID, strLOTID);
            m_gem.SendEventReport(CEID.LOT_START);
        }
        else if (strCommand == RCMD.PPSELECT)
        {
            if (strPPID != "")
            {
                m_gem.ReplyRemoteCommand(lMsgId, nHCACK); //응답후 해당작업 진행 가능하면 작업진행.

                m_gem.SetVIDValue(SVID.PPID, strPPID);
                m_gem.SendEventReport(CEID.PP_SELECTED_LOADED);
            }
            else
            {
                nHCACK = 3;//해당되는 레시피 이름이 없는 경우 작업진행 불가.
                m_gem.ReplyRemoteCommand(lMsgId, nHCACK); //응답후 해당작업 진행 가능하면 작업진행.

            }
        }
    }
}
```


---

# 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/api-reference/undefined-5/replyremotecommand.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.
