Пример #1
0
        public void ReplyS3F20(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg)
        {
            string newReplyMsg = GetMessageName(replyMsg.ToSml());

            newReplyMsg += "< L[2]\r\n";

            newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n";
            newReplyMsg += "<L[0]\r\n>\r\n";

            newReplyMsg += ">\r\n";
            e.ReplyAsync(newReplyMsg.ToSecsMessage());

            E87_HostCommand hcObj = new E87_HostCommand
            {
                Name        = "CancelAllCarrier",
                MessageName = "S3F19",
                lpObj       = null,
                carrierObj  = null
            };

            ThreadPool.QueueUserWorkItem(callback =>
            {
                S3F19CancelAllCarrierEvent?.Invoke(this, hcObj);
            });
        }
Пример #2
0
        public void ReplyS2F14(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg)
        {
            //儲存所有要顯示的EC

            Dictionary <string, SecsFormat> tempECIDList = new Dictionary <string, SecsFormat>();

            CheckReceiveIDList(receiveMsg, ref tempECIDList, _ecIDList);

            string newReplyMsg = GetMessageName(replyMsg.ToSml());

            newReplyMsg += "< L[" + tempECIDList.Count.ToString() + "]\r\n";

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

            foreach (string ecid in tempECIDList.Keys)
            {
                ecidlist.Add(ecid);
            }

            newReplyMsg = RecursivelyECList(_ecIDList, ecidlist, newReplyMsg);

            newReplyMsg += ">";

            e.ReplyAsync(newReplyMsg.ToSecsMessage());
        }
Пример #3
0
        private void ReplyInOffLineState(PrimaryMessageWrapper e)
        {
            string SearchKey = "S" + e.Message.S.ToString() + "F0";

            _smlManager._messageList.TryGetValue(SearchKey, out SanwaSML smlObj);

            if (smlObj != null)
            {
                SecsMessage replySecsmsg = new SecsMessage(e.Message.S, (byte)0, smlObj.MessageName);
                replySecsmsg.ReplyExpected = false;

                string newReplyMsg = GetMessageName(replySecsmsg.ToSml());

                string text = smlObj.Text;
                string line;
                using (StringReader reader = new StringReader(text))
                {
                    while ((line = reader.ReadLine()) != null)
                    {
                        newReplyMsg += line;
                        newReplyMsg += "\r\n";
                    }
                }

                e.ReplyAsync(newReplyMsg.ToSecsMessage());
            }
            else
            {
                ThreadPool.QueueUserWorkItem(callback =>
                {
                    ReceiveInOffLineEvent?.Invoke(this, e);
                });
            }
        }
Пример #4
0
        private void ReplyCancelBindService(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg)
        {
            //    0. < DATAID >
            //    1. < CARRIERACTION >
            //    2. < CARRIERID >
            //    3. < PTN >
            string newReplyMsg = GetMessageName(replyMsg.ToSml());
            string carrierID   = e.Message.SecsItem.Items[2].GetString();
            Item   PTNItem     = e.Message.SecsItem.Items[3];

            LoadPort lpObj = _loadPortList.FirstOrDefault(x => x.Value.Number == PTNItem.GetValue <byte>()).Value;

            newReplyMsg += "< L[2]\r\n";

            _carrierList.TryGetValue(carrierID, out SanwaCarrier carrierObj);

            if (lpObj == null)
            {
                //無對應Load Port
                newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n";
                newReplyMsg += "<L[2]\r\n";
                newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_LOAD_PORT_DOES_NOT_EXIST.ToString());
                newReplyMsg += "<A[0]>\r\n";
                newReplyMsg += ">\r\n";
            }
            else if (carrierObj == null)
            {
                newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n";
                newReplyMsg += "<L[2]\r\n";
                newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_UNKNOWN_OBJECT_INSTANCE.ToString());
                newReplyMsg += "<A[0]>\r\n";
                newReplyMsg += ">\r\n";
            }
            else
            {
                _carrierList.Remove(carrierObj.ObjID);

                newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n";
                newReplyMsg += "<L[0]\r\n>\r\n";

                E87_HostCommand Obj = new E87_HostCommand
                {
                    Name        = "CancelBind",
                    MessageName = "S3F17",
                    lpObj       = lpObj,
                    carrierObj  = carrierObj
                };

                //S3F17CancelBindEvent?.Invoke(this, Obj);
                ThreadPool.QueueUserWorkItem(callback =>
                {
                    S3F17CancelBindEvent?.Invoke(this, Obj);
                });
            }

            newReplyMsg += ">\r\n";
            e.ReplyAsync(newReplyMsg.ToSecsMessage());
        }
Пример #5
0
        private void ReplyOffLineState(PrimaryMessageWrapper e, SecsMessage secsMessage, byte[] OFLACK)
        {
            SecsMessage relymsg = new SecsMessage(secsMessage.S, secsMessage.F,
                                                  secsMessage.Name,
                                                  Item.B(OFLACK),
                                                  false);

            e.ReplyAsync(relymsg);
        }
Пример #6
0
        public bool ReplyS1F2(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg)
        {
            bool ReturnOutput = true;

            string SearchKey = "S1F2";

            _smlManager._messageList.TryGetValue(SearchKey, out SanwaSML smlObj);
            string text = smlObj.Text;

            string line;

            string newReplyMsg = GetMessageName(replyMsg.ToSml());

            using (StringReader reader = new StringReader(text))
            {
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.Contains("\'"))
                    {
                        if (line.Contains("MDLN"))
                        {
                            GetSVData(SVName.GEM_MDLN, out SanwaSV mdlnSV);
                            newReplyMsg += "<A[0]" + mdlnSV._value + ">\r\n";
                        }
                        else if (line.Contains("SOFTREV"))
                        {
                            GetSVData(SVName.GEM_SOFTREV, out SanwaSV softrevSV);
                            newReplyMsg += "<A[0]" + softrevSV._value + ">\r\n";
                        }
                        else
                        {
                            ReturnOutput = false;
                        }
                    }
                    else
                    {
                        newReplyMsg += line;
                        newReplyMsg += "\r\n";
                    }
                }
            }

            if (ReturnOutput)
            {
                e.ReplyAsync(newReplyMsg.ToSecsMessage());
            }

            return(ReturnOutput);

            //newReplyMsg += "<L[2]\r\n";
            //GetSVData(SVName.GEM_MDLN, out SanwaSV mdlnSV);
            //GetSVData(SVName.GEM_SOFTREV, out SanwaSV softrevSV);
            //newReplyMsg += "<A[0]" + mdlnSV._value + ">\r\n";
            //newReplyMsg += "<A[0]" + softrevSV._value + ">\r\n";

            //newReplyMsg += ">\r\n";
        }
Пример #7
0
        public void ReplyS2F18(PrimaryMessageWrapper e, SecsMessage replyMsg)
        {
            string datetime = GetDateTime();

            //_svList.TryGetValue(SVName.GEM_CLOCK, out SanwaSV svObj);
            //if(svObj != null) svObj._value = datetime;
            SetSV(SVName.GEM_CLOCK, datetime);
            replyMsg.SecsItem = Item.A(datetime);

            e.ReplyAsync(replyMsg);
        }
