Exemplo n.º 1
0
 public static void WriteTo(this SecsMessage msg, TextWriter writer)
 {
     writer.WriteLine(msg.ToString());
     if (msg.SecsItem != null)
     {
         Write(writer, msg.SecsItem, SmlIndent);
     }
     writer.Write('.');
 }
Exemplo n.º 2
0
 public SecsMessageViewModel(SecsMessage secsMsg)
     : base(null, false)
 {
     _secsMsg = secsMsg;
     if (secsMsg.SecsItem != null)
     {
         base.Children.Add(new SecsItemViewModel(secsMsg.SecsItem, this));
     }
 }
Exemplo n.º 3
0
        void EQP_ProcessJobEnd(SecsMessage msg)
        {
            string id = msg.SecsItem.Items[2].Items[0].Items[1].Items[0].GetValue <string>().Trim();

            EAP.Report(new ProcessJobEndReport {
                ProcessJobID = id
            });
            EAP.Report(new DataCollectionCompleteReport(GetProcessJob(id)));
        }
Exemplo n.º 4
0
 public void MessageOut(SecsMessage msg, int systembyte)
 {
     EapLogger.Info(new SecsMessageLogInfo
     {
         In         = false,
         Message    = msg,
         SystemByte = systembyte
     });
 }
Exemplo n.º 5
0
            public void MessageOut(SecsMessage msg, int systembyte)
            {
                string temp = msg.ToSml();

                _form.Invoke((MethodInvoker) delegate {
                    _form.richTextBox2.SelectionColor = Color.Black;
                    _form.richTextBox2.AppendText($"--> [0x{systembyte:X8}] {temp}\n");
                });
            }
Exemplo n.º 6
0
        void EQP_CarrierIDRead(SecsMessage msg)
        {
            var portNo    = (byte)msg.SecsItem.Items[2].Items[0].Items[1].Items[0];
            var carrierId = msg.SecsItem.Items[2].Items[0].Items[1].Items[1].GetString().Trim();

            EAP.Report(new CarrierIDReport {
                LoadPortId = GetPortID(portNo),
                CarrierId  = carrierId
            });
        }
Exemplo n.º 7
0
        void EQP_CarrierIDRead(SecsMessage msg)
        {
            byte   portNo    = (byte)msg.SecsItem.Items[2].Items[0].Items[1].Items[0];
            string carrierID = msg.SecsItem.Items[2].Items[0].Items[1].Items[1].GetValue <string>().Trim();

            EAP.Report(new CarrierIDReport {
                LoadPortId = GetPortID(portNo),
                CarrierId  = carrierID
            });
        }
 /// <summary>
 /// Establish Communications Acknowledge
 /// </summary>
 /// <returns></returns>
 public static SecsMessage S1F14(this SecsMessage secsMessage, string MDLN, string SOFTREV, string ACK)
 {
     return(SendMessage(1, 14, secsMessage.SystenBytes, L(
                            A(ACK ?? String.Empty),
                            L(
                                A(MDLN ?? String.Empty),
                                A(SOFTREV ?? String.Empty)
                                )
                            )));
 }
