RecipeService.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ServiceModel;
  4. using Aitex.Core.RT.Event;
  5. using Aitex.Core.RT.Key;
  6. using Aitex.Core.RT.OperationCenter;
  7. using Aitex.Core.RT.RecipeCenter;
  8. using MECF.Framework.Common.Equipment;
  9. using Aitex.Core.RT.Log;
  10. namespace MECF.Framework.Common.RecipeCenter
  11. {
  12. public class RecipeService : IRecipeService
  13. {
  14. /// <summary>
  15. /// Load a recipe from server to client for editing.
  16. /// </summary>
  17. /// <param name="chamId"></param>
  18. /// <param name="recipeName"></param>
  19. /// <returns></returns>
  20. public string LoadRecipe(ModuleName chamId, string recipeName)
  21. {
  22. LOG.Write(eEvent.EV_SEQUENCE, ModuleName.System, string.Format("Read {0} recipe {1}", chamId, recipeName));
  23. return RecipeFileManager.Instance.LoadRecipe(chamId.ToString(), recipeName, false);
  24. }
  25. /// <summary>
  26. /// Delete a recipe by recipe name
  27. /// </summary>
  28. /// <param name="chamId"></param>
  29. /// <param name="recipeName"></param>
  30. /// <returns></returns>
  31. public bool DeleteRecipe(ModuleName chamId, string recipeName)
  32. {
  33. if (CheckSoftwareExpired())
  34. return false;
  35. //if (!ChamberOperationService.IsSuperEnter()) return false;
  36. LOG.Write(eEvent.EV_SEQUENCE, ModuleName.System, string.Format("Delete {0} recipe {1}", chamId, recipeName));
  37. return RecipeFileManager.Instance.DeleteRecipe(chamId.ToString(), recipeName);
  38. }
  39. /// <summary>
  40. /// Get recipe list in xml format
  41. /// </summary>
  42. /// <param name="chamId"></param>
  43. /// <param name="includingUsedRecipe"></param>
  44. /// <returns></returns>
  45. public string GetXmlRecipeList(ModuleName chamId, bool includingUsedRecipe)
  46. {
  47. return RecipeFileManager.Instance.GetXmlRecipeList(chamId.ToString(), includingUsedRecipe);
  48. }
  49. /// <summary>
  50. /// Get recipe data by recipe name
  51. /// </summary>
  52. /// <param name="chamId"></param>
  53. /// <param name="includingUsedRecipe"></param>
  54. /// <returns></returns>
  55. public IEnumerable<string> GetRecipes(ModuleName chamId, bool includingUsedRecipe)
  56. {
  57. return RecipeFileManager.Instance.GetRecipes(chamId.ToString(), includingUsedRecipe);
  58. }
  59. /// <summary>
  60. /// Rename recipe
  61. /// </summary>
  62. /// <param name="chamId"></param>
  63. /// <param name="oldName"></param>
  64. /// <param name="newName"></param>
  65. /// <returns></returns>
  66. public bool RenameRecipe(ModuleName chamId, string oldName, string newName)
  67. {
  68. if (CheckSoftwareExpired())
  69. return false;
  70. LOG.Write(eEvent.EV_SEQUENCE, ModuleName.System, string.Format("Rename {0} recipe {1}为{2}", chamId, oldName, newName));
  71. //if (!ChamberOperationService.IsSuperEnter()) return false;
  72. return RecipeFileManager.Instance.RenameRecipe(chamId.ToString(), oldName, newName);
  73. }
  74. /// <summary>
  75. /// delete a recipe folder
  76. /// </summary>
  77. /// <param name="chamId"></param>
  78. /// <param name="folderName"></param>
  79. /// <returns></returns>
  80. public bool DeleteFolder(ModuleName chamId, string folderName)
  81. {
  82. if (CheckSoftwareExpired())
  83. return false;
  84. //if (!ChamberOperationService.IsSuperEnter()) return false;
  85. LOG.Write(eEvent.EV_SEQUENCE, ModuleName.System, string.Format("Delete {0} recipe folder {1}", chamId, folderName));
  86. return RecipeFileManager.Instance.DeleteFolder(chamId.ToString(), folderName);
  87. }
  88. /// <summary>
  89. /// save recipe content
  90. /// </summary>
  91. /// <param name="chamId"></param>
  92. /// <param name="recipeName"></param>
  93. /// <param name="recipeContent"></param>
  94. /// <returns></returns>
  95. public bool SaveRecipe(ModuleName chamId, string recipeName, string recipeContent)
  96. {
  97. if (CheckSoftwareExpired())
  98. return false;
  99. LOG.Write(eEvent.EV_SEQUENCE, ModuleName.System, string.Format("Modify and save {0} recipe {1}", chamId, recipeName));
  100. return RecipeFileManager.Instance.SaveRecipe(chamId.ToString(), recipeName, recipeContent, false, false);
  101. }
  102. /// <summary>
  103. /// move recipe content
  104. /// </summary>
  105. /// <param name="chamId"></param>
  106. /// <param name="recipeName"></param>
  107. /// <returns></returns>
  108. public bool MoveRecipeFile(ModuleName chamId, string recipeName, string tragetFolderName)
  109. {
  110. if (CheckSoftwareExpired())
  111. return false;
  112. LOG.Write(eEvent.EV_SEQUENCE, ModuleName.System, string.Format("Move {0} recipe {1}", chamId, recipeName));
  113. return RecipeFileManager.Instance.MoveRecipeFile(chamId.ToString(), recipeName, tragetFolderName, false, false);
  114. }
  115. /// <summary>
  116. /// save recipe content
  117. /// </summary>
  118. /// <param name="chamId"></param>
  119. /// <param name="recipeName"></param>
  120. /// <param name="recipeContent"></param>
  121. /// <returns></returns>
  122. public bool SaveAsRecipe(ModuleName chamId, string recipeName, string recipeContent)
  123. {
  124. if (CheckSoftwareExpired())
  125. return false;
  126. LOG.Write(eEvent.EV_SEQUENCE, ModuleName.System, string.Format("Modify and save as {0} recipe {1}", chamId, recipeName));
  127. return RecipeFileManager.Instance.SaveAsRecipe(chamId.ToString(), recipeName, recipeContent);
  128. }
  129. /// <summary>
  130. /// create a new recipe folder
  131. /// </summary>
  132. /// <param name="chamId"></param>
  133. /// <param name="folderName"></param>
  134. /// <returns></returns>
  135. public bool CreateFolder(ModuleName chamId, string folderName)
  136. {
  137. if (CheckSoftwareExpired())
  138. return false;
  139. LOG.Write(eEvent.EV_SEQUENCE, ModuleName.System, string.Format("Create {0} recipe foler {1}", chamId, folderName));
  140. return RecipeFileManager.Instance.CreateFolder(chamId.ToString(), folderName);
  141. }
  142. /// <summary>
  143. /// Rename recipe folder name
  144. /// </summary>
  145. /// <param name="chamId"></param>
  146. /// <param name="oldName"></param>
  147. /// <param name="newName"></param>
  148. /// <returns></returns>
  149. public bool RenameFolder(ModuleName chamId, string oldName, string newName)
  150. {
  151. if (CheckSoftwareExpired())
  152. return false;
  153. LOG.Write(eEvent.EV_SEQUENCE, ModuleName.System, string.Format("Rename {0} recipe folder {1} to {2}", chamId, oldName, newName));
  154. return RecipeFileManager.Instance.RenameFolder(chamId.ToString(), oldName, newName);
  155. }
  156. private bool CheckSoftwareExpired()
  157. {
  158. bool isExpired = KeyManager.Instance.IsExpired;
  159. if (isExpired)
  160. LOG.Write(eEvent.WARN_SEQUENCE,ModuleName.System, "Software is expired. Can not do the operation");
  161. return isExpired;
  162. }
  163. /// <summary>
  164. /// get reactor's recipe format define file
  165. /// </summary>
  166. /// <param name="chamId"></param>
  167. /// <returns></returns>
  168. public string GetRecipeFormatXml(ModuleName chamId)
  169. {
  170. return RecipeFileManager.Instance.GetRecipeFormatXml(chamId.ToString());
  171. }
  172. /// <summary>
  173. /// get reactor's template recipe file
  174. /// </summary>
  175. /// <param name="chamId"></param>
  176. /// <returns></returns>
  177. public string GetRecipeTemplate(ModuleName chamId)
  178. {
  179. return RecipeFileManager.Instance.GetRecipeTemplate(chamId.ToString());
  180. }
  181. /// <summary>
  182. /// 获取当前反应腔正在运行的Recipe信息
  183. /// </summary>
  184. /// <param name="chamId"></param>
  185. /// <returns>recipeName + recipeContent</returns>
  186. public Tuple<string, string> LoadRunTimeRecipeInfo(ModuleName chamId)
  187. {
  188. return null;
  189. //var pm = PmManager.GetReactor(chamId);
  190. //if (pm != null) return pm.LoadRunTimeRecipeInfo();
  191. //return Singleton<PMEntity>.Instance.GetRecipeInfo();
  192. }
  193. public string GetRecipeByBarcode(ModuleName chamId, string barcode)
  194. {
  195. return "";
  196. //return RecipeFileManager.Instance.GetRecipeByBarcode(chamId.ToString(), barcode);
  197. }
  198. public string GetXmlSequenceList(ModuleName chamId )
  199. {
  200. return RecipeFileManager.Instance.GetXmlSequenceList(chamId.ToString() );
  201. }
  202. public string GetSequence(string sequenceName)
  203. {
  204. return RecipeFileManager.Instance.GetSequence(sequenceName, true);
  205. }
  206. public List<string> GetSequenceNameList()
  207. {
  208. return RecipeFileManager.Instance.GetSequenceNameList();
  209. }
  210. public bool DeleteSequence(string sequenceName)
  211. {
  212. return RecipeFileManager.Instance.DeleteSequence(sequenceName);
  213. }
  214. public bool SaveSequence(string sequenceName, string sequenceContent)
  215. {
  216. return RecipeFileManager.Instance.SaveSequence(sequenceName, sequenceContent, false);
  217. }
  218. public bool SaveAsSequence(string sequenceName, string sequenceContent)
  219. {
  220. return RecipeFileManager.Instance.SaveAsSequence(sequenceName, sequenceContent);
  221. }
  222. public bool RenameSequence(string oldName, string newName)
  223. {
  224. return RecipeFileManager.Instance.RenameSequence(oldName, newName);
  225. }
  226. public string GetSequenceFormatXml()
  227. {
  228. return RecipeFileManager.Instance.GetSequenceFormatXml();
  229. }
  230. public bool RenameSequenceFolder(string oldName, string newName)
  231. {
  232. return RecipeFileManager.Instance.RenameSequenceFolder(oldName, newName);
  233. }
  234. public bool CreateSequenceFolder(string folderName)
  235. {
  236. return RecipeFileManager.Instance.CreateSequenceFolder(folderName);
  237. }
  238. public bool DeleteSequenceFolder(string folderName)
  239. {
  240. return RecipeFileManager.Instance.DeleteSequenceFolder(folderName);
  241. }
  242. #region extended recipe interface
  243. public string LoadRecipeByPath(string pathName, string recipeName)
  244. {
  245. return RecipeFileManager.Instance.LoadRecipe(pathName, recipeName, false);
  246. }
  247. public bool DeleteRecipeByPath(string pathName, string recipeName)
  248. {
  249. return RecipeFileManager.Instance.DeleteRecipe(pathName, recipeName);
  250. }
  251. public string GetXmlRecipeListByPath(string pathName, bool includingUsedRecipe)
  252. {
  253. return RecipeFileManager.Instance.GetXmlRecipeList(pathName, includingUsedRecipe);
  254. }
  255. public IEnumerable<string> GetRecipesByPath(string pathName, bool includingUsedRecipe)
  256. {
  257. return RecipeFileManager.Instance.GetRecipes(pathName, includingUsedRecipe);
  258. }
  259. public bool RenameRecipeByPath(string pathName, string oldName, string newName)
  260. {
  261. return RecipeFileManager.Instance.RenameRecipe(pathName, oldName, newName);
  262. }
  263. public bool DeleteFolderByPath(string pathName, string folderName)
  264. {
  265. return RecipeFileManager.Instance.DeleteFolder(pathName, folderName);
  266. }
  267. public bool SaveRecipeByPath(string pathName, string recipeName, string recipeContent)
  268. {
  269. return RecipeFileManager.Instance.SaveRecipe(pathName, recipeName, recipeContent, false, false);
  270. }
  271. public bool SaveAsRecipeByPath(string pathName, string recipeName, string recipeContent)
  272. {
  273. return RecipeFileManager.Instance.SaveAsRecipe(pathName, recipeName, recipeContent);
  274. }
  275. public bool CreateFolderByPath(string pathName, string folderName)
  276. {
  277. return RecipeFileManager.Instance.CreateFolder(pathName, folderName);
  278. }
  279. public bool RenameFolderByPath(string pathName, string oldName, string newName)
  280. {
  281. return RecipeFileManager.Instance.RenameFolder(pathName, oldName, newName);
  282. }
  283. public string GetRecipeFormatXmlByPath(string pathName)
  284. {
  285. return RecipeFileManager.Instance.GetRecipeFormatXml(pathName);
  286. }
  287. public string GetRecipeTemplateByPath(string pathName)
  288. {
  289. return RecipeFileManager.Instance.GetRecipeTemplate(pathName);
  290. }
  291. public Tuple<string, string> LoadRunTimeRecipeInfoByPath(string pathName)
  292. {
  293. return null;
  294. }
  295. public string GetRecipeByBarcodeByPath(string pathName, string barcode)
  296. {
  297. return "";
  298. }
  299. #endregion
  300. }
  301. }