123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Documents;
- namespace EPD.Data
- {
- public class CytAsciiDefine
- {
- public static Dictionary<int, string> ErrorMap = new Dictionary<int, string>()
- {
- {0x0000, "OK"},
- {0x1000, "Format error"},
- {0x1001, "Parameter invalid"},
- {0x1002, "EPD not online"},
- {0x1003, "EPD is initializing"},
- {0x1004, "EPD config file has invalid setting"},
- {0x1005, "EPD calculation failed"},
- {0x1006, "EPD not remote"},
- { 0x1100, "Device has other error" },
- { 0x1101, "Device nvalid" },
- { 0x1102, "No Device" },
- { 0x1103, "Device close failed" },
- { 0x1104, "Device: order not implemented" },
- { 0x1105, "Device: a features not found" },
- { 0x1106, "Device: transfer Error" },
- { 0x1107, "Device: bad user buffer" },
- { 0x1108, "Device: out of bounds" },
- { 0x1109, "Device Saturated" },
- {0x2000, "EPD device error"},
- };
- public static Dictionary<int, string> StateMap = new Dictionary<int, string>()
- {
- {0, "OK"},
- {1, "SYNTAX ERROR: The number of zero limiters in the header is not correct."},
- {2, "SYNTAX ERROR: The number of zero limiters in the body is not correct."},
- {3, "SYNTAX ERROR: The numbers of items in the body do not match the header."},
- {4, "SYNTAX ERROR: Correct value is required."},
- {5, "SYNTAX ERROR: Recognizable text character is required"},
- {6, "MESSAGE ERROR: The numbers of items in the body do not conform to specifications."},
- {7, "HEADER ERROR: Numerical value is beyond the defined range."},
- {8, "HEADER ERROR: The text is not of defined size."},
- {9, "BODY ERROR: Numerical value is beyond the deined range."},
- {10, "BODY ERROR: The tetx is not of defined size."},
- {11, "Sensor ID does not match the current sensor setting."},
- {12, "WatchDog Code: The remote control system is not ready."},
- {13, "WatchDog Code: The sensor subsystem is not ready"},
- {14, "WatchDog Code: The cluster control subsystem is not ready."},
- {15, "WatchDog Code: The available hard disk capacity has reached its upper limit."},
- {16, "WatchDog Code: Mismatch between step names occurred."},
- {17, "Step name is missing."},
- {18, "Required action is beyond the defined range."},
- {19, "Warning is raised in the sensor subsystem."},
- };
- }
- public enum CytAsciiEvent
- {
- Event_Message = 0x01,
- Event_SystemError = 0x02,
- Event_StepStart = 0x03,
- Event_StepDelay = 0x04,
- Event_StepNormalize = 0x05,
- Event_StepSatisfied = 0x06,
- Event_StepTrigger = 0x07,
- Event_StepStop = 0x08,
- Event_TrendData = 0x10,
- }
- public enum CytAsciiCommand
- {
- Reset = 0x00,
- RecipeStart = 0x01,
- RecipeStop = 0x02,
- Complete = 0x03,
- Start = 0x04,
- Stop = 0x05,
- SetWaferInfo = 0x06,
- QueryCfgList = 0x07,
- QueryState = 0x08,
- QueryVer = 0x09,
- Event = 0x0A,
- Connect = 0x10,
- Disconnect = 0x11,
- HeartBeat = 0x20,
- QueryData = 0x30,
- QueryRunStatus = 0x31,
- SetRunStatus = 0x32,
- QueryOperateMode = 0x33,
- SetOperateMode = 0x34,
- }
- public class CytAsciiData
- {
- public int MessageID { get; set; }
- public int CommandID { get; set; }
- public string SenderID { get; set; }
- public string ReceiveID { get; set; }
- public List<string> Params { get; set; }
- public CytAsciiData(int messageID, int commandID, string senderID, string receiveID)
- {
- MessageID = messageID;
- CommandID = commandID;
- SenderID = senderID;
- ReceiveID = receiveID;
- Params = new List<string>();
- }
- private List<string> ToList()
- {
- var lst = new List<string> {MessageID.ToString(), CommandID.ToString(), SenderID, ReceiveID, Params.Count.ToString() };
- lst.AddRange(Params);
- return lst;
- }
- public byte[] ToBytes()
- {
- var lst = ToList();
- var length = 2;
- foreach (var item in lst)
- length += item.Length + 1;
- var pos = 0;
- var bytes = new byte[length];
- foreach (var item in lst)
- {
- Buffer.BlockCopy(Encoding.UTF8.GetBytes(item), 0, bytes, pos, item.Length);
- pos += item.Length + 1;
- }
- bytes[pos] = 0x0D;
- bytes[pos + 1] = 0x0A;
- return bytes;
- }
- public static List<string> ToList(byte[] bytes, int index, ref int len)
- {
- var lst = new List<string>();
- var startIndex = index;
- for (int i = index; i < index + len - 1; i++)
- {
- if (bytes[i] == 0)
- {
- lst.Add(Encoding.UTF8.GetString(bytes, startIndex, i - startIndex));
- startIndex = i + 1;
- }
- else if (bytes[i] == 0x0D && bytes[i + 1] == 0x0A)
- {
- len = i - index + 2;
- return lst;
- }
- }
- len = -1;
- return lst;
- }
- }
- public struct CytAsciiResponseHeader
- {
- public static readonly int Size = Marshal.SizeOf(typeof(ResponseHeader));
- [MarshalAs(UnmanagedType.U4, SizeConst = 4)]
- public int token;
- [MarshalAs(UnmanagedType.U1, SizeConst = 1)]
- public byte channel;
- [MarshalAs(UnmanagedType.U1, SizeConst = 1)]
- public byte command;
- [MarshalAs(UnmanagedType.U4, SizeConst = 4)]
- public int errorcode;
- [MarshalAs(UnmanagedType.U4, SizeConst = 4)]
- public int length;
- }
- }
|