Class: Ocpp::Rails::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/ocpp/rails.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/ocpp/rails.rb', line 42

def initialize
  @ocpp_version = "1.6"
  # Only 1.6 is implemented; expand when 2.x support lands.
  @supported_versions = [ "1.6" ]
  @heartbeat_interval = 300
  @connection_timeout = 30
  @state_change_hooks = []
  @authorization_hooks = []
  @state_change_retention_days = 30
  @state_change_cleanup_enabled = true
  @authorization_retention_days = 30
  @authorization_cleanup_enabled = true
  # Max plausible energy register increase between samples, in Wh;
  # readings jumping further are flagged. nil disables the check.
  @implausible_energy_jump_wh = 1_000_000
  # :basic (OCPP-J Security Profile 1, HTTP Basic Auth) or :none.
  # :none accepts any client that knows a station identifier - only
  # for closed networks or during migration.
  @authentication_mode = :basic
  # Per-station ingress limits (fixed 60s windows, per process);
  # nil disables the respective check.
  @max_messages_per_minute = 300
  @max_connection_attempts_per_minute = 12
end

Instance Attribute Details

#authentication_modeObject

Returns the value of attribute authentication_mode.



36
37
38
# File 'lib/ocpp/rails.rb', line 36

def authentication_mode
  @authentication_mode
end

#authorization_cleanup_enabledObject

Returns the value of attribute authorization_cleanup_enabled.



36
37
38
# File 'lib/ocpp/rails.rb', line 36

def authorization_cleanup_enabled
  @authorization_cleanup_enabled
end

#authorization_hooksObject

Returns the value of attribute authorization_hooks.



36
37
38
# File 'lib/ocpp/rails.rb', line 36

def authorization_hooks
  @authorization_hooks
end

#authorization_retention_daysObject

Returns the value of attribute authorization_retention_days.



36
37
38
# File 'lib/ocpp/rails.rb', line 36

def authorization_retention_days
  @authorization_retention_days
end

#connection_timeoutObject

Returns the value of attribute connection_timeout.



36
37
38
# File 'lib/ocpp/rails.rb', line 36

def connection_timeout
  @connection_timeout
end

#heartbeat_intervalObject

Returns the value of attribute heartbeat_interval.



36
37
38
# File 'lib/ocpp/rails.rb', line 36

def heartbeat_interval
  @heartbeat_interval
end

#implausible_energy_jump_whObject

Returns the value of attribute implausible_energy_jump_wh.



36
37
38
# File 'lib/ocpp/rails.rb', line 36

def implausible_energy_jump_wh
  @implausible_energy_jump_wh
end

#max_connection_attempts_per_minuteObject

Returns the value of attribute max_connection_attempts_per_minute.



36
37
38
# File 'lib/ocpp/rails.rb', line 36

def max_connection_attempts_per_minute
  @max_connection_attempts_per_minute
end

#max_messages_per_minuteObject

Returns the value of attribute max_messages_per_minute.



36
37
38
# File 'lib/ocpp/rails.rb', line 36

def max_messages_per_minute
  @max_messages_per_minute
end

#ocpp_versionObject

Returns the value of attribute ocpp_version.



36
37
38
# File 'lib/ocpp/rails.rb', line 36

def ocpp_version
  @ocpp_version
end

#state_change_cleanup_enabledObject

Returns the value of attribute state_change_cleanup_enabled.



36
37
38
# File 'lib/ocpp/rails.rb', line 36

def state_change_cleanup_enabled
  @state_change_cleanup_enabled
end

#state_change_hooksObject

Returns the value of attribute state_change_hooks.



36
37
38
# File 'lib/ocpp/rails.rb', line 36

def state_change_hooks
  @state_change_hooks
end

#state_change_retention_daysObject

Returns the value of attribute state_change_retention_days.



36
37
38
# File 'lib/ocpp/rails.rb', line 36

def state_change_retention_days
  @state_change_retention_days
end

#supported_versionsObject

Returns the value of attribute supported_versions.



36
37
38
# File 'lib/ocpp/rails.rb', line 36

def supported_versions
  @supported_versions
end

Instance Method Details

#register_authorization_hook(hook) ⇒ Object



74
75
76
77
78
79
# File 'lib/ocpp/rails.rb', line 74

def register_authorization_hook(hook)
  unless hook.respond_to?(:call)
    raise ArgumentError, "Hook must respond to :call method"
  end
  @authorization_hooks << hook
end

#register_state_change_hook(hook) ⇒ Object



67
68
69
70
71
72
# File 'lib/ocpp/rails.rb', line 67

def register_state_change_hook(hook)
  unless hook.respond_to?(:call)
    raise ArgumentError, "Hook must respond to :call method"
  end
  @state_change_hooks << hook
end