/// <summary>
        /// 用于host/eqt向eqt/host端发送消息
        /// </summary>
        /// <param name="messages">消息内容</param>
        /// <param name="byOP">是否是从Operator端发送,true为是, false为从host端发送</param>
        /// <returns></returns>
        public bool SendMessages(string[] messages, bool byOP = true)
        {
            if (messages.Length <= 0)
            {
                return(false);
            }
            var itemList = new List <Item>();

            // Terminal number
            // 0: Single or main terminal,
            // >0: Additional terminals at the same equipment.
            itemList.Add(A("0"));
            itemList.Add(
                new Func <string[], Item>((messageArr) =>
            {
                var itemList1 = new List <Item>();
                foreach (var ite in messageArr)
                {
                    itemList1.Add(A(ite ?? String.Empty));
                }
                return(itemList1.Count > 1 ? L(itemList1) : itemList1[0]);
            })(messages)
                );
            var item = L(itemList);

            if (byOP)
            {
                var replyMsg = S10F1(item);
                if (replyMsg != null && replyMsg.GetSFString() == "S10F2")
                {
                    var ack = replyMsg.GetCommandValue();
                    if (ack == 0)
                    {
                        eqtTerminalService.SendMessageDone(messages);
                        return(true);
                    }
                }
            }
            else
            {
                var replyMsg = S10F5(item);
                if (replyMsg != null && replyMsg.GetSFString() == "S10F6")
                {
                    var ack = replyMsg.GetCommandValue();
                    if (ack == 0)
                    {
                        eqtTerminalService.SendMessageDone(messages);
                        return(true);
                    }
                }
            }
            CIMBASE.WriteLog(AATS.Log.LogLevel.ERROR, "something wrong was happened when send display message.");
            return(false);
        }
