123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630 |
- using MECF.Framework.Common.Communications;
- using Newtonsoft.Json.Linq;
- using System;
- using System.Linq;
- using System.Text;
- namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.VCE.SiasunVCEII
- {
- public abstract class SiasunVCEHandler : HandlerBase
- {
- public SiasunVCE Device { get; set; }
- protected string _commandType;
- protected string _command;
- protected string _parameter;
- public bool IsSendText(string commandType, string command, string commandArgumen)
- {
- return _commandType == commandType && _command == command && _parameter == commandArgumen;
- }
- protected SiasunVCEHandler(SiasunVCE device, string commandType, string command, string parameter = null)
- : base(BuildMessage(commandType, command, parameter))
- {
- Device = device;
- _commandType = commandType;
- _command = command;
- _parameter = parameter;
- Name = command;
- }
- private static string BuildMessage(string commandType, string command, string parameter)
- {
- string strCommand = $"{commandType}";
- if (!string.IsNullOrEmpty(command))
- {
- strCommand += "," + command;
- }
- if (!string.IsNullOrEmpty(parameter))
- {
- strCommand += "," + parameter;
- }
- return strCommand + "\r";
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- var result = msg as SiasunVCEMessage;
- handled = msg.IsComplete;
- if (result.IsError)
- {
- Device.NoteError(result.Data);
- }
- else
- {
- Device.NoteError(null);
- }
- if (result.IsComplete)
- {
- SetState(EnumHandlerState.Completed);
- }
- if (result.IsAck)
- {
- SetState(EnumHandlerState.Acked);
- }
- ResponseMessage = msg;
- return handled;
- }
- }
- public class SiasunVCERawCommandHandler : SiasunVCEHandler
- {
- public SiasunVCERawCommandHandler(SiasunVCE device, string commandType, string command, string parameter = null)
- : base(device, commandType, command, parameter)
- {
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- base.HandleMessage(msg, out handled);
- var result = msg as SiasunVCEMessage;
- Device.NoteRawCommandInfo(_commandType, _command, result.RawMessage);
- return true;
- }
- }
- public class SiasunVCEAbortHandler : SiasunVCEHandler
- {
- public SiasunVCEAbortHandler(SiasunVCE device)
- : base(device, "E", "")
- {
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- Device.IsIdle = true;
- }
- return true;
- }
- }
- public class SiasunVCEMoveHandler : SiasunVCEHandler
- {
- public SiasunVCEMoveHandler(SiasunVCE device, string axis, string type, string value)
- : base(device, "A", "MOVE", axis + "," + type + "," + value)
- {
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- Device.NoteMoveResult(_parameter);
- Device.IsIdle = true;
- }
- return true;
- }
- }
- public class SiasunVCEZAxisMoveToLoadPositionHandler : SiasunVCEHandler
- {
- public SiasunVCEZAxisMoveToLoadPositionHandler(SiasunVCE device, int timeout)
- : base(device, "A", "LP")
- {
- AckTimeout = TimeSpan.FromSeconds(timeout);
- CompleteTimeout = TimeSpan.FromSeconds(timeout);
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- Device.IsZAxisAtLoadPostion = true;
- Device.IsIdle = true;
- }
- return true;
- }
- }
- public class SiasunVCEPlatformInHandler : SiasunVCEHandler
- {
- public SiasunVCEPlatformInHandler(SiasunVCE device, int timeout)
- : base(device, "A", "PI")
- {
- AckTimeout = TimeSpan.FromSeconds(timeout);
- CompleteTimeout = TimeSpan.FromSeconds(timeout);
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- Device.IsPlatformIn = true;
- Device.IsPlatformOut = false;
- Device.IsIdle = true;
- }
- return true;
- }
- }
- public class SiasunVCEMappingHandler : SiasunVCEHandler
- {
- public SiasunVCEMappingHandler(SiasunVCE device, int timeout)
- : base(device, "A", "MP")
- {
- AckTimeout = TimeSpan.FromSeconds(timeout);
- CompleteTimeout = TimeSpan.FromSeconds(timeout);
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- Device.IsIdle = true;
- Device.IsMapped = true;
- }
- return true;
- }
- }
- public class SiasunVCEPlatformOutHandler : SiasunVCEHandler
- {
- public SiasunVCEPlatformOutHandler(SiasunVCE device, int timeout)
- : base(device, "A", "PO")
- {
- AckTimeout = TimeSpan.FromSeconds(timeout);
- CompleteTimeout = TimeSpan.FromSeconds(timeout);
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- Device.IsPlatformOut = true;
- Device.IsPlatformIn = false;
- Device.IsIdle = true;
- }
- return true;
- }
- }
- public class SiasunVCECloseDoorHandler : SiasunVCEHandler
- {
- public SiasunVCECloseDoorHandler(SiasunVCE device, int timeout)
- : base(device, "A", "DC")
- {
- AckTimeout = TimeSpan.FromSeconds(timeout);
- CompleteTimeout = TimeSpan.FromSeconds(timeout);
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- Device.IsDoorClosed = true;
- Device.IsDoorOpened = false;
- Device.IsIdle = true;
- }
- return true;
- }
- }
- public class SiasunVCEOpenDoorHandler : SiasunVCEHandler
- {
- public SiasunVCEOpenDoorHandler(SiasunVCE device, int timeout)
- : base(device, "A", "DO")
- {
- AckTimeout = TimeSpan.FromSeconds(timeout);
- CompleteTimeout = TimeSpan.FromSeconds(timeout);
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- Device.IsDoorOpened = true;
- Device.IsDoorClosed = false;
- Device.IsMapped = false;
- Device.IsIdle = true;
- }
- return true;
- }
- }
- public class SiasunVCEHomeHandler : SiasunVCEHandler
- {
- public SiasunVCEHomeHandler(SiasunVCE device, int timeout)
- : base(device, "A", "HM", "ALL")
- {
- AckTimeout = TimeSpan.FromSeconds(timeout);
- CompleteTimeout = TimeSpan.FromSeconds(timeout);
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- Device.NoteHomed(true);
- Device.IsIdle = true;
- }
- return true;
- }
- }
- public class SiasunVCEHomeRAxisHandler : SiasunVCEHandler
- {
- public SiasunVCEHomeRAxisHandler(SiasunVCE device, int timeout)
- : base(device, "A", "HM", "R")
- {
- AckTimeout = TimeSpan.FromSeconds(timeout);
- CompleteTimeout = TimeSpan.FromSeconds(timeout);
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- Device.IsIdle = true;
- }
- return true;
- }
- }
- public class SiasunVCEHomeZAxisHandler : SiasunVCEHandler
- {
- public SiasunVCEHomeZAxisHandler(SiasunVCE device, int timeout)
- : base(device, "A", "HM", "Z")
- {
- AckTimeout = TimeSpan.FromSeconds(timeout);
- CompleteTimeout = TimeSpan.FromSeconds(timeout);
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- Device.NoteHomed(true);
- Device.IsIdle = true;
- }
- return true;
- }
- }
- public class SiasunVCEZAxisGotoSlotHandler : SiasunVCEHandler
- {
- public SiasunVCEZAxisGotoSlotHandler(SiasunVCE device, int slot, int timeout)
- : base(device, "A", "GO", (slot + 1).ToString())
- {
- AckTimeout = TimeSpan.FromSeconds(timeout);
- CompleteTimeout = TimeSpan.FromSeconds(timeout);
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- Device.NoteZAxisPosition(_parameter);
- Device.IsIdle = true;
- }
- return true;
- }
- }
- //motor motion scope
- public class SiasunVCERequestZAxisMotionScopenHandler : SiasunVCEHandler
- {
- public SiasunVCERequestZAxisMotionScopenHandler(SiasunVCE device, bool isUp)
- : base(device, "R", "ARM", "Z," + (isUp ? "UP" : "DN"))
- {
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- var result = msg as SiasunVCEMessage;
- Device.NoteArmRPositon(result.Data.Split(',')[2]);
- }
- return true;
- }
- }
- public class SiasunVCEResetErrorHandler : SiasunVCEHandler
- {
- public SiasunVCEResetErrorHandler(SiasunVCE device)
- : base(device, "S", "ER")
- {
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- Device.IsAlarm = false;
- }
- return true;
- }
- }
- public class SiasunVCECassetteInterlockHandler : SiasunVCEHandler
- {
- public SiasunVCECassetteInterlockHandler(SiasunVCE device, bool isEnable)
- : base(device, "S", "CE", isEnable ? "Y" : "N")
- {
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- Device.IsAlarm = false;
- }
- return true;
- }
- }
- public class SiasunVCEDoorInterlockHandler : SiasunVCEHandler
- {
- public SiasunVCEDoorInterlockHandler(SiasunVCE device, bool isEnable)
- : base(device, "S", "ZD", isEnable ? "Y" : "N")
- {
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- Device.IsAlarm = false;
- }
- return true;
- }
- }
- public class SiasunVCERequestErrorInfoHandler : SiasunVCEHandler
- {
- public SiasunVCERequestErrorInfoHandler(SiasunVCE device)
- : base(device, "R", "ER")
- {
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- var result = msg as SiasunVCEMessage;
- Device.NoteCurrentErrorStatus(result.Data.Replace("ER", ""));//X,ERcode
- Device.IsIdle = true;
- }
- return true;
- }
- }
- public class SiasunVCERequestWaferSlideOutHandler : SiasunVCEHandler
- {
- public SiasunVCERequestWaferSlideOutHandler(SiasunVCE device)
- : base(device, "R", "SO")
- {
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- var result = msg as SiasunVCEMessage;
- Device.IsWaferSlideOut = result.Data.Replace("SO", "").ToUpper() == "Y";
- Device.IsIdle = true;
- }
- return true;
- }
- }
- public class SiasunVCERequestCassettePresentHandler : SiasunVCEHandler
- {
- public SiasunVCERequestCassettePresentHandler(SiasunVCE device)
- : base(device, "R", "W2")
- {
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- var result = msg as SiasunVCEMessage;
- Device.IsCassettePresent = result.Data.Replace("W2", "").ToUpper() == "Y";
- Device.IsIdle = true;
- }
- return true;
- }
- }
- // R,STAT,DOOR
- public class SiasunVCERequestDoorStatusHandler : SiasunVCEHandler
- {
- public SiasunVCERequestDoorStatusHandler(SiasunVCE device)
- : base(device, "R", "STAT", "DOOR")
- {
- }
- // X,STATC
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- var result = msg as SiasunVCEMessage;
- string resp = result.Data.Replace("STAT", "").ToUpper();
- Device.IsDoorOpened = resp.Last() == 'O';
- Device.IsDoorClosed = resp.Last() == 'C';
- Device.IsIdle = true;
- }
- return true;
- }
- }
- public class SiasunVCERequestArmPositionHandler : SiasunVCEHandler
- {
- public SiasunVCERequestArmPositionHandler(SiasunVCE device)
- : base(device, "R", "STAT", "ARM")
- {
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- var result = msg as SiasunVCEMessage;
- var pos = result.Data.Replace("STAT", "").ToUpper();
- if (int.TryParse(pos, out int slot) && slot > 0)
- {
- //slot
- Device.IsZAxisAtLoadPostion = false;
- Device.IsZAxisAtHomePostion = false;
- Device.ZAxisAtSlot = slot - 1;
- }
- else if (pos == "M")
- {
- //Mapping end position
- Device.IsZAxisAtLoadPostion = false;
- Device.IsZAxisAtHomePostion = false;
- Device.ZAxisAtSlot = -1;
- }
- else if (pos == "H")
- {
- //Home position
- Device.IsZAxisAtLoadPostion = false;
- Device.IsZAxisAtHomePostion = true;
- Device.ZAxisAtSlot = -1;
- }
- else if (pos == "L")
- {
- //Home position
- Device.IsZAxisAtLoadPostion = true;
- Device.IsZAxisAtHomePostion = false;
- Device.ZAxisAtSlot = -1;
- }
- else
- {
- //unknown position
- Device.IsZAxisAtLoadPostion = false;
- Device.IsZAxisAtHomePostion = false;
- Device.ZAxisAtSlot = -1;
- }
- Device.IsIdle = true;
- }
- return true;
- }
- }
- public class SiasunVCERequestMappingInfoHandler : SiasunVCEHandler
- {
- //S:single wafer
- //O;no wafer
- //T:double wafer
- //C:cross wafer
- //?:slot spare
- //X,MI****
- public SiasunVCERequestMappingInfoHandler(SiasunVCE device)
- : base(device, "R", "MI")
- {
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- var result = msg as SiasunVCEMessage;
- var arr = result.Data.Replace("MI", "").Replace("?", "").ToCharArray();
- Array.Reverse(arr);// slot25->slot1 to slot1->slot25
- Device.NoteCurrentMappingInfo(new string(arr));
- Device.IsIdle = true;
- }
- return true;
- }
- }
- public class SiasunVCESetCassetteSlotNumberHandler : SiasunVCEHandler
- {
- // slot number [1, 25]
- public SiasunVCESetCassetteSlotNumberHandler(SiasunVCE device, int slotNum)
- : base(device, "S", "CF,NS", slotNum.ToString())
- {
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- }
- return true;
- }
- }
- public class SiasunVCESetMappingTeachFlagHandler : SiasunVCEHandler
- {
- public SiasunVCESetMappingTeachFlagHandler(SiasunVCE device, bool isMappingTeach)
- : base(device, "S", "MP", (isMappingTeach ? 1 : 0).ToString())
- {
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- }
- return true;
- }
- }
- public class SiasunVCESetZAxisSpeedHandler : SiasunVCEHandler
- {
- //speed range (0,99] %
- public SiasunVCESetZAxisSpeedHandler(SiasunVCE device, int speed)
- : base(device, "S", "SPEED,Z", speed.ToString())
- {
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- }
- return true;
- }
- }
- public class SiasunVCESetWaferDetectHandler : SiasunVCEHandler
- {
- public SiasunVCESetWaferDetectHandler(SiasunVCE device, bool isDetect)
- : base(device, "S", "WS", isDetect ? "Y" : "N")
- {
- }
- public override bool HandleMessage(MessageBase msg, out bool handled)
- {
- if (base.HandleMessage(msg, out handled))
- {
- }
- return true;
- }
- }
- }
|