Esempio n. 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);
            });
        }
Esempio n. 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());
        }
Esempio n. 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);
                });
            }
        }
Esempio n. 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());
        }
Esempio n. 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);
        }
Esempio n. 6
0
        public void ReceiveS2F37(PrimaryMessageWrapper e, ref byte[] ERACK)
        {
            //Structure: L,2
            //    1. < CEED > enable / disable
            //    2.L,n #CEIDs
            //        1. < CEID1 >
            //        .
            //        .
            //        n. < CEIDn >

            ERACK[0] = SanwaACK.ERACK_ACK;

            Item CEEDItem      = e.Message.SecsItem.Items[0];
            Item EventListItem = e.Message.SecsItem.Items[1];

            //確認所有CEID是否正確
            for (int i = 0; i < EventListItem.Count; i++)
            {
                Item EventItem = EventListItem.Items[i];
                if (!CheckFomart3x5x20(EventItem))
                {
                    ERACK[0] = SanwaACK.ERACK_CEID_NOT_EXIS;
                    return;
                }

                SetItemToStringType(EventItem, out string EventID);

                _eventIDList.TryGetValue(EventID, out SanwaEvent eventObj);

                if (eventObj == null)
                {
                    ERACK[0] = SanwaACK.ERACK_CEID_NOT_EXIS;
                    return;
                }
            }

            bool enabled = CEEDItem.GetValue <bool>();

            if (EventListItem.Count == 0)   //Event 全部設定
            {
                foreach (var keyValuePair in _eventList)
                {
                    SanwaEvent eventObj = keyValuePair.Value;
                    eventObj._enabled = enabled;
                }
            }
            else
            {
                for (int i = 0; i < EventListItem.Count; i++)
                {
                    Item EventItem = EventListItem.Items[i];
                    SetItemToStringType(EventItem, out string EventID);
                    _eventIDList.TryGetValue(EventID, out SanwaEvent eventObj);
                    eventObj._enabled = enabled;
                }
            }
        }
Esempio n. 7
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";
        }
Esempio n. 8
0
 public void ReplyS3F28(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg)
 {
     //L,2   1. < ACCESSMODE >
     //    2.L,n
     //        1. < PTN1 >
     //        .
     //        .
     //        n. < PTNn >
     ReplyAccessMode(e, receiveMsg, replyMsg, false);
 }
Esempio n. 9
0
        public void ReplyS3F26(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg)
        {
            //L,3
            //    1. < PORTACTION >
            //    2. < PTN >
            //    3.L,m
            //        1.L,2
            //          1. < PARAMNAME1 >
            //          2. < PARAMVAL1 >
            //        .
            //        .
            //        m.L,2
            //          1. < PARAMNAMEm >
            //          2. < PARAMVALm >
            Item PORTACTIONItem = e.Message.SecsItem.Items[0];
            Item PTNItem        = e.Message.SecsItem.Items[1];

            switch (PORTACTIONItem.GetString().ToUpper())
            {
            case "CANCELRESERVEATPORT":
                ReplyChangeReservePortStatus(e, receiveMsg, replyMsg, false);
                break;

            case "RESERVEATPORT":
                ReplyChangeReservePortStatus(e, receiveMsg, replyMsg, true);
                break;

            case "AUTO":
                ReplyChangeAccess(e, receiveMsg, replyMsg, true);
                break;

            case "MANUAL":
                ReplyChangeAccess(e, receiveMsg, replyMsg, false);
                break;

            case "CHANGEACCESS":
                ReplyChangeAccess(e, receiveMsg, replyMsg, true);
                break;

            case "IN SERVICE":
            case "INSERVICE":
                ReplyChangeServiceStatus(e, receiveMsg, replyMsg, true);
                break;

            case "OUT OF SERVICE":
            case "OUTOFSERVICE":
                ReplyChangeServiceStatus(e, receiveMsg, replyMsg, false);
                break;

            case "CHANGESERVICESTATUS":
                ReplyChangeServiceStatus(e, receiveMsg, replyMsg, true);
                break;
            }
        }
