Multi-Condition Association

Function Description

The OPS allows you to associate multiple conditions with an OPS object.

Command Prototype

opsObj.correlate("correlation expression")

Parameter Description

Table 1 describes the parameters supported by multi-condition association APIs.
Table 1 Parameters supported by multi-condition association APIs




Specifies an OPS object. It is obtained through ops.ops() instantiation.

correlation expression

The value is a string of a maximum of 128 characters, consisting of a condition identifier string and an operator (and, or, or andnot). Operators and and andnot have the same priority, which is greater than that of or.

Description of Return Values

  • First return value: The value 0 indicates a success, and the value 1 indicates a failure.
  • Second return value: This value describes success or failure reasons, expressed in a character string.


import ops

def ops_condition(_ops): 
       ret1, reason1 = _ops.cli.subscribe("con1","display device",True,True,False,20)
       ret2, reason2 = _ops.cli.subscribe("con2","display this",True,True,False,20)
       _ops.correlate("con1 and con2")

def ops_execute(_ops): 
       _ops.terminal.write("Hello world!",None) 
       return 0

When con1 and con2 are both met, the assistant is triggered.

Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >