Examples of using the Python Library

Describes examples of using Python libraries.

Use the examples below to familiarize yourself with how to use the Python libraries.

Python Library: Arrow

Arrow is a Python library that offers a sensible and human-friendly approach to creating, manipulating, formatting and converting dates, times and timestamps.

 

  1. Type the command below at a command prompt to install Arrow. The process of adding a Python library is well documented in the parent article of the current page (the "Adding Python Library" page), so please refer to it.

pip install arrow --trusted-host pypi.org

 

  1. Open CimonD [Scripts], add a script page, and import the Arrow library you installed.

image-20240711-010747.png
Import Arrow library

 

 

  1. Use functions supported by the Arrow library. For more information on supported functions, see the official documentation, which has plenty of example code.

image-20240711-013740.png
Use functions of Arrow library
scada = cimon.Scada(port) import arrow present = arrow.now('Asia/Seoul') morning = present.replace(hour=9, minute=0) distance = present.humanize(morning, only_distance=True, granularity=["hour","minute"],locale='ko-kr') scada.SetTagVal("STR_TAG",distance)

 

 

  1. Write an command expression to execute a Python script in the CimonD object.

 

  1. Check that the Python script is working properly in the web client.