Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DAQmx proto file with misplaced attributes #934

Merged
merged 15 commits into from
Jun 2, 2023
74 changes: 37 additions & 37 deletions generated/nidaqmx/nidaqmx.proto
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -1699,34 +1699,19 @@ enum DeviceBoolAttribute {
enum DeviceInt32Attribute {
DEVICE_INT32_ATTRIBUTE_UNSPECIFIED = 0;
DEVICE_ATTRIBUTE_BUS_TYPE = 8998;
DEVICE_ATTRIBUTE_PRODUCT_CATEGORY = 10665;
DEVICE_ATTRIBUTE_CI_CURRENT_UTC_OFFSET = 12320;
DEVICE_ATTRIBUTE_NAV_MODE = 12325;
DEVICE_ATTRIBUTE_NAV_ALT_REF = 12329;
DEVICE_ATTRIBUTE_NAV_ANT_STATUS = 12334;
DEVICE_ATTRIBUTE_NAV_CURRENT_UTC_OFFSET = 12336;
}

enum DeviceInt32ArrayAttribute {
DEVICE_INT32_ARRAY_ATTRIBUTE_UNSPECIFIED = 0;
DEVICE_ATTRIBUTE_AI_TRIG_USAGE = 10630;
DEVICE_ATTRIBUTE_AO_TRIG_USAGE = 10631;
DEVICE_ATTRIBUTE_DI_TRIG_USAGE = 10632;
DEVICE_ATTRIBUTE_DO_TRIG_USAGE = 10633;
DEVICE_ATTRIBUTE_CI_TRIG_USAGE = 10634;
DEVICE_ATTRIBUTE_CO_TRIG_USAGE = 10635;
DEVICE_ATTRIBUTE_AI_COUPLINGS = 10644;
DEVICE_ATTRIBUTE_AI_SUPPORTED_MEAS_TYPES = 12242;
DEVICE_ATTRIBUTE_AO_SUPPORTED_OUTPUT_TYPES = 12243;
DEVICE_ATTRIBUTE_CI_SUPPORTED_MEAS_TYPES = 12244;
DEVICE_ATTRIBUTE_CO_SUPPORTED_OUTPUT_TYPES = 12245;
DEVICE_ATTRIBUTE_AI_SAMP_MODES = 12252;
DEVICE_ATTRIBUTE_AO_SAMP_MODES = 12253;
DEVICE_ATTRIBUTE_CI_SAMP_MODES = 12254;
DEVICE_ATTRIBUTE_CO_SAMP_MODES = 12255;
DEVICE_ATTRIBUTE_NAV_SUPPORTED_MEAS_TYPES = 12323;
DEVICE_ATTRIBUTE_NAV_TRIG_USAGE = 12324;
DEVICE_ATTRIBUTE_AI_DIG_FLTR_TYPES = 12551;
DEVICE_ATTRIBUTE_PRODUCT_CATEGORY = 10665;
DEVICE_ATTRIBUTE_CI_CURRENT_UTC_OFFSET = 12320;
DEVICE_ATTRIBUTE_NAV_MODE = 12325;
DEVICE_ATTRIBUTE_NAV_ALT_REF = 12329;
DEVICE_ATTRIBUTE_NAV_ANT_STATUS = 12334;
DEVICE_ATTRIBUTE_NAV_CURRENT_UTC_OFFSET = 12336;
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved
}

enum DeviceDoubleAttribute {
Expand Down Expand Up @@ -1776,6 +1761,21 @@ enum DeviceUInt32ArrayAttribute {
DEVICE_ATTRIBUTE_ACCESSORY_SERIAL_NUMS = 12143;
}

enum DeviceInt32ArrayAttribute {
DEVICE_INT32_ARRAY_ATTRIBUTE_UNSPECIFIED = 0;
DEVICE_ATTRIBUTE_AI_SUPPORTED_MEAS_TYPES = 12242;
DEVICE_ATTRIBUTE_AO_SUPPORTED_OUTPUT_TYPES = 12243;
DEVICE_ATTRIBUTE_CI_SUPPORTED_MEAS_TYPES = 12244;
DEVICE_ATTRIBUTE_CO_SUPPORTED_OUTPUT_TYPES = 12245;
DEVICE_ATTRIBUTE_AI_SAMP_MODES = 12252;
DEVICE_ATTRIBUTE_AO_SAMP_MODES = 12253;
DEVICE_ATTRIBUTE_CI_SAMP_MODES = 12254;
DEVICE_ATTRIBUTE_CO_SAMP_MODES = 12255;
DEVICE_ATTRIBUTE_NAV_SUPPORTED_MEAS_TYPES = 12323;
DEVICE_ATTRIBUTE_NAV_TRIG_USAGE = 12324;
DEVICE_ATTRIBUTE_AI_DIG_FLTR_TYPES = 12551;
}

enum ExportSignalDoubleAttribute {
EXPORTSIGNAL_DOUBLE_ATTRIBUTE_UNSPECIFIED = 0;
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved
EXPORTSIGNAL_ATTRIBUTE_START_TRIG_DELAY = 1409;
Expand Down Expand Up @@ -2002,19 +2002,11 @@ enum PhysicalChannelUInt32ArrayAttribute {
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_TEDS_TEMPLATE_I_DS = 8847;
}

enum PhysicalChannelInt32ArrayAttribute {
PHYSICALCHANNEL_INT32_ARRAY_ATTRIBUTE_UNSPECIFIED = 0;
enum PhysicalChannelInt32Attribute {
PHYSICALCHANNEL_INT32_ATTRIBUTE_UNSPECIFIED = 0;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_AI_TERM_CFGS = 9026;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_AO_TERM_CFGS = 10659;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_AI_SUPPORTED_MEAS_TYPES = 12247;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_AO_SUPPORTED_OUTPUT_TYPES = 12249;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_CI_SUPPORTED_MEAS_TYPES = 12250;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_CO_SUPPORTED_OUTPUT_TYPES = 12251;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_DI_SAMP_MODES = 12256;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_DO_SAMP_MODES = 12257;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_NAV_SUPPORTED_MEAS_TYPES = 12343;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_AO_SUPPORTED_POWER_UP_OUTPUT_TYPES = 12366;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_AI_SENSOR_POWER_TYPES = 12665;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_AI_POWER_CONTROL_TYPE = 12654;
}

enum PhysicalChannelBoolAttribute {
Expand Down Expand Up @@ -2049,17 +2041,25 @@ enum PhysicalChannelDoubleAttribute {
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_AI_POWER_CONTROL_VOLTAGE = 12652;
}

enum PhysicalChannelInt32ArrayAttribute {
PHYSICALCHANNEL_INT32_ARRAY_ATTRIBUTE_UNSPECIFIED = 0;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_AI_SUPPORTED_MEAS_TYPES = 12247;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_AO_SUPPORTED_OUTPUT_TYPES = 12249;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_CI_SUPPORTED_MEAS_TYPES = 12250;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_CO_SUPPORTED_OUTPUT_TYPES = 12251;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_DI_SAMP_MODES = 12256;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_DO_SAMP_MODES = 12257;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_NAV_SUPPORTED_MEAS_TYPES = 12343;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_AO_SUPPORTED_POWER_UP_OUTPUT_TYPES = 12366;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_AI_SENSOR_POWER_TYPES = 12665;
}

enum PhysicalChannelDoubleArrayAttribute {
PHYSICALCHANNEL_DOUBLE_ARRAY_ATTRIBUTE_UNSPECIFIED = 0;
PHYSICALCHANNEL_ATTRIBUTE_AO_POWER_AMP_SCALING_COEFF = 12387;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_AI_SENSOR_POWER_VOLTAGE_RANGE_VALS = 12666;
}

enum PhysicalChannelInt32Attribute {
PHYSICALCHANNEL_INT32_ATTRIBUTE_UNSPECIFIED = 0;
PHYSICALCHANNEL_ATTRIBUTE_PHYSICAL_CHAN_AI_POWER_CONTROL_TYPE = 12654;
}

enum ReadInt32Attribute {
READ_INT32_ATTRIBUTE_UNSPECIFIED = 0;
READ_ATTRIBUTE_OVERWRITE = 4625;
Expand Down
15 changes: 14 additions & 1 deletion source/codegen/common_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,12 +915,25 @@ def get_attribute_groups(data):
# If the attributes are already in string categories: those are the groups. Return as-is.
first_key = next(iter(attributes), None)
if isinstance(first_key, str):
return [AttributeGroup(name, attributes, config) for name, attributes in attributes.items()]
attribute_groups = [AttributeGroup(name, attributes, config) for name, attributes in attributes.items()]
return _transform_attributes(attribute_groups)

# If there's just one level of attributes: use the service_class_prefix as the group.
service_class_prefix = config["service_class_prefix"]
return [AttributeGroup(service_class_prefix, attributes, config)]

def _transform_attributes(attribute_groups):
# This is handles the specific attributes that uses bitfield enum.
# Currently this affects only NI-DAQmx generation.
for attribute_group in attribute_groups:
for id,data in attribute_group.attributes.items():
if "bitfield_enum" in data:
data["type"] = BITFIELD_ENUM_RETURN_TYPES.get(data["type"], data["type"])
return attribute_groups
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved

BITFIELD_ENUM_RETURN_TYPES={
"int32[]": "int32",
}
Sakthi-SM marked this conversation as resolved.
Show resolved Hide resolved

def strip_prefix(s: str, prefix: str) -> str:
"""Strip the given prefix, if present, and return the resulting string."""
Expand Down