Orange-OpenSource / its-client

This Intelligent Transportation Systems (ITS) MQTT client based on the JSon ETSI specification transcription provides a ready to connect project for the mobility (connected and autonomous vehicles, road side units, vulnerable road users,...). Let's connect your device or application to our Intelligent Transport Systems (ITS) platform!
MIT License
7 stars 8 forks source link

python: add abstraction for the RoR, and advertise a RoR #83

Closed ymorin-orange closed 1 year ago

ymorin-orange commented 1 year ago

New features:


How to test:

  1. Prerequisites:

    • an MQTT broker running
    • an mqtt client listening on the info topic, like: mosquitto_sub -h BROKER -p PORT -u USERNAME -P PASSWORD -t info
  2. run the its-quadkey test-suite:

    $ cd ${ITS_CLIENT_GIT}/python/its-quadkeys
    $ ./quadkeys-test
  3. install its-quadkeys and its-info:

    $ cd ${ITS_CLIENT_GIT}/python/
    $ pip3 wheel -w wheels ./its-quadkeys/ ./its-info/
    $ pip3 install wheels/*.whl

    Also take note of where the its-info script has been installed (e.g. ${HOME}/.local/bin); replicate that path in the following tests.

  4. run its-info without a RoR:

    • adapt the configuration file its-info.cfg to match your setup, esp. the MQTT settings and use a short period (e.g. 10s), but leave the RoR section empty
    • run its-info:
      $ ${HOME}/.local/bin/its-info --config its-info.cfg
    • stop its-info (with Ctrl-C)
  5. run its-info with a RoR:

    • update the configuration file its-info.cfg with a RoR section:
      [RoR]
      type = static
      path = /tmp/its-info-ror.json
      reload = yes
    • run its-info:
      $ ${HOME}/.local/bin/its-info --config its-info.cfg
    • wait for the next MQTT message
    • create a RoR file in /tmp/its-info-ror.json; a RoR file is just a json list of strings, each string a quadkey:
      [
        "03131",
        "03133",
        "1202"
      ]
    • wait for the next MQTT message
    • update a RoR file in /tmp/its-info-ror.json, add, remove, and/or modify the quadkeys:
      [
        "1202",
        "1200",
        "12011"
      ]
    • wait for the next MQTT message
    • remove /tmp/its-info-ror.json
    • wait for the next MQTT message
    • stop its-info (with Ctrl-C)

Expected results:

  1. the MQTT broker and MQTT clents are running
  2. the test suite passes:
    QuadKey in: OK
    QuadKey not in: OK
    QuadKey split (depth): OK
    QuadKey split (extra_depth): OK
    QuadKey neighbours: OK
    QuadZone optimise: OK
    QuadZone optimise (merge-reduce): OK
    QuadZone serialise: OK
    QuadZone neighbours (depth 7): OK
    QuadZone neighbours (depth 6): OK
    QuadZone addition (neighbours 7): OK
    QuadZone addition (neighbours 6): OK
    QuadZone intersection: OK
    QuadZone substraction (neighbours 7): OK
    QuadZone substraction (neighbours 6): OK
    QuadZone substraction (quadkeys): OK
    QuadZone symmetric substraction (xor): OK
  3. the python modules are installed:
    Processing ./its-quadkeys
      Preparing metadata (setup.py) ... done
    Processing ./its-info
      Preparing metadata (setup.py) ... done
    Collecting linuxfd==1.5
      Downloading linuxfd-1.5.tar.gz (14 kB)
      Preparing metadata (setup.py) ... done
    Collecting netifaces==0.11.0
      Downloading netifaces-0.11.0.tar.gz (30 kB)
      Preparing metadata (setup.py) ... done
    Collecting paho-mqtt==1.6.1
      Downloading paho-mqtt-1.6.1.tar.gz (99 kB)
         ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 99.4/99.4 KB 3.5 MB/s eta 0:00:00
      Preparing metadata (setup.py) ... done
    Building wheels for collected packages: its-quadkeys, its-info, linuxfd, netifaces, paho-mqtt
      Building wheel for its-quadkeys (setup.py) ... done
      Created wheel for its-quadkeys: filename=its_quadkeys-0.0.0-py3-none-any.whl size=6332 sha256=6607bcb1acc265c64af10b2ee7fb670f4e98dbb673549012c32e4d5fb796d1a3
      Stored in directory: /home/foo/.cache/pip/wheels/33/82/1a/cee230c08b5b4815b3921b8b1c119bbf3ac23ed747ac8f0ca6
      Building wheel for its-info (setup.py) ... done
      Created wheel for its-info: filename=its_info-0.0.0-py3-none-any.whl size=4441 sha256=74422eb0cd9107892dcc959e2f0ed46633ff1e1b0008d0d996988645bcb68a3a
      Stored in directory: /home/foo/.cache/pip/wheels/a5/13/37/641ec846d142b5417b69bd9d9c42dbba19dc7c814e27c92a7e
      Building wheel for linuxfd (setup.py) ... done
      Created wheel for linuxfd: filename=linuxfd-1.5-cp310-cp310-linux_x86_64.whl size=54043 sha256=14676de4dbc79103c68084716f58657e0fd19a80e48a50334d0071c15ac4bc6c
      Stored in directory: /home/foo/.cache/pip/wheels/47/a9/1c/0d9819f7f8440c2017d5b8d96f52cc49f519d2b302a2a769fd
      Building wheel for netifaces (setup.py) ... done
      Created wheel for netifaces: filename=netifaces-0.11.0-cp310-cp310-linux_x86_64.whl size=35018 sha256=e48db67f0d392dbd50f5469260030214972bb512fde46a6dbf2c8e87c963c6ee
      Stored in directory: /home/foo/.cache/pip/wheels/48/65/b3/4c4cc6038b81ff21cc9df69f2b6774f5f52e23d3c275ed15aa
      Building wheel for paho-mqtt (setup.py) ... done
      Created wheel for paho-mqtt: filename=paho_mqtt-1.6.1-py3-none-any.whl size=62133 sha256=8b342a920d6d61a7acf3630b1becc3668d91eaa43430047b31b697dbf9f07fca
      Stored in directory: /home/foo/.cache/pip/wheels/8b/bb/0c/79444d1dee20324d442856979b5b519b48828b0bd3d05df84a
    Successfully built its-quadkeys its-info linuxfd netifaces paho-mqtt
    Defaulting to user installation because normal site-packages is not writeable
    Processing ./wheels/its_info-0.0.0-py3-none-any.whl
    Processing ./wheels/its_quadkeys-0.0.0-py3-none-any.whl
    Processing ./wheels/linuxfd-1.5-cp310-cp310-linux_x86_64.whl
    Processing ./wheels/netifaces-0.11.0-cp310-cp310-linux_x86_64.whl
    Processing ./wheels/paho_mqtt-1.6.1-py3-none-any.whl
    Installing collected packages: paho-mqtt, netifaces, linuxfd, its-quadkeys, its-info
      WARNING: The script its-info is installed in '/home/foo/.local/bin' which is not on PATH.
      Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
    Successfully installed its-info-0.0.0 its-quadkeys-0.0.0 linuxfd-1.5 netifaces-0.11.0 paho-mqtt-1.6.1
  4. the MQTT client dumps the info messages, without a RoR, e.g.:
    {
      "type": "broker",
      "version": "1.2.0",
      "instance_id": "ID",
      "instance_type": "local",
      "running": true,
      "timestamp": 1686809196359,
      "validity_duration": 20
    }
  5. the MQTT client dumps the info messages, with or without the RoR, depending on the presence and content of the RoR file:
    • first, messages without a RoR are reported
    • then messages with the first RoR (aka _servicearea):
      {
        "type": "broker",
        "version": "1.2.0",
        "instance_id": "ID",
        "instance_type": "local",
        "running": true,
        "timestamp": 1686809196359,
        "validity_duration": 20,
        "service_area": {
          "type": "tiles",
          "quadkeys": [
            "03131",
            "03133",
            "1202"
          ]
        }
      }
    • then messages with the first RoR:
      {
        "type": "broker",
        "version": "1.2.0",
        "instance_id": "ID",
        "instance_type": "local",
        "running": true,
        "timestamp": 1686809196359,
        "validity_duration": 20,
        "service_area": {
          "type": "tiles",
          "quadkeys": [
            "1200",
            "12011",
            "1202"
          ]
        }
      }
    • then messages without a RoR