RtRecipeFileContext.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using Aitex.Common.Util;
  5. using Aitex.Core.RT.Event;
  6. using Aitex.Core.RT.Log;
  7. using Aitex.Core.RT.RecipeCenter;
  8. namespace Aitex.Sorter.RT.Module.Recipe
  9. {
  10. public class RtRecipeFileContext : IRecipeFileContext
  11. {
  12. public string GetRecipeDefiniton(string chamberId)
  13. {
  14. return string.Empty;
  15. }
  16. public IEnumerable<string> GetRecipes(string chamberId, bool includingUsedRecipe)
  17. {
  18. try
  19. {
  20. string recipePath = PathManager.GetRecipeDir() + chamberId + "\\";
  21. var di = new DirectoryInfo(recipePath);
  22. if (!Directory.Exists(di.FullName)) return new List<string>();
  23. var fis = di.GetFiles("*.rcp", SearchOption.AllDirectories);
  24. var recipes = new List<string>();
  25. foreach (var fi in fis)
  26. {
  27. string str = fi.FullName.Substring(recipePath.Length);
  28. str = str.Substring(0, str.LastIndexOf('.'));
  29. if (includingUsedRecipe || !str.Contains("HistoryRecipe\\"))
  30. {
  31. recipes.Add(str);
  32. }
  33. }
  34. return recipes;
  35. }
  36. catch (Exception ex)
  37. {
  38. LOG.Write(ex);
  39. return new List<string>();
  40. }
  41. }
  42. public void PostEvent(string message)
  43. {
  44. EV.PostNotificationMessage(message);
  45. }
  46. public string GetRecipeTemplate(string chamberId)
  47. {
  48. return String.Empty;
  49. }
  50. public void PostInfoEvent(string message)
  51. {
  52. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  53. }
  54. public void PostWarningEvent(string message)
  55. {
  56. EV.PostMessage("System", EventEnum.DefaultWarning, message);
  57. }
  58. public void PostAlarmEvent(string message)
  59. {
  60. EV.PostMessage("System", EventEnum.DefaultAlarm, message);
  61. }
  62. public void PostDialogEvent(string message)
  63. {
  64. EV.PostNotificationMessage(message);
  65. }
  66. public void PostInfoDialogMessage(string message)
  67. {
  68. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  69. EV.PostPopDialogMessage(EventLevel.Information, "System Information", message);
  70. }
  71. public void PostWarningDialogMessage(string message)
  72. {
  73. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  74. EV.PostPopDialogMessage(EventLevel.Warning, "System Warning", message);
  75. }
  76. public void PostAlarmDialogMessage(string message)
  77. {
  78. EV.PostMessage("System", EventEnum.GeneralInfo, message);
  79. EV.PostPopDialogMessage(EventLevel.Alarm, "System Alarm", message);
  80. }
  81. }
  82. }