Exemplo n.º 9
0
        async void EQP_LoadComplete(SecsMessage msg)
        {
            byte   portNo = (byte)msg.SecsItem.Items[2].Items[0].Items[1].Items[0];
            string portId = GetPortID(portNo);

            EAP.Report(new LoadCompReport {
                PortID = portId
            });

            // Wait CarrierIDRead Event 10 sec.
            {
                // Method 1:
                //ThreadPool.QueueUserWorkItem(delegate {
                //    EapLogger.Notice(portId + " StartAsync CarrierIDRead Timer");
                //    using (var ev = new ManualResetEvent(false)) {
                //        var callback = new Action<SecsMessage>(secsMsg => {
                //            if (portNo == (byte)secsMsg.SecsItem.Items[2].Items[0].Items[1].Items[0])
                //                ev.Set();
                //        });
                //        using (EAP.SubscribeS6F11("CarrierIDRead", callback))
                //        using (EAP.SubscribeS6F11("CarrierIDReadFail", callback)) {
                //            if (!ev.WaitOne(10000)) {
                //                EapLogger.Error(portId + " CarrierIDRead Timeout!!");
                //                EAP.Report(new CarrierIDReport {
                //                    LoadPortId = portId
                //                });
                //            }
                //        }
                //    }
                //});
            }
            {
                // Method 2:
                //EapLogger.Notice(portId + " StartAsync CarrierIDRead Timer");
                //var ev = new ManualResetEvent(false);
                //var callback = new Action<SecsMessage>(secsMsg => {
                //    if (portNo == (byte)secsMsg.SecsItem.Items[2].Items[0].Items[1].Items[0])
                //        ev.Set();
                //});
                //var read = EAP.SubscribeS6F11("CarrierIDRead", callback);
                //var readfail = EAP.SubscribeS6F11("CarrierIDReadFail", callback);
                //ThreadPool.RegisterWaitForSingleObject(ev, (state, timeout) => {
                //    if (read != null)
                //        read.Dispose();
                //    if (readfail != null)
                //        readfail.Dispose();
                //    if (timeout) {
                //        EapLogger.Error(portId + " CarrierIDRead Timeout!!");
                //        EAP.Report(new CarrierIDReport {
                //            LoadPortId = portId
                //        });
                //    }
                //}, null, 10000, true);
            }
        }
