clickplc


Nameclickplc JSON
Version 0.8.3 PyPI version JSON
download
home_pagehttps://github.com/numat/clickplc/
SummaryPython driver for Koyo Ethernet ClickPLCs.
upload_time2024-05-05 17:02:38
maintainerAlex Ruddick
docs_urlNone
authorPatrick Fuller
requires_pythonNone
licenseGPLv2
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            clickplc
========

Python ≥3.8 driver and command-line tool for [Koyo Ethernet ClickPLCs](https://www.automationdirect.com/adc/Overview/Catalog/Programmable_Controllers/CLICK_Series_PLCs_(Stackable_Micro_Brick)).

<p align="center">
  <img src="https://www.automationdirect.com/microsites/clickplcs/images/expandedclick.jpg" />
</p>

Installation
============

```
pip install clickplc
```

Usage
=====

### Command Line

```
$ clickplc the-plc-ip-address
```

This will print all the X, Y, DS, and DF registers to stdout as JSON. You can pipe
this as needed. However, you'll likely want the python functionality below.

### Python

This uses Python ≥3.5's async/await syntax to asynchronously communicate with
a ClickPLC. For example:

```python
import asyncio
from clickplc import ClickPLC

async def get():
    async with ClickPLC('the-plc-ip-address') as plc:
        print(await plc.get('df1-df500'))

asyncio.run(get())
```

The entire API is `get` and `set`, and takes a range of inputs:

```python
>>> await plc.get('df1')
0.0
>>> await plc.get('df1-df20')
{'df1': 0.0, 'df2': 0.0, ..., 'df20': 0.0}
>>> await plc.get('y101-y316')
{'y101': False, 'y102': False, ..., 'y316': False}

>>> await plc.set('df1', 0.0)  # Sets DF1 to 0.0
>>> await plc.set('df1', [0.0, 0.0, 0.0])  # Sets DF1-DF3 to 0.0.
>>> await plc.set('y101', True)  # Sets Y101 to true
```

Currently, only X, Y, C, DS, DF, and CTD are supported:

|  |  |  |
|---|---|---|
| x | bool | Input point |
| y | bool | Output point |
| c | bool | (C)ontrol relay |
| df | float | (D)ata register, (f)loating point |
| ds | int16 | (D)ata register, (s)igned int |
| ctd | int32 | (C)oun(t)er Current Values, (d)ouble int |

We personally haven't needed to use the other categories, but they are
straightforward to add if needed.

### Tags / Nicknames

Recent ClickPLC software provides the ability to export a "tags file", which
contains all variables with user-assigned nicknames. The tags file can be used
with this driver to improve code readability. (Who really wants to think about
modbus addresses and register/coil types?)

To export a tags file, open the ClickPLC software, go to the Address Picker,
select "Display MODBUS address", and export the file.

Once you have this file, simply pass the file path to the driver. You can now
`set` variables by name and `get` all named variables by default.

```python
async with ClickPLC('the-plc-ip-address', 'path-to-tags.csv') as plc:
    await plc.set('my-nickname', True)  # Set variable by nickname
    print(await plc.get())  # Get all named variables in tags file
```

Additionally, the tags file can be used with the commandline tool to provide more informative output:
```
$ clickplc the-plc-ip-address tags-filepath
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/numat/clickplc/",
    "name": "clickplc",
    "maintainer": "Alex Ruddick",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": "alex@ruddick.tech",
    "keywords": null,
    "author": "Patrick Fuller",
    "author_email": "pat@numat-tech.com",
    "download_url": "https://files.pythonhosted.org/packages/06/20/61ce15fc556bdbb5fc7a67a09f578fd7a8620dcb292885849467a021dfcc/clickplc-0.8.3.tar.gz",
    "platform": null,
    "description": "clickplc\n========\n\nPython \u22653.8 driver and command-line tool for [Koyo Ethernet ClickPLCs](https://www.automationdirect.com/adc/Overview/Catalog/Programmable_Controllers/CLICK_Series_PLCs_(Stackable_Micro_Brick)).\n\n<p align=\"center\">\n  <img src=\"https://www.automationdirect.com/microsites/clickplcs/images/expandedclick.jpg\" />\n</p>\n\nInstallation\n============\n\n```\npip install clickplc\n```\n\nUsage\n=====\n\n### Command Line\n\n```\n$ clickplc the-plc-ip-address\n```\n\nThis will print all the X, Y, DS, and DF registers to stdout as JSON. You can pipe\nthis as needed. However, you'll likely want the python functionality below.\n\n### Python\n\nThis uses Python \u22653.5's async/await syntax to asynchronously communicate with\na ClickPLC. For example:\n\n```python\nimport asyncio\nfrom clickplc import ClickPLC\n\nasync def get():\n    async with ClickPLC('the-plc-ip-address') as plc:\n        print(await plc.get('df1-df500'))\n\nasyncio.run(get())\n```\n\nThe entire API is `get` and `set`, and takes a range of inputs:\n\n```python\n>>> await plc.get('df1')\n0.0\n>>> await plc.get('df1-df20')\n{'df1': 0.0, 'df2': 0.0, ..., 'df20': 0.0}\n>>> await plc.get('y101-y316')\n{'y101': False, 'y102': False, ..., 'y316': False}\n\n>>> await plc.set('df1', 0.0)  # Sets DF1 to 0.0\n>>> await plc.set('df1', [0.0, 0.0, 0.0])  # Sets DF1-DF3 to 0.0.\n>>> await plc.set('y101', True)  # Sets Y101 to true\n```\n\nCurrently, only X, Y, C, DS, DF, and CTD are supported:\n\n|  |  |  |\n|---|---|---|\n| x | bool | Input point |\n| y | bool | Output point |\n| c | bool | (C)ontrol relay |\n| df | float | (D)ata register, (f)loating point |\n| ds | int16 | (D)ata register, (s)igned int |\n| ctd | int32 | (C)oun(t)er Current Values, (d)ouble int |\n\nWe personally haven't needed to use the other categories, but they are\nstraightforward to add if needed.\n\n### Tags / Nicknames\n\nRecent ClickPLC software provides the ability to export a \"tags file\", which\ncontains all variables with user-assigned nicknames. The tags file can be used\nwith this driver to improve code readability. (Who really wants to think about\nmodbus addresses and register/coil types?)\n\nTo export a tags file, open the ClickPLC software, go to the Address Picker,\nselect \"Display MODBUS address\", and export the file.\n\nOnce you have this file, simply pass the file path to the driver. You can now\n`set` variables by name and `get` all named variables by default.\n\n```python\nasync with ClickPLC('the-plc-ip-address', 'path-to-tags.csv') as plc:\n    await plc.set('my-nickname', True)  # Set variable by nickname\n    print(await plc.get())  # Get all named variables in tags file\n```\n\nAdditionally, the tags file can be used with the commandline tool to provide more informative output:\n```\n$ clickplc the-plc-ip-address tags-filepath\n```\n\n\n",
    "bugtrack_url": null,
    "license": "GPLv2",
    "summary": "Python driver for Koyo Ethernet ClickPLCs.",
    "version": "0.8.3",
    "project_urls": {
        "Homepage": "https://github.com/numat/clickplc/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6eec5b07da03930a41f8a3a536746ff96bd9662b047053e55c0e04323f03191a",
                "md5": "c0808e01d2dc81c85e9cebe699c20d71",
                "sha256": "0a9f206064a6fff4ff3601a627b643a1eb603543dc7efb2a91256a345aa6ebd2"
            },
            "downloads": -1,
            "filename": "clickplc-0.8.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c0808e01d2dc81c85e9cebe699c20d71",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 18639,
            "upload_time": "2024-05-05T17:02:36",
            "upload_time_iso_8601": "2024-05-05T17:02:36.248621Z",
            "url": "https://files.pythonhosted.org/packages/6e/ec/5b07da03930a41f8a3a536746ff96bd9662b047053e55c0e04323f03191a/clickplc-0.8.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "062061ce15fc556bdbb5fc7a67a09f578fd7a8620dcb292885849467a021dfcc",
                "md5": "91367ec92a66e821d6adc5bcf7b36410",
                "sha256": "8e8669bd9db8e04a0c7b7eb8612930c53a3b3e7aaf43961ae6bb445864c3912b"
            },
            "downloads": -1,
            "filename": "clickplc-0.8.3.tar.gz",
            "has_sig": false,
            "md5_digest": "91367ec92a66e821d6adc5bcf7b36410",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 18480,
            "upload_time": "2024-05-05T17:02:38",
            "upload_time_iso_8601": "2024-05-05T17:02:38.185102Z",
            "url": "https://files.pythonhosted.org/packages/06/20/61ce15fc556bdbb5fc7a67a09f578fd7a8620dcb292885849467a021dfcc/clickplc-0.8.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-05 17:02:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "numat",
    "github_project": "clickplc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "clickplc"
}
        
Elapsed time: 0.26720s