> 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/id/addremotecommand.md).

# AddRemoteCommand

### int AddRemoteCommand(string strCommand)

EZGemPlus에 Remote Command를 추가하는 함수

Host의 S2F41W 메시지 수신 시 수신을 허용할 RCMD를 EZGemPlus 구동 전 미리 등록하는 함수입니다.

해당 함수를 이용하여 등록하지 않는 Remote Command 수신 시 자동으로 HCACK = 1을 S2F42메시지로 응답합니다.

{% hint style="info" %}
EZGemPlus User Manual For C#에서도 확인하실 수 있습니다.
{% endhint %}

Parameters

<table data-header-hidden><thead><tr><th width="168" valign="top"></th><th width="122" 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">strCommand</td><td valign="top">string</td><td valign="top">EZGemPlus에 등록할 Remote Command</td></tr></tbody></table>

```csharp
 //GEM 구동전 미리 등록해둡니다.
 m_gem.AddRemoteCommand("START");
 m_gem.AddRemoteCommand("PP-SELECT");
 m_gem.AddRemoteCommand("STOP");
 m_gem.AddRemoteCommand("CANCEL");
 m_gem.AddRemoteCommand("ABORT");
```

```csharp
//S2F41 수신시 OnEventReceived()통해 사용작에게 전달해줍니다.
case EZGEM_EVENT.HOST_COMMAND:
    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/api-reference/id/addremotecommand.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.