Пример #8
0
        public void ReplyS1F12(PrimaryMessageWrapper e, SecsMessage receiveSecsmsg, SecsMessage tempReplySecsmsg)
        {
            //1.複製"收到訊息格式"給"回覆訊息的格式"
            //2.根據訊息長度決定根據SVID回覆,還是全部回覆
            //2.a.將個別SVID存入List裡面
            //2.b.將所有SVID存入List裡面
            //3.根據SVID開始寫檔

            //1.複製"收到訊息格式"給"回覆訊息的格式"
            CopyReceiveMsgToReply(ref receiveSecsmsg, ref tempReplySecsmsg);

            Dictionary <string, SecsFormat> svIDList = new Dictionary <string, SecsFormat>();

            if (tempReplySecsmsg.SecsItem.Count > 0)//2.根據訊息長度決定根據SVID回覆,還是全部回覆
            {
                //a.將個別SVID存入List裡面
                foreach (Item items in receiveSecsmsg.SecsItem.Items)
                {
                    SetItemToStringType(items, out string id);
                    //SanwaSV svObj = _svList.FirstOrDefault(x => x.Value._id == id).Value;
                    _svIDList.TryGetValue(id, out SanwaSV svObj);
                    if (svObj != null)
                    {
                        svIDList.Add(svObj._id, items.Format);
                    }
                    else
                    {
                        svIDList.Add(id, items.Format);
                    }
                }
            }
            else
            {
                //2.b.將所有SVID存入List裡面
                foreach (KeyValuePair <string, SanwaSV> item in _svIDList)
                {
                    //暫時將輸出SVID的Format定義為U4
                    svIDList.Add(item.Key, SecsFormat.U4);
                }
            }

            //3.根據SVID開始寫檔
            string smlFormat = tempReplySecsmsg.ToSml();

            //4.編輯SML檔
            string NewsmlFormat = ParseSVNRRToSML(svIDList, smlFormat);

            //5.轉換為SECSMessage
            tempReplySecsmsg = NewsmlFormat.ToSecsMessage();

            e.ReplyAsync(tempReplySecsmsg);
        }
Пример #9
0
        public void ReplyS16F20(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg)
        {
            string newReplyMsg = GetMessageName(replyMsg.ToSml());

            newReplyMsg += "<L[" + _pJList.Count + "]\r\n";
            foreach (var pjObj in _pJList)
            {
                newReplyMsg += "<L[2]\r\n";
                newReplyMsg += "<A[0]" + pjObj.ObjID + ">\r\n";
                newReplyMsg += "<U1[0]" + ((byte)pjObj.PRJobState).ToString() + ">\r\n";
                newReplyMsg += ">\r\n";
            }
            newReplyMsg += ">\r\n";

            e.ReplyAsync(newReplyMsg.ToSecsMessage());
        }
Пример #10
0
        private void ReplyCancelCarrierNotificationService(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg)
        {
            //    0. < DATAID >
            //    1. < CARRIERACTION >
            //    2. < CARRIERID >
            //    3. < PTN >
            string newReplyMsg = GetMessageName(replyMsg.ToSml());
            string carrierID   = e.Message.SecsItem.Items[2].GetString();

            newReplyMsg += "< L[2]\r\n";

            _carrierList.TryGetValue(carrierID, out SanwaCarrier carrierObj);

            if (carrierObj == null)
            {
                newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n";
                newReplyMsg += "<L[2]\r\n";
                newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_UNKNOWN_OBJECT_INSTANCE.ToString());
                newReplyMsg += "<A[0]>\r\n";
                newReplyMsg += ">\r\n";
            }
            else
            {
                _carrierList.Remove(carrierObj.ObjID);

                newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n";
                newReplyMsg += "<L[0]\r\n>\r\n";

                E87_HostCommand Obj = new E87_HostCommand
                {
                    Name        = "CancelCarrierNotification",
                    MessageName = "S3F17",
                    lpObj       = null,
                    carrierObj  = carrierObj
                };

                //S3F17CancelCarrierNotificationEvent?.Invoke(this, Obj);
                ThreadPool.QueueUserWorkItem(callback =>
                {
                    S3F17CancelCarrierNotificationEvent?.Invoke(this, Obj);
                });
            }

            newReplyMsg += ">\r\n";
            e.ReplyAsync(newReplyMsg.ToSecsMessage());
        }
Пример #11
0
        public void ReplyS5F6(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg)
        {
            //儲存所有要顯示的EC
            //List<string> alarmidlist = new List<string>();
            Dictionary <string, SecsFormat> alarmidlist = new Dictionary <string, SecsFormat>();

            CheckReceiveIDList(receiveMsg, ref alarmidlist, _alarmIDList);

            string newReplyMsg = GetMessageName(replyMsg.ToSml());

            newReplyMsg += "< L[" + alarmidlist.Count.ToString() + "]\r\n";

            newReplyMsg = GetAlarmDetailItem(_alarmIDList, alarmidlist, newReplyMsg);

            newReplyMsg += ">";

            e.ReplyAsync(newReplyMsg.ToSecsMessage());
        }
Пример #12
0
        public void ReplyS1F4(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg)
        {
            Dictionary <string, SecsFormat> sVIDList = new Dictionary <string, SecsFormat>();

            CheckReceiveIDList(receiveMsg, ref sVIDList, _svIDList);

            string newReplyMsg = GetMessageName(replyMsg.ToSml());

            newReplyMsg += "< L[" + sVIDList.Count.ToString() + "]\r\n";

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

            foreach (string id in sVIDList.Keys)
            {
                tempSVIDList.Add(id);
            }

            newReplyMsg  = RecursivelySVList(_svIDList, tempSVIDList, newReplyMsg);
            newReplyMsg += ">";

            e.ReplyAsync(newReplyMsg.ToSecsMessage());
        }
