Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions _alp/Classes/Class.J_ActivityTrackerTrips.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,36 @@ public double getAnnualDistance_km() {
return currentAnnualDistance_km;
}

public List<TripRecord> getTripsActiveBetween_h(double t1_h, double t2_h) {
List<TripRecord> matchingTrips = new ArrayList<>();
if (tripRecords.isEmpty() || t2_h <= t1_h) {
return matchingTrips;
}

// Start one week earlier so a trip that began before t1_h (and is still running) is
// reachable by the unroll. A single trip is assumed shorter than a week.
double weekStartOffset_h = t1_h - getTimeSinceWeekStart_h(t1_h);

for (double weekOffset_h = weekStartOffset_h - 168.0; weekOffset_h < t2_h; weekOffset_h += 168.0) {
for (TripRecord tripRecord : tripRecords) {
double absoluteStartTime_h = tripRecord.startTime_h() + weekOffset_h;

double duration_h = tripRecord.endTime_h() - tripRecord.startTime_h();
if (duration_h < 0) duration_h += 168.0; // trip straddles the week wrap
double absoluteEndTime_h = absoluteStartTime_h + duration_h;

// Include if it starts inside the window, OR it is in progress at t1_h.
boolean startsInWindow = absoluteStartTime_h >= t1_h && absoluteStartTime_h < t2_h;
boolean inProgressAtT1 = absoluteStartTime_h < t1_h && absoluteEndTime_h > t1_h;

if (startsInWindow || inProgressAtT1) {
matchingTrips.add(tripRecord);
}
}
}
return matchingTrips;
}

public static record TripRecord(double startTime_h, double endTime_h, double distance_km) {
}

Expand Down
2 changes: 1 addition & 1 deletion _alp/Classes/Class.J_EAChargingSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public void enableV2GCapabilityOverride(boolean enableV2GCapabilityOverride, Dou
setV2GActive(getV2GActive());
}

protected void setV2GActive(boolean activateV2G) { // Should only be called by the chargingManagement class or J_EAChargingSession during initialization itself. (No such thing as friend class in java, so only can put on protected).
public void setV2GActive(boolean activateV2G) { // Should only be called by the chargingManagement class or J_EAChargingSession during initialization itself. (No such thing as friend class in java).
this.V2GActive = activateV2G;
if((!this.overrideV2GCapability || (this.overrideV2GCapability && this.V2GCapabilityProbablityOverride > 0)) && activateV2G) {
this.assetFlowCategory = OL_AssetFlowCategories.V2GPower_kW;
Expand Down
6 changes: 3 additions & 3 deletions _alp/Classes/Class.J_EAEV.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ public boolean endTrip(double tripDist_km) {

energyUsed_kWh += tripDist_km * vehicleScaling * energyConsumption_kWhpkm;
energyUse_kW += tripDist_km * vehicleScaling * energyConsumption_kWhpkm / this.timeParameters.getTimeStep_h();
if (stateOfCharge_fr < 0) {
traceln("EV of type: " + this.energyAssetType + " arrived home with negative SOC: " + roundToDecimal(100 * stateOfCharge_fr,2) + "%");
if (DoubleCompare.lessThanZero(stateOfCharge_fr)) {
traceln("EV of type: " + this.energyAssetType + " arrived home with negative SOC: " + (100 * stateOfCharge_fr) + "%");
}
this.available = true;
return true;
Expand Down Expand Up @@ -254,7 +254,7 @@ public boolean getV2GActive() {
return this.V2GActive;
}

protected void setV2GActive(boolean activateV2G) { // Should only be called by the chargingManagement class or J_EAEV during initialization itself. (No such thing as friend class in java, so only can put on protected).
public void setV2GActive(boolean activateV2G) { // Should only be called by the chargingManagement class or J_EAEV during initialization itself. (No such thing as friend class in java).
this.V2GActive = activateV2G;
if(this.V2GCapable && activateV2G) {
this.assetFlowCategory = OL_AssetFlowCategories.V2GPower_kW;
Expand Down