半导体semi通讯的协议SECS/GEM

2019/03/07 11:28
阅读数 451

经过多年的从事SECS/GEM开发,还有研究。
写出了如下软件,与大家分享, 还有C# Demo
整理出标准API接口,如下边C#代码。

 

// 开始
        public long start()
        {
            InitSecs();
            InitWhenever();

            MapManage.SetSecsEquipObject(m_nKey, this);
            return m_pImpl.Start(m_pMDLN, "");
        }
        
        // 停止
        public void Abort()
        {
            m_pImpl.Abort();           
            MapManage.DeleteSecsEquipObject(m_nKey);
        }
        
        // 警告处理
        public void AlarmAdd(int ALID, string ALTX)
        {
            AlarmAdd(ALID, ALTX, ALID, ALID+1);
        }
        
        
        // Extended version of AlarmAdd used when you need to customize the event report
        // CEID's used for the Alarm Set and Alarm Clear events
        // 警告与CEID不能相同
        // ALID:Alaram ID
        // ALTX:描述
        // alarmSetCEID: 设置ID
        // alarmClearCEID: 清除ID
        public void AlarmAdd(int ALID, string ALTX, int alarmSetCEID, int alarmClearCEID) 
        {
            // eq_alarm_add, ALID, ALTX, SetCEID, ClearCEID 

            if ( ALTX.Length > 120) 
            {
                throw new Exception("ALTX should be <=120 ASCII characters");
            }
            
            string cmd = "eq_alarm_add";

            CListOperate.listAppend(ref cmd, ALID.ToString(), ALTX,
                alarmSetCEID.ToString(), alarmClearCEID.ToString());

            m_pImpl.toolCmd(cmd);
        }

        // 报警使能
        public void AlarmEnable(int ALID, bool bEnabled)
        {
            // eq_alarm_enable, ALID, Enable
            string cmd = "eq_alarm_enable";
            CListOperate.listAppend(ref cmd, ALID.ToString(), bEnabled?"1":"0");        
            m_pImpl.toolCmd(cmd);
        }


        // 报警设置
        public void AlarmSet(int ALID, bool bSet)
        {
            // eq_alarm_set, ALID, set
            string cmd = "eq_alarm_set";
            CListOperate.listAppend(ref cmd, ALID.ToString(), bSet ? "1" : "0");
            m_pImpl.toolCmd(cmd);
        }

        // 报警获取列表
        public List<AlarmInfo> AlarmGetList()
        {
            // eq_alarm_get_list
            // ALID, ALTX, Enable, Set

            string cmd = "eq_alarm_get_list";
            RcResult reply;
            reply = m_pImpl.toolCmdReply(cmd);

            // 解析            
            List<AlarmInfo> listInfo = new List<AlarmInfo>();
            if (reply.rc == 0 && reply.result != null)
            {
                string[] listAlarm = null;
                string[] element = null;
                CListOperate.listSplit(reply.result, ref listAlarm);

                for (int i = 0; i < listAlarm.Length; i++ )
                {
                    CListOperate.listSplit(listAlarm[i], ref element);
                    if (element != null && element.Length > 3)
                    {
                        AlarmInfo info = new AlarmInfo();
                        info.ALID = element[0];
                        info.ALTX = element[1];
                        info.bEnable = element[2]=="1"?true:false;
                        info.bSet = element[3] == "1" ? true : false;
                        listInfo.Add(info);
                    }
                }
            }
            return listInfo;
        }


        public void SendSingleTerminal(string content)
        {
            string type = "B 0";
            string msg = "L";
            string info = "A";

            CListOperate.listAppend(ref info, content);
            CListOperate.listAppend(ref msg, type, info);

            string Reply = "";
            m_pImpl.SendMsg(msg, ref Reply);

        }

 

 

 

 

QQ 369883431

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部