Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/310 min operational hours #402

Merged
merged 2 commits into from
Jun 11, 2024
Merged
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
7 changes: 4 additions & 3 deletions src/components/editor/faultTree/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { JOINTJS_NODE_MODEL } from "@components/editor/faultTree/shapes/constant
import { calculateCutSets } from "@services/faultTreeService";
import { FaultEventScenario } from "@models/faultEventScenario";
import { useAppBar } from "../../../contexts/AppBarContext";
import { asArray } from "@utils/utils";

const Editor = () => {
const history = useNavigate();
Expand Down Expand Up @@ -58,7 +59,7 @@ const Editor = () => {
setRootEvent(updatedRootEvent);

if (faultTree.faultEventScenarios) {
setFaultEventScenarios([getScenarioWithHighestProbability(faultTree.faultEventScenarios)]);
setFaultEventScenarios([getScenarioWithHighestProbability(asArray(faultTree.faultEventScenarios))]);
}

if (contextMenuSelectedEvent) {
Expand Down Expand Up @@ -181,7 +182,7 @@ const Editor = () => {
const handleCutSetAnalysis = () => {
setShowPath(!showPath);
setShowTable(!showTable);
calculateCutSets(faultTree.iri)
calculateCutSets(faultTree.iri, faultTree.operationalDataFilter)
.then((d) => {
refreshTree();
})
Expand Down Expand Up @@ -256,7 +257,7 @@ const Editor = () => {
setHighlightedElement={setHighlightedElementView}
refreshTree={refreshTree}
faultEventScenarios={faultEventScenarios}
possibleFaultEventScenarios={faultTree?.faultEventScenarios ? faultTree?.faultEventScenarios : []}
possibleFaultEventScenarios={asArray(faultTree?.faultEventScenarios)}
showPath={showPath}
showTable={showTable}
onScenarioSelect={(scenario: FaultEventScenario) => handleOnScenarioSelect(scenario)}
Expand Down
5 changes: 4 additions & 1 deletion src/models/faultTreeModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import VocabularyUtils from "@utils/VocabularyUtils";
import { FaultEvent, CONTEXT as EVENT_CONTEXT } from "@models/eventModel";
import { AbstractModel, CONTEXT as ABSTRACT_CONTEXT } from "@models/abstractModel";
import { FaultEventScenario, CONTEXT as SCENARIO_CONTEXT } from "@models/faultEventScenario";
import { OperationalDataFilter, CONTEXT as FILTER_CONTEXT } from "@models/operationalDataFilterModel";

const ctx = {
manifestingEvent: VocabularyUtils.PREFIX + "is-manifested-by",
faultEventScenarios: VocabularyUtils.PREFIX + "has-scenario",
operationalDataFilter: VocabularyUtils.PREFIX + "has-operational-data-filter",
name: VocabularyUtils.PREFIX + "name",
};

export const CONTEXT = Object.assign({}, ctx, ABSTRACT_CONTEXT, EVENT_CONTEXT, SCENARIO_CONTEXT);
export const CONTEXT = Object.assign({}, ctx, ABSTRACT_CONTEXT, EVENT_CONTEXT, SCENARIO_CONTEXT, FILTER_CONTEXT);

export interface FaultTree extends AbstractModel {
name: string;
Expand All @@ -29,4 +31,5 @@ export interface FaultTree extends AbstractModel {
subSystem?: {
name?: string;
};
operationalDataFilter: OperationalDataFilter;
}
12 changes: 12 additions & 0 deletions src/models/operationalDataFilterModel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import VocabularyUtils from "@utils/VocabularyUtils";
import { AbstractModel, CONTEXT as ABSTRACT_CONTEXT } from "@models/abstractModel";

const ctx = {
minOperationalHours: VocabularyUtils.PREFIX + "min-operational-hours",
};

export const CONTEXT = Object.assign({}, ctx, ABSTRACT_CONTEXT);

export interface OperationalDataFilter extends AbstractModel {
minOperationalHours: number;
}
7 changes: 6 additions & 1 deletion src/models/systemModel.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import VocabularyUtils from "@utils/VocabularyUtils";
import { Component, CONTEXT as COMPONENT_CONTEXT } from "@models/componentModel";
import { AbstractModel, CONTEXT as ABSTRACT_CONTEXT } from "@models/abstractModel";
import { OperationalDataFilter, CONTEXT as FILTER_CONTEXT } from "@models/operationalDataFilterModel";

const ctx = {
name: VocabularyUtils.PREFIX + "name",
globalOperationalDataFilter: VocabularyUtils.PREFIX + "has-global-operational-data-filter",
operationalDataFilter: VocabularyUtils.PREFIX + "has-operational-data-filter",
components: VocabularyUtils.PREFIX + "has-part-component",
};

export const CONTEXT = Object.assign({}, ctx, COMPONENT_CONTEXT, ABSTRACT_CONTEXT);
export const CONTEXT = Object.assign({}, ctx, COMPONENT_CONTEXT, ABSTRACT_CONTEXT, FILTER_CONTEXT);

export interface System extends AbstractModel {
name: string;
components?: Component[];
globalOperationalDataFilter: OperationalDataFilter;
operationalDataFilter: OperationalDataFilter;
}
7 changes: 5 additions & 2 deletions src/services/faultTreeService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { authHeaders } from "@services/utils/authUtils";
import axiosClient from "@services/utils/axiosUtils";
import { CONTEXT, FaultTree } from "@models/faultTreeModel";
import { CONTEXT as EVENT_CONTEXT, FaultEvent } from "@models/eventModel";
import { CONTEXT as FILTER_CONTEXT, OperationalDataFilter } from "@models/operationalDataFilterModel";
import VocabularyUtils from "@utils/VocabularyUtils";
import { extractFragment } from "@services/utils/uriIdentifierUtils";
import {
Expand Down Expand Up @@ -198,10 +199,12 @@ export const getTreePathsAggregate = async (): Promise<[FaultEvent[]]> => {
}
};

export const calculateCutSets = async (faultTreeUri: string) => {
export const calculateCutSets = async (faultTreeUri: string, operationalDataFilter: OperationalDataFilter) => {
try {
const fragment = extractFragment(faultTreeUri);
const response = await axiosClient.put(`/faultTrees/${fragment}/evaluate`, null, {
const filter = Object.assign({}, operationalDataFilter, { "@context": FILTER_CONTEXT });

const response = await axiosClient.put(`/faultTrees/${fragment}/evaluate`, filter, {
headers: authHeaders(),
});
return response;
Expand Down
1 change: 1 addition & 0 deletions src/utils/VocabularyUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export default {
SYSTEM: _NS_FTA_FMEA + "system",
FAILURE_MODES_TABLE: _NS_FTA_FMEA + "failure-modes-table",
FAILURE_MODES_ROW: _NS_FTA_FMEA + "failure-modes-row",
OPERATIONAL_DATA_FILTER: _NS_FTA_FMEA + "operational-data-filter",
};
Loading