Skip to content
Draft
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
2 changes: 1 addition & 1 deletion tango_simlib/tango_sim_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def initialize_dynamic_attributes(self):
# PyTango data type when passed to the Attr function.
# e.g. 'READ' -> tango._tango.AttrWriteType.READ
rw_type = meta_data["writable"]
rw_type = getattr(AttrWriteType, rw_type)
rw_type = getattr(AttrWriteType, rw_type, AttrWriteType.READ)
attr = self._create_attribute(
attribute_name, meta_data["data_type"], rw_type
)
Expand Down
125 changes: 125 additions & 0 deletions tango_simlib/tests/config_files/Integers_SimDD.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"class_name": "Ints",
"dynamicAttributes": [
{
"basicAttributeData": {
"name": "scalarShort",
"label": "scalar_short",
"description": "scalar short",
"data_type": "Short",
"data_format": "Scalar",
"data_shape": {
"max_dim_x": 1,
"max_dim_y": 0
},
"dataSimulationParameters": {
"quantity_simulation_type": "ConstantQuantity"
},
"attributeControlSystem": {
"display_level": "OPERATOR",
"period": 1000
}
}
},
{
"basicAttributeData": {
"name": "scalarUShort",
"label": "scalar_ushort",
"description": "scalar ushort",
"data_type": "UShort",
"data_format": "Scalar",
"data_shape": {
"max_dim_x": 1,
"max_dim_y": 0
},
"dataSimulationParameters": {
"quantity_simulation_type": "ConstantQuantity"
},
"attributeControlSystem": {
"display_level": "OPERATOR",
"period": 1000
}
}
},
{
"basicAttributeData": {
"name": "scalarLong",
"label": "scalar_long",
"description": "scalar long",
"data_type": "Long",
"data_format": "Scalar",
"data_shape": {
"max_dim_x": 1,
"max_dim_y": 0
},
"dataSimulationParameters": {
"quantity_simulation_type": "ConstantQuantity"
},
"attributeControlSystem": {
"display_level": "OPERATOR",
"period": 1000
}
}
},
{
"basicAttributeData": {
"name": "scalarLong64",
"label": "scalar_long64",
"description": "scalar long64",
"data_type": "Long64",
"data_format": "Scalar",
"data_shape": {
"max_dim_x": 1,
"max_dim_y": 0
},
"dataSimulationParameters": {
"quantity_simulation_type": "ConstantQuantity"
},
"attributeControlSystem": {
"display_level": "OPERATOR",
"period": 1000
}
}
},
{
"basicAttributeData": {
"name": "scalarULong",
"label": "scalar_ulong",
"description": "scalar ulong",
"data_type": "ULong",
"data_format": "Scalar",
"data_shape": {
"max_dim_x": 1,
"max_dim_y": 0
},
"dataSimulationParameters": {
"quantity_simulation_type": "ConstantQuantity"
},
"attributeControlSystem": {
"display_level": "OPERATOR",
"period": 1000
}
}
},
{
"basicAttributeData": {
"name": "scalarULong64",
"label": "scalar_ulong64",
"description": "scalar ulong64",
"data_type": "ULong64",
"data_format": "Scalar",
"data_shape": {
"max_dim_x": 1,
"max_dim_y": 0
},
"dataSimulationParameters": {
"quantity_simulation_type": "ConstantQuantity"
},
"attributeControlSystem": {
"display_level": "OPERATOR",
"period": 1000
}
}
}
]
}
50 changes: 50 additions & 0 deletions tango_simlib/tests/test_simdd_json_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,3 +963,53 @@ def test_image_attribute_readable(self):
self.assertIsInstance(
self.device.read_attribute(attribute_name), tango.DeviceAttribute
)


class test_SimdddIntAttributeDevice(ClassCleanupUnittestMixin, unittest.TestCase):
"""A test class that tests the simdd file for integer attribute."""

longMessage = True

@classmethod
def setUpClassWithCleanup(cls):
cls.tango_db = cleanup_tempfile(cls, prefix="tango", suffix=".db")
cls.data_descr_files = []
cls.data_descr_files.append(
pkg_resources.resource_filename(
"tango_simlib.tests.config_files", "Integers_SimDD.json"
)
)
cls.device_name = "test/nodb/tangodeviceserver"
model = tango_sim_generator.configure_device_models(
cls.data_descr_files, cls.device_name
)
cls.TangoDeviceServer = tango_sim_generator.get_tango_device_server(
model, cls.data_descr_files
)[0]
cls.tango_context = DeviceTestContext(
cls.TangoDeviceServer, device_name=cls.device_name, db=cls.tango_db
)

with patch("tango_simlib.utilities.helper_module.get_database"):
start_thread_with_cleanup(cls, cls.tango_context)

def setUp(self):
super(test_SimdddIntAttributeDevice, self).setUp()
self.device = self.tango_context.device

def test_spectrum_attributes_are_readable(self):
attribute_names_data_types = (
("scalarShort", tango.DevShort),
("scalarUShort", tango.DevUShort),
("scalarLong", tango.DevLong),
("scalarLong64", tango.DevLong64),
("scalarULong", tango.DevULong),
("scalarULong64", tango.DevULong64),
)
for attribute_name, data_type in attribute_names_data_types:
attribute_config = self.device.get_attribute_config(attribute_name)
self.assertEqual(attribute_config.data_type, data_type)
self.assertEqual(attribute_config.data_format, tango.AttrDataFormat.SCALAR)
self.assertIsInstance(
self.device.read_attribute(attribute_name), tango.DeviceAttribute
)
14 changes: 13 additions & 1 deletion tango_simlib/utilities/SimDD.schema
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,19 @@
},
"data_type": {
"type": "string",
"enum": ["Boolean", "String", "Double", "VarStringArray", "VarDoubleArray"]
"enum": [
"Boolean",
"Double",
"Float",
"Long",
"Long64",
"Short",
"String",
"ULong",
"ULong64",
"UShort",
"VarStringArray"
]
},
"data_format": {
"type": "string"
Expand Down