1.主动发送自定义指令

函数SendSecsMsgAsync(int nStream, int nFunction, bool bNeedReply, ref Int64 nMsgID, string TSN_data)  
用途发送SECS消息
参数nStream:SECS消息的流编号。例如S1F1
nFunction:SECS消息的功能编号。例如S1F1
bNeedReply:是否需要答复消息
nMsgID:用于判断对方答复的标识位
TSN_data:发送的数据

1.主动发送SECS消息,构造消息体,使用1.1.2多层结构的例子

string pValue = “”;

long mesID=0;

List<string> listDataTopLevel = new List<string>();

List<string> listData1 = new List<string>();

List<string> listData2 = new List<string>();

string pLotID = CListOperate.listJoin(“A”, “lotA”);

string pProcessID = CListOperate.listJoin(“A”, “proceeIDA”);         

string pProdutID = CListOperate.listJoin(“A”, “ProdutA”);

listData1.Add(“L”);                     

listData1.Add(pLotID);

listData1.Add(pProcessID);

listData1.Add(pProdutID);    

pLotID = CListOperate.listJoin(“A”, “lotB”);  

pProcessID = CListOperate.listJoin(“A”, “proceeIDB”);   

pProdutID = CListOperate.listJoin(“A”, “ProdutB”);    

listData2.Add(“L”);         

listData2.Add(pLotID);    

listData2.Add(pProcessID);      

listData2.Add(pProdutID);     

listDataTopLevel.Add(“L”);

listDataTopLevel.Add(CListOperate.listJoin(listData1));

listDataTopLevel.Add(CListOperate.listJoin(listData2));

2.把整体的结构组合成字符串赋值给变量pValue

pValue = CListOperate.listJoin(listDataTopLevel);

3.把pValue赋值到变量TSN_data中

m_pSecs.SendSecsMsgAsync(99,99,false,ref mesID,pValue);

4.当发送该条指令时,会发送以下数据

2 回复自定义指令

    特殊地,Host(MES/EAP)端会对标准指令格式进行增减操作,以符合实际作业要求,或发送自定义的SxFy,此时Equip端需要对非标格式解析、处理和回复。具体流程如下:

1.添加需要回复的指令

函数public RcResult MessageTypeAdd(long stream, long function, SecsMessageReceiveProc pCallback, object pClientData);
用途SECS消息类型处理添加
参数stream:SECS消息的流编号。例如S1F1
function:SECS消息的功能编号。例如S1F1
pCallback:SecsMessageReceiveProc委托 SecsMessageReceiveProc参数: Stream:SECS消息的流编号。例如S1F1 Function:SECS消息的功能编号。例如S1F1 send_reply:是否需要回复 transactionID: TSN_data:Host发来的数据 Header:  
pClientData

使用MessageTypeAdd添加需要接收的指令,例如添加“S99F99”

m_pescs.MessageTypeAdd(99,99, OnS99F99Proc, this);    

 

2.处理回调

private void OnS99F99Proc(long stream, long function, bool send_reply, long transactionID, string TSN_data, string header)

        {

  1. 通过send_reply判断是否需要回复
  2. 处理TSN_data

        }

TSN_data是Host发来指令的整体,需要用函数listSplit来解析出我们需要的数据

函数listSplit(string srcList, ref List<string> sv)
参数srcList:需要解析的List字符串
List<string> sv:解析后的List

3.处理完成

如果需要返回,解析完成之后构造返回格式,回复指令,使用以下方法回复

函数public void SendReply(long stream, long function, long transactionID, string TSN_data);
参数Stream:SECS消息的流编号。例如S1F1
Function:SECS消息的功能编号。例如S1F1
transactionID:SecsMessageReceiveProc委托中的参数
TSN_data:回复的数据

private void OnS99F99Proc(long stream, long function, bool send_reply, long transactionID, string TSN_data, string header)

        {

1.通过send_reply判断是否需要回复

2.处理TSN_data

3.SendReply(99, 100, 9transactionID, string TSN_data);

        }