Code Monkey home page Code Monkey logo

8.1's Introduction

ignition-api 8.1

Downloads Code style: black Join us on GitHub discussions

ignition-api is a Python package that allows developers to get code completion for Ignition Scripting API scripting functions in their IDE of choice.

Table of contents

Prerequisites

Before you begin, ensure you have met the following requirements:

Installation and usage

To use ignition-api, you may install it by doing any of the following.

Installing with pip

The preferred method is to install it by running pip. It requires Python 2.7.18.

python2 -m pip install ignition-api

This will install it as package to your Python installation, which will allow you to call Ignition Scripting functions from Python's REPL, and get code completion using an IDE such as PyCharm and Visual Studio Code.

$ python2
Python 2.7.18 (default, Nov  9 2020, 16:23:15)
[GCC Apple LLVM 12.0.0 (clang-1200.0.32.21)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> import system.util
>>> print(system.util.__doc__)
Utility Functions.

The following functions give you access to view various Gateway and
Client data, as well as interact with other various systems.

>>> system.util.beep()
>>> quit()

And to uninstall:

python2 -m pip uninstall ignition-api

Downloading from releases

You may also download the code targeted to your desired version from releases and add it as a dependency to your scripting project.

Using as a dependency in PyCharm

To include ignition-api as a dependency in PyCharm, you will need to attach it to your project.

  1. Clone the repo or download from releases
  2. With your project open where you want to include ignition-api, navigate to File > Open and select the ignition-api project folder
  3. Choose Attach when prompted
  4. Under the ignitition-api project folder, right-click on the src/ folder and choose Mark Directory as > Sources Root

Project structure

Packages

This project consists of the following packages:

  • com.inductiveautomation
  • java
  • javax
  • org
  • system

com.inductiveautomation

This package includes supporting Inductive Automation's classes and interfaces. For more information, see documentation here: https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.42/index.html.

java/javax

These packages include supporting Java classes and interfaces. For more information, see documentation here: https://docs.oracle.com/en/java/javase/17/docs/api/index.html.

org.apache

This package includes supporting classes and interfaces from Apache Commons Math API. For more information, see documentation here: https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/index.html

org.json

This package includes supporting classes and interfaces from the Inductive Automation's org.json package, see documentation here: https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.42/org/json/package-summary.html

org.python

This package includes supporting Jython classes and interfaces. For more information, see documentation here: https://www.javadoc.io/doc/org.python/jython-standalone/2.7.3/index.html.

org.slf4j

This package includes supporting classes and interfaces from SLF4J API Module. For more information, see documentation here: https://www.javadoc.io/doc/org.slf4j/slf4j-api/1.7.26/overview-summary.html.

system

This package includes all Ignition Scripting Functions. For more information, see documentation here: https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions.

Contributing

See CONTRIBUTING.md.

Discussions

Feel free to post your questions and/or ideas at Discussions.

Contributors

Thanks to everyone who has contributed to this project.

Up-to-date list of contributors can be found here: CONTRIBUTORS.

License

See the LICENSE.

Code of conduct

This project has adopted the Microsoft Open Source Code of Conduct.

8.1's People

Contributors

cesarcoatl avatar coatl-bot avatar dependabot[bot] avatar ethanejohnsons avatar keith-gamble avatar pre-commit-ci[bot] avatar sourcery-ai[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

8.1's Issues

Should `AlarmQueryResultImpl` inherit from `List`?

Describe the bug
Should AlarmQueryResultImpl inherit from List?

https://github.com/ignition-api/8.1-stubs/blob/895288e8b0e1f61a0d9c826b16a674ebd53c12cd/stubs/com/inductiveautomation/ignition/common/alarming/query/__init__.pyi#L7-L10

To Reproduce

results = system.alarm.queryStatus(state=["ActiveUnacked", "ActiveAcked"], all_properties = props)
for x in range(len(results)):
    print(results[x])
Argument of type "AlarmQueryResultImpl" cannot be assigned to parameter "obj" of type "Sized" in function "len"
  "AlarmQueryResultImpl" is incompatible with protocol "Sized"
    "__len__" is not present

"__getitem__" method not defined on type "AlarmQueryResultImpl"

Expected behavior
No type error for working code.

Add ApplicationScope class from com.inductiveautomation.common.model

Is your feature request related to a problem? Please describe.

In some scripts, the end-user might want to check the scope of the application. In order to accomplish this they might use ApplicationScope.

See here: https://forum.inductiveautomation.com/t/detect-vision-or-perspective/44636/2?u=thecesrom

Describe the solution you'd like

Add ApplicationScope under com.inductiveautomation.common.model

Describe alternatives you've considered

Additional context

[BUG] ImportError: cannot import name BrowseFilter when importing system.tag

Describe the bug
When we import system.tag on PyCharm's Python Console or IDLE we get the following error:

$ python                                     
Python 2.7.18 (default, Dec 29 2022, 09:23:27) 
[GCC Apple LLVM 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import system.tag
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/thecesrom/.venvs/SCADA/lib/python2.7/site-packages/system/tag.py", line 43, in <module>
    from com.inductiveautomation.ignition.common.browsing import Results
  File "/Users/thecesrom/.venvs/SCADA/lib/python2.7/site-packages/com/inductiveautomation/ignition/common/browsing/__init__.py", line 9, in <module>
    from com.inductiveautomation.ignition.common.model.values import QualityCode
  File "/Users/thecesrom/.venvs/SCADA/lib/python2.7/site-packages/com/inductiveautomation/ignition/common/model/__init__.py", line 11, in <module>
    from com.inductiveautomation.ignition.common.tags.model import TagManager
  File "/Users/thecesrom/.venvs/SCADA/lib/python2.7/site-packages/com/inductiveautomation/ignition/common/tags/model/__init__.py", line 6, in <module>
    from com.inductiveautomation.ignition.common.browsing import BrowseFilter
ImportError: cannot import name BrowseFilter

To Reproduce

Install ignition-api on a Python2 virtual environment, and import system.tag on an interactive session (IDLE).

Expected behavior

It should run without issues.

Screenshots

Additional context

Affected versions: 8.1.24.post6, 8.1.25.post6, 8.1.26.post2, 8.1.27, 8.1.28, 8.1.29, 8.1.30.

Ref: https://github.com/orgs/ignition-api/discussions/8, originally reported by @golf-n-code

smtp argument should be optional in system.net.sendEmail

Is your feature request related to a problem? Please describe.

When using smtpProfile smtp, username and password keyword arguments are ignored; the only "truly" required argument is fromAddr.

Describe the solution you'd like

Mark smtp as optional.

Describe alternatives you've considered

Additional context

Importing certain `system` modules results in `ImportError: cannot import name Path`

Describe the bug

When importing the following system modules on PyCharm's Python Console, I get an ImportError exception.

To Reproduce

Open PyCharm's Python Console on a project which depends on ignition-api/8.1 and import any of the following system modules:

  • alarm
  • dataset
  • db
  • device
  • eam
  • gui
  • nav
  • opc
  • opchda
  • perspective
  • report
  • roster
  • secsgem
  • sfc
  • tag
  • twilio
  • user
  • util

Expected behavior

There should be no error.

Screenshots

Additional context

This is caused by a circular import that goes undetected by pylint.

Add java.awt.GridLayout

Is your feature request related to a problem? Please describe.

The GridLayout class is missing from the java.awt package.

Describe the solution you'd like

Add it.

Describe alternatives you've considered

None.

Additional context

[FEATURE] Add classes implementing TagPath

Is your feature request related to a problem? Please describe.

Feature request.

Describe the solution you'd like

Add all classes implementing TagPath.

Describe alternatives you've considered

Additional context

Ref: #104

[FEATURE] Modify type hints on __iter__ for JythonSequence et.al.

Is your feature request related to a problem? Please describe.

With the latest changes to JythonSequence's __iter__ type hints we are getting the following error in incendium:

$ mypy --py2 src
src/incendium/dataset.py:152: error: Invalid index type "Union[str, unicode]" for "PyObject"; expected type "Union[int, PyObject]"
src/incendium/dataset.py:154: error: Invalid index type "Union[str, unicode]" for "PyObject"; expected type "Union[int, PyObject]"
Found 2 errors in 1 file (checked 16 source files)

Describe the solution you'd like

We believe Iterator[PyObject], while accurate, should be changed to Iterator[Any].

Allow unicode type on SProcCall functions

Is your feature request related to a problem? Please describe.

In certain modules, when unicode_literals is imported from __future__ PyCharm warns our users about potentially passing the "wrong" type.

Describe the solution you'd like

Change from:

def getOutParamValue(self, param: Union[int, str]) -> Any: ...
def registerInParam(
    self, param: Union[int, str], typeCode: int, value: Any
 ) -> None: ...
def registerOutParam(self, param: Union[int, str], typeCode: int) -> None: ...

To:

def getOutParamValue(self, param: Union[int, String]) -> Any: ...
def registerInParam(
    self, param: Union[int, String], typeCode: int, value: Any
 ) -> None: ...
def registerOutParam(self, param: Union[int, String], typeCode: int) -> None: ...

Since String is an alias for Union[str, unicode].

Describe alternatives you've considered

Additional context

See ignition-devs/incendium#64

Remove class aliases from `system` modules

Is your feature request related to a problem? Please describe.

These class aliases were "necessary" before we added type hints. Now with type hints these are not required as they pollute the stubs package.

Describe the solution you'd like

Take system.util lines 72-73:

PyDataSet = DatasetUtilities.PyDataSet
RequestImpl = SystemUtilities.RequestImpl

Describe alternatives you've considered

Additional context

Add `system.db.*` constants to `__all__`

Is your feature request related to a problem? Please describe.

When I run mypy against incendium I get the following errors regarding system.db constants:

$ mypy src
src/incendium/db.py:166: error: Module has no attribute "INTEGER"
src/incendium/db.py:253: error: Module has no attribute "BIT"

Describe the solution you'd like

In order to make those constants available on ignition-api-stubs, all constants must be added to __all__.

Describe alternatives you've considered

Additional context

Add java.nio.file Files and Paths

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

Describe alternatives you've considered

Additional context

Add javax.swing.JPasswordField

Is your feature request related to a problem? Please describe.

The JPasswordField class is missing from javax.swing package.

Describe the solution you'd like

Add it.

Describe alternatives you've considered

None.

Additional context

Add getNodeId() to OPCBrowseElement

Is your feature request related to a problem? Please describe.

New in 8.1.20

An OPCBrowseElement’s server node ID can now be obtained using the getNodeId method call on the system.opc.browseServer function.

Describe the solution you'd like

Describe alternatives you've considered

Additional context

Add type hints to all PyUser functions

Is your feature request related to a problem? Please describe.

Some PyUser functions are missing type hints, and I get the following error when I run mypy against incendium:

$ mypy src
src/incendium/user.py:39: error: "getOrDefault" of "PyUser" does not return a value

Describe the solution you'd like

Add type hints to all PyUser functions

Describe alternatives you've considered

Additional context

mypy error: Argument 1 to "toPyDataSet" has incompatible type "Dataset"; expected "BasicDataset"

Describe the bug

system.dataset.toPyDataSet and the underlying method check if the dataset is of type BasicDataset, it should accept any class implementing Dataset.

Classes implementing Dataset:

AbstractDataset, ArrayDataset, BasicDataset, BasicStreamingDataset, CacheAggregateDataset, ColumnAttributesDataSet, ColumnFilteredDataSet, DatasetUtilities.PyDataSet, JsonDataset, MutableDataset, NonSerializingDataset, OptimizedDataSet, RowFilteredDataSet, StreamingDataset, TimeMaskedDataset

To Reproduce

Anything other than an instance of BasicDataset throws the same error.

Expected behavior

Allow instance of a class which implements the Dataset interface.

Screenshots

Additional context

AttributeError: 'module' object has no attribute '_copy_dispatch'

Describe the bug

Originally reported here: https://github.com/thecesrom/Ignition/issues/53

When we import typing at java.lang, install the package, and run python2 -m pip list we get the following error:

AttributeError: 'module' object has no attribute '_copy_dispatch'

To Reproduce

On a dev environment add type hints to java.lang, and try to install the package locally.

  1. Clone the repo
  2. Add type hints that would require importing the typing module
  3. Install the package locally on a virtual environment
  4. Run python2 -m pip list

Expected behavior

We should be able to add type hints and not get an error like this.

Screenshots

Additional context

The exception is thrown because we are mocking org.python.core and line 60 at copy.py is causing the exception:

try:
    from org.python.core import PyStringMap
except ImportError:
    PyStringMap = None

Add java.io.IOException

Is your feature request related to a problem? Please describe.

Describe the solution you'd like

Describe alternatives you've considered

Additional context

[FEATURE] how to get the value of tag

I write code like this
tagR = system.tag.readBlocking(['[default]xxx/xxx/xxx/xxx'])
tagR0=tagR[0]
testValue =tagR0.getValue()
print(tagR0.getValue())
but I get the value is java.lang.object ,how to convert it to the python base type ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.