diff --git a/data/pid_data.py b/data/pid_data.py index c3835c19..1545fce4 100644 --- a/data/pid_data.py +++ b/data/pid_data.py @@ -4193,8 +4193,16 @@ (0x1e, 'Items'), (0x1f, 'Humidity'), (0x20, '16 bit counter'), + (0x21, "CPU load"), + (0x22, "Bandwidth"), + (0x23, "Concentration"), + (0x24, "Sound pressure level"), + (0x25, "Solid angle"), + (0x26, "Log ratio"), + (0x27, "Log ratio volts"), + (0x28, "Log ratio watts"), (0x7f, 'Other')], - 'range': [(0, 0x20), (0x7f, 0xff)]}, + 'range': [(0, 0x28), (0x7f, 0xff)]}, {'name': 'unit', 'type': 'uint8', 'labels': [(0x00, 'None'), (0x01, 'Centigrade'), @@ -4224,8 +4232,16 @@ (0x19, 'Lumens'), (0x1a, 'Lux'), (0x1b, 'Ire'), - (0x1c, 'Bytes')], - 'range': [(0, 0x1c), (0x80, 0xff)]}, + (0x1c, 'Bytes'), + (0x1d, 'Decibel'), + (0x1e, 'Decibel Volt'), + (0x1f, 'Decibel Watt'), + (0x20, 'Decibel Meter'), + (0x21, 'Percent'), + (0x22, 'Moles per meter Cubed'), + (0x23, 'RPM'), + (0x24, 'Bytes per Second')], + 'range': [(0, 0x24), (0x80, 0xff)]}, {'name': 'prefix', 'type': 'uint8', 'labels': [(0x00, 'None'), (0x01, 'Deci'), @@ -4409,6 +4425,26 @@ 'set_sub_device_range': 1, 'value': 51}, + # QUEUED_MESSAGE_SENSOR_SUBSCRIBE + {'get_request': {'items': []}, + 'get_response': {'items': [{'type': 'group', + 'name': 'sensors', + 'items': [{'name': 'sensor_number', + 'type': 'uint8'}], + }]}, + 'get_sub_device_range': 2, + 'name': 'QUEUED_MESSAGE_SENSOR_SUBSCRIBE', + 'set_request': {'items': [{'name': 'action', 'type': 'uint8', 'labels': [ + (0, 'Remove'), (1, 'Add')]}, + {'type': 'group', + 'name': 'sensors', + 'items': [{'name': 'sensor_number', + 'type': 'uint8'}]} + ]}, + 'set_response': {'items': []}, + 'set_sub_device_range': 1, + 'value': 52}, + # SENSOR_VALUE {'get_request': {'items': [{'name': 'sensor_number', 'type': 'uint8', 'range': [(0, 0xfe)], @@ -4500,6 +4536,28 @@ 'set_sub_device_range': 1, 'value': 4145}, + # SELFTEST_ENHANCED + {'get_request': {'items': []}, + 'get_response': {'items': [{'name': 'result_code_pid', 'type': 'uint16', + 'labels': [(0, 'Not supported')]}, + {'type': 'group', 'name': 'self_tests', + 'items': [{'name': 'test_number', 'type': 'uint8', + 'labels': [(0xff, 'All')]}, + {'name': 'test_status', 'type': 'uint8', + 'labels': [(0x00, 'Status not supported'), + (0x01, 'Not run since last power cycle'), + (0x02, 'Aborted/reset'), + (0x03, 'Active/running'), + (0x04, 'Complete - Pass'), + (0x05, 'Complete - Fail'), + (0x06, 'Complete - No analysis'), + (0x07, 'Complete - Result code available'), + (0xff, 'Other - Manufacturer specific') + ]}]}]}, + 'get_sub_device_range': 2, + 'name': 'SELFTEST_ENHANCED', + 'value': 4130}, + # DMX_PERSONALITY_DESCRIPTION {'get_request': {'items': [{'name': 'personality', 'type': 'uint8', 'range': [ (1, 0xff)] @@ -4571,6 +4629,12 @@ (0x0207, 'Additive Color Mixer - Blue'), (0x0208, 'Color Temperature Correction'), (0x0209, 'Color Scroll'), + (0x020a, 'Additive Color Mixer - Lime'), + (0x020b, 'Additive Color Mixer - Indigo'), + (0x020c, 'Additive Color Mixer - Cyan'), + (0x020d, 'Additive Color Mixer - Deep Red'), + (0x020e, 'Additive Color Mixer - Deep Blue'), + (0x020f, 'Additive Color Mixer - Natural White'), (0x0210, 'Color Semaphore'), (0x0211, 'Additive Color Mixer - Amber'), (0x0212, 'Additive Color Mixer - White'), @@ -4579,6 +4643,7 @@ (0x0215, 'Subtractive Color Mixer - UV'), (0x0216, 'Hue'), (0x0217, 'Saturation'), + (0x0218, 'Additive Color Mixer - UV'), (0x0301, 'Static gobo wheel'), (0x0302, 'Rotating gobo wheel'), (0x0303, 'Prism wheel'), @@ -4624,14 +4689,24 @@ {'name': 'data_type', 'type': 'uint8', 'labels': [(0x00, 'Not defined'), (0x01, 'Bit field'), - (0x02, 'ASCII'), + (0x02, 'String'), (0x03, 'uint8'), (0x04, 'int8'), (0x05, 'uint16'), (0x06, 'int16'), (0x07, 'uint32'), - (0x08, 'int32')], - 'range': [(0x00, 0x08), (0x80, 0xdf)]}, + (0x08, 'int32'), + (0x09, 'uint64'), + (0x0a, 'int64'), + (0x0b, 'Group'), + (0x0c, 'UID'), + (0x0d, 'Boolean'), + (0x0e, 'URL'), + (0x0f, 'MAC'), + (0x10, 'IPv4'), + (0x11, 'IPv6'), + (0x12, 'Enumeration')], + 'range': [(0x00, 0x12), (0x80, 0xdf)]}, {'name': 'command_class', 'type': 'uint8', 'labels': [(1, 'Get'), (2, 'Set'), (3, 'Get and Set')]}, {'name': 'type', 'type': 'uint8'}, @@ -4664,8 +4739,16 @@ (0x19, 'Lumens'), (0x1a, 'Lux'), (0x1b, 'Ire'), - (0x1c, 'Bytes')], - 'range': [(0, 0x1c), (0x80, 0xff)]}, + (0x1c, 'Bytes'), + (0x1d, 'Decibel'), + (0x1e, 'Decibel Volt'), + (0x1f, 'Decibel Watt'), + (0x20, 'Decibel Meter'), + (0x21, 'Percent'), + (0x22, 'Moles per meter Cubed'), + (0x23, 'RPM'), + (0x24, 'Bytes per Second')], + 'range': [(0, 0x24), (0x80, 0xff)]}, {'name': 'prefix', 'type': 'uint8', 'labels': [(0x00, 'None'), (0x01, 'Deci'), @@ -4699,6 +4782,102 @@ 'name': 'PARAMETER_DESCRIPTION', 'value': 81}, + # ENUM_LABEL + # TODO(Peter): There's currently no PID value defined for this in the released E1.20-2025 standard so we can't implement it! + # {'get_request': {'items': [{'name': 'pid', 'type': 'uint16'}, {'name': 'enumeration_index', 'type': 'uint32'}]}, + # 'get_response': {'items': [{'name': 'pid', 'type': 'uint16'}, {'name': 'enumeration_index', 'type': 'uint32'}, + # {'name': 'max_enumeration_index', 'type': 'uint32'}, + # {'name': 'description', + # 'max_size': 32, + # 'type': 'string'}]}, + # 'get_sub_device_range': 2, + # 'name': 'ENUM_LABEL', + # 'value': }, + + # SUPPORTED_PARAMETERS_ENHANCED + {'get_request': {'items': []}, + 'get_response': {'items': [{'name': 'params', + 'type': 'group', + 'items': [{'name': 'param_id', 'type': 'uint16'}, + {'name': 'param_id_support', 'type': 'uint16'}], + }] + }, + 'get_sub_device_range': 2, + 'name': 'SUPPORTED_PARAMETERS_ENHANCED', + 'value': 85}, + + # CONTROLLER_FLAG_SUPPORT + {'get_request': {'items': []}, + 'get_response': {'items': [{'name': 'controller_flags', 'type': 'uint8'}]}, + 'get_sub_device_range': 2, + 'name': 'CONTROLLER_FLAG_SUPPORT', + 'value': 86}, + + # NACK_DESCRIPTION + {'get_request': {'items': [{'name': 'nack_reason_code', 'type': 'uint16'}]}, + 'get_response': {'items': [{'name': 'nack_reason_code', 'type': 'uint16'}, + {'name': 'description', + 'max_size': 32, + 'type': 'string'}]}, + 'get_sub_device_range': 2, + 'name': 'NACK_DESCRIPTION', + 'value': 87}, + + # PACKED_PID_SUB + {'get_request': {'items': [{'name': 'pid', 'type': 'uint16'}, + {'name': 'index', 'type': 'uint16'}, + {'name': 'first_device_requested', 'type': 'uint16'}, + {'name': 'number_of_devices_requested', 'type': 'uint16'}]}, + 'get_response': {'items': [{'name': 'pid', 'type': 'uint16'}, + {'name': 'index', 'type': 'uint16'}, + {'name': 'packed_results', + 'type': 'group', + 'items': [{'name': 'device', 'type': 'uint16'}, + {'name': 'pdl_size', 'type': 'uint8'}, + {'name': 'param_data', 'type': 'group', + 'items': [{'name': 'data', 'type': 'uint8'}]}] + }]}, + 'get_sub_device_range': 0, + 'set_request': {'items': [{'name': 'pid', 'type': 'uint16'}, + {'name': 'index', 'type': 'uint16'}, + {'name': 'packed_request', + 'type': 'group', + 'items': [{'name': 'device', 'type': 'uint16'}, + {'name': 'pdl_size', 'type': 'uint8'}, + {'name': 'param_data', 'type': 'group', + 'items': [{'name': 'data', 'type': 'uint8'}]}] + }]}, + 'set_response': {'items': []}, + 'set_sub_device_range': 0, + 'name': 'PACKED_PID_SUB', + 'value': 88}, + + # PACKED_PID_INDEX + {'get_request': {'items': [{'name': 'pid', 'type': 'uint16'}, + {'name': 'first_item_requested', 'type': 'uint16'}, + {'name': 'number_of_items_requested', 'type': 'uint16'}]}, + 'get_response': {'items': [{'name': 'pid', 'type': 'uint16'}, + {'name': 'packed_results', + 'type': 'group', + 'items': [{'name': 'item', 'type': 'uint16'}, + {'name': 'pdl_size', 'type': 'uint8'}, + {'name': 'param_data', 'type': 'group', + 'items': [{'name': 'data', 'type': 'uint8'}]}] + }]}, + 'get_sub_device_range': 2, + 'set_request': {'items': [{'name': 'pid', 'type': 'uint16'}, + {'name': 'packed_request', + 'type': 'group', + 'items': [{'name': 'item', 'type': 'uint16'}, + {'name': 'pdl_size', 'type': 'uint8'}, + {'name': 'param_data', 'type': 'group', + 'items': [{'name': 'data', 'type': 'uint8'}]}] + }]}, + 'set_response': {'items': []}, + 'set_sub_device_range': 2, + 'name': 'PACKED_PID_INDEX', + 'value': 89}, + # TILT_INVERT {'get_request': {'items': []}, 'get_response': {'items': [{'name': 'invert', 'type': 'bool'}]}, @@ -4853,7 +5032,7 @@ 'set_sub_device_range': 1, 'value': 4112}, - # PERFORM_SELF_TEST + # PERFORM_SELFTEST {'get_request': {'items': []}, 'get_response': {'items': [{'name': 'tests_active', 'type': 'bool'}]}, 'get_sub_device_range': 2, @@ -4961,6 +5140,8 @@ (0x0a00, 'GFI / RCD Device'), (0x0a01, 'Battery'), (0x0a02, 'Controllable Breaker'), + (0x0b00, 'Input Device'), + (0x0b01, 'Sensor Input'), (0x7fff, 'Other Device')], 'range': [(0x0000, 0x0009), (0x0100, 0x0108), @@ -4973,6 +5154,7 @@ (0x0800, 0x0802), (0x0900, 0x0902), (0x0a00, 0x0a02), + (0x0b00, 0x0b01), (0x7fff, 0x7fff), (0x8000, 0xdfff)]}], }]}, @@ -5424,7 +5606,7 @@ {'name': 'shipping_lock_state', 'type': 'uint8', 'labels': [(0, 'Unlocked'), (1, 'Locked'), - (2, 'Partially Locked'),] + (2, 'Partially Locked')] }, ]}, 'get_sub_device_range': 0, @@ -5432,7 +5614,7 @@ 'set_request': {'items': [ {'name': 'shipping_lock_state', 'type': 'uint8', 'labels': [(0, 'Unlocked'), - (1, 'Locked'),] + (1, 'Locked')] }, ]}, 'set_response': {'items': []}, @@ -5471,9 +5653,7 @@ 'name': 'loopback_data', 'max_size': 231, 'min_size': 0, - 'items': [ - {'name': 'data', 'type': 'uint8'} - ]}, + 'items': [{'name': 'data', 'type': 'uint8'}]} ]}, 'set_response': {'items': [ {'type': 'group', 'name': 'loopback_data', 'items': [ diff --git a/data/sensor_types.py b/data/sensor_types.py index 3af72b9c..b92769b6 100644 --- a/data/sensor_types.py +++ b/data/sensor_types.py @@ -51,5 +51,13 @@ 0x1e: "Items", 0x1f: "Humidity", 0x20: "16 bit counter", + 0x21: "CPU load", + 0x22: "Bandwidth", + 0x23: "Concentration", + 0x24: "Sound pressure level", + 0x25: "Solid angle", + 0x26: "Log ratio", + 0x27: "Log ratio volts", + 0x28: "Log ratio watts", 0x7f: "Other", } diff --git a/js_src/rdm.js b/js_src/rdm.js index 17408756..a5ae40a8 100644 --- a/js_src/rdm.js +++ b/js_src/rdm.js @@ -35,7 +35,14 @@ angular.module('rdmApp', []) 'NR_INVALID_STATIC_CONFIG_TYPE': 0x0010, 'NR_INVALID_IPV4_ADDRESS': 0x0011, 'NR_INVALID_IPV6_ADDRESS': 0x0012, - 'NR_INVALID_PORT': 0x0013 + 'NR_INVALID_PORT': 0x0013, + 'NR_DEVICE_ABSENT': 0x0014, + 'NR_SENSOR_OUT_OF_RANGE': 0x0015, + 'NR_SENSOR_FAULT': 0x0016, + 'NR_PACKING_NOT_SUPPORTED': 0x0017, + 'NR_ERROR_IN_PACKED_LIST_TRANSACTION': 0x0018, + 'NR_PROXY_DROP': 0x0019, + 'NR_ALL_CALL_SET_FAIL': 0x0020 }, 'PIDS': { 'DISC_UNIQUE_BRANCH': 0x0001, @@ -44,13 +51,24 @@ angular.module('rdmApp', []) 'PROXIED_DEVICES': 0x0010, 'PROXIED_DEVICE_COUNT': 0x0011, 'COMMS_STATUS': 0x0015, + 'TEST_DATA': 0x0016, + 'COMMS_STATUS_NSC': 0x0017, 'QUEUED_MESSAGE': 0x0020, 'STATUS_MESSAGES': 0x0030, 'STATUS_ID_DESCRIPTION': 0x0031, 'CLEAR_STATUS_ID': 0x0032, 'SUB_DEVICE_STATUS_REPORT_THRESHOLD': 0x0033, + 'QUEUED_MESSAGE_SENSOR_SUBSCRIBE': 0x0034, 'SUPPORTED_PARAMETERS': 0x0050, 'PARAMETER_DESCRIPTION': 0x0051, + 'METADATA_PARAMETER_VERSION': 0x0052, + 'METADATA_JSON': 0x0053, + 'METADATA_JSON_URL': 0x0054, + 'SUPPORTED_PARAMETERS_ENHANCED': 0x0055, + 'CONTROLLER_FLAG_SUPPORT': 0x0056, + 'NACK_DESCRIPTION': 0x0057, + 'PACKED_PID_SUB': 0x0058, + 'PACKED_PID_INDEX': 0x0059, 'DEVICE_INFO': 0x0060, 'PRODUCT_DETAIL_ID_LIST': 0x0070, 'DEVICE_MODEL_DESCRIPTION': 0x0080, @@ -62,55 +80,58 @@ angular.module('rdmApp', []) 'SOFTWARE_VERSION_LABEL': 0x00c0, 'BOOT_SOFTWARE_VERSION_ID': 0x00c1, 'BOOT_SOFTWARE_VERSION_LABEL': 0x00c2, - 'DMX_PERSONALITY': 0x00E0, + 'MANUFACTURER_URL': 0x00d0, + 'PRODUCT_URL': 0x00d1, + 'FIRMWARE_URL': 0x00d2, + 'SERIAL_NUMBER': 0x00d3, + 'DEVICE_INFO_OFFSTAGE': 0x00d4, + 'DMX_PERSONALITY': 0x00e0, 'DMX_PERSONALITY_DESCRIPTION': 0x00e1, + 'DMX_PERSONALITY_ID': 0x00e2, 'DMX_START_ADDRESS': 0x00f0, 'SLOT_INFO': 0x0120, 'SLOT_DESCRIPTION': 0x0121, 'DEFAULT_SLOT_VALUE': 0x0122, + 'DMX_BLOCK_ADDRESS': 0x0140, + 'DMX_FAIL_MODE': 0x0141, + 'DMX_STARTUP_MODE': 0x0142, 'SENSOR_DEFINITION': 0x0200, 'SENSOR_VALUE': 0x0201, 'RECORD_SENSORS': 0x0202, + 'SENSOR_TYPE_CUSTOM': 0x0210, + 'SENSOR_UNIT_CUSTOM': 0x0211, + 'DIMMER_INFO': 0x0340, + 'MINIMUM_LEVEL': 0x0341, + 'MAXIMUM_LEVEL': 0x0342, + 'CURVE': 0x0343, + 'CURVE_DESCRIPTION': 0x0344, + 'OUTPUT_RESPONSE_TIME': 0x0345, + 'OUTPUT_RESPONSE_TIME_DESCRIPTION': 0x0346, + 'MODULATION_FREQUENCY': 0x0347, + 'MODULATION_FREQUENCY_DESCRIPTION': 0x0348, 'DEVICE_HOURS': 0x0400, 'LAMP_HOURS': 0x0401, 'LAMP_STRIKES': 0x0402, 'LAMP_STATE': 0x0403, 'LAMP_ON_MODE': 0x0404, 'DEVICE_POWER_CYCLES': 0x0405, + 'BURN_IN': 0x0440, 'DISPLAY_INVERT': 0x0500, 'DISPLAY_LEVEL': 0x0501, 'PAN_INVERT': 0x0600, 'TILT_INVERT': 0x0601, 'PAN_TILT_SWAP': 0x0602, 'REAL_TIME_CLOCK': 0x0603, - 'IDENTIFY_DEVICE': 0x1000, - 'RESET_DEVICE': 0x1001, - 'POWER_STATE': 0x1010, - 'PERFORM_SELFTEST': 0x1020, - 'SELF_TEST_DESCRIPTION': 0x1021, - 'CAPTURE_PRESET': 0x1030, - 'PRESET_PLAYBACK': 0x1031, - 'DMX_BLOCK_ADDRESS': 0x0140, - 'DMX_FAIL_MODE': 0x0141, - 'DMX_STARTUP_MODE': 0x0142, - 'DIMMER_INFO': 0x0340, - 'MINIMUM_LEVEL': 0x0341, - 'MAXIMUM_LEVEL': 0x0342, - 'CURVE': 0x0343, - 'CURVE_DESCRIPTION': 0x0344, - 'OUTPUT_RESPONSE_TIME': 0x0345, - 'OUTPUT_RESPONSE_TIME_DESCRIPTION': 0x0346, - 'MODULATION_FREQUENCY': 0x0347, - 'MODULATION_FREQUENCY_DESCRIPTION': 0x0348, - 'BURN_IN': 0x0440, 'LOCK_PIN': 0x0640, 'LOCK_STATE': 0x0641, 'LOCK_STATE_DESCRIPTION': 0x0642, - 'IDENTIFY_MODE': 0x1040, - 'PRESET_INFO': 0x1041, - 'PRESET_STATUS': 0x1042, - 'PRESET_MERGEMODE': 0x1043, - 'POWER_ON_SELF_TEST': 0x1044, + 'SHIPPING_LOCK': 0x0650, + 'LIST_TAGS': 0x0651, + 'ADD_TAG': 0x0652, + 'REMOVE_TAG': 0x0653, + 'CHECK_TAG': 0x0654, + 'CLEAR_TAGS': 0x0655, + 'DEVICE_UNIT_NUMBER': 0x0656, 'LIST_INTERFACES': 0x0700, 'INTERFACE_LABEL': 0x0701, 'INTERFACE_HARDWARE_ADDRESS_TYPE1': 0x0702, @@ -122,15 +143,51 @@ angular.module('rdmApp', []) 'INTERFACE_RELEASE_DHCP': 0x0708, 'INTERFACE_APPLY_CONFIGURATION': 0x0709, 'IPV4_DEFAULT_ROUTE': 0x070a, - 'DNS_NAME_SERVER': 0x070b, + 'DNS_IPV4_NAME_SERVER': 0x070b, 'DNS_HOSTNAME': 0x070c, - 'DNS_DOMAIN_NAME': 0x070d + 'DNS_DOMAIN_NAME': 0x070d, + 'COMPONENT_SCOPE': 0x0800, + 'SEARCH_DOMAIN': 0x0801, + 'TCP_COMMS_STATUS': 0x0802, + 'BROKER_STATUS': 0x0803, + 'ENDPOINT_LIST': 0x0900, + 'ENDPOINT_LIST_CHANGE': 0x0901, + 'IDENTIFY_ENDPOINT': 0x0902, + 'ENDPOINT_TO_UNIVERSE': 0x0903, + 'ENDPOINT_MODE': 0x0904, + 'ENDPOINT_LABEL': 0x0905, + 'RDM_TRAFFIC_ENABLE': 0x0906, + 'DISCOVERY_STATE': 0x0907, + 'BACKGROUND_DISCOVERY': 0x0908, + 'ENDPOINT_TIMING': 0x0909, + 'ENDPOINT_TIMING_DESCRIPTION': 0x090a, + 'ENDPOINT_RESPONDERS': 0x090b, + 'ENDPOINT_RESPONDER_LIST_CHANGE': 0x090c, + 'BINDING_CONTROL_FIELDS': 0x090d, + 'BACKGROUND_QUEUED_STATUS_POLICY': 0x090e, + 'BACKGROUND_QUEUED_STATUS_POLICY_DESCRIPTION': 0x090f, + 'IDENTIFY_DEVICE': 0x1000, + 'RESET_DEVICE': 0x1001, + 'POWER_STATE': 0x1010, + 'PERFORM_SELFTEST': 0x1020, + 'SELF_TEST_DESCRIPTION': 0x1021, + 'SELFTEST_ENHANCED': 0x1022, + 'CAPTURE_PRESET': 0x1030, + 'PRESET_PLAYBACK': 0x1031, + 'IDENTIFY_MODE': 0x1040, + 'PRESET_INFO': 0x1041, + 'PRESET_STATUS': 0x1042, + 'PRESET_MERGEMODE': 0x1043, + 'POWER_ON_SELF_TEST': 0x1044, + 'IDENTIFY_TIMEOUT': 0x1050, + 'POWER_OFF_READY': 0x1051 }, 'RESPONSE_TYPE': { 'ACK': 0, 'ACK_TIMER': 1, 'NACK': 2, - 'ACK_OVERFLOW': 3 + 'ACK_OVERFLOW': 3, + 'ACK_TIMER_HI_RES': 4 }, 'START_CODE': 0xcc, 'SUB_DEVICE': { diff --git a/tools/pid_names_to_js.py b/tools/pid_names_to_js.py new file mode 100755 index 00000000..5acde3b3 --- /dev/null +++ b/tools/pid_names_to_js.py @@ -0,0 +1,52 @@ +#!/usr/bin/python +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# pid_names_to_js.py +# Copyright (C) 2025 Peter Newman + +'''Convert rdm-app PID data in Python dict format to JS.''' + +__author__ = 'nomis52@gmail.com (Simon Newton)' + +import sys + + +def main(): + if len(sys.argv) != 2: + print('Usage: %s ' % sys.argv[0]) + sys.exit() + + locals_dict = {} + # Python 2 and 3 compatible version of execfile + exec(open(sys.argv[1]).read(), {}, locals_dict) + raw_esta_pids = locals_dict['ESTA_PIDS'] + + esta_pids = {} + for pid in raw_esta_pids: + esta_pids[pid['value']] = pid['name'] + + print(" 'PIDS': {") + + for id in sorted(esta_pids): + ending_comma = "," + if id == sorted(esta_pids)[-1]: + ending_comma = "" + print(" '%s': 0x%04x%s" % (esta_pids[id], id, ending_comma)) + + print(" },") + + +if __name__ == '__main__': + main()