|
1 | 1 | package api
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "errors" |
| 5 | + "time" |
| 6 | + |
4 | 7 | "github.com/enbility/eebus-go/api"
|
| 8 | + "github.com/enbility/spine-go/model" |
| 9 | +) |
| 10 | + |
| 11 | +type EVChargeStateType string |
| 12 | + |
| 13 | +const ( |
| 14 | + EVChargeStateTypeUnknown EVChargeStateType = "Unknown" |
| 15 | + EVChargeStateTypeUnplugged EVChargeStateType = "unplugged" |
| 16 | + EVChargeStateTypeError EVChargeStateType = "error" |
| 17 | + EVChargeStateTypePaused EVChargeStateType = "paused" |
| 18 | + EVChargeStateTypeActive EVChargeStateType = "active" |
| 19 | + EVChargeStateTypeFinished EVChargeStateType = "finished" |
| 20 | +) |
| 21 | + |
| 22 | +// Defines a phase specific limit |
| 23 | +type LoadLimitsPhase struct { |
| 24 | + Phase model.ElectricalConnectionPhaseNameType |
| 25 | + IsActive bool |
| 26 | + Value float64 |
| 27 | +} |
| 28 | + |
| 29 | +type EVChargeStrategyType string |
| 30 | + |
| 31 | +const ( |
| 32 | + EVChargeStrategyTypeUnknown EVChargeStrategyType = "unknown" |
| 33 | + EVChargeStrategyTypeNoDemand EVChargeStrategyType = "nodemand" |
| 34 | + EVChargeStrategyTypeDirectCharging EVChargeStrategyType = "directcharging" |
| 35 | + EVChargeStrategyTypeMinSoC EVChargeStrategyType = "minsoc" |
| 36 | + EVChargeStrategyTypeTimedCharging EVChargeStrategyType = "timedcharging" |
5 | 37 | )
|
6 | 38 |
|
| 39 | +// Contains details about the actual demands from the EV |
| 40 | +// |
| 41 | +// General: |
| 42 | +// - If duration and energy is 0, charge mode is EVChargeStrategyTypeNoDemand |
| 43 | +// - If duration is 0, charge mode is EVChargeStrategyTypeDirectCharging and the slots should cover at least 48h |
| 44 | +// - If both are != 0, charge mode is EVChargeStrategyTypeTimedCharging and the slots should cover at least the duration, but at max 168h (7d) |
| 45 | +type Demand struct { |
| 46 | + MinDemand float64 // minimum demand in Wh to reach the minSoC setting, 0 if not set |
| 47 | + OptDemand float64 // demand in Wh to reach the timer SoC setting |
| 48 | + MaxDemand float64 // the maximum possible demand until the battery is full |
| 49 | + DurationUntilStart float64 // the duration in s from now until charging will start, this could be in the future but usualy is now |
| 50 | + DurationUntilEnd float64 // the duration in s from now until minDemand or optDemand has to be reached, 0 if direct charge strategy is active |
| 51 | +} |
| 52 | + |
| 53 | +// Contains details about an EV generated charging plan |
| 54 | +type ChargePlan struct { |
| 55 | + Slots []ChargePlanSlotValue // Individual charging slot details |
| 56 | +} |
| 57 | + |
| 58 | +// Contains details about a charging plan slot |
| 59 | +type ChargePlanSlotValue struct { |
| 60 | + Start time.Time // The start time of the slot |
| 61 | + End time.Time // The duration of the slot |
| 62 | + Value float64 // planned power value |
| 63 | + MinValue float64 // minimum power value |
| 64 | + MaxValue float64 // maximum power value |
| 65 | +} |
| 66 | + |
| 67 | +// Details about the time slot constraints |
| 68 | +type TimeSlotConstraints struct { |
| 69 | + MinSlots uint // the minimum number of slots, no minimum if 0 |
| 70 | + MaxSlots uint // the maximum number of slots, unlimited if 0 |
| 71 | + MinSlotDuration time.Duration // the minimum duration of a slot, no minimum if 0 |
| 72 | + MaxSlotDuration time.Duration // the maximum duration of a slot, unlimited if 0 |
| 73 | + SlotDurationStepSize time.Duration // the duration has to be a multiple of this value if != 0 |
| 74 | +} |
| 75 | + |
| 76 | +// Details about the incentive slot constraints |
| 77 | +type IncentiveSlotConstraints struct { |
| 78 | + MinSlots uint // the minimum number of slots, no minimum if 0 |
| 79 | + MaxSlots uint // the maximum number of slots, unlimited if 0 |
| 80 | +} |
| 81 | + |
| 82 | +// details about the boundary |
| 83 | +type TierBoundaryDescription struct { |
| 84 | + // the id of the boundary |
| 85 | + Id uint |
| 86 | + |
| 87 | + // the type of the boundary |
| 88 | + Type model.TierBoundaryTypeType |
| 89 | + |
| 90 | + // the unit of the boundary |
| 91 | + Unit model.UnitOfMeasurementType |
| 92 | +} |
| 93 | + |
| 94 | +// details about incentive |
| 95 | +type IncentiveDescription struct { |
| 96 | + // the id of the incentive |
| 97 | + Id uint |
| 98 | + |
| 99 | + // the type of the incentive |
| 100 | + Type model.IncentiveTypeType |
| 101 | + |
| 102 | + // the currency of the incentive, if it is price based |
| 103 | + Currency model.CurrencyType |
| 104 | +} |
| 105 | + |
| 106 | +// Contains about one tier in a tariff |
| 107 | +type IncentiveTableDescriptionTier struct { |
| 108 | + // the id of the tier |
| 109 | + Id uint |
| 110 | + |
| 111 | + // the tiers type |
| 112 | + Type model.TierTypeType |
| 113 | + |
| 114 | + // each tear has 1 to 3 boundaries |
| 115 | + // used for different power limits, e.g. 0-1kW x€, 1-3kW y€, ... |
| 116 | + Boundaries []TierBoundaryDescription |
| 117 | + |
| 118 | + // each tier has 1 to 3 incentives |
| 119 | + // - price/costs (absolute or relative) |
| 120 | + // - renewable energy percentage |
| 121 | + // - CO2 emissions |
| 122 | + Incentives []IncentiveDescription |
| 123 | +} |
| 124 | + |
| 125 | +// Contains details about a tariff |
| 126 | +type IncentiveTariffDescription struct { |
| 127 | + // each tariff can have 1 to 3 tiers |
| 128 | + Tiers []IncentiveTableDescriptionTier |
| 129 | +} |
| 130 | + |
| 131 | +// Contains details about power limits or incentives for a defined timeframe |
| 132 | +type DurationSlotValue struct { |
| 133 | + Duration time.Duration // Duration of this slot |
| 134 | + Value float64 // Energy Cost or Power Limit |
| 135 | +} |
| 136 | + |
| 137 | +// value if the UCEVCC communication standard is unknown |
| 138 | +const ( |
| 139 | + UCEVCCCommunicationStandardUnknown string = "unknown" |
| 140 | +) |
| 141 | + |
| 142 | +// type for usecase specfic event names |
| 143 | +type UseCaseEventType string |
| 144 | + |
| 145 | +const ( |
| 146 | + // UCCEVC |
| 147 | + |
| 148 | + // EV provided an energy demand |
| 149 | + UCCEVCEnergyDemandProvided UseCaseEventType = "ucCEVCEnergyDemandProvided" |
| 150 | + |
| 151 | + // EV provided a charge plan |
| 152 | + UCCEVCChargePlanProvided UseCaseEventType = "ucCEVCChargePlanProvided" |
| 153 | + |
| 154 | + // EV provided a charge plan constraints |
| 155 | + UCCEVCChargePlanConstraintsProvided UseCaseEventType = "ucCEVCChargePlanConstraintsProvided" |
| 156 | + |
| 157 | + UCCEVCIncentiveDescriptionsRequired UseCaseEventType = "ucCEVCIncentiveDescriptionsRequired" |
| 158 | + |
| 159 | + // EV incentive table data updated |
| 160 | + UCCEVCIncentiveTableDataUpdate UseCaseEventType = "ucCEVCIncentiveTableDataUpdate" |
| 161 | + |
| 162 | + // EV requested power limits |
| 163 | + UCCEVPowerLimitsRequested UseCaseEventType = "ucCEVPowerLimitsRequested" |
| 164 | + |
| 165 | + // EV requested incentives |
| 166 | + UCCEVCIncentivesRequested UseCaseEventType = "ucCEVCIncentivesRequested" |
| 167 | + |
| 168 | + // UCEVCC |
| 169 | + |
| 170 | + // An EV was connected |
| 171 | + // |
| 172 | + // Use Case EVCC, Scenario 1 |
| 173 | + UCEVCCEventConnected UseCaseEventType = "ucEVCCEventConnected" |
| 174 | + |
| 175 | + // An EV was disconnected |
| 176 | + // |
| 177 | + // Use Case EVCC, Scenario 8 |
| 178 | + UCEVCCEventDisconnected UseCaseEventType = "ucEVCCEventDisconnected" |
| 179 | + |
| 180 | + // EV communication standard data was updated |
| 181 | + // |
| 182 | + // Use Case EVCC, Scenario 2 |
| 183 | + UCEVCCCommunicationStandardDataUpdate UseCaseEventType = "ucEVCCCommunicationStandardDataUpdate" |
| 184 | + |
| 185 | + // EV asymmetric charging data was updated |
| 186 | + // |
| 187 | + // Use Case EVCC, Scenario 3 |
| 188 | + UCEVCCAsymmetricChargingDataUpdate UseCaseEventType = "ucEVCCAsymmetricChargingDataUpdate" |
| 189 | + |
| 190 | + // EV identificationdata was updated |
| 191 | + // |
| 192 | + // Use Case EVCC, Scenario 4 |
| 193 | + UCEVCCIdentificationDataUpdate UseCaseEventType = "ucEVCCIdentificationDataUpdate" |
| 194 | + |
| 195 | + // EV manufacturer data was updated |
| 196 | + // |
| 197 | + // Use Case EVCC, Scenario 5 |
| 198 | + UCEVCCManufacturerDataUpdate UseCaseEventType = "ucEVCCManufacturerDataUpdate" |
| 199 | + |
| 200 | + // EV charging power limits |
| 201 | + // |
| 202 | + // Use Case EVCC, Scenario 6 |
| 203 | + UCEVCCChargingPowerLimitsDataUpdate UseCaseEventType = "ucEVCCChargingPowerLimitsDataUpdate" |
| 204 | + |
| 205 | + // EV permitted power limits updated |
| 206 | + // |
| 207 | + // Use Case EVCC, Scenario 7 |
| 208 | + UCEVCCSleepModeDataUpdate UseCaseEventType = "ucEVCCSleepModeDataUpdate" |
| 209 | + |
| 210 | + // UCEVCEM |
| 211 | + |
| 212 | + // EV number of connected phases data updated |
| 213 | + // |
| 214 | + // Use Case EVCEM, Scenario 1 |
| 215 | + UCEVCEMNumberOfConnectedPhasesDataUpdate UseCaseEventType = "ucEVCEMNumberOfConnectedPhasesDataUpdate" |
| 216 | + |
| 217 | + // EV current measurement data updated |
| 218 | + // |
| 219 | + // Use Case EVCEM, Scenario 1 |
| 220 | + UCEVCEMCurrentMeasurementDataUpdate UseCaseEventType = "ucEVCEMCurrentMeasurementDataUpdate" |
| 221 | + |
| 222 | + // EV power measurement data updated |
| 223 | + // |
| 224 | + // Use Case EVCEM, Scenario 2 |
| 225 | + // |
| 226 | + // Note: the referred data may be updated together with UCEVCEMCurrentMeasurementDataUpdate |
| 227 | + UCEVCEMPowerMeasurementDataUpdate UseCaseEventType = "ucEVCEMCurrentMeasurementDataUpdate" |
| 228 | + |
| 229 | + // EV charging energy measurement data updated |
| 230 | + // |
| 231 | + // Use Case EVCEM, Scenario 3 |
| 232 | + // |
| 233 | + // Note: the referred data may be updated together with UCEVCEMCurrentMeasurementDataUpdate |
| 234 | + UCEVCEMChargingEnergyMeasurementDataUpdate UseCaseEventType = "UCEVCEMChargingEnergyMeasurementDataUpdate" |
| 235 | + |
| 236 | + // UCEVSECC |
| 237 | + |
| 238 | + // An EVSE was connected |
| 239 | + UCEVSECCEventConnected UseCaseEventType = "ucEVSEConnected" |
| 240 | + |
| 241 | + // An EVSE was disconnected |
| 242 | + UCEVSECCEventDisconnected UseCaseEventType = "ucEVSEDisonnected" |
| 243 | + |
| 244 | + // EVSE manufacturer data was updated |
| 245 | + // |
| 246 | + // Use Case EVSECC, Scenario 1 |
| 247 | + UCEVSECCEventManufacturerUpdate UseCaseEventType = "ucEVSEManufacturerUpdate" |
| 248 | + |
| 249 | + // EVSE operation state was updated |
| 250 | + // |
| 251 | + // Use Case EVSECC, Scenario 2 |
| 252 | + UCEVSECCEventOperationStateUpdate UseCaseEventType = "ucEVSEOperationStateUpdate" |
| 253 | + |
| 254 | + // UCEVSOC |
| 255 | + |
| 256 | + // EV state of charge data was updated |
| 257 | + // |
| 258 | + // Use Case EVSOC, Scenario 1 |
| 259 | + UCEVSOCStateOfChargeDataUpdate UseCaseEventType = "ucEVSOCStateOfChargeDataUpdate" |
| 260 | + |
| 261 | + // EV nominal capacity data was updated |
| 262 | + // |
| 263 | + // Use Case EVSOC, Scenario 2 |
| 264 | + UCEVSOCNominalCapacityDataUpdate UseCaseEventType = "ucEVSOCNominalCapacityDataUpdate" |
| 265 | + |
| 266 | + // EV state of health data was updated |
| 267 | + // |
| 268 | + // Use Case EVSOC, Scenario 3 |
| 269 | + UCEVSOCStateOfHealthDataUpdate UseCaseEventType = "ucEVSOCStateOfHealthDataUpdate" |
| 270 | + |
| 271 | + // EV actual range data was updated |
| 272 | + // |
| 273 | + // Use Case EVSOC, Scenario 4 |
| 274 | + UCEVSOCActualRangeDataUpdate UseCaseEventType = "ucEVSOCActualRangeDataUpdate" |
| 275 | + |
| 276 | + // UCOPEV |
| 277 | + |
| 278 | + // EV load control obligation limit data updated |
| 279 | + // |
| 280 | + // Use Case OPEV, Scenario 1 |
| 281 | + UCOPEVLoadControlLimitDataUpdate UseCaseEventType = "ucOPEVLoadControlLimitDataUpdate" |
| 282 | + |
| 283 | + // UCOSCEV |
| 284 | + |
| 285 | + // EV load control recommendation limit data updated |
| 286 | + // |
| 287 | + // Use Case OSCEV, Scenario 1 |
| 288 | + // |
| 289 | + // Note: the referred data may be updated together with UCOPEVLoadControlLimitDataUpdate |
| 290 | + UCOSCEVLoadControlLimitDataUpdate UseCaseEventType = "ucOSCEVLoadControlLimitDataUpdate" |
| 291 | +) |
| 292 | + |
| 293 | +var ErrNoEvseEntity = errors.New("entity is not an EVSE") |
| 294 | +var ErrNoEvEntity = errors.New("entity is not an EV") |
| 295 | +var ErrEVDisconnected = errors.New("ev is disconnected") |
| 296 | +var ErrNotSupported = errors.New("function is not supported") |
| 297 | + |
7 | 298 | type Solution struct {
|
8 | 299 | Service api.ServiceInterface
|
9 | 300 | }
|
|
0 commit comments