Skip to content

Commit c93d7d0

Browse files
feat: added get_mount_point_props and update_mount_points methods. (#672)
Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent 9328091 commit c93d7d0

File tree

5 files changed

+640
-0
lines changed

5 files changed

+640
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Feat: added get_mount_point_props and update_mount_points methods.

doc/source/api/layer_types.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ Classes used for the Layer API.
1414
CopyPottingRegionRequest
1515
DeletePottingRegionRequest
1616
GetICTFixturesPropertiesRequest
17+
GetMountPointsPropertiesRequest
1718
GetTestPointPropertiesRequest
1819
ICTFixtureProperties
20+
MountPointProperties
1921
PolygonalShape
2022
RectangularShape
2123
SlotShape
@@ -27,6 +29,7 @@ Classes used for the Layer API.
2729
PottingRegionUpdateData
2830
TestPointProperties
2931
UpdateICTFixturesRequest
32+
UpdateMountPointsRequest
3033
UpdatePottingRegionRequest
3134
UpdateTestPointsRequest
3235

src/ansys/sherlock/core/layer.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
CopyPottingRegionRequest,
99
DeletePottingRegionRequest,
1010
GetICTFixturesPropertiesRequest,
11+
GetMountPointsPropertiesRequest,
1112
GetTestPointPropertiesRequest,
1213
PCBShape,
1314
PolygonalShape,
1415
RectangularShape,
1516
SlotShape,
1617
UpdateICTFixturesRequest,
18+
UpdateMountPointsRequest,
1719
UpdatePottingRegionRequest,
1820
UpdateTestPointsRequest,
1921
)
@@ -2239,3 +2241,97 @@ def update_ict_fixtures(
22392241
update_request = request._convert_to_grpc()
22402242
response = self.stub.updateICTFixtures(update_request)
22412243
return response
2244+
2245+
@require_version(261)
2246+
def get_mount_point_props(
2247+
self, request: GetMountPointsPropertiesRequest
2248+
) -> SherlockLayerService_pb2.GetMountPointsPropertiesResponse:
2249+
"""
2250+
Return the properties for each mount point given a comma-separated list of mount point IDs.
2251+
2252+
Available Since: 2026R1
2253+
2254+
Parameters
2255+
----------
2256+
request: GetmountPointsPropertiesRequest
2257+
Contains all the information needed to return the properties for one or more mount
2258+
points.
2259+
2260+
Returns
2261+
-------
2262+
SherlockCommonService_pb2.GetMountPointsPropertiesResponse
2263+
Properties for each mount point that correspond to the reference designators.
2264+
2265+
Examples
2266+
--------
2267+
>>> from ansys.sherlock.core.launcher import launch_sherlock
2268+
>>> from ansys.sherlock.core.types.layer_types import GetMountPointsPropertiesRequest
2269+
>>> sherlock = launch_sherlock()
2270+
>>> request = layer_types.GetMountPointsPropertiesRequest(
2271+
>>> project = "Tutorial Project"
2272+
>>> cca_name = "Main Board"
2273+
>>> mount_point_ids = "MP1,MP2"
2274+
>>> )
2275+
>>> response = layer.get_mount_point_props(request)
2276+
"""
2277+
if not self._is_connection_up():
2278+
raise SherlockNoGrpcConnectionException()
2279+
2280+
return self.stub.getMountPointsProperties(request._convert_to_grpc())
2281+
2282+
@require_version(261)
2283+
def update_mount_points(
2284+
self, request: UpdateMountPointsRequest
2285+
) -> SherlockLayerService_pb2.UpdateMountPointsResponse:
2286+
"""Update mount point properties of a CCA from input parameters.
2287+
2288+
Available Since: 2026R1
2289+
2290+
Parameters
2291+
----------
2292+
request: UpdateMountPointsRequest
2293+
Contains all the information needed to update the properties for one or more
2294+
mount points.
2295+
2296+
Returns
2297+
-------
2298+
SherlockCommonService_pb2.UpdateMountPointsResponse
2299+
A status code and message for the update mount points request.
2300+
2301+
Examples
2302+
--------
2303+
>>> from ansys.sherlock.core.launcher import launch_sherlock
2304+
>>> from ansys.sherlock.core.types.layer_types import UpdateMountPointsRequest,
2305+
>>> MountPointProperties
2306+
>>> sherlock = connect()
2307+
>>> mount_point = MountPointProperties(
2308+
>>> id="MP1",
2309+
>>> type="Mount Pad",
2310+
>>> shape="Rectangular",
2311+
>>> units="mm",
2312+
>>> side="BOTTOM",
2313+
>>> height=1.0,
2314+
>>> material="GOLD",
2315+
>>> state="DISABLED",
2316+
>>> x=0.3,
2317+
>>> y=-0.4,
2318+
>>> length=1.0,
2319+
>>> width=0.2,
2320+
>>> diameter=0.0,
2321+
>>> nodes="",
2322+
>>> rotation=45,
2323+
>>> polygon="",
2324+
>>> boundary="Outline",
2325+
>>> constraints="X-axis translation|Z-axis translation",
2326+
>>> chassis_material="SILVER",
2327+
>>> )
2328+
>>> response = sherlock.layer.update_mount_points(UpdateMountPointsRequest(
2329+
>>> project="Tutorial Project",
2330+
>>> cca_name="Main Board",
2331+
>>> update_mount_points=[mount_point],
2332+
>>> ))
2333+
"""
2334+
if not self._is_connection_up():
2335+
raise SherlockNoGrpcConnectionException()
2336+
2337+
return self.stub.updateMountPoints(request._convert_to_grpc())

src/ansys/sherlock/core/types/layer_types.py

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,3 +574,148 @@ def _convert_to_grpc(self) -> SherlockLayerService_pb2.UpdateICTFixturesRequest:
574574
for update_fixture in self.update_fixtures:
575575
request.ICTFixtureProperties.append(update_fixture._convert_to_grpc())
576576
return request
577+
578+
579+
class MountPointProperties(BaseModel):
580+
"""Contains the properties of a mount point."""
581+
582+
id: str
583+
"""ID"""
584+
type: str
585+
"""Type"""
586+
shape: str
587+
"""Shape type"""
588+
units: str
589+
"""Units"""
590+
x: float
591+
"""Center X"""
592+
y: float
593+
"""Center Y"""
594+
length: float
595+
"""Length"""
596+
width: float
597+
"""Width"""
598+
diameter: float
599+
"""Diameter"""
600+
nodes: str
601+
"""Number of nodes"""
602+
rotation: float
603+
"""Degrees of rotation"""
604+
side: str
605+
"""Side"""
606+
height: float
607+
"""Height"""
608+
material: str
609+
"""Material"""
610+
boundary: str
611+
"""Boundary point(s)"""
612+
constraints: str
613+
"""FEA constraints"""
614+
polygon: str
615+
"""Coordinates of points"""
616+
state: str
617+
"""State"""
618+
chassis_material: str
619+
"""Chassis material"""
620+
621+
def _convert_to_grpc(self) -> SherlockLayerService_pb2.MountPointProperties:
622+
grpc_mount_point_data = SherlockLayerService_pb2.MountPointProperties()
623+
624+
grpc_mount_point_data.ID = self.id
625+
grpc_mount_point_data.type = self.type
626+
grpc_mount_point_data.shape = self.shape
627+
grpc_mount_point_data.units = self.units
628+
grpc_mount_point_data.x = str(self.x)
629+
grpc_mount_point_data.y = str(self.y)
630+
grpc_mount_point_data.length = str(self.length)
631+
grpc_mount_point_data.width = str(self.width)
632+
grpc_mount_point_data.diameter = str(self.diameter)
633+
grpc_mount_point_data.nodes = self.nodes
634+
grpc_mount_point_data.rotation = str(self.rotation)
635+
grpc_mount_point_data.side = self.side
636+
grpc_mount_point_data.height = str(self.height)
637+
grpc_mount_point_data.material = self.material
638+
grpc_mount_point_data.boundary = self.boundary
639+
grpc_mount_point_data.constraints = self.constraints
640+
grpc_mount_point_data.polygon = self.polygon
641+
grpc_mount_point_data.state = self.state
642+
grpc_mount_point_data.chassisMaterial = self.chassis_material
643+
644+
return grpc_mount_point_data
645+
646+
@field_validator("type", "shape", "units", "side", "state")
647+
@classmethod
648+
def str_validation(cls, value: str, info: ValidationInfo):
649+
"""Validate string fields listed."""
650+
return basic_str_validator(value, info.field_name)
651+
652+
653+
class GetMountPointsPropertiesRequest(BaseModel):
654+
"""Return the properties for each mount point given a comma-separated list of mount point ids.""" # noqa: E501
655+
656+
project: str
657+
"""Name of the project."""
658+
cca_name: str
659+
"""Name of the CCA containing the mount point properties to return."""
660+
mount_point_ids: Optional[str] = None
661+
"""Optional Param: Comma-separated list of mount point ids representing one or more mount
662+
points. If this parameter is not included, then the entire list of mount points
663+
for a given CCA will have their properties returned.
664+
"""
665+
666+
@field_validator("project", "cca_name", "mount_point_ids")
667+
@classmethod
668+
def str_validation(cls, value: str, info: ValidationInfo):
669+
"""Validate string fields listed."""
670+
return basic_str_validator(value, info.field_name)
671+
672+
@field_validator("mount_point_ids")
673+
@classmethod
674+
def optional_str_validation(cls, value: Optional[str], info):
675+
"""Allow the mount_point_ids to not be set, i.e., None."""
676+
return optional_str_validator(value, info.field_name)
677+
678+
def _convert_to_grpc(self) -> SherlockLayerService_pb2.GetMountPointsPropertiesRequest:
679+
request = SherlockLayerService_pb2.GetMountPointsPropertiesRequest()
680+
request.project = self.project
681+
request.ccaName = self.cca_name
682+
if self.mount_point_ids is not None:
683+
request.mountPointIDs = self.mount_point_ids
684+
return request
685+
686+
687+
class UpdateMountPointsRequest(BaseModel):
688+
"""Contains the properties of a mount point update per project."""
689+
690+
project: str
691+
"""Name of the Sherlock project."""
692+
cca_name: str
693+
"""Name of the Sherlock CCA."""
694+
mount_points: list[MountPointProperties]
695+
"""List of mount points with their properties to update"""
696+
697+
@field_validator("project", "cca_name")
698+
@classmethod
699+
def str_validation(cls, value: str, info: ValidationInfo):
700+
"""Validate string fields listed."""
701+
return basic_str_validator(value, info.field_name)
702+
703+
@field_validator("mount_points")
704+
@classmethod
705+
def list_validation(cls, value: list, info: ValidationInfo):
706+
"""Validate that mount_points is not empty."""
707+
if not value:
708+
raise ValueError(f"{info.field_name} must contain at least one item.")
709+
return value
710+
711+
def _convert_to_grpc(self) -> SherlockLayerService_pb2.UpdateMountPointsRequest:
712+
request = SherlockLayerService_pb2.UpdateMountPointsRequest()
713+
request.project = self.project
714+
request.ccaName = self.cca_name
715+
if self.mount_points is not None:
716+
for mount_point in self.mount_points:
717+
request.mountPointsProperties.append(mount_point._convert_to_grpc())
718+
else:
719+
raise ValueError("mount_points is invalid because it is None or empty.")
720+
721+
return request

0 commit comments

Comments
 (0)