DobotRPC


NameDobotRPC JSON
Version 4.7.4 PyPI version JSON
download
home_page
SummaryDobotlink communication module
upload_time2021-06-11 07:02:46
maintainer
docs_urlNone
authorsonglijun
requires_python
licenseApache Licence
keywords websocket json-rpc asyncio dobot dobotlink client server
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ***This version is relevant for Dobotlink 5.0.0 and python3.5+***

DobotRPC is a dobotlink communication module based on websocket and
JSON-RPC . It provides python ports to communicate with dobotlink and
allows developers to communicate with the GUI. 

APIS
-----

- RPCClient: RPCClient is a class that allows users to instantiate their own client, 
which uses WebSocket protocol to connect to a target IP and port, and then uses JSON format for data communication. 
  - set_ip: Version 4.7.4 or above is acceptable. The IP and port used to set the destination address.
- RPCServer: RPCServer is a class that allows users to instantiate their own server, 
which waits for a client to connect using the WebSocket protocol, and then uses JSON format for data communication.
The default port number is 9091.

- loggers: Provide an instantiated loggers interface. The user can call the following interfaces to do the configuration.
  - set_filename: Set log file name.
  - set_level: Set the log output level.
  - set_use_console: Set log output to the console.
  - set_use_file: Set log output to a file.
- DobotlinkAdapter: Provides an adapter for DobotLink RPC communication.
- NormalAdapter: Provides an adapter for normal RPC communication


Examples
--------

-  Users can communicate synchronously or asynchronously.The
   asynchronous mode is as follows:

```python

# Async demo
from DobotRPC import DobotlinkAdapter, RPCClient, loggers
# The asyncio module provides infrastructure for writing single-threaded concurrent code using coroutines, multiplexing I/O access over sockets and other resources, running network clients and servers, and other related primitives.
import asyncio


# Coroutines function
async def main(dobotlink_async):
    # Display information with Dobotlink
    await dobotlink_async.api.ShowMessage(title="Async Demo Message",
                                          message="Async Demo is running.")

    # Search for available ports
    res = await dobotlink_async.Magician.SearchDobot()

    # Get ports
    if len(res) < 1:
        return
    port_name = res[0]["portName"]

    # Connect
    await dobotlink_async.Magician.ConnectDobot(portName=port_name)

    # PTP
    await dobotlink_async.Magician.SetPTPCmd(portName=port_name,
                                             ptpMode=0,
                                             x=230,
                                             y=50,
                                             z=0,
                                             r=20)
    # Disconnect
    await dobotlink_async.Magician.DisconnectDobot(portName=port_name,
                                                   queueStop=True,
                                                   queueClear=True)


if __name__ == "__main__":
    loggers.set_level(loggers.DEBUG)
    # Get the Eventloop reference
    loop = asyncio.get_event_loop()
    # Initializes, connects to dobotlink, and is executed before the Loop runs
    dobotlink_async = DobotlinkAdapter(RPCClient(loop=loop), is_sync=False)
    # Perform coroutines
    loop.run_until_complete(main(dobotlink_async))

```
-  The synchronization mode is as follows:

```python

# Sync Demo
from DobotRPC import RPCClient, DobotlinkAdapter, loggers


def main(dobotlink_sync):
    # Display information with Dobotlink
    dobotlink_sync.api.ShowMessage(title="Sync Demo Message",
                                   message="Sync Demo is running.")

    # Search for available ports
    res = dobotlink_sync.Magician.SearchDobot()

    # Get ports
    if len(res) < 1:
        return
    port_name = res[0]["portName"]

    # Connect
    dobotlink_sync.Magician.ConnectDobot(portName=port_name)

    # PTP
    dobotlink_sync.Magician.SetPTPCmd(portName=port_name,
                                      ptpMode=0,
                                      x=230,
                                      y=50,
                                      z=0,
                                      r=20)

    # Disconnect
    dobotlink_sync.Magician.DisconnectDobot(portName=port_name)


if __name__ == "__main__":
    loggers.set_level(loggers.DEBUG)
    # Initialize, connect to dobotlink
    dobotlink_sync = DobotlinkAdapter(RPCClient(), is_sync=True)

    main(dobotlink_sync)

```

