Пример #1
0
 def executeSafetyCheck(self, state):
     """
     Execute safety check over this compnent.
     :param state: State object which contains state information
     """
     logAllChecksDescription("SAFETY",
                             "CONSUMER %s" % self.name,
                             indentation=2)
     checkStatus = dict()
     try:
         checkStatus["R1"] = self.safetyCheckR1(state)
         checkStatus["R2"] = self.safetyCheckR2(state)
         checkStatus["R3"] = self.safetyCheckR3(state)
         checkStatus["R4"] = self.safetyCheckR4(state)
         checkStatus["R8a"] = self.safetyCheckR8a(state)
         checkStatus["R8b"] = self.safetyCheckR8b(state)
         checkStatus["R9a"] = self.safetyCheckR9a(state)
         checkStatus["R9b"] = self.safetyCheckR9b(state)
         logAllChecksPassed("SAFETY",
                            "CONSUMER %s" % self.name,
                            all(checkStatus.values()),
                            indentation=2)
     except Exception, e:
         logError("Unknown exception or error: %s" % e.message,
                  indentation=2)
Пример #2
0
def checkTopology(topology, state, rtusToTest=None):
    """
    Evaluate all consistency and safety rules on the topology with the given state information
    :param topology: Topology list of RTUs
    :param state: State object with stateful information
    :param rtusToTest: RTUs which should be tested
    :return: (T,T) If all tests are successful, (F,T) if consistency violation, (T,F) if safety violation, (F,F) if violation in both
    """
    logAllChecksDescription("ALL CHECKS", "TOPOLOGY", indentation=0)
    checkStatusConsistency = dict()
    checkStatusSafety = dict()
    try:
        if type(rtusToTest) == set or type(rtusToTest) == list:
            relevantRTUs = [rtu for rtu in topology if rtu.name in rtusToTest]
        else:
            relevantRTUs = topology
        for rtu in relevantRTUs:
            checkStatusConsistency[rtu.name] = all(
                rtu.executeFullConsistencyCheck(state).values())
            checkStatusSafety[rtu.name] = all(
                rtu.executeFullSafetyCheck(state).values())
        logAllChecksPassed("ALL CHECKS",
                           "TOPOLOGY",
                           all(checkStatusConsistency.values())
                           and all(checkStatusSafety.values()),
                           indentation=0)
    except Exception, e:
        logError("Unknown exception or error: %s" % e.message, indentation=0)
Пример #3
0
 def executeFullConsistencyCheck(self, state):
     """
     Execute consistency check over all compnents connected to this RTU.
     :param state: State object which contains state information
     """
     logAllChecksDescription("CONSISTENCY", "RTU %s" % self.name, indentation=1)
     checkStatus = dict()
     try:
         for n in self.controlledNodes:
             checkStatus[n.name] = all(n.executeConsistencyCheck(state).values())
         logAllChecksPassed("CONSISTENCY", "RTU %s" % self.name, all(checkStatus.values()), indentation=1)
     except Exception, e:
         logError("Unknown exception or error: %s" % e.message, indentation=1)
Пример #4
0
 def executeConsistencyCheck(self, state):
     """
     Execute consistency check over this compnent.
     :param state: State object which contains state information
     """
     logAllChecksDescription("CONSISTENCY",
                             "CONSUMER %s" % self.name,
                             indentation=2)
     checkStatus = dict()
     try:
         checkStatus["P3"] = self.consistencyCheckP3(state)
         checkStatus["P4"] = self.consistencyCheckP4(state)
         checkStatus["P5b"] = self.consistencyCheckP5b(state)
         logAllChecksPassed("CONSISTENCY",
                            "CONSUMER %s" % self.name,
                            all(checkStatus.values()),
                            indentation=2)
     except Exception, e:
         logError("Unknown exception or error: %s" % e.message,
                  indentation=2)