Sic.Framework/MECF.Framework.Common/MECF/Framework/Common/RecipeCenter/DefaultRecipeFileContext.cs

110 lines
3.0 KiB
C#
Raw Normal View History

2023-04-13 11:51:03 +08:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using Aitex.Common.Util;
using Aitex.Core.RT.Event;
using Aitex.Core.RT.Log;
using Aitex.Core.RT.RecipeCenter;
using MECF.Framework.Common.Equipment;
2023-04-13 11:51:03 +08:00
namespace MECF.Framework.Common.RecipeCenter
{
public class DefaultRecipeFileContext : IRecipeFileContext
{
public string GetRecipeDefiniton(string chamberType)
{
try
{
string filename = PathManager.GetCfgDir() + "\\Recipe\\" + chamberType + "\\RecipeFormat.xml";
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(filename);
return xmlDocument.OuterXml;
}
catch (Exception ex)
{
LOG.Write(ex);
return "";
}
}
public IEnumerable<string> GetRecipes(string path, bool includingUsedRecipe)
{
try
{
List<string> list = new List<string>();
string path2 = PathManager.GetRecipeDir() + path + "\\";
if (!Directory.Exists(path2))
{
return list;
}
DirectoryInfo directoryInfo = new DirectoryInfo(path2);
FileInfo[] files = directoryInfo.GetFiles("*.rcp", SearchOption.AllDirectories);
FileInfo[] array = files;
foreach (FileInfo fileInfo in array)
{
string text = fileInfo.FullName.Substring(directoryInfo.FullName.Length);
text = text.Substring(0, text.LastIndexOf('.'));
if (includingUsedRecipe || (!includingUsedRecipe && !text.Contains("HistoryRecipe\\")))
{
list.Add(text);
}
}
return list;
}
catch (Exception ex)
{
LOG.Write(ex);
return new List<string>();
}
}
public void PostInfoEvent(string message)
{
EV.PostMessage(ModuleName.System.ToString(), EventEnum.GeneralInfo, message);
2023-04-13 11:51:03 +08:00
}
public void PostWarningEvent(string message)
{
EV.PostMessage(ModuleName.System.ToString(), EventEnum.DefaultWarning, message);
2023-04-13 11:51:03 +08:00
}
public void PostAlarmEvent(string message)
{
EV.PostMessage(ModuleName.System.ToString(), EventEnum.DefaultAlarm, message);
2023-04-13 11:51:03 +08:00
}
public void PostDialogEvent(string message)
{
EV.PostNotificationMessage(message);
}
public void PostInfoDialogMessage(string message)
{
EV.PostMessage(ModuleName.System.ToString(), EventEnum.GeneralInfo, message);
2023-04-13 11:51:03 +08:00
EV.PostPopDialogMessage(EventLevel.Information, "System Information", message);
}
public void PostWarningDialogMessage(string message)
{
EV.PostMessage(ModuleName.System.ToString(), EventEnum.GeneralInfo, message);
2023-04-13 11:51:03 +08:00
EV.PostPopDialogMessage(EventLevel.Warning, "System Warning", message);
}
public void PostAlarmDialogMessage(string message)
{
EV.PostMessage(ModuleName.System.ToString(), EventEnum.GeneralInfo, message);
2023-04-13 11:51:03 +08:00
EV.PostPopDialogMessage(EventLevel.Alarm, "System Alarm", message);
}
public string GetRecipeTemplate(string chamberId)
{
string recipeDefiniton = GetRecipeDefiniton(chamberId);
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(recipeDefiniton);
XmlNode xmlNode = xmlDocument.SelectSingleNode("/Aitex/TableRecipeData");
return xmlNode.OuterXml;
}
}
}