query_type#
project: QueryType.etp
get_cell_type
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Example for ansys.scade.apitools.query.get_cell_type.
Project: ./QueryType.etp
"""
from scade import output
from scade.model.suite import get_roots as get_sessions
from ansys.scade.apitools.query import get_cell_type
# load the Scade model
model = get_sessions()[0].model
# retrieve the type Matrix which is an array of Vector
matrix = model.get_object_from_path('Types::Matrix/')
# direct type of the array
cell_type = get_cell_type(matrix)
# the result shall be Vector
output('direct cell type: %s\n' % cell_type.name)
# leaf type of the array
cell_type = get_cell_type(matrix, True)
# the result shall be Real
output('leaf cell type: %s\n' % cell_type.name)
Output:
direct cell type: Vector
leaf cell type: Real
get_leaf_alias
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Example for ansys.scade.apitools.query.get_leaf_alias.
Project: ./QueryType.etp
"""
from scade import output
from scade.model.suite import get_roots as get_sessions
from ansys.scade.apitools.query import get_leaf_alias
# load the Scade model
model = get_sessions()[0].model
# retrieve the type Speed which is an alias for Real
speed = model.get_object_from_path('Types::Speed/')
leaf_alias = get_leaf_alias(speed)
# the result shall be float32
output('leaf alias: %s\n' % leaf_alias.name)
Output:
leaf alias: float32
get_leaf_type
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Example for ansys.scade.apitools.query.get_leaf_type.
Project: ./QueryType.etp
"""
from scade import output
from scade.model.suite import get_roots as get_sessions
from ansys.scade.apitools.query import get_leaf_type
# load the Scade model
model = get_sessions()[0].model
# retrieve the type Speed which resolves to float32
speed = model.get_object_from_path('Types::Speed/')
leaf_type = get_leaf_type(speed)
# the result shall be float32
output('leaf type: %s\n' % leaf_type.name)
# retrieve the type Vector which resolves to an array
vector = model.get_object_from_path('Types::Vector/')
leaf_type = get_leaf_type(vector)
# the result shall be an instance of Table
output('leaf type: %s\n' % type(leaf_type))
Output:
leaf type: float32
leaf type: <class 'scade.model.suite.suite.Table'>
get_type_name
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Example for ansys.scade.apitools.query.get_type_name.
Project: ./QueryType.etp
"""
from scade import output
from scade.model.suite import get_roots as get_sessions
from ansys.scade.apitools.query import get_type_name
# load the Scade model
model = get_sessions()[0].model
# retrieve the named type Vector
vector = model.get_object_from_path('Types::Vector/')
# the result shall be Vector
output('name: %s\n' % get_type_name(vector))
# the type of vector is an array, its name shall be its definition
array = vector.type
output('definition: %s\n' % get_type_name(array))
# <null> for None
output('name: %s\n' % get_type_name(None))
Output:
name: Vector
definition: Real ^2
name: <null>
is_array
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Example for ansys.scade.apitools.query.is_array.
Project: ./QueryType.etp
"""
from scade import output
from scade.model.suite import get_roots as get_sessions
from ansys.scade.apitools.query import is_array
# load the Scade model
model = get_sessions()[0].model
# retrieve the type Vector which resolves to an array
vector = model.get_object_from_path('Types::Vector/')
# the result shall be True
output('%s is array: %s\n' % (vector.name, is_array(vector)))
# retrieve the type Speed which is scalar
speed = model.get_object_from_path('Types::Speed/')
# the result shall be False
output('%s is array: %s\n' % (speed.name, is_array(speed)))
Output:
Vector is array: True
Speed is array: False
is_enum
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Example for ansys.scade.apitools.query.is_enum.
Project: ./QueryType.etp
"""
from scade import output
from scade.model.suite import get_roots as get_sessions
from ansys.scade.apitools.query import is_enum
# load the Scade model
model = get_sessions()[0].model
# retrieve the type Vector which resolves to an enumeration
color = model.get_object_from_path('Types::Color/')
# the result shall be True
output('%s is enum: %s\n' % (color.name, is_enum(color)))
# retrieve the type Speed which is scalar
speed = model.get_object_from_path('Types::Speed/')
# the result shall be False
output('%s is enum: %s\n' % (speed.name, is_enum(speed)))
Output:
Color is enum: True
Speed is enum: False
is_imported
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Example for ansys.scade.apitools.query.is_imported.
Project: ./QueryType.etp
"""
from scade import output
from scade.model.suite import get_roots as get_sessions
from ansys.scade.apitools.query import is_imported
# load the Scade model
model = get_sessions()[0].model
# retrieve the type Imported which is imported
imported = model.get_object_from_path('Types::ImportedScalar/')
# the result shall be True
output('%s is imported: %s\n' % (imported.name, is_imported(imported)))
# retrieve the type Speed which resolves to float32
speed = model.get_object_from_path('Types::Speed/')
# the result shall be False
output('%s is imported: %s\n' % (speed.name, is_imported(speed)))
Output:
ImportedScalar is imported: True
Speed is imported: False
is_predefined
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Example for ansys.scade.apitools.query.is_predefined.
Project: ./QueryType.etp
"""
from scade import output
from scade.model.suite import get_roots as get_sessions
from ansys.scade.apitools.query import is_predefined
# load the Scade model
model = get_sessions()[0].model
# retrieve the type Speed which resolves to float32
speed = model.get_object_from_path('Types::Speed/')
# the result shall be TRue
output('%s is predefined: %s\n' % (speed.name, is_predefined(speed)))
# retrieve the type Vector which is an array
vector = model.get_object_from_path('Types::Vector/')
# the result shall be False
output('%s is predefined: %s\n' % (vector.name, is_predefined(vector)))
Output:
Speed is predefined: True
Vector is predefined: False
is_scalar
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Example for ansys.scade.apitools.query.is_scalar.
Project: ./QueryType.etp
"""
from scade import output
from scade.model.suite import get_roots as get_sessions
from ansys.scade.apitools.query import is_scalar
# load the Scade model
model = get_sessions()[0].model
# retrieve the type Speed which resolves to float32
speed = model.get_object_from_path('Types::Speed/')
# the result shall be True
output('%s is scalar: %s\n' % (speed.name, is_scalar(speed)))
# retrieve the type Vector which is an array of float32
vector = model.get_object_from_path('Types::Vector/')
# the result shall be False
output('%s is scalar: %s\n' % (vector.name, is_scalar(vector)))
# retrieve the type ImportedScalar which is tagged as scalar for C
imported = model.get_object_from_path('Types::ImportedScalar/')
# the result shall be True
output('%s is scalar: %s\n' % (imported.name, is_scalar(imported, 'C')))
Output:
Speed is scalar: True
Vector is scalar: False
ImportedScalar is scalar: True
is_structure
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Example for ansys.scade.apitools.query.is_structure.
Project: ./QueryType.etp
"""
from scade import output
from scade.model.suite import get_roots as get_sessions
from ansys.scade.apitools.query import is_structure
# load the Scade model
model = get_sessions()[0].model
# retrieve the type Structure which resolves to a structure
structure = model.get_object_from_path('Types::Structure/')
# the result shall be True
output('%s is structure: %s\n' % (structure.name, is_structure(structure)))
# retrieve the type Speed which is scalar
speed = model.get_object_from_path('Types::Speed/')
# the result shall be False
output('%s is structure: %s\n' % (speed.name, is_structure(speed)))
Output:
Structure is structure: True
Speed is structure: False