No relevant resource is found in the selected language.

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Read our privacy policy>Search

Reminder

To have a better experience, please upgrade your IE browser.

upgrade

Configuration Guide - Device Management

S2720, S5700, and S6720 V200R013C00

This document describes the configurations of Device Management, including device status query, hardware management, Stack, SVF, cloud-based management, PoE, monitoring interface, OPS, energy-saving management, information center, fault management, NTP, synchronous ethernet, PTP.
Rate and give feedback:
Huawei uses machine translation combined with human proofreading to translate this document to different languages in order to help you better understand the content of this document. Note: Even the most advanced machine translation cannot match the quality of professional translators. Huawei shall not bear any responsibility for translation accuracy and it is recommended that you refer to the English document (a link for which has been provided).
Supporting Resident Script

Supporting Resident Script

Interface Name

Supporting resident script

Application Phase

Execution phase

API Prototype

result1_value, result2_description = ops.wait()

Description

None

Return Value

The result1_value and result2_description in the API prototype indicate return values.

The first return value 0 indicates that an event is executed successfully, and the first return value 1 indicates that an event fails to be executed.

The second return value is a string of characters indicating the results.

Usage Description

In most circumstances, a process needs to be started before and stopped after a Python script is executed. It takes some time to start and stop a process. If the subscription event in the script is triggered for multiple times, the device needs to repeat starting a process before executing the action defined in the subscription phase and stopping the process after the action is complete. In this case, you can use a resident script to reduce the time a device waits for a process to start or stop.

A resident script is usually used together with a cycle counter. After a subscription event is matched, the device starts a process when it performs the action for the first time. After this action is complete, the process is suspended and the number of cycles decreases by one. When the event is matched again, the next action is triggered, and the number of cycles is decreased by one again. This step is repeated until the number of cycles in the script reaches 0, at which point the process is stopped.

You can use the Returning Event Execution Results API to return the result, and then suspend the process and wait for the next event. In this way, the resident script can be used to process events.

Example

When a subscription event is matched for the first time, the device starts a process and displays the message alarm generated. Then the process enters the waiting state and waits for the next time the subscribed event is matched. After the event is matched five times and the message alarm generated is displayed five times, the device displays the message end and stops the process.

a = 5
while a > 0:
	a = a - 1
	print("alarm generated")
	status, err_str = ops.wait()     # The message alarm generated is displayed, the process enters the waiting status and waits for the event to be matched for the next time.
print 'end'
return 0
Translation
Download
Updated: 2019-04-20

Document ID: EDOC1100065674

Views: 42664

Downloads: 360

Average rating:
This Document Applies to these Products
Related Documents
Related Version
Share
Previous Next