ICommunication.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts
  3. {
  4. public class ErrorEventArgs : EventArgs
  5. {
  6. public readonly string Reason;
  7. public readonly string Code;
  8. public ErrorEventArgs(string reason, string code = "")
  9. {
  10. Reason = reason;
  11. Code = code;
  12. }
  13. }
  14. public class DataEventArgs : EventArgs
  15. {
  16. public readonly string Data;
  17. public DataEventArgs(string data)
  18. {
  19. Data = data;
  20. }
  21. }
  22. public interface ICommunication
  23. {
  24. bool Write(string msg);
  25. }
  26. public interface IHandler
  27. {
  28. int ID { get; set; }
  29. int Unit { get; set; }
  30. bool IsBackground { get; }
  31. bool Execute<T>(ref T port) where T : ICommunication;
  32. /// <summary>
  33. /// return value : handle
  34. /// </summary>
  35. /// <typeparam name="T"></typeparam>
  36. /// <param name="port"></param>
  37. /// <param name="msg"></param>
  38. /// <param name="completed"></param>
  39. /// <returns></returns>
  40. bool OnMessage<T>(ref T port, string msg, out bool completed) where T : ICommunication;
  41. }
  42. public class InvalidPackageException : ApplicationException
  43. {
  44. public InvalidPackageException(string msg) : base(msg)
  45. {
  46. }
  47. public override string Message
  48. {
  49. get
  50. {
  51. return base.Message;
  52. }
  53. }
  54. }
  55. public class ExcuteFailedException : ApplicationException
  56. {
  57. public ExcuteFailedException(string msg)
  58. : base(msg)
  59. {
  60. }
  61. public override string Message
  62. {
  63. get
  64. {
  65. return base.Message;
  66. }
  67. }
  68. }
  69. }