Пример #13
0
        public void ReplyChangeAccess(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg, bool autoMode)
        {
            string newReplyMsg = GetMessageName(replyMsg.ToSml());
            Item   PTNItem     = e.Message.SecsItem.Items[1];
            Item   ChangeAccessList;

            if (e.Message.SecsItem.Count == 3)  //CHANGESERVICESTATUS
            {
                ChangeAccessList = e.Message.SecsItem.Items[2];

                if (ChangeAccessList.Count > 0)
                {
                    //0 :Manual
                    //1 :Auto

                    Item PARAMVALItem = ChangeAccessList.Items[1];
                    switch (PARAMVALItem.Format)
                    {
                    case SecsFormat.ASCII:
                        autoMode = PARAMVALItem.GetString() == "0" ? false : true;
                        break;

                    case SecsFormat.Binary:
                        byte[] paramval = PARAMVALItem.GetValues <byte>();
                        autoMode = paramval[0] == 0x00 ? false : true;
                        break;

                    case SecsFormat.Boolean:
                        autoMode = PARAMVALItem.GetValue <bool>();
                        break;

                    case SecsFormat.F4:
                        autoMode = PARAMVALItem.GetValue <float>() == 0.0f ? false : true;
                        break;

                    case SecsFormat.F8:
                        autoMode = PARAMVALItem.GetValue <double>() == 0.0d ? false : true;
                        break;

                    case SecsFormat.I1:
                        autoMode = PARAMVALItem.GetValue <byte>() == 0 ? false : true;
                        break;

                    case SecsFormat.I2:
                        autoMode = PARAMVALItem.GetValue <short>() == 0 ? false : true;
                        break;

                    case SecsFormat.I4:
                        autoMode = PARAMVALItem.GetValue <int>() == 0 ? false : true;
                        break;

                    case SecsFormat.I8:
                        autoMode = PARAMVALItem.GetValue <long>() == 0 ? false : true;
                        break;

                    case SecsFormat.U1:
                        autoMode = PARAMVALItem.GetValue <sbyte>() == 0 ? false : true;
                        break;

                    case SecsFormat.U2:
                        autoMode = PARAMVALItem.GetValue <ushort>() == 0 ? false : true;
                        break;

                    case SecsFormat.U4:
                        autoMode = PARAMVALItem.GetValue <uint>() == 0 ? false : true;
                        break;

                    case SecsFormat.U8:
                        autoMode = PARAMVALItem.GetValue <ulong>() == 0 ? false : true;
                        break;
                    }
                }
            }

            LoadPort lpObj = _loadPortList.FirstOrDefault(x => x.Value.Number == PTNItem.GetValue <byte>()).Value;

            newReplyMsg += "< L[2]\r\n";

            if (lpObj == null)
            {
                newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n";
                newReplyMsg += "<L[0]\r\n";
                newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_LOAD_PORT_DOES_NOT_EXIST.ToString());
                newReplyMsg += "<A[0]>\r\n";
                newReplyMsg += ">\r\n";
            }
            else
            {
                E87RETURN_AM Return;

                if (autoMode)
                {
                    Return = ChangeAccessMode(lpObj, E87_AM.AUTO);
                }
                else
                {
                    Return = ChangeAccessMode(lpObj, E87_AM.MANUAL);
                }


                if (Return == E87RETURN_AM.SUCCESSFUL || Return == E87RETURN_AM.IN_ACCESS_MODE_ALREADY)
                {
                    newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n";
                    newReplyMsg += "<L[0]\r\n>\r\n";

                    if (Return == E87RETURN_AM.SUCCESSFUL)
                    {
                        if (autoMode)
                        {
                            E87_HostCommand hcObj = new E87_HostCommand
                            {
                                lpObj       = lpObj,
                                Name        = "AUTOMODE",
                                MessageName = "S3F25"
                            };
                            S3F25AutoModeEvent?.Invoke(this, hcObj);
                        }
                        else
                        {
                            E87_HostCommand hcObj = new E87_HostCommand
                            {
                                lpObj       = lpObj,
                                Name        = "MANUALMODE",
                                MessageName = "S3F25"
                            };
                            S3F25ManualModeEvent?.Invoke(this, hcObj);
                        }
                    }
                }
                else
                {
                    newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n";
                    newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_OBJECT_IDENTIFIER_IN_USE.ToString());
                    newReplyMsg += "<A[0]>\r\n";
                }
            }
            newReplyMsg += ">\r\n";

            e.ReplyAsync(newReplyMsg.ToSecsMessage());
        }
Пример #14
0
        public void ReplyS16F18(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg)
        {
            //L,m[m = # jobs to remove]
            //    1. <PRJOBID1>
            //    .
            //    m. <PRJOBIDm>

            //L,2
            //    1.L,m[m = # jobs removed]
            //        1. <PRJOBID1>
            //        .
            //        m. <PRJOBIDm>
            //    2. L,2
            //        1. <ACKA>
            //        2. L,n
            //            1. L,2
            //                1. <ERRCODE1>
            //                2. <ERRTEXT1>
            //            .
            //            n. L,2
            //                1. <ERRCODEn>
            //                2. <ERRTEXTn>

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

            Item PRJOBIDItemList = e.Message.SecsItem;

            if (PRJOBIDItemList.Count.Equals(0))
            {
                foreach (SanwaPJ sanwaPJ in _pJQueue)
                {
                    prJobID.Add(sanwaPJ.ObjID);
                }
            }
            else
            {
                for (int m = 0; m < PRJOBIDItemList.Count; m++)
                {
                    Item PRJOBIDItem = PRJOBIDItemList.Items[m];

                    SetItemToStringType(PRJOBIDItem, out string jobID);

                    var sanwaPJObjQ = _pJQueue
                                      .Where(x => x.ObjID.Equals(jobID))
                                      .Select(x => x);

                    foreach (var sanwaPJ in sanwaPJObjQ)
                    {
                        SanwaPJ PJ = (SanwaPJ)sanwaPJ;
                        prJobID.Add(PJ.ObjID);
                    }
                }
            }

            bool acka = SanwaACK.ACKA_SUCCESSFUL;

            if (acka == SanwaACK.ACKA_SUCCESSFUL)
            {
                foreach (var id in prJobID)
                {
                    int count;
                    count = _pJQueue.RemoveAll(x => x.ObjID == id);

                    if (!count.Equals(0))
                    {
                        _pJList.RemoveAll(x => x.ObjID == id);
                    }
                }
            }

            string newReplyMsg = GetMessageName(replyMsg.ToSml());

            newReplyMsg += "<L[2]\r\n";
            newReplyMsg += "<L[" + prJobID.Count + "]\r\n";
            foreach (string ObjID in prJobID)
            {
                newReplyMsg += "<A[1]" + ObjID + ">\r\n";
            }
            newReplyMsg += ">\r\n";
            newReplyMsg += "<L[2]\r\n";
            newReplyMsg += "<Boolean[1]" + acka.ToString() + ">\r\n";
            newReplyMsg += "<L[0]\r\n";
            newReplyMsg += ">\r\n";
            newReplyMsg += ">\r\n";
            newReplyMsg += ">\r\n";

            e.ReplyAsync(newReplyMsg.ToSecsMessage());
        }