Exemplo n.º 2
0
        public static Task <SecsMessage> SendMessage(this SecsGem secsGem, short deviceId, byte s, byte f, bool replyExpected, int systemBytes, Item item = null, string key = "", int value = 0)
        {
            SecsMessage secsMessage = new SecsMessage(s, f, replyExpected, GetFunctionName(s, f, key, value), item);

            CIMBASE.WriteLog(AATS.Log.LogLevel.INFO, "\r\n" + secsMessage.ToSml());
            if (systemBytes == -1)
            {
                return(secsGem.SendAsync(secsMessage));
            }
            else
            {
                return(secsGem.SendAsync(secsMessage, systemBytes));
            }
        }
        /// <summary>
        /// 设置Control State状态:
        /// CEID 113==>ONLINE REMOTE
        ///      112==>ONLINE LOCAL
        ///      111==>OFFLINE
        ///      114==>EQUIPMENT STATUS CHANGE
        /// </summary>
        /// <param name="ceid"></param>
        /// <returns></returns>
        private bool launchControlStateProcess(int ceid)
        {
            ControlStateChangeReport controlStateChangeReport = new ControlStateChangeReport()
            {
                CEID            = ceid,
                EquipmentStatus = new EquipmentStatus()
                {
                    CRST     = ceid == 114 ? CRST.R : (CRST)ceid,
                    EQST     = this._equipmentStatusInfo.EQST,
                    EQSTCODE = this._equipmentStatusInfo.EQSTCODE,
                },
                RPTID = 100,
            };
            var replyMsg = S6F11(controlStateChangeReport.SecsItem, (int)ceid);

            switch (ceid)
            {
            case (int)CRST.R:
            case (int)CRST.L:
                if (replyMsg != null && replyMsg.GetSFString() == "S6F12")
                {
                    int ack = replyMsg.GetCommandValue();
                    if (ack == 0)
                    {
                        this._equipmentStatusInfo = controlStateChangeReport.EquipmentStatus;
                        itializeScenario?.UpdateControlState(this._equipmentStatusInfo.CRST);
                        return(true);
                    }
                }
                break;

            case (int)CRST.O:    // no matter what happened, send control state change event
                this._equipmentStatusInfo = controlStateChangeReport.EquipmentStatus;
                itializeScenario?.UpdateControlState(this._equipmentStatusInfo.CRST);
                return(true);

            case 114:
                if (replyMsg != null && replyMsg.GetSFString() == "S6F12")
                {
                    return(replyMsg.GetCommandValue() == 0);
                }
                break;

            default:
                break;
            }
            CIMBASE.WriteLog(LogLevel.ERROR, "something was wrong when sending S6F11 message.");
            return(false);
        }
        /// <summary>
        /// 启动date and time更新请求
        /// </summary>
        /// <returns></returns>
        public bool LaunchDateTimeUpdateProcess()
        {
            CIMBASE.WriteLog(LogLevel.DEBUG, "send update date and time request to host.");
            var replyMsg = S2F17();

            if (replyMsg != null && replyMsg.GetSFString() == "S2F18")
            {
                var dateTimeStr = replyMsg.SecsItem.GetString();
                CIMBASE.WriteLog(LogLevel.DEBUG, "get response datetime string: " + dateTimeStr);
                itializeScenario?.UpdateDateTime(dateTimeStr);
                return(true);
            }
            CIMBASE.WriteLog(LogLevel.ERROR, "something wrong happened in sending update date and time request to host");
            return(false);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Equipment Constants data report
        /// </summary>
        /// <param name="report"></param>
        /// <returns></returns>
        public bool LaunchEquipmentConstantChangeReportProcess(IReport report)
        {
            SubScenarioName = Resource.DCS_Host_request_value_status;
            var replyMsg = S6F11(report.SecsItem, 109);

            if (replyMsg != null && replyMsg.GetSFString() == "S6F12")
            {
                var ack = replyMsg.GetCommandValue();
                if (ack == 0)
                {
                    return(true);
                }
            }
            CIMBASE.WriteLog(AATS.Log.LogLevel.ERROR, "something wrong was happened when send Epuipment Constanrs Report message.");
            return(false);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Glass/Lot/Mask Process result report
        /// </summary>
        /// <param name="report"></param>
        /// <returns></returns>
        public bool LaunchProcessResultReportProcess(IReport report)
        {
            SubScenarioName = Resource.DCS_Discrete_Variable_Data_Send;
            var processResult = (ProcessResultReport)report;
            var replyMsg      = S6F3(report.SecsItem, (int)processResult.CEID);

            if (replyMsg != null && replyMsg.GetSFString() == "S6F4")
            {
                var ack = replyMsg.GetCommandValue();
                if (ack == 0)
                {
                    return(true);
                }
            }
            CIMBASE.WriteLog(AATS.Log.LogLevel.ERROR, "something wrong was happened when sending process result report");
            return(false);
        }
        /// <summary>
        /// 启动建立连接进程 online by Unit
        /// </summary>
        /// <returns></returns>
        public bool LaunchOnlineProcess(EquipmentInfo equipmentInfo)
        {
            SubScenarioName           = Resource.Intialize_Scenario_1;
            this._equipmentBaseInfo   = equipmentInfo.EquipmentBase;
            this._equipmentStatusInfo = equipmentInfo.EquipmentStatus;
            // send estublish communication request
            var replyMsg = S1F13(_equipmentBaseInfo.SecsItem);

            if ((replyMsg != null && replyMsg.GetSFString() == "S1F14"))
            {
                var ack = replyMsg.GetCommandValue();
                if (ack != 0)
                {
                    CIMBASE.WriteLog(LogLevel.INFO, "Host denies establish communication request.");
                    return(false);
                }
            }
            if (replyMsg == null)
            {
                return(false);
            }
            replyMsg = S1F1();
            if (replyMsg == null || replyMsg.F == 0)
            {// host denies online request
                CIMBASE.WriteLog(LogLevel.INFO, "Host denies online request.");
                return(false);
            }
            CIMBASE.WriteLog(LogLevel.DEBUG, "Host grants online.");
            if (launchControlStateProcess((int)CRST.R))
            {
                if (LaunchDateTimeUpdateProcess())
                {
                    return(launchControlStateProcess(114));
                }
            }
            CIMBASE.WriteLog(LogLevel.ERROR, "estublish communication with host failed.");
            return(false);
        }
        /// <summary>
        /// local端Process Program or Recipe发生变化时向host发送通知
        /// </summary>
        /// <returns></returns>
        public bool LaunchRecipeChangeReportProcess(IReport report)
        {
            SubScenarioName = Resource.RMS_Recipe_Changed;
            var replyMsg = S6F11(report.SecsItem, 401);

            if (replyMsg != null && replyMsg.GetSFString() == "S6F12")
            {
                try
                {
                    int ack = replyMsg.GetCommandValue();
                    if (ack == 0)
                    {
                        return(true);
                    }
                }
                catch (InvalidOperationException ex)
                {
                    CIMBASE.WriteLog(AATS.Log.LogLevel.ERROR, "", ex);
                    return(false);
                }
            }
            CIMBASE.WriteLog(AATS.Log.LogLevel.ERROR, "something wrong was happened when send recipe change data");
            return(false);
        }
        /// <summary>
        /// Process Report
        /// CEID: 301=>start, 304=>cancel, 305=>abort, 306=>pause, 307=>resume
        /// </summary>
        /// <returns></returns>
        public bool LaunchProcessReport(RCMD rcmd,
                                        ProcessLaunchReport processLaunchReport,
                                        EquipmentStatus equipmentStatus)
        {
            int ceid = 0;

            switch (rcmd)
            {
            case RCMD.START:
                ceid = 301;
                break;

            case RCMD.CANCEL:
                ceid = 304;
                break;

            case RCMD.ABORT:
                ceid = 305;
                break;

            case RCMD.PAUSE:
                ceid = 306;
                break;

            case RCMD.RESUME:
                ceid = 307;
                break;

            case RCMD.OPERATOR_CALL:
            default:
                break;
            }
            if (ceid <= 0)
            {
                CIMBASE.WriteLog(AATS.Log.LogLevel.ERROR, "CEID value is out of range. CEID: " + ceid);
                return(false);
            }
            ProcessLaunchReport newReport = new ProcessLaunchReport(0, ceid, 100, equipmentStatus, 301)
            {
                LOTID     = processLaunchReport.LOTID,
                PTID      = processLaunchReport.PTID,
                PTTYPE    = processLaunchReport.PTTYPE,
                PTUSETYPE = processLaunchReport.PTUSETYPE,
                CSTID     = processLaunchReport.CSTID,
                PPID      = processLaunchReport.PPID,
            };
            var replyMsg = S6F11(newReport.SecsItem, (int)ceid);

            if (replyMsg != null && replyMsg.GetSFString() == "S6F12")
            {
                try
                {
                    int ack = replyMsg.GetCommandValue();
                    if (ack == 0)
                    {
                        return(true);
                    }
                }
                catch (InvalidOperationException ex)
                {
                    CIMBASE.WriteLog(AATS.Log.LogLevel.ERROR, "", ex);
                    return(false);
                }
            }
            CIMBASE.WriteLog(AATS.Log.LogLevel.ERROR, "something wrong was happened when send process report");
            return(false);
        }