|
| 1 | +package io.openems.edge.meter.test; |
| 2 | + |
| 3 | +import io.openems.edge.common.channel.Channel; |
| 4 | +import io.openems.edge.common.component.AbstractOpenemsComponent; |
| 5 | +import io.openems.edge.common.test.TestUtils; |
| 6 | +import io.openems.edge.meter.api.ElectricityMeter; |
| 7 | +import io.openems.edge.meter.api.MeterType; |
| 8 | + |
| 9 | +public abstract class AbstractDummyElectricityMeter<SELF extends AbstractDummyElectricityMeter<?>> |
| 10 | + extends AbstractOpenemsComponent implements ElectricityMeter { |
| 11 | + |
| 12 | + private MeterType meterType; |
| 13 | + |
| 14 | + protected AbstractDummyElectricityMeter(String id, |
| 15 | + io.openems.edge.common.channel.ChannelId[] firstInitialChannelIds, |
| 16 | + io.openems.edge.common.channel.ChannelId[]... furtherInitialChannelIds) { |
| 17 | + super(firstInitialChannelIds, furtherInitialChannelIds); |
| 18 | + for (Channel<?> channel : this.channels()) { |
| 19 | + channel.nextProcessImage(); |
| 20 | + } |
| 21 | + super.activate(null, id, "", true); |
| 22 | + } |
| 23 | + |
| 24 | + protected abstract SELF self(); |
| 25 | + |
| 26 | + /** |
| 27 | + * Set the {@link MeterType}. |
| 28 | + * |
| 29 | + * @param meterType the meterType |
| 30 | + * @return myself |
| 31 | + */ |
| 32 | + public SELF withMeterType(MeterType meterType) { |
| 33 | + this.meterType = meterType; |
| 34 | + return this.self(); |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * Set {@link ElectricityMeter.ChannelId#ACTIVE_POWER} of this |
| 39 | + * {@link ElectricityMeter}. |
| 40 | + * |
| 41 | + * @param value the value |
| 42 | + * @return myself |
| 43 | + */ |
| 44 | + public SELF withActivePower(Integer value) { |
| 45 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.ACTIVE_POWER, value); |
| 46 | + return this.self(); |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Set {@link ElectricityMeter.ChannelId#ACTIVE_POWER_L1} of this |
| 51 | + * {@link ElectricityMeter}. |
| 52 | + * |
| 53 | + * @param value the value |
| 54 | + * @return myself |
| 55 | + */ |
| 56 | + public SELF withActivePowerL1(Integer value) { |
| 57 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.ACTIVE_POWER_L1, value); |
| 58 | + return this.self(); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Set {@link ElectricityMeter.ChannelId#ACTIVE_POWER_L2} of this |
| 63 | + * {@link ElectricityMeter}. |
| 64 | + * |
| 65 | + * @param value the value |
| 66 | + * @return myself |
| 67 | + */ |
| 68 | + public SELF withActivePowerL2(Integer value) { |
| 69 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.ACTIVE_POWER_L2, value); |
| 70 | + return this.self(); |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * Set {@link ElectricityMeter.ChannelId#ACTIVE_POWER_L3} of this |
| 75 | + * {@link ElectricityMeter}. |
| 76 | + * |
| 77 | + * @param value the value |
| 78 | + * @return myself |
| 79 | + */ |
| 80 | + public SELF withActivePowerL3(Integer value) { |
| 81 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.ACTIVE_POWER_L3, value); |
| 82 | + return this.self(); |
| 83 | + } |
| 84 | + |
| 85 | + /** |
| 86 | + * Set {@link ElectricityMeter.ChannelId#REACTIVE_POWER} of this |
| 87 | + * {@link ElectricityMeter}. |
| 88 | + * |
| 89 | + * @param value the value |
| 90 | + * @return myself |
| 91 | + */ |
| 92 | + public SELF withReactivePower(Integer value) { |
| 93 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.REACTIVE_POWER, value); |
| 94 | + return this.self(); |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * Set {@link ElectricityMeter.ChannelId#REACTIVE_POWER_L1} of this |
| 99 | + * {@link ElectricityMeter}. |
| 100 | + * |
| 101 | + * @param value the value |
| 102 | + * @return myself |
| 103 | + */ |
| 104 | + public SELF withReactivePowerL1(Integer value) { |
| 105 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.REACTIVE_POWER_L1, value); |
| 106 | + return this.self(); |
| 107 | + } |
| 108 | + |
| 109 | + /** |
| 110 | + * Set {@link ElectricityMeter.ChannelId#REACTIVE_POWER_L2} of this |
| 111 | + * {@link ElectricityMeter}. |
| 112 | + * |
| 113 | + * @param value the value |
| 114 | + * @return myself |
| 115 | + */ |
| 116 | + public SELF withReactivePowerL2(Integer value) { |
| 117 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.REACTIVE_POWER_L2, value); |
| 118 | + return this.self(); |
| 119 | + } |
| 120 | + |
| 121 | + /** |
| 122 | + * Set {@link ElectricityMeter.ChannelId#REACTIVE_POWER_L3} of this |
| 123 | + * {@link ElectricityMeter}. |
| 124 | + * |
| 125 | + * @param value the value |
| 126 | + * @return myself |
| 127 | + */ |
| 128 | + public SELF withReactivePowerL3(Integer value) { |
| 129 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.REACTIVE_POWER_L3, value); |
| 130 | + return this.self(); |
| 131 | + } |
| 132 | + |
| 133 | + /** |
| 134 | + * Set {@link ElectricityMeter.ChannelId#CURRENT} of this |
| 135 | + * {@link ElectricityMeter}. |
| 136 | + * |
| 137 | + * @param value the value |
| 138 | + * @return myself |
| 139 | + */ |
| 140 | + public SELF withCurrent(Integer value) { |
| 141 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.CURRENT, value); |
| 142 | + return this.self(); |
| 143 | + } |
| 144 | + |
| 145 | + /** |
| 146 | + * Set {@link ElectricityMeter.ChannelId#CURRENT_L1} of this |
| 147 | + * {@link ElectricityMeter}. |
| 148 | + * |
| 149 | + * @param value the value |
| 150 | + * @return myself |
| 151 | + */ |
| 152 | + public SELF withCurrentL1(Integer value) { |
| 153 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.CURRENT_L1, value); |
| 154 | + return this.self(); |
| 155 | + } |
| 156 | + |
| 157 | + /** |
| 158 | + * Set {@link ElectricityMeter.ChannelId#CURRENT_L2} of this |
| 159 | + * {@link ElectricityMeter}. |
| 160 | + * |
| 161 | + * @param value the value |
| 162 | + * @return myself |
| 163 | + */ |
| 164 | + public SELF withCurrentL2(Integer value) { |
| 165 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.CURRENT_L2, value); |
| 166 | + return this.self(); |
| 167 | + } |
| 168 | + |
| 169 | + /** |
| 170 | + * Set {@link ElectricityMeter.ChannelId#CURRENT_L3} of this |
| 171 | + * {@link ElectricityMeter}. |
| 172 | + * |
| 173 | + * @param value the value |
| 174 | + * @return myself |
| 175 | + */ |
| 176 | + public SELF withCurrentL3(Integer value) { |
| 177 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.CURRENT_L3, value); |
| 178 | + return this.self(); |
| 179 | + } |
| 180 | + |
| 181 | + /** |
| 182 | + * Set {@link ElectricityMeter.ChannelId#VOLTAGE} of this |
| 183 | + * {@link ElectricityMeter}. |
| 184 | + * |
| 185 | + * @param value the value |
| 186 | + * @return myself |
| 187 | + */ |
| 188 | + public SELF withVoltage(Integer value) { |
| 189 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.VOLTAGE, value); |
| 190 | + return this.self(); |
| 191 | + } |
| 192 | + |
| 193 | + /** |
| 194 | + * Set {@link ElectricityMeter.ChannelId#VOLTAGE_L1} of this |
| 195 | + * {@link ElectricityMeter}. |
| 196 | + * |
| 197 | + * @param value the value |
| 198 | + * @return myself |
| 199 | + */ |
| 200 | + public SELF withVoltageL1(Integer value) { |
| 201 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.VOLTAGE_L1, value); |
| 202 | + return this.self(); |
| 203 | + } |
| 204 | + |
| 205 | + /** |
| 206 | + * Set {@link ElectricityMeter.ChannelId#VOLTAGE_L2} of this |
| 207 | + * {@link ElectricityMeter}. |
| 208 | + * |
| 209 | + * @param value the value |
| 210 | + * @return myself |
| 211 | + */ |
| 212 | + public SELF withVoltageL2(Integer value) { |
| 213 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.VOLTAGE_L2, value); |
| 214 | + return this.self(); |
| 215 | + } |
| 216 | + |
| 217 | + /** |
| 218 | + * Set {@link ElectricityMeter.ChannelId#VOLTAGE_L3} of this |
| 219 | + * {@link ElectricityMeter}. |
| 220 | + * |
| 221 | + * @param value the value |
| 222 | + * @return myself |
| 223 | + */ |
| 224 | + public SELF withVoltageL3(Integer value) { |
| 225 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.VOLTAGE_L3, value); |
| 226 | + return this.self(); |
| 227 | + } |
| 228 | + |
| 229 | + /** |
| 230 | + * Set {@link ElectricityMeter.ChannelId#ACTIVE_PRODUCTION_ENERGY} of this |
| 231 | + * {@link ElectricityMeter}. |
| 232 | + * |
| 233 | + * @param value the value |
| 234 | + * @return myself |
| 235 | + */ |
| 236 | + public SELF withActiveProductionEnergy(Integer value) { |
| 237 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, value); |
| 238 | + return this.self(); |
| 239 | + } |
| 240 | + |
| 241 | + /** |
| 242 | + * Set {@link ElectricityMeter.ChannelId#ACTIVE_PRODUCTION_ENERGY_L1} of this |
| 243 | + * {@link ElectricityMeter}. |
| 244 | + * |
| 245 | + * @param value the value |
| 246 | + * @return myself |
| 247 | + */ |
| 248 | + public SELF withActiveProductionEnergyL1(Integer value) { |
| 249 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY_L1, value); |
| 250 | + return this.self(); |
| 251 | + } |
| 252 | + |
| 253 | + /** |
| 254 | + * Set {@link ElectricityMeter.ChannelId#ACTIVE_PRODUCTION_ENERGY_L2} of this |
| 255 | + * {@link ElectricityMeter}. |
| 256 | + * |
| 257 | + * @param value the value |
| 258 | + * @return myself |
| 259 | + */ |
| 260 | + public SELF withActiveProductionEnergyL2(Integer value) { |
| 261 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY_L2, value); |
| 262 | + return this.self(); |
| 263 | + } |
| 264 | + |
| 265 | + /** |
| 266 | + * Set {@link ElectricityMeter.ChannelId#ACTIVE_PRODUCTION_ENERGY_L3} of this |
| 267 | + * {@link ElectricityMeter}. |
| 268 | + * |
| 269 | + * @param value the value |
| 270 | + * @return myself |
| 271 | + */ |
| 272 | + public SELF withActiveProductionEnergyL3(Integer value) { |
| 273 | + TestUtils.withValue(this, ElectricityMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY_L3, value); |
| 274 | + return this.self(); |
| 275 | + } |
| 276 | + |
| 277 | + @Override |
| 278 | + public MeterType getMeterType() { |
| 279 | + return this.meterType; |
| 280 | + } |
| 281 | + |
| 282 | +} |
0 commit comments