IACommService_t.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace IACommService4CSharp
  7. {
  8. public class IACommService_t
  9. {
  10. private static IIACommService4CSharp m_commService = null;
  11. private static GeneralConfig_t m_config = null;
  12. private static bool m_isInitialised = false;
  13. public static uint SetLogConfig(LogConfig_t logConfig)
  14. {
  15. if (m_isInitialised)
  16. return ErrorCode.InvalidState;
  17. if (null == logConfig)
  18. return ErrorCode.InvalidArgument;
  19. var logConfigItems = logConfig.GetConfig();
  20. var config = LogConfig();
  21. foreach (var configItem in logConfigItems)
  22. {
  23. config.SetParameter(configItem.Key, configItem.Value);
  24. }
  25. return ErrorCode.Good;
  26. }
  27. public static uint Initialise()
  28. {
  29. if (m_isInitialised)
  30. return ErrorCode.InvalidState;
  31. var commService = Instance();
  32. if (null == commService)
  33. return ErrorCode.InternalError;
  34. var status = commService.Initialise(LogConfig().Internal);
  35. if (ErrorCode.Good == status)
  36. m_isInitialised = true;
  37. return status;
  38. }
  39. //Internal use
  40. public static IIACommService4CSharp Instance()
  41. {
  42. if (null == m_commService)
  43. m_commService = IACommServiceFactory4CSharp.Create();
  44. return m_commService;
  45. }
  46. public static bool IsInitialised
  47. {
  48. get
  49. {
  50. return m_isInitialised;
  51. }
  52. }
  53. private static GeneralConfig_t LogConfig()
  54. {
  55. if (null == m_config)
  56. m_config = new GeneralConfig_t();
  57. return m_config;
  58. }
  59. }
  60. }