Esempio n. 10
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);
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
        public void ReplyS3F22(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg)
        {
            //L,3
            //    1. < PORTGRPNAME >
            //    2. < ACCESSMODE >
            //    3.L,n
            //        1. < PTN1 >
            //        .
            //        .
            //        n. < PTNn >

            ReplyAccessMode(e, receiveMsg, replyMsg, true);
        }
Esempio n. 13
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());
        }
Esempio n. 14
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());
        }
Esempio n. 15
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());
        }
Esempio n. 16
0
        public void ReceiveS10F5(PrimaryMessageWrapper e, ref byte[] ACKC10)
        {
            //ReceiveS10F5
            //L,2
            //    1. < TID >
            //    L,n.
            //      1.< TEXT>
            Item TIDItem      = e.Message.SecsItem.Items[0];
            Item TEXTItemList = e.Message.SecsItem.Items[1];

            ACKC10[0] = SanwaACK.ACKC10_ACK;

            if (TIDItem.Format != SecsFormat.Binary)
            {
                ACKC10[0] = SanwaACK.ACKC10_NOT_DISPLAYED;
                return;
            }

            if (TEXTItemList.Format != SecsFormat.ASCII)
            {
                ACKC10[0] = SanwaACK.ACKC10_NOT_DISPLAYED;
                return;
            }

            _terminalMSGList.Clear();

            for (int i = 0; i < TEXTItemList.Count; i++)
            {
                _terminalMSGList.Add(TEXTItemList.Items[i].GetString());
            }



            SecsMessageCommand msgObj = new SecsMessageCommand
            {
                Name        = "TerminalDisplay(M)",
                MessageName = "S10F5"
            };

            ThreadPool.QueueUserWorkItem(callback =>
            {
                S10F5TerminalMessageEvent?.Invoke(this, msgObj);
            });
        }
Esempio n. 17
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());
        }
Esempio n. 18
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());
        }
