COffLineClassifyLogic.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using OTSCLRINTERFACE;
  2. using OTSModelSharp.ServiceCenter;
  3. using System.Collections.Generic;
  4. using static OTSDataType.otsdataconst;
  5. namespace OTSCommon
  6. {
  7. public static class COffLineClassifyLogic
  8. {
  9. //we have a complicate online classify logic(considering the xray counts and using the spectrum compare and may do not quantify)
  10. //when we do classification offline we cann't use that mechanism so we use a surrogate mechanism which is simpler and general .
  11. private static CClassifyEngine m_classifyEngine = new CClassifyEngine();
  12. public static bool ClassifyIncA(List<COTSParticleClr> parts, string stdname, int steelTech, int type)
  13. {
  14. bool r = true;
  15. if (type == -1)
  16. {
  17. if (stdname != "NoSTDDB" && stdname != "NoSTDDB.db")
  18. {
  19. foreach (var part in parts)
  20. {
  21. part.SetType((int)OTS_PARTICLE_TYPE.NOT_IDENTIFIED);
  22. IClassifyEngine engine = m_classifyEngine.GetExpressionClassifyEngine(stdname);
  23. r = engine.ClassifyByExpression(part);
  24. if (part.GetType() == (int)OTS_PARTICLE_TYPE.NOT_IDENTIFIED)
  25. {
  26. engine = m_classifyEngine.GetIncClassifyEngine();
  27. r = engine.ClassifyIncA(part, steelTech);
  28. }
  29. }
  30. }
  31. else
  32. {
  33. foreach (var part in parts)
  34. {
  35. IClassifyEngine engine;
  36. engine = m_classifyEngine.GetIncClassifyEngine();
  37. r = engine.ClassifyIncA(part, steelTech);
  38. }
  39. }
  40. }
  41. else if (type == 0)
  42. {
  43. foreach (var part in parts)
  44. {
  45. IClassifyEngine engine;
  46. engine = m_classifyEngine.GetIncClassifyEngine();
  47. r = engine.ClassifyIncA(part, steelTech);
  48. }
  49. }
  50. else if (type == 1 || type == 2 || type == 3 )
  51. {
  52. if (stdname != "NoSTDDB" && stdname != "NoSTDDB.db")
  53. {
  54. foreach (var part in parts)
  55. {
  56. part.SetType((int)OTS_PARTICLE_TYPE.NOT_IDENTIFIED);
  57. IClassifyEngine engine = m_classifyEngine.GetExpressionClassifyEngine(stdname);
  58. r = engine.ClassifyByExpression(part);
  59. if (part.GetType() == (int)OTS_PARTICLE_TYPE.NOT_IDENTIFIED)
  60. {
  61. engine = m_classifyEngine.GetIncClassifyEngine();
  62. r = engine.ClassifyIncA(part, steelTech);
  63. }
  64. }
  65. }
  66. else
  67. {
  68. foreach (var part in parts)
  69. {
  70. IClassifyEngine engine;
  71. engine = m_classifyEngine.GetIncClassifyEngine();
  72. r = engine.ClassifyIncA(part, steelTech);
  73. }
  74. }
  75. }
  76. return r;
  77. }
  78. public static bool ClassifyCleannessA(List<COTSParticleClr> parts, string stdname)
  79. {
  80. bool r = true;
  81. IClassifyEngine engine;
  82. engine = m_classifyEngine.GetExpressionClassifyEngine(stdname);
  83. if (stdname != "NoSTDDB")
  84. {
  85. foreach (var p in parts)
  86. {
  87. r = engine.ClassifyByExpression(p);
  88. }
  89. }
  90. return true;
  91. }
  92. }
  93. }