Exemplo n.º 10
0
    public void Setup()
    {
        const int ItemCount = 16;

        using var message = new SecsMessage(s: 1, f: 2, replyExpected: false)
              {
                  SecsItem = L(
                      L(),
                      U1(MemoryOwner <byte> .Allocate(ItemCount)),
                      U2(MemoryOwner <ushort> .Allocate(ItemCount)),
                      U4(MemoryOwner <uint> .Allocate(ItemCount)),
                      F4(MemoryOwner <float> .Allocate(ItemCount)),
                      A(CreateString(ItemCount, Encoding.ASCII)),
                      J(CreateString(ItemCount, Item.Jis8Encoding)),
                      F8(MemoryOwner <double> .Allocate(ItemCount)),
                      L(
                          I1(MemoryOwner <sbyte> .Allocate(ItemCount)),
                          I2(MemoryOwner <short> .Allocate(ItemCount)),
                          I4(MemoryOwner <int> .Allocate(ItemCount)),
                          F4(MemoryOwner <float> .Allocate(ItemCount)),
                          L(
                              I1(MemoryOwner <sbyte> .Allocate(ItemCount)),
                              I2(MemoryOwner <short> .Allocate(ItemCount)),
                              I4(MemoryOwner <int> .Allocate(ItemCount)),
                              F4(MemoryOwner <float> .Allocate(ItemCount)),
                              Boolean(MemoryOwner <bool> .Allocate(ItemCount)),
                              B(MemoryOwner <byte> .Allocate(ItemCount)),
                              L(
                                  A(CreateString(ItemCount, Encoding.ASCII)),
                                  J(CreateString(ItemCount, Item.Jis8Encoding)),
                                  Boolean(MemoryOwner <bool> .Allocate(ItemCount)),
                                  B(MemoryOwner <byte> .Allocate(ItemCount))),
                              F8(MemoryOwner <double> .Allocate(ItemCount))),
                          Boolean(MemoryOwner <bool> .Allocate(ItemCount)),
                          B(MemoryOwner <byte> .Allocate(ItemCount)),
                          L(
                              A(CreateString(ItemCount, Encoding.ASCII)),
                              J(CreateString(ItemCount, Item.Jis8Encoding)),
                              Boolean(MemoryOwner <bool> .Allocate(ItemCount)),
                              B(MemoryOwner <byte> .Allocate(ItemCount))),
                          F8(MemoryOwner <double> .Allocate(ItemCount))),
                      U1(MemoryOwner <byte> .Allocate(ItemCount)),
                      U2(MemoryOwner <ushort> .Allocate(ItemCount)),
                      U4(MemoryOwner <uint> .Allocate(ItemCount)),
                      F4(MemoryOwner <float> .Allocate(ItemCount))),
              };

        using var buffer = new ArrayPoolBufferWriter <byte>();

        for (var i = 0; i < MessageCount; i++)
        {
            SecsGem.EncodeMessage(message, 1000 + i, deviceId: 0, buffer);
        }

        _encodedBytes = buffer.WrittenSpan.ToArray().Chunk(InputChunkSize).ToArray();
        ///// <summary>
        ///// 保存Equipment当前基本信息
        ///// </summary>
        //public EquipmentBaseInfo EquipmentBaseInfo { get => _equipmentBaseInfo; set => _equipmentBaseInfo = value; }
        ///// <summary>
        ///// 保存设备当前的状态信息
        ///// </summary>
        //public EquipmentStatus EquipmentStatusInfo { get => _equipmentStatusInfo; set => _equipmentStatusInfo = value; }

        #endregion

        #region message handler methods
        /// <summary>
        /// handle online/offline request by host
        /// </summary>
        public void HandleSecsMessage(SecsMessage secsMessage)
        {
            PrimaryMessage = secsMessage;
            switch (PrimaryMessage.GetSFString())
            {
            case "S1F1":                                                                                                         // are you there request
                SubScenarioName = Resource.Intialize_Scenario_1;
                secsMessage.S1F2(this._equipmentBaseInfo.MDLN ?? String.Empty, this._equipmentBaseInfo.SOFTREV ?? String.Empty); // 作为unit端, 只考虑online的选项
                break;

            case "S1F13":    // estublish communication request
                handleS1F13();
                break;

            case "S1F17":    // request online by host
                handleS1F17();
                break;

            case "S1F15":    // request offline by host
                SubScenarioName = Resource.Intialize_Scenario_4;
                switch (this._equipmentStatusInfo.CRST)
                {
                case CRST.O:
                    //send equipment denies requests
                    S1F0();
                    break;

                case CRST.L:
                case CRST.R:
                    // send OFF_LINE Acknowledge
                    // 0: Accepted, 1: Not Accepted
                    secsMessage.S1F16("0");
                    // send Control State Change(OFF_LINE)
                    launchControlStateProcess((int)CRST.O);
                    break;

                default:
                    break;
                }
                break;

            case "S2F17":    // Date and Time Request
                string dataTime = DateTime.Now.ToString("yyyyMMddHHmmss");
                secsMessage.S2F18(dataTime);
                break;

            case "S6F11":    // Event Report Send (ERS)
                secsMessage.S6F12("0");
                break;

            default:
                break;
            }
        }
Exemplo n.º 12
0
        void EQP_UnloadComplete(SecsMessage msg)
        {
            var portId = GetPortID((byte)msg.SecsItem.Items[2].Items[0].Items[1].Items[0]);

            EAP.Report(new UnloadCompleteReport {
                PortID = portId
            });

            //清除相關Loadport上的ProcessJob物件
            _ProcessingJobs.RemoveAll(pj => pj.Carriers.First().LoadPortId == portId);
        }
Exemplo n.º 13
0
    public AndConstraint <SecsMessageAssertions> NotBeEquivalentTo(SecsMessage expectation, string because = "", params object[] becauseArgs)
    {
        if (IsMessageEquals(expectation, Subject))
        {
            Execute.Assertion
            .BecauseOf(because, becauseArgs)
            .FailWith("Expected message not be equivalent, but they are.");
        }

        return(new AndConstraint <SecsMessageAssertions>(this));
    }
Exemplo n.º 14
0
 public static string ToSml(this SecsMessage secsMessage)
 {
     if (secsMessage == null)
     {
         return(null);
     }
     using (var sw = new StringWriter())
     {
         secsMessage.WriteTo(sw, 0);
         return(sw.ToString());
     }
 }
Exemplo n.º 15
0
 public Task <SecsMessage> SendAsync(SecsMessage msg)
 {
     if (_secsGem == null)
     {
         throw new Exception("SECS/GEM not enable!");
     }
     if (RemotingServices.IsTransparentProxy(msg) && InvalidRemoteMessage.Contains(msg.GetKey()))
     {
         throw new ArgumentException("This message is not remotable!");
     }
     return(_secsGem.SendAsync(msg));
 }
Exemplo n.º 16
0
        public static string ToSml(this SecsMessage msg)
        {
            if (msg is null)
            {
                return(null);
            }

            using (var sw = new StringWriter())
            {
                msg.WriteTo(sw);
                return(sw.ToString());
            }
        }
Exemplo n.º 17
0
    private static bool IsMessageEquals(SecsMessage left, SecsMessage?right)
    {
        if (right is null)
        {
            return(false);
        }

        // exclude Name property
        return(left.S == right.S &&
               left.F == right.F &&
               left.ReplyExpected == right.ReplyExpected &&
               EqualityComparer <Item> .Default.Equals(left.SecsItem !, right.SecsItem !));
    }
Exemplo n.º 18
0
        void EQP_SlotMapReport(SecsMessage msg)
        {
            var portNo    = (byte)msg.SecsItem.Items[2].Items[0].Items[1].Items[0];
            var carrierId = (string)msg.SecsItem.Items[2].Items[0].Items[1].Items[1];
            var map       = (string)msg.SecsItem.Items[2].Items[0].Items[1].Items[1 + portNo];

            EAP.Report(new SlotMapReport {
                LoadPortID = GetPortID(portNo),
                CarrierID  = carrierId,
                Slots      = from i in Enumerable.Range(0, map.Length)
                             where map[i] == '1'
                             select(byte)(i + 1)
            });
        }
Exemplo n.º 19
0
        public void HandleSecsMessage(SecsMessage secsMessage)
        {
            PrimaryMessage = secsMessage;
            switch (PrimaryMessage.GetSFString())
            {
            case "S2F41":    // host command
                int rcmd = PrimaryMessage.GetCommandValue();
                handleRCMDMessage(rcmd);
                break;

            default:
                break;
            }
        }
Exemplo n.º 20
0
        public static void WriteTo(this SecsMessage msg, TextWriter writer, int indent = 4)
        {
            if (msg is null)
            {
                return;
            }

            writer.WriteLine(msg.ToString());
            if (msg.SecsItem != null)
            {
                Write(writer, msg.SecsItem, indent);
            }
            writer.Write('.');
        }
Exemplo n.º 21
0
        public SecsMessage getChatMsgFromJsonStr(string jsonStr)
        {
            SecsMessage sMsg = null;

            try
            {
                sMsg = Serializer.Deserialize <SecsMessage>(jsonStr);
            }
            catch (Exception ex)
            {
            }

            return(sMsg);
        }
Exemplo n.º 22
0
        public static Task <SecsMessage> SendMessage(this SecsGem secsGem, short deviceId, byte s, byte f, bool replyExpected, int systemBytes, Item item = null, string key = "", int value = 0)
        {
            SecsMessage secsMessage = new SecsMessage(s, f, replyExpected, GetFunctionName(s, f, key, value), item);

            CIMBASE.WriteLog(AATS.Log.LogLevel.INFO, "\r\n" + secsMessage.ToSml());
            if (systemBytes == -1)
            {
                return(secsGem.SendAsync(secsMessage));
            }
            else
            {
                return(secsGem.SendAsync(secsMessage, systemBytes));
            }
        }
Exemplo n.º 23
0
        void EQP_SlotMapReport(SecsMessage msg)
        {
            byte   portNo    = (byte)msg.SecsItem.Items[2].Items[0].Items[1].Items[0];
            string carrierID = msg.SecsItem.Items[2].Items[0].Items[1].Items[1].GetValue <string>().Trim();
            var    mapItem   = msg.SecsItem.Items[2].Items[0].Items[1].Items[2].Items;

            EAP.Report(new SlotMapReport {
                LoadPortID = GetPortID(portNo),
                CarrierID  = carrierID,
                Slots      = from i in Enumerable.Range(0, mapItem.Count)
                             where mapItem[i].GetValue <byte>() == 4
                             select(byte)(i + 1)
            });
        }
Exemplo n.º 24
0
        public static async Task WriteToAsync(this SecsMessage msg, TextWriter writer, int indent = 4)
        {
            if (msg is null)
            {
                return;
            }

            await writer.WriteLineAsync(msg.ToString());

            if (msg.SecsItem != null)
            {
                await WriteAsync(writer, msg.SecsItem, indent);
            }
            await writer.WriteAsync('.');
        }
Exemplo n.º 25
0
        public void HandleSecsMessage(SecsMessage secsMessage)
        {
            PrimaryMessage = secsMessage;
            switch (PrimaryMessage.GetSFString())
            {
            case "S6F3":    //Discrete Variable Data Send
                SubScenarioName = Resource.DCS_Discrete_Variable_Data_Send;
                PrimaryMessage.S6F4(0);
                break;

            case "S2F23":    // trace data initialization request
                SubScenarioName = Resource.DCS_Host_Initiates_Trace_Report;
                PrimaryMessage.S2F24("0");
                TraceDataInitializationRequest traceDataInitializationRequest = new TraceDataInitializationRequest();
                traceDataInitializationRequest.Parse(PrimaryMessage.SecsItem);
                dataCollection.TraceDataInitializationRequestEvent(traceDataInitializationRequest);
                break;

            case "S6F1":
                break;

            case "S1F3":    // Selected Equipment Status Request
                SubScenarioName = Resource.DCS_Host_request_value_status;
                handleS1F3();
                break;

            case "S1F5":    // Request formatted status
                SubScenarioName = Resource.DCS_Host_request_Formatted_status;
                handleS1F5();
                break;

            case "S2F13":    // equipment constants request
                SubScenarioName = Resource.DCS_Equipment_Constants_Request;
                handleS2F13();
                break;

            case "S2F15":    // X
                break;

            case "S2F37":    // host request enable or disable events
                SubScenarioName = Resource.DCS_Host_Requests_Enable_Disable_Event;
                handleS2F37();
                break;

            default:
                break;
            }
        }
Exemplo n.º 26
0
        private void chatMsgReceivedEventHandler(object sender, string msg)
        {
            int         id   = Thread.CurrentThread.ManagedThreadId;
            SecsMessage cMsg = getChatMsgFromJsonStr(msg);

            if (cMsg != null)
            {
                StreamTextBox.Text   = cMsg.S.ToString();
                FunctionTextBox.Text = cMsg.F.ToString();
                MessageTextBox.Text  = cMsg.ToString();
            }
            else
            {
                //MessageBox.Show("event received, but no secs message.");
            }
        }
Exemplo n.º 27
0
    public void Setup()
    {
        _message = new(s : 1, f : 2, replyExpected : false)
        {
            Name     = "Test",
            SecsItem = L(
                L(),
                U1(MemoryOwner <byte> .Allocate(ItemCount)),
                U2(MemoryOwner <ushort> .Allocate(ItemCount)),
                U4(MemoryOwner <uint> .Allocate(ItemCount)),
                F4(MemoryOwner <float> .Allocate(ItemCount)),
                A(CreateString(ItemCount, Encoding.ASCII)),
                J(CreateString(ItemCount, Item.Jis8Encoding)),  //JIS encoding cost more memory in coreclr
                F8(MemoryOwner <double> .Allocate(ItemCount)),
                L(
                    I1(MemoryOwner <sbyte> .Allocate(ItemCount)),
                    I2(MemoryOwner <short> .Allocate(ItemCount)),
                    I4(MemoryOwner <int> .Allocate(ItemCount)),
                    F4(MemoryOwner <float> .Allocate(ItemCount)),
                    L(
                        I1(MemoryOwner <sbyte> .Allocate(ItemCount)),
                        I2(MemoryOwner <short> .Allocate(ItemCount)),
                        I4(MemoryOwner <int> .Allocate(ItemCount)),
                        F4(MemoryOwner <float> .Allocate(ItemCount)),
                        Boolean(MemoryOwner <bool> .Allocate(ItemCount)),
                        B(MemoryOwner <byte> .Allocate(ItemCount)),
                        L(
                            A(CreateString(ItemCount, Encoding.ASCII)),
                            J(CreateString(ItemCount, Item.Jis8Encoding)),
                            Boolean(MemoryOwner <bool> .Allocate(ItemCount)),
                            B(MemoryOwner <byte> .Allocate(ItemCount))),
                        F8(MemoryOwner <double> .Allocate(ItemCount))),
                    Boolean(MemoryOwner <bool> .Allocate(ItemCount)),
                    B(MemoryOwner <byte> .Allocate(ItemCount)),
                    L(
                        A(CreateString(ItemCount, Encoding.ASCII)),
                        J(CreateString(ItemCount, Item.Jis8Encoding)),
                        Boolean(MemoryOwner <bool> .Allocate(ItemCount)),
                        B(MemoryOwner <byte> .Allocate(ItemCount))),
                    F8(MemoryOwner <double> .Allocate(ItemCount))),
                U1(MemoryOwner <byte> .Allocate(ItemCount)),
                U2(MemoryOwner <ushort> .Allocate(ItemCount)),
                U4(MemoryOwner <uint> .Allocate(ItemCount)),
                F4(MemoryOwner <float> .Allocate(ItemCount))),
        };

        _sml = _message.ToSml();
Exemplo n.º 28
0
        void EQP_WaferProcessData_PVD(SecsMessage msg)
        {
            Item   tempList = msg.SecsItem.Items[2].Items[0].Items[1].Items[0];
            string pjID     = tempList.Items[1].GetValue <string>();
            byte   slotNo   = (byte)tempList.Items[4].Items[0].Items[1];

            tempList = tempList.Items[4].Items[0].Items[2].Items[0];
            string chamber = tempList.Items[0].Items[1].GetValue <string>();

            var dc = new DataCollectionReport(GetProcessJob(pjID));

            try {
                dc.AddLotData("CIWW", chamber);
            } finally {
                EAP.Report(dc);
            }
        }
Exemplo n.º 29
0
        async Task ChangeAccessMode(AccessMode changeAccessMode, byte portNo)
        {
            var S3F23 = new SecsMessage(3, 23, "ChangeAccessMode",
                                        Item.L(
                                            Item.A(),
                                            Item.U1((byte)changeAccessMode),
                                            Item.L(
                                                Item.U1(portNo))));

            var S3F24 = await EAP.SendAsync(S3F23);

            var returnCode = (byte)S3F24.SecsItem.Items[0];

            if (returnCode != 0 && returnCode != 4)
            {
                throw new ScenarioException("Change Loadport[" + portNo + "] access mode fial. " + S3F24.SecsItem.Items[1].Items[1].GetString());
            }
        }
Exemplo n.º 30
0
        void Recover(object sender, ReceiveCompletedEventArgs e)
        {
            var queue = sender as MessageQueue;

            try {
                Message     msg     = queue.EndReceive(e.AsyncResult);
                SecsMessage secsMsg = msg.Body as SecsMessage;
                if (secsMsg != null)
                {
                    _subscription.Handle(secsMsg);
                }
                queue.BeginReceive(TimeSpan.FromSeconds(QUEUE_RECEIVE_TIMEOUT));
            } catch (MessageQueueException) {
                _serverDisposable.RecoverComplete();
                queue.Close();
                MessageQueue.Delete(_queuePath);
            }
        }
Exemplo n.º 31
0
 public IObservable<PrimaryMessageWrapper> Match(SecsMessage pattern) 
     => MessageEvents.Where(a => a.Message.IsMatch(pattern));