Reference Manual: DSL caseLibrary

From DSL

Jump to: navigation, search

This class makes it possible to save, open and update the environment of a diagnosis session into several cases. These operations can be done, before, during or after the diagnosis process. During the process, the system will have a set of faultStates where one or more are pursued by the user, and observation nodes which may be in the array of unperformedtest or may already be performed and are then in the array of performedtest. For more information about these variables see the previous class DIAG_network.

Each case that contains the information about the state of a diagnosis process belongs to the class DSL_caseLibrary and is a member of the collection _caseContainer. A case is from the type DSL_case which consist of the following variables:


Title The title of the case
Comment The comment on the case
PursuedFaults A collection of all the pursuedFaults selected in the diagnosis system, each item of the collection contains two strings, one for the nodeID, the node where the pursuedFault is from, and one for which state of the node is the pursuedFault.
Evidence A collection of all the evidence entered in the diagnosis system, each item of the collection contains two strings, one for the nodeID of the node where the evidence was entered and one for the value of the evidence.
ModelName The name of the model when the environment was saved.


The structure for DSL_case is defined as follows:

  struct DSL_case {  typedef std::pair<std::string,std::string> _evidenceItem; 
  // (nodeId,outcomeId) 
  typedef std::vector<_evidenceItem> _evidenceContainer;  
  typedef std::pair<std::string,std::string> _pursuedFaultItem; // (nodeId,outcomeId)  
  typedef std::vector<_pursuedFaultItem> _pursuedFaultsContainer;  
  DSL_case(); 
  DSL_case(const DSL_case &likeThisOne);  
  std::string title; 
  std::string comment; 
  _pursuedFaultsContainer pursuedFaults;  
  td::string modelName; 
  _evidenceContainer evidence; };

The _caseContainer is defined as follows:

  typedef std::vector<DSL_case> _caseContainer;


Methods

  • DSL_caseLibrary(DIAG_network *linkToNetwork)

Links ourselves to the DIAG_network specified with linkToNetwork. If no input value is available =NULL we will not get linked: DSL_caseLibrary(void);


  • void LinkTo(DIAG_network *thisNetwork)

Links ourselves to the specified network, thisNetwork.


  • int ReadCaseLibrary(char *thisFile)

Empties all the cases of the _caseContainer and fills them again with the cases from the file thisFile. Before reading the rest of the file, the function reads the first line to determine if the content is suitable for the caseLibrary.


  • int WriteCaseLibrary(char *thisFile)

Writes all the cases of the _caseContainer to a file thisFile. Before writing the information about each case, there is written that the file contains cases for a caseLibrary. After that, for each case the following items are written:


Title The title of the case
Comment The comment on the case
PursuedFaults A collection of all the pursuedFaults selected in the diagnosis system, each item of the collection contains two strings, one for the nodeID, the node where the pursuedFault is from, and one for which state of the node is the pursuedFault.
Evidence A collection of all the evidence entered in the diagnosis system, each item of the collection contains two strings, one for the nodeID of the node where the evidence was entered and one for the value of the evidence.
ModelName The name of the model when the environment was saved.


  • int AddCase(const DSL_case &newCase)

Adds a new case to the end of the vector _caseContainer of DSL_cases.


  • const DSL_case &GetCase(int thisOne)

Returns the DSL_case of the vector _caseContainer specified by the position thisOne. There is no check if the position thisOne is valid, and therefore it is unknown what this function will give back if anything goes wrong.


  • int DeleteCase(int thisOne)

Deletes the case on the position thisOne in the vector _caseContainer. There is no check if the position thisOne is valid, and therefore it is unknown what this function will give back if anything goes wrong.


  • int InstantiateCaseEvidence(int thisOne)

Instantiates the evidence contained in the case thisOne. This case is selected from the collection _caseContainer with the function &GetCase(int thisOne). Before assigning the evidence to the nodes, the function first checks if the evidence is valid with the function EvidenceValid.


  • int FillCaseWithEvidence(DSL_case &here)

First deletes all the 'old' evidence from the evidence collection in the DSL_case &here. Then refilling all the evidence from all the nodes of the network in the DSL_case &here. This is done by looking at each node if there is evidence and when so, put the name of the node along with the value of the evidence into the evidence collection of the case.


  • int FillCaseWithPursuedFaults(DSL_case &here)

First deletes all the 'old' pursuedFaults from the pursuedFaults collection in the DSL_case &here. Then refilling all the pursuedFaults from the network in the DSL_case &here. This is done by collecting the node and state of each pursuedFault in the array pursuedFaults, and inserting them in the collection of pursuedFaults within the case.


  • bool EvidenceValid(const DSL_case::_evidenceItem &thisEvidence, std::pair <int,int> &handles)

Returns true if thisEvidence contains a valid pair [NodeID][OutcomeID] for the current network. If the pair is valid, the function returns the [nodeHandle, outcomeIndex] in handles. If there cannot be found a node with thisEvidence then the function will return false.


  • bool FaultValid(const std::string &faultNode, const std::string &faultState,std::pair <int,int> &handles)

Returns true if faultNode and faultState contains a valid node/state for the current network. If the pair is valid, the function returns the [nodeHandle, outcomeIndex] in handles. If there cannot be found a node with faultNode or the faultNode doesn't contain the faultState then the function will return false.


  • int SaveCurrentCase(const char *withThisTitle, bool overwrite = false);

Adds a new case with the title withThisTitle to the _caseContainer and insert the current evidence, and pursuedFaults into it. If there is already a case withThisTitle in the library, nothing is added and DSL_OUT_OF_RANGE is returned unless overwrite =true. When overwrite is true the content of the case with the name withThisTitle will be replaced with the current evidence, faults and the pursuedFault.


  • int FindCase(const char *withThisTitle);

Searches the caseLibrary for the case with the title withThisTitle. If the case if found the function returns the position of the case. When the case cannot be found the function will return the error DSL_OUT_OF_RANGE.


  • void SaveCurrentCase(DSL_case &here);

Saves the current evidence, pursuedFaults and the name of the network into the case identified by the position here. The function assumes that the case exists with the handle here.


  • void InstantiateCase(const DSL_case &thisOne);

Instantiates the evidence and pursuedFaults of the case thisOne. Before the evidence is instantiated, the function first checks if the evidence is valid with the function EvidenceValid. Before the faults are instantiated the function first checks if the pursued fault(s) are valid with, FaultValid.


  • int ConsistentCase(const DSL_case &thisOne, bool ignoreModelName);

Checks if the case thisOne is consistent with the current network. When ignoreModelName is false the function compares the name of the case with the name of the network. Following the evidence of the case is compared with the evidence in the network and finally the pursuedFaults of the case are compared with the pursuedFaults of the network. The function returns -1 when the name is not consistent, it returns -2 when the evidence is not consistent, and -3 if the pursued faults are not consistent.

Personal tools