onroute-policy-engine 2.32.1 → 2.32.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -235,7 +235,8 @@ function CheckAxleGroupMaximumLegalWeightThreshold(policy, vehicleConfiguration,
235
235
  return policyCheckResults;
236
236
  }
237
237
  function meetsMinimumSteerPercentageOfDriveAxleWeight(steerAxle, driveAxle, minimumPercentage) {
238
- return (steerAxle.axleUnitWeight >= driveAxle.axleUnitWeight * minimumPercentage);
238
+ return (steerAxle.axleUnitWeight >=
239
+ Math.round(driveAxle.axleUnitWeight * minimumPercentage));
239
240
  }
240
241
  /**
241
242
  * Validates the number of axles in each axle unit.
@@ -276,36 +277,37 @@ function CheckNumberOfAxles(_policy, _vehicleConfiguration, axleConfiguration) {
276
277
  });
277
278
  return policyCheckResults;
278
279
  }
279
- function getBridgeFormulaInputFailure(axleConfiguration) {
280
+ /**
281
+ * This function basically lets us skip Bridge Formula if we know it'll crash.
282
+ *
283
+ * This function is a 'necessary evil.' The Bridge Formula calculation is
284
+ * important legacy code, but with certain inputs it would throw an
285
+ * exception and crash the entire calculation, especially in the ASW table.
286
+ *
287
+ * These "crashing inputs" are always STOW eval errors, so even if we don't
288
+ * run bridge formula the user should be seeing seperate errors, so once they
289
+ * fix those errors then re-run it should include Bridge Formula.
290
+ *
291
+ */
292
+ function hasInvalidBridgeFormulaInput(axleConfiguration) {
280
293
  for (let axleIndex = 0; axleIndex < axleConfiguration.length; axleIndex++) {
281
294
  const axleUnit = axleConfiguration[axleIndex];
282
- const axleUnitNumber = axleIndex + 1;
283
- let message;
284
295
  if (!Number.isFinite(axleUnit.axleUnitWeight) ||
285
296
  axleUnit.axleUnitWeight <= 0) {
286
- message = `Axle unit weight for axle unit ${axleUnitNumber} must be a finite number greater than 0.`;
297
+ return true;
287
298
  }
288
299
  else if (axleUnit.numberOfAxles > 1 &&
289
300
  (!Number.isFinite(axleUnit.axleSpread) ||
290
301
  axleUnit.axleSpread <= 0)) {
291
- message = `Axle spread for axle unit ${axleUnitNumber} must be a finite number greater than 0 when the unit has multiple axles.`;
302
+ return true;
292
303
  }
293
304
  else if (axleIndex > 0 &&
294
305
  (!Number.isFinite(axleUnit.interaxleSpacing) ||
295
306
  axleUnit.interaxleSpacing <= 0)) {
296
- message = `Axle spacing before axle unit ${axleUnitNumber} must be a finite number greater than 0.`;
297
- }
298
- if (message) {
299
- return {
300
- id: enum_1.PolicyCheckId.BridgeFormula,
301
- message,
302
- result: enum_1.PolicyCheckResultType.Fail,
303
- startAxleUnit: axleUnitNumber,
304
- endAxleUnit: axleUnitNumber,
305
- };
307
+ return true;
306
308
  }
307
309
  }
308
- return undefined;
310
+ return false;
309
311
  }
310
312
  /**
311
313
  * Performs bridge formula calculations on axle groups and returns policy check results.
@@ -336,9 +338,12 @@ function getBridgeFormulaInputFailure(axleConfiguration) {
336
338
  function CheckBridgeFormula(policy, vehicleConfiguration, axleConfiguration) {
337
339
  const policyCheckResults = new Array();
338
340
  const policyId = enum_1.PolicyCheckId.BridgeFormula;
339
- const inputFailure = getBridgeFormulaInputFailure(axleConfiguration);
340
- if (inputFailure) {
341
- return [inputFailure];
341
+ // This basically skips Bridge Formula if the input is invalid.
342
+ // This is important for STOW, which in the ASW runs this as well as STOW evals
343
+ // Some of those STOW evals can accept inputs that would make Bridge Formula throw
344
+ // errors and crash.
345
+ if (hasInvalidBridgeFormulaInput(axleConfiguration)) {
346
+ return [];
342
347
  }
343
348
  const bridgeCalcResults = policy.calculateBridge(axleConfiguration, vehicleConfiguration);
344
349
  bridgeCalcResults.forEach((br) => {
@@ -1251,7 +1256,7 @@ function CheckLegalAxleSpread(policy, vehicleConfiguration, axleConfiguration) {
1251
1256
  const axleUnitVehicleIndexes = (0, dimensions_helper_1.getAxleUnitVehicleIndexLookup)(policy, vehicleConfiguration, axleConfiguration);
1252
1257
  return axleConfiguration.flatMap((axleUnit, axleIndex) => {
1253
1258
  const threshold = (0, axle_spread_helper_1.getAxleSpreadThreshold)(vehicleConfiguration, axleUnitVehicleIndexes, axleConfiguration, axleIndex);
1254
- if (!axleUnit.axleSpread ||
1259
+ if (axleUnit.axleSpread === undefined ||
1255
1260
  !threshold ||
1256
1261
  !Number.isFinite(axleUnit.axleSpread)) {
1257
1262
  return [];
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "v2.32.1";
1
+ export declare const version = "v2.32.3";
package/dist/version.js CHANGED
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // Generated by genversion.
5
- exports.version = 'v2.32.1';
5
+ exports.version = 'v2.32.3';
package/package.json CHANGED
@@ -91,5 +91,5 @@
91
91
  ],
92
92
  "testEnvironment": "node"
93
93
  },
94
- "version": "v2.32.1"
94
+ "version": "v2.32.3"
95
95
  }