PageRenderTime 67ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/Spinach/UserInterface/Error.cs

https://github.com/shranjan/pinac
C# | 101 lines | 66 code | 12 blank | 23 comment | 11 complexity | e951611c49a3eeaafbb7f1ca60954222 MD5 | raw file
  1. //////////////////////////////////////////////////////////////////////////////////
  2. // Error.cs - Error Module //
  3. // ver 1.0 //
  4. // //
  5. // Language: C# //
  6. // Platform: Windows Vista //
  7. // Application: SPINACH //
  8. // Author: Arunkumar K T (akyasara@syr.edu) //
  9. // Abhay Ketkar (asketkar@syr.edu) //
  10. // Prateek Jain (pjain02@syr.edu) //
  11. // Rutu Pandya (rkpandya@syr.edu) //
  12. //////////////////////////////////////////////////////////////////////////////////
  13. using System;
  14. using System.Collections.Generic;
  15. using Spinach;
  16. namespace Spinach
  17. {
  18. /// <summary>
  19. ///
  20. /// </summary>
  21. public delegate void ErrorNotification(string Msg);
  22. public class ErrorModule
  23. {
  24. public event ErrorNotification ConnError;
  25. public event ErrorNotification ProgConfError;
  26. public event ErrorNotification ProgWinError;
  27. private executor Ex;
  28. private PlotReceiver plot;
  29. private SwarmConnection SC;
  30. private SwarmMemory SM = null;
  31. private Dictionary<int, string> ErrorDict = new Dictionary<int, string>();
  32. //----< Create the Dictionary of Errors >----
  33. public ErrorModule()
  34. {
  35. // Swarm Error Messages
  36. ErrorDict.Add(10, "Connection Error: ");
  37. // FrontEnd Error Messages
  38. ErrorDict.Add(101, "Syntax Error: ");
  39. ErrorDict.Add(102, "Exception: ");
  40. // CoreTeam Error Messages
  41. ErrorDict.Add(112, "Semantic Error: ");
  42. ErrorDict.Add(113, "Exception: ");
  43. // PlotTeam Error Messages
  44. ErrorDict.Add(121, "Plotting Error: ");
  45. ErrorDict.Add(122, "Plotting Error: ");
  46. ErrorDict.Add(123, "Plotting Error: ");
  47. }
  48. //----< Sends Error Message to appropriate window >----
  49. public void ErrorMsg(int Code, string Msg)
  50. {
  51. string ErrMsg = ErrorDict[Code] + Msg;
  52. if (Code < 50 && ConnError != null)
  53. ConnError(ErrMsg);
  54. else if (Code < 100 && ProgConfError != null)
  55. ProgConfError(ErrMsg);
  56. else if (Code < 150 && ProgWinError != null)
  57. {
  58. SM.BroadcastError(ErrMsg);
  59. //if (Code == 101 || Code == 102 || Code == 201 || Code == 202 || Code==203)
  60. SM.clearMasterBackup(true);
  61. //ProgWinError(ErrMsg);
  62. }
  63. }
  64. public void SetExecutorObject(executor E)
  65. {
  66. Ex = E;
  67. Ex.errEvent +=new executor.err(ErrorMsg);
  68. }
  69. public void SetPlotObject(PlotReceiver p)
  70. {
  71. plot = p;
  72. plot.error +=new PlotReceiver.PlotError(ErrorMsg);
  73. }
  74. public void SetSwarmConnectionObject(SwarmConnection s)
  75. {
  76. SC = s;
  77. SC.ErrorChanged +=new SwarmConnection.ErrorEventHandler(ErrorMsg);
  78. }
  79. public void SetSwarmMemoryObject(SwarmMemory s)
  80. {
  81. SM = s;
  82. SM.ErrorResult+=new SwarmMemory.BrdErrorResult(ShowMsg);
  83. }
  84. public void ShowMsg(string ErrMsg)
  85. {
  86. ProgWinError(ErrMsg);
  87. }
  88. }
  89. }