Пример #15
0
        private void ReplyCarrierReCreate(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg)
        {
            //    0. < DATAID >
            //    1. < CARRIERACTION >
            //    2. < CARRIERID >
            //    3. < PTN >
            string newReplyMsg = GetMessageName(replyMsg.ToSml());

            string carrierID = e.Message.SecsItem.Items[2].GetString();
            Item   PTNItem   = e.Message.SecsItem.Items[3];

            LoadPort lpObj = _loadPortList.FirstOrDefault(x => x.Value.Number == PTNItem.GetValue <byte>()).Value;

            newReplyMsg += "< L[2]\r\n";

            _carrierList.TryGetValue(carrierID, out SanwaCarrier carrierObj);

            if (lpObj == null)
            {
                //無對應Load Port
                newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n";
                newReplyMsg += "<L[2]\r\n";
                newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_LOAD_PORT_DOES_NOT_EXIST.ToString());
                newReplyMsg += "<A[0]>\r\n";
                newReplyMsg += ">\r\n";
            }
            //else if (lpObj.IsReserved == E87_RS.RESERVED)
            //{
            //    newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n";
            //    newReplyMsg += "<L[2]\r\n";
            //    newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_LOAD_PORT_ALREADY_IN_USE.ToString());
            //    newReplyMsg += "<A[0]>\r\n";
            //    newReplyMsg += ">\r\n";
            //}
            else if (carrierObj == null)
            {
                newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n";
                newReplyMsg += "<L[2]\r\n";
                newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_UNKNOWN_OBJECT_INSTANCE.ToString());
                newReplyMsg += "<A[0]>\r\n";
                newReplyMsg += ">\r\n";
            }
            else if (lpObj.CurrentState != E87_LPTS.READY_TO_UNLOAD)
            {
                newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n";
                newReplyMsg += "<L[2]\r\n";
                newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_COMMAND_NOT_VALID_FOR_CURRENT_STATE.ToString());
                newReplyMsg += "<A[0]>\r\n";
                newReplyMsg += ">\r\n";
            }
            else
            {
                Item  CattrList        = e.Message.SecsItem.Items[4];
                ulong CheckCattrReturn = CheckCattrList(CattrList);

                if (CheckCattrReturn != SanwaACK.ERRCODE_NO_ERROR)
                {
                    newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n";
                    newReplyMsg += "<L[2]\r\n";
                    newReplyMsg += GetToSMLItem(SecsFormat.U1, CheckCattrReturn.ToString());
                    newReplyMsg += "<A[0]>\r\n";
                    newReplyMsg += ">\r\n";
                }
                else
                {
                    newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n";
                    newReplyMsg += "<L[0]\r\n>\r\n";

                    _carrierList.Remove(carrierID);

                    SanwaCarrier newCarrierObj = new SanwaCarrier
                    {
                        ObjID = carrierID
                    };

                    SetCarrierAttribute(CattrList, ref newCarrierObj);

                    _carrierList.Add(newCarrierObj.ObjID, newCarrierObj);

                    //ChangeReserviceState(lpObj, E87_RS.NOT_RESERVED);

                    //LoadPortCarrierAssociated(lpObj, newCarrierObj, E87_ASSOCIATED.NOT_ASSOCIATION);

                    ////等效於Bind
                    //if (CattrList.Count > 0)
                    //{
                    //    ChangeReserviceState(lpObj, E87_RS.RESERVED);

                    //    LoadPortCarrierAssociated(lpObj, newCarrierObj, E87_ASSOCIATED.ASSOCIATION);
                    //}


                    E87_HostCommand Obj = new E87_HostCommand
                    {
                        Name        = "CarrierReCreate",
                        MessageName = "S3F17",
                        lpObj       = lpObj,
                        carrierObj  = newCarrierObj
                    };

                    //S3F17CarrierReCreateEvent?.Invoke(this, Obj);
                    ThreadPool.QueueUserWorkItem(callback =>
                    {
                        S3F17CarrierReCreateEvent?.Invoke(this, Obj);
                    });
                }
            }

            newReplyMsg += ">\r\n";
            e.ReplyAsync(newReplyMsg.ToSecsMessage());
        }
Пример #16
0
        private void ReplyCarrierNotificationService(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg)
        {
            //    0. < DATAID >
            //    1. < CARRIERACTION >
            //    2. < CARRIERID >
            //    3. < PTN >
            string newReplyMsg = GetMessageName(replyMsg.ToSml());
            string carrierID   = e.Message.SecsItem.Items[2].GetString();

            newReplyMsg += "< L[2]\r\n";

            _carrierList.TryGetValue(carrierID, out SanwaCarrier carrierObj);

            if (carrierObj != null)
            {
                newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n";
                newReplyMsg += "<L[2]\r\n";
                newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_OBJECT_IDENTIFIER_IN_USE.ToString());
                newReplyMsg += "<A[0]>\r\n";
                newReplyMsg += ">\r\n";
            }
            else
            {
                Item  CattrList        = e.Message.SecsItem.Items[4];
                ulong CheckCattrReturn = CheckCattrList(CattrList);

                if (CheckCattrReturn != SanwaACK.ERRCODE_NO_ERROR)
                {
                    newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n";
                    newReplyMsg += "<L[2]\r\n";
                    newReplyMsg += GetToSMLItem(SecsFormat.U1, CheckCattrReturn.ToString());
                    newReplyMsg += "<A[0]>\r\n";
                    newReplyMsg += ">\r\n";
                }
                else
                {
                    newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n";
                    newReplyMsg += "<L[0]\r\n>\r\n";

                    SanwaCarrier newCarrierObj = new SanwaCarrier
                    {
                        ObjID = carrierID
                    };

                    SetCarrierAttribute(CattrList, ref newCarrierObj);

                    _carrierList.Add(newCarrierObj.ObjID, newCarrierObj);

                    E87_HostCommand Obj = new E87_HostCommand
                    {
                        Name        = "CarrierNotification",
                        MessageName = "S3F17",
                        lpObj       = null,
                        carrierObj  = newCarrierObj
                    };

                    //S3F17CarrierNotificationEvent?.Invoke(this, Obj);
                    ThreadPool.QueueUserWorkItem(callback =>
                    {
                        S3F17CarrierNotificationEvent?.Invoke(this, Obj);
                    });
                }
            }
            newReplyMsg += ">\r\n";
            e.ReplyAsync(newReplyMsg.ToSecsMessage());
        }
