Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions build/templates/_attributes.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ class AttributeViInt32TimeDeltaMilliseconds(Attribute):
session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_milliseconds_int32(value))


class AttributeViInt32TimeDeltaMonths(Attribute):

def __get__(self, session, session_type):
return _converters.convert_month_to_timedelta(session._get_attribute_vi_int32(self._attribute_id))

def __set__(self, session, value):
session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_months_int32(value))


class AttributeViInt64(Attribute):

def __get__(self, session, session_type):
Expand Down Expand Up @@ -80,6 +89,15 @@ class AttributeViStringRepeatedCapability(Attribute):
session._set_attribute_vi_string(self._attribute_id, _converters.convert_repeated_capabilities_without_prefix(value))


class AttributeViStringCommaSeparated(Attribute):

def __get__(self, session, session_type):
return _converters.convert_comma_separated_string_to_list(session._get_attribute_vi_string(self._attribute_id))

def __set__(self, session, value):
session._set_attribute_vi_string(self._attribute_id, _converters.convert_list_to_comma_separated_string(value))


class AttributeViBoolean(Attribute):

def __get__(self, session, session_type):
Expand Down
18 changes: 18 additions & 0 deletions build/templates/_converters.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ def convert_month_to_timedelta(months):
return hightime.timedelta(days=(30.4167 * months))


# Scaling factor to apply on seconds to get months
# would be 1/(60 seconds * 60 minutes * 24 hours * 30.4167 days)
def convert_timedelta_to_months_int32(value):
return _convert_timedelta(value, _visatype.ViInt32, 1.0 / (60 * 60 * 24 * 30.4167))


# This converter is not called from the normal codegen path for function. Instead it is
# call from init and is a special case.
def convert_init_with_options_dictionary(values):
Expand Down Expand Up @@ -332,6 +338,18 @@ def convert_comma_separated_string_to_list(comma_separated_string):
return [x.strip() for x in comma_separated_string.split(',')]


def convert_list_to_comma_separated_string(list_of_strings):
'''Convert a list of strings into a comma-separated string.

Args:
list_of_strings (list[str]): List of strings.

Returns:
str: Comma-separated string.
'''
return ','.join(list_of_strings)


def convert_chained_repeated_capability_to_parts(chained_repeated_capability):
'''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string.

Expand Down
18 changes: 18 additions & 0 deletions generated/nidcpower/nidcpower/_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ def __set__(self, session, value):
session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_milliseconds_int32(value))


class AttributeViInt32TimeDeltaMonths(Attribute):

def __get__(self, session, session_type):
return _converters.convert_month_to_timedelta(session._get_attribute_vi_int32(self._attribute_id))

def __set__(self, session, value):
session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_months_int32(value))


class AttributeViInt64(Attribute):

def __get__(self, session, session_type):
Expand Down Expand Up @@ -76,6 +85,15 @@ def __set__(self, session, value):
session._set_attribute_vi_string(self._attribute_id, _converters.convert_repeated_capabilities_without_prefix(value))


class AttributeViStringCommaSeparated(Attribute):

def __get__(self, session, session_type):
return _converters.convert_comma_separated_string_to_list(session._get_attribute_vi_string(self._attribute_id))

def __set__(self, session, value):
session._set_attribute_vi_string(self._attribute_id, _converters.convert_list_to_comma_separated_string(value))


class AttributeViBoolean(Attribute):

def __get__(self, session, session_type):
Expand Down
18 changes: 18 additions & 0 deletions generated/nidcpower/nidcpower/_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ def convert_month_to_timedelta(months):
return hightime.timedelta(days=(30.4167 * months))


# Scaling factor to apply on seconds to get months
# would be 1/(60 seconds * 60 minutes * 24 hours * 30.4167 days)
def convert_timedelta_to_months_int32(value):
return _convert_timedelta(value, _visatype.ViInt32, 1.0 / (60 * 60 * 24 * 30.4167))


# This converter is not called from the normal codegen path for function. Instead it is
# call from init and is a special case.
def convert_init_with_options_dictionary(values):
Expand Down Expand Up @@ -323,6 +329,18 @@ def convert_comma_separated_string_to_list(comma_separated_string):
return [x.strip() for x in comma_separated_string.split(',')]


def convert_list_to_comma_separated_string(list_of_strings):
'''Convert a list of strings into a comma-separated string.

Args:
list_of_strings (list[str]): List of strings.

Returns:
str: Comma-separated string.
'''
return ','.join(list_of_strings)


def convert_chained_repeated_capability_to_parts(chained_repeated_capability):
'''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string.

