IntegratedSubsystem.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /****************************************************************************
  2. * Copyright 2019 Nreal Techonology Limited. All rights reserved.
  3. *
  4. * This file is part of NRSDK.
  5. *
  6. * https://www.nreal.ai/
  7. *
  8. *****************************************************************************/
  9. namespace NRKernal
  10. {
  11. public class IntegratedSubsystem : ISubsystem
  12. {
  13. protected ISubsystemDescriptor m_Descripe;
  14. public IntegratedSubsystem(ISubsystemDescriptor descripe)
  15. {
  16. m_Descripe = descripe;
  17. }
  18. /// <summary>
  19. /// Whether or not the subsystem is running.
  20. /// </summary>
  21. public virtual bool running { get; protected set; } = false;
  22. /// <summary>
  23. /// Starts an instance of a subsystem.
  24. /// </summary>
  25. public virtual void Start()
  26. {
  27. running = true;
  28. }
  29. /// <summary>
  30. /// Pause an instance of a subsystem.
  31. /// </summary>
  32. public virtual void Pause()
  33. {
  34. running = false;
  35. }
  36. /// <summary>
  37. /// Resume an instance of a subsystem.
  38. /// </summary>
  39. public virtual void Resume()
  40. {
  41. running = true;
  42. }
  43. /// <summary>
  44. /// Destroys this instance of a subsystem.
  45. /// </summary>
  46. public virtual void Stop()
  47. {
  48. running = false;
  49. }
  50. }
  51. public class IntegratedSubsystem<TSubsystemDescriptor> : IntegratedSubsystem where TSubsystemDescriptor : ISubsystemDescriptor
  52. {
  53. public IntegratedSubsystem(TSubsystemDescriptor descripe) : base(descripe) { }
  54. public virtual TSubsystemDescriptor SubsystemDescriptor => (TSubsystemDescriptor)m_Descripe;
  55. }
  56. }