Пример #17
0
        private void ReplyAccessMode(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg, bool GroupDefine)
        {
            Item PORTGRPNAMEItem = null;
            Item ACCESSMODEItem  = null;
            Item PTNList         = null;

            if (GroupDefine)
            {
                PORTGRPNAMEItem = e.Message.SecsItem.Items[0];
                ACCESSMODEItem  = e.Message.SecsItem.Items[1];
                PTNList         = e.Message.SecsItem.Items[2];
            }
            else
            {
                ACCESSMODEItem = e.Message.SecsItem.Items[0];
                PTNList        = e.Message.SecsItem.Items[1];
            }

            if (GroupDefine)
            {
                string LPGroupName = PORTGRPNAMEItem.GetString();
                _loadPortGroupList.TryGetValue(LPGroupName, out LoadPortGroup LPGObj);

                if (LPGObj != null)
                {
                    _loadPortGroupList.Remove(LPGroupName);
                }

                if (PTNList.Count > 0)
                {
                    LoadPortGroup lpgObj = new LoadPortGroup
                    {
                        Name = LPGroupName
                    };

                    for (int i = 0; i < PTNList.Count; i++)
                    {
                        Item     PTNItem = PTNList.Items[i];
                        byte     ptn     = PTNItem.GetValue <byte>();
                        LoadPort loadObj = _loadPortList.FirstOrDefault(x => x.Value.Number == ptn).Value;
                        if (loadObj != null)
                        {
                            lpgObj._loadPortList.Add(loadObj.Name, loadObj);
                        }
                    }

                    _loadPortGroupList.Add(LPGroupName, lpgObj);
                }
            }

            string newReplyMsg = GetMessageName(replyMsg.ToSml());

            newReplyMsg += "< L[2]\r\n";

            Dictionary <string, SanwaLoadPortACK> LPACKList = new Dictionary <string, SanwaLoadPortACK>();

            if (ACCESSMODEItem.Format != SecsFormat.U1 || PTNList.Format != SecsFormat.List)
            {
                newReplyMsg += "<U1[0] " + SanwaACK.CAACK_INVALID_DATA.ToString() + ">\r\n";
                newReplyMsg += "<L[0]\r\n>\r\n";
            }
            else
            {
                byte accessmode = ACCESSMODEItem.GetValue <byte>();

                bool allPTNSuccessful = true;

                if (PTNList.Count > 0)
                {
                    for (int i = 0; i < PTNList.Count; i++)
                    {
                        Item             PTNItem  = PTNList.Items[i];
                        SanwaLoadPortACK lpACKObj = new SanwaLoadPortACK();
                        byte             ptn      = PTNItem.GetValue <byte>();
                        LoadPort         loadObj  = _loadPortList.FirstOrDefault(x => x.Value.Number == ptn).Value;

                        if (loadObj == null)
                        {
                            allPTNSuccessful = false;

                            lpACKObj.PortNumber = ptn;
                            lpACKObj.ErrCode    = SanwaACK.ERRCODE_LOAD_PORT_DOES_NOT_EXIST;
                        }
                        else
                        {
                            CheckLoadPortACK(GroupDefine, accessmode, loadObj, ref lpACKObj, ref allPTNSuccessful);
                        }

                        LPACKList.Add(lpACKObj.PortNumber.ToString(), lpACKObj);
                    }
                }
                else
                {
                    foreach (var loadObj in _loadPortList.Values)
                    {
                        SanwaLoadPortACK lpACKObj = new SanwaLoadPortACK();

                        CheckLoadPortACK(GroupDefine, accessmode, loadObj, ref lpACKObj, ref allPTNSuccessful);

                        LPACKList.Add(lpACKObj.PortNumber.ToString(), lpACKObj);
                    }
                }

                if (allPTNSuccessful)
                {
                    newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n";
                    newReplyMsg += "<L[0]\r\n>\r\n";
                }
                else
                {
                    newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n";
                    foreach (var lpACKObj in LPACKList.Values)
                    {
                        newReplyMsg += GetToSMLItem(SecsFormat.U1, lpACKObj.ErrCode.ToString());
                        newReplyMsg += GetToSMLItem(SecsFormat.ASCII, lpACKObj.ErrText);
                    }
                }

                newReplyMsg += ">\r\n";
                e.ReplyAsync(newReplyMsg.ToSecsMessage());
            }
        }