Installtion
-----------

To install DobotRPC, type:

```python
pip install DobotRPC
```

DobotRPC is a free software distributed under the Apache license

Usage
-----

- Users can use the API:
    loggers, RPCClient, DobotlinkAdapter, NetworkError, client, aip
-  Install Dobotlink [32bit](https://cdn.dobotlab.dobot.cc/release/DobotLinkSetup_32.exe) [64bit](https://cdn.dobotlab.dobot.cc/release/DobotLinkSetup_64.exe)
-  Right-click the Dobotlink icon and click ``help``, pop up a
   ``Dobotlink help documentation``.
-  You can guide by ``examples``, reference the
   ``Dobotlink help documentation``.
-  Then go ahead and develop your first python script.
            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "DobotRPC",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "websocket,JSON-RPC,asyncio,Dobot,Dobotlink,Client,Server",
    "author": "songlijun",
    "author_email": "songlijun@dobot.cc",
    "download_url": "https://files.pythonhosted.org/packages/d4/bf/bf90d6e03a951dbe20e53da4f527a0025d687c653174bde2296a0c0a8fff/DobotRPC-4.7.4.tar.gz",
    "platform": "any",
    "description": "***This version is relevant for Dobotlink 5.0.0 and python3.5+***\n\nDobotRPC is a dobotlink communication module based on websocket and\nJSON-RPC . It provides python ports to communicate with dobotlink and\nallows developers to communicate with the GUI. \n\nAPIS\n-----\n\n- RPCClient: RPCClient is a class that allows users to instantiate their own client, \nwhich uses WebSocket protocol to connect to a target IP and port, and then uses JSON format for data communication. \n  - set_ip: Version 4.7.4 or above is acceptable. The IP and port used to set the destination address.\n- RPCServer: RPCServer is a class that allows users to instantiate their own server, \nwhich waits for a client to connect using the WebSocket protocol, and then uses JSON format for data communication.\nThe default port number is 9091.\n\n- loggers: Provide an instantiated loggers interface. The user can call the following interfaces to do the configuration.\n  - set_filename: Set log file name.\n  - set_level: Set the log output level.\n  - set_use_console: Set log output to the console.\n  - set_use_file: Set log output to a file.\n- DobotlinkAdapter: Provides an adapter for DobotLink RPC communication.\n- NormalAdapter: Provides an adapter for normal RPC communication\n\n\nExamples\n--------\n\n-  Users can communicate synchronously or asynchronously.The\n   asynchronous mode is as follows:\n\n```python\n\n# Async demo\nfrom DobotRPC import DobotlinkAdapter, RPCClient, loggers\n# The asyncio module provides infrastructure for writing single-threaded concurrent code using coroutines, multiplexing I/O access over sockets and other resources, running network clients and servers, and other related primitives.\nimport asyncio\n\n\n# Coroutines function\nasync def main(dobotlink_async):\n    # Display information with Dobotlink\n    await dobotlink_async.api.ShowMessage(title=\"Async Demo Message\",\n                                          message=\"Async Demo is running.\")\n\n    # Search for available ports\n    res = await dobotlink_async.Magician.SearchDobot()\n\n    # Get ports\n    if len(res) < 1:\n        return\n    port_name = res[0][\"portName\"]\n\n    # Connect\n    await dobotlink_async.Magician.ConnectDobot(portName=port_name)\n\n    # PTP\n    await dobotlink_async.Magician.SetPTPCmd(portName=port_name,\n                                             ptpMode=0,\n                                             x=230,\n                                             y=50,\n                                             z=0,\n                                             r=20)\n    # Disconnect\n    await dobotlink_async.Magician.DisconnectDobot(portName=port_name,\n                                                   queueStop=True,\n                                                   queueClear=True)\n\n\nif __name__ == \"__main__\":\n    loggers.set_level(loggers.DEBUG)\n    # Get the Eventloop reference\n    loop = asyncio.get_event_loop()\n    # Initializes, connects to dobotlink, and is executed before the Loop runs\n    dobotlink_async = DobotlinkAdapter(RPCClient(loop=loop), is_sync=False)\n    # Perform coroutines\n    loop.run_until_complete(main(dobotlink_async))\n\n```\n-  The synchronization mode is as follows:\n\n```python\n\n# Sync Demo\nfrom DobotRPC import RPCClient, DobotlinkAdapter, loggers\n\n\ndef main(dobotlink_sync):\n    # Display information with Dobotlink\n    dobotlink_sync.api.ShowMessage(title=\"Sync Demo Message\",\n                                   message=\"Sync Demo is running.\")\n\n    # Search for available ports\n    res = dobotlink_sync.Magician.SearchDobot()\n\n    # Get ports\n    if len(res) < 1:\n        return\n    port_name = res[0][\"portName\"]\n\n    # Connect\n    dobotlink_sync.Magician.ConnectDobot(portName=port_name)\n\n    # PTP\n    dobotlink_sync.Magician.SetPTPCmd(portName=port_name,\n                                      ptpMode=0,\n                                      x=230,\n                                      y=50,\n                                      z=0,\n                                      r=20)\n\n    # Disconnect\n    dobotlink_sync.Magician.DisconnectDobot(portName=port_name)\n\n\nif __name__ == \"__main__\":\n    loggers.set_level(loggers.DEBUG)\n    # Initialize, connect to dobotlink\n    dobotlink_sync = DobotlinkAdapter(RPCClient(), is_sync=True)\n\n    main(dobotlink_sync)\n\n```\n\nInstalltion\n-----------\n\nTo install DobotRPC, type:\n\n```python\npip install DobotRPC\n```\n\nDobotRPC is a free software distributed under the Apache license\n\nUsage\n-----\n\n- Users can use the API:\n    loggers, RPCClient, DobotlinkAdapter, NetworkError, client, aip\n-  Install Dobotlink [32bit](https://cdn.dobotlab.dobot.cc/release/DobotLinkSetup_32.exe) [64bit](https://cdn.dobotlab.dobot.cc/release/DobotLinkSetup_64.exe)\n-  Right-click the Dobotlink icon and click ``help``, pop up a\n   ``Dobotlink help documentation``.\n-  You can guide by ``examples``, reference the\n   ``Dobotlink help documentation``.\n-  Then go ahead and develop your first python script.",
    "bugtrack_url": null,
    "license": "Apache Licence",
    "summary": "Dobotlink communication module",
    "version": "4.7.4",
    "split_keywords": [
        "websocket",
        "json-rpc",
        "asyncio",
        "dobot",
        "dobotlink",
        "client",
        "server"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "d338877a85009c029b05abafdc819d47",
                "sha256": "0aef1f8e73fa510b1c8cb5671e0ea46c495ded67e96813b47d8161cca0c70ffb"
            },
            "downloads": -1,
            "filename": "DobotRPC-4.7.4.tar.gz",
            "has_sig": false,
            "md5_digest": "d338877a85009c029b05abafdc819d47",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 10759,
            "upload_time": "2021-06-11T07:02:46",
            "upload_time_iso_8601": "2021-06-11T07:02:46.738362Z",
            "url": "https://files.pythonhosted.org/packages/d4/bf/bf90d6e03a951dbe20e53da4f527a0025d687c653174bde2296a0c0a8fff/DobotRPC-4.7.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-06-11 07:02:46",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "dobotrpc"
}
        
Elapsed time: 0.29374s