Profile.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace EVCB_OCPP.Packet.Features
  7. {
  8. public enum Actions
  9. {
  10. //Core
  11. None,
  12. BootNotification,
  13. GetConfiguration,
  14. Heartbeat,
  15. StartTransaction,
  16. ChangeConfiguration,
  17. StatusNotification,
  18. Authorize,
  19. StopTransaction,
  20. MeterValues,
  21. RemoteStartTransaction,
  22. RemoteStopTransaction,
  23. ChangeAvailability,
  24. ClearCache,
  25. DataTransfer,
  26. Reset,
  27. UnlockConnector,
  28. //FirmwareManagement
  29. GetDiagnostics,
  30. UpdateFirmware,
  31. FirmwareStatusNotification,
  32. DiagnosticsStatusNotification,
  33. //LocalAuthListManagement
  34. SendLocalList,
  35. GetLocalListVersion,
  36. //Reservation
  37. CancelReservation,
  38. ReserveNow,
  39. //Remote Trigger
  40. TriggerMessage,
  41. //SmartCharging
  42. ClearChargingProfile,
  43. GetCompositeSchedule,
  44. SetChargingProfile,
  45. //Security
  46. CertificateSigned,
  47. DeleteCertificate,
  48. ExtendedTriggerMessage,
  49. GetInstalledCertificateIds,
  50. GetLog,
  51. InstallCertificate,
  52. LogStatusNotification,
  53. SecurityEventNotification,
  54. SignCertificate,
  55. SignedFirmwareStatusNotification,
  56. SignedUpdateFirmware
  57. }
  58. public class Profile
  59. {
  60. public string Name { protected set; get; }
  61. protected List<Feature> features = new List<Feature>();
  62. protected List<string> actions = new List<string>();
  63. public List<Feature> GetAllFeatures()
  64. {
  65. return features;
  66. }
  67. public string GetActionFromConfirmation(Type seekType)
  68. {
  69. var _feature = features.Where(x => x.GetConfirmationType() == seekType).FirstOrDefault();
  70. return _feature == null ? string.Empty : _feature.GetAction();
  71. }
  72. public string GetActionFromRequest(Type seekType)
  73. {
  74. var feature = GetFeaturebyType(seekType);
  75. return feature == null ? string.Empty : feature.GetAction();
  76. }
  77. public virtual Feature GetFeaturebyAction(string action)
  78. {
  79. return features.Where(x => x.GetAction() == action).FirstOrDefault(); ; ;
  80. }
  81. public virtual Feature GetFeaturebyType(Type seekType)
  82. {
  83. return features.Where(x => x.GetRequestType() == seekType).FirstOrDefault(); ;
  84. }
  85. public bool IsExisted(string action)
  86. {
  87. return actions.Contains(action);
  88. }
  89. public bool IsExisted(Actions action)
  90. {
  91. string _action = action.ToString();
  92. return actions.Contains(_action);
  93. }
  94. }
  95. }