Constant Table ============== Read ConstTable --------------- Instruct the data logger to publish the list of constants defined in CRBasic ConstTable. **Topic Structure:** ``/cc//constTable`` .. admonition:: Properties - {*string*} ``{}`` empty json payload **Example Command** :guilabel:`Subscribe` ``cs/v2/cc/ABCD-EFGH-1234/constTable`` .. code-block:: json { } **Response** :guilabel:`Publish` ``cs/v2/cr/ABCD-EFGH-1234/constTable`` .. code-block:: json { "constTable": { "name": "Const_Table", "model": "CR1000X", "serialNumber": "70021", "clientID": "7GY3-DZYK-KBWF" }, "constants": { "THERMAL_RATIO": "1.8", "THAW_OFFSET": "32" } } Edit Constant Table ------------------- Instruct the data logger to edit and apply new values to the ConstTable in the CRBasic Program. The ConstTable is available for editing only when the Name parameter is set. **Topic Structure:** ``/cc//editConst`` .. admonition:: Properties - ``"CONST_NAME":`` {*string*} Value to be applied Example entries: The JSON ``keys`` and ``values`` must both be of type **string**. The data logger will cast the string values to their initialized types when updating the constants. - ``"THRESHOLD": "10.5"`` — sets a **float** - ``"SENSOR_ID": "99"`` — sets an **integer** - ``"STATION_NAME": "North 40"`` — sets a **string** The ``editConst`` command relies entirely on the client to ensure that each constant is updated with an appropriate value. If an invalid or empty value is provided, the resulting CRBasic program may produce undefined constant declarations, which will result in compile errors. Example of an invalid entry: - ``"THRESHOLD": "ABC"`` — sets a constant that was initialized as a **float** to a **string** ``"ABC"`` This would modify the CRBasic code to: ``Const THRESHOLD = ABC`` The program may fail to compile because **ABC is not defined**. **Example Command** :guilabel:`Subscribe` ``cs/v2/cc/ABCD-EFGH-1234/editConst`` .. code-block:: json { "TEAM_NAME": "Dodgers", "PLAYER_NAME": "Freeman", "PLAYER_NUMBER": "5", "BAT_AVG_BENCHMARK": "0.333" } **Progress** Progress of the editConst will be published on the state topic. :guilabel:`Publish` ``cs/v2/state/ABCD-EFGH-1234`` - Applying New Values .. code-block:: json { "clientId": "ABCD-EFGH-1234", "state": "offline", "reason": "Changed constants, recompiling" } **Response** :guilabel:`Publish` ``cs/v2/cr/ABCD-EFGH-1234/editConst`` In addition to the state topic messages, the data logger will publish a final result of the process on the ``cr`` topic. .. code-block:: json { "success": "Editing constants succeeded" } .. admonition:: Error Responses - ``{"error": "Constant table does not exist or has no name"}`` - ``{"error": " does not exist"}`` Will immediately quit and report the non-existent constant. - ``{"error": "No constant table changes (Empty request)"}`` - ``{"error": "No constant table changes"}`` - ``{"error": "Includes value that is too large (max 79 chars)"}`` - ``{"error": "Constant values must be of type string"}`` - ``{"error": "Editing constants failed"}``