Пример #18
0
        public void ReplyS16F12(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg)
        {
            //L,7
            //    1.  < DATAID >
            //    2.  < PRJOBID >
            //    3.  < MF >
            //    4a.L,n[MF = carrier, n = # of carriers]
            //        1. L,2
            //            1. <CARRIERID1>
            //            2. L,j   [j = # of slots, may be implemented as an array]
            //                1. <SLOTID1>
            //                .
            //                j. <SLOTIDj>
            //        .
            //        n. L,2
            //            1. <CARRIERIDn>
            //            2. L,j   [j = # of slots, may be implemented as an array]
            //                1. <SLOTID1>
            //                .
            //                j. <SLOTIDj>
            //    4b. L,n    [MF = substrate]
            //        1. <MID1>
            //        .
            //        n. <MIDn>
            //    5.  L,3
            //        1. <PRRECIPEMETHOD>
            //        2. <RCPSPEC> or <PPID>
            //        3. L,m   [m = # recipe parameters]
            //            1. L,2
            //                1. <RCPPARNM1>
            //                2. <RCPPARVAL1>
            //            .
            //            m. L,2
            //                1. <RCPPARNMm>
            //                2. <RCPPARVALm>
            //    6. <PRPROCESSSTART>
            //    7. <PRPAUSEEVENT>

            // The list for specifying material (item 4a and 4b) is empty (L, 0 instead of L, n),
            // when no material is specified for the Process Job.
            // The form of data item 4(a or b) depends on the value in MF.
            // If an implementer used PPID for this message,
            // the format of PPID shall be ASCII because RecID is defined as the text in SEMI E40.

            //L,2
            //    1. < PRJOBID >
            //    2.L,2
            //        1. < ACKA >
            //        2.L,n(n = { 0,n})
            //            1.L,2
            //                1. < ERRCODE1 >
            //                2. < ERRTEXT1 >
            //            .
            //            n.L,2
            //                1. < ERRCODEn >
            //                2. < ERRTEXTn >

            //檢查相關格式 Start
            bool               acka = SanwaACK.ACKA_SUCCESSFUL;
            ErrorStatus        errorStatus;
            List <ErrorStatus> errorList = new List <ErrorStatus>();

            Item PRJOBIDItem        = null;
            Item MFItem             = null;
            Item MFItemList         = null;
            Item PPIDItemList       = null;
            Item PRRECIPEMETHODItem = null;
            Item PPIDItem           = null;
            Item RCPPARItemList     = null;
            Item PRPROCESSSTARTItem = null;
            Item PRPAUSEEVENTItem   = null;

            if (e.Message.SecsItem.Count != 7)
            {
                acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                errorStatus = new ErrorStatus
                {
                    Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                    Errortext = "Parameters improperly specified"
                };
                errorList.Add(errorStatus);

                _logger.Warn("ReplyS6F12_e.Message.SecsItem.Count != 7");
            }
            else
            {
                PRJOBIDItem        = e.Message.SecsItem.Items[1];
                MFItem             = e.Message.SecsItem.Items[2];
                MFItemList         = e.Message.SecsItem.Items[3];
                PPIDItemList       = e.Message.SecsItem.Items[4];
                PRPROCESSSTARTItem = e.Message.SecsItem.Items[5];
                PRPAUSEEVENTItem   = e.Message.SecsItem.Items[6];

                if (!CheckFomart20(PRJOBIDItem))
                {
                    acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                    errorStatus = new ErrorStatus
                    {
                        Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                        Errortext = "Parameters improperly specified"
                    };
                    errorList.Add(errorStatus);

                    _logger.Warn("ReplyS6F12_!CheckFomart20(PRJOBIDItem)");
                }
                else
                {
                    if (PRJOBIDItem.GetString().Length.Equals(0))
                    {
                        acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                        errorStatus = new ErrorStatus
                        {
                            Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                            Errortext = "PRJobID is empty"
                        };
                        errorList.Add(errorStatus);

                        _logger.Warn("ReplyS6F12_PRJOBIDItem.GetString().Length.Equals(0)");
                    }
                    else
                    {
                        bool IsMemberExists = _pJList.Exists(x => x.ObjID.Equals(PRJOBIDItem.GetString()));

                        if (IsMemberExists)
                        {
                            acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                            errorStatus = new ErrorStatus
                            {
                                Errorcode = SanwaACK.ERRCODE_OBJECT_IDENTIFIER_IN_USE,
                                Errortext = "PRJobID identifier in use"
                            };
                            errorList.Add(errorStatus);

                            _logger.Warn("ReplyS6F12_Object identifier in use");
                        }
                    }
                }

                if (!CheckFomart1020(MFItem))
                {
                    acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                    errorStatus = new ErrorStatus
                    {
                        Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                        Errortext = "Parameters improperly specified"
                    };
                    errorList.Add(errorStatus);

                    _logger.Warn("ReplyS6F12_!CheckFomart1020(MFItem)");
                }
                else
                {
                    if (MFItem.Format == SecsFormat.Binary)
                    {
                        if (MFItem.Count != 0)
                        {
                            byte[] mf = MFItem.GetValues <byte>();

                            if (mf[0] != (byte)E30_MF.IN_CARRIERS &&
                                mf[0] != (byte)E30_MF.IN_SUBSTRATES)
                            {
                                acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                                errorStatus = new ErrorStatus
                                {
                                    Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                                    Errortext = "Parameters improperly specified"
                                };
                                errorList.Add(errorStatus);

                                _logger.Warn("ReplyS6F12_(mf[0] != (byte)E30_MF.IN_CARRIERS && mf[0] != (byte)E30_MF.IN_SUBSTRATES)");
                            }
                            else
                            {
                                if (MFItemList.Format != SecsFormat.List)
                                {
                                    acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                                    errorStatus = new ErrorStatus
                                    {
                                        Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                                        Errortext = "Parameters improperly specified"
                                    };
                                    errorList.Add(errorStatus);


                                    _logger.Warn("ReplyS6F12_MFItemList.Format != SecsFormat.List");
                                }
                                else
                                {
                                    if (mf[0] == E30_MF.IN_CARRIERS)
                                    {
                                        for (int i = 0; i < MFItemList.Count; i++)
                                        {
                                            Item item = MFItemList.Items[i];

                                            if (item.Format != SecsFormat.List)
                                            {
                                                acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                                                errorStatus = new ErrorStatus
                                                {
                                                    Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                                                    Errortext = "Parameters improperly specified"
                                                };
                                                errorList.Add(errorStatus);

                                                _logger.Warn("ReplyS6F12_item.Format != SecsFormat.List");
                                            }
                                            else
                                            {
                                                Item CarrierItem    = item.Items[0];
                                                Item SlotIDItemList = item.Items[1];

                                                if (!CheckFomart20(CarrierItem) || SlotIDItemList.Format != SecsFormat.List)
                                                {
                                                    acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                                                    errorStatus = new ErrorStatus
                                                    {
                                                        Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                                                        Errortext = "Parameters improperly specified"
                                                    };
                                                    errorList.Add(errorStatus);

                                                    _logger.Warn("ReplyS6F12_!CheckFomart20(CarrierItem) || SlotIDItemList.Format != SecsFormat.List");
                                                }
                                                else if (CarrierItem.GetString().Equals(0))
                                                {
                                                    acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                                                    errorStatus = new ErrorStatus
                                                    {
                                                        Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                                                        Errortext = "Carrier is empty"
                                                    };
                                                    errorList.Add(errorStatus);

                                                    _logger.Warn("ReplyS6F12_CarrierItem.GetString().Equals(0)");
                                                }
                                                else
                                                {
                                                    for (int j = 0; j < SlotIDItemList.Count; j++)
                                                    {
                                                        Item slotItem = SlotIDItemList.Items[j];

                                                        if (slotItem.Format != SecsFormat.U1)
                                                        {
                                                            acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                                                            errorStatus = new ErrorStatus
                                                            {
                                                                Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                                                                Errortext = "Parameters improperly specified"
                                                            };
                                                            errorList.Add(errorStatus);

                                                            _logger.Warn("ReplyS6F12_slotItem.Format != SecsFormat.U1");
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        for (int i = 0; i < MFItemList.Count; i++)
                                        {
                                            Item item = MFItemList.Items[i];

                                            if (item.Format != SecsFormat.ASCII)
                                            {
                                                acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                                                errorStatus = new ErrorStatus
                                                {
                                                    Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                                                    Errortext = "Parameters improperly specified"
                                                };
                                                errorList.Add(errorStatus);
                                                _logger.Warn("ReplyS6F12_item.Format != SecsFormat.ASCII");
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        //Items with format 20 will be a unit identifier for one of the special SECS generic units,
                        //as specified in § 12
                    }
                }

                if (PPIDItemList.Format != SecsFormat.List)
                {
                    acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                    errorStatus = new ErrorStatus
                    {
                        Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                        Errortext = "Parameters improperly specified"
                    };
                    errorList.Add(errorStatus);
                    _logger.Warn("ReplyS6F12_PPIDItemList.Format != SecsFormat.List");
                }
                else
                {
                    PRRECIPEMETHODItem = PPIDItemList.Items[0];
                    PPIDItem           = PPIDItemList.Items[1];
                    RCPPARItemList     = PPIDItemList.Items[2];

                    //bool mFFormatErrror = false;
                    if (PRRECIPEMETHODItem.Format != SecsFormat.U1)
                    {
                        acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                        errorStatus = new ErrorStatus
                        {
                            Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                            Errortext = "Parameters improperly specified"
                        };
                        errorList.Add(errorStatus);

                        _logger.Warn("ReplyS6F12_PRRECIPEMETHODItem.Format != SecsFormat.U1");
                    }

                    if (PPIDItem.Format != SecsFormat.ASCII)
                    {
                        acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                        errorStatus = new ErrorStatus
                        {
                            Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                            Errortext = "Parameters improperly specified"
                        };
                        errorList.Add(errorStatus);

                        _logger.Warn("ReplyS6F12_PPIDItem.Format != SecsFormat.ASCII");
                    }

                    if (RCPPARItemList.Format != SecsFormat.List)
                    {
                        acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                        errorStatus = new ErrorStatus
                        {
                            Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                            Errortext = "Parameters improperly specified"
                        };
                        errorList.Add(errorStatus);

                        _logger.Warn("ReplyS6F12_RCPPARItemList.Format != SecsFormat.List");
                    }
                    else
                    {
                        for (int i = 0; i < RCPPARItemList.Count; i++)
                        {
                            Item RCPPARNMItem  = RCPPARItemList.Items[0];
                            Item RCPPARVALItem = RCPPARItemList.Items[1];

                            if (RCPPARNMItem.Format != SecsFormat.ASCII)
                            {
                                acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                                errorStatus = new ErrorStatus
                                {
                                    Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                                    Errortext = "Parameters improperly specified"
                                };
                                errorList.Add(errorStatus);

                                _logger.Warn("ReplyS6F12_RCPPARNMItem.Format != SecsFormat.ASCII");
                            }
                        }
                    }
                }

                if (PRPROCESSSTARTItem.Format != SecsFormat.Boolean)
                {
                    acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                    errorStatus = new ErrorStatus
                    {
                        Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                        Errortext = "Parameters improperly specified"
                    };
                    errorList.Add(errorStatus);

                    _logger.Warn("ReplyS6F12_PRPROCESSSTARTItem.Format != SecsFormat.Boolean");
                }

                if (PRPAUSEEVENTItem.Format != SecsFormat.List)
                {
                    acka        = SanwaACK.ACKA_UNSUCCESSFUL;
                    errorStatus = new ErrorStatus
                    {
                        Errorcode = SanwaACK.ERRCODE_PARAMETERS_IMPROPERLY_SPECIFIED,
                        Errortext = "Parameters improperly specified"
                    };
                    errorList.Add(errorStatus);

                    _logger.Warn("ReplyS6F12_PRPAUSEEVENTItem.Format != SecsFormat.List");
                }
            }
            //檢查相關格式 End

            string prJobID = "";

            if (PRJOBIDItem != null)
            {
                if (PRJOBIDItem.Format == SecsFormat.ASCII)
                {
                    prJobID = PRJOBIDItem.GetString();
                }
            }

            string newReplyMsg = GetMessageName(replyMsg.ToSml());

            newReplyMsg += "<L[2]\r\n";
            newReplyMsg += "<Boolean[1]" + acka.ToString() + ">\r\n";
            newReplyMsg += "<L[" + errorList.Count + "]\r\n";
            for (int i = 0; i < errorList.Count; i++)
            {
                errorStatus  = errorList[i];
                newReplyMsg += GetToSMLItem(SecsFormat.U1, errorStatus.Errorcode.ToString());
                newReplyMsg += "< A[0]" + errorStatus.Errortext + ">\r\n";
            }
            newReplyMsg += ">\r\n";
            newReplyMsg += ">\r\n";

            if (acka == SanwaACK.ACKA_SUCCESSFUL)
            {
                SanwaPJ sanwaPJ = new SanwaPJ
                {
                    ObjID = prJobID
                };

                for (int i = 0; i < PRPAUSEEVENTItem.Count; i++)
                {
                    Item EventItem = PRPAUSEEVENTItem.Items[i];

                    SetItemToStringType(EventItem, out string eventId);

                    if (eventId != "")
                    {
                        sanwaPJ.PauseEvent.Add(eventId);
                    }
                }

                if (MFItem.Count != 0)
                {
                    byte[] mf = MFItem.GetValues <byte>();
                    sanwaPJ.PRMtlType = mf[0];

                    if (sanwaPJ.PRMtlType == E30_MF.IN_CARRIERS)
                    {
                        //object carrierList;
                        Dictionary <string, List <string> > carrierIDList = new Dictionary <string, List <string> >();
                        for (int n = 0; n < MFItemList.Count; n++)
                        {
                            Item CarrierIDList = MFItemList.Items[n];

                            Item CarrierIDItem = CarrierIDList.Items[0];
                            Item SlotIDList    = CarrierIDList.Items[1];

                            SetItemToStringType(CarrierIDItem, out string carrierID);

                            List <string> slotList = new List <string>();
                            AddToPRMtlNameList(SlotIDList, slotList);

                            carrierIDList.Add(carrierID, slotList);
                        }
                        sanwaPJ.PRMtlNameList = carrierIDList;
                    }
                    else if (sanwaPJ.PRMtlType == E30_MF.IN_SUBSTRATES)
                    {
                        //object Substrates;
                        List <string> mIDList = new List <string>();
                        for (int n = 0; n < MFItemList.Count; n++)
                        {
                            Item MIDItem = MFItemList.Items[n];

                            SetItemToStringType(MIDItem, out string materialID);

                            mIDList.Add(materialID);
                        }
                        sanwaPJ.PRMtlNameList = mIDList;
                    }
                }

                if (PRRECIPEMETHODItem != null)
                {
                    sanwaPJ.PRRecipeMethod = (E40_PR_RECIPE_METHOD)PRRECIPEMETHODItem.GetValue <byte>();
                }

                if (PPIDItem != null)
                {
                    sanwaPJ.RecID = PPIDItem.GetString();
                }

                if (RCPPARItemList != null)
                {
                    for (int m = 0; m < RCPPARItemList.Count; m++)
                    {
                        Item RCPPARItem    = RCPPARItemList.Items[m];
                        Item RCPPARNMItem  = null;
                        Item RCPPARVALItem = null;
                        if (RCPPARItem.Count.Equals(2))
                        {
                            RCPPARNMItem  = RCPPARItem.Items[0];
                            RCPPARVALItem = RCPPARItem.Items[1];

                            RecipeVariable recipeVariable = new RecipeVariable
                            {
                                RecipeVarName = RCPPARNMItem.GetString()
                            };
                            switch (RCPPARVALItem.Format)
                            {
                            case SecsFormat.ASCII:
                                recipeVariable.RecipeVarValue = RCPPARVALItem.GetString();
                                break;

                            case SecsFormat.Binary:
                                recipeVariable.RecipeVarValue = RCPPARVALItem.GetValues <byte>();
                                break;

                            case SecsFormat.Boolean:
                                recipeVariable.RecipeVarValue = RCPPARVALItem.GetValue <bool>();
                                break;

                            case SecsFormat.F4:
                                recipeVariable.RecipeVarValue = RCPPARVALItem.GetValue <float>();
                                break;

                            case SecsFormat.F8:
                                recipeVariable.RecipeVarValue = RCPPARVALItem.GetValue <double>();
                                break;

                            case SecsFormat.I1:
                                recipeVariable.RecipeVarValue = RCPPARVALItem.GetValue <sbyte>();
                                break;

                            case SecsFormat.I2:
                                recipeVariable.RecipeVarValue = RCPPARVALItem.GetValue <short>();
                                break;

                            case SecsFormat.I4:
                                recipeVariable.RecipeVarValue = RCPPARVALItem.GetValue <int>();
                                break;

                            case SecsFormat.I8:
                                recipeVariable.RecipeVarValue = RCPPARVALItem.GetValue <long>();
                                break;

                            case SecsFormat.U1:
                                recipeVariable.RecipeVarValue = RCPPARVALItem.GetValue <byte>();
                                break;

                            case SecsFormat.U2:
                                recipeVariable.RecipeVarValue = RCPPARVALItem.GetValue <ushort>();
                                break;

                            case SecsFormat.U4:
                                recipeVariable.RecipeVarValue = RCPPARVALItem.GetValue <uint>();
                                break;

                            case SecsFormat.U8:
                                recipeVariable.RecipeVarValue = RCPPARVALItem.GetValue <ulong>();
                                break;

                            default:
                                ///case SecsFormat.List:
                                break;
                            }

                            sanwaPJ.RecVariableList.Add(recipeVariable.RecipeVarName, recipeVariable);
                        }
                    }
                }

                if (PRPROCESSSTARTItem != null)
                {
                    sanwaPJ.PRProcessStart = PRPROCESSSTARTItem.GetValue <bool>();
                }

                _pJList.Add(sanwaPJ);
                _pJQueue.Add(sanwaPJ);
            }

            e.ReplyAsync(newReplyMsg.ToSecsMessage());
        }
Пример #19
0
        public void ReplyChangeServiceStatus(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg, bool inService)
        {
            string newReplyMsg = GetMessageName(replyMsg.ToSml());

            Item PTNItem = e.Message.SecsItem.Items[1];
            Item ServiceStatusList;

            if (e.Message.SecsItem.Count == 3)  //CHANGESERVICESTATUS
            {
                ServiceStatusList = e.Message.SecsItem.Items[2];

                if (ServiceStatusList.Count > 0)
                {
                    //0 :out of service
                    //1 :In service

                    Item PARAMVALItem = ServiceStatusList.Items[1];
                    switch (PARAMVALItem.Format)
                    {
                    case SecsFormat.ASCII:
                        inService = PARAMVALItem.GetString() == "0" ? false : true;
                        break;

                    case SecsFormat.Binary:
                        byte[] paramval = PARAMVALItem.GetValues <byte>();
                        inService = paramval[0] == 0x00 ? false : true;
                        break;

                    case SecsFormat.Boolean:
                        inService = PARAMVALItem.GetValue <bool>();
                        break;

                    case SecsFormat.F4:
                        inService = PARAMVALItem.GetValue <float>() == 0.0f ? false : true;
                        break;

                    case SecsFormat.F8:
                        inService = PARAMVALItem.GetValue <double>() == 0.0d ? false : true;
                        break;

                    case SecsFormat.I1:
                        inService = PARAMVALItem.GetValue <byte>() == 0 ? false : true;
                        break;

                    case SecsFormat.I2:
                        inService = PARAMVALItem.GetValue <short>() == 0 ? false : true;
                        break;

                    case SecsFormat.I4:
                        inService = PARAMVALItem.GetValue <int>() == 0 ? false : true;
                        break;

                    case SecsFormat.I8:
                        inService = PARAMVALItem.GetValue <long>() == 0 ? false : true;
                        break;

                    case SecsFormat.U1:
                        inService = PARAMVALItem.GetValue <sbyte>() == 0 ? false : true;
                        break;

                    case SecsFormat.U2:
                        inService = PARAMVALItem.GetValue <ushort>() == 0 ? false : true;
                        break;

                    case SecsFormat.U4:
                        inService = PARAMVALItem.GetValue <uint>() == 0 ? false : true;
                        break;

                    case SecsFormat.U8:
                        inService = PARAMVALItem.GetValue <ulong>() == 0 ? false : true;
                        break;
                    }
                }
            }

            LoadPort lpObj = _loadPortList.FirstOrDefault(x => x.Value.Number == PTNItem.GetValue <byte>()).Value;

            newReplyMsg += "< L[2]\r\n";

            if (lpObj == null)
            {
                newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n";
                newReplyMsg += "<L[0]\r\n";
                newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_LOAD_PORT_DOES_NOT_EXIST.ToString());
                newReplyMsg += "<A[0]>\r\n";
                newReplyMsg += ">\r\n";
            }
            else
            {
                newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n";

                bool Return = true;


                if (inService)
                {
                    Return = ChangeLoadPortState(lpObj, E87_LPTS.IN_SERVICE);

                    if (Return)
                    {
                        E87_HostCommand hcObj = new E87_HostCommand
                        {
                            lpObj       = lpObj,
                            Name        = "INSERVICE",
                            MessageName = "S3F25"
                        };

                        ThreadPool.QueueUserWorkItem(callback =>
                        {
                            S3F25InServiceEvent?.Invoke(this, hcObj);
                        });
                    }
                }
                else
                {
                    Return = ChangeLoadPortState(lpObj, E87_LPTS.OUT_OF_SERVICE);

                    if (Return)
                    {
                        E87_HostCommand hcObj = new E87_HostCommand
                        {
                            lpObj       = lpObj,
                            Name        = "OUTOFSERVICE",
                            MessageName = "S3F25"
                        };

                        ThreadPool.QueueUserWorkItem(callback =>
                        {
                            S3F25OutOfServiceEvent?.Invoke(this, hcObj);
                        });
                    }
                }
                newReplyMsg += "<L[0]\r\n>\r\n";
            }


            newReplyMsg += ">\r\n";

            e.ReplyAsync(newReplyMsg.ToSecsMessage());
        }
Пример #20
0
        public void ReplyChangeReservePortStatus(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg, bool reserveAtPort)
        {
            string   newReplyMsg = GetMessageName(replyMsg.ToSml());
            Item     PTNItem     = e.Message.SecsItem.Items[1];
            LoadPort lpObj       = _loadPortList.FirstOrDefault(x => x.Value.Number == PTNItem.GetValue <byte>()).Value;

            newReplyMsg += "< L[2]\r\n";

            if (lpObj == null)
            {
                newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n";
                newReplyMsg += "<L[0]\r\n";
                newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_LOAD_PORT_DOES_NOT_EXIST.ToString());
                newReplyMsg += "<A[0]>\r\n";
                newReplyMsg += ">\r\n";
            }
            else
            {
                bool Return = true;
                if (reserveAtPort)
                {
                    Return = ChangeReserviceState(lpObj, E87_RS.RESERVED);
                }
                else
                {
                    Return = ChangeReserviceState(lpObj, E87_RS.NOT_RESERVED);
                }

                if (Return)
                {
                    newReplyMsg += "<U1[0] " + SanwaACK.CAACK_ACK.ToString() + ">\r\n";
                    newReplyMsg += "<L[0]\r\n>\r\n";

                    if (reserveAtPort)
                    {
                        E87_HostCommand hcObj = new E87_HostCommand
                        {
                            lpObj       = lpObj,
                            Name        = "RESERVEATPORT",
                            MessageName = "S3F25"
                        };

                        ThreadPool.QueueUserWorkItem(callback =>
                        {
                            S3F25ReserveAtPortEvent?.Invoke(this, hcObj);
                        });
                    }
                    else
                    {
                        E87_HostCommand hcObj = new E87_HostCommand
                        {
                            lpObj       = lpObj,
                            Name        = "CANCELRESERVEATPORT",
                            MessageName = "S3F25"
                        };

                        ThreadPool.QueueUserWorkItem(callback =>
                        {
                            S3F25CancelReserveAtPortEvent?.Invoke(this, hcObj);
                        });
                    }
                }
                else
                {
                    newReplyMsg += "<U1[0] " + SanwaACK.CAACK_CMD_PERFOEM_WITH_ERR.ToString() + ">\r\n";
                    newReplyMsg += "<L[0]\r\n";
                    newReplyMsg += GetToSMLItem(SecsFormat.U1, SanwaACK.ERRCODE_LOAD_PORT_ALREADY_IN_USE.ToString());
                    newReplyMsg += "<A[0]>\r\n";
                    newReplyMsg += ">\r\n";
                }
            }

            newReplyMsg += ">\r\n";

            e.ReplyAsync(newReplyMsg.ToSecsMessage());
        }