예제 #1
0
 def _calc_state(operand):
     if operand.logic_operator:
         subs = []
         for o in operand.sub_expr_list:
             subs.append(_calc_state(o))
         return calculator.calc_logic(operand.logic_operator, subs)
     else:
         return expr_data['data'][operand.fmtd_sub_expr_str]['state']
예제 #2
0
 def _calc_state(operand):
     if operand.logic_operator:
         subs = []
         for o in operand.sub_expr_list:
             subs.append(_calc_state(o))
         return calculator.calc_logic(operand.logic_operator, subs)
     else:
         return expr_data["data"][operand.fmtd_sub_expr_str]["state"]
 def test_calc_logic(self):
     op = 'AND'
     subs = ['ALARM', 'OK', 'ALARM', 'UNDETERMINED']
     self.assertEqual('OK', calculator.calc_logic(op, subs))
     subs = ['ALARM', 'UNDETERMINED', 'ALARM', 'UNDETERMINED']
     self.assertEqual('UNDETERMINED', calculator.calc_logic(op, subs))
     subs = ['ALARM', 'ALARM', 'ALARM']
     self.assertEqual('ALARM', calculator.calc_logic(op, subs))
     op = 'OR'
     subs = ['ALARM', 'OK', 'ALARM', 'UNDETERMINED']
     self.assertEqual('ALARM', calculator.calc_logic(op, subs))
     subs = ['UNDETERMINED', 'OK', 'UNDETERMINED']
     self.assertEqual('UNDETERMINED', calculator.calc_logic(op, subs))
     subs = ['OK', 'OK', 'OK']
     self.assertEqual('OK', calculator.calc_logic(op, subs))
     op = 'NOT'
     self.assertEqual('UNDETERMINED', calculator.calc_logic(op, subs))
 def test_calc_logic(self):
     op = 'AND'
     subs = ['ALARM', 'OK', 'ALARM', 'UNDETERMINED']
     self.assertEqual('OK', calculator.calc_logic(op, subs))
     subs = ['ALARM', 'UNDETERMINED', 'ALARM', 'UNDETERMINED']
     self.assertEqual('UNDETERMINED', calculator.calc_logic(op, subs))
     subs = ['ALARM', 'ALARM', 'ALARM']
     self.assertEqual('ALARM', calculator.calc_logic(op, subs))
     op = 'OR'
     subs = ['ALARM', 'OK', 'ALARM', 'UNDETERMINED']
     self.assertEqual('ALARM', calculator.calc_logic(op, subs))
     subs = ['UNDETERMINED', 'OK', 'UNDETERMINED']
     self.assertEqual('UNDETERMINED', calculator.calc_logic(op, subs))
     subs = ['OK', 'OK', 'OK']
     self.assertEqual('OK', calculator.calc_logic(op, subs))
     op = 'NOT'
     self.assertEqual('UNDETERMINED', calculator.calc_logic(op, subs))