Expand Down
18 changes: 18 additions & 0 deletions generated/nidigital/nidigital/_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ def __set__(self, session, value):
session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_milliseconds_int32(value))


class AttributeViInt32TimeDeltaMonths(Attribute):

def __get__(self, session, session_type):
return _converters.convert_month_to_timedelta(session._get_attribute_vi_int32(self._attribute_id))

def __set__(self, session, value):
session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_months_int32(value))


class AttributeViInt64(Attribute):

def __get__(self, session, session_type):
Expand Down Expand Up @@ -76,6 +85,15 @@ def __set__(self, session, value):
session._set_attribute_vi_string(self._attribute_id, _converters.convert_repeated_capabilities_without_prefix(value))


class AttributeViStringCommaSeparated(Attribute):

def __get__(self, session, session_type):
return _converters.convert_comma_separated_string_to_list(session._get_attribute_vi_string(self._attribute_id))

def __set__(self, session, value):
session._set_attribute_vi_string(self._attribute_id, _converters.convert_list_to_comma_separated_string(value))


class AttributeViBoolean(Attribute):

def __get__(self, session, session_type):
Expand Down
18 changes: 18 additions & 0 deletions generated/nidigital/nidigital/_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ def convert_month_to_timedelta(months):
return hightime.timedelta(days=(30.4167 * months))


# Scaling factor to apply on seconds to get months
# would be 1/(60 seconds * 60 minutes * 24 hours * 30.4167 days)
def convert_timedelta_to_months_int32(value):
return _convert_timedelta(value, _visatype.ViInt32, 1.0 / (60 * 60 * 24 * 30.4167))


# This converter is not called from the normal codegen path for function. Instead it is
# call from init and is a special case.
def convert_init_with_options_dictionary(values):
Expand Down Expand Up @@ -322,6 +328,18 @@ def convert_comma_separated_string_to_list(comma_separated_string):
return [x.strip() for x in comma_separated_string.split(',')]


def convert_list_to_comma_separated_string(list_of_strings):
'''Convert a list of strings into a comma-separated string.

Args:
list_of_strings (list[str]): List of strings.

Returns:
str: Comma-separated string.
'''
return ','.join(list_of_strings)


def convert_chained_repeated_capability_to_parts(chained_repeated_capability):
'''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string.

Expand Down
18 changes: 18 additions & 0 deletions generated/nidmm/nidmm/_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ def __set__(self, session, value):
session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_milliseconds_int32(value))


class AttributeViInt32TimeDeltaMonths(Attribute):

def __get__(self, session, session_type):
return _converters.convert_month_to_timedelta(session._get_attribute_vi_int32(self._attribute_id))

def __set__(self, session, value):
session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_months_int32(value))


class AttributeViInt64(Attribute):

def __get__(self, session, session_type):
Expand Down Expand Up @@ -76,6 +85,15 @@ def __set__(self, session, value):
session._set_attribute_vi_string(self._attribute_id, _converters.convert_repeated_capabilities_without_prefix(value))


class AttributeViStringCommaSeparated(Attribute):

def __get__(self, session, session_type):
return _converters.convert_comma_separated_string_to_list(session._get_attribute_vi_string(self._attribute_id))

def __set__(self, session, value):
session._set_attribute_vi_string(self._attribute_id, _converters.convert_list_to_comma_separated_string(value))


class AttributeViBoolean(Attribute):

def __get__(self, session, session_type):
Expand Down
18 changes: 18 additions & 0 deletions generated/nidmm/nidmm/_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ def convert_month_to_timedelta(months):
return hightime.timedelta(days=(30.4167 * months))


# Scaling factor to apply on seconds to get months
# would be 1/(60 seconds * 60 minutes * 24 hours * 30.4167 days)
def convert_timedelta_to_months_int32(value):
return _convert_timedelta(value, _visatype.ViInt32, 1.0 / (60 * 60 * 24 * 30.4167))


# This converter is not called from the normal codegen path for function. Instead it is
# call from init and is a special case.
def convert_init_with_options_dictionary(values):
Expand Down Expand Up @@ -322,6 +328,18 @@ def convert_comma_separated_string_to_list(comma_separated_string):
return [x.strip() for x in comma_separated_string.split(',')]


def convert_list_to_comma_separated_string(list_of_strings):
'''Convert a list of strings into a comma-separated string.

Args:
list_of_strings (list[str]): List of strings.

Returns:
str: Comma-separated string.
'''
return ','.join(list_of_strings)


def convert_chained_repeated_capability_to_parts(chained_repeated_capability):
'''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string.

Expand Down
18 changes: 18 additions & 0 deletions generated/nifake/nifake/_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ def __set__(self, session, value):
session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_milliseconds_int32(value))