Esempio n. 19
0
        public bool ReceiveS2F23(PrimaryMessageWrapper e, ref byte[] TIAACK, ref SanwaTIS obj)
        {
            //L,5
            //    1. < TRID >
            //    2. < DSPER >
            //    3. < TOTSMP >
            //    4. < REPGSZ >
            //    5.L,n
            //        1. < SVID1 >
            //        2. < SVID2 >
            //        n. < SVIDn >

            //L,5
            //    1. < TRID >
            //    2. < DSPER >
            //    3. < TOTSMP >
            //    4. < REPGSZ >
            //    5. < SVID1 SVID2 SVID3 SVIDn>

            int TRIDIndex     = -1;
            int DSPERIndex    = -1;
            int TOTSMPIndex   = -1;
            int REPGSZIndex   = -1;
            int SVIDListIndex = 4;

            string SearchKey = "S2F23";

            _smlManager._messageList.TryGetValue(SearchKey, out SanwaSML smlObj);
            if (smlObj == null)
            {
                return(false);
            }

            string text = smlObj.Text;
            string line;

            using (StringReader reader = new StringReader(text))
            {
                int rowIndex = 0;

                while ((line = reader.ReadLine()) != null)
                {
                    if (line.Contains("TRID"))
                    {
                        TRIDIndex = rowIndex;
                    }
                    else if (line.Contains("DSPER"))
                    {
                        DSPERIndex = rowIndex;
                    }
                    else if (line.Contains("TOTSMP"))
                    {
                        TOTSMPIndex = rowIndex;
                    }
                    else if (line.Contains("REPGSZ"))
                    {
                        REPGSZIndex = rowIndex;
                    }

                    if (line.Contains("L"))
                    {
                        rowIndex = 0;
                    }
                    else
                    {
                        rowIndex++;
                    }
                }
            }


            TIAACK[0] = SanwaACK.TIAACK_ACK;

            if (e.Message.SecsItem.Count != 5)
            {
                TIAACK[0] = SanwaACK.TIAACK_NO_MORE_TRACES_ALLOWED;
                return(true);
            }

            if (TRIDIndex >= 0)
            {
                Item TRIDItem = e.Message.SecsItem.Items[TRIDIndex];

                if (!CheckFomart3x5x20(TRIDItem))
                {
                    TIAACK[0] = SanwaACK.TIAACK_INVALID_SVID;
                    return(true);
                }

                SetItemToStringType(TRIDItem, out obj._trid);
            }

            if (DSPERIndex >= 0)
            {
                Item DSPERItem = e.Message.SecsItem.Items[1];
                if (DSPERItem.Format != SecsFormat.ASCII)
                {
                    TIAACK[0] = SanwaACK.TIAACK_INVALID_DSPER;
                    return(true);
                }

                string _dsper = DSPERItem.GetString();

                if (!(_dsper.Length == 6 || _dsper.Length == 8))
                {
                    TIAACK[0] = SanwaACK.TIAACK_INVALID_DSPER;
                    return(true);
                }

                string hh = _dsper.Substring(0, 2);
                string mm = _dsper.Substring(2, 2);
                string ss = _dsper.Substring(4, 2);
                string cc = _dsper.Length == 6 ? "0" : _dsper.Substring(6, 2);

                obj._dsper = Convert.ToInt32(hh) * 60 * 60 * 1000 +
                             Convert.ToInt32(mm) * 60 * 1000 +
                             Convert.ToInt32(ss) * 1000 +
                             Convert.ToInt32(cc);
            }

            if (TOTSMPIndex >= 0)
            {
                Item TOTSMPItem = e.Message.SecsItem.Items[2];

                if (!CheckFomart3x5x20(TOTSMPItem))
                {
                    TIAACK[0] = SanwaACK.TIAACK_NO_MORE_TRACES_ALLOWED;
                    return(true);
                }

                SetItemToStringType(TOTSMPItem, out string totsmp);

                obj._totsmp = Convert.ToInt32(totsmp);
            }

            if (REPGSZIndex >= 0)
            {
                Item REPGSZItem = e.Message.SecsItem.Items[3];

                if (!CheckFomart3x5x20(REPGSZItem))
                {
                    TIAACK[0] = SanwaACK.TIAACK_INVALID_REPGSZ;
                    return(true);
                }

                SetItemToStringType(REPGSZItem, out string repgsz);

                if (repgsz == "0")
                {
                    TIAACK[0] = SanwaACK.TIAACK_INVALID_REPGSZ;
                    return(true);
                }

                obj._repgsz = Convert.ToInt32(repgsz);
            }

            if (SVIDListIndex >= 0)
            {
                //型式1與型式二
                Item SVIDListItem = e.Message.SecsItem.Items[SVIDListIndex];
                if (SVIDListItem.Format == SecsFormat.List)
                {
                    for (int i = 0; i < SVIDListItem.Count; i++)
                    {
                        Item SVItem = SVIDListItem.Items[i];

                        if (!CheckFomart3x5x20(SVItem))
                        {
                            TIAACK[0] = SanwaACK.TIAACK_INVALID_SVID;
                            return(true);
                        }

                        SetItemToStringType(SVItem, out string svid);

                        _svIDList.TryGetValue(svid, out SanwaSV sanwaSV);

                        if (sanwaSV == null)
                        {
                            TIAACK[0] = SanwaACK.TIAACK_INVALID_SVID;
                            return(true);
                        }
                        else
                        {
                            obj._svIDList.Add(svid);
                        }
                    }
                }
                else
                {
                    if (SVIDListItem.Format == SecsFormat.I1)
                    {
                        sbyte[] array = new sbyte[SVIDListItem.Count];
                        array = SVIDListItem.GetValues <sbyte>();
                        for (int i = 0; i < SVIDListItem.Count; ++i)
                        {
                            obj._svIDList.Add(array[i].ToString());
                        }
                    }
                    else if (SVIDListItem.Format == SecsFormat.I2)
                    {
                        short[] array = new short[SVIDListItem.Count];
                        array = SVIDListItem.GetValues <short>();
                        for (int i = 0; i < SVIDListItem.Count; ++i)
                        {
                            obj._svIDList.Add(array[i].ToString());
                        }
                    }
                    else if (SVIDListItem.Format == SecsFormat.I4)
                    {
                        int[] array = new int[SVIDListItem.Count];
                        array = SVIDListItem.GetValues <int>();
                        for (int i = 0; i < SVIDListItem.Count; ++i)
                        {
                            obj._svIDList.Add(array[i].ToString());
                        }
                    }
                    else if (SVIDListItem.Format == SecsFormat.I8)
                    {
                        long[] array = new long[SVIDListItem.Count];
                        array = SVIDListItem.GetValues <long>();
                        for (int i = 0; i < SVIDListItem.Count; ++i)
                        {
                            obj._svIDList.Add(array[i].ToString());
                        }
                    }
                    else if (SVIDListItem.Format == SecsFormat.U1)
                    {
                        byte[] array = new byte[SVIDListItem.Count];
                        array = SVIDListItem.GetValues <byte>();
                        for (int i = 0; i < SVIDListItem.Count; ++i)
                        {
                            obj._svIDList.Add(array[i].ToString());
                        }
                    }
                    else if (SVIDListItem.Format == SecsFormat.U2)
                    {
                        ushort[] array = new ushort[SVIDListItem.Count];
                        array = SVIDListItem.GetValues <ushort>();
                        for (int i = 0; i < SVIDListItem.Count; ++i)
                        {
                            obj._svIDList.Add(array[i].ToString());
                        }
                    }
                    else if (SVIDListItem.Format == SecsFormat.U4)
                    {
                        uint[] array = new uint[SVIDListItem.Count];
                        array = SVIDListItem.GetValues <uint>();
                        for (int i = 0; i < SVIDListItem.Count; ++i)
                        {
                            obj._svIDList.Add(array[i].ToString());
                        }
                    }
                    else if (SVIDListItem.Format == SecsFormat.U8)
                    {
                        ulong[] array = new ulong[SVIDListItem.Count];
                        array = SVIDListItem.GetValues <ulong>();
                        for (int i = 0; i < SVIDListItem.Count; ++i)
                        {
                            obj._svIDList.Add(array[i].ToString());
                        }
                    }
                }
            }
            return(true);
        }
