123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557 |
- using System;
- using System.Text.RegularExpressions;
- using System.Threading;
- using System.Threading.Tasks;
- using Aitex.Core.UI.Control;
- using MECF.Framework.Simulator.Core.Driver;
- using Aitex.Core.Util;
- using CyberX8_Core;
- using Aitex.Core.RT.DataCenter;
- using System.Linq;
- using MECF.Framework.Common.DataCenter;
- using Aitex.Core.RT.ConfigCenter;
- using CyberX8_Simulator.Instances;
- using System.Collections.Generic;
- namespace CyberX8_Simulator.Devices
- {
- public class SunWayEfemSimulator : SocketDeviceSimulator
- {
- private const string SCMD = @"(?<=\:)(.*?)(?=\/)";
- private const string SFOUP = @"(?<=P)(\d{1})(?=[\;\/])";
- private const string ACK = "ACK";
- private readonly char[] delimiters = { ':', '/', '>', '|', ';' };
- private string[] _slotMap = new string[25];
- private string[] _slotDummy = new string[25];
- private PeriodicJob _HwThread;
- private bool _bCommReady;
- private bool _isDoorOpen;
- private bool _isLp1Placed;
- private bool _isLp2Placed;
- private bool _isLp3Placed;
- private bool _isLp1Clamped;
- private bool _isLp2Clamped;
- private bool _isLp3Clamped;
- private bool _isLP1Docked;
- private bool _isLP2Docked;
- private bool _isLP3Docked;
- public int WaferSize = 200;
- private int _speed = 20;
- private string _carrier1ID = "12345678";
- private string _carrier2ID = "12345678";
- private string _carrier3ID = "12345678";
- private List<int> _lpStationNumber;
- private List<int> _dummyStationNumber;
- public string SlotMap
- {
- get { return string.Join("", _slotMap); }
- }
- public bool _isVacuumError { get; set; }
- public bool _isAirError { get; set; }
- public bool _isFlowError { get; set; }
- public bool _isLeak { get; set; }
- public bool _isMaintain { get; set; }
- public bool _isWaferPresent { get; set; }
- public bool _isMaintainDoorOpen { get; private set; }
- public bool _isProtrude1 { get; set; }
- public bool _isProtrude2 { get; set; }
- public bool _isVAC { get; set; }
- public bool _isAIR { get; set; }
- private bool _isDoorOpen1;
- public bool IsDoorOpen1 { get { return _isDoorOpen1; } set { _isDoorOpen1 = value; SendLP1Data(); } }
- private bool _isDoorOpen2;
- public bool IsDoorOpen2 { get { return _isDoorOpen2; } set { _isDoorOpen2 = value;SendLP2Data(); } }
- private bool _isDoorOpen3;
- public bool IsDoorOpen3
- {
- get { return _isDoorOpen3; }
- set { _isDoorOpen3 = value; SendLP3Data(); }
- }
- public SunWayEfemSimulator() : base(1102, -1, "\r", ' ')
- {
- for (int i = 0; i < _slotMap.Length; i++)
- _slotMap[i] = "0";
- for(int i=0; i < _slotDummy.Length; i++)
- {
- _slotDummy[i]="0";
- }
- _HwThread = new PeriodicJob(5000, OnSendEvent, "EfemHardware", true);
- GetStationNumber();
- }
- private bool OnSendEvent()
- {
- if (IsConnected)
- {
-
- }
- return true;
- }
- private void GetStationNumber()
- {
- _lpStationNumber = new List<int>();
- _lpStationNumber.Add(SystemConfig.Instance.GetValue<int>("EFEM.LP1.Cassete200Station"));
- _lpStationNumber.Add(SystemConfig.Instance.GetValue<int>("EFEM.LP1.Cassete150Station"));
- _lpStationNumber.Add(SystemConfig.Instance.GetValue<int>("EFEM.LP1.Cassete100Station"));
- _lpStationNumber.Add(SystemConfig.Instance.GetValue<int>("EFEM.LP2.Cassete200Station"));
- _lpStationNumber.Add(SystemConfig.Instance.GetValue<int>("EFEM.LP2.Cassete150Station"));
- _lpStationNumber.Add(SystemConfig.Instance.GetValue<int>("EFEM.LP2.Cassete100Station"));
- _lpStationNumber.Add(SystemConfig.Instance.GetValue<int>("EFEM.LP3.Cassete200Station"));
- _lpStationNumber.Add(SystemConfig.Instance.GetValue<int>("EFEM.LP3.Cassete150Station"));
- _lpStationNumber.Add(SystemConfig.Instance.GetValue<int>("EFEM.LP3.Cassete100Station"));
- _dummyStationNumber = new List<int>();
- _dummyStationNumber.Add(SystemConfig.Instance.GetValue<int>("EFEM.Dummy1.Cassete200Station"));
- _dummyStationNumber.Add(SystemConfig.Instance.GetValue<int>("EFEM.Dummy1.Cassete150Station"));
- _dummyStationNumber.Add(SystemConfig.Instance.GetValue<int>("EFEM.Dummy1.Cassete100Station"));
- _dummyStationNumber.Add(SystemConfig.Instance.GetValue<int>("EFEM.Dummy2.Cassete200Station"));
- _dummyStationNumber.Add(SystemConfig.Instance.GetValue<int>("EFEM.Dummy2.Cassete150Station"));
- _dummyStationNumber.Add(SystemConfig.Instance.GetValue<int>("EFEM.Dummy2.Cassete100Station"));
- }
- protected override void ProcessUnsplitMessage(string str)
- {
-
-
- OnWork(str);
- }
- internal void SetCassetteDoor(bool doorOpen)
- {
- _isMaintainDoorOpen = doorOpen;
- uint data = doorOpen ? (uint)0b0111111111000001110 : (uint)0b0111111111000001111;
- string msg = $"EVT:SIGSTAT/System/{data:X8}/00000000;";
- OnWriteMessage(msg);
- }
- internal void SetMaintain(bool maintain)
- {
- _isMaintain = maintain;
- uint data = maintain ? (uint)0b0111111111000011111 : (uint)0b0111111111000001111;
- string msg = $"EVT:SIGSTAT/System/{data:X8}/00000000;";
- OnWriteMessage(msg);
- }
- internal void SetProtrude1(bool protrude)
- {
- _isProtrude1 = protrude;
- uint data = protrude? (uint)0b0111111111000101111: (uint)0b0111111111000001111;
- string msg = $"EVT:SIGSTAT/System/{data:X8}/00000000;";
- OnWriteMessage(msg);
- }
- internal void SetProtrude2(bool protrude)
- {
- _isProtrude2 = protrude;
- uint data = protrude ? (uint)0b0111111111001001111 : (uint)0b0111111111000001111;
- string msg = $"EVT:SIGSTAT/System/{data:X8}/00000000;";
- OnWriteMessage(msg);
- }
- internal void SetVAC(bool VAC)
- {
- _isVAC = VAC;
- uint data = VAC ? (uint)0b0111111111000001101 : (uint)0b0111111111000001111;
- string msg = $"EVT:SIGSTAT/System/{data:X8}/00000000;";
- OnWriteMessage(msg);
- }
- internal void SetAIR(bool AIR)
- {
- _isAIR = AIR;
- uint data = AIR ? (uint)0b0111111111000001011 : (uint)0b0111111111000001111;
- string msg = $"EVT:SIGSTAT/System/{data:X8}/00000000;";
- OnWriteMessage(msg);
- }
- private void OnWork(string str)
- {
- string ack = "";
- if (str.StartsWith("RQ LOAD"))
- {
- ack = "LOAD A OFF\n_RDY";
- }
- else if (str.StartsWith("RSR"))
- {
- string[] strings = str.Split(' ').ToArray();
- int stationNumber = int.Parse(strings[1]);
- if (_lpStationNumber.Contains(stationNumber))
- {
- string lpwafer = "";
- foreach (var item in _slotMap)
- {
- lpwafer += $" {item}";
- }
- ack = "MAP" + lpwafer;
- }
- else if (_dummyStationNumber.Contains(stationNumber))
- {
- string dummywafer = "";
- foreach (var item in _slotDummy)
- {
- dummywafer += $" {item}";
- }
- ack = "MAP" + dummywafer;
- }
- }
- else
- {
- if (str.StartsWith("PICK") || str.StartsWith("PLACE") || str.StartsWith("MAP") || str.StartsWith("ALIGNER ALGN") || str.StartsWith("ALIGNER HOME"))
- {
- Thread.Sleep((ushort)2200);
- }
- ack = "_RDY";
- }
- OnWriteMessage(ack);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- private void UpdateLocked(string lpNumber,bool locked)
- {
- if (lpNumber== "1")
- {
- _isLP1Docked = locked;
- SendLP1Data();
- }
- else if (lpNumber == "2")
- {
- _isLP2Docked = locked;
- SendLP2Data();
- }
- else if (lpNumber == "3")
- {
- _isLP3Docked = locked;
- SendLP3Data();
- }
- }
- private void UpdateClamped(string lpNumber, bool clamped)
- {
- if (lpNumber == "1")
- {
- _isLp1Clamped = clamped;
- SendLP1Data();
- }
- else if (lpNumber == "2")
- {
- _isLp2Clamped = clamped;
- SendLP2Data();
- }
- else if (lpNumber == "3")
- {
- _isLp3Clamped = clamped;
- SendLP3Data();
- }
- }
- private void SendLP1Data()
- {
- uint data = GetLP1Data1();
- string msg = $"EVT:SIGSTAT/LP1/{data:X8}/0000;";
- OnWriteMessage(msg);
- }
- private void SendLP2Data()
- {
- uint data = GetLP2Data1();
- string msg = $"EVT:SIGSTAT/LP2/{data:X8}/0000;";
- OnWriteMessage(msg);
- }
- private void SendLP3Data()
- {
- uint data = GetLP3Data1();
- string msg = $"EVT:SIGSTAT/LP3/{data:X8}/0000;";
- OnWriteMessage(msg);
- }
- private void SendAlignData()
- {
- string msg = $"EVT:ALIGN/ALN1/0;";
- OnWriteMessage(msg);
- }
- private void SendDummyMapData(string dummy)
- {
- string s2 = $"EVT:MAPDT/{dummy}/{_slotDummy};\r";
- OnWriteMessage(s2);
- }
- private void SendSystemData()
- {
- uint data = 0b0111111111000001111;
- string msg = $"EVT:SIGSTAT/System/{data:X8}/00000000;";
- OnWriteMessage(msg);
- }
- private ushort SimuOperationTime(EfemOperation op)
- {
- ushort sec = 0;
- switch (op)
- {
- case EfemOperation.Map:
- case EfemOperation.GetWaferInfo:
- case EfemOperation.Align:
- sec = 2200;
- break;
- case EfemOperation.Pick:
- case EfemOperation.Place:
- case EfemOperation.Orgsh:
- sec = 2200;
- break;
- case EfemOperation.Light:
- case EfemOperation.SigStatus:
- sec = 0;
- break;
- default:
- sec = 100;
- break;
- }
- return sec;
- }
- public void PlaceCarrier1()
- {
- _isLp1Placed = true;
- SendLP1Data();
- }
- public void RemoveCarrier1()
- {
- _isLp1Placed = false;
- SendLP1Data();
- }
- public void PlaceCarrier2()
- {
- _isLp2Placed = true;
- SendLP2Data();
- }
- public void RemoveCarrier2()
- {
- _isLp2Placed = false;
- SendLP2Data();
- }
- public void PlaceCarrier3()
- {
- _isLp3Placed = true;
- SendLP3Data();
- }
- public void RemoveCarrier3()
- {
- _isLp3Placed = false;
- SendLP3Data();
- }
- public void ClearWafer()
- {
- for (int i = 0; i < _slotMap.Length; i++)
- {
- _slotMap[i] = "0";
- }
- for (int i = 0; i < _slotDummy.Length; i++)
- {
- _slotDummy[i] = "0";
- }
- }
- public void SetAllWafer()
- {
- for (int i = 0; i < _slotMap.Length; i++)
- {
- _slotMap[i] = "1";
- }
- }
- public void RandomWafer()
- {
- Random _rd = new Random();
- for (int i = 0; i < _slotMap.Length; i++)
- {
-
- _slotMap[i]= _rd.Next(0, 10) < 6 ? "0" : "1";
- }
- }
- public void RandomDummyWafer()
- {
- Random _rdDummy = new Random();
- for (int i = 0; i < _slotDummy.Length; i++)
- {
- _slotDummy[i] = _rdDummy.Next(0, 10) < 6 ? "0" : "1";
- }
- }
- private uint GetLP1Data1()
- {
- uint data1 = 0x0u;
- data1 |= (_isLp1Placed ? 0x00000001u : 0x0);
- data1 |= (_isLp1Clamped ? 0x00000002u : 0x0);
- data1 |= (_isLP1Docked ? 0x00000004u : 0x0);
- data1 |= (_isDoorOpen1 ? 0x00000020u : 0x0);
- return data1;
- }
-
- private uint GetLP2Data1()
- {
- uint data1 = 0x0u;
- data1 |= (_isLp2Placed ? 0x00000001u : 0x0);
- data1 |= (_isLp2Clamped ? 0x00000002u : 0x0);
- data1 |= (_isLP2Docked ? 0x00000004u : 0x0);
- data1 |= (_isDoorOpen2 ? 0x00000020u : 0x0);
- return data1;
- }
- private uint GetLP3Data1()
- {
- uint data1 = 0x0u;
- data1 |= (_isLp3Placed ? 0x00000001u : 0x0);
- data1 |= (_isLp3Clamped ? 0x00000002u : 0x0);
- data1 |= (_isLP3Docked ? 0x00000004u : 0x0);
- data1 |= (_isDoorOpen3 ? 0x00000020u : 0x0);
- return data1;
- }
- }
- }
|