class AttributeViInt32TimeDeltaMonths(Attribute):

def __get__(self, session, session_type):
return _converters.convert_month_to_timedelta(session._get_attribute_vi_int32(self._attribute_id))

def __set__(self, session, value):
session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_months_int32(value))


class AttributeViInt64(Attribute):

def __get__(self, session, session_type):
Expand Down Expand Up @@ -76,6 +85,15 @@ def __set__(self, session, value):
session._set_attribute_vi_string(self._attribute_id, _converters.convert_repeated_capabilities_without_prefix(value))


class AttributeViStringCommaSeparated(Attribute):

def __get__(self, session, session_type):
return _converters.convert_comma_separated_string_to_list(session._get_attribute_vi_string(self._attribute_id))

def __set__(self, session, value):
session._set_attribute_vi_string(self._attribute_id, _converters.convert_list_to_comma_separated_string(value))


class AttributeViBoolean(Attribute):

def __get__(self, session, session_type):
Expand Down
18 changes: 18 additions & 0 deletions generated/nifake/nifake/_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ def convert_month_to_timedelta(months):
return hightime.timedelta(days=(30.4167 * months))


# Scaling factor to apply on seconds to get months
# would be 1/(60 seconds * 60 minutes * 24 hours * 30.4167 days)
def convert_timedelta_to_months_int32(value):
return _convert_timedelta(value, _visatype.ViInt32, 1.0 / (60 * 60 * 24 * 30.4167))


# This converter is not called from the normal codegen path for function. Instead it is
# call from init and is a special case.
def convert_init_with_options_dictionary(values):
Expand Down Expand Up @@ -323,6 +329,18 @@ def convert_comma_separated_string_to_list(comma_separated_string):
return [x.strip() for x in comma_separated_string.split(',')]


def convert_list_to_comma_separated_string(list_of_strings):
'''Convert a list of strings into a comma-separated string.

Args:
list_of_strings (list[str]): List of strings.

Returns:
str: Comma-separated string.
'''
return ','.join(list_of_strings)


def convert_chained_repeated_capability_to_parts(chained_repeated_capability):
'''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string.

Expand Down
10 changes: 10 additions & 0 deletions generated/nifake/nifake/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ class _SessionBase(object):

A property of type Color with read/write access.
'''
read_write_comma_separated_string = _attributes.AttributeViStringCommaSeparated(1000015)
'''Type: str

A property of type comma separated string with read/write access.
'''
read_write_double = _attributes.AttributeViReal64(1000001)
'''Type: float

Expand Down Expand Up @@ -155,6 +160,11 @@ class _SessionBase(object):

Property in milliseconds
'''
read_write_integer_with_month_converter = _attributes.AttributeViInt32TimeDeltaMonths(1000014)
'''Type: hightime.timedelta, datetime.timedelta, or int in months

Property in months
'''
read_write_string = _attributes.AttributeViString(1000002)
'''Type: str

Expand Down
18 changes: 18 additions & 0 deletions generated/nifake/nifake/unit_tests/test_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ def test_convert_timedeltas_to_seconds_real64():
assert all([actual == pytest.approx(expected) for actual, expected in zip(test_result, time_values)])


def test_convert_timedelta_to_months_int32():
# 1 month = 60*60*24*30.4167 seconds = 2628002.88 seconds
seconds_per_month = 60 * 60 * 24 * 30.4167
test_result = _converters.convert_timedelta_to_months_int32(hightime.timedelta(seconds=seconds_per_month))
assert test_result == 1
test_result = _converters.convert_timedelta_to_months_int32(hightime.timedelta(seconds=-5 * seconds_per_month))
assert test_result == -5
test_result = _converters.convert_timedelta_to_months_int32(seconds_per_month * 2)
assert test_result == 2
test_result = _converters.convert_timedelta_to_months_int32(-seconds_per_month)
assert test_result == -1


def test_convert_seconds_real64_to_timedelta():
time_value = -5e-10
test_result = _converters.convert_seconds_real64_to_timedelta(time_value)
Expand Down Expand Up @@ -395,3 +408,8 @@ def test_string_to_list_prefix():
def test_convert_comma_separated_string_to_list():
out_list = _converters.convert_comma_separated_string_to_list(' PinA , PinB , PinC ')
assert out_list == ['PinA', 'PinB', 'PinC']


def test_convert_list_to_comma_separated_string():
out_string = _converters.convert_list_to_comma_separated_string(['PinA', 'PinB', 'PinC'])
assert out_string == 'PinA,PinB,PinC'
Loading