Esempio n. 20
0
        public void ReceiveS2F33(PrimaryMessageWrapper e, ref byte[] DRACK)
        {
            //Structure: L,2
            //        1. < DATAID >
            //        2.L,a # reports
            //            1.L,2 report 1
            //                1. < RPTID1 >
            //                2.L,b #VIDs this report
            //                    1. < VID1 >
            //                    .
            //                    .
            //                    b.< VIDb >
            //            a.L,2 report a
            //                1. < RPTIDa >
            //                2.L,c #VIDs this report
            //                    1. < VID1 >
            //                    .
            //                    .
            //                    c. < VIDc >
            DRACK[0] = SanwaACK.DRACK_ACK;

            Item ReportListItem = e.Message.SecsItem.Items[1];

            //不符合資料格式 start ++
            if (ReportListItem.Format != SecsFormat.List)
            {
                DRACK[0] = SanwaACK.DRACK_INVALID_FORMAT;
                return;
            }

            for (int i = 0; i < ReportListItem.Count; i++)
            {
                Item RPTIDItem   = ReportListItem.Items[i].Items[0];
                Item VIDListItem = ReportListItem.Items[i].Items[1];

                if (!CheckFomart3x5x20(RPTIDItem))
                {
                    DRACK[0] = SanwaACK.DRACK_INVALID_FORMAT;
                    return;
                }

                if (VIDListItem.Count > 0)
                {
                    SetItemToStringType(RPTIDItem, out string rptid);
                    foreach (var reportObj in _reportList)
                    {
                        SanwaRPTID sanwaRPTID = reportObj.Value;

                        //RPTID 已經被定義
                        if (sanwaRPTID._id == rptid)
                        {
                            DRACK[0] = SanwaACK.DRACK_RPTID_DEFINED;
                            return;
                        }
                    }

                    for (int j = 0; j < VIDListItem.Count; j++)
                    {
                        Item VIDItem = VIDListItem.Items[j];

                        if (!CheckFomart3x5x20(VIDItem))
                        {
                            DRACK[0] = SanwaACK.DRACK_INVALID_FORMAT;
                            return;
                        }

                        SetItemToStringType(VIDItem, out string vid);

                        _svIDList.TryGetValue(vid, out SanwaSV svObj);
                        if (svObj != null)
                        {
                            continue;
                        }

                        _ecIDList.TryGetValue(vid, out SanwaEC ecObj);
                        if (ecObj != null)
                        {
                            continue;
                        }

                        _dvIDList.TryGetValue(vid, out SanwaDV dvObj);
                        if (ecObj != null)
                        {
                            continue;
                        }

                        DRACK[0] = SanwaACK.DRACK_VID_NOT_EXIST;
                        return;
                    }
                }
            }
            //不符合資料格式 End ++
            //是否停止移除所有Host定義的PRID
            if (ReportListItem.Count == 0)
            {
                foreach (var reportObj in _reportList)
                {
                    SanwaRPTID sanwaRPTID = reportObj.Value;
                    sanwaRPTID.Clear();
                }

                foreach (var eventObj in _eventList)
                {
                    SanwaEvent eventList = eventObj.Value;
                    eventList.ClearRPTIDList();
                }

                _reportList.Clear();
            }
            //寫入_reportList中
            for (int i = 0; i < ReportListItem.Count; i++)
            {
                Item RPTIDItem   = ReportListItem.Items[i].Items[0];
                Item VIDListItem = ReportListItem.Items[i].Items[1];

                SetItemToStringType(RPTIDItem, out string rptid);

                if (VIDListItem.Count != 0)
                {
                    SanwaRPTID rptObj = new SanwaRPTID
                    {
                        _id     = rptid,
                        _format = RPTIDItem.Format
                    };

                    for (int j = 0; j < VIDListItem.Count; j++)
                    {
                        Item VIDItem = VIDListItem.Items[j];
                        SetItemToStringType(VIDItem, out string vid);

                        SanwaVID vidObj = new SanwaVID();
                        vidObj._id     = vid;
                        vidObj._format = VIDItem.Format;

                        rptObj.Add(vidObj);
                    }

                    _reportList.Add(rptid, rptObj);
                }
                else//VIDListItem.Count
                {
                    bool RemoveRPTID = false;
                    foreach (var reportObj in _reportList)
                    {
                        SanwaRPTID sanwaRPTID = reportObj.Value;
                        if (sanwaRPTID._id == rptid)
                        {
                            sanwaRPTID.Clear();
                            RemoveRPTID = true;
                            break;
                        }
                    }

                    if (RemoveRPTID)
                    {
                        //移除_reportList中的實體物件
                        _reportList.Remove(rptid);
                        //移除eventList中的註冊
                        foreach (var sanwaEventObj in _eventList)
                        {
                            SanwaEvent sanwaEvent = sanwaEventObj.Value;
                            if (sanwaEvent._rptidList.Count > 0)
                            {
                                sanwaEvent._rptidList.RemoveAll(id => id == rptid);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 21
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());
        }
Esempio n. 22
0
        public void ReplyS3F18(PrimaryMessageWrapper e, SecsMessage receiveMsg, SecsMessage replyMsg)
        {
            //L,5
            //    1. < DATAID >
            //    2. < CARRIERACTION >
            //    3. < CARRIERID >
            //    4. < PTN >
            //    5.L,n n = number of carrier attributes
            //        1.L,2
            //            1. < CATTRID1 >
            //            2. < CATTRDATA1 >
            //            .
            //            .
            //        n.L,2
            //            1. < CATTRIDn >
            //            2. < CATTRDATAn >
            Item CARRIERACTIONItem = e.Message.SecsItem.Items[1];

            //CARRIERACTION
            //Bind
            //CancelBind
            //CancelCarrier
            //CancelCarrierAtPort
            //CancelCarrierNotification
            //CarrierNotification
            //CarrierReCreate
            //ProceedWithCarrier
            //CarrierRelease

            switch (CARRIERACTIONItem.GetString().ToUpper())
            {
            case "BIND":
                ReplyBindService(e, receiveMsg, replyMsg);
                break;

            case "CANCELBIND":
                ReplyCancelBindService(e, receiveMsg, replyMsg);
                break;

            case "CANCELCARRIER":
                ReplyCancelCarrierService(e, receiveMsg, replyMsg, false);
                break;

            case "CANCELCARRIERATPORT":
                ReplyCancelCarrierService(e, receiveMsg, replyMsg, true);
                break;

            case "CANCELCARRIERNOTIFICATION":
                ReplyCancelCarrierNotificationService(e, receiveMsg, replyMsg);
                break;

            case "CARRIERNOTIFICATION":
                ReplyCarrierNotificationService(e, receiveMsg, replyMsg);
                break;

            case "CARRIERRECREATE":
                ReplyCarrierReCreate(e, receiveMsg, replyMsg);
                break;

            case "PROCEEDWITHCARRIER":
                ReplyProceedWithCarrierService(e, receiveMsg, replyMsg);
                break;

            case "CARRIERRELEASE":
                ReplyCarrierRelease(e, receiveMsg, replyMsg);
                break;

            case "CARRIEROUT":
                ReplyCarrierOut(e, receiveMsg, replyMsg);
                break;

            case "CANCELCARRIEROUT":
                ReplyCancelCarrierOut(e, receiveMsg, replyMsg);
                break;

            case "CARRIERIN":
                ReplyCarrierIn(e, receiveMsg, replyMsg);
                break;
            }
        }
Esempio n. 23
0
        public void ReceiveS10F3(PrimaryMessageWrapper e, ref byte[] ACKC10)
        {
            //ReceiveS10F3
            //L,2
            //    1.< TID >
            //    2.< TEXT >

            int TIDIndex  = -1;
            int TEXTIndex = -1;

            string SearchKey = "S10F3";

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

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

            using (StringReader reader = new StringReader(smlObj.Text))
            {
                string line;
                int    rowIndex = 0;

                while ((line = reader.ReadLine()) != null)
                {
                    if (line.Contains("TID"))
                    {
                        TIDIndex = rowIndex;
                    }
                    else if (line.Contains("TEXT"))
                    {
                        TEXTIndex = rowIndex;
                    }

                    if (line.Contains("<L"))
                    {
                        rowIndex++;
                    }
                    else
                    {
                        rowIndex = 0;
                    }
                }
            }

            ACKC10[0] = SanwaACK.ACKC10_ACK;

            if (TIDIndex != -1)
            {
                Item TIDItem = e.Message.SecsItem.Items[TIDIndex];

                if (TIDItem.Format != SecsFormat.Binary)
                {
                    ACKC10[0] = SanwaACK.ACKC10_NOT_DISPLAYED;
                    return;
                }
            }

            if (TEXTIndex != -1)
            {
                Item TEXTItem = e.Message.SecsItem.Items[TEXTIndex];

                if (TEXTItem.Format != SecsFormat.ASCII)
                {
                    ACKC10[0] = SanwaACK.ACKC10_NOT_DISPLAYED;
                    return;
                }

                _terminalMSGList.Clear();

                _terminalMSGList.Add(TEXTItem.GetString());
            }

            SecsMessageCommand msgObj = new SecsMessageCommand
            {
                Name        = "TerminalDisplay(S)",
                MessageName = "S10F3"
            };

            ThreadPool.QueueUserWorkItem(callback =>
            {
                S10F3TerminalMessageEvent?.Invoke(this, msgObj);
            });
        }
Esempio n. 24
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());
        }
Esempio n. 25
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());
        }
Esempio n. 26
0
        public void ReceiveS2F35(PrimaryMessageWrapper e, ref byte[] LRACK)
        {
            //Structure: L,2
            //            1. < DATAID >
            //            2.L,a # event
            //                1.L,2 #event 1
            //                    1. < CEID1>
            //                    2. L,b
            //                        1. <RPTID1>
            //                        .
            //                        .
            //                        b. <RPTIDb>

            //                a.L,2 #event a
            //                    1. < CEIDa >
            //                    2.L,c
            //                        1.<RPTID1>
            //                        .
            //                        .
            //                        c. <RPTIDc>
            LRACK[0] = SanwaACK.LRACK_ACK;

            Item EventListItem = e.Message.SecsItem.Items[1];

            //不符合資料格式 start ++
            if (EventListItem.Format != SecsFormat.List)
            {
                LRACK[0] = SanwaACK.LRACK_INVALID_FORMAT;
                return;
            }

            for (int i = 0; i < EventListItem.Count; i++)
            {
                Item CEIDItem      = EventListItem.Items[i].Items[0];
                Item RPTIDListItem = EventListItem.Items[i].Items[1];

                if (!CheckFomart3x5x20(CEIDItem))
                {
                    LRACK[0] = SanwaACK.LRACK_INVALID_FORMAT;
                    return;
                }

                if (RPTIDListItem.Count > 0)
                {
                    SetItemToStringType(CEIDItem, out string ceid);

                    bool       FindEventObj = false;
                    SanwaEvent eventObj     = null;
                    foreach (SanwaEvent EvntObj in _eventList.Values)
                    {
                        if (EvntObj._id == ceid)
                        {
                            eventObj     = EvntObj;
                            FindEventObj = true;
                            break;
                        }
                    }

                    if (!FindEventObj)
                    {
                        LRACK[0] = SanwaACK.LRACK_INVALID_FORMAT;
                        return;
                    }

                    //RPID List 清單已經滿了
                    if (eventObj._rptidList.Count > 0)
                    {
                        LRACK[0] = SanwaACK.LRACK_CEID_DEFINED;
                        return;
                    }

                    for (int j = 0; j < RPTIDListItem.Count; j++)
                    {
                        Item RPTIDItem = RPTIDListItem.Items[j];

                        if (!CheckFomart3x5x20(RPTIDItem))
                        {
                            LRACK[0] = SanwaACK.LRACK_INVALID_FORMAT;
                            return;
                        }

                        SetItemToStringType(RPTIDItem, out string rptid);

                        _reportList.TryGetValue(rptid, out SanwaRPTID sanwaRPTID);

                        if (sanwaRPTID == null)
                        {
                            LRACK[0] = SanwaACK.LRACK_RPTID_NOT_EXIST;
                            return;
                        }
                    }
                }
            }
            //不符合資料格式 End ++

            if (EventListItem.Count == 0)
            {
                foreach (var eventObj in _eventList)
                {
                    SanwaEvent eventList = eventObj.Value;
                    eventList.ClearRPTIDList();
                }
            }

            for (int i = 0; i < EventListItem.Count; i++)
            {
                Item CEIDItem      = EventListItem.Items[i].Items[0];
                Item RPTIDListItem = EventListItem.Items[i].Items[1];

                SetItemToStringType(CEIDItem, out string ceid);

                //_eventList.TryGetValue(ceid, out SanwaEvent eventObj);


                bool       FindEventObj = false;
                SanwaEvent eventObj     = null;
                foreach (SanwaEvent EvntObj in _eventList.Values)
                {
                    if (EvntObj._id == ceid)
                    {
                        eventObj     = EvntObj;
                        FindEventObj = true;
                        break;
                    }
                }

                if (FindEventObj)
                {
                    if (RPTIDListItem.Count == 0)
                    {
                        eventObj.ClearRPTIDList();
                    }
                    else
                    {
                        for (int j = 0; j < RPTIDListItem.Count; j++)
                        {
                            Item RPTIDItem = RPTIDListItem.Items[j];
                            SetItemToStringType(RPTIDItem, out string rptid);
                            eventObj.AddRPTID(rptid);
                        }
                    }
                }
            }
        }
Esempio n. 27
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());
        }
Esempio n. 28
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());
            }
        }
Esempio n. 29
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());
        }
Esempio n. 30
0
 private static void DefaultPrimaryMessageReceived(object sender, PrimaryMessageWrapper _)
 {
 }