Handler.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using Aitex.Core.RT.Log;
  7. using Aitex.Sorter.Common;
  8. using Aitex.Core.RT.SCCore;
  9. using MECF.Framework.Common.Equipment;
  10. namespace Aitex.Sorter.RT.Device.Robot
  11. {
  12. public interface ITransferMsg
  13. {
  14. bool background { get; }
  15. bool evt { get; }
  16. string package(params object[] args);
  17. /// </summary>
  18. /// return value, completed
  19. /// <param name="type"></param>
  20. /// <param name="cmd"></param>
  21. /// <returns></returns>
  22. bool unpackage(string type, string[] cmd);
  23. }
  24. public class TokenGenerator
  25. {
  26. private int _last = 0;
  27. List<int> _pool = new List<int>();
  28. SCConfigItem scToken = null;
  29. public TokenGenerator(string scName)
  30. {
  31. scToken = SC.GetConfigItem(scName);
  32. _last = scToken.IntValue;
  33. Random r = new Random();
  34. _last = r.Next() % 20;
  35. }
  36. public int create()
  37. {
  38. int first = _last;
  39. int token = first;
  40. do
  41. {
  42. token = (token + 1) % 100;
  43. if (_pool.Contains(token))
  44. continue;
  45. _pool.Add(token);
  46. _last = token;
  47. scToken.IntValue = _last;
  48. return _last;
  49. } while (token != first);
  50. throw (new ExcuteFailedException("Get tocken failed,pool is full"));
  51. }
  52. public void release(int token)
  53. {
  54. _pool.Remove(token);
  55. }
  56. public void release()
  57. {
  58. _last = 0;
  59. _pool.Clear();
  60. }
  61. }
  62. public interface IHandlerFactory
  63. {
  64. IHandler Init();
  65. IHandler Home();
  66. IHandler Event();
  67. IHandler Grip(Hand hand);
  68. IHandler Release(Hand hand);
  69. IHandler QueryState();
  70. IHandler QueryPosition();
  71. IHandler Clear();
  72. IHandler Stop(bool isEmergency);
  73. IHandler Resume();
  74. IHandler SetSpeed(int speed);
  75. IHandler Pick(ModuleName chamber, int slot, Hand hand);
  76. IHandler Place(ModuleName chamber, int slot, Hand hand);
  77. IHandler Exchange(ModuleName chamber, int slot, Hand hand);
  78. IHandler Goto(ModuleName chamber, int slot, Motion next, Hand hand, int x,int y, int z);
  79. IHandler MoveTo(ModuleName chamber, int slot,Hand hand, bool isPick, int x,int y, int z);
  80. IHandler WaferMapping(ModuleName loadport);
  81. IHandler QueryWaferMap(ModuleName loadport);
  82. IHandler PickEx(ModuleName chamber, int slot, Hand hand, int x, int y, int z);
  83. IHandler PlaceEx(ModuleName chamber, int slot, Hand hand, int x, int y, int z);
  84. IHandler ExchangeEx(ModuleName chamber, int slot, Hand hand, int x, int y, int z);
  85. IHandler PlaceExtend(ModuleName chamber, int slot, Hand hand);
  86. IHandler PlaceRetract(ModuleName chamber, int slot, Hand hand);
  87. IHandler PickExtend(ModuleName chamber, int slot, Hand hand);
  88. IHandler PickRetract(ModuleName chamber, int slot, Hand hand);
  89. }
  90. public interface IAlignerHandlerFactory
  91. {
  92. IHandler Init();
  93. IHandler Home();
  94. IHandler Event();
  95. IHandler Grip(Hand hand);
  96. IHandler Release(Hand hand);
  97. IHandler LiftUp( );
  98. IHandler LiftDown( );
  99. IHandler QueryState();
  100. IHandler Clear();
  101. IHandler Stop();
  102. IHandler Align(double anlge);